Makes portal names and networks case and color-insensitive and increases length limit to 13. #17
Ignores &[0-9a-f] color codes when counting towards the name and network string limits Makes portal lists store cleaned portal and network names to ignore case and color Names and networks will now match regardless of case and color Increases portal name/network limit to 13 characters
This commit is contained in:
@ -4,6 +4,7 @@ import net.knarcraft.stargate.Stargate;
|
||||
import net.knarcraft.stargate.portal.Portal;
|
||||
import net.knarcraft.stargate.portal.PortalHandler;
|
||||
import net.knarcraft.stargate.portal.teleporter.PlayerTeleporter;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
|
||||
@ -71,7 +72,7 @@ public final class BungeeHelper {
|
||||
//Build the message data and send it over the SGBungee BungeeCord channel
|
||||
dataOutputStream.writeUTF("Forward");
|
||||
//Send the message to the server defined in the entrance portal's network line
|
||||
dataOutputStream.writeUTF(entrancePortal.getNetwork());
|
||||
dataOutputStream.writeUTF(stripColor(entrancePortal.getNetwork()));
|
||||
//Specify the sub-channel/tag to make it recognizable on arrival
|
||||
dataOutputStream.writeUTF(bungeeSubChannel);
|
||||
//Write the length of the message
|
||||
@ -102,7 +103,7 @@ public final class BungeeHelper {
|
||||
|
||||
//Send a connect-message to connect the player to the server defined in the entrance portal's network line
|
||||
dataOutputStream.writeUTF("Connect");
|
||||
dataOutputStream.writeUTF(entrancePortal.getNetwork());
|
||||
dataOutputStream.writeUTF(stripColor(entrancePortal.getNetwork()));
|
||||
|
||||
//Send the plugin message
|
||||
player.sendPluginMessage(Stargate.getInstance(), bungeeChannel, byteArrayOutputStream.toByteArray());
|
||||
@ -207,4 +208,14 @@ public final class BungeeHelper {
|
||||
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>
|
||||
*/
|
||||
private static String stripColor(String string) {
|
||||
return ChatColor.stripColor(ChatColor.translateAlternateColorCodes('&', string));
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user