Skip to content

Commit

Permalink
Fixes #372
Browse files Browse the repository at this point in the history
  • Loading branch information
Thorinwasher committed Jun 10, 2024
1 parent 0ec41cb commit 32700d7
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import org.sgrewritten.stargate.api.formatting.LanguageManager;
import org.sgrewritten.stargate.api.formatting.TranslatableMessage;
import org.sgrewritten.stargate.api.network.portal.Portal;
import org.sgrewritten.stargate.api.network.portal.RealPortal;
import org.sgrewritten.stargate.api.network.portal.flag.StargateFlag;
import org.sgrewritten.stargate.api.network.portal.formatting.SignLineType;
import org.sgrewritten.stargate.api.network.portal.formatting.data.LineData;
Expand All @@ -14,6 +15,7 @@
import org.sgrewritten.stargate.exception.UnimplementedFlagException;
import org.sgrewritten.stargate.exception.name.BungeeNameException;
import org.sgrewritten.stargate.exception.name.InvalidNameException;
import org.sgrewritten.stargate.exception.name.NameConflictException;
import org.sgrewritten.stargate.exception.name.NameLengthException;
import org.sgrewritten.stargate.network.NetworkType;
import org.sgrewritten.stargate.network.StargateNetwork;
Expand Down Expand Up @@ -89,4 +91,14 @@ public void update() {
public @NotNull StargateFlag getAttachedFlag() {
return StargateFlag.LEGACY_INTERSERVER;
}

@Override
public void assignPortal(@NotNull RealPortal portal){
super.assignPortal(portal);
try {
portal.setNetwork(fakeNetwork);
} catch (NameConflictException e) {
Stargate.log(e);
}
}
}
13 changes: 5 additions & 8 deletions src/main/java/org/sgrewritten/stargate/database/SQLDatabase.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,15 @@
import org.sgrewritten.stargate.api.network.NetworkManager;
import org.sgrewritten.stargate.api.network.RegistryAPI;
import org.sgrewritten.stargate.api.network.portal.Portal;
import org.sgrewritten.stargate.api.network.portal.flag.StargateFlag;
import org.sgrewritten.stargate.api.network.portal.PortalPosition;
import org.sgrewritten.stargate.api.network.portal.RealPortal;
import org.sgrewritten.stargate.api.network.portal.flag.PortalFlag;
import org.sgrewritten.stargate.api.network.portal.flag.StargateFlag;
import org.sgrewritten.stargate.config.ConfigurationHelper;
import org.sgrewritten.stargate.config.TableNameConfiguration;
import org.sgrewritten.stargate.database.property.StoredPropertiesAPI;
import org.sgrewritten.stargate.database.property.StoredProperty;
import org.sgrewritten.stargate.exception.InvalidStructureException;
import org.sgrewritten.stargate.exception.PortalLoadException;
import org.sgrewritten.stargate.exception.StargateInitializationException;
import org.sgrewritten.stargate.exception.TranslatableException;
import org.sgrewritten.stargate.exception.UnimplementedFlagException;
import org.sgrewritten.stargate.exception.*;
import org.sgrewritten.stargate.exception.database.StorageReadException;
import org.sgrewritten.stargate.exception.database.StorageWriteException;
import org.sgrewritten.stargate.exception.name.InvalidNameException;
Expand All @@ -30,8 +27,8 @@
import org.sgrewritten.stargate.network.NetworkType;
import org.sgrewritten.stargate.network.StargateNetwork;
import org.sgrewritten.stargate.network.StorageType;
import org.sgrewritten.stargate.network.portal.StargatePortal;
import org.sgrewritten.stargate.network.portal.GlobalPortalId;
import org.sgrewritten.stargate.network.portal.StargatePortal;
import org.sgrewritten.stargate.network.portal.VirtualPortal;
import org.sgrewritten.stargate.network.portal.portaldata.PortalData;
import org.sgrewritten.stargate.thread.task.StargateRegionTask;
Expand Down Expand Up @@ -286,7 +283,7 @@ private void loadPortal(PortalData portalData, StargateAPI stargateAPI) throws S
portalData.flags().add(StargateFlag.NETWORKED);
}

