diff options
-rw-r--r-- | Essentials/src/com/earth2me/essentials/Essentials.java | 5 | ||||
-rw-r--r-- | Essentials/src/com/earth2me/essentials/Mob.java | 5 | ||||
-rw-r--r-- | Essentials/src/com/earth2me/essentials/commands/Commandenchant.java | 115 | ||||
-rw-r--r-- | Essentials/src/com/earth2me/essentials/commands/Commandspawnmob.java | 3 | ||||
-rw-r--r-- | Essentials/src/com/earth2me/essentials/commands/NotEnoughArgumentsException.java | 9 | ||||
-rw-r--r-- | Essentials/src/messages.properties | 5 | ||||
-rw-r--r-- | Essentials/src/messages_da.properties | 5 | ||||
-rw-r--r-- | Essentials/src/messages_de.properties | 5 | ||||
-rw-r--r-- | Essentials/src/messages_en.properties | 5 | ||||
-rw-r--r-- | Essentials/src/messages_es.properties | 5 | ||||
-rw-r--r-- | Essentials/src/messages_fr.properties | 5 | ||||
-rw-r--r-- | Essentials/src/messages_nl.properties | 5 |
12 files changed, 167 insertions, 5 deletions
diff --git a/Essentials/src/com/earth2me/essentials/Essentials.java b/Essentials/src/com/earth2me/essentials/Essentials.java index 5ede55fc5..6af8e83e6 100644 --- a/Essentials/src/com/earth2me/essentials/Essentials.java +++ b/Essentials/src/com/earth2me/essentials/Essentials.java @@ -57,7 +57,7 @@ import org.bukkit.scheduler.BukkitScheduler; public class Essentials extends JavaPlugin implements IEssentials { - public static final int BUKKIT_VERSION = 1501; + public static final int BUKKIT_VERSION = 1512; private static final Logger LOGGER = Logger.getLogger("Minecraft"); private transient ISettings settings; private final transient TNTExplodeListener tntListener = new TNTExplodeListener(this); @@ -345,6 +345,9 @@ public class Essentials extends JavaPlugin implements IEssentials { sender.sendMessage(command.getDescription()); sender.sendMessage(command.getUsage().replaceAll("<command>", commandLabel)); + if (!ex.getMessage().isEmpty()) { + sender.sendMessage(ex.getMessage()); + } return true; } catch (Throwable ex) diff --git a/Essentials/src/com/earth2me/essentials/Mob.java b/Essentials/src/com/earth2me/essentials/Mob.java index e9b269218..394bbaf23 100644 --- a/Essentials/src/com/earth2me/essentials/Mob.java +++ b/Essentials/src/com/earth2me/essentials/Mob.java @@ -4,6 +4,7 @@ import static com.earth2me.essentials.I18n._; import java.util.HashMap; import java.util.Locale; import java.util.Map; +import java.util.Set; import java.util.logging.Level; import java.util.logging.Logger; import org.bukkit.Location; @@ -66,6 +67,10 @@ public enum Mob hashMap.put(mob.name.toLowerCase(Locale.ENGLISH), mob); } } + + public static Set<String> getMobList() { + return hashMap.keySet(); + } public LivingEntity spawn(final Player player, final Server server, final Location loc) throws MobException { diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandenchant.java b/Essentials/src/com/earth2me/essentials/commands/Commandenchant.java new file mode 100644 index 000000000..107727e32 --- /dev/null +++ b/Essentials/src/com/earth2me/essentials/commands/Commandenchant.java @@ -0,0 +1,115 @@ +package com.earth2me.essentials.commands; + +import com.earth2me.essentials.User; +import com.earth2me.essentials.Util; +import java.util.HashMap; +import java.util.Locale; +import java.util.Map; +import java.util.Set; +import java.util.TreeSet; +import org.bukkit.Server; +import org.bukkit.enchantments.Enchantment; +import org.bukkit.inventory.ItemStack; +import static com.earth2me.essentials.I18n._; + + +public class Commandenchant extends EssentialsCommand +{ + private static final Map<String, Enchantment> ENCHANTMENTS = new HashMap<String, Enchantment>(); + + static + { + ENCHANTMENTS.put("alldamage", Enchantment.DAMAGE_ALL); + ENCHANTMENTS.put("alldmg", Enchantment.DAMAGE_ALL); + ENCHANTMENTS.put("arthropodsdamage", Enchantment.DAMAGE_ARTHROPODS); + ENCHANTMENTS.put("ardmg", Enchantment.DAMAGE_ARTHROPODS); + ENCHANTMENTS.put("undeaddamage", Enchantment.DAMAGE_UNDEAD); + ENCHANTMENTS.put("undeaddmg", Enchantment.DAMAGE_UNDEAD); + ENCHANTMENTS.put("digspeed", Enchantment.DIG_SPEED); + ENCHANTMENTS.put("durability", Enchantment.DURABILITY); + ENCHANTMENTS.put("dura", Enchantment.DURABILITY); + ENCHANTMENTS.put("fireaspect", Enchantment.FIRE_ASPECT); + ENCHANTMENTS.put("fire", Enchantment.FIRE_ASPECT); + ENCHANTMENTS.put("knockback", Enchantment.KNOCKBACK); + ENCHANTMENTS.put("blockslootbonus", Enchantment.LOOT_BONUS_BLOCKS); + ENCHANTMENTS.put("blocksbonus", Enchantment.LOOT_BONUS_BLOCKS); + ENCHANTMENTS.put("mobslootbonus", Enchantment.LOOT_BONUS_MOBS); + ENCHANTMENTS.put("mobsbonus", Enchantment.LOOT_BONUS_MOBS); + ENCHANTMENTS.put("oxygen", Enchantment.OXYGEN); + ENCHANTMENTS.put("environmentalprotection", Enchantment.PROTECTION_ENVIRONMENTAL); + ENCHANTMENTS.put("envprot", Enchantment.PROTECTION_ENVIRONMENTAL); + ENCHANTMENTS.put("explosionsprotection", Enchantment.PROTECTION_EXPLOSIONS); + ENCHANTMENTS.put("expprot", Enchantment.PROTECTION_EXPLOSIONS); + ENCHANTMENTS.put("fallprotection", Enchantment.PROTECTION_FALL); + ENCHANTMENTS.put("fallprot", Enchantment.PROTECTION_FALL); + ENCHANTMENTS.put("fireprotection", Enchantment.PROTECTION_FIRE); + ENCHANTMENTS.put("fireprot", Enchantment.PROTECTION_FIRE); + ENCHANTMENTS.put("projectileprotection", Enchantment.PROTECTION_PROJECTILE); + ENCHANTMENTS.put("projprot", Enchantment.PROTECTION_PROJECTILE); + ENCHANTMENTS.put("silktouch", Enchantment.SILK_TOUCH); + ENCHANTMENTS.put("waterworker", Enchantment.WATER_WORKER); + } + + public Commandenchant() + { + super("enchant"); + } + + @Override + protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception + { + final ItemStack stack = user.getItemInHand(); + if (stack == null) + { + throw new Exception(_("nothingInHand")); + } + if (args.length == 0) + { + final Set<String> enchantmentslist = new TreeSet<String>(); + for (Map.Entry<String, Enchantment> entry : ENCHANTMENTS.entrySet()) + { + final String enchantmentName = entry.getValue().getName().toLowerCase(); + if (enchantmentslist.contains(enchantmentName) || user.isAuthorized("essentials.enchant." + enchantmentName)) + { + enchantmentslist.add(entry.getKey()); + enchantmentslist.add(enchantmentName); + } + } + throw new NotEnoughArgumentsException(_("entchantments", Util.joinList(enchantmentslist.toArray()))); + } + int level = -1; + if (args.length > 1) + { + try + { + level = Integer.parseInt(args[1]); + } + catch (NumberFormatException ex) + { + level = -1; + } + } + Enchantment enchantment = Enchantment.getByName(args[0].toUpperCase(Locale.ENGLISH)); + if (enchantment == null) + { + enchantment = ENCHANTMENTS.get(args[0].toLowerCase(Locale.ENGLISH)); + } + if (enchantment == null) + { + throw new Exception(_("enchantmentNotFound")); + } + final String enchantmentName = enchantment.getName().toLowerCase(); + if (!user.isAuthorized("essentials.enchant." + enchantmentName)) + { + throw new Exception(_("enchantmentPerm", enchantmentName)); + } + if (level < enchantment.getStartLevel() || level > enchantment.getMaxLevel()) + { + level = enchantment.getMaxLevel(); + } + stack.addEnchantment(enchantment, level); + user.setItemInHand(stack); + user.updateInventory(); + user.sendMessage(_("enchantmentApplied", enchantmentName.replace('_', ' '))); + } +} diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandspawnmob.java b/Essentials/src/com/earth2me/essentials/commands/Commandspawnmob.java index eb26d29b1..14fa3dca3 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandspawnmob.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandspawnmob.java @@ -26,8 +26,7 @@ public class Commandspawnmob extends EssentialsCommand { if (args.length < 1) { - throw new NotEnoughArgumentsException(); - //TODO: user.sendMessage("ยง7Mobs: Zombie PigZombie Skeleton Slime Chicken Pig Monster Spider Creeper Ghast Squid Giant Cow Sheep Wolf"); + throw new NotEnoughArgumentsException(_("mobsAvailable", Util.joinList(Mob.getMobList()))); } diff --git a/Essentials/src/com/earth2me/essentials/commands/NotEnoughArgumentsException.java b/Essentials/src/com/earth2me/essentials/commands/NotEnoughArgumentsException.java index 9513fc934..0c47b9893 100644 --- a/Essentials/src/com/earth2me/essentials/commands/NotEnoughArgumentsException.java +++ b/Essentials/src/com/earth2me/essentials/commands/NotEnoughArgumentsException.java @@ -5,11 +5,16 @@ public class NotEnoughArgumentsException extends Exception { public NotEnoughArgumentsException() { - super(); + super(""); + } + + public NotEnoughArgumentsException(final String string) + { + super(string); } public NotEnoughArgumentsException(final Throwable ex) { - super(ex); + super("", ex); } } diff --git a/Essentials/src/messages.properties b/Essentials/src/messages.properties index e0a23002b..f162176de 100644 --- a/Essentials/src/messages.properties +++ b/Essentials/src/messages.properties @@ -68,6 +68,10 @@ downloadingGeoIp=Downloading GeoIP database ... this might take a while (country duplicatedUserdata=Duplicated userdata: {0} and {1} enableUnlimited=\u00a77Giving unlimited amount of {0} to {1}. enabled=enabled +enchantmentApplied = \u00a77The enchantment {0} has been applied to your item in hand. +enchantmentNotFound = \u00a7cEnchantment not found +enchantmentPerm = \u00a7cYou do not have the permission for {0} +enchantments = \u00a77Enchantments: {0} errorCallingCommand=Error calling command /{0} errorWithMessage=\u00a7cError: {0} essentialsReload=\u00a77Essentials Reloaded {0} @@ -221,6 +225,7 @@ notAllowedToShout=\u00a7cYou are not authorized to shout. notEnoughMoney=You do not have sufficient funds. notRecommendedBukkit=Bukkit version is not the recommended build for Essentials. notSupportedYet=Not supported yet. +nothingInHand = \u00a7cYou have nothing in your hand. now=now numberRequired=A number goes there, silly. onlyDayNight=/time only supports day/night. diff --git a/Essentials/src/messages_da.properties b/Essentials/src/messages_da.properties index 53bf399f3..997f48acc 100644 --- a/Essentials/src/messages_da.properties +++ b/Essentials/src/messages_da.properties @@ -68,6 +68,10 @@ downloadingGeoIp=Downloader GeoIP database ... det her kan tage et stykke tid (l duplicatedUserdata=Duplikerede userdata: {0} og {1} enableUnlimited=\u00a77Giver ubegr\u00e6nset m\u00e6ngde af {0} til {1}. enabled=aktiveret +enchantmentApplied = \u00a77The enchantment {0} has been applied to your item in hand. +enchantmentNotFound = \u00a7cEnchantment not found +enchantmentPerm = \u00a7cYou do not have the permission for {0} +enchantments = \u00a77Enchantments: {0} errorCallingCommand=Fejl ved opkald af kommando /{0} errorWithMessage=\u00a7cFejl: {0} essentialsReload=\u00a77Essentials Genindl\u00e6st {0} @@ -221,6 +225,7 @@ notAllowedToShout=\u00a7cDu er ikke autoriseret til at r\u00e5be. notEnoughMoney=Du har ikke tilstr\u00e6kkelig penge. notRecommendedBukkit=Bukkit version er ikke den anbefalede byg for Essentials. notSupportedYet=Ikke underst\u00f8ttet endnu. +nothingInHand = \u00a7cYou have nothing in your hand. now=nu numberRequired=Der skal v\u00e6re et nummer, fjolle. onlyDayNight=/time underst\u00f8tter kun day/night. diff --git a/Essentials/src/messages_de.properties b/Essentials/src/messages_de.properties index e0bd6dca7..f92d6e18e 100644 --- a/Essentials/src/messages_de.properties +++ b/Essentials/src/messages_de.properties @@ -68,6 +68,10 @@ downloadingGeoIp=Lade GeoIP-Datenbank ... dies kann etwas dauern (country: 0.6 M duplicatedUserdata=Doppelte Datei in userdata: {0} und {1} enableUnlimited=\u00a77Gebe {1} unendliche Mengen von {0}. enabled=aktiviert +enchantmentApplied = \u00a77The enchantment {0} has been applied to your item in hand. +enchantmentNotFound = \u00a7cEnchantment not found +enchantmentPerm = \u00a7cYou do not have the permission for {0} +enchantments = \u00a77Enchantments: {0} errorCallingCommand=Fehler beim Aufrufen des Befehls /{0} errorWithMessage=\u00a7cFehler: {0} essentialsReload=\u00a77Essentials neu geladen {0} @@ -221,6 +225,7 @@ notAllowedToShout=\u00a7cDu bist nicht berechtigt zu schreien. notEnoughMoney=Du hast nicht genug Geld. notRecommendedBukkit=Die verwendete Bukkit-Version ist nicht f\u00fcr Essentials empfohlen. notSupportedYet=Noch nicht verf\u00fcgbar. +nothingInHand = \u00a7cYou have nothing in your hand. now=jetzt numberRequired=Ein Zahl wird ben\u00f6tigt. onlyDayNight=/time unterst\u00fctzt nur day und night. diff --git a/Essentials/src/messages_en.properties b/Essentials/src/messages_en.properties index e89004bf7..d8f4b85da 100644 --- a/Essentials/src/messages_en.properties +++ b/Essentials/src/messages_en.properties @@ -68,6 +68,10 @@ downloadingGeoIp=Downloading GeoIP database ... this might take a while (country duplicatedUserdata=Duplicated userdata: {0} and {1} enableUnlimited=\u00a77Giving unlimited amount of {0} to {1}. enabled=enabled +enchantmentApplied = \u00a77The enchantment {0} has been applied to your item in hand. +enchantmentNotFound = \u00a7cEnchantment not found +enchantmentPerm = \u00a7cYou do not have the permission for {0} +enchantments = \u00a77Enchantments: {0} errorCallingCommand=Error calling command /{0} errorWithMessage=\u00a7cError: {0} essentialsReload=\u00a77Essentials Reloaded {0} @@ -221,6 +225,7 @@ notAllowedToShout=\u00a7cYou are not authorized to shout. notEnoughMoney=You do not have sufficient funds. notRecommendedBukkit=Bukkit version is not the recommended build for Essentials. notSupportedYet=Not supported yet. +nothingInHand = \u00a7cYou have nothing in your hand. now=now numberRequired=A number goes there, silly. onlyDayNight=/time only supports day/night. diff --git a/Essentials/src/messages_es.properties b/Essentials/src/messages_es.properties index ffa0af2ce..796515a15 100644 --- a/Essentials/src/messages_es.properties +++ b/Essentials/src/messages_es.properties @@ -68,6 +68,10 @@ downloadingGeoIp=Descargando base de datos de GeoIP ... puede llevar un tiempo ( duplicatedUserdata=Datos de usuario duplicados: {0} y {1} enableUnlimited=\u00a77Dando cantidad ilimitada de {0} a {1}. enabled=activado +enchantmentApplied = \u00a77The enchantment {0} has been applied to your item in hand. +enchantmentNotFound = \u00a7cEnchantment not found +enchantmentPerm = \u00a7cYou do not have the permission for {0} +enchantments = \u00a77Enchantments: {0} errorCallingCommand=Error al ejecutar el comando /{0} errorWithMessage=\u00a7cError: {0} essentialsReload=\u00a77Essentials Recargado {0} @@ -221,6 +225,7 @@ notAllowedToShout=\u00a7cNo estas autorizado para gritar. notEnoughMoney=No tienes el dinero suficiente. notRecommendedBukkit=La version de bukkit no es la recomendada para esta version de Essentials. notSupportedYet=No esta soportado aun. +nothingInHand = \u00a7cYou have nothing in your hand. now=ahora numberRequired=Un numero es necesario, amigo. onlyDayNight=/time solo soporta day/night. (dia/noche) diff --git a/Essentials/src/messages_fr.properties b/Essentials/src/messages_fr.properties index 1d3cddea0..93b4d6c83 100644 --- a/Essentials/src/messages_fr.properties +++ b/Essentials/src/messages_fr.properties @@ -68,6 +68,10 @@ downloadingGeoIp=T\u00e9l\u00e9chargement de la base de donn\u00e9es GeoIP ... c duplicatedUserdata=Donn\u00e9e utilisateur dupliqu\u00e9e: {0} et {1} enableUnlimited=\u00a77Donner un nombre illimit\u00e9 de {0} \u00e0 {1}. enabled=activ\u00e9 +enchantmentApplied = \u00a77The enchantment {0} has been applied to your item in hand. +enchantmentNotFound = \u00a7cEnchantment not found +enchantmentPerm = \u00a7cYou do not have the permission for {0} +enchantments = \u00a77Enchantments: {0} errorCallingCommand=Erreur en appelant la commande /{0} errorWithMessage=\u00a7cErreur: {0} essentialsReload=\u00a77Essentials Recharg\u00e9 {0} @@ -221,6 +225,7 @@ notAllowedToShout=\u00a7cVous n''\u00eates pas autoris\u00e9 \u00e0 crier. notEnoughMoney=Vous n''avez pas les fonds n\u00e9cessaires. notRecommendedBukkit=La version de Bukkit n''est pas celle qui est recommand\u00e9 pour cette version de Essentials. notSupportedYet=Pas encore pris en charge. +nothingInHand = \u00a7cYou have nothing in your hand. now=maintenant numberRequired=On a besoin d''un nombre ici, idiot. onlyDayNight=/time ne supporte que (jour) day/night (nuit). diff --git a/Essentials/src/messages_nl.properties b/Essentials/src/messages_nl.properties index ea0cf99d8..a297dc683 100644 --- a/Essentials/src/messages_nl.properties +++ b/Essentials/src/messages_nl.properties @@ -68,6 +68,10 @@ downloadingGeoIp=Bezig met downloaden van GeoIP database ... Dit kan een tijdje duplicatedUserdata=Dubbele userdata: {0} en {1}. enableUnlimited=\u00a77Oneindig aantal {0} aan {1} gegeven. enabled=ingeschakeld +enchantmentApplied = \u00a77The enchantment {0} has been applied to your item in hand. +enchantmentNotFound = \u00a7cEnchantment not found +enchantmentPerm = \u00a7cYou do not have the permission for {0} +enchantments = \u00a77Enchantments: {0} errorCallingCommand=Fout bij het aanroepen van de opdracht /{0} errorWithMessage=\u00a7cFout: {0} essentialsReload=\u00a77Essentials is herladen {0} @@ -221,6 +225,7 @@ notAllowedToShout=\u00a7cJe bent niet bevoegd om de roep functie te gebruiken. notEnoughMoney=Je hebt niet voldoende middelen. notRecommendedBukkit=De Bukkit versie is niet de aangeraden build voor Essentials. notSupportedYet=Nog niet ondersteund. +nothingInHand = \u00a7cYou have nothing in your hand. now=nu numberRequired=Er moet daar een nummer, grapjas. onlyDayNight=/time ondersteund alleen day/night. |