diff options
-rw-r--r-- | Essentials/src/com/earth2me/essentials/AlternativeCommandsHandler.java | 15 | ||||
-rw-r--r-- | Essentials/src/com/earth2me/essentials/Essentials.java | 3 | ||||
-rw-r--r-- | Essentials/src/com/earth2me/essentials/commands/Commandbreak.java | 6 | ||||
-rw-r--r-- | Essentials/src/com/earth2me/essentials/commands/Commandfeed.java | 41 | ||||
-rw-r--r-- | Essentials/src/com/earth2me/essentials/commands/Commandmore.java | 6 | ||||
-rw-r--r-- | Essentials/src/com/earth2me/essentials/commands/Commandremove.java | 60 | ||||
-rw-r--r-- | Essentials/src/messages.properties | 3 | ||||
-rw-r--r-- | Essentials/src/messages_da.properties | 3 | ||||
-rw-r--r-- | Essentials/src/messages_de.properties | 3 | ||||
-rw-r--r-- | Essentials/src/messages_en.properties | 3 | ||||
-rw-r--r-- | Essentials/src/messages_es.properties | 3 | ||||
-rw-r--r-- | Essentials/src/messages_fr.properties | 3 | ||||
-rw-r--r-- | Essentials/src/messages_nl.properties | 3 | ||||
-rw-r--r-- | Essentials/src/plugin.yml | 6 |
14 files changed, 110 insertions, 48 deletions
diff --git a/Essentials/src/com/earth2me/essentials/AlternativeCommandsHandler.java b/Essentials/src/com/earth2me/essentials/AlternativeCommandsHandler.java index 366c86cc6..e75644ad5 100644 --- a/Essentials/src/com/earth2me/essentials/AlternativeCommandsHandler.java +++ b/Essentials/src/com/earth2me/essentials/AlternativeCommandsHandler.java @@ -1,6 +1,8 @@ package com.earth2me.essentials; import java.util.*; +import java.util.logging.Level; +import java.util.logging.Logger; import org.bukkit.command.Command; import org.bukkit.command.PluginCommand; import org.bukkit.command.PluginCommandYamlParser; @@ -9,8 +11,9 @@ import org.bukkit.plugin.Plugin; public class AlternativeCommandsHandler { + private static final Logger LOGGER = Logger.getLogger("Minecraft"); private final transient Map<String, List<PluginCommand>> altcommands = new HashMap<String, List<PluginCommand>>(); - private final transient Map<String, String> executed = new HashMap<String, String>(); + private final transient Map<String, String> disabledList = new HashMap<String, String>(); private final transient IEssentials ess; public AlternativeCommandsHandler(final IEssentials ess) @@ -118,13 +121,17 @@ public class AlternativeCommandsHandler return commands.get(0); } - public void executed(final String label, final String otherlabel) + public void executed(final String label, final String otherLabel) { - executed.put(label, otherlabel); + if (ess.getSettings().isDebug()) + { + LOGGER.log(Level.INFO, "Essentials: Alternative command " + label + " found, using " + otherLabel); + } + disabledList.put(label, otherLabel); } public Map<String, String> disabledCommands() { - return executed; + return disabledList; } } diff --git a/Essentials/src/com/earth2me/essentials/Essentials.java b/Essentials/src/com/earth2me/essentials/Essentials.java index ca86b2b2a..98d919150 100644 --- a/Essentials/src/com/earth2me/essentials/Essentials.java +++ b/Essentials/src/com/earth2me/essentials/Essentials.java @@ -309,8 +309,7 @@ public class Essentials extends JavaPlugin implements IEssentials final PluginCommand pc = alternativeCommandsHandler.getAlternative(commandLabel); if (pc != null) { - alternativeCommandsHandler.executed(commandLabel, pc.getLabel()); - LOGGER.log(Level.FINE, "Essentials: Alternative command " + commandLabel + " found, using " + pc.getLabel()); + alternativeCommandsHandler.executed(commandLabel, pc.getLabel()); return pc.execute(sender, commandLabel, args); } } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandbreak.java b/Essentials/src/com/earth2me/essentials/commands/Commandbreak.java index 7528d6068..48c19e9e7 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandbreak.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandbreak.java @@ -15,9 +15,9 @@ public class Commandbreak extends EssentialsCommand } @Override - public void run(Server server, User user, String commandLabel, String[] args) throws Exception + public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception { - Block block = user.getTargetBlock(null, 20); + final Block block = user.getTargetBlock(null, 20); if (block.getType() == Material.AIR) { throw new NoChargeException(); @@ -26,7 +26,7 @@ public class Commandbreak extends EssentialsCommand { throw new NoChargeException(); } - BlockBreakEvent event = new BlockBreakEvent(block, user); + final BlockBreakEvent event = new BlockBreakEvent(block, user); server.getPluginManager().callEvent(event); if (event.isCancelled()) { diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandfeed.java b/Essentials/src/com/earth2me/essentials/commands/Commandfeed.java index ac3078309..0c1579835 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandfeed.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandfeed.java @@ -1,7 +1,10 @@ package com.earth2me.essentials.commands; +import static com.earth2me.essentials.I18n._; import com.earth2me.essentials.User; +import java.util.List; import org.bukkit.Server; +import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; @@ -13,25 +16,37 @@ public class Commandfeed extends EssentialsCommand } @Override - protected void run(Server server, User user, String commandLabel, String[] args) throws Exception + protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception { - if (args.length > 0) + if (args.length > 0 && user.isAuthorized("essentials.feed.others")) { - Player player = ess.getServer().getPlayer(args[0]); - if (player != null) - { - player.setFoodLevel(20); - player.setSaturation(10); - } - else - { - throw new NotEnoughArgumentsException(); // TODO: Translate "Player not found" - } + feedOtherPlayers(server,user,args[0]); } else { user.setFoodLevel(20); - user.setSaturation(10); // 10 because 20 seems way overpowered + user.setSaturation(10); + user.sendMessage(_("feed")); + } + } + + private void feedOtherPlayers(final Server server, final CommandSender sender, final String name) + { + final List<Player> players = server.matchPlayer(name); + if (players.isEmpty()) + { + sender.sendMessage(_("playerNotFound")); + return; + } + for (Player player : players) + { + if (ess.getUser(player).isHidden()) + { + continue; + } + player.setFoodLevel(20); + player.setSaturation(10); + sender.sendMessage(_("feedOther", player.getDisplayName())); } } } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandmore.java b/Essentials/src/com/earth2me/essentials/commands/Commandmore.java index 3bf5d4187..3fce3110c 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandmore.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandmore.java @@ -1,7 +1,7 @@ package com.earth2me.essentials.commands; -import com.earth2me.essentials.User; import static com.earth2me.essentials.I18n._; +import com.earth2me.essentials.User; import java.util.Locale; import org.bukkit.Server; import org.bukkit.inventory.ItemStack; @@ -15,9 +15,9 @@ public class Commandmore extends EssentialsCommand } @Override - public void run(Server server, User user, String commandLabel, String[] args) throws Exception + public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception { - ItemStack stack = user.getItemInHand(); + final ItemStack stack = user.getItemInHand(); if (stack == null) { throw new Exception(_("cantSpawnItem", "Air")); diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandremove.java b/Essentials/src/com/earth2me/essentials/commands/Commandremove.java index 3839ee81d..33b37ac39 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandremove.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandremove.java @@ -1,19 +1,13 @@ package com.earth2me.essentials.commands; -import java.util.Locale; import static com.earth2me.essentials.I18n._; +import com.earth2me.essentials.User; +import java.util.Locale; import org.bukkit.Chunk; import org.bukkit.Server; import org.bukkit.World; import org.bukkit.command.CommandSender; -import org.bukkit.entity.Boat; -import org.bukkit.entity.Entity; -import org.bukkit.entity.ExperienceOrb; -import org.bukkit.entity.Item; -import org.bukkit.entity.Minecart; -import org.bukkit.entity.Painting; -import org.bukkit.entity.Player; -import org.bukkit.entity.Projectile; +import org.bukkit.entity.*; public class Commandremove extends EssentialsCommand @@ -23,6 +17,7 @@ public class Commandremove extends EssentialsCommand super("remove"); } + private enum ToRemove { DROPS, @@ -34,17 +29,18 @@ public class Commandremove extends EssentialsCommand } @Override - protected void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception + protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception { - if (args.length < 2) + if (args.length < 1) { throw new NotEnoughArgumentsException(); } - World world; - int radius = -1; - if (sender instanceof Player) + ToRemove toRemove; + final World world = user.getWorld(); + int radius = 0; + + if (args.length < 2) { - world = ((Player)sender).getWorld(); try { radius = Integer.parseInt(args[1]); @@ -54,10 +50,29 @@ public class Commandremove extends EssentialsCommand throw new Exception(_("numberRequired")); } } - else + + try { - world = ess.getWorld(args[1]); + toRemove = ToRemove.valueOf(args[0].toUpperCase(Locale.ENGLISH)); + } + catch (IllegalArgumentException e) + { + throw new NotEnoughArgumentsException(); //TODO: translate and list types } + + removeEntities(user, world, toRemove, radius); + } + + @Override + protected void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception + { + if (args.length < 2) + { + throw new NotEnoughArgumentsException(); + } + World world; + world = ess.getWorld(args[1]); + if (world == null) { throw new Exception(_("invalidWorld")); @@ -71,14 +86,19 @@ public class Commandremove extends EssentialsCommand { throw new NotEnoughArgumentsException(); //TODO: translate and list types } + removeEntities(sender, world, toRemove, 0); + } + + protected void removeEntities(final CommandSender sender, final World world, final ToRemove toRemove, final int radius) throws Exception + { int removed = 0; for (Chunk chunk : world.getLoadedChunks()) { for (Entity e : chunk.getEntities()) { - if (sender instanceof Player) + if (radius > 0) { - if (((Player)sender).getLocation().distance(e.getLocation()) > radius && radius >= 0) + if (((Player)sender).getLocation().distance(e.getLocation()) > radius) { continue; } @@ -133,6 +153,6 @@ public class Commandremove extends EssentialsCommand } } } - sender.sendMessage(_("kill", removed)); + sender.sendMessage(_("removed", removed)); } } diff --git a/Essentials/src/messages.properties b/Essentials/src/messages.properties index 2bcf2f646..2df0cf8d2 100644 --- a/Essentials/src/messages.properties +++ b/Essentials/src/messages.properties @@ -397,3 +397,6 @@ year=year years=years youAreHealed=\u00a77You have been healed. youHaveNewMail=\u00a7cYou have {0} messages!\u00a7f Type \u00a77/mail read\u00a7f to view your mail. +feed=\u00a77Your appetite was sated. +feedOther=\u00a77Satisfied {0}. +removed=\u00a77Removed {0} entities. diff --git a/Essentials/src/messages_da.properties b/Essentials/src/messages_da.properties index 774b7e55d..02f95516a 100644 --- a/Essentials/src/messages_da.properties +++ b/Essentials/src/messages_da.properties @@ -86,6 +86,8 @@ failedToCloseConfig=Fejlede i at lukke config {0} failedToCreateConfig=Fejl i oprettelse af config {0} failedToWriteConfig=Fejlede i at skrive config {0} false=false +feed=\u00a77Your appetite was sated. +feedOther=\u00a77Satisfied {0}. fileRenameError=Resterende fil {0} fejlede foreverAlone=\u00a7cDu har ingen du kan svare. freedMemory=Befriede {0} MB. @@ -277,6 +279,7 @@ protectionOwner=\u00a76[EssentialsProtect] Beskyttelses ejer: {0} questionFormat=\u00a77[Sp\u00f8rgsm\u00e5l]\u00a7f {0} readNextPage=Type /{0} {1} to read the next page reloadAllPlugins=\u00a77Genindl\u00e6ste alle tilf\u00f8jelser. +removed=\u00a77Removed {0} entities. repair=You have successfully repaired your: \u00a7e{0}. repairAlreadyFixed=\u00a77This item does not need repairing. repairEnchanted=\u00a77You are not allowed to repair enchanted items. diff --git a/Essentials/src/messages_de.properties b/Essentials/src/messages_de.properties index e8194b623..edc7b78d1 100644 --- a/Essentials/src/messages_de.properties +++ b/Essentials/src/messages_de.properties @@ -86,6 +86,8 @@ failedToCloseConfig=Fehler beim Schliessen der Konfiguration {0} failedToCreateConfig=Fehler beim Erstellen der Konfiguration {0} failedToWriteConfig=Fehler beim Schreiben der Konfiguration {0} false=false +feed=\u00a77Your appetite was sated. +feedOther=\u00a77Satisfied {0}. fileRenameError=Umbenennen von {0} gescheitert. foreverAlone=\u00a7cDu hast niemanden, dem du antworten kannst. freedMemory={0} MB frei gemacht. @@ -277,6 +279,7 @@ protectionOwner=\u00a76[EssentialsProtect] Besitzer dieses Blocks: {0} questionFormat=\u00a77[Frage]\u00a7f {0} readNextPage=Type /{0} {1} to read the next page reloadAllPlugins=\u00a77Alle plugins neu geladen. +removed=\u00a77Removed {0} entities. repair=Du hast erfolgreich deine {0} repariert. repairAlreadyFixed=\u00a77Dieser Gegenstand ben\u00f6tigt keine Reparatur. repairEnchanted=\u00a77You are not allowed to repair enchanted items. diff --git a/Essentials/src/messages_en.properties b/Essentials/src/messages_en.properties index 61d0bf6e8..2e84079f9 100644 --- a/Essentials/src/messages_en.properties +++ b/Essentials/src/messages_en.properties @@ -86,6 +86,8 @@ failedToCloseConfig=Failed to close config {0} failedToCreateConfig=Failed to create config {0} failedToWriteConfig=Failed to write config {0} false=false +feed=\u00a77Your appetite was sated. +feedOther=\u00a77Satisfied {0}. fileRenameError=Renaming file {0} failed foreverAlone=\u00a7cYou have nobody to whom you can reply. freedMemory=Freed {0} MB. @@ -277,6 +279,7 @@ protectionOwner=\u00a76[EssentialsProtect] Protection owner: {0} questionFormat=\u00a77[Question]\u00a7f {0} readNextPage=Type /{0} {1} to read the next page reloadAllPlugins=\u00a77Reloaded all plugins. +removed=\u00a77Removed {0} entities. repair=You have successfully repaired your: \u00a7e{0}. repairAlreadyFixed=\u00a77This item does not need repairing. repairEnchanted=\u00a77You are not allowed to repair enchanted items. diff --git a/Essentials/src/messages_es.properties b/Essentials/src/messages_es.properties index 22520bf58..538e3e07c 100644 --- a/Essentials/src/messages_es.properties +++ b/Essentials/src/messages_es.properties @@ -86,6 +86,8 @@ failedToCloseConfig=Error al cerrar configuracion {0} failedToCreateConfig=Error al crear configuracion {0} failedToWriteConfig=Error al escribir configuracion {0} false=false +feed=\u00a77Your appetite was sated. +feedOther=\u00a77Satisfied {0}. fileRenameError=Error al renombrar el archivo {0} foreverAlone=\u00a7cNo tienes nadie a quien puedas responder. freedMemory= {0} MB libres. @@ -277,6 +279,7 @@ protectionOwner=\u00a76[EssentialsProtect] Dueño de la proteccion: {0} questionFormat=\u00a77[Pregunta]\u00a7f {0} readNextPage=Type /{0} {1} to read the next page reloadAllPlugins=\u00a77Todos los plugins recargados. +removed=\u00a77Removed {0} entities. repair=Has reparado satisfactoriamente tu: \u00a7e{0}. repairAlreadyFixed=\u00a77Este objeto no necesita de reparado. repairEnchanted=\u00a77You are not allowed to repair enchanted items. diff --git a/Essentials/src/messages_fr.properties b/Essentials/src/messages_fr.properties index 31309fa55..a67e21acf 100644 --- a/Essentials/src/messages_fr.properties +++ b/Essentials/src/messages_fr.properties @@ -86,6 +86,8 @@ failedToCloseConfig=Echec de la fermeture de la configuration {0} failedToCreateConfig=Echec de la cr\u00e9ation de la configuration {0} failedToWriteConfig=\u00c9chec de l''\u00e9criture de la configuration {0} false=faux +feed=\u00a77Your appetite was sated. +feedOther=\u00a77Satisfied {0}. fileRenameError=Echec du changement de nom de {0} foreverAlone=\u00a7cVous n''avez personne \u00e0 qui r\u00e9pondre freedMemory=A lib\u00e9r\u00e9 {0} Mo. @@ -277,6 +279,7 @@ protectionOwner=\u00a76[EssentialsProtect] Propri\u00e9taire de la protection : questionFormat=\u00a77[Question]\u00a7f {0} readNextPage=Type /{0} {1} to read the next page reloadAllPlugins=\u00a77Toutes les extensions ont \u00e9t\u00e9 recharg\u00e9es. +removed=\u00a77Removed {0} entities. repair=Vous avez r\u00e9par\u00e9 votre : \u00a7e{0}. repairAlreadyFixed=\u00a77Cet objet n''a pas besoin de r\u00e9paration. repairEnchanted=\u00a77You are not allowed to repair enchanted items. diff --git a/Essentials/src/messages_nl.properties b/Essentials/src/messages_nl.properties index d5ad33813..632cfd0eb 100644 --- a/Essentials/src/messages_nl.properties +++ b/Essentials/src/messages_nl.properties @@ -86,6 +86,8 @@ failedToCloseConfig=Fout bij het sluiten van config {0} failedToCreateConfig=Fout tijdens het aanmaken van config {0} failedToWriteConfig=Fout bij het cre\u00ebren van config {0} false=false +feed=\u00a77Your appetite was sated. +feedOther=\u00a77Satisfied {0}. fileRenameError=Hernoemen van {0} mislukt foreverAlone=\u00a7cJe hebt niemand waarnaar je kan reageren. freedMemory={0} MB gelost. @@ -277,6 +279,7 @@ protectionOwner=\u00a76[EssentialsProtect] Beschermingeigenaar: {0} questionFormat=\u00a77[Vraag]\u00a7f {0} readNextPage=Type /{0} {1} to read the next page reloadAllPlugins=\u00a77Alle plugins zijn herladen. +removed=\u00a77Removed {0} entities. repair=You have successfully repaired your: \u00a7e{0}. repairAlreadyFixed=\u00a77This item does not need repairing. repairEnchanted=\u00a77You are not allowed to repair enchanted items. diff --git a/Essentials/src/plugin.yml b/Essentials/src/plugin.yml index efeaf2648..48578906f 100644 --- a/Essentials/src/plugin.yml +++ b/Essentials/src/plugin.yml @@ -99,8 +99,8 @@ commands: usage: /<command> [player] aliases: [extinguish,eext,eextinguish] feed: - description: Shove food down someone's throat. - usage: /<command> <player> + description: Satisfy the hunger. + usage: /<command> [player] aliases: [efeed] fireball: description: Throw a fireball. @@ -256,7 +256,7 @@ commands: aliases: [erealname] remove: description: Removes entities in your world - usage: /<command> <drops|arrows|boats|minecarts|xp|paintings> <radius> + usage: /<command> <drops|arrows|boats|minecarts|xp|paintings> [radius] aliases: [eremove] repair: description: Repairs the durability of all or one item. |