From 42872650d25c1403ef9e6c435819f6e8c50a2c60 Mon Sep 17 00:00:00 2001 From: KHobbits Date: Fri, 16 Nov 2012 01:35:35 +0000 Subject: [PATCH 1/4] Add tptoggle others Essentials style. --- .../essentials/commands/Commandtptoggle.java | 61 ++++++++++++++----- Essentials/src/messages.properties | 2 + Essentials/src/messages_cs.properties | 2 + Essentials/src/messages_da.properties | 2 + Essentials/src/messages_de.properties | 2 + Essentials/src/messages_en.properties | 2 + Essentials/src/messages_es.properties | 6 +- Essentials/src/messages_fi.properties | 2 + Essentials/src/messages_fr.properties | 10 +-- Essentials/src/messages_it.properties | 2 + Essentials/src/messages_nl.properties | 2 + Essentials/src/messages_pl.properties | 2 + Essentials/src/messages_pt.properties | 2 + Essentials/src/messages_se.properties | 2 + Essentials/src/plugin.yml | 2 +- 15 files changed, 80 insertions(+), 21 deletions(-) diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtptoggle.java b/Essentials/src/com/earth2me/essentials/commands/Commandtptoggle.java index 6a17de81a..769060980 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandtptoggle.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandtptoggle.java @@ -3,6 +3,8 @@ package com.earth2me.essentials.commands; import static com.earth2me.essentials.I18n._; import com.earth2me.essentials.User; import org.bukkit.Server; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; public class Commandtptoggle extends EssentialsCommand @@ -12,29 +14,60 @@ public class Commandtptoggle extends EssentialsCommand super("tptoggle"); } + @Override + public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception + { + if (args.length < 1) + { + throw new NotEnoughArgumentsException(); + } + + toggleOtherPlayers(server, sender, args); + } + @Override public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception { - User otherUser = null; - if (args.length > 0 && user.isAuthorized("essentials.tptoggle.others")) + if (args.length > 0 && args[0].trim().length() > 2 && user.isAuthorized("essentials.tptoggle.others")) { - otherUser = ess.getUser(server.getPlayer(args[0])); - if (otherUser == null) + toggleOtherPlayers(server, user, args); + return; + } + + user.sendMessage(user.toggleTeleportEnabled() ? _("teleportationEnabled") : _("teleportationDisabled")); + } + + private void toggleOtherPlayers(final Server server, final CommandSender sender, final String[] args) + { + for (Player matchPlayer : server.matchPlayer(args[0])) + { + final User player = ess.getUser(matchPlayer); + if (player.isHidden()) + { + continue; + } + + if (args.length > 1) + { + if (args[1].contains("on") || args[1].contains("ena") || args[1].equalsIgnoreCase("1")) { - throw new Exception(_("playerNotFound")); + player.setTeleportEnabled(true); } else { - ess.getUser(server.getPlayer(args[0])).sendMessage(user.toggleTeleportEnabled() - ? _("teleportationEnabled") - : _("teleportationDisabled")); + player.setTeleportEnabled(false); } - } - else - { - user.sendMessage(user.toggleTeleportEnabled() - ? _("teleportationEnabled") - : _("teleportationDisabled")); + } + else + { + player.toggleTeleportEnabled(); + } + + final boolean enabled = player.isTeleportEnabled(); + + + player.sendMessage(enabled ? _("teleportationEnabled") : _("teleportationDisabled")); + sender.sendMessage(enabled ? _("teleportationEnabledFor", matchPlayer.getDisplayName()) : _("teleportationDisabledFor", matchPlayer.getDisplayName())); } } } diff --git a/Essentials/src/messages.properties b/Essentials/src/messages.properties index ea780bb03..c7170ae0b 100644 --- a/Essentials/src/messages.properties +++ b/Essentials/src/messages.properties @@ -460,3 +460,5 @@ gcWorld=\u00a76{0} "\u00a7c{1}\u00a76": \u00a7c{2}\u00a76 chunks, \u00a7c{3}\u00 invalidHomeName=\u00a74Invalid home name invalidWarpName=\u00a74Invalid warp name userUnknown=\u00a74Warning: The user '\u00a7c{0}\u00a74' has never joined this server. +teleportationEnabledFor=\u00a76Teleportation enabled for {0} +teleportationDisabledFor=\u00a76Teleportation disabled for {0} diff --git a/Essentials/src/messages_cs.properties b/Essentials/src/messages_cs.properties index f8eccb7f9..6eef42338 100644 --- a/Essentials/src/messages_cs.properties +++ b/Essentials/src/messages_cs.properties @@ -463,3 +463,5 @@ gcWorld=\u00a76{0} "\u00a7c{1}\u00a76": \u00a7c{2}\u00a76 chunks, \u00a7c{3}\u00 invalidHomeName=\u00a74Invalid home name invalidWarpName=\u00a74Invalid warp name userUnknown=\u00a74Warning: The user '\u00a7c{0}\u00a74' has never joined this server. +teleportationEnabledFor=\u00a76Teleportation enabled for {0} +teleportationDisabledFor=\u00a76Teleportation disabled for {0} diff --git a/Essentials/src/messages_da.properties b/Essentials/src/messages_da.properties index 06339f3b6..45329febb 100644 --- a/Essentials/src/messages_da.properties +++ b/Essentials/src/messages_da.properties @@ -460,3 +460,5 @@ gcWorld=\u00a76{0} "\u00a7c{1}\u00a76": \u00a7c{2}\u00a76 chunks, \u00a7c{3}\u00 invalidHomeName=\u00a74Invalid home name invalidWarpName=\u00a74Invalid warp name userUnknown=\u00a74Warning: The user '\u00a7c{0}\u00a74' has never joined this server. +teleportationEnabledFor=\u00a76Teleportation enabled for {0} +teleportationDisabledFor=\u00a76Teleportation disabled for {0} diff --git a/Essentials/src/messages_de.properties b/Essentials/src/messages_de.properties index 487fbf85b..b8f087cd7 100644 --- a/Essentials/src/messages_de.properties +++ b/Essentials/src/messages_de.properties @@ -460,3 +460,5 @@ gcWorld=\u00a76{0} "\u00a7c{1}\u00a76": \u00a7c{2}\u00a76 chunks, \u00a7c{3}\u00 invalidHomeName=\u00a74Invalid home name invalidWarpName=\u00a74Invalid warp name userUnknown=\u00a74Warning: The user '\u00a7c{0}\u00a74' has never joined this server. +teleportationEnabledFor=\u00a76Teleportation enabled for {0} +teleportationDisabledFor=\u00a76Teleportation disabled for {0} diff --git a/Essentials/src/messages_en.properties b/Essentials/src/messages_en.properties index ea780bb03..c7170ae0b 100644 --- a/Essentials/src/messages_en.properties +++ b/Essentials/src/messages_en.properties @@ -460,3 +460,5 @@ gcWorld=\u00a76{0} "\u00a7c{1}\u00a76": \u00a7c{2}\u00a76 chunks, \u00a7c{3}\u00 invalidHomeName=\u00a74Invalid home name invalidWarpName=\u00a74Invalid warp name userUnknown=\u00a74Warning: The user '\u00a7c{0}\u00a74' has never joined this server. +teleportationEnabledFor=\u00a76Teleportation enabled for {0} +teleportationDisabledFor=\u00a76Teleportation disabled for {0} diff --git a/Essentials/src/messages_es.properties b/Essentials/src/messages_es.properties index cd6d1208c..a2dec7c90 100644 --- a/Essentials/src/messages_es.properties +++ b/Essentials/src/messages_es.properties @@ -251,7 +251,7 @@ noPendingRequest=No tienes ninguna peticion pendiente. noPerm=\u00a7cNo tienes el permiso de \u00a7f{0}\u00a7c. noPermToSpawnMob=\u00a7cNo tienes permisos para spawnear a este mob. noPlacePermission=\u00a7cNo tienes permiso para situar ese bloque en ese lugar. -noPowerTools=Usted no tiene ningunas herramientas eléctricas asignadas. +noPowerTools=Usted no tiene ningunas herramientas el\u00c3\u00a9ctricas asignadas. noRules=\u00a7cNo hay reglas especificadas todavia. noWarpsDefined=No hay teletransportes definidos aun. none=ninguno @@ -448,7 +448,7 @@ youHaveNewMail=\u00a7cTienes {0} mensajes!\u00a7f Pon \u00a77/mail read\u00a7f p posX=\u00a76X: {0} (+Este <-> -Oeste) posY=\u00a76Y: {0} (+Arriba <-> -abajo) posZ=\u00a76Z: {0} (+Sur <-> -Norte) -posYaw=\u00a76guiñar: {0} (Rotacion) +posYaw=\u00a76gui\u00c3\u00b1ar: {0} (Rotacion) posPitch=\u00a76Tono: {0} (Angulo de cabeza) distance=\u00a76Distancia: {0} giveSpawn=\u00a76Se a dado\u00a7c {0} \u00a76de\u00a7c {1} a\u00a7c {2}\u00a76. @@ -460,3 +460,5 @@ gcWorld=\u00a76{0} "\u00a7c{1}\u00a76": \u00a7c{2}\u00a76 chunks, \u00a7c{3}\u00 invalidHomeName=\u00a74Nombre de casa invalido invalidWarpName=\u00a74Nombre de warp invalido userUnknown=\u00a74Peligro: El jugador '\u00a7c{0}\u00a74' Nunca a ingresado a este servidor. +teleportationEnabledFor=\u00a76Teleportation enabled for {0} +teleportationDisabledFor=\u00a76Teleportation disabled for {0} diff --git a/Essentials/src/messages_fi.properties b/Essentials/src/messages_fi.properties index 3ff85ebfb..ff9df7257 100644 --- a/Essentials/src/messages_fi.properties +++ b/Essentials/src/messages_fi.properties @@ -460,3 +460,5 @@ gcWorld=\u00a76{0} "\u00a7c{1}\u00a76": \u00a7c{2}\u00a76 chunks, \u00a7c{3}\u00 invalidHomeName=\u00a74Invalid home name invalidWarpName=\u00a74Invalid warp name userUnknown=\u00a74Warning: The user '\u00a7c{0}\u00a74' has never joined this server. +teleportationEnabledFor=\u00a76Teleportation enabled for {0} +teleportationDisabledFor=\u00a76Teleportation disabled for {0} diff --git a/Essentials/src/messages_fr.properties b/Essentials/src/messages_fr.properties index 605c0b884..fb858afe2 100644 --- a/Essentials/src/messages_fr.properties +++ b/Essentials/src/messages_fr.properties @@ -35,7 +35,7 @@ burnMsg=\u00a77Vous avez enflamm\u00e9 {0} pour {1} seconde(s). 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\u00e9es GeoIP! -cantSpawnItem=\u00a7cVous n''avez pas le droit de faire appara\u00eEtre {0} +cantSpawnItem=\u00a7cVous n''avez pas le droit de faire appara\u00eetre {0} chatTypeAdmin=[A] chatTypeLocal=[L] chatTypeSpy=[Spy] @@ -91,7 +91,7 @@ essentialsHelp2=Le fichier est corrompuet Essentials ne peut l'ouvrir. Essential essentialsReload=\u00a77Essentials {0} a \u00e9t\u00e9 recharg\u00e9. exp=\u00a7c{0} \u00a77a\u00a7c {1} \u00a77exp (niveau\u00a7c {2}\u00a77) et a besoin de\u00a7c {3} \u00a77pour monter d'un niveau. expSet=\u00a7c{0} \u00a77a maintenant\u00a7c {1} \u00a77exp. -extinguish=\u00a77Vous cessez de br\u00FBler. +extinguish=\u00a77Vous cessez de br\u00fbler. extinguishOthers=\u00a77Vous avez \u00e9teint la combustion de {0}. failedToCloseConfig=Echec de la fermeture de la configuration {0} failedToCreateConfig=Echec de la cr\u00e9ation de la configuration {0} @@ -142,7 +142,7 @@ infoChapterPages=Chapitre {0}, page \u00a7c{1}\u00a7f sur \u00a7c{2}\u00a7f: infoFileDoesNotExist=Le fichier info.txt n'existe pas. Le fichier est en cours de cr\u00e9ation pour vous. infoPages=\u00a7e ---- \u00a76{2} \u00a7e--\u00a76 Page \u00a74{0}\u00a76/\u00a74{1} \u00a7e---- infoUnknownChapter=Chapitre inconnu. -invBigger=Les inventaires des autres joueurs sont plus gros que le v\u00F4tre. +invBigger=Les inventaires des autres joueurs sont plus gros que le v\u00f4tre. invRestored=Votre inventaire vous a \u00e9t\u00e9 rendu. invSee=Vous voyez l''inventaire de {0}. invSeeHelp=Utilisez /invsee pour revenir \u00e0 votre inventaire. @@ -459,4 +459,6 @@ antiBuildDrop=\u00a74Vous n'\u00eates pas autoris\u00e9s \u00e0 jeter\u00a7c {0} gcWorld=\u00a76{0} "\u00a7c{1}\u00a76": \u00a7c{2}\u00a76 portions, \u00a7c{3}\u00a76 entit\u00e9s invalidHomeName=\u00a74Nom de r\u00e9sindence invalide invalidWarpName=\u00a74Nom de warp invalide -userUnknown=\u00a74Attention : Le joueur '\u00a7c{0}\u00a74' n'est jamais venu sur ce serveur. \ No newline at end of file +userUnknown=\u00a74Attention : Le joueur '\u00a7c{0}\u00a74' n'est jamais venu sur ce serveur. +teleportationEnabledFor=\u00a76Teleportation enabled for {0} +teleportationDisabledFor=\u00a76Teleportation disabled for {0} diff --git a/Essentials/src/messages_it.properties b/Essentials/src/messages_it.properties index 5f414f6ee..901433e83 100644 --- a/Essentials/src/messages_it.properties +++ b/Essentials/src/messages_it.properties @@ -460,3 +460,5 @@ gcWorld=\u00a76{0} "\u00a7c{1}\u00a76": \u00a7c{2}\u00a76 chunks, \u00a7c{3}\u00 invalidHomeName=\u00a74Invalid home name invalidWarpName=\u00a74Invalid warp name userUnknown=\u00a74Warning: The user '\u00a7c{0}\u00a74' has never joined this server. +teleportationEnabledFor=\u00a76Teleportation enabled for {0} +teleportationDisabledFor=\u00a76Teleportation disabled for {0} diff --git a/Essentials/src/messages_nl.properties b/Essentials/src/messages_nl.properties index 2b49d17bb..aeaa048b4 100644 --- a/Essentials/src/messages_nl.properties +++ b/Essentials/src/messages_nl.properties @@ -460,3 +460,5 @@ gcWorld=\u00a76{0} "\u00a7c{1}\u00a76": \u00a7c{2}\u00a76 chunks, \u00a7c{3}\u00 invalidHomeName=\u00a74Invalid home name invalidWarpName=\u00a74Invalid warp name userUnknown=\u00a74Warning: The user '\u00a7c{0}\u00a74' has never joined this server. +teleportationEnabledFor=\u00a76Teleportation enabled for {0} +teleportationDisabledFor=\u00a76Teleportation disabled for {0} diff --git a/Essentials/src/messages_pl.properties b/Essentials/src/messages_pl.properties index 24884d9d6..094a22663 100644 --- a/Essentials/src/messages_pl.properties +++ b/Essentials/src/messages_pl.properties @@ -460,3 +460,5 @@ gcWorld=\u00a76{0} "\u00a7c{1}\u00a76": \u00a7c{2}\u00a76 chunks, \u00a7c{3}\u00 invalidHomeName=\u00a74Invalid home name invalidWarpName=\u00a74Invalid warp name userUnknown=\u00a74Warning: The user '\u00a7c{0}\u00a74' has never joined this server. +teleportationEnabledFor=\u00a76Teleportation enabled for {0} +teleportationDisabledFor=\u00a76Teleportation disabled for {0} diff --git a/Essentials/src/messages_pt.properties b/Essentials/src/messages_pt.properties index cdb544026..513bf2f4d 100644 --- a/Essentials/src/messages_pt.properties +++ b/Essentials/src/messages_pt.properties @@ -460,3 +460,5 @@ gcWorld=\u00a76{0} "\u00a7c{1}\u00a76": \u00a7c{2}\u00a76 chunks, \u00a7c{3}\u00 invalidHomeName=\u00a74Invalid home name invalidWarpName=\u00a74Invalid warp name userUnknown=\u00a74Warning: The user '\u00a7c{0}\u00a74' has never joined this server. +teleportationEnabledFor=\u00a76Teleportation enabled for {0} +teleportationDisabledFor=\u00a76Teleportation disabled for {0} diff --git a/Essentials/src/messages_se.properties b/Essentials/src/messages_se.properties index de1061753..75d175330 100644 --- a/Essentials/src/messages_se.properties +++ b/Essentials/src/messages_se.properties @@ -460,3 +460,5 @@ gcWorld=\u00a76{0} "\u00a7c{1}\u00a76": \u00a7c{2}\u00a76 chunks, \u00a7c{3}\u00 invalidHomeName=\u00a74Invalid home name invalidWarpName=\u00a74Invalid warp name userUnknown=\u00a74Warning: The user '\u00a7c{0}\u00a74' has never joined this server. +teleportationEnabledFor=\u00a76Teleportation enabled for {0} +teleportationDisabledFor=\u00a76Teleportation disabled for {0} diff --git a/Essentials/src/plugin.yml b/Essentials/src/plugin.yml index c24c4de30..95c7e943a 100644 --- a/Essentials/src/plugin.yml +++ b/Essentials/src/plugin.yml @@ -404,7 +404,7 @@ commands: aliases: [etppos] tptoggle: description: Blocks all forms of teleportation. - usage: / + usage: / [player [on|off]] aliases: [etptoggle] tree: description: Spawn a tree where you are looking. From 1363406b84477db08be0e1bea7bb18cf17999511 Mon Sep 17 00:00:00 2001 From: snowleo Date: Mon, 19 Nov 2012 20:28:12 +0100 Subject: [PATCH 2/4] Fix for the plugin conflict with any plugin that contains a log4j library --- .../earth2me/essentials/protect/EssentialsProtect.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtect.java b/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtect.java index 06dc03656..1bd9991a9 100644 --- a/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtect.java +++ b/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtect.java @@ -27,6 +27,16 @@ public class EssentialsProtect extends JavaPlugin implements IProtect @Override public void onLoad() { + try { + // Simple fix for the case that log4j is on the class path by another plugin + Class basicConfiguratorClass = Class.forName("org.apache.log4j.BasicConfigurator"); + basicConfiguratorClass.getMethod("configure").invoke(null); + } + catch (Exception ex) + { + //Ignore me, log4j not found on classloader. + } + C3P0logger = com.mchange.v2.log.MLog.getLogger(com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource.class); C3P0logger.setFilter(new Filter() { From 0b1625f4c1252734f476a6c4c11bc432dcdd07df Mon Sep 17 00:00:00 2001 From: snowleo Date: Mon, 19 Nov 2012 22:03:25 +0100 Subject: [PATCH 3/4] Better fix for last commit --- .../essentials/protect/EssentialsProtect.java | 24 +++++++++---------- .../essentials/protect/log4j.properties | 4 ++++ 2 files changed, 15 insertions(+), 13 deletions(-) create mode 100644 EssentialsProtect/src/com/earth2me/essentials/protect/log4j.properties diff --git a/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtect.java b/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtect.java index 1bd9991a9..0ccf6917f 100644 --- a/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtect.java +++ b/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtect.java @@ -1,9 +1,11 @@ package com.earth2me.essentials.protect; import com.earth2me.essentials.protect.data.IProtectedBlock; +import com.mchange.v2.log.MLevel; import java.util.EnumMap; import java.util.List; import java.util.Map; +import java.util.Properties; import java.util.logging.Filter; import java.util.logging.Level; import java.util.logging.LogRecord; @@ -27,24 +29,20 @@ public class EssentialsProtect extends JavaPlugin implements IProtect @Override public void onLoad() { - try { + try + { // Simple fix for the case that log4j is on the class path by another plugin - Class basicConfiguratorClass = Class.forName("org.apache.log4j.BasicConfigurator"); - basicConfiguratorClass.getMethod("configure").invoke(null); + Class propertyConfiguratorClass = Class.forName("org.apache.log4j.PropertyConfigurator"); + Properties properties = new Properties(); + properties.load(this.getClass().getResourceAsStream("log4j.properties")); + propertyConfiguratorClass.getMethod("configure", Properties.class).invoke(null, properties); } catch (Exception ex) { //Ignore me, log4j not found on classloader. } - C3P0logger = com.mchange.v2.log.MLog.getLogger(com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource.class); - C3P0logger.setFilter(new Filter() - { - public boolean isLoggable(LogRecord lr) - { - return lr.getLevel() != Level.INFO; - } - }); + C3P0logger.setLevel(MLevel.WARNING); } public void onEnable() @@ -75,7 +73,7 @@ public class EssentialsProtect extends JavaPlugin implements IProtect { final EmergencyListener emListener = new EmergencyListener(); pm.registerEvents(emListener, this); - + for (Player player : getServer().getOnlinePlayers()) { player.sendMessage("Essentials Protect is in emergency mode. Check your log for errors."); @@ -99,7 +97,7 @@ public class EssentialsProtect extends JavaPlugin implements IProtect { return ess; } - + public Map getSettingsBoolean() { return settingsBoolean; diff --git a/EssentialsProtect/src/com/earth2me/essentials/protect/log4j.properties b/EssentialsProtect/src/com/earth2me/essentials/protect/log4j.properties new file mode 100644 index 000000000..2642ee541 --- /dev/null +++ b/EssentialsProtect/src/com/earth2me/essentials/protect/log4j.properties @@ -0,0 +1,4 @@ +log4j.rootLogger=INFO, A1 +log4j.appender.A1=org.apache.log4j.ConsoleAppender +log4j.appender.A1.layout=org.apache.log4j.PatternLayout +log4j.appender.A1.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n \ No newline at end of file From ad7d751856e62f72f3a1e46392e031c2309c6ede Mon Sep 17 00:00:00 2001 From: Necrodoom Date: Tue, 20 Nov 2012 19:38:21 +0200 Subject: [PATCH 4/4] fix spacing at disabled-commands --- Essentials/src/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Essentials/src/config.yml b/Essentials/src/config.yml index b1f1dedd6..724eb3541 100644 --- a/Essentials/src/config.yml +++ b/Essentials/src/config.yml @@ -89,7 +89,7 @@ overridden-commands: # Disabled commands will be completely unavailable on the server. # Disabling commands here will have no effect on command conflicts. disabled-commands: -# - nick +# - nick # If you do not wish to use a permission system, you can define a list of 'player perms' below. # This list has no effect if your using a supported permissions system.