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));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -105,12 +105,12 @@ public final class PermissionHelper {
|
||||
boolean deny = false;
|
||||
|
||||
if (entrancePortal.getOptions().isBungee()) {
|
||||
if (!PermissionHelper.canAccessServer(player, entrancePortal.getNetwork())) {
|
||||
if (!PermissionHelper.canAccessServer(player, entrancePortal.getCleanNetwork())) {
|
||||
//If the portal is a bungee portal, and the player cannot access the server, deny
|
||||
Stargate.debug("cannotAccessPortal", "Cannot access server");
|
||||
deny = true;
|
||||
}
|
||||
} else if (PermissionHelper.cannotAccessNetwork(player, entrancePortal.getNetwork())) {
|
||||
} else if (PermissionHelper.cannotAccessNetwork(player, entrancePortal.getCleanNetwork())) {
|
||||
//If the player does not have access to the network, deny
|
||||
Stargate.debug("cannotAccessPortal", "Cannot access network");
|
||||
deny = true;
|
||||
@ -345,7 +345,7 @@ public final class PermissionHelper {
|
||||
* @return <p>True if the player is allowed to destroy the portal</p>
|
||||
*/
|
||||
public static boolean canDestroyPortal(Player player, Portal portal) {
|
||||
String network = portal.getNetwork();
|
||||
String network = portal.getCleanNetwork();
|
||||
|
||||
//Use a special check for bungee portals
|
||||
if (portal.getOptions().isBungee()) {
|
||||
|
@ -22,7 +22,7 @@ import java.util.UUID;
|
||||
public final class UUIDMigrationHelper {
|
||||
|
||||
private UUIDMigrationHelper() {
|
||||
|
||||
|
||||
}
|
||||
|
||||
private static Map<String, List<Portal>> playerNamesToMigrate;
|
||||
@ -68,7 +68,7 @@ public final class UUIDMigrationHelper {
|
||||
|
||||
//Get the real portal from the copy and set UUID
|
||||
for (Portal portalCopy : portals) {
|
||||
Portal portal = PortalHandler.getByName(portalCopy.getName(), portalCopy.getNetwork());
|
||||
Portal portal = PortalHandler.getByName(portalCopy.getCleanName(), portalCopy.getCleanNetwork());
|
||||
if (portal != null) {
|
||||
portal.getOwner().setUUID(uniqueId);
|
||||
worldsToSave.add(portal.getWorld());
|
||||
|
Reference in New Issue
Block a user