From 2500ecef0c1e2cb16e40c9f4b36fbb0378689a4f Mon Sep 17 00:00:00 2001 From: Alastair Date: Tue, 29 Mar 2016 14:35:41 +0100 Subject: [PATCH] Added the prefix change options --- Resources/config.yml | 2 ++ .../advancedportals/AdvancedPortalsPlugin.java | 5 ++++- .../sekwah/advancedportals/DestinationCommand.java | 2 +- src/com/sekwah/advancedportals/WarpCommand.java | 6 +++--- .../advancedportals/destinations/Destination.java | 4 ++-- .../sekwah/advancedportals/listeners/Listeners.java | 6 +++--- src/com/sekwah/advancedportals/portals/Portal.java | 12 ++++++------ 7 files changed, 21 insertions(+), 16 deletions(-) diff --git a/Resources/config.yml b/Resources/config.yml index 7e2a8416..bac75c91 100644 --- a/Resources/config.yml +++ b/Resources/config.yml @@ -67,3 +67,5 @@ UseWarpPrefix: true UseCustomPrefix: false CustomPrefix: '&a[&eAdvancedPortals&a]' + +CustomPrefixFail: '&c[&7AdvancedPortals&c]' diff --git a/src/com/sekwah/advancedportals/AdvancedPortalsPlugin.java b/src/com/sekwah/advancedportals/AdvancedPortalsPlugin.java index 17400cec..717fdfe5 100644 --- a/src/com/sekwah/advancedportals/AdvancedPortalsPlugin.java +++ b/src/com/sekwah/advancedportals/AdvancedPortalsPlugin.java @@ -20,6 +20,8 @@ public class AdvancedPortalsPlugin extends JavaPlugin { public String customPrefix = "\u00A7a[\u00A7eAdvancedPortals\u00A7a]"; + public String customPrefixFail = "\u00A7c[\u00A77AdvancedPortals\u00A7c]"; + public void onEnable() { try { @@ -59,7 +61,8 @@ public class AdvancedPortalsPlugin extends JavaPlugin { this.useCustomPrefix = config.getConfig().getBoolean("UseCustomPrefix"); if (useCustomPrefix) { - this.customPrefix = config.getConfig().getString("CustomPrefix"); + this.customPrefix = config.getConfig().getString("CustomPrefix").replaceAll("&", "\u00A7"); + this.customPrefixFail = config.getConfig().getString("CustomPrefixFail").replaceAll("&", "\u00A7"); } ConfigAccessor portalConfig = new ConfigAccessor(this, "portals.yml"); diff --git a/src/com/sekwah/advancedportals/DestinationCommand.java b/src/com/sekwah/advancedportals/DestinationCommand.java index c464d332..22e72530 100644 --- a/src/com/sekwah/advancedportals/DestinationCommand.java +++ b/src/com/sekwah/advancedportals/DestinationCommand.java @@ -73,7 +73,7 @@ public class DestinationCommand implements CommandExecutor, TabCompleter { Destination.warp(sender, args[1]); if (PortalMessagesDisplay == 1) { sender.sendMessage(""); - sender.sendMessage("\u00A7a[\u00A7eAdvancedPortals\u00A7a] You have been warped to \u00A7e" + args[1].replaceAll("_", " ") + "\u00A7a."); + sender.sendMessage(plugin.customPrefixFail + "\u00A7a You have been warped to \u00A7e" + args[1].replaceAll("_", " ") + "\u00A7a."); sender.sendMessage(""); } else if (PortalMessagesDisplay == 2) { ConfigAccessor config = new ConfigAccessor(plugin, "destinations.yml"); diff --git a/src/com/sekwah/advancedportals/WarpCommand.java b/src/com/sekwah/advancedportals/WarpCommand.java index 1c6426e7..6823a76f 100644 --- a/src/com/sekwah/advancedportals/WarpCommand.java +++ b/src/com/sekwah/advancedportals/WarpCommand.java @@ -32,7 +32,7 @@ public class WarpCommand implements CommandExecutor, TabCompleter { if (Destination.warp(sender, args[0], false)) { if (DestinationCommand.PortalMessagesDisplay == 1) { sender.sendMessage(""); - sender.sendMessage("\u00A7a[\u00A7eAdvancedPortals\u00A7a] You have been warped to \u00A7e" + args[0].replaceAll("_", " ") + "\u00A7a."); + sender.sendMessage(plugin.customPrefixFail + "\u00A7a You have been warped to \u00A7e" + args[0].replaceAll("_", " ") + "\u00A7a."); sender.sendMessage(""); } else if (DestinationCommand.PortalMessagesDisplay == 2) { ConfigAccessor config = new ConfigAccessor(plugin, "destinations.yml"); @@ -42,12 +42,12 @@ public class WarpCommand implements CommandExecutor, TabCompleter { } } else { sender.sendMessage(""); - sender.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] The destination you tried to warp to does not exist!"); + sender.sendMessage(plugin.customPrefixFail + "\u00A7c The destination you tried to warp to does not exist!"); sender.sendMessage(""); } } else { sender.sendMessage(""); - sender.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] You need to type a destination after /" + command + "!"); + sender.sendMessage(plugin.customPrefixFail + "\u00A7c You need to type a destination after /" + command + "!"); sender.sendMessage(""); } return true; diff --git a/src/com/sekwah/advancedportals/destinations/Destination.java b/src/com/sekwah/advancedportals/destinations/Destination.java index d1014a16..01b03180 100644 --- a/src/com/sekwah/advancedportals/destinations/Destination.java +++ b/src/com/sekwah/advancedportals/destinations/Destination.java @@ -127,7 +127,7 @@ public class Destination { return true; } else { if (senderror) { - player.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] The destination you are trying to warp to seems to be linked to a world that doesn't exist!"); + player.sendMessage(plugin.customPrefixFail + "\u00A7c The destination you are trying to warp to seems to be linked to a world that doesn't exist!"); plugin.getLogger().log(Level.SEVERE, "The destination '" + name + "' is linked to the world " + config.getConfig().getString(name + ".world") + " which doesnt seem to exist any more!"); } @@ -135,7 +135,7 @@ public class Destination { } } else { if (senderror) { - player.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] There has been a problem warping you to the selected destination!"); + player.sendMessage(plugin.customPrefixFail + "\u00A7c There has been a problem warping you to the selected destination!"); plugin.getLogger().log(Level.SEVERE, "The destination '" + name + "' has just had a warp " + "attempt and either the data is corrupt or that destination doesn't exist!"); } diff --git a/src/com/sekwah/advancedportals/listeners/Listeners.java b/src/com/sekwah/advancedportals/listeners/Listeners.java index ecee4cc6..24cb61a6 100644 --- a/src/com/sekwah/advancedportals/listeners/Listeners.java +++ b/src/com/sekwah/advancedportals/listeners/Listeners.java @@ -105,7 +105,7 @@ public class Listeners implements Listener { boolean warped = Portal.activate(player, portal); if (PortalMessagesDisplay == 1 && warped) { player.sendMessage(""); - player.sendMessage("\u00A7a[\u00A7eAdvancedPortals\u00A7a] You have been warped to \u00A7e" + portal.destiation.replaceAll("_", " ") + "\u00A7."); + player.sendMessage(plugin.customPrefixFail + "\u00A7a You have been warped to \u00A7e" + portal.destiation.replaceAll("_", " ") + "\u00A7."); player.sendMessage(""); } else if (PortalMessagesDisplay == 2 && warped) { ConfigAccessor config = new ConfigAccessor(plugin, "portals.yml"); @@ -284,7 +284,7 @@ public class Listeners implements Listener { if ((portal.pos1.getX()) >= block.getX() && (portal.pos1.getY()) >= block.getY() && (portal.pos1.getZ()) >= block.getZ()) { if ((portal.pos2.getX()) <= block.getX() && (portal.pos2.getY()) <= block.getY() && (portal.pos2.getZ()) <= block.getZ()) { - player.sendMessage("\u00A7a[\u00A7eAdvancedPortals\u00A7a] You have selected: \u00A7e" + portal.portalName); + player.sendMessage(plugin.customPrefixFail + "\u00A7a You have selected: \u00A7e" + portal.portalName); player.setMetadata("selectedPortal", new FixedMetadataValue(plugin, portal.portalName)); // adds the name to the metadata of the character event.setCancelled(true); player.removeMetadata("selectingPortal", plugin); @@ -295,7 +295,7 @@ public class Listeners implements Listener { } } - player.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] No portal was selected. If you would like to stop selecting please type \u00A7e/portal select \u00A7cagain!"); + player.sendMessage(plugin.customPrefixFail + "\u00A7c No portal was selected. If you would like to stop selecting please type \u00A7e/portal select \u00A7cagain!"); event.setCancelled(true); return; } diff --git a/src/com/sekwah/advancedportals/portals/Portal.java b/src/com/sekwah/advancedportals/portals/Portal.java index 41eeea56..dbe6e73f 100644 --- a/src/com/sekwah/advancedportals/portals/Portal.java +++ b/src/com/sekwah/advancedportals/portals/Portal.java @@ -362,13 +362,13 @@ public class Portal { /*if((permission == null || (permission != null && player.hasPermission(permission)) || player.isOp())){*/ // 3 checks, 1st is if it doesnt need perms. 2nd is if it does do they have it. And third is are they op. if (!(permission == null || (permission != null && player.hasPermission(permission)) || player.isOp())) { - player.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] You do not have permission to use this portal!"); + player.sendMessage(plugin.customPrefix + "\u00A7c You do not have permission to use this portal!"); return false; } if (portal.bungee != null) { if (ShowBungeeMessage) { - player.sendMessage("\u00A7a[\u00A7eAdvancedPortals\u00A7a] Attempting to warp to \u00A7e" + portal.bungee + "\u00A7a."); + player.sendMessage(plugin.customPrefix + "\u00A7a Attempting to warp to \u00A7e" + portal.bungee + "\u00A7a."); } ByteArrayDataOutput out = ByteStreams.newDataOutput(); out.writeUTF("Connect"); @@ -422,14 +422,14 @@ public class Portal { boolean warped = Destination.warp(player, portal.destiation); return warped; } else { - player.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] The destination you are currently attempting to warp to doesnt exist!"); + player.sendMessage(plugin.customPrefix + "\u00A7c The destination you are currently attempting to warp to doesnt exist!"); plugin.getLogger().log(Level.SEVERE, "The portal '" + portal.portalName + "' has just had a warp " + "attempt and either the data is corrupt or that destination listed doesn't exist!"); return false; } } else { if (showFailMessage) { - player.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] The portal you are trying to use doesn't have a destination!"); + player.sendMessage(plugin.customPrefix + "\u00A7c The portal you are trying to use doesn't have a destination!"); plugin.getLogger().log(Level.SEVERE, "The portal '" + portal.portalName + "' has just had a warp " + "attempt and either the data is corrupt or portal doesn't exist!"); } @@ -443,12 +443,12 @@ public class Portal { return warped; } else{ - player.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] You do not have permission to use this portal!"); + player.sendMessage(plugin.customPrefix + "\u00A7c You do not have permission to use this portal!"); return false; } } else{ - player.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] The destination you are currently attempting to warp to doesnt exist!"); + player.sendMessage(plugin.customPrefix + "\u00A7c The destination you are currently attempting to warp to doesnt exist!"); plugin.getLogger().log(Level.SEVERE, "The portal '" + portalName + "' has just had a warp " + "attempt and either the data is corrupt or that destination listed doesn't exist!"); return false;