final List<PortalPosition> portalPositions = getPortalPositions(portalData, network.getId());
final List<PortalPosition> portalPositions = getPortalPositions(portalData, portalData.flags().contains(PortalFlag.LEGACY_INTERSERVER) ? portalData.networkName() : network.getId());

//Actually register the gate and its positions
new StargateRegionTask(portalData.gateData().topLeft()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
import org.bukkit.plugin.java.JavaPlugin;
import org.sgrewritten.stargate.Stargate;
import org.sgrewritten.stargate.api.network.Network;
import org.sgrewritten.stargate.api.network.portal.flag.PortalFlag;
import org.sgrewritten.stargate.api.network.portal.flag.StargateFlag;
import org.sgrewritten.stargate.api.network.portal.RealPortal;
import org.sgrewritten.stargate.api.network.portal.flag.PortalFlag;
import org.sgrewritten.stargate.property.PluginChannel;
import org.sgrewritten.stargate.util.BungeeHelper;

Expand Down Expand Up @@ -51,7 +50,7 @@ public void teleportHere(Entity target, RealPortal origin) {
msgData.writeUTF(PluginChannel.LEGACY_BUNGEE.getChannel());
String msg = BungeeHelper.generateLegacyTeleportMessage(player.getName(), this);
msgData.writeUTF(msg);
Stargate.log(Level.FINEST, bao.toString());
Stargate.log(Level.FINEST, "Sending plugin message: " + bao);
player.sendPluginMessage(plugin, PluginChannel.BUNGEE.getChannel(), bao.toByteArray());
} catch (IOException e) {
Stargate.log(Level.WARNING, "[Stargate] Error sending BungeeCord teleport packet");
Expand All @@ -64,6 +63,7 @@ public void teleportHere(Entity target, RealPortal origin) {
DataOutputStream msgData = new DataOutputStream(bao);
msgData.writeUTF(PluginChannel.PLAYER_CONNECT.getChannel());
msgData.writeUTF(server);
Stargate.log(Level.FINEST, "Sending plugin message: " + bao);
player.sendPluginMessage(plugin, PluginChannel.BUNGEE.getChannel(), bao.toByteArray());
} catch (IOException e) {
Stargate.log(Level.WARNING, "[Stargate] Error sending BungeeCord connect packet");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@

import java.util.*;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
* An abstract implementation of a real portal
Expand Down Expand Up @@ -202,7 +201,7 @@ public void close(boolean forceClose) {
if (!isOpen() || (hasFlag(StargateFlag.ALWAYS_ON) && !forceClose)) {
return;
}
if(this.isDestroyed){
if (this.isDestroyed) {
getGate().close();
return;
}
Expand Down Expand Up @@ -238,7 +237,8 @@ public Network getNetwork() {

@Override
public void setNetwork(Network targetNetwork) throws NameConflictException {
if (targetNetwork.getPortal(this.name) != null) {
Portal conflictingPortal = targetNetwork.getPortal(this.name);
if (conflictingPortal != null && conflictingPortal != this) {
throw new NameConflictException(String.format("Portal of name %s already exists in network %s", this.name, targetNetwork.getId()), false);
}
this.network = targetNetwork;
Expand Down Expand Up @@ -305,7 +305,7 @@ public void doTeleport(@NotNull Entity target, @Nullable Portal destination) {

@Override
public void doTeleport(@NotNull Entity target) {
if(overriddenDestination != null){
if (overriddenDestination != null) {
this.doTeleport(target, overriddenDestination);
return;
}
Expand Down Expand Up @@ -566,7 +566,7 @@ public PortalBehavior getBehavior() {

@Override
public void setBehavior(PortalBehavior portalBehavior) {
if(isDestroyed){
if (isDestroyed) {
return;
}
clearBehaviorFlags();
Expand All @@ -581,7 +581,7 @@ public void setBehavior(PortalBehavior portalBehavior) {

@Override
public void redrawSigns() {
if(isDestroyed || !savedToStorage){
if (isDestroyed || !savedToStorage) {
return;
}
LineData[] lineData = behavior.getLines();
Expand Down

0 comments on commit 32700d7

Please sign in to comment.