From ba2b827d7cab1c078a3078f78d32394e3e1f01ea Mon Sep 17 00:00:00 2001 From: ementalo Date: Fri, 22 Jul 2011 12:36:49 +0100 Subject: [PATCH 01/17] Test #723 essentials.ban.notify - only people with this permission get notified on ban --- .../src/com/earth2me/essentials/commands/Commandban.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandban.java b/Essentials/src/com/earth2me/essentials/commands/Commandban.java index 2bd09831d..45e6a2035 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandban.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandban.java @@ -53,6 +53,13 @@ public class Commandban extends EssentialsCommand } player.kickPlayer(banReason); ess.getBans().banByName(player.getName()); - server.broadcastMessage(Util.format("playerBanned", player.getName(), banReason)); + for(Player p : server.getOnlinePlayers()) + { + User u = ess.getUser(p); + if(u.isAuthorized("essentials.ban.notify")) + { + p.sendMessage(Util.format("playerBanned", player.getName(), banReason)); + } + } } } From 7b7289db4c8c776c924722e379911defdefdcdd2 Mon Sep 17 00:00:00 2001 From: ementalo Date: Fri, 22 Jul 2011 14:07:04 +0100 Subject: [PATCH 02/17] Test #725 fix for Protection signs created before 2.5 --- .../src/com/earth2me/essentials/signs/SignProtection.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Essentials/src/com/earth2me/essentials/signs/SignProtection.java b/Essentials/src/com/earth2me/essentials/signs/SignProtection.java index 4922b3dbb..f988dcb0b 100644 --- a/Essentials/src/com/earth2me/essentials/signs/SignProtection.java +++ b/Essentials/src/com/earth2me/essentials/signs/SignProtection.java @@ -9,6 +9,7 @@ import java.util.EnumSet; import java.util.HashMap; import java.util.Map; import java.util.Set; +import org.bukkit.ChatColor; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.block.Block; @@ -152,12 +153,13 @@ public class SignProtection extends EssentialsSign { return SignProtectionState.ALLOWED; } - else if (line.equalsIgnoreCase(username)) + else if (line.equalsIgnoreCase(username)|| line.equalsIgnoreCase(ChatColor.stripColor(username))) { return SignProtectionState.ALLOWED; } } - if (sign.getLine(3).substring(2).equalsIgnoreCase(username)) + String signOwner = sign.getLine(3).substring(2); + if (signOwner.equalsIgnoreCase(username) || signOwner.equalsIgnoreCase(ChatColor.stripColor(username))) { return SignProtectionState.OWNER; } From d7b2ac97aa6864bd041ebfee27bb53994849da14 Mon Sep 17 00:00:00 2001 From: ementalo Date: Fri, 22 Jul 2011 16:56:41 +0100 Subject: [PATCH 03/17] fix of my fix --- .../src/com/earth2me/essentials/signs/SignProtection.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Essentials/src/com/earth2me/essentials/signs/SignProtection.java b/Essentials/src/com/earth2me/essentials/signs/SignProtection.java index f988dcb0b..52848a4f7 100644 --- a/Essentials/src/com/earth2me/essentials/signs/SignProtection.java +++ b/Essentials/src/com/earth2me/essentials/signs/SignProtection.java @@ -153,13 +153,13 @@ public class SignProtection extends EssentialsSign { return SignProtectionState.ALLOWED; } - else if (line.equalsIgnoreCase(username)|| line.equalsIgnoreCase(ChatColor.stripColor(username))) + else if (line.equalsIgnoreCase(username)|| ChatColor.stripColor(line).equalsIgnoreCase((username))) { return SignProtectionState.ALLOWED; } } String signOwner = sign.getLine(3).substring(2); - if (signOwner.equalsIgnoreCase(username) || signOwner.equalsIgnoreCase(ChatColor.stripColor(username))) + if (signOwner.equalsIgnoreCase(username) || ChatColor.stripColor(signOwner).equalsIgnoreCase((username))) { return SignProtectionState.OWNER; } From 6a1c53dd0190ed1ed14bcc4415a261a1bd79b81c Mon Sep 17 00:00:00 2001 From: ementalo Date: Fri, 22 Jul 2011 17:03:55 +0100 Subject: [PATCH 04/17] SignProtection another fix --- .../src/com/earth2me/essentials/signs/SignProtection.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Essentials/src/com/earth2me/essentials/signs/SignProtection.java b/Essentials/src/com/earth2me/essentials/signs/SignProtection.java index 52848a4f7..0a74129d1 100644 --- a/Essentials/src/com/earth2me/essentials/signs/SignProtection.java +++ b/Essentials/src/com/earth2me/essentials/signs/SignProtection.java @@ -153,13 +153,12 @@ public class SignProtection extends EssentialsSign { return SignProtectionState.ALLOWED; } - else if (line.equalsIgnoreCase(username)|| ChatColor.stripColor(line).equalsIgnoreCase((username))) + else if (line.equalsIgnoreCase(username)) { return SignProtectionState.ALLOWED; } } - String signOwner = sign.getLine(3).substring(2); - if (signOwner.equalsIgnoreCase(username) || ChatColor.stripColor(signOwner).equalsIgnoreCase((username))) + if (ChatColor.stripColor(sign.getLine(3).substring(2)).equalsIgnoreCase(username)) { return SignProtectionState.OWNER; } From 304b13ca5e25c3ad9341a1ba7e3d1cd6b52414ff Mon Sep 17 00:00:00 2001 From: ementalo Date: Fri, 22 Jul 2011 17:16:08 +0100 Subject: [PATCH 05/17] SignProtection code fix number 92324 --- .../src/com/earth2me/essentials/signs/SignProtection.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Essentials/src/com/earth2me/essentials/signs/SignProtection.java b/Essentials/src/com/earth2me/essentials/signs/SignProtection.java index 0a74129d1..43bb964b0 100644 --- a/Essentials/src/com/earth2me/essentials/signs/SignProtection.java +++ b/Essentials/src/com/earth2me/essentials/signs/SignProtection.java @@ -158,7 +158,7 @@ public class SignProtection extends EssentialsSign return SignProtectionState.ALLOWED; } } - if (ChatColor.stripColor(sign.getLine(3).substring(2)).equalsIgnoreCase(username)) + if (ChatColor.stripColor(sign.getLine(3)).equalsIgnoreCase(username)) { return SignProtectionState.OWNER; } From 85cab9533e4871651da86e4918a2aeb1cd82ad38 Mon Sep 17 00:00:00 2001 From: Robert Meany Date: Fri, 22 Jul 2011 13:53:06 -0400 Subject: [PATCH 06/17] *First Commit - Please verify I did everything right* - Added translations to plugin help command failure log messagets. --- .../src/com/earth2me/essentials/commands/Commandhelp.java | 3 ++- Essentials/src/messages.properties | 3 ++- Essentials/src/messages_da.properties | 3 ++- Essentials/src/messages_de.properties | 5 +++-- Essentials/src/messages_en.properties | 3 ++- Essentials/src/messages_fr.properties | 3 ++- Essentials/src/messages_nl.properties | 3 ++- 7 files changed, 15 insertions(+), 8 deletions(-) diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandhelp.java b/Essentials/src/com/earth2me/essentials/commands/Commandhelp.java index c105e2e41..98f58151f 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandhelp.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandhelp.java @@ -173,7 +173,8 @@ public class Commandhelp extends EssentialsCommand { if (!reported) { - logger.log(Level.WARNING, "Error getting help for:" + pluginName, ex); + // + logger.log(Level.WARNING, Util.format("commandHelpFailedForPlugin", pluginName), ex); } reported = true; continue; diff --git a/Essentials/src/messages.properties b/Essentials/src/messages.properties index 9712cf007..75125a121 100644 --- a/Essentials/src/messages.properties +++ b/Essentials/src/messages.properties @@ -29,7 +29,8 @@ canTalkAgain = \u00a77You can talk again cantFindGeoIpDB = Can''t find GeoIP database! cantReadGeoIpDB = Failed to read GeoIP database! cantSpawnItem = \u00a7cYou are not allowed to spawn the item {0} -commandFailed = Command {0} failed: +commandFailed = Command {0} failed: +commandHelpFailedForPlugin = Error getting help for: {0} commandNotLoaded = \u00a7cCommand {0} is improperly loaded. compassBearing = \u00a77Bearing: {0} ({1} degrees). configFileMoveError = Failed to move config.yml to backup location. diff --git a/Essentials/src/messages_da.properties b/Essentials/src/messages_da.properties index 81b387074..f57224d0f 100644 --- a/Essentials/src/messages_da.properties +++ b/Essentials/src/messages_da.properties @@ -31,7 +31,8 @@ canTalkAgain = \u00a77Du kan snakke igen cantFindGeoIpDB = Kan ikke finde GeoIP database! cantReadGeoIpDB = Fejl ved l\u00e6sning af GeoIP database! cantSpawnItem = \u00a7cDu er ikke tilladt at spawne elementet {0} -commandFailed = Kommando {0} fejlede: +commandFailed = Kommando {0} fejlede: +commandHelpFailedForPlugin=Fejl ved at f\u00e5 hj\u00e6lp til: {0} commandNotLoaded = \u00a7cCommand {0} er ikke indl\u00e6st korrekt. compassBearing = \u00a77B\u00e6rer: {0} ({1} grader). configFileMoveError = Kunne ikke flytte config.yml til backup placering. diff --git a/Essentials/src/messages_de.properties b/Essentials/src/messages_de.properties index a9ec7497b..992c36b7c 100644 --- a/Essentials/src/messages_de.properties +++ b/Essentials/src/messages_de.properties @@ -29,7 +29,8 @@ canTalkAgain = \u00a77Du kannst wieder sprechen. cantFindGeoIpDB = Kann GeoIP-Datenbank nicht finden! cantReadGeoIpDB = Fehler beim Einlesen der GeoIP-Datenbank! cantSpawnItem = \u00a7cDu darfst {0} nicht erzeugen. -commandFailed = Befehl {0} scheiterte: +commandFailed = Befehl {0} scheiterte: +commandHelpFailedForPlugin=Fehler beim Abrufen der Hilfe f\u00fcr: {0} commandNotLoaded = \u00a7cBefehl {0} ist nicht richtig geladen. compassBearing = \u00a77Peilung: {0} ({1} Grad). configFileMoveError = Verschieben von config.yml zu einer Sicherheitskopie gescheitert. @@ -325,4 +326,4 @@ year = Jahr years = Jahre youAreHealed = \u00a77Du wurdest geheilt. youHaveNewMail = \u00a7cDu hast {0} Nachrichten!\u00a7f Schreibe \u00a77/mail read\u00a7f um deine Nachrichten anzuzeigen. -invalidCharge = \u00a7cUng\u00fcltige Verf\u00fcgung. \ No newline at end of file +invalidCharge = \u00a7cUng\u00fcltige Verf\u00fcgung. diff --git a/Essentials/src/messages_en.properties b/Essentials/src/messages_en.properties index 420768a35..97cdd57b1 100644 --- a/Essentials/src/messages_en.properties +++ b/Essentials/src/messages_en.properties @@ -29,7 +29,8 @@ canTalkAgain = \u00a77You can talk again cantFindGeoIpDB = Can''t find GeoIP database! cantReadGeoIpDB = Failed to read GeoIP database! cantSpawnItem = \u00a7cYou are not allowed to spawn the item {0} -commandFailed = Command {0} failed: +commandFailed = Command {0} failed: +commandHelpFailedForPlugin=Error getting help for: {0} commandNotLoaded = \u00a7cCommand {0} is improperly loaded. compassBearing = \u00a77Bearing: {0} ({1} degrees). configFileMoveError = Failed to move config.yml to backup location. diff --git a/Essentials/src/messages_fr.properties b/Essentials/src/messages_fr.properties index 5f32ff3bc..09ae9bc12 100644 --- a/Essentials/src/messages_fr.properties +++ b/Essentials/src/messages_fr.properties @@ -29,7 +29,8 @@ canTalkAgain = \u00a77Vous pouvez de nouveau parler. cantFindGeoIpDB = N''arrive pas \u00e0 trouver la base de donn\u00e9es GeoIP! cantReadGeoIpDB = Echec de la lecture de la base de donn\u00e9s GeoIP! cantSpawnItem = \u00a7cVous n''avez pas le droit de faire apparaitre {0} -commandFailed = \u00c9chec de la commande {0}: +commandFailed = \u00c9chec de la commande {0}: +commandHelpFailedForPlugin=Erreur d'obtention d'aider \u00e0: {0} commandNotLoaded = \u00a7cLa commande {0} a \u00e9t\u00e9 mal charg\u00e9e. compassBearing = \u00a77Orientation: {0} ({1} degr\u00e9s). configFileMoveError = \u00c9chec du d\u00e9placement de config.yml vers l''emplacement de backup. diff --git a/Essentials/src/messages_nl.properties b/Essentials/src/messages_nl.properties index be4037210..fc6044b6c 100644 --- a/Essentials/src/messages_nl.properties +++ b/Essentials/src/messages_nl.properties @@ -30,7 +30,8 @@ canTalkAgain = \u00a77Je kan weer praten. cantFindGeoIpDB = De GeoIP database kon niet gevonden worden! cantReadGeoIpDB = Fout bij het lezen van de GeoIP database! cantSpawnItem = \u00a7cJe bent niet bevoegd om {0} te spawnen. -commandFailed = Opdracht {0} mislukt: +commandFailed = Opdracht {0} mislukt: +commandHelpFailedForPlugin=Fout bij het \u200b\u200bkrijgen van hulp voor: {0} commandNotLoaded = \u00a7cOpdracht {0} is fout geladen. compassBearing = \u00a77Ligging: {0} ({1} graden). configFileMoveError = Het verplaatsen van config.yml naar de backup locatie is mislukt. From 50271980104e5a944baf1f417fa87beaeef810cd Mon Sep 17 00:00:00 2001 From: ementalo Date: Fri, 22 Jul 2011 23:33:33 +0100 Subject: [PATCH 07/17] minor cleanup --- .../essentials/commands/Commandhelp.java | 368 +++++++++--------- 1 file changed, 183 insertions(+), 185 deletions(-) diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandhelp.java b/Essentials/src/com/earth2me/essentials/commands/Commandhelp.java index 98f58151f..4bae61439 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandhelp.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandhelp.java @@ -1,185 +1,183 @@ -package com.earth2me.essentials.commands; - -import java.io.BufferedReader; -import java.io.File; -import java.io.FileReader; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import org.bukkit.Server; -import org.bukkit.command.CommandSender; -import org.bukkit.plugin.Plugin; -import org.bukkit.plugin.PluginDescriptionFile; -import org.yaml.snakeyaml.Yaml; -import org.yaml.snakeyaml.constructor.SafeConstructor; -import com.earth2me.essentials.User; -import com.earth2me.essentials.Util; -import java.util.Map.Entry; -import java.util.logging.Level; - - -public class Commandhelp extends EssentialsCommand -{ - public final Yaml yaml = new Yaml(new SafeConstructor()); - - public Commandhelp() - { - super("help"); - } - - @Override - protected void run(Server server, User user, String commandLabel, String[] args) throws Exception - { - int page = 1; - String match = ""; - try - { - if (args.length > 0) - { - match = args[0].toLowerCase(); - page = Integer.parseInt(args[args.length - 1]); - if (args.length == 1) - { - match = ""; - } - } - - } - catch (Exception ex) - { - if (args.length == 1) - { - match = args[0].toLowerCase(); - } - } - - List lines = getHelpLines(user, match); - if (lines.size() > 0) - { - int start = (page - 1) * 9; - int pages = lines.size() / 9 + (lines.size() % 9 > 0 ? 1 : 0); - - user.sendMessage(Util.format("helpPages", page, pages)); - for (int i = start; i < lines.size() && i < start + 9; i++) - { - user.sendMessage(lines.get(i)); - } - } - else - { - user.sendMessage(Util.i18n("noHelpFound")); - } - } - - @Override - protected void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception - { - sender.sendMessage(Util.i18n("helpConsole")); - } - - @SuppressWarnings("CallToThreadDumpStack") - private List getHelpLines(User user, String match) throws Exception - { - List retval = new ArrayList(); - File helpFile = new File(ess.getDataFolder(), "help_" + Util.sanitizeFileName(user.getName()) + ".txt"); - if (!helpFile.exists()) - { - helpFile = new File(ess.getDataFolder(), "help_" + Util.sanitizeFileName(user.getGroup()) + ".txt"); - } - if (!helpFile.exists()) - { - helpFile = new File(ess.getDataFolder(), "help.txt"); - } - if (helpFile.exists()) - { - final BufferedReader bufferedReader = new BufferedReader(new FileReader(helpFile)); - try - { - - while (bufferedReader.ready()) - { - final String line = bufferedReader.readLine(); - retval.add(line.replace('&', '§')); - } - } - finally - { - bufferedReader.close(); - } - return retval; - } - - boolean reported = false; - String pluginName = ""; - for (Plugin p : ess.getServer().getPluginManager().getPlugins()) - { - try - { - final PluginDescriptionFile desc = p.getDescription(); - final HashMap> cmds = (HashMap>)desc.getCommands(); - for (Entry> k : cmds.entrySet()) - { - if ((!match.equalsIgnoreCase("")) && (!k.getKey().toLowerCase().contains(match)) - && (!k.getValue().get("description").toLowerCase().contains(match))) - { - continue; - } - - if (p.getDescription().getName().toLowerCase().contains("essentials")) - { - final String node = "essentials." + k.getKey(); - if (!ess.getSettings().isCommandDisabled(k.getKey()) && user.isAuthorized(node)) - { - retval.add("§c" + k.getKey() + "§7: " + k.getValue().get("description")); - } - } - else - { - if (ess.getSettings().showNonEssCommandsInHelp()) - { - pluginName = p.getDescription().getName(); - final HashMap value = k.getValue(); - if (value.containsKey("permission") && value.get("permission") != null && !(value.get("permission").equals(""))) - { - if (user.isAuthorized(value.get("permission"))) - { - retval.add("§c" + k.getKey() + "§7: " + value.get("description")); - } - } - else if (value.containsKey("permissions") && value.get("permissions") != null && !(value.get("permissions").equals(""))) - { - if (user.isAuthorized(value.get("permissions"))) - { - retval.add("§c" + k.getKey() + "§7: " + value.get("description")); - } - } - else - { - if (!ess.getSettings().hidePermissionlessHelp()) - { - retval.add("§c" + k.getKey() + "§7: " + value.get("description")); - } - } - } - - } - } - } - catch (NullPointerException ex) - { - continue; - } - catch (Exception ex) - { - if (!reported) - { - // - logger.log(Level.WARNING, Util.format("commandHelpFailedForPlugin", pluginName), ex); - } - reported = true; - continue; - } - } - return retval; - } -} +package com.earth2me.essentials.commands; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileReader; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import org.bukkit.Server; +import org.bukkit.command.CommandSender; +import org.bukkit.plugin.Plugin; +import org.bukkit.plugin.PluginDescriptionFile; +import org.yaml.snakeyaml.Yaml; +import org.yaml.snakeyaml.constructor.SafeConstructor; +import com.earth2me.essentials.User; +import com.earth2me.essentials.Util; +import java.util.Map.Entry; +import java.util.logging.Level; + + +public class Commandhelp extends EssentialsCommand +{ + public final Yaml yaml = new Yaml(new SafeConstructor()); + + public Commandhelp() + { + super("help"); + } + + @Override + protected void run(Server server, User user, String commandLabel, String[] args) throws Exception + { + int page = 1; + String match = ""; + try + { + if (args.length > 0) + { + match = args[0].toLowerCase(); + page = Integer.parseInt(args[args.length - 1]); + if (args.length == 1) + { + match = ""; + } + } + } + catch (Exception ex) + { + if (args.length == 1) + { + match = args[0].toLowerCase(); + } + } + + List lines = getHelpLines(user, match); + if (lines.size() > 0) + { + int start = (page - 1) * 9; + int pages = lines.size() / 9 + (lines.size() % 9 > 0 ? 1 : 0); + + user.sendMessage(Util.format("helpPages", page, pages)); + for (int i = start; i < lines.size() && i < start + 9; i++) + { + user.sendMessage(lines.get(i)); + } + } + else + { + user.sendMessage(Util.i18n("noHelpFound")); + } + } + + @Override + protected void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception + { + sender.sendMessage(Util.i18n("helpConsole")); + } + + @SuppressWarnings("CallToThreadDumpStack") + private List getHelpLines(User user, String match) throws Exception + { + List retval = new ArrayList(); + File helpFile = new File(ess.getDataFolder(), "help_" + Util.sanitizeFileName(user.getName()) + ".txt"); + if (!helpFile.exists()) + { + helpFile = new File(ess.getDataFolder(), "help_" + Util.sanitizeFileName(user.getGroup()) + ".txt"); + } + if (!helpFile.exists()) + { + helpFile = new File(ess.getDataFolder(), "help.txt"); + } + if (helpFile.exists()) + { + final BufferedReader bufferedReader = new BufferedReader(new FileReader(helpFile)); + try + { + + while (bufferedReader.ready()) + { + final String line = bufferedReader.readLine(); + retval.add(line.replace('&', '§')); + } + } + finally + { + bufferedReader.close(); + } + return retval; + } + + boolean reported = false; + String pluginName = ""; + for (Plugin p : ess.getServer().getPluginManager().getPlugins()) + { + try + { + final PluginDescriptionFile desc = p.getDescription(); + final HashMap> cmds = (HashMap>)desc.getCommands(); + for (Entry> k : cmds.entrySet()) + { + if ((!match.equalsIgnoreCase("")) && (!k.getKey().toLowerCase().contains(match)) + && (!k.getValue().get("description").toLowerCase().contains(match))) + { + continue; + } + + if (p.getDescription().getName().toLowerCase().contains("essentials")) + { + final String node = "essentials." + k.getKey(); + if (!ess.getSettings().isCommandDisabled(k.getKey()) && user.isAuthorized(node)) + { + retval.add("§c" + k.getKey() + "§7: " + k.getValue().get("description")); + } + } + else + { + if (ess.getSettings().showNonEssCommandsInHelp()) + { + pluginName = p.getDescription().getName(); + final HashMap value = k.getValue(); + if (value.containsKey("permission") && value.get("permission") != null && !(value.get("permission").equals(""))) + { + if (user.isAuthorized(value.get("permission"))) + { + retval.add("§c" + k.getKey() + "§7: " + value.get("description")); + } + } + else if (value.containsKey("permissions") && value.get("permissions") != null && !(value.get("permissions").equals(""))) + { + if (user.isAuthorized(value.get("permissions"))) + { + retval.add("§c" + k.getKey() + "§7: " + value.get("description")); + } + } + else + { + if (!ess.getSettings().hidePermissionlessHelp()) + { + retval.add("§c" + k.getKey() + "§7: " + value.get("description")); + } + } + } + + } + } + } + catch (NullPointerException ex) + { + continue; + } + catch (Exception ex) + { + if (!reported) + { + logger.log(Level.WARNING, Util.format("commandHelpFailedForPlugin", pluginName), ex); + } + reported = true; + continue; + } + } + return retval; + } +} From fdb46f60fd4d9ce23b110285a34ea16d14d2dd82 Mon Sep 17 00:00:00 2001 From: snowleo Date: Sat, 23 Jul 2011 00:46:54 +0200 Subject: [PATCH 08/17] Add white color after each name to prevent coloration of the next name. --- .../src/com/earth2me/essentials/commands/Commandlist.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandlist.java b/Essentials/src/com/earth2me/essentials/commands/Commandlist.java index 29afb7b71..d5f946bf9 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandlist.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandlist.java @@ -102,6 +102,7 @@ public class Commandlist extends EssentialsCommand groupString.append("§7[HIDDEN]§f"); } groupString.append(user.getDisplayName()); + groupString.append("§f"); } sender.sendMessage(groupString.toString()); } @@ -142,6 +143,7 @@ public class Commandlist extends EssentialsCommand onlineUsers.append("§7[HIDDEN]§f"); } onlineUsers.append(user.getDisplayName()); + onlineUsers.append("§f"); } sender.sendMessage(onlineUsers.toString()); } From ee13d33b66c4d27f756819c59f775f3f9a7652ed Mon Sep 17 00:00:00 2001 From: snowleo Date: Sat, 23 Jul 2011 00:50:52 +0200 Subject: [PATCH 09/17] Revert "minor cleanup" This reverts commit 50271980104e5a944baf1f417fa87beaeef810cd. Don't mess with the line endings! --- .../essentials/commands/Commandhelp.java | 368 +++++++++--------- 1 file changed, 185 insertions(+), 183 deletions(-) diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandhelp.java b/Essentials/src/com/earth2me/essentials/commands/Commandhelp.java index 4bae61439..98f58151f 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandhelp.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandhelp.java @@ -1,183 +1,185 @@ -package com.earth2me.essentials.commands; - -import java.io.BufferedReader; -import java.io.File; -import java.io.FileReader; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import org.bukkit.Server; -import org.bukkit.command.CommandSender; -import org.bukkit.plugin.Plugin; -import org.bukkit.plugin.PluginDescriptionFile; -import org.yaml.snakeyaml.Yaml; -import org.yaml.snakeyaml.constructor.SafeConstructor; -import com.earth2me.essentials.User; -import com.earth2me.essentials.Util; -import java.util.Map.Entry; -import java.util.logging.Level; - - -public class Commandhelp extends EssentialsCommand -{ - public final Yaml yaml = new Yaml(new SafeConstructor()); - - public Commandhelp() - { - super("help"); - } - - @Override - protected void run(Server server, User user, String commandLabel, String[] args) throws Exception - { - int page = 1; - String match = ""; - try - { - if (args.length > 0) - { - match = args[0].toLowerCase(); - page = Integer.parseInt(args[args.length - 1]); - if (args.length == 1) - { - match = ""; - } - } - } - catch (Exception ex) - { - if (args.length == 1) - { - match = args[0].toLowerCase(); - } - } - - List lines = getHelpLines(user, match); - if (lines.size() > 0) - { - int start = (page - 1) * 9; - int pages = lines.size() / 9 + (lines.size() % 9 > 0 ? 1 : 0); - - user.sendMessage(Util.format("helpPages", page, pages)); - for (int i = start; i < lines.size() && i < start + 9; i++) - { - user.sendMessage(lines.get(i)); - } - } - else - { - user.sendMessage(Util.i18n("noHelpFound")); - } - } - - @Override - protected void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception - { - sender.sendMessage(Util.i18n("helpConsole")); - } - - @SuppressWarnings("CallToThreadDumpStack") - private List getHelpLines(User user, String match) throws Exception - { - List retval = new ArrayList(); - File helpFile = new File(ess.getDataFolder(), "help_" + Util.sanitizeFileName(user.getName()) + ".txt"); - if (!helpFile.exists()) - { - helpFile = new File(ess.getDataFolder(), "help_" + Util.sanitizeFileName(user.getGroup()) + ".txt"); - } - if (!helpFile.exists()) - { - helpFile = new File(ess.getDataFolder(), "help.txt"); - } - if (helpFile.exists()) - { - final BufferedReader bufferedReader = new BufferedReader(new FileReader(helpFile)); - try - { - - while (bufferedReader.ready()) - { - final String line = bufferedReader.readLine(); - retval.add(line.replace('&', '§')); - } - } - finally - { - bufferedReader.close(); - } - return retval; - } - - boolean reported = false; - String pluginName = ""; - for (Plugin p : ess.getServer().getPluginManager().getPlugins()) - { - try - { - final PluginDescriptionFile desc = p.getDescription(); - final HashMap> cmds = (HashMap>)desc.getCommands(); - for (Entry> k : cmds.entrySet()) - { - if ((!match.equalsIgnoreCase("")) && (!k.getKey().toLowerCase().contains(match)) - && (!k.getValue().get("description").toLowerCase().contains(match))) - { - continue; - } - - if (p.getDescription().getName().toLowerCase().contains("essentials")) - { - final String node = "essentials." + k.getKey(); - if (!ess.getSettings().isCommandDisabled(k.getKey()) && user.isAuthorized(node)) - { - retval.add("§c" + k.getKey() + "§7: " + k.getValue().get("description")); - } - } - else - { - if (ess.getSettings().showNonEssCommandsInHelp()) - { - pluginName = p.getDescription().getName(); - final HashMap value = k.getValue(); - if (value.containsKey("permission") && value.get("permission") != null && !(value.get("permission").equals(""))) - { - if (user.isAuthorized(value.get("permission"))) - { - retval.add("§c" + k.getKey() + "§7: " + value.get("description")); - } - } - else if (value.containsKey("permissions") && value.get("permissions") != null && !(value.get("permissions").equals(""))) - { - if (user.isAuthorized(value.get("permissions"))) - { - retval.add("§c" + k.getKey() + "§7: " + value.get("description")); - } - } - else - { - if (!ess.getSettings().hidePermissionlessHelp()) - { - retval.add("§c" + k.getKey() + "§7: " + value.get("description")); - } - } - } - - } - } - } - catch (NullPointerException ex) - { - continue; - } - catch (Exception ex) - { - if (!reported) - { - logger.log(Level.WARNING, Util.format("commandHelpFailedForPlugin", pluginName), ex); - } - reported = true; - continue; - } - } - return retval; - } -} +package com.earth2me.essentials.commands; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileReader; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import org.bukkit.Server; +import org.bukkit.command.CommandSender; +import org.bukkit.plugin.Plugin; +import org.bukkit.plugin.PluginDescriptionFile; +import org.yaml.snakeyaml.Yaml; +import org.yaml.snakeyaml.constructor.SafeConstructor; +import com.earth2me.essentials.User; +import com.earth2me.essentials.Util; +import java.util.Map.Entry; +import java.util.logging.Level; + + +public class Commandhelp extends EssentialsCommand +{ + public final Yaml yaml = new Yaml(new SafeConstructor()); + + public Commandhelp() + { + super("help"); + } + + @Override + protected void run(Server server, User user, String commandLabel, String[] args) throws Exception + { + int page = 1; + String match = ""; + try + { + if (args.length > 0) + { + match = args[0].toLowerCase(); + page = Integer.parseInt(args[args.length - 1]); + if (args.length == 1) + { + match = ""; + } + } + + } + catch (Exception ex) + { + if (args.length == 1) + { + match = args[0].toLowerCase(); + } + } + + List lines = getHelpLines(user, match); + if (lines.size() > 0) + { + int start = (page - 1) * 9; + int pages = lines.size() / 9 + (lines.size() % 9 > 0 ? 1 : 0); + + user.sendMessage(Util.format("helpPages", page, pages)); + for (int i = start; i < lines.size() && i < start + 9; i++) + { + user.sendMessage(lines.get(i)); + } + } + else + { + user.sendMessage(Util.i18n("noHelpFound")); + } + } + + @Override + protected void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception + { + sender.sendMessage(Util.i18n("helpConsole")); + } + + @SuppressWarnings("CallToThreadDumpStack") + private List getHelpLines(User user, String match) throws Exception + { + List retval = new ArrayList(); + File helpFile = new File(ess.getDataFolder(), "help_" + Util.sanitizeFileName(user.getName()) + ".txt"); + if (!helpFile.exists()) + { + helpFile = new File(ess.getDataFolder(), "help_" + Util.sanitizeFileName(user.getGroup()) + ".txt"); + } + if (!helpFile.exists()) + { + helpFile = new File(ess.getDataFolder(), "help.txt"); + } + if (helpFile.exists()) + { + final BufferedReader bufferedReader = new BufferedReader(new FileReader(helpFile)); + try + { + + while (bufferedReader.ready()) + { + final String line = bufferedReader.readLine(); + retval.add(line.replace('&', '§')); + } + } + finally + { + bufferedReader.close(); + } + return retval; + } + + boolean reported = false; + String pluginName = ""; + for (Plugin p : ess.getServer().getPluginManager().getPlugins()) + { + try + { + final PluginDescriptionFile desc = p.getDescription(); + final HashMap> cmds = (HashMap>)desc.getCommands(); + for (Entry> k : cmds.entrySet()) + { + if ((!match.equalsIgnoreCase("")) && (!k.getKey().toLowerCase().contains(match)) + && (!k.getValue().get("description").toLowerCase().contains(match))) + { + continue; + } + + if (p.getDescription().getName().toLowerCase().contains("essentials")) + { + final String node = "essentials." + k.getKey(); + if (!ess.getSettings().isCommandDisabled(k.getKey()) && user.isAuthorized(node)) + { + retval.add("§c" + k.getKey() + "§7: " + k.getValue().get("description")); + } + } + else + { + if (ess.getSettings().showNonEssCommandsInHelp()) + { + pluginName = p.getDescription().getName(); + final HashMap value = k.getValue(); + if (value.containsKey("permission") && value.get("permission") != null && !(value.get("permission").equals(""))) + { + if (user.isAuthorized(value.get("permission"))) + { + retval.add("§c" + k.getKey() + "§7: " + value.get("description")); + } + } + else if (value.containsKey("permissions") && value.get("permissions") != null && !(value.get("permissions").equals(""))) + { + if (user.isAuthorized(value.get("permissions"))) + { + retval.add("§c" + k.getKey() + "§7: " + value.get("description")); + } + } + else + { + if (!ess.getSettings().hidePermissionlessHelp()) + { + retval.add("§c" + k.getKey() + "§7: " + value.get("description")); + } + } + } + + } + } + } + catch (NullPointerException ex) + { + continue; + } + catch (Exception ex) + { + if (!reported) + { + // + logger.log(Level.WARNING, Util.format("commandHelpFailedForPlugin", pluginName), ex); + } + reported = true; + continue; + } + } + return retval; + } +} From 40a2bccf2dbeb84b19e601bd47cfb3fa88951e37 Mon Sep 17 00:00:00 2001 From: snowleo Date: Sat, 23 Jul 2011 00:53:55 +0200 Subject: [PATCH 10/17] Now the cleanup --- Essentials/src/com/earth2me/essentials/commands/Commandhelp.java | 1 - 1 file changed, 1 deletion(-) diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandhelp.java b/Essentials/src/com/earth2me/essentials/commands/Commandhelp.java index 98f58151f..07945b75b 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandhelp.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandhelp.java @@ -173,7 +173,6 @@ public class Commandhelp extends EssentialsCommand { if (!reported) { - // logger.log(Level.WARNING, Util.format("commandHelpFailedForPlugin", pluginName), ex); } reported = true; From 7001798874801166f04b074b1c8277ae328a2e14 Mon Sep 17 00:00:00 2001 From: snowleo Date: Sat, 23 Jul 2011 01:03:45 +0200 Subject: [PATCH 11/17] Don't give out a full stack on /unlimited, instead either 2 or 1, if the max stack size is 1 --- .../src/com/earth2me/essentials/commands/Commandunlimited.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandunlimited.java b/Essentials/src/com/earth2me/essentials/commands/Commandunlimited.java index cc8c7e128..3c79df4cb 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandunlimited.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandunlimited.java @@ -56,7 +56,7 @@ public class Commandunlimited extends EssentialsCommand } final ItemStack stack = ess.getItemDb().get(args[0], 1); - stack.setAmount(stack.getType().getMaxStackSize()); + stack.setAmount(Math.min(stack.getType().getMaxStackSize(), 2)); String itemname = stack.getType().toString().toLowerCase().replace("_", ""); if (!user.isAuthorized("essentials.unlimited.item-all") From 979592c8bac87854333dfa95f2df945fe50142c3 Mon Sep 17 00:00:00 2001 From: snowleo Date: Sat, 23 Jul 2011 01:10:22 +0200 Subject: [PATCH 12/17] Missing space in Spawnmob message --- .../src/com/earth2me/essentials/commands/Commandspawnmob.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandspawnmob.java b/Essentials/src/com/earth2me/essentials/commands/Commandspawnmob.java index c15fd6656..a2af502ee 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandspawnmob.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandspawnmob.java @@ -164,7 +164,7 @@ public class Commandspawnmob extends EssentialsCommand changeMobData(mobMount.name, spawnedMount, mountData, user); } } - user.sendMessage(args[1] + " " + mob.name.toLowerCase() + mob.suffix + Util.i18n("spawned")); + user.sendMessage(args[1] + " " + mob.name.toLowerCase() + mob.suffix + " " + Util.i18n("spawned")); } catch (MobException e1) { From b2e32900381dd590691db56f527cbd09f661d93a Mon Sep 17 00:00:00 2001 From: snowleo Date: Sat, 23 Jul 2011 01:13:55 +0200 Subject: [PATCH 13/17] Removed quotes from translation files --- Essentials/src/messages.properties | 4 ++-- Essentials/src/messages_da.properties | 4 ++-- Essentials/src/messages_de.properties | 4 ++-- Essentials/src/messages_en.properties | 4 ++-- Essentials/src/messages_fr.properties | 2 +- Essentials/src/messages_nl.properties | 4 ++-- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Essentials/src/messages.properties b/Essentials/src/messages.properties index 75125a121..3691f2a83 100644 --- a/Essentials/src/messages.properties +++ b/Essentials/src/messages.properties @@ -191,7 +191,7 @@ noKitPermission = \u00a7cYou need the \u00a7c{0}\u00a7c permission to use that k noKits = \u00a77There are no kits available yet noMail = You do not have any mail noMailSendPerm = \u00a7cYou do not have the \u00a7fessentials.mail.send\u00a7c permission. -noMotd = \u00a7cThere is no message of the day." +noMotd = \u00a7cThere is no message of the day. noNewMail = \u00a77You have no new mail. noPendingRequest = You do not have a pending request. noPlacePermission = \u00a7cYou do not have permission to place a block near that sign. @@ -220,7 +220,7 @@ playerMuted = \u00a77You have been muted playerMutedFor = \u00a77You have been muted for {0} playerNeverOnServer = \u00a7cPlayer {0} was never on this server. playerNotFound = \u00a7cPlayer not found. -playerUnmuted = "\u00a77You have been unmuted" +playerUnmuted = \u00a77You have been unmuted pong = Pong! possibleWorlds = \u00a77Possible worlds are the numbers 0 through {0}. powerToolAir = Command can''t be attached to air. diff --git a/Essentials/src/messages_da.properties b/Essentials/src/messages_da.properties index f57224d0f..13f68b5db 100644 --- a/Essentials/src/messages_da.properties +++ b/Essentials/src/messages_da.properties @@ -193,7 +193,7 @@ noKitPermission = \u00a7cDu har brug for \u00a7c{0}\u00a7c tilladelsen for at br noKits = \u00a77Der er ikke nogen pakker tilg\u00e6ngelig endnu noMail = Du har ikke noget post noMailSendPerm = \u00a7cDu har ikke \u00a7fessentials.mail.send\u00a7c tilladelsen. -noMotd = \u00a7cDer er ikke nogen besked for dagen." +noMotd = \u00a7cDer er ikke nogen besked for dagen. noNewMail = \u00a77Du har ingen ny post. noPendingRequest = Du har ikke en ventende anmodning. noPlacePermission = \u00a7cYou do not have permission to place a block near that sign. @@ -222,7 +222,7 @@ playerMuted = \u00a77You have been muted playerMutedFor = \u00a77You have been muted for {0} playerNeverOnServer = \u00a7cSpiller {0} var aldrig p\u00e5 denne server. playerNotFound = \u00a7cSpiller ikke fundet. -playerUnmuted = "\u00a77You have been unmuted" +playerUnmuted = \u00a77You have been unmuted pong = Pong! possibleWorlds = \u00a77Mulige verdener er numrene 0 igennem {0}. powerToolAir = Kommando kan ikke blive tildelt luft. diff --git a/Essentials/src/messages_de.properties b/Essentials/src/messages_de.properties index 992c36b7c..67a91e084 100644 --- a/Essentials/src/messages_de.properties +++ b/Essentials/src/messages_de.properties @@ -191,7 +191,7 @@ noKitPermission = \u00a7cDu brauchst die Berechtigung \u00a7c{0}\u00a7c um diese noKits = \u00a77Es sind keine Ausr\u00fcstungen verf\u00fcgbar. noMail = Du hast keine Nachrichten noMailSendPerm = \u00a7cDu hast die Rechte \u00a7fessentials.mail.send\u00a7c nicht. -noMotd = \u00a7cEs existiert keine Willkommensnachricht." +noMotd = \u00a7cEs existiert keine Willkommensnachricht. noNewMail = \u00a77Du hast keine Nachrichten. noPendingRequest = Du hast keine Teleportierungsanfragen. noPlacePermission = \u00a7cDu hast keine Rechte, einen Block in der N\u00e4he des Schildes zu platzieren. @@ -220,7 +220,7 @@ playerMuted = \u00a77You have been muted playerMutedFor = \u00a77You have been muted for {0} playerNeverOnServer = \u00a7cSpieler {0} war niemals auf diesem Server. playerNotFound = \u00a7cSpieler nicht gefunden. -playerUnmuted = "\u00a77You have been unmuted" +playerUnmuted = \u00a77Du bist nicht mehr stumm. pong = Pong! possibleWorlds = \u00a77M\u00f6gliche Welten sind nummeriet von 0 bis {0}. powerToolAir = Befehl kann nicht mit Luft verbunden werden. diff --git a/Essentials/src/messages_en.properties b/Essentials/src/messages_en.properties index 97cdd57b1..38b84bb93 100644 --- a/Essentials/src/messages_en.properties +++ b/Essentials/src/messages_en.properties @@ -191,7 +191,7 @@ noKitPermission = \u00a7cYou need the \u00a7c{0}\u00a7c permission to use that k noKits = \u00a77There are no kits available yet noMail = You do not have any mail noMailSendPerm = \u00a7cYou do not have the \u00a7fessentials.mail.send\u00a7c permission. -noMotd = \u00a7cThere is no message of the day." +noMotd = \u00a7cThere is no message of the day. noNewMail = \u00a77You have no new mail. noPendingRequest = You do not have a pending request. noPlacePermission = \u00a7cYou do not have permission to place a block near that sign. @@ -220,7 +220,7 @@ playerMuted = \u00a77You have been muted playerMutedFor = \u00a77You have been muted for {0} playerNeverOnServer = \u00a7cPlayer {0} was never on this server. playerNotFound = \u00a7cPlayer not found. -playerUnmuted = "\u00a77You have been unmuted" +playerUnmuted = \u00a77You have been unmuted pong = Pong! possibleWorlds = \u00a77Possible worlds are the numbers 0 through {0}. powerToolAir = Command can''t be attached to air. diff --git a/Essentials/src/messages_fr.properties b/Essentials/src/messages_fr.properties index 09ae9bc12..e240b43af 100644 --- a/Essentials/src/messages_fr.properties +++ b/Essentials/src/messages_fr.properties @@ -220,7 +220,7 @@ playerMuted = \u00a77You have been muted playerMutedFor = \u00a77You have been muted for {0} playerNeverOnServer = \u00a7cLe joueur {0} n''a jamais \u00e9t\u00e9 sur le serveur. playerNotFound = \u00a7cLe joueur est introuvable. -playerUnmuted = "\u00a77You have been unmuted" +playerUnmuted = \u00a77You have been unmuted pong = Pong! possibleWorlds = \u00a77Les mondes possibles sont les nombres 0 par {0}. powerToolAir = La commande ne peut pas \u00eatre attach\u00e9e \u00e0 l''air. diff --git a/Essentials/src/messages_nl.properties b/Essentials/src/messages_nl.properties index fc6044b6c..658897b2a 100644 --- a/Essentials/src/messages_nl.properties +++ b/Essentials/src/messages_nl.properties @@ -192,7 +192,7 @@ noKitPermission = \u00a7cJe hebt de \u00a7c{0}\u00a7c toestemming nodig om die k noKits = \u00a77Er zijn nog geen kits beschikbaar noMail = Je hebt geen berichten noMailSendPerm = \u00a7cJe hebt de \u00a7fessentials.mail.send\u00a7c toestemming niet. -noMotd = \u00a7cEr is geen bericht van de dag." +noMotd = \u00a7cEr is geen bericht van de dag. noNewMail = \u00a77Je hebt geen nieuwe berichten. noPendingRequest = Je hebt geen aanvragen. noPlacePermission = \u00a7cYou do not have permission to place a block near that sign. @@ -221,7 +221,7 @@ playerMuted = \u00a77You have been muted playerMutedFor = \u00a77You have been muted for {0} playerNeverOnServer = \u00a7cSpeler {0} is nooit op deze server geweest. playerNotFound = \u00a7cSpeler niet gevonden. -playerUnmuted = "\u00a77You have been unmuted" +playerUnmuted = \u00a77You have been unmuted pong = Pong! possibleWorlds = \u00a77Mogelijk zijn de werelden de nummer 0 tot en met {0}. powerToolAir = Command kan niet worden bevestigd aan de lucht. From a20f2b71da49ac1c65fd577be2264ae14a85367c Mon Sep 17 00:00:00 2001 From: snowleo Date: Sat, 23 Jul 2011 01:29:31 +0200 Subject: [PATCH 14/17] Added more default permissions for players to config.yml --- Essentials/src/config.yml | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/Essentials/src/config.yml b/Essentials/src/config.yml index 7aaec6027..ea40bd87d 100644 --- a/Essentials/src/config.yml +++ b/Essentials/src/config.yml @@ -117,7 +117,8 @@ disabled-commands: # Restricted commands have been removed. # Now we have a whitelist, all commands not on this list are only available to ops. # These will have NO EFFECT if you have Permissions installed! -# These are here only if you want something simpler than Permissions. +# They are here only if you want something simpler than Permissions. +# These are the permissions without the "essentials." part. player-commands: - afk - back @@ -127,6 +128,7 @@ player-commands: - compass - depth - getpos + - geoip.show - help - helpop - home @@ -143,13 +145,31 @@ player-commands: - nick - pay - ping + - portal - powertool + - protect - r - rules - seen - sell - sethome - setxmpp + - signs.create.protection + - signs.create.trade + - signs.break.protection + - signs.break.trade + - signs.use.balance + - signs.use.buy + - signs.use.disposal + - signs.use.free + - signs.use.heal + - signs.use.mail + - signs.use.protection + - signs.use.sell + - signs.use.time + - signs.use.trade + - signs.use.warp + - signs.use.weather - spawn - suicide - tpa @@ -157,6 +177,7 @@ player-commands: - tpahere - tpdeny - warp + - warp.list - world - worth - xmpp From 3cedfeef2c0afe0b7b428a7e26a560e04529aae3 Mon Sep 17 00:00:00 2001 From: snowleo Date: Sat, 23 Jul 2011 01:43:02 +0200 Subject: [PATCH 15/17] Separate config setting for prefix/suffix --- .../src/com/earth2me/essentials/ISettings.java | 2 ++ .../src/com/earth2me/essentials/Settings.java | 5 +++++ .../src/com/earth2me/essentials/User.java | 17 ++++++++++------- Essentials/src/config.yml | 5 +++++ 4 files changed, 22 insertions(+), 7 deletions(-) diff --git a/Essentials/src/com/earth2me/essentials/ISettings.java b/Essentials/src/com/earth2me/essentials/ISettings.java index c53992461..13717f469 100644 --- a/Essentials/src/com/earth2me/essentials/ISettings.java +++ b/Essentials/src/com/earth2me/essentials/ISettings.java @@ -130,4 +130,6 @@ public interface ISettings extends IConf boolean isPlayerCommand(String string); public boolean useBukkitPermissions(); + + public boolean addPrefixSuffix(); } diff --git a/Essentials/src/com/earth2me/essentials/Settings.java b/Essentials/src/com/earth2me/essentials/Settings.java index 9f4bde9e0..63e017bf5 100644 --- a/Essentials/src/com/earth2me/essentials/Settings.java +++ b/Essentials/src/com/earth2me/essentials/Settings.java @@ -468,4 +468,9 @@ public class Settings implements ISettings { return config.getBoolean("use-bukkit-permissions", false); } + + public boolean addPrefixSuffix() + { + return config.getBoolean("add-prefix-suffix", false); + } } diff --git a/Essentials/src/com/earth2me/essentials/User.java b/Essentials/src/com/earth2me/essentials/User.java index b1392a2e6..a0b072752 100644 --- a/Essentials/src/com/earth2me/essentials/User.java +++ b/Essentials/src/com/earth2me/essentials/User.java @@ -246,14 +246,17 @@ public class User extends UserData implements Comparable, IReplyTo, IUser } } - final String prefix = ess.getPermissionsHandler().getPrefix(this).replace('&', '§').replace("{WORLDNAME}", this.getWorld().getName()); - final String suffix = ess.getPermissionsHandler().getSuffix(this).replace('&', '§').replace("{WORLDNAME}", this.getWorld().getName()); - - nickname.insert(0, prefix); - nickname.append(suffix); - if (suffix.length() < 2 || !suffix.substring(suffix.length() - 2, suffix.length() - 1).equals("§")) + if (ess.getSettings().addPrefixSuffix()) { - nickname.append("§f"); + final String prefix = ess.getPermissionsHandler().getPrefix(this).replace('&', '§').replace("{WORLDNAME}", this.getWorld().getName()); + final String suffix = ess.getPermissionsHandler().getSuffix(this).replace('&', '§').replace("{WORLDNAME}", this.getWorld().getName()); + + nickname.insert(0, prefix); + nickname.append(suffix); + if (suffix.length() < 2 || !suffix.substring(suffix.length() - 2, suffix.length() - 1).equals("§")) + { + nickname.append("§f"); + } } return nickname.toString(); diff --git a/Essentials/src/config.yml b/Essentials/src/config.yml index ea40bd87d..186d4a1f0 100644 --- a/Essentials/src/config.yml +++ b/Essentials/src/config.yml @@ -37,6 +37,11 @@ nickname-prefix: '~' # Disable this if you have any other plugin, that modifies the displayname of a user. change-displayname: true +# Adds the prefix and suffix to the displayname of the player, so it will be displayed in messages and lists. +# The prefix/suffix can be set using Permissions, Group Manager or PermissionsEx. +# The value of change-displayname (above) has to be true. +add-prefix-suffix: false + # The delay, in seconds, required between /home, /tp, etc. teleport-cooldown: 0 From 0e21d3287e46543aaa95186d68aef556359b874d Mon Sep 17 00:00:00 2001 From: snowleo Date: Sat, 23 Jul 2011 02:06:13 +0200 Subject: [PATCH 16/17] Fix Util.getSafeDestination() to use int instead of double. --- .../src/com/earth2me/essentials/Util.java | 44 +++++++++---------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/Essentials/src/com/earth2me/essentials/Util.java b/Essentials/src/com/earth2me/essentials/Util.java index 97f051db4..6e772a252 100644 --- a/Essentials/src/com/earth2me/essentials/Util.java +++ b/Essentials/src/com/earth2me/essentials/Util.java @@ -216,21 +216,21 @@ public class Util return c.getTimeInMillis(); } - public static Location getSafeDestination(Location loc) throws Exception + public static Location getSafeDestination(final Location loc) throws Exception { if (loc == null || loc.getWorld() == null) { throw new Exception(Util.i18n("destinationNotSet")); } - World world = loc.getWorld(); - double x = Math.floor(loc.getX()) + 0.5; - double y = Math.floor(loc.getY()); - double z = Math.floor(loc.getZ()) + 0.5; + final World world = loc.getWorld(); + int x = loc.getBlockX(); + int y = loc.getBlockY(); + int z = loc.getBlockZ(); while (isBlockAboveAir(world, x, y, z)) { - y -= 1.0D; - if (y < 0.0D) + y -= 1; + if (y < 0) { throw new Exception(Util.i18n("holeInFloor")); } @@ -238,33 +238,33 @@ public class Util while (isBlockUnsafe(world, x, y, z)) { - y += 1.0D; - if (y >= 110.0D) + y += 1; + if (y >= 127) { - x += 1.0D; + x += 1; break; } } while (isBlockUnsafe(world, x, y, z)) { - y -= 1.0D; - if (y <= 1.0D) + y -= 1; + if (y <= 1) { - y = 110.0D; - x += 1.0D; + y = 127; + x += 1; } } - return new Location(world, x, y, z, loc.getYaw(), loc.getPitch()); + return new Location(world, x + 0.5D, y, z + 0.5D, loc.getYaw(), loc.getPitch()); } - private static boolean isBlockAboveAir(World world, double x, double y, double z) + private static boolean isBlockAboveAir(final World world, final int x, final int y, final int z) { - return world.getBlockAt((int)Math.floor(x), (int)Math.floor(y - 1.0D), (int)Math.floor(z)).getType() == Material.AIR; + return world.getBlockAt(x, y - 1, z).getType() == Material.AIR; } - public static boolean isBlockUnsafe(World world, double x, double y, double z) + public static boolean isBlockUnsafe(final World world, final int x, final int y, final int z) { - Block below = world.getBlockAt((int)Math.floor(x), (int)Math.floor(y - 1.0D), (int)Math.floor(z)); + final Block below = world.getBlockAt(x, y - 1, z); if (below.getType() == Material.LAVA || below.getType() == Material.STATIONARY_LAVA) { return true; @@ -275,8 +275,8 @@ public class Util return true; } - if ((world.getBlockAt((int)Math.floor(x), (int)Math.floor(y), (int)Math.floor(z)).getType() != Material.AIR) - || (world.getBlockAt((int)Math.floor(x), (int)Math.floor(y + 1.0D), (int)Math.floor(z)).getType() != Material.AIR)) + if ((world.getBlockAt(x, y, z).getType() != Material.AIR) + || (world.getBlockAt(x, y + 1, z).getType() != Material.AIR)) { return true; } @@ -294,7 +294,7 @@ public class Util return str; } - public static double roundDouble(double d) + public static double roundDouble(final double d) { return Math.round(d * 100.0) / 100.0; } From 0f3c0e82f23a700c79e752592d5c01a42f7bcbbe Mon Sep 17 00:00:00 2001 From: snowleo Date: Sat, 23 Jul 2011 02:07:25 +0200 Subject: [PATCH 17/17] Readded some code, so that the user is not checked, if he is next to himself. --- .../earth2me/essentials/chat/EssentialsChatPlayerListener.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChatPlayerListener.java b/EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChatPlayerListener.java index bb5443a26..6b3039d0b 100644 --- a/EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChatPlayerListener.java +++ b/EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChatPlayerListener.java @@ -101,7 +101,7 @@ public class EssentialsChatPlayerListener extends PlayerListener { continue; } - if (!u.isAuthorized("essentials.chat.spy")) + if (!u.equals(user) && !u.isAuthorized("essentials.chat.spy")) { final Location l = u.getLocation(); final int dx = x - l.getBlockX();