Added the prefix change options

This commit is contained in:
Alastair 2016-03-29 14:35:41 +01:00
parent c7690bafad
commit 2500ecef0c
7 changed files with 21 additions and 16 deletions

View File

@ -67,3 +67,5 @@ UseWarpPrefix: true
UseCustomPrefix: false
CustomPrefix: '&a[&eAdvancedPortals&a]'
CustomPrefixFail: '&c[&7AdvancedPortals&c]'

View File

@ -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");

View File

@ -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");

View File

@ -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;

View File

@ -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!");
}

View File

@ -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;
}

View File

@ -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;