Everything should be using customPrefixes now

This commit is contained in:
Max Qian 2016-08-01 20:51:16 -07:00
parent db76bc6ef2
commit 75d5fef5b0
7 changed files with 83 additions and 79 deletions

View File

@ -63,7 +63,7 @@ public class AdvancedPortalsCommand implements CommandExecutor, TabCompleter {
regionselector.setItemMeta(selectorname); regionselector.setItemMeta(selectorname);
inventory.addItem(regionselector); inventory.addItem(regionselector);
sender.sendMessage("\u00A7a[\u00A7eAdvancedPortals\u00A7a] You have been given a \u00A7ePortal Region Selector\u00A7a!"); sender.sendMessage(PluginMessages.customPrefix + " You have been given a \u00A7ePortal Region Selector\u00A7a!");
break; break;
case "portal": case "portal":
case "portalblock": case "portalblock":
@ -71,7 +71,7 @@ public class AdvancedPortalsCommand implements CommandExecutor, TabCompleter {
inventory.addItem(portalBlock); inventory.addItem(portalBlock);
sender.sendMessage("\u00A7a[\u00A7eAdvancedPortals\u00A7a] You have been given a \u00A7ePortal Block\u00A7a!"); sender.sendMessage(PluginMessages.customPrefix + " You have been given a \u00A7ePortal Block\u00A7a!");
break; break;
case "create": case "create":
if (player.hasMetadata("Pos1World") && player.hasMetadata("Pos2World")) { if (player.hasMetadata("Pos1World") && player.hasMetadata("Pos2World")) {
@ -98,7 +98,7 @@ public class AdvancedPortalsCommand implements CommandExecutor, TabCompleter {
hasName = true; hasName = true;
portalName = args[i].replaceFirst("name:", ""); portalName = args[i].replaceFirst("name:", "");
} else if (args[i].toLowerCase().startsWith("name:")) { } else if (args[i].toLowerCase().startsWith("name:")) {
player.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] You must include a name for the portal that isnt nothing!"); player.sendMessage(PluginMessages.customPrefixFail + " You must include a name for the portal that isnt nothing!");
return true; return true;
} else if (args[i].toLowerCase().startsWith("destination:") && args[i].length() > 12) { } else if (args[i].toLowerCase().startsWith("destination:") && args[i].length() > 12) {
hasDestination = true; hasDestination = true;
@ -128,7 +128,7 @@ public class AdvancedPortalsCommand implements CommandExecutor, TabCompleter {
} }
} }
if (!hasName) { if (!hasName) {
player.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] You must include a name for the portal that you are creating in the variables!"); player.sendMessage(PluginMessages.customPrefixFail + " You must include a name for the portal that you are creating in the variables!");
return true; return true;
} }
@ -142,7 +142,7 @@ public class AdvancedPortalsCommand implements CommandExecutor, TabCompleter {
if (!Portal.portalExists(portalName)) { if (!Portal.portalExists(portalName)) {
player.sendMessage(""); player.sendMessage("");
player.sendMessage("\u00A7a[\u00A7eAdvancedPortals\u00A7a]\u00A7e You have created a new portal with the following details:"); player.sendMessage(PluginMessages.customPrefix + "\u00A7e You have created a new portal with the following details:");
player.sendMessage("\u00A7aname: \u00A7e" + portalName); player.sendMessage("\u00A7aname: \u00A7e" + portalName);
if (hasDestination) { if (hasDestination) {
player.sendMessage("\u00A7adestination: \u00A7e" + destination); player.sendMessage("\u00A7adestination: \u00A7e" + destination);
@ -192,25 +192,25 @@ public class AdvancedPortalsCommand implements CommandExecutor, TabCompleter {
player.sendMessage(Portal.create(pos1, pos2, portalName, destination, serverName, portalArgs)); player.sendMessage(Portal.create(pos1, pos2, portalName, destination, serverName, portalArgs));
} }
} else { } else {
sender.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] A portal by that name already exists!"); sender.sendMessage(PluginMessages.customPrefixFail + " A portal by that name already exists!");
} }
// add code to save the portal to the portal config and reload the portals // add code to save the portal to the portal config and reload the portals
player.sendMessage(""); player.sendMessage("");
} else { } else {
player.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] You need to at least add the name of the portal as a variable, \u00A7cType \u00A7e/portal variables\u00A7c" player.sendMessage(PluginMessages.customPrefixFail + " You need to at least add the name of the portal as a variable, \u00A7cType \u00A7e/portal variables\u00A7c"
+ " for a full list of currently available variables and an example command!"); + " for a full list of currently available variables and an example command!");
} }
} else { } else {
player.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] The points you have selected need to be in the same world!"); player.sendMessage(PluginMessages.customPrefixFail + " The points you have selected need to be in the same world!");
} }
} else { } else {
player.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] You need to have two points selected to make a portal!"); player.sendMessage(PluginMessages.customPrefixFail + " You need to have two points selected to make a portal!");
} }
break; break;
case "variables" : case "variables" :
sender.sendMessage("\u00A7a[\u00A7eAdvancedPortals\u00A7a] Currently available variables: name, triggerBlock, destination"); sender.sendMessage(PluginMessages.customPrefix + " Currently available variables: name, triggerBlock, destination");
sender.sendMessage(""); sender.sendMessage("");
sender.sendMessage("\u00A7aExample command: \u00A7e/portal create name:test triggerId:portal"); sender.sendMessage("\u00A7aExample command: \u00A7e/portal create name:test triggerId:portal");
break; break;
@ -221,23 +221,23 @@ public class AdvancedPortalsCommand implements CommandExecutor, TabCompleter {
if (Portal.portalExists(args[1])) { if (Portal.portalExists(args[1])) {
player.setMetadata("selectedPortal", new FixedMetadataValue(plugin, args[1])); player.setMetadata("selectedPortal", new FixedMetadataValue(plugin, args[1]));
} else { } else {
player.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] No portal by the name \u00A7e" + args[1] + "\u00A7c exists (maybe you got the caps wrong)\n Try typing \u00A7e/portal select\u00A7c and hit inside the apropriate portals area!"); player.sendMessage(PluginMessages.customPrefixFail + " No portal by the name \u00A7e" + args[1] + "\u00A7c exists (maybe you got the caps wrong)\n Try typing \u00A7e/portal select\u00A7c and hit inside the apropriate portals area!");
} }
} else { } else {
player.sendMessage("\u00A7a[\u00A7eAdvancedPortals\u00A7a] Hit a block inside the portal region to select the portal!"); player.sendMessage(PluginMessages.customPrefix + " Hit a block inside the portal region to select the portal!");
player.setMetadata("selectingPortal", new FixedMetadataValue(plugin, true)); player.setMetadata("selectingPortal", new FixedMetadataValue(plugin, true));
} }
} else { } else {
player.removeMetadata("selectingPortal", plugin); player.removeMetadata("selectingPortal", plugin);
player.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] Portal selection cancelled!"); player.sendMessage(PluginMessages.customPrefixFail + " Portal selection cancelled!");
} }
break; break;
case "gui" : case "gui" :
if (args.length > 1) { if (args.length > 1) {
if (args[1].toLowerCase().equals("remove") && args.length > 2) { if (args[1].toLowerCase().equals("remove") && args.length > 2) {
sender.sendMessage(""); sender.sendMessage("");
sender.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] Are you sure you would like to remove the portal \u00A7e" + args[2] + "\u00A7c?"); sender.sendMessage(PluginMessages.customPrefixFail + " Are you sure you would like to remove the portal \u00A7e" + args[2] + "\u00A7c?");
sender.sendMessage(""); sender.sendMessage("");
plugin.nmsAccess.sendRawMessage("{\"text\":\" \",\"extra\":[{\"text\":\"\u00A7e[Yes]\",\"hoverEvent\":{\"action\":\"show_text\",\"value\":\"Confirm removing this portal\"},\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/portal remove " + args[2] + "\"}}, " + plugin.nmsAccess.sendRawMessage("{\"text\":\" \",\"extra\":[{\"text\":\"\u00A7e[Yes]\",\"hoverEvent\":{\"action\":\"show_text\",\"value\":\"Confirm removing this portal\"},\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/portal remove " + args[2] + "\"}}, " +
"{\"text\":\" \"},{\"text\":\"\u00A7e[No]\",\"hoverEvent\":{\"action\":\"show_text\",\"value\":\"Cancel removing this portal\"},\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/portal edit " + args[2] + "\"}}]}", player); "{\"text\":\" \"},{\"text\":\"\u00A7e[No]\",\"hoverEvent\":{\"action\":\"show_text\",\"value\":\"Cancel removing this portal\"},\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/portal edit " + args[2] + "\"}}]}", player);
@ -251,7 +251,7 @@ public class AdvancedPortalsCommand implements CommandExecutor, TabCompleter {
player.setMetadata("selectedPortal", new FixedMetadataValue(plugin, args[1])); player.setMetadata("selectedPortal", new FixedMetadataValue(plugin, args[1]));
portalEditMenu(sender, portalConfig, args[1]); portalEditMenu(sender, portalConfig, args[1]);
} else { } else {
sender.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] No portal by the name \u00A7e" + args[1] + "\u00A7c exists!"); sender.sendMessage(PluginMessages.customPrefixFail + " No portal by the name \u00A7e" + args[1] + "\u00A7c exists!");
} }
} else { } else {
if (player.hasMetadata("selectedPortal")) { if (player.hasMetadata("selectedPortal")) {
@ -260,11 +260,11 @@ public class AdvancedPortalsCommand implements CommandExecutor, TabCompleter {
if (posX != null) { if (posX != null) {
portalEditMenu(sender, portalConfig, portalName); portalEditMenu(sender, portalConfig, portalName);
} else { } else {
sender.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] The portal you had selected no longer seems to exist!"); sender.sendMessage(PluginMessages.customPrefixFail + " The portal you had selected no longer seems to exist!");
player.removeMetadata("selectedPortal", plugin); player.removeMetadata("selectedPortal", plugin);
} }
} else { } else {
sender.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] No portal has been defined or selected!"); sender.sendMessage(PluginMessages.customPrefixFail + " No portal has been defined or selected!");
} }
} }
break; break;
@ -280,22 +280,22 @@ public class AdvancedPortalsCommand implements CommandExecutor, TabCompleter {
String newPortalPosX = portalConfig.getConfig().getString(args[1] + ".pos1.X"); String newPortalPosX = portalConfig.getConfig().getString(args[1] + ".pos1.X");
if (posX != null && newPortalPosX == null) { if (posX != null && newPortalPosX == null) {
Portal.rename(portalName, args[1]); Portal.rename(portalName, args[1]);
sender.sendMessage("\u00A7a[\u00A7eAdvancedPortals\u00A7a] The portal \u00A7e" + portalName + "\u00A7a has been renamed to \u00A7e" + args[1] + "\u00A7a."); sender.sendMessage(PluginMessages.customPrefix + " The portal \u00A7e" + portalName + "\u00A7a has been renamed to \u00A7e" + args[1] + "\u00A7a.");
player.setMetadata("selectedPortal", new FixedMetadataValue(plugin, args[1])); player.setMetadata("selectedPortal", new FixedMetadataValue(plugin, args[1]));
} else if (newPortalPosX != null) { } else if (newPortalPosX != null) {
sender.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] There is already a portal with the name \u00A7e" + args[1] + "\u00A7c!"); sender.sendMessage(PluginMessages.customPrefixFail + " There is already a portal with the name \u00A7e" + args[1] + "\u00A7c!");
} else { } else {
sender.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] The portal you had selected no longer seems to exist!"); sender.sendMessage(PluginMessages.customPrefixFail + " The portal you had selected no longer seems to exist!");
player.removeMetadata("selectedPortal", plugin); player.removeMetadata("selectedPortal", plugin);
} }
} else { } else {
sender.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] The portal you have selected is already called that!"); sender.sendMessage(PluginMessages.customPrefixFail + " The portal you have selected is already called that!");
} }
} else { } else {
sender.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] No portal has been defined or selected!"); sender.sendMessage(PluginMessages.customPrefixFail + " No portal has been defined or selected!");
} }
} else { } else {
sender.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] You must select a portal first and then type \u00A7e/portal rename (new name)\u00A7c!"); sender.sendMessage(PluginMessages.customPrefixFail + " You must select a portal first and then type \u00A7e/portal rename (new name)\u00A7c!");
} }
break; break;
case "command": case "command":
@ -310,13 +310,13 @@ public class AdvancedPortalsCommand implements CommandExecutor, TabCompleter {
portalCommand += args[i]; portalCommand += args[i];
} }
if (Portal.addCommand(portalName, portalCommand)) { if (Portal.addCommand(portalName, portalCommand)) {
sender.sendMessage("\u00A77a[\u00A77eAdvancedPortals\u00A77a] Command added to portal!"); sender.sendMessage(PluginMessages.customPrefixFail + " Command added to portal!");
} else { } else {
sender.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] Failed to add command to portal!"); sender.sendMessage(PluginMessages.customPrefixFail + " Failed to add command to portal!");
} }
} else { } else {
sender.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] You must actually specify a command to execute!"); sender.sendMessage(PluginMessages.customPrefixFail + " You must actually specify a command to execute!");
} }
} else if (args[1].toLowerCase().equals("remove")) { } else if (args[1].toLowerCase().equals("remove")) {
@ -324,10 +324,10 @@ public class AdvancedPortalsCommand implements CommandExecutor, TabCompleter {
} else if (args[1].toLowerCase().equals("show")) { } else if (args[1].toLowerCase().equals("show")) {
// Show all the commands the portal executes // Show all the commands the portal executes
} else { } else {
sender.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] You must specify to \u00A7eadd\u00A7c or \u00A7eremove a command!"); sender.sendMessage(PluginMessages.customPrefixFail + " You must specify to \u00A7eadd\u00A7c or \u00A7eremove a command!");
} }
} else { } else {
sender.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] You must specify to \u00A7eadd\u00A7c or \u00A7eremove\u00A7c a command!"); sender.sendMessage(PluginMessages.customPrefixFail + " You must specify to \u00A7eadd\u00A7c or \u00A7eremove\u00A7c a command!");
} }
} else { } else {
@ -338,9 +338,9 @@ public class AdvancedPortalsCommand implements CommandExecutor, TabCompleter {
String posX = portalConfig.getConfig().getString(args[1] + ".pos1.X"); String posX = portalConfig.getConfig().getString(args[1] + ".pos1.X");
if (posX != null) { if (posX != null) {
Portal.remove(args[1]); Portal.remove(args[1]);
sender.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] The portal \u00A7e" + args[1] + "\u00A7c has been removed!"); sender.sendMessage(PluginMessages.customPrefixFail + " The portal \u00A7e" + args[1] + "\u00A7c has been removed!");
} else { } else {
sender.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] No portal by that name exists!"); sender.sendMessage(PluginMessages.customPrefixFail + " No portal by that name exists!");
} }
} else { } else {
if (player.hasMetadata("selectedPortal")) { if (player.hasMetadata("selectedPortal")) {
@ -348,23 +348,23 @@ public class AdvancedPortalsCommand implements CommandExecutor, TabCompleter {
String posX = portalConfig.getConfig().getString(portalName + ".pos1.X"); String posX = portalConfig.getConfig().getString(portalName + ".pos1.X");
if (posX != null) { if (posX != null) {
Portal.remove(portalName); Portal.remove(portalName);
sender.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] The portal \u00A77" + portalName + "\u00A7c has been removed!"); sender.sendMessage(PluginMessages.customPrefixFail + " The portal \u00A77" + portalName + "\u00A7c has been removed!");
} else { } else {
sender.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] The portal you had selected no longer seems to exist!"); sender.sendMessage(PluginMessages.customPrefixFail + " The portal you had selected no longer seems to exist!");
player.removeMetadata("selectedPortal", plugin); player.removeMetadata("selectedPortal", plugin);
} }
} else { } else {
sender.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] No portal has been defined or selected!"); sender.sendMessage(PluginMessages.customPrefixFail + " No portal has been defined or selected!");
} }
} }
break; break;
case "help": case "help":
case "helppage": case "helppage":
sender.sendMessage("\u00A7a[\u00A7eAdvancedPortals\u00A7a] Still designing in game help page :("); sender.sendMessage(PluginMessages.customPrefix + " Still designing in game help page :(");
sender.sendMessage("\u00A7a[\u00A7eAdvancedPortals\u00A7a] For now please use the wiki http://bit.ly/portals-help"); sender.sendMessage(PluginMessages.customPrefix + " For now please use the wiki http://bit.ly/portals-help");
break; break;
case "bukkitpage": case "bukkitpage":
sender.sendMessage("\u00A7a[\u00A7eAdvancedPortals\u00A7a] Bukkit page: http://bit.ly/adv-portals!"); sender.sendMessage(PluginMessages.customPrefix + " Bukkit page: http://bit.ly/adv-portals!");
break; break;
case "show": case "show":
if (args.length > 1) { if (args.length > 1) {
@ -372,29 +372,29 @@ public class AdvancedPortalsCommand implements CommandExecutor, TabCompleter {
if (posX != null) { if (posX != null) {
Selection.Show(player, this.plugin, args[1]); Selection.Show(player, this.plugin, args[1]);
} else { } else {
sender.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] No portal by that name exists!"); sender.sendMessage(PluginMessages.customPrefixFail + " No portal by that name exists!");
} }
} else { } else {
if (player.hasMetadata("selectedPortal")) { if (player.hasMetadata("selectedPortal")) {
player.sendMessage("\u00A7a[\u00A7eAdvancedPortals\u00A7a] Your currently selected portal has been shown, it will dissapear shortly!"); player.sendMessage(PluginMessages.customPrefix + " Your currently selected portal has been shown, it will dissapear shortly!");
Selection.Show(player, this.plugin, player.getMetadata("selectedPortal").get(0).asString()); Selection.Show(player, this.plugin, player.getMetadata("selectedPortal").get(0).asString());
} else if (player.hasMetadata("Pos1World") && player.hasMetadata("Pos2World")) { } else if (player.hasMetadata("Pos1World") && player.hasMetadata("Pos2World")) {
if (player.getMetadata("Pos1World").get(0).asString().equals(player.getMetadata("Pos2World").get(0).asString()) && player.getMetadata("Pos1World").get(0).asString().equals(player.getLocation().getWorld().getName())) { if (player.getMetadata("Pos1World").get(0).asString().equals(player.getMetadata("Pos2World").get(0).asString()) && player.getMetadata("Pos1World").get(0).asString().equals(player.getLocation().getWorld().getName())) {
player.sendMessage("\u00A7a[\u00A7eAdvancedPortals\u00A7a] Your currently selected area has been shown, it will dissapear shortly!"); player.sendMessage(PluginMessages.customPrefix + " Your currently selected area has been shown, it will dissapear shortly!");
Selection.Show(player, this.plugin, null); Selection.Show(player, this.plugin, null);
} }
} else { } else {
player.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] No regions selected!"); player.sendMessage(PluginMessages.customPrefixFail + " No regions selected!");
} }
} }
break; break;
case "reload": case "reload":
sender.sendMessage("\u00A7a[\u00A7eAdvancedPortals\u00A7a] Reloaded values!"); sender.sendMessage(PluginMessages.customPrefix + " Reloaded values!");
Listeners.reloadValues(plugin); Listeners.reloadValues(plugin);
Portal.loadPortals(); Portal.loadPortals();
break; break;
case "list" : case "list" :
String message = "\u00A7eAdvancedPortals\u00A7a :"; String message = PluginMessages.customPrefix + " \u00A7c:\u00A7a";
for (AdvancedPortal portal : Portal.Portals) { for (AdvancedPortal portal : Portal.Portals) {
message = message + " " + portal.portalName; message = message + " " + portal.portalName;
} }
@ -444,7 +444,7 @@ public class AdvancedPortalsCommand implements CommandExecutor, TabCompleter {
// use the usual messages for normal lines but anything that needs special features make sure you use the // use the usual messages for normal lines but anything that needs special features make sure you use the
// chat steriliser // chat steriliser
sender.sendMessage(""); sender.sendMessage("");
sender.sendMessage("\u00A7a[\u00A7eAdvancedPortals\u00A7a] Editing: \u00A7e" + portalName); sender.sendMessage(PluginMessages.customPrefix + " Editing: \u00A7e" + portalName);
sender.sendMessage(" \u00A7apos1\u00A7e: " + portalConfig.getConfig().getString(portalName + ".pos1.X") + ", " + portalConfig.getConfig().getString(portalName + ".pos1.Y") + ", " + portalConfig.getConfig().getString(portalName + ".pos1.Z")); sender.sendMessage(" \u00A7apos1\u00A7e: " + portalConfig.getConfig().getString(portalName + ".pos1.X") + ", " + portalConfig.getConfig().getString(portalName + ".pos1.Y") + ", " + portalConfig.getConfig().getString(portalName + ".pos1.Z"));
sender.sendMessage(" \u00A7apos2\u00A7e: " + portalConfig.getConfig().getString(portalName + ".pos2.X") + ", " + portalConfig.getConfig().getString(portalName + ".pos2.Y") + ", " + portalConfig.getConfig().getString(portalName + ".pos2.Z")); sender.sendMessage(" \u00A7apos2\u00A7e: " + portalConfig.getConfig().getString(portalName + ".pos2.X") + ", " + portalConfig.getConfig().getString(portalName + ".pos2.Y") + ", " + portalConfig.getConfig().getString(portalName + ".pos2.Z"));

View File

@ -16,12 +16,6 @@ public class AdvancedPortalsPlugin extends JavaPlugin {
public NMS nmsAccess; public NMS nmsAccess;
public boolean useCustomPrefix = false;
public String customPrefix = "\u00A7a[\u00A7eAdvancedPortals\u00A7a]";
public String customPrefixFail = "\u00A7c[\u00A77AdvancedPortals\u00A7c]";
public void onEnable() { public void onEnable() {
try { try {
@ -59,6 +53,7 @@ public class AdvancedPortalsPlugin extends JavaPlugin {
new DataCollector(this); new DataCollector(this);
// These register the commands // These register the commands
new PluginMessages(this);
new AdvancedPortalsCommand(this); new AdvancedPortalsCommand(this);
new DestinationCommand(this); new DestinationCommand(this);
new WarpCommand(this); new WarpCommand(this);
@ -99,14 +94,6 @@ public class AdvancedPortalsPlugin extends JavaPlugin {
// thanks to the new config accessor code the config.saveDefaultConfig(); will now // thanks to the new config accessor code the config.saveDefaultConfig(); will now
// only copy the file if it doesnt exist! // only copy the file if it doesnt exist!
ConfigAccessor config = new ConfigAccessor(this, "config.yml");
this.useCustomPrefix = config.getConfig().getBoolean("UseCustomPrefix");
if (useCustomPrefix) {
this.customPrefix = config.getConfig().getString("CustomPrefix").replaceAll("&", "\u00A7");
this.customPrefixFail = config.getConfig().getString("CustomPrefixFail").replaceAll("&", "\u00A7");
}
} }

View File

@ -3,17 +3,31 @@ package com.sekwah.advancedportals;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
public class PluginMessages { public class PluginMessages {
private AdvancedPortalsPlugin plugin;
public boolean useCustomPrefix = false;
public static String customPrefix = "\u00A7a[\u00A7eAdvancedPortals\u00A7a]";
public static String customPrefixFail = "\u00A7c[\u00A77AdvancedPortals\u00A7c]";
public PluginMessages (AdvancedPortalsPlugin plugin) {
this.plugin = plugin;
ConfigAccessor config = new ConfigAccessor(this.plugin, "config.yml");
this.useCustomPrefix = config.getConfig().getBoolean("UseCustomPrefix");
if (useCustomPrefix) {
PluginMessages.customPrefixFail = config.getConfig().getString("CustomPrefix").replaceAll("&", "\u00A7");
PluginMessages.customPrefixFail = config.getConfig().getString("CustomPrefixFail").replaceAll("&", "\u00A7");
}
}
// This class is so then the common messages in commands or just messages over the commands are the same and can be // This class is so then the common messages in commands or just messages over the commands are the same and can be
// easily changed. // easily changed.
public static void UnknownCommand(CommandSender sender, String command) { public static void UnknownCommand(CommandSender sender, String command) {
sender.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] You need to type something after /" + command + "\n"); sender.sendMessage(customPrefixFail + " You need to type something after /" + command + "\n");
sender.sendMessage("\u00A7cIf you do not know what you can put or would like some help with the commands please type \u00A7e" + '"' + "\u00A7e/" + command + " help" + '"' + "\u00A7c\n"); sender.sendMessage("\u00A7cIf you do not know what you can put or would like some help with the commands please type \u00A7e" + '"' + "\u00A7e/" + command + " help" + '"' + "\u00A7c\n");
} }
public static void NoPermission(CommandSender sender, String command) { public static void NoPermission(CommandSender sender, String command) {
sender.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] You do not have permission to perform that command!"); sender.sendMessage(customPrefixFail + " You do not have permission to perform that command!");
} }
} }

View File

@ -2,6 +2,7 @@ package com.sekwah.advancedportals.destinations;
import com.sekwah.advancedportals.AdvancedPortalsPlugin; import com.sekwah.advancedportals.AdvancedPortalsPlugin;
import com.sekwah.advancedportals.ConfigAccessor; import com.sekwah.advancedportals.ConfigAccessor;
import com.sekwah.advancedportals.PluginMessages;
import com.sekwah.advancedportals.effects.WarpEffects; import com.sekwah.advancedportals.effects.WarpEffects;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Chunk; import org.bukkit.Chunk;
@ -141,7 +142,7 @@ public class Destination {
if (PortalMessagesDisplay == 1) { if (PortalMessagesDisplay == 1) {
player.sendMessage(""); player.sendMessage("");
player.sendMessage(plugin.customPrefixFail + "\u00A7a You have been warped to \u00A7e" + name.replaceAll("_", " ") + "\u00A7a."); player.sendMessage(PluginMessages.customPrefixFail + "\u00A7a You have been warped to \u00A7e" + name.replaceAll("_", " ") + "\u00A7a.");
player.sendMessage(""); player.sendMessage("");
} else if (PortalMessagesDisplay == 2) { } else if (PortalMessagesDisplay == 2) {
plugin.nmsAccess.sendActionBarMessage("{\"text\":\"\u00A7aYou have warped to \u00A7e" + name.replaceAll("_", " ") + "\u00A7a.\"}", player); plugin.nmsAccess.sendActionBarMessage("{\"text\":\"\u00A7aYou have warped to \u00A7e" + name.replaceAll("_", " ") + "\u00A7a.\"}", player);
@ -151,12 +152,12 @@ public class Destination {
return true; return true;
} else { } else {
player.sendMessage(plugin.customPrefixFail + "\u00A7c The destination you are trying to warp to seems to be linked to a world that doesn't exist!"); player.sendMessage(PluginMessages.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 " 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!"); + config.getConfig().getString(name + ".world") + " which doesnt seem to exist any more!");
} }
} else { } else {
player.sendMessage(plugin.customPrefix + "\u00A7c The destination you are currently attempting to warp to doesnt exist!"); player.sendMessage(PluginMessages.customPrefix + "\u00A7c The destination you are currently attempting to warp to doesnt exist!");
plugin.getLogger().log(Level.SEVERE, "The destination '" + name + "' has just had a warp " 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!"); + "attempt and either the data is corrupt or that destination doesn't exist!");
} }

View File

@ -34,17 +34,17 @@ public class DestinationCommand implements CommandExecutor, TabCompleter {
if (args.length > 1) { if (args.length > 1) {
String posX = config.getConfig().getString(args[1].toLowerCase() + ".pos.X"); String posX = config.getConfig().getString(args[1].toLowerCase() + ".pos.X");
if (posX == null) { if (posX == null) {
sender.sendMessage("§a[\u00A7eAdvancedPortals\u00A7a] You have created a new destination called \u00A7e" + args[1] + "!"); sender.sendMessage(PluginMessages.customPrefix + " You have created a new destination called \u00A7e" + args[1] + "!");
Player player = sender.getServer().getPlayer(sender.getName()); Player player = sender.getServer().getPlayer(sender.getName());
Destination.create(player.getLocation(), args[1]); Destination.create(player.getLocation(), args[1]);
} else { } else {
sender.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] A destination by that name already exists!"); sender.sendMessage(PluginMessages.customPrefixFail + " A destination by that name already exists!");
} }
} else { } else {
sender.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] Please state the name of the destination you would like to create!"); sender.sendMessage(PluginMessages.customPrefixFail + " Please state the name of the destination you would like to create!");
} }
} else { } else {
sender.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] You do not have permission to create portals so you cannot give yourself a \u00A7ePortal Region Selector\u00A7c!"); sender.sendMessage(PluginMessages.customPrefixFail + " You do not have permission to create portals so you cannot give yourself a \u00A7ePortal Region Selector\u00A7c!");
} }
break; break;
case "remove": case "remove":
@ -53,12 +53,12 @@ public class DestinationCommand implements CommandExecutor, TabCompleter {
String posX = portalConfig.getConfig().getString(args[1] + ".pos.X"); String posX = portalConfig.getConfig().getString(args[1] + ".pos.X");
if (posX != null) { if (posX != null) {
Destination.remove(args[1]); Destination.remove(args[1]);
sender.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] The destination \u00A7e" + args[1] + "\u00A7c has been removed!"); sender.sendMessage(PluginMessages.customPrefixFail + " The destination \u00A7e" + args[1] + "\u00A7c has been removed!");
} else { } else {
sender.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] No destination by that name exists."); sender.sendMessage(PluginMessages.customPrefixFail + " No destination by that name exists.");
} }
} else { } else {
sender.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] You need to state the name of the destination you wish to remove."); sender.sendMessage(PluginMessages.customPrefixFail + " You need to state the name of the destination you wish to remove.");
} }
break; break;
case "goto": case "goto":
@ -66,7 +66,7 @@ public class DestinationCommand implements CommandExecutor, TabCompleter {
if (args.length > 1) { if (args.length > 1) {
Destination.warp((Player) sender, args[1]); Destination.warp((Player) sender, args[1]);
} else { } else {
sender.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] You need to state the name of the destination you wish to warp to."); sender.sendMessage(PluginMessages.customPrefixFail + " You need to state the name of the destination you wish to warp to.");
} }
break; break;
case "list": case "list":
@ -80,7 +80,7 @@ public class DestinationCommand implements CommandExecutor, TabCompleter {
} }
} }
sender.sendMessage("\u00A7a[\u00A7eAdvancedPortals\u00A7a] Showing destinations page 1 of 1"); sender.sendMessage(PluginMessages.customPrefix + " Showing destinations page 1 of 1");
for (int i = (page - 1) * 5; i < page * 5; i++) { for (int i = (page - 1) * 5; i < page * 5; i++) {
if (i > destiList.size()) { if (i > destiList.size()) {
break; break;
@ -92,7 +92,7 @@ public class DestinationCommand implements CommandExecutor, TabCompleter {
} }
} }
sender.sendMessage("\u00A7a[\u00A7eAdvancedPortals\u00A7a] Showing destinations page 1 of 1"); sender.sendMessage(PluginMessages.customPrefix + " Showing destinations page 1 of 1");
for (int i = 0; i < 5; i++) { for (int i = 0; i < 5; i++) {
if (i > destiList.size()) { if (i > destiList.size()) {
break; break;
@ -100,7 +100,7 @@ public class DestinationCommand implements CommandExecutor, TabCompleter {
sender.sendMessage(" \u00A7e" + destiList.get(i)); sender.sendMessage(" \u00A7e" + destiList.get(i));
} }
sender.sendMessage("\u00A7a[\u00A7eAdvancedPortals\u00A7a] Showing destinations page 1 of 1"); sender.sendMessage(PluginMessages.customPrefix + " Showing destinations page 1 of 1");
for (int i = 0; i < 5; i++) { for (int i = 0; i < 5; i++) {
if (i > destiList.size()) { if (i > destiList.size()) {
break; break;
@ -108,7 +108,7 @@ public class DestinationCommand implements CommandExecutor, TabCompleter {
sender.sendMessage(" \u00A7e" + destiList.get(i)); sender.sendMessage(" \u00A7e" + destiList.get(i));
} }
} else { } else {
sender.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] There are currently no defined destinations."); sender.sendMessage(PluginMessages.customPrefixFail + " There are currently no defined destinations.");
} }
break; break;
} }

View File

@ -2,6 +2,7 @@ package com.sekwah.advancedportals.listeners;
import com.sekwah.advancedportals.AdvancedPortalsPlugin; import com.sekwah.advancedportals.AdvancedPortalsPlugin;
import com.sekwah.advancedportals.ConfigAccessor; import com.sekwah.advancedportals.ConfigAccessor;
import com.sekwah.advancedportals.PluginMessages;
import com.sekwah.advancedportals.api.events.WarpEvent; import com.sekwah.advancedportals.api.events.WarpEvent;
import com.sekwah.advancedportals.portals.AdvancedPortal; import com.sekwah.advancedportals.portals.AdvancedPortal;
import com.sekwah.advancedportals.portals.Portal; import com.sekwah.advancedportals.portals.Portal;
@ -170,14 +171,14 @@ public class Listeners implements Listener {
if (player.hasMetadata("selectingPortal") && (event.getAction() == Action.LEFT_CLICK_BLOCK || event.getAction() == Action.RIGHT_CLICK_BLOCK)) { if (player.hasMetadata("selectingPortal") && (event.getAction() == Action.LEFT_CLICK_BLOCK || event.getAction() == Action.RIGHT_CLICK_BLOCK)) {
for (AdvancedPortal portal : Portal.Portals) { for (AdvancedPortal portal : Portal.Portals) {
if (Portal.locationInPortal(portal, event.getClickedBlock().getLocation(), 0)) { if (Portal.locationInPortal(portal, event.getClickedBlock().getLocation(), 0)) {
player.sendMessage(plugin.customPrefixFail + "\u00A7a You have selected: \u00A7e" + portal.portalName); player.sendMessage(PluginMessages.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 player.setMetadata("selectedPortal", new FixedMetadataValue(plugin, portal.portalName)); // adds the name to the metadata of the character
event.setCancelled(true); event.setCancelled(true);
player.removeMetadata("selectingPortal", plugin); player.removeMetadata("selectingPortal", plugin);
return; return;
} }
} }
player.sendMessage(plugin.customPrefixFail + "\u00A7c No portal was selected. If you would like to stop selecting please type \u00A7e/portal select \u00A7cagain!"); player.sendMessage(PluginMessages.customPrefixFail + "\u00A7c No portal was selected. If you would like to stop selecting please type \u00A7e/portal select \u00A7cagain!");
event.setCancelled(true); event.setCancelled(true);
return; return;
} }

View File

@ -4,6 +4,7 @@ import com.google.common.io.ByteArrayDataOutput;
import com.google.common.io.ByteStreams; import com.google.common.io.ByteStreams;
import com.sekwah.advancedportals.AdvancedPortalsPlugin; import com.sekwah.advancedportals.AdvancedPortalsPlugin;
import com.sekwah.advancedportals.ConfigAccessor; import com.sekwah.advancedportals.ConfigAccessor;
import com.sekwah.advancedportals.PluginMessages;
import com.sekwah.advancedportals.destinations.Destination; import com.sekwah.advancedportals.destinations.Destination;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
@ -368,7 +369,7 @@ public class Portal {
/*if((permission == null || (permission != null && player.hasPermission(permission)) || player.isOp())){*/ /*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. // 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())) { if (!(permission == null || (permission != null && player.hasPermission(permission)) || player.isOp())) {
player.sendMessage(plugin.customPrefix + "\u00A7c You do not have permission to use this portal!"); player.sendMessage(PluginMessages.customPrefix + "\u00A7c You do not have permission to use this portal!");
return false; return false;
} }
@ -426,7 +427,7 @@ public class Portal {
//plugin.getLogger().info(portal.portalName + ":" + portal.destiation); //plugin.getLogger().info(portal.portalName + ":" + portal.destiation);
if (portal.bungee != null) { if (portal.bungee != null) {
if (ShowBungeeMessage) { if (ShowBungeeMessage) {
player.sendMessage(plugin.customPrefix + "\u00A7a Attempting to warp to \u00A7e" + portal.bungee + "\u00A7a."); player.sendMessage(PluginMessages.customPrefix + "\u00A7a Attempting to warp to \u00A7e" + portal.bungee + "\u00A7a.");
} }
ByteArrayDataOutput out = ByteStreams.newDataOutput(); ByteArrayDataOutput out = ByteStreams.newDataOutput();
out.writeUTF("Connect"); out.writeUTF("Connect");
@ -442,7 +443,7 @@ public class Portal {
} }
} else { } else {
if (showFailMessage) { if (showFailMessage) {
player.sendMessage(plugin.customPrefix + "\u00A7c The portal you are trying to use doesn't have a destination!"); player.sendMessage(PluginMessages.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 " 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!"); + "attempt and either the data is corrupt or portal doesn't exist!");
} }