Removes unnecessary hashmap copying
This commit is contained in:
		@@ -82,6 +82,7 @@ public class PlayerEventListener implements Listener {
 | 
				
			|||||||
        //Check if the player is waiting to be teleported to a stargate
 | 
					        //Check if the player is waiting to be teleported to a stargate
 | 
				
			||||||
        String destination = BungeeHelper.removeFromQueue(player.getUniqueId());
 | 
					        String destination = BungeeHelper.removeFromQueue(player.getUniqueId());
 | 
				
			||||||
        if (destination == null) {
 | 
					        if (destination == null) {
 | 
				
			||||||
 | 
					            Stargate.debug("PlayerJoin", "No bungee request found in queue");
 | 
				
			||||||
            return;
 | 
					            return;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -79,10 +79,10 @@ public class PortalActivator {
 | 
				
			|||||||
            }
 | 
					            }
 | 
				
			||||||
            //Get one random destination
 | 
					            //Get one random destination
 | 
				
			||||||
            String randomDestination = ListHelper.getRandom(destinations);
 | 
					            String randomDestination = ListHelper.getRandom(destinations);
 | 
				
			||||||
            return PortalHandler.getByName(Portal.cleanString(randomDestination), portalNetwork);
 | 
					            return PortalHandler.getByName(randomDestination, portalNetwork);
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
            //Just return the normal fixed destination
 | 
					            //Just return the normal fixed destination
 | 
				
			||||||
            return PortalHandler.getByName(Portal.cleanString(destination), portalNetwork);
 | 
					            return PortalHandler.getByName(destination, portalNetwork);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -249,8 +249,10 @@ public class PortalActivator {
 | 
				
			|||||||
            }
 | 
					            }
 | 
				
			||||||
            activate = true;
 | 
					            activate = true;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            Stargate.debug("cycleDestination", "Network Size: " +
 | 
					            List<String> portalsInNetwork = PortalHandler.getNetwork(portal.getCleanNetwork());
 | 
				
			||||||
                    PortalHandler.getNetwork(portal.getCleanNetwork()).size());
 | 
					            if (portalsInNetwork != null) {
 | 
				
			||||||
 | 
					                Stargate.debug("cycleDestination", "Network Size: " + portalsInNetwork.size());
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
            Stargate.debug("cycleDestination", "Player has access to: " + destinations.size());
 | 
					            Stargate.debug("cycleDestination", "Player has access to: " + destinations.size());
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -303,7 +303,7 @@ public class PortalCreator {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        if (portal.getOptions().isBungee()) {
 | 
					        if (portal.getOptions().isBungee()) {
 | 
				
			||||||
            //Check if the bungee portal's name has been duplicated
 | 
					            //Check if the bungee portal's name has been duplicated
 | 
				
			||||||
            if (PortalHandler.getBungeePortals().get(portal.getCleanName()) != null) {
 | 
					            if (PortalRegistry.getBungeePortal(portal.getCleanName()) != null) {
 | 
				
			||||||
                Stargate.debug(route, "Gate name duplicate");
 | 
					                Stargate.debug(route, "Gate name duplicate");
 | 
				
			||||||
                Stargate.getMessageSender().sendErrorMessage(player, Stargate.getString(Message.CREATION_NAME_COLLISION));
 | 
					                Stargate.getMessageSender().sendErrorMessage(player, Stargate.getString(Message.CREATION_NAME_COLLISION));
 | 
				
			||||||
                return false;
 | 
					                return false;
 | 
				
			||||||
@@ -317,7 +317,7 @@ public class PortalCreator {
 | 
				
			|||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            //Check if the number of portals in the network has been surpassed
 | 
					            //Check if the number of portals in the network has been surpassed
 | 
				
			||||||
            List<String> networkList = PortalHandler.getAllPortalNetworks().get(portal.getCleanNetwork());
 | 
					            List<String> networkList = PortalHandler.getNetwork(portal.getCleanNetwork());
 | 
				
			||||||
            int maxGates = Stargate.getGateConfig().maxGatesEachNetwork();
 | 
					            int maxGates = Stargate.getGateConfig().maxGatesEachNetwork();
 | 
				
			||||||
            if (maxGates > 0 && networkList != null && networkList.size() >= maxGates) {
 | 
					            if (maxGates > 0 && networkList != null && networkList.size() >= maxGates) {
 | 
				
			||||||
                Stargate.getMessageSender().sendErrorMessage(player, Stargate.getString(Message.CREATION_NETWORK_FULL));
 | 
					                Stargate.getMessageSender().sendErrorMessage(player, Stargate.getString(Message.CREATION_NETWORK_FULL));
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -42,24 +42,14 @@ public class PortalHandler {
 | 
				
			|||||||
        return PortalRegistry.getAllPortalNetworks();
 | 
					        return PortalRegistry.getAllPortalNetworks();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					 | 
				
			||||||
     * Gets a copy of all bungee portals
 | 
					 | 
				
			||||||
     *
 | 
					 | 
				
			||||||
     * @return <p>A copy of all bungee portals</p>
 | 
					 | 
				
			||||||
     */
 | 
					 | 
				
			||||||
    @NotNull
 | 
					 | 
				
			||||||
    public static Map<String, Portal> getBungeePortals() {
 | 
					 | 
				
			||||||
        return PortalRegistry.getBungeePortals();
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Gets names of all portals within a network
 | 
					     * Gets names of all portals within a network
 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
     * @param network <p>The network to get portals from</p>
 | 
					     * @param network <p>The network to get portals from</p>
 | 
				
			||||||
     * @return <p>A list of portal names</p>
 | 
					     * @return <p>A list of portal names</p>
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    @NotNull
 | 
					    @Nullable
 | 
				
			||||||
    public static List<String> getNetwork(String network) {
 | 
					    public static List<String> getNetwork(@NotNull String network) {
 | 
				
			||||||
        return PortalRegistry.getNetwork(network);
 | 
					        return PortalRegistry.getNetwork(network);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -75,7 +65,11 @@ public class PortalHandler {
 | 
				
			|||||||
    public static List<String> getDestinations(@NotNull Portal entrancePortal, @Nullable Player player,
 | 
					    public static List<String> getDestinations(@NotNull Portal entrancePortal, @Nullable Player player,
 | 
				
			||||||
                                               @NotNull String network) {
 | 
					                                               @NotNull String network) {
 | 
				
			||||||
        List<String> destinations = new ArrayList<>();
 | 
					        List<String> destinations = new ArrayList<>();
 | 
				
			||||||
        for (String destination : PortalRegistry.getAllPortalNetworks().get(network)) {
 | 
					        List<String> portalsInNetwork = PortalRegistry.getNetwork(network);
 | 
				
			||||||
 | 
					        if (portalsInNetwork == null) {
 | 
				
			||||||
 | 
					            return List.of();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        for (String destination : portalsInNetwork) {
 | 
				
			||||||
            Portal portal = getByName(destination, network);
 | 
					            Portal portal = getByName(destination, network);
 | 
				
			||||||
            if (portal == null) {
 | 
					            if (portal == null) {
 | 
				
			||||||
                continue;
 | 
					                continue;
 | 
				
			||||||
@@ -148,17 +142,18 @@ public class PortalHandler {
 | 
				
			|||||||
     */
 | 
					     */
 | 
				
			||||||
    public static boolean isValidBungeePortal(@NotNull Map<PortalOption, Boolean> portalOptions, @NotNull Player player,
 | 
					    public static boolean isValidBungeePortal(@NotNull Map<PortalOption, Boolean> portalOptions, @NotNull Player player,
 | 
				
			||||||
                                              @NotNull String destinationName, String network) {
 | 
					                                              @NotNull String destinationName, String network) {
 | 
				
			||||||
        if (portalOptions.get(PortalOption.BUNGEE)) {
 | 
					        if (!portalOptions.get(PortalOption.BUNGEE)) {
 | 
				
			||||||
            if (!PermissionHelper.hasPermission(player, "stargate.admin.bungee")) {
 | 
					            return true;
 | 
				
			||||||
                Stargate.getMessageSender().sendErrorMessage(player, Stargate.getString(Message.BUNGEE_CREATION_DENIED));
 | 
					        }
 | 
				
			||||||
                return false;
 | 
					        if (!PermissionHelper.hasPermission(player, "stargate.admin.bungee")) {
 | 
				
			||||||
            } else if (!Stargate.getGateConfig().enableBungee()) {
 | 
					            Stargate.getMessageSender().sendErrorMessage(player, Stargate.getString(Message.BUNGEE_CREATION_DENIED));
 | 
				
			||||||
                Stargate.getMessageSender().sendErrorMessage(player, Stargate.getString(Message.BUNGEE_DISABLED));
 | 
					            return false;
 | 
				
			||||||
                return false;
 | 
					        } else if (!Stargate.getGateConfig().enableBungee()) {
 | 
				
			||||||
            } else if (destinationName.isEmpty() || network.isEmpty()) {
 | 
					            Stargate.getMessageSender().sendErrorMessage(player, Stargate.getString(Message.BUNGEE_DISABLED));
 | 
				
			||||||
                Stargate.getMessageSender().sendErrorMessage(player, Stargate.getString(Message.BUNGEE_MISSING_INFO));
 | 
					            return false;
 | 
				
			||||||
                return false;
 | 
					        } else if (destinationName.isEmpty() || network.isEmpty()) {
 | 
				
			||||||
            }
 | 
					            Stargate.getMessageSender().sendErrorMessage(player, Stargate.getString(Message.BUNGEE_MISSING_INFO));
 | 
				
			||||||
 | 
					            return false;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        return true;
 | 
					        return true;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@@ -215,7 +210,11 @@ public class PortalHandler {
 | 
				
			|||||||
     * @param portal <p>The newly created portal</p>
 | 
					     * @param portal <p>The newly created portal</p>
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public static void updatePortalsPointingAtNewPortal(@NotNull Portal portal) {
 | 
					    public static void updatePortalsPointingAtNewPortal(@NotNull Portal portal) {
 | 
				
			||||||
        for (String originName : PortalRegistry.getAllPortalNetworks().get(portal.getCleanNetwork())) {
 | 
					        List<String> portalsInNetwork = PortalRegistry.getNetwork(portal.getCleanNetwork());
 | 
				
			||||||
 | 
					        if (portalsInNetwork == null) {
 | 
				
			||||||
 | 
					            return;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        for (String originName : portalsInNetwork) {
 | 
				
			||||||
            Portal origin = getByName(originName, portal.getCleanNetwork());
 | 
					            Portal origin = getByName(originName, portal.getCleanNetwork());
 | 
				
			||||||
            if (origin == null ||
 | 
					            if (origin == null ||
 | 
				
			||||||
                    !Portal.cleanString(origin.getDestinationName()).equals(portal.getCleanName()) ||
 | 
					                    !Portal.cleanString(origin.getDestinationName()).equals(portal.getCleanName()) ||
 | 
				
			||||||
@@ -283,12 +282,7 @@ public class PortalHandler {
 | 
				
			|||||||
     */
 | 
					     */
 | 
				
			||||||
    @Nullable
 | 
					    @Nullable
 | 
				
			||||||
    public static Portal getByName(@NotNull String name, @NotNull String network) {
 | 
					    public static Portal getByName(@NotNull String name, @NotNull String network) {
 | 
				
			||||||
        Map<String, Map<String, Portal>> lookupMap = PortalRegistry.getPortalLookupByNetwork();
 | 
					        return PortalRegistry.getPortalInNetwork(Portal.cleanString(network), Portal.cleanString(name));
 | 
				
			||||||
        if (!lookupMap.containsKey(network.toLowerCase())) {
 | 
					 | 
				
			||||||
            return null;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        return lookupMap.get(network.toLowerCase()).get(name.toLowerCase());
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
@@ -371,7 +365,7 @@ public class PortalHandler {
 | 
				
			|||||||
     */
 | 
					     */
 | 
				
			||||||
    @Nullable
 | 
					    @Nullable
 | 
				
			||||||
    public static Portal getByControl(@NotNull Block block) {
 | 
					    public static Portal getByControl(@NotNull Block block) {
 | 
				
			||||||
        return PortalRegistry.getLookupControls().get(new BlockLocation(block));
 | 
					        return PortalRegistry.getPortalFromControl(new BlockLocation(block));
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
@@ -382,7 +376,7 @@ public class PortalHandler {
 | 
				
			|||||||
     */
 | 
					     */
 | 
				
			||||||
    @Nullable
 | 
					    @Nullable
 | 
				
			||||||
    public static Portal getByBlock(@NotNull Block block) {
 | 
					    public static Portal getByBlock(@NotNull Block block) {
 | 
				
			||||||
        return PortalRegistry.getLookupBlocks().get(new BlockLocation(block));
 | 
					        return PortalRegistry.getPortalFromFrame(new BlockLocation(block));
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
@@ -393,7 +387,7 @@ public class PortalHandler {
 | 
				
			|||||||
     */
 | 
					     */
 | 
				
			||||||
    @Nullable
 | 
					    @Nullable
 | 
				
			||||||
    public static Portal getBungeePortal(@NotNull String name) {
 | 
					    public static Portal getBungeePortal(@NotNull String name) {
 | 
				
			||||||
        return PortalRegistry.getBungeePortals().get(name.toLowerCase());
 | 
					        return PortalRegistry.getBungeePortal(name);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -95,38 +95,47 @@ public class PortalRegistry {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Gets a copy of the lookup map for finding a portal by its frame
 | 
					     * Gets a portal that the given frame block belongs to
 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
     * @return <p>A copy of the frame block lookup map</p>
 | 
					     * @param blockLocation <p>The location that might be a frame block</p>
 | 
				
			||||||
 | 
					     * @return <p>The portal the frame block belongs to, or null</p>
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    @NotNull
 | 
					    @Nullable
 | 
				
			||||||
    public static Map<BlockLocation, Portal> getLookupBlocks() {
 | 
					    public static Portal getPortalFromFrame(@NotNull BlockLocation blockLocation) {
 | 
				
			||||||
        return new HashMap<>(lookupBlocks);
 | 
					        return lookupBlocks.get(blockLocation);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Gets a copy of the lookup map for finding a portal by its control block
 | 
					     * Gets the portal that the given control block belongs to
 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
     * @return <p>A copy of the control block lookup map</p>
 | 
					     * @param blockLocation <p>The location that might be a portal control block</p>
 | 
				
			||||||
 | 
					     * @return <p>The portal the control block belongs to, or null</p>
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    @NotNull
 | 
					    @Nullable
 | 
				
			||||||
    public static Map<BlockLocation, Portal> getLookupControls() {
 | 
					    public static Portal getPortalFromControl(@NotNull BlockLocation blockLocation) {
 | 
				
			||||||
        return new HashMap<>(lookupControls);
 | 
					        return lookupControls.get(blockLocation);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Gets a copy of the lookup map for finding all portals in a network
 | 
					     * Gets the portal identified by the given network name and portal name
 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
     * @return <p>A copy of the network portal lookup map</p>
 | 
					     * @param networkName <p>The name of the network the portal belongs to</p>
 | 
				
			||||||
 | 
					     * @param portalName  <p>The name of the portal</p>
 | 
				
			||||||
 | 
					     * @return <p>The portal, or null if no such network and/or portal exists</p>
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    @NotNull
 | 
					    @Nullable
 | 
				
			||||||
    public static Map<String, Map<String, Portal>> getPortalLookupByNetwork() {
 | 
					    public static Portal getPortalInNetwork(@NotNull String networkName, @NotNull String portalName) {
 | 
				
			||||||
        return new HashMap<>(portalLookupByNetwork);
 | 
					        Map<String, Portal> portalsInNetwork = portalLookupByNetwork.get(Portal.cleanString(networkName));
 | 
				
			||||||
 | 
					        if (portalsInNetwork == null) {
 | 
				
			||||||
 | 
					            return null;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        return portalsInNetwork.get(Portal.cleanString(portalName));
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Gets a portal from the location of a possible entrance
 | 
					     * Gets a portal from the location of a possible entrance
 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
 | 
					     * @param blockLocation <p>A location that might be a portal's entrance</p>
 | 
				
			||||||
     * @return <p>A portal, or null</p>
 | 
					     * @return <p>A portal, or null</p>
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    @Nullable
 | 
					    @Nullable
 | 
				
			||||||
@@ -145,13 +154,14 @@ public class PortalRegistry {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Gets a copy of all bungee portals
 | 
					     * Gets the BungeeCord portal with the given name
 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
     * @return <p>A copy of all bungee portals</p>
 | 
					     * @param portalName <p>The name of the portal to get</p>
 | 
				
			||||||
 | 
					     * @return <p>The portal, or null</p>
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    @NotNull
 | 
					    @Nullable
 | 
				
			||||||
    public static Map<String, Portal> getBungeePortals() {
 | 
					    public static Portal getBungeePortal(@NotNull String portalName) {
 | 
				
			||||||
        return new HashMap<>(bungeePortals);
 | 
					        return bungeePortals.get(Portal.cleanString(portalName));
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
@@ -160,7 +170,7 @@ public class PortalRegistry {
 | 
				
			|||||||
     * @param network <p>The network to get portals from</p>
 | 
					     * @param network <p>The network to get portals from</p>
 | 
				
			||||||
     * @return <p>A list of portal names</p>
 | 
					     * @return <p>A list of portal names</p>
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    @NotNull
 | 
					    @Nullable
 | 
				
			||||||
    public static List<String> getNetwork(@NotNull String network) {
 | 
					    public static List<String> getNetwork(@NotNull String network) {
 | 
				
			||||||
        return allPortalNetworks.get(network.toLowerCase());
 | 
					        return allPortalNetworks.get(network.toLowerCase());
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -358,8 +358,7 @@ public class PortalSignDrawer {
 | 
				
			|||||||
    private void drawFixedSign(@NotNull SignData signData, @NotNull String[] output) {
 | 
					    private void drawFixedSign(@NotNull SignData signData, @NotNull String[] output) {
 | 
				
			||||||
        ChatColor highlightColor = signData.getHighlightSignColor();
 | 
					        ChatColor highlightColor = signData.getHighlightSignColor();
 | 
				
			||||||
        ChatColor mainColor = signData.getMainSignColor();
 | 
					        ChatColor mainColor = signData.getMainSignColor();
 | 
				
			||||||
        Portal destinationPortal = PortalHandler.getByName(Portal.cleanString(portal.getDestinationName()),
 | 
					        Portal destinationPortal = PortalHandler.getByName(portal.getDestinationName(), portal.getCleanNetwork());
 | 
				
			||||||
                portal.getCleanNetwork());
 | 
					 | 
				
			||||||
        String destinationName = portal.getOptions().isRandom() ? Stargate.getString(Message.SIGN_RANDOM) :
 | 
					        String destinationName = portal.getOptions().isRandom() ? Stargate.getString(Message.SIGN_RANDOM) :
 | 
				
			||||||
                (destinationPortal != null ? destinationPortal.getName() : portal.getDestinationName());
 | 
					                (destinationPortal != null ? destinationPortal.getName() : portal.getDestinationName());
 | 
				
			||||||
        setLine(signData, 1, highlightColor + ">" + mainColor + translateAllColorCodes(destinationName) +
 | 
					        setLine(signData, 1, highlightColor + ">" + mainColor + translateAllColorCodes(destinationName) +
 | 
				
			||||||
@@ -371,8 +370,7 @@ public class PortalSignDrawer {
 | 
				
			|||||||
            setLine(signData, 2, highlightColor + "(" + mainColor +
 | 
					            setLine(signData, 2, highlightColor + "(" + mainColor +
 | 
				
			||||||
                    translateAllColorCodes(portal.getNetwork()) + highlightColor + ")", output);
 | 
					                    translateAllColorCodes(portal.getNetwork()) + highlightColor + ")", output);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        Portal destination = PortalHandler.getByName(Portal.cleanString(portal.getDestinationName()),
 | 
					        Portal destination = PortalHandler.getByName(portal.getDestinationName(), portal.getNetwork());
 | 
				
			||||||
                portal.getNetwork());
 | 
					 | 
				
			||||||
        if (destination == null && !portal.getOptions().isRandom()) {
 | 
					        if (destination == null && !portal.getOptions().isRandom()) {
 | 
				
			||||||
            setLine(signData, 3, errorColor + Stargate.getString(Message.SIGN_DISCONNECTED), output);
 | 
					            setLine(signData, 3, errorColor + Stargate.getString(Message.SIGN_DISCONNECTED), output);
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -5,7 +5,6 @@ import net.knarcraft.stargate.config.Message;
 | 
				
			|||||||
import net.knarcraft.stargate.portal.Portal;
 | 
					import net.knarcraft.stargate.portal.Portal;
 | 
				
			||||||
import net.knarcraft.stargate.portal.PortalHandler;
 | 
					import net.knarcraft.stargate.portal.PortalHandler;
 | 
				
			||||||
import net.knarcraft.stargate.portal.teleporter.PlayerTeleporter;
 | 
					import net.knarcraft.stargate.portal.teleporter.PlayerTeleporter;
 | 
				
			||||||
import net.md_5.bungee.api.ChatColor;
 | 
					 | 
				
			||||||
import org.bukkit.entity.Player;
 | 
					import org.bukkit.entity.Player;
 | 
				
			||||||
import org.bukkit.event.player.PlayerMoveEvent;
 | 
					import org.bukkit.event.player.PlayerMoveEvent;
 | 
				
			||||||
import org.jetbrains.annotations.NotNull;
 | 
					import org.jetbrains.annotations.NotNull;
 | 
				
			||||||
@@ -77,7 +76,7 @@ public final class BungeeHelper {
 | 
				
			|||||||
            //Build the message data and send it over the SGBungee BungeeCord channel
 | 
					            //Build the message data and send it over the SGBungee BungeeCord channel
 | 
				
			||||||
            dataOutputStream.writeUTF("Forward");
 | 
					            dataOutputStream.writeUTF("Forward");
 | 
				
			||||||
            //Send the message to the server defined in the entrance portal's network line
 | 
					            //Send the message to the server defined in the entrance portal's network line
 | 
				
			||||||
            dataOutputStream.writeUTF(stripColor(entrancePortal.getNetwork()));
 | 
					            dataOutputStream.writeUTF(Portal.cleanString(entrancePortal.getNetwork()));
 | 
				
			||||||
            //Specify the sub-channel/tag to make it recognizable on arrival
 | 
					            //Specify the sub-channel/tag to make it recognizable on arrival
 | 
				
			||||||
            dataOutputStream.writeUTF(bungeeSubChannel);
 | 
					            dataOutputStream.writeUTF(bungeeSubChannel);
 | 
				
			||||||
            //Write the length of the message
 | 
					            //Write the length of the message
 | 
				
			||||||
@@ -107,7 +106,7 @@ public final class BungeeHelper {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
            //Send a connect-message to connect the player to the server defined in the entrance portal's network line
 | 
					            //Send a connect-message to connect the player to the server defined in the entrance portal's network line
 | 
				
			||||||
            dataOutputStream.writeUTF("Connect");
 | 
					            dataOutputStream.writeUTF("Connect");
 | 
				
			||||||
            dataOutputStream.writeUTF(stripColor(entrancePortal.getNetwork()));
 | 
					            dataOutputStream.writeUTF(Portal.cleanString(entrancePortal.getNetwork()));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            //Send the plugin message
 | 
					            //Send the plugin message
 | 
				
			||||||
            player.sendPluginMessage(Stargate.getInstance(), bungeeChannel, byteArrayOutputStream.toByteArray());
 | 
					            player.sendPluginMessage(Stargate.getInstance(), bungeeChannel, byteArrayOutputStream.toByteArray());
 | 
				
			||||||
@@ -212,15 +211,4 @@ public final class BungeeHelper {
 | 
				
			|||||||
        return true;
 | 
					        return true;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					 | 
				
			||||||
     * Strips all color tags from a string
 | 
					 | 
				
			||||||
     *
 | 
					 | 
				
			||||||
     * @param string <p>The string to strip color from</p>
 | 
					 | 
				
			||||||
     * @return <p>The string without color codes</p>
 | 
					 | 
				
			||||||
     */
 | 
					 | 
				
			||||||
    @NotNull
 | 
					 | 
				
			||||||
    private static String stripColor(@NotNull String string) {
 | 
					 | 
				
			||||||
        return ChatColor.stripColor(ChatColor.translateAlternateColorCodes('&', string));
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user