diff options
50 files changed, 698 insertions, 551 deletions
diff --git a/Essentials/nbproject/project.properties b/Essentials/nbproject/project.properties index a9cebbb92..40b0ae9b6 100644 --- a/Essentials/nbproject/project.properties +++ b/Essentials/nbproject/project.properties @@ -68,7 +68,6 @@ file.reference.BOSEconomy7.jar=../lib/BOSEconomy7.jar file.reference.bPermissions.jar=../lib/bPermissions.jar file.reference.bpermissions2.jar=../lib/bpermissions2.jar file.reference.bukkit.jar=../lib/bukkit.jar -file.reference.craftbukkit.jar=../lib/craftbukkit.jar file.reference.iCo4.jar=../lib/iCo4.jar file.reference.iCo5.jar=../lib/iCo5.jar file.reference.iCo6.jar=../lib/iCo6.jar @@ -96,12 +95,11 @@ javac.classpath=\ ${file.reference.lombok.jar}:\ ${reference.EssentialsGroupManager.jar}:\ ${file.reference.bukkit.jar}:\ - ${file.reference.craftbukkit.jar}:\ ${file.reference.Vault.jar}:\ ${file.reference.Privileges.jar}:\ ${file.reference.bpermissions2.jar} # Space-separated list of extra javac options -javac.compilerargs= +javac.compilerargs=-Xlint:unchecked javac.deprecation=false javac.processorpath=\ ${javac.classpath} diff --git a/Essentials/src/com/earth2me/essentials/AlternativeCommandsHandler.java b/Essentials/src/com/earth2me/essentials/AlternativeCommandsHandler.java index e75644ad5..e9cb6fe19 100644 --- a/Essentials/src/com/earth2me/essentials/AlternativeCommandsHandler.java +++ b/Essentials/src/com/earth2me/essentials/AlternativeCommandsHandler.java @@ -121,13 +121,14 @@ public class AlternativeCommandsHandler return commands.get(0); } - public void executed(final String label, final String otherLabel) + public void executed(final String label, final PluginCommand pc) { + final String altString = pc.getPlugin().getName() + ":" + pc.getLabel(); if (ess.getSettings().isDebug()) { - LOGGER.log(Level.INFO, "Essentials: Alternative command " + label + " found, using " + otherLabel); + LOGGER.log(Level.INFO, "Essentials: Alternative command " + label + " found, using " + altString); } - disabledList.put(label, otherLabel); + disabledList.put(label, altString); } public Map<String, String> disabledCommands() diff --git a/Essentials/src/com/earth2me/essentials/Essentials.java b/Essentials/src/com/earth2me/essentials/Essentials.java index 9ba2c696a..49c09fe90 100644 --- a/Essentials/src/com/earth2me/essentials/Essentials.java +++ b/Essentials/src/com/earth2me/essentials/Essentials.java @@ -65,7 +65,7 @@ import org.yaml.snakeyaml.error.YAMLException; public class Essentials extends JavaPlugin implements IEssentials { - public static final int BUKKIT_VERSION = 2455; + public static final int BUKKIT_VERSION = 2543; private static final Logger LOGGER = Logger.getLogger("Minecraft"); private transient ISettings settings; private final transient TNTExplodeListener tntListener = new TNTExplodeListener(this); @@ -308,7 +308,7 @@ public class Essentials extends JavaPlugin implements IEssentials final PluginCommand pc = alternativeCommandsHandler.getAlternative(commandLabel); if (pc != null) { - alternativeCommandsHandler.executed(commandLabel, pc.getLabel()); + alternativeCommandsHandler.executed(commandLabel, pc); try { return pc.execute(sender, commandLabel, args); @@ -368,6 +368,19 @@ public class Essentials extends JavaPlugin implements IEssentials return true; } + if (user != null && user.isJailed() && !user.isAuthorized(cmd, "essentials.jail.allow.")) + { + if (user.getJailTimeout() > 0) + { + user.sendMessage(_("playerJailedFor", user.getName(), Util.formatDateDiff(user.getJailTimeout()))); + } + else + { + user.sendMessage(_("jailMessage")); + } + return true; + } + // Run the command try { @@ -471,7 +484,7 @@ public class Essentials extends JavaPlugin implements IEssentials } return null; } - + @Override public User getOfflineUser(final String name) { diff --git a/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java b/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java index 56098832e..8887955a4 100644 --- a/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java +++ b/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java @@ -335,14 +335,13 @@ public class EssentialsPlayerListener implements Listener }); } } - private final static List<String> COMMANDS = Arrays.asList("msg", "r", "mail", "m", "t", "whisper", "emsg", "tell", "er", "reply", "ereply", "email", "action", "describe", "eme", "eaction", "edescribe", "etell", "ewhisper", "pm"); @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onPlayerCommandPreprocess(final PlayerCommandPreprocessEvent event) { final Player player = event.getPlayer(); final String cmd = event.getMessage().toLowerCase(Locale.ENGLISH).split(" ")[0].replace("/", "").toLowerCase(Locale.ENGLISH); - if (COMMANDS.contains(cmd)) + if (ess.getSettings().getSocialSpyCommands().contains(cmd)) { for (Player onlinePlayer : ess.getServer().getOnlinePlayers()) { @@ -538,6 +537,14 @@ public class EssentialsPlayerListener implements Listener event.setCancelled(true); } } + else if (event.getView().getTopInventory().getType() == InventoryType.WORKBENCH) + { + User user = ess.getUser(event.getWhoClicked()); + if (user.isRecipeSee()) + { + event.setCancelled(true); + } + } } @EventHandler(priority = EventPriority.MONITOR) @@ -553,12 +560,21 @@ public class EssentialsPlayerListener implements Listener final User user = ess.getUser(event.getPlayer()); user.setEnderSee(false); } + if (event.getView().getTopInventory().getType() == InventoryType.WORKBENCH) + { + final User user = ess.getUser(event.getPlayer()); + if(user.isRecipeSee()) + { + user.setRecipeSee(false); + event.getView().getTopInventory().clear(); + } + } } - + @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void onPlayerFishEvent(final PlayerFishEvent event) { final User user = ess.getUser(event.getPlayer()); user.updateActivity(true); } -}
\ No newline at end of file +} diff --git a/Essentials/src/com/earth2me/essentials/ISettings.java b/Essentials/src/com/earth2me/essentials/ISettings.java index fb0073c8a..a261c80bb 100644 --- a/Essentials/src/com/earth2me/essentials/ISettings.java +++ b/Essentials/src/com/earth2me/essentials/ISettings.java @@ -42,6 +42,8 @@ public interface ISettings extends IConf double getHealCooldown(); + Set<String> getSocialSpyCommands(); + Map<String, Object> getKit(String name); ConfigurationSection getKits(); @@ -183,4 +185,6 @@ public interface ISettings extends IConf public int getMailsPerMinute(); public void setEssentialsChatActive(boolean b); + + long getMaxTempban(); } diff --git a/Essentials/src/com/earth2me/essentials/Kit.java b/Essentials/src/com/earth2me/essentials/Kit.java index 89965e589..fcd1b4932 100644 --- a/Essentials/src/com/earth2me/essentials/Kit.java +++ b/Essentials/src/com/earth2me/essentials/Kit.java @@ -158,11 +158,11 @@ public class Kit final Map<Integer, ItemStack> overfilled; if (user.isAuthorized("essentials.oversizedstacks")) { - overfilled = InventoryWorkaround.addItem(user.getInventory(), true, ess.getSettings().getOversizedStackSize(), stack); + overfilled = InventoryWorkaround.addOversizedItems(user.getInventory(), ess.getSettings().getOversizedStackSize(), stack); } else { - overfilled = InventoryWorkaround.addItem(user.getInventory(), true, 0, stack); + overfilled = InventoryWorkaround.addItems(user.getInventory(), stack); } for (ItemStack itemStack : overfilled.values()) { diff --git a/Essentials/src/com/earth2me/essentials/OfflinePlayer.java b/Essentials/src/com/earth2me/essentials/OfflinePlayer.java index 571873384..a47b32582 100644 --- a/Essentials/src/com/earth2me/essentials/OfflinePlayer.java +++ b/Essentials/src/com/earth2me/essentials/OfflinePlayer.java @@ -11,11 +11,8 @@ import org.bukkit.conversations.ConversationAbandonedEvent; import org.bukkit.entity.*; import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; -import org.bukkit.inventory.Inventory; -import org.bukkit.inventory.InventoryView; +import org.bukkit.inventory.*; import org.bukkit.inventory.InventoryView.Property; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.PlayerInventory; import org.bukkit.map.MapView; import org.bukkit.metadata.MetadataValue; import org.bukkit.permissions.Permission; @@ -1117,4 +1114,40 @@ public class OfflinePlayer implements Player { throw new UnsupportedOperationException("Not supported yet."); } + + @Override + public boolean getRemoveWhenFarAway() + { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setRemoveWhenFarAway(boolean bln) + { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public EntityEquipment getEquipment() + { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setCanPickupItems(boolean bln) + { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean getCanPickupItems() + { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Location getLocation(Location lctn) + { + throw new UnsupportedOperationException("Not supported yet."); + } } diff --git a/Essentials/src/com/earth2me/essentials/Settings.java b/Essentials/src/com/earth2me/essentials/Settings.java index 416602c4d..d3c6b49d5 100644 --- a/Essentials/src/com/earth2me/essentials/Settings.java +++ b/Essentials/src/com/earth2me/essentials/Settings.java @@ -191,9 +191,9 @@ public class Settings implements ISettings for (String command : section.getKeys(false)) { PluginCommand cmd = ess.getServer().getPluginCommand(command); - if (cmd == null || !cmd.getPlugin().equals(ess)) + if (command.charAt(0) == '/') { - ess.getLogger().warning("Invalid command cost. '" + command + "' is not a command handled by Essentials."); + ess.getLogger().warning("Invalid command cost. '" + command + "' should not start with '/'."); } if (section.isDouble(command)) { @@ -237,6 +237,31 @@ public class Settings implements ISettings } return 0.0; } + private Set<String> socialSpyCommands = new HashSet<String>(); + + public Set<String> _getSocialSpyCommands() + { + Set<String> socialspyCommands = new HashSet<String>(); + + if (config.isConfigurationSection("socialspy-commands")) + { + for (String c : config.getStringList("socialspy-commands")) + { + socialspyCommands.add(c.toLowerCase(Locale.ENGLISH)); + } + } + else + { + socialspyCommands.addAll(Arrays.asList("msg", "r", "mail", "m", "whisper", "emsg", "t", "tell", "er", "reply", "ereply", "email", "action", "describe", "eme", "eaction", "edescribe", "etell", "ewhisper", "pm")); + } + + return socialspyCommands; + } + + public Set<String> getSocialSpyCommands() + { + return socialSpyCommands; + } private String nicknamePrefix = "~"; private String _getNicknamePrefix() @@ -462,6 +487,7 @@ public class Settings implements ISettings disableSuffix = _disableSuffix(); chatRadius = _getChatRadius(); commandCosts = _getCommandCosts(); + socialSpyCommands = _getSocialSpyCommands(); warnOnBuildDisallow = _warnOnBuildDisallow(); mailsPerMinute = _getMailsPerMinute(); } @@ -982,4 +1008,10 @@ public class Settings implements ISettings { return mailsPerMinute; } + + @Override + public long getMaxTempban() + { + return config.getLong("max-tempban-time", -1); + } } diff --git a/Essentials/src/com/earth2me/essentials/SpawnMob.java b/Essentials/src/com/earth2me/essentials/SpawnMob.java index 8ea5c9492..7eb59974c 100644 --- a/Essentials/src/com/earth2me/essentials/SpawnMob.java +++ b/Essentials/src/com/earth2me/essentials/SpawnMob.java @@ -12,6 +12,7 @@ import org.bukkit.Server; import org.bukkit.block.Block; import org.bukkit.command.CommandSender; import org.bukkit.entity.*; +import org.bukkit.entity.Skeleton.SkeletonType; import org.bukkit.material.Colorable; @@ -34,20 +35,20 @@ public class SpawnMob } return Util.joinList(availableList); } - - public static String[] mobData(final String mobString) + + public static String[] mobData(final String mobString) { String[] returnString = new String[4]; - + final String[] parts = mobString.split(","); String[] mobParts = parts[0].split(":"); - + returnString[0] = mobParts[0]; if (mobParts.length == 2) { returnString[1] = mobParts[1]; } - + if (parts.length > 1) { String[] mountParts = parts[1].split(":"); @@ -57,8 +58,8 @@ public class SpawnMob returnString[3] = mountParts[1]; } } - - return returnString; + + return returnString; } // This method spawns a mob where the user is looking, owned by user @@ -71,7 +72,7 @@ public class SpawnMob } spawnmob(ess, server, user, user, block.getLocation(), Data, mobCount); } - + // This method spawns a mob at loc, owned by noone public static void spawnmob(final IEssentials ess, final Server server, final CommandSender sender, final Location loc, final String[] Data, int mobCount) throws Exception { @@ -83,7 +84,7 @@ public class SpawnMob { spawnmob(ess, server, sender, target, target.getLocation(), Data, mobCount); } - + // This method spawns a mob at loc, owned by target public static void spawnmob(final IEssentials ess, final Server server, final CommandSender sender, final User target, final Location loc, final String[] Data, int mobCount) throws Exception { @@ -91,7 +92,7 @@ public class SpawnMob final String mobType = Data[0]; final String mobData = Data[1]; final String mountType = Data[2]; - final String mountData = Data[3]; + final String mountData = Data[3]; Mob mob = Mob.fromName(mobType); Mob mobMount = null; @@ -137,7 +138,7 @@ public class SpawnMob { Entity spawnedMob = mob.spawn(sloc.getWorld(), server, sloc); Entity spawnedMount = null; - + if (mobMount != null) { spawnedMount = mobMount.spawn(sloc.getWorld(), server, sloc); @@ -186,14 +187,16 @@ public class SpawnMob throw new Exception(_("slimeMalformedSize"), e); } } - if (spawned instanceof Ageable && data.contains("baby")) + + if ((spawned instanceof Ageable) && data.contains("baby")) { ((Ageable)spawned).setBaby(); - return; + data = data.replace("baby", ""); } + if (spawned instanceof Colorable) { - final String color = data.toUpperCase(Locale.ENGLISH).replace("BABY", ""); + final String color = data.toUpperCase(Locale.ENGLISH); try { if (color.equals("RANDOM")) @@ -201,7 +204,7 @@ public class SpawnMob final Random rand = new Random(); ((Colorable)spawned).setColor(DyeColor.values()[rand.nextInt(DyeColor.values().length)]); } - else + else if (color.length() > 1) { ((Colorable)spawned).setColor(DyeColor.valueOf(color)); } @@ -211,21 +214,28 @@ public class SpawnMob throw new Exception(_("sheepMalformedColor"), e); } } + if (spawned instanceof Tameable && data.contains("tamed") && target != null) { final Tameable tameable = ((Tameable)spawned); tameable.setTamed(true); tameable.setOwner(target.getBase()); + data = data.replace("tamed", ""); } - if (type == EntityType.WOLF - && data.contains("angry")) + + if (type == EntityType.WOLF) { - ((Wolf)spawned).setAngry(true); + if (data.contains("angry")) + { + ((Wolf)spawned).setAngry(true); + } } + if (type == EntityType.CREEPER && data.contains("powered")) { ((Creeper)spawned).setPowered(true); } + if (type == EntityType.OCELOT) { if (data.contains("siamese")) @@ -241,6 +251,7 @@ public class SpawnMob ((Ocelot)spawned).setCatType(Ocelot.Type.BLACK_CAT); } } + if (type == EntityType.VILLAGER) { for (Villager.Profession prof : Villager.Profession.values()) @@ -251,5 +262,26 @@ public class SpawnMob } } } + + if (spawned instanceof Zombie) + { + if (data.contains("villager")) + { + ((Zombie)spawned).setVillager(true); + } + if (data.contains("baby")) + { + ((Zombie)spawned).setBaby(true); + } + } + + if (type == EntityType.SKELETON) + { + if (data.contains("wither")) + { + ((Skeleton)spawned).setSkeletonType(SkeletonType.WITHER); + } + } + } } diff --git a/Essentials/src/com/earth2me/essentials/Trade.java b/Essentials/src/com/earth2me/essentials/Trade.java index 420525e63..1a03a0145 100644 --- a/Essentials/src/com/earth2me/essentials/Trade.java +++ b/Essentials/src/com/earth2me/essentials/Trade.java @@ -77,7 +77,7 @@ public class Trade } if (getItemStack() != null - && !InventoryWorkaround.containsItem(user.getInventory(), true, true, itemStack)) + && !user.getInventory().containsAtLeast(itemStack, itemStack.getAmount())) { throw new ChargeException(_("missingItems", getItemStack().getAmount(), getItemStack().getType().toString().toLowerCase(Locale.ENGLISH).replace("_", " "))); } @@ -113,7 +113,7 @@ public class Trade { if (dropItems) { - final Map<Integer, ItemStack> leftOver = InventoryWorkaround.addItem(user.getInventory(), true, getItemStack()); + final Map<Integer, ItemStack> leftOver = InventoryWorkaround.addItems(user.getInventory(), getItemStack()); final Location loc = user.getLocation(); for (ItemStack itemStack : leftOver.values()) { @@ -137,7 +137,7 @@ public class Trade } else { - success = InventoryWorkaround.addAllItems(user.getInventory(), true, getItemStack()); + success = InventoryWorkaround.addAllItems(user.getInventory(), getItemStack()); } user.updateInventory(); } @@ -165,11 +165,11 @@ public class Trade } if (getItemStack() != null) { - if (!InventoryWorkaround.containsItem(user.getInventory(), true, true, itemStack)) + if (!user.getInventory().containsAtLeast(itemStack, itemStack.getAmount())) { throw new ChargeException(_("missingItems", getItemStack().getAmount(), getItemStack().getType().toString().toLowerCase(Locale.ENGLISH).replace("_", " "))); } - InventoryWorkaround.removeItem(user.getInventory(), true, true, getItemStack()); + user.getInventory().removeItem(getItemStack()); user.updateInventory(); } if (command != null) diff --git a/Essentials/src/com/earth2me/essentials/User.java b/Essentials/src/com/earth2me/essentials/User.java index 5de4b7609..bb1e290f4 100644 --- a/Essentials/src/com/earth2me/essentials/User.java +++ b/Essentials/src/com/earth2me/essentials/User.java @@ -29,6 +29,7 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser private boolean rightClickJump = false; private transient Location afkPosition = null; private boolean invSee = false; + private boolean recipeSee = false; private boolean enderSee = false; private static final Logger logger = Logger.getLogger("Minecraft"); @@ -79,11 +80,6 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser return false; } - if (isJailed()) - { - return false; - } - try { return ess.getPermissionsHandler().hasPermission(base, node); @@ -743,4 +739,14 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser { return this.isAuthorized("essentials.chat.ignoreexempt"); } + + public boolean isRecipeSee() + { + return recipeSee; + } + + public void setRecipeSee(boolean recipeSee) + { + this.recipeSee = recipeSee; + } } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandgive.java b/Essentials/src/com/earth2me/essentials/commands/Commandgive.java index c5c1a0b6b..c4e26d9a8 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandgive.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandgive.java @@ -94,11 +94,11 @@ public class Commandgive extends EssentialsCommand sender.sendMessage(_("giveSpawn", stack.getAmount(), itemName, giveTo.getDisplayName())); if (giveTo.isAuthorized("essentials.oversizedstacks")) { - InventoryWorkaround.addItem(giveTo.getInventory(), true, ess.getSettings().getOversizedStackSize(), stack); + InventoryWorkaround.addOversizedItems(giveTo.getInventory(), ess.getSettings().getOversizedStackSize(), stack); } else { - InventoryWorkaround.addItem(giveTo.getInventory(), true, stack); + InventoryWorkaround.addItems(giveTo.getInventory(), stack); } giveTo.updateInventory(); } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandhat.java b/Essentials/src/com/earth2me/essentials/commands/Commandhat.java index 5dd0fbb74..7ab9a446c 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandhat.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandhat.java @@ -31,7 +31,7 @@ public class Commandhat extends EssentialsCommand { final ItemStack air = new ItemStack(Material.AIR); inv.setHelmet(air); - InventoryWorkaround.addItem(user.getInventory(), true, head); + InventoryWorkaround.addItems(user.getInventory(), head); user.sendMessage(_("hatRemoved")); } } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commanditem.java b/Essentials/src/com/earth2me/essentials/commands/Commanditem.java index 1a77d772d..d14b04d2a 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commanditem.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commanditem.java @@ -87,11 +87,11 @@ public class Commanditem extends EssentialsCommand user.sendMessage(_("itemSpawn", stack.getAmount(), displayName)); if (user.isAuthorized("essentials.oversizedstacks")) { - InventoryWorkaround.addItem(user.getInventory(), true, ess.getSettings().getOversizedStackSize(), stack); + InventoryWorkaround.addOversizedItems(user.getInventory(), ess.getSettings().getOversizedStackSize(), stack); } else { - InventoryWorkaround.addItem(user.getInventory(), true, stack); + InventoryWorkaround.addItems(user.getInventory(), stack); } user.updateInventory(); } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandrecipe.java b/Essentials/src/com/earth2me/essentials/commands/Commandrecipe.java new file mode 100755 index 000000000..e5c69a88b --- /dev/null +++ b/Essentials/src/com/earth2me/essentials/commands/Commandrecipe.java @@ -0,0 +1,189 @@ +package com.earth2me.essentials.commands;
+
+import static com.earth2me.essentials.I18n._;
+import com.earth2me.essentials.User;
+import com.earth2me.essentials.Util;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Map.Entry;
+import org.bukkit.Material;
+import org.bukkit.Server;
+import org.bukkit.command.CommandSender;
+import org.bukkit.entity.Player;
+import org.bukkit.inventory.FurnaceRecipe;
+import org.bukkit.inventory.InventoryView;
+import org.bukkit.inventory.ItemStack;
+import org.bukkit.inventory.Recipe;
+import org.bukkit.inventory.ShapedRecipe;
+import org.bukkit.inventory.ShapelessRecipe;
+
+
+public class Commandrecipe extends EssentialsCommand
+{
+ public Commandrecipe()
+ {
+ super("recipe");
+ }
+
+ @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();
+ }
+
+ final ItemStack itemType = ess.getItemDb().get(args[0]);
+ int recipeNo = 0;
+
+ if (args.length > 1)
+ {
+ if (Util.isInt(args[1]))
+ {
+ recipeNo = Integer.parseInt(args[1]) - 1;
+ }
+ else
+ {
+ throw new Exception(_("invalidNumber"));
+ }
+ }
+
+ final List<Recipe> recipesOfType = ess.getServer().getRecipesFor(itemType);
+ if (recipesOfType.size() < 1)
+ {
+ throw new Exception(_("recipeNone", getMaterialName(itemType)));
+ }
+
+ if (recipeNo < 0 || recipeNo >= recipesOfType.size())
+ {
+ throw new Exception(_("recipeBadIndex"));
+ }
+
+ final Recipe selectedRecipe = recipesOfType.get(recipeNo);
+ sender.sendMessage(_("recipe", getMaterialName(itemType), recipeNo + 1, recipesOfType.size()));
+
+ if (selectedRecipe instanceof FurnaceRecipe)
+ {
+ furnaceRecipe(sender, (FurnaceRecipe)selectedRecipe);
+ }
+ else if (selectedRecipe instanceof ShapedRecipe)
+ {
+ shapedRecipe(sender, (ShapedRecipe)selectedRecipe);
+ }
+ else if (selectedRecipe instanceof ShapelessRecipe)
+ {
+ shapelessRecipe(sender, (ShapelessRecipe)selectedRecipe);
+ }
+
+ if (recipesOfType.size() > 1 && args.length == 1)
+ {
+ sender.sendMessage(_("recipeMore", commandLabel, args[0], getMaterialName(itemType)));
+ }
+ }
+
+ public void furnaceRecipe(final CommandSender sender, final FurnaceRecipe recipe)
+ {
+ sender.sendMessage(_("recipeFurnace", getMaterialName(recipe.getInput())));
+ }
+
+ public void shapedRecipe(final CommandSender sender, final ShapedRecipe recipe)
+ {
+ final Map<Character, ItemStack> recipeMap = recipe.getIngredientMap();
+
+ if (sender instanceof Player)
+ {
+ final User user = ess.getUser(sender);
+ user.setRecipeSee(true);
+ final InventoryView view = user.openWorkbench(null, true);
+ final String shapeMap = recipe.getShape().length == 2 ? " abecdfghi" : " abcdefghi";
+ for (Entry<Character, ItemStack> e : ((ShapedRecipe)recipe).getIngredientMap().entrySet())
+ {
+ e.getValue().setAmount(0);
+ view.setItem(shapeMap.indexOf(e.getKey()), e.getValue());
+ }
+
+ }
+ else
+ {
+ final HashMap<Material, String> colorMap = new HashMap<Material, String>();
+ int i = 1;
+ for (Character c : "abcdefghi".toCharArray())
+ {
+ ItemStack item = recipeMap.get(c);
+ if (!colorMap.containsKey(item == null ? null : item.getType()))
+ {
+ colorMap.put(item == null ? null : item.getType(), String.valueOf(i++));
+ }
+ }
+ final Material[][] materials = new Material[3][3];
+ for (int j = 0; j < recipe.getShape().length; j++)
+ {
+ for (int k = 0; k < recipe.getShape()[j].length(); k++)
+ {
+ ItemStack item = recipe.getIngredientMap().get(recipe.getShape()[j].toCharArray()[k]);
+ materials[j][k] = item == null ? null : item.getType();
+ }
+ }
+ sender.sendMessage(_("recipeGrid", colorMap.get(materials[0][0]), colorMap.get(materials[0][1]), colorMap.get(materials[0][2])));
+ sender.sendMessage(_("recipeGrid", colorMap.get(materials[1][0]), colorMap.get(materials[1][1]), colorMap.get(materials[1][2])));
+ sender.sendMessage(_("recipeGrid", colorMap.get(materials[2][0]), colorMap.get(materials[2][1]), colorMap.get(materials[2][2])));
+
+ StringBuilder s = new StringBuilder();
+ for (Material items : colorMap.keySet().toArray(new Material[colorMap.size()]))
+ {
+ s.append(_("recipeGridItem", colorMap.get(items), getMaterialName(items)));
+ }
+ sender.sendMessage(_("recipeWhere", s.toString()));
+ }
+ }
+
+ public void shapelessRecipe(final CommandSender sender, final ShapelessRecipe recipe)
+ {
+ final List<ItemStack> ingredients = recipe.getIngredientList();
+ if (sender instanceof Player)
+ {
+ final User user = ess.getUser(sender);
+ user.setRecipeSee(true);
+ final InventoryView view = user.openWorkbench(null, true);
+ for (int i = 0; i < ingredients.size(); i++)
+ {
+ view.setItem(i + 1, ingredients.get(i));
+ }
+
+ }
+ else
+ {
+ StringBuilder s = new StringBuilder();
+ for (int i = 0; i < ingredients.size(); i++)
+ {
+ s.append(getMaterialName(ingredients.get(i)));
+ if (i != ingredients.size() - 1)
+ {
+ s.append(",");
+ }
+ s.append(" ");
+ }
+ sender.sendMessage(_("recipeShapeless", s.toString()));
+ }
+ }
+
+ public String getMaterialName(final ItemStack stack)
+ {
+ if (stack == null)
+ {
+ return _("recipeNothing");
+ }
+ return getMaterialName(stack.getType());
+ }
+
+ public String getMaterialName(final Material type)
+ {
+ if (type == null)
+ {
+ return _("recipeNothing");
+ }
+ return type.toString().replace("_", " ").toLowerCase(Locale.ENGLISH);
+ }
+}
\ No newline at end of file diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandseen.java b/Essentials/src/com/earth2me/essentials/commands/Commandseen.java index 24f1f9c41..5c204fda5 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandseen.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandseen.java @@ -35,12 +35,23 @@ public class Commandseen extends EssentialsCommand } try { - User player = getPlayer(server, args, 0); - player.setDisplayNick(); - sender.sendMessage(_("seenOnline", player.getDisplayName(), Util.formatDateDiff(player.getLastLogin()))); + User user = getPlayer(server, args, 0); + user.setDisplayNick(); + sender.sendMessage(_("seenOnline", user.getDisplayName(), Util.formatDateDiff(user.getLastLogin()))); + sender.sendMessage(_("whoisAFK", (user.isAfk() ? _("true") : _("false")))); + sender.sendMessage(_("whoisJail", (user.isJailed() + ? user.getJailTimeout() > 0 + ? Util.formatDateDiff(user.getJailTimeout()) + : _("true") + : _("false")))); + sender.sendMessage(_("whoisMuted", (user.isMuted() + ? user.getMuteTimeout() > 0 + ? Util.formatDateDiff(user.getMuteTimeout()) + : _("true") + : _("false")))); if (extra) { - sender.sendMessage(_("whoisIPAddress", player.getAddress().getAddress().toString())); + sender.sendMessage(_("whoisIPAddress", user.getAddress().getAddress().toString())); } } catch (NoSuchFieldException e) @@ -60,7 +71,8 @@ public class Commandseen extends EssentialsCommand { sender.sendMessage(_("whoisIPAddress", player.getLastLoginAddress())); final Location loc = player.getLastLocation(); - if (loc != null) { + if (loc != null) + { sender.sendMessage(_("whoisLocation", loc.getWorld().getName(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ())); } } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandsell.java b/Essentials/src/com/earth2me/essentials/commands/Commandsell.java index 904990e39..ec3262958 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandsell.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandsell.java @@ -166,7 +166,7 @@ public class Commandsell extends EssentialsCommand //TODO: Prices for Enchantments final ItemStack ris = is.clone(); ris.setAmount(amount); - InventoryWorkaround.removeItem(user.getInventory(), true, true, ris); + user.getInventory().removeItem(ris); user.updateInventory(); Trade.log("Command", "Sell", "Item", user.getName(), new Trade(ris, ess), user.getName(), new Trade(worth * amount, ess), user.getLocation(), ess); user.giveMoney(worth * amount); diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtempban.java b/Essentials/src/com/earth2me/essentials/commands/Commandtempban.java index 0549e9c0d..97aa2ea3b 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandtempban.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandtempban.java @@ -4,6 +4,8 @@ import com.earth2me.essentials.Console; import static com.earth2me.essentials.I18n._; import com.earth2me.essentials.User; import com.earth2me.essentials.Util; +import java.util.Calendar; +import java.util.GregorianCalendar; import org.bukkit.Server; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; @@ -35,7 +37,7 @@ public class Commandtempban extends EssentialsCommand } else { - if (user.isAuthorized("essentials.tempban.exempt")) + if (user.isAuthorized("essentials.tempban.exempt") && sender instanceof Player) { sender.sendMessage(_("tempbanExempt")); return; @@ -44,6 +46,13 @@ public class Commandtempban extends EssentialsCommand final String time = getFinalArg(args, 1); final long banTimestamp = Util.parseDateDiff(time, true); + final long maxBanLength = ess.getSettings().getMaxTempban() * 1000; + if(maxBanLength > 0 && ((banTimestamp - GregorianCalendar.getInstance().getTimeInMillis()) > maxBanLength) && ess.getUser(sender).isAuthorized("essentials.tempban.unlimited")) + { + sender.sendMessage(_("oversizedTempban")); + throw new NoChargeException(); + } + final String senderName = sender instanceof Player ? ((Player)sender).getDisplayName() : Console.NAME; final String banReason = _("tempBanned", Util.formatDateDiff(banTimestamp), senderName); user.setBanReason(banReason); diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtp.java b/Essentials/src/com/earth2me/essentials/commands/Commandtp.java index 64332be68..59dbc1a3e 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandtp.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandtp.java @@ -46,7 +46,6 @@ public class Commandtp extends EssentialsCommand { throw new Exception(_("noPerm", "essentials.tp.others")); } - user.sendMessage(_("teleporting")); final User target2 = getPlayer(server, args, 0); final double x = args[1].startsWith("~") ? target2.getLocation().getX() + Integer.parseInt(args[1].substring(1)) : Integer.parseInt(args[1]); final double y = args[2].startsWith("~") ? target2.getLocation().getY() + Integer.parseInt(args[2].substring(1)) : Integer.parseInt(args[2]); @@ -61,14 +60,15 @@ public class Commandtp extends EssentialsCommand throw new Exception(_("teleportDisabled", target2.getDisplayName())); } target2.getTeleport().now(location, false, TeleportCause.COMMAND); + user.sendMessage(_("teleporting")); target2.sendMessage(_("teleporting")); + break; case 2: default: if (!user.isAuthorized("essentials.tp.others")) { throw new Exception(_("noPerm", "essentials.tp.others")); } - user.sendMessage(_("teleporting")); final User target = getPlayer(server, args, 0); final User toPlayer = getPlayer(server, args, 1); if (!target.isTeleportEnabled()) @@ -85,6 +85,7 @@ public class Commandtp extends EssentialsCommand throw new Exception(_("noPerm", "essentials.worlds." + toPlayer.getWorld().getName())); } target.getTeleport().now(toPlayer, false, TeleportCause.COMMAND); + user.sendMessage(_("teleporting")); target.sendMessage(_("teleportAtoB", user.getDisplayName(), toPlayer.getDisplayName())); break; } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtpaccept.java b/Essentials/src/com/earth2me/essentials/commands/Commandtpaccept.java index 865492921..7c950ae96 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandtpaccept.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandtpaccept.java @@ -1,5 +1,6 @@ package com.earth2me.essentials.commands; +import com.earth2me.essentials.ChargeException; import static com.earth2me.essentials.I18n._; import com.earth2me.essentials.Trade; import com.earth2me.essentials.User; @@ -52,24 +53,24 @@ public class Commandtpaccept extends EssentialsCommand } final Trade charge = new Trade(this.getName(), ess); - if (user.isTpRequestHere()) - { - charge.isAffordableFor(user); - } - else - { - charge.isAffordableFor(target); - } user.sendMessage(_("requestAccepted")); target.sendMessage(_("requestAcceptedFrom", user.getDisplayName())); - if (user.isTpRequestHere()) + try { - target.getTeleport().teleportToMe(user, charge, TeleportCause.COMMAND); + if (user.isTpRequestHere()) + { + target.getTeleport().teleportToMe(user, charge, TeleportCause.COMMAND); + } + else + { + target.getTeleport().teleport(user, charge, TeleportCause.COMMAND); + } } - else + catch (ChargeException ex) { - target.getTeleport().teleport(user, charge, TeleportCause.COMMAND); + user.sendMessage(_("pendingTeleportCancelled")); + ess.showError(target, ex, commandLabel); } user.requestTeleport(null, false); throw new NoChargeException(); diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandunlimited.java b/Essentials/src/com/earth2me/essentials/commands/Commandunlimited.java index 38a8725ba..fd0f3be2c 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandunlimited.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandunlimited.java @@ -103,7 +103,7 @@ public class Commandunlimited extends EssentialsCommand { message = "enableUnlimited"; enableUnlimited = true; - if (!InventoryWorkaround.containsItem(target.getInventory(), true, true, stack)) + if (!target.getInventory().containsAtLeast(stack, stack.getAmount())) { target.getInventory().addItem(stack); } diff --git a/Essentials/src/com/earth2me/essentials/craftbukkit/FakeInventory.java b/Essentials/src/com/earth2me/essentials/craftbukkit/FakeInventory.java deleted file mode 100644 index 8456c956e..000000000 --- a/Essentials/src/com/earth2me/essentials/craftbukkit/FakeInventory.java +++ /dev/null @@ -1,243 +0,0 @@ -package com.earth2me.essentials.craftbukkit; - -import java.util.HashMap; -import java.util.List; -import java.util.ListIterator; -import org.bukkit.Material; -import org.bukkit.entity.HumanEntity; -import org.bukkit.event.inventory.InventoryType; -import org.bukkit.inventory.Inventory; -import org.bukkit.inventory.InventoryHolder; -import org.bukkit.inventory.ItemStack; - - -public class FakeInventory implements Inventory -{ - ItemStack[] items; - - public FakeInventory(ItemStack[] items) - { - this.items = new ItemStack[items.length]; - for (int i = 0; i < items.length; i++) - { - if (items[i] == null) - { - continue; - } - this.items[i] = items[i].clone(); - } - } - - @Override - public int getSize() - { - return items.length; - } - - @Override - public String getName() - { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public ItemStack getItem(int i) - { - return items[i]; - } - - @Override - public void setItem(int i, ItemStack is) - { - items[i] = is; - } - - @Override - public HashMap<Integer, ItemStack> addItem(ItemStack... iss) - { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public HashMap<Integer, ItemStack> removeItem(ItemStack... iss) - { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public ItemStack[] getContents() - { - return items; - } - - @Override - public void setContents(ItemStack[] iss) - { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public boolean contains(int i) - { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public boolean contains(Material mtrl) - { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public boolean contains(ItemStack is) - { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public boolean contains(int i, int i1) - { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public boolean contains(Material mtrl, int i) - { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public boolean contains(ItemStack is, int i) - { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public HashMap<Integer, ? extends ItemStack> all(int i) - { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public HashMap<Integer, ? extends ItemStack> all(Material mtrl) - { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public HashMap<Integer, ? extends ItemStack> all(ItemStack is) - { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public int first(int i) - { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public int first(Material mtrl) - { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public int first(ItemStack is) - { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public int firstEmpty() - { - for (int i = 0; i < items.length; i++) - { - if (items[i] == null || items[i].getTypeId() == 0) { - return i; - } - } - return -1; - } - - @Override - public void remove(int i) - { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public void remove(Material mtrl) - { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public void remove(ItemStack is) - { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public void clear(int i) - { - items[i] = null; - } - - @Override - public void clear() - { - for (int i = 0; i < items.length; i++) - { - items[i] = null; - } - } - - @Override - public List<HumanEntity> getViewers() - { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public String getTitle() - { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public InventoryType getType() - { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public InventoryHolder getHolder() - { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public ListIterator<ItemStack> iterator() - { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public int getMaxStackSize() - { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public void setMaxStackSize(int size) - { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public ListIterator<ItemStack> iterator(int index) - { - throw new UnsupportedOperationException("Not supported yet."); - } -} diff --git a/Essentials/src/com/earth2me/essentials/craftbukkit/FakeWorld.java b/Essentials/src/com/earth2me/essentials/craftbukkit/FakeWorld.java index 7239ea475..df7a237fa 100644 --- a/Essentials/src/com/earth2me/essentials/craftbukkit/FakeWorld.java +++ b/Essentials/src/com/earth2me/essentials/craftbukkit/FakeWorld.java @@ -735,4 +735,10 @@ public class FakeWorld implements World { throw new UnsupportedOperationException("Not supported yet."); } + + @Override + public boolean createExplosion(double d, double d1, double d2, float f, boolean bln, boolean bln1) + { + throw new UnsupportedOperationException("Not supported yet."); + } } diff --git a/Essentials/src/com/earth2me/essentials/craftbukkit/InventoryWorkaround.java b/Essentials/src/com/earth2me/essentials/craftbukkit/InventoryWorkaround.java index fc9cbb74b..2e05f5c43 100644 --- a/Essentials/src/com/earth2me/essentials/craftbukkit/InventoryWorkaround.java +++ b/Essentials/src/com/earth2me/essentials/craftbukkit/InventoryWorkaround.java @@ -2,6 +2,7 @@ package com.earth2me.essentials.craftbukkit; import java.util.HashMap; import java.util.Map; +import org.bukkit.Bukkit; import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; @@ -15,49 +16,17 @@ public final class InventoryWorkaround { } - public static int first(final Inventory inventory, final ItemStack item, final boolean enforceDurability, final boolean enforceAmount, final boolean enforceEnchantments) - { - return next(inventory, item, 0, enforceDurability, enforceAmount, enforceEnchantments); - } - - public static int next(final Inventory cinventory, final ItemStack item, final int start, final boolean enforceDurability, final boolean enforceAmount, final boolean enforceEnchantments) - { - final ItemStack[] inventory = cinventory.getContents(); - for (int i = start; i < inventory.length; i++) - { - final ItemStack cItem = inventory[i]; - if (cItem == null) - { - continue; - } - if (item.getTypeId() == cItem.getTypeId() && (!enforceAmount || item.getAmount() == cItem.getAmount()) && (!enforceDurability || cItem.getDurability() == item.getDurability()) && (!enforceEnchantments || cItem.getEnchantments().equals(item.getEnchantments()))) - { - return i; - } - } - return -1; - } - - public static int firstPartial(final Inventory cinventory, final ItemStack item, final boolean enforceDurability) - { - return firstPartial(cinventory, item, enforceDurability, item.getType().getMaxStackSize()); - } - - public static int firstPartial(final Inventory cinventory, final ItemStack item, final boolean enforceDurability, final int maxAmount) + private static int firstPartial(final Inventory inventory, final ItemStack item, final int maxAmount) { if (item == null) { return -1; } - final ItemStack[] inventory = cinventory.getContents(); - for (int i = 0; i < inventory.length; i++) + final ItemStack[] stacks = inventory.getContents(); + for (int i = 0; i < stacks.length; i++) { - final ItemStack cItem = inventory[i]; - if (cItem == null) - { - continue; - } - if (item.getTypeId() == cItem.getTypeId() && cItem.getAmount() < maxAmount && (!enforceDurability || cItem.getDurability() == item.getDurability()) && cItem.getEnchantments().equals(item.getEnchantments())) + final ItemStack cItem = stacks[i]; + if (cItem != null && cItem.getAmount() < maxAmount && cItem.isSimilar(item)) { return i; } @@ -65,26 +34,24 @@ public final class InventoryWorkaround return -1; } - public static boolean addAllItems(final Inventory cinventory, final boolean enforceDurability, final ItemStack... items) + public static boolean addAllItems(final Inventory inventory, final ItemStack... items) { - final Inventory fake = new FakeInventory(cinventory.getContents()); - if (addItem(fake, enforceDurability, items).isEmpty()) + final Inventory fakeInventory = Bukkit.getServer().createInventory(null, inventory.getType()); + fakeInventory.setContents(inventory.getContents()); + if (addItems(fakeInventory, items).isEmpty()) { - addItem(cinventory, enforceDurability, items); + addItems(inventory, items); return true; } - else - { - return false; - } + return false; } - public static Map<Integer, ItemStack> addItem(final Inventory cinventory, final boolean forceDurability, final ItemStack... items) + public static Map<Integer, ItemStack> addItems(final Inventory inventory, final ItemStack... items) { - return addItem(cinventory, forceDurability, 0, items); + return addOversizedItems(inventory, 0, items); } - public static Map<Integer, ItemStack> addItem(final Inventory cinventory, final boolean enforceDurability, final int oversizedStacks, final ItemStack... items) + public static Map<Integer, ItemStack> addOversizedItems(final Inventory inventory, final int oversizedStacks, final ItemStack... items) { final Map<Integer, ItemStack> leftover = new HashMap<Integer, ItemStack>(); @@ -95,7 +62,7 @@ public final class InventoryWorkaround // combine items - ItemStack[] combined = new ItemStack[items.length]; + final ItemStack[] combined = new ItemStack[items.length]; for (int i = 0; i < items.length; i++) { if (items[i] == null || items[i].getAmount() < 1) @@ -109,7 +76,7 @@ public final class InventoryWorkaround combined[j] = items[i].clone(); break; } - if (combined[j].getTypeId() == items[i].getTypeId() && (!enforceDurability || combined[j].getDurability() == items[i].getDurability()) && combined[j].getEnchantments().equals(items[i].getEnchantments())) + if (combined[j].isSimilar(items[i])) { combined[j].setAmount(combined[j].getAmount() + items[i].getAmount()); break; @@ -130,13 +97,13 @@ public final class InventoryWorkaround { // Do we already have a stack of it? final int maxAmount = oversizedStacks > item.getType().getMaxStackSize() ? oversizedStacks : item.getType().getMaxStackSize(); - final int firstPartial = firstPartial(cinventory, item, enforceDurability, maxAmount); + final int firstPartial = firstPartial(inventory, item, maxAmount); // Drat! no partial stack if (firstPartial == -1) { // Find a free spot! - final int firstFree = cinventory.firstEmpty(); + final int firstFree = inventory.firstEmpty(); if (firstFree == -1) { @@ -151,13 +118,13 @@ public final class InventoryWorkaround { final ItemStack stack = item.clone(); stack.setAmount(maxAmount); - cinventory.setItem(firstFree, stack); + inventory.setItem(firstFree, stack); item.setAmount(item.getAmount() - maxAmount); } else { // Just store it - cinventory.setItem(firstFree, item); + inventory.setItem(firstFree, item); break; } } @@ -165,7 +132,7 @@ public final class InventoryWorkaround else { // So, apparently it might only partially fit, well lets do just that - final ItemStack partialItem = cinventory.getItem(firstPartial); + final ItemStack partialItem = inventory.getItem(firstPartial); final int amount = item.getAmount(); final int partialAmount = partialItem.getAmount(); @@ -185,138 +152,4 @@ public final class InventoryWorkaround } return leftover; } - - public static Map<Integer, ItemStack> removeItem(final Inventory cinventory, final boolean enforceDurability, final boolean enforceEnchantments, final ItemStack... items) - { - final Map<Integer, ItemStack> leftover = new HashMap<Integer, ItemStack>(); - - // TODO: optimization - - for (int i = 0; i < items.length; i++) - { - final ItemStack item = items[i]; - if (item == null) - { - continue; - } - int toDelete = item.getAmount(); - - while (true) - { - - // Bail when done - if (toDelete <= 0) - { - break; - } - - // get first Item, ignore the amount - final int first = first(cinventory, item, enforceDurability, false, enforceEnchantments); - - // Drat! we don't have this type in the inventory - if (first == -1) - { - item.setAmount(toDelete); - leftover.put(i, item); - break; - } - else - { - final ItemStack itemStack = cinventory.getItem(first); - final int amount = itemStack.getAmount(); - - if (amount <= toDelete) - { - toDelete -= amount; - // clear the slot, all used up - cinventory.clear(first); - } - else - { - // split the stack and store - itemStack.setAmount(amount - toDelete); - cinventory.setItem(first, itemStack); - toDelete = 0; - } - } - } - } - return leftover; - } - - public static boolean containsItem(final Inventory cinventory, final boolean enforceDurability, final boolean enforceEnchantments, final ItemStack... items) - { - final Map<Integer, ItemStack> leftover = new HashMap<Integer, ItemStack>(); - - // TODO: optimization - - // combine items - - ItemStack[] combined = new ItemStack[items.length]; - for (int i = 0; i < items.length; i++) - { - if (items[i] == null) - { - continue; - } - for (int j = 0; j < combined.length; j++) - { - if (combined[j] == null) - { - combined[j] = items[i].clone(); - break; - } - if (combined[j].getTypeId() == items[i].getTypeId() && (!enforceDurability || combined[j].getDurability() == items[i].getDurability()) && (!enforceEnchantments || combined[j].getEnchantments().equals(items[i].getEnchantments()))) - { - combined[j].setAmount(combined[j].getAmount() + items[i].getAmount()); - break; - } - } - } - - for (int i = 0; i < combined.length; i++) - { - final ItemStack item = combined[i]; - if (item == null) - { - continue; - } - int mustHave = item.getAmount(); - int position = 0; - - while (true) - { - // Bail when done - if (mustHave <= 0) - { - break; - } - - final int slot = next(cinventory, item, position, enforceDurability, false, enforceEnchantments); - - // Drat! we don't have this type in the inventory - if (slot == -1) - { - leftover.put(i, item); - break; - } - else - { - final ItemStack itemStack = cinventory.getItem(slot); - final int amount = itemStack.getAmount(); - - if (amount <= mustHave) - { - mustHave -= amount; - } - else - { - mustHave = 0; - } - position = slot + 1; - } - } - } - return leftover.isEmpty(); - } } diff --git a/Essentials/src/com/earth2me/essentials/metrics/MetricsStarter.java b/Essentials/src/com/earth2me/essentials/metrics/MetricsStarter.java index b0592855d..3e9ee9e49 100644 --- a/Essentials/src/com/earth2me/essentials/metrics/MetricsStarter.java +++ b/Essentials/src/com/earth2me/essentials/metrics/MetricsStarter.java @@ -134,6 +134,14 @@ public class MetricsStarter implements Runnable { enabledGraph.addPlotter(new SimplePlotter("Warps")); } + if (ess.getSettings().getTeleportCooldown() > 0) + { + enabledGraph.addPlotter(new SimplePlotter("TeleportCooldown")); + } + if (ess.getSettings().getTeleportDelay() > 0) + { + enabledGraph.addPlotter(new SimplePlotter("TeleportDelay")); + } if (!ess.getSettings().areSignsDisabled()) { enabledGraph.addPlotter(new SimplePlotter("Signs")); @@ -142,6 +150,14 @@ public class MetricsStarter implements Runnable { enabledGraph.addPlotter(new SimplePlotter("AutoAFK")); } + if (ess.getSettings().changePlayerListName()) + { + enabledGraph.addPlotter(new SimplePlotter("PlayerListName")); + } + if (ess.getSettings().getOperatorColor() != null) + { + enabledGraph.addPlotter(new SimplePlotter("OpColour")); + } if (ess.getSettings().changeDisplayName()) { enabledGraph.addPlotter(new SimplePlotter("DisplayName")); diff --git a/Essentials/src/com/earth2me/essentials/storage/BukkitConstructor.java b/Essentials/src/com/earth2me/essentials/storage/BukkitConstructor.java index b6fbe3b33..8c12acfe3 100644 --- a/Essentials/src/com/earth2me/essentials/storage/BukkitConstructor.java +++ b/Essentials/src/com/earth2me/essentials/storage/BukkitConstructor.java @@ -13,22 +13,22 @@ import org.bukkit.enchantments.Enchantment; import org.bukkit.inventory.ItemStack; import org.bukkit.material.MaterialData; import org.bukkit.plugin.Plugin; -import org.bukkit.plugin.java.JavaPluginLoader; import org.yaml.snakeyaml.TypeDescription; import org.yaml.snakeyaml.constructor.Constructor; +import org.yaml.snakeyaml.constructor.CustomClassLoaderConstructor; import org.yaml.snakeyaml.error.YAMLException; import org.yaml.snakeyaml.introspector.Property; import org.yaml.snakeyaml.nodes.*; -public class BukkitConstructor extends Constructor +public class BukkitConstructor extends CustomClassLoaderConstructor { private final transient Pattern NUMPATTERN = Pattern.compile("\\d+"); private final transient Plugin plugin; public BukkitConstructor(final Class clazz, final Plugin plugin) { - super(clazz); + super(clazz, plugin.getClass().getClassLoader()); this.plugin = plugin; yamlClassConstructors.put(NodeId.scalar, new ConstructBukkitScalar()); yamlClassConstructors.put(NodeId.mapping, new ConstructBukkitMapping()); @@ -276,6 +276,7 @@ public class BukkitConstructor extends Constructor return super.construct(node); } + @Override protected Object constructJavaBean2ndStep(final MappingNode node, final Object object) { Map<Class<? extends Object>, TypeDescription> typeDefinitions; @@ -284,7 +285,8 @@ public class BukkitConstructor extends Constructor final Field typeDefField = Constructor.class.getDeclaredField("typeDefinitions"); typeDefField.setAccessible(true); typeDefinitions = (Map<Class<? extends Object>, TypeDescription>)typeDefField.get((Constructor)BukkitConstructor.this); - if (typeDefinitions == null) { + if (typeDefinitions == null) + { throw new NullPointerException(); } } @@ -402,29 +404,4 @@ public class BukkitConstructor extends Constructor return object; } } - - @Override - protected Class<?> getClassForNode(final Node node) - { - Class<?> clazz; - final String name = node.getTag().getClassName(); - if (plugin == null) - { - clazz = super.getClassForNode(node); - } - else - { - final JavaPluginLoader jpl = (JavaPluginLoader)plugin.getPluginLoader(); - clazz = jpl.getClassByName(name); - } - - if (clazz == null) - { - throw new YAMLException("Class not found: " + name); - } - else - { - return clazz; - } - } } diff --git a/Essentials/src/com/earth2me/essentials/textreader/HelpInput.java b/Essentials/src/com/earth2me/essentials/textreader/HelpInput.java index 4efb6c43f..b091e2135 100644 --- a/Essentials/src/com/earth2me/essentials/textreader/HelpInput.java +++ b/Essentials/src/com/earth2me/essentials/textreader/HelpInput.java @@ -47,6 +47,7 @@ public class HelpInput implements IText newLines.clear(); lines.add(_("helpFrom", p.getDescription().getName())); } + final boolean isOnWhitelist = user.isAuthorized("essentials.help." + pluginNameLow); for (Map.Entry<String, Map<String, Object>> k : cmds.entrySet()) { @@ -81,7 +82,7 @@ public class HelpInput implements IText { permissions = value.get(PERMISSIONS); } - if (user.isAuthorized("essentials.help." + pluginNameLow)) + if (isOnWhitelist || user.isAuthorized("essentials.help." + pluginNameLow + "." + k.getKey())) { pluginLines.add(_("helpLine", k.getKey(), value.get(DESCRIPTION))); } diff --git a/Essentials/src/com/earth2me/essentials/textreader/KeywordReplacer.java b/Essentials/src/com/earth2me/essentials/textreader/KeywordReplacer.java index 4c875098b..2a95d4d84 100644 --- a/Essentials/src/com/earth2me/essentials/textreader/KeywordReplacer.java +++ b/Essentials/src/com/earth2me/essentials/textreader/KeywordReplacer.java @@ -3,6 +3,7 @@ package com.earth2me.essentials.textreader; import com.earth2me.essentials.DescParseTickFormat; import com.earth2me.essentials.IEssentials; import com.earth2me.essentials.User; +import com.earth2me.essentials.Util; import java.text.DateFormat; import java.util.ArrayList; import java.util.Date; @@ -42,7 +43,7 @@ public class KeywordReplacer implements IText userName = user.getName(); ipAddress = user.getAddress() == null || user.getAddress().getAddress() == null ? "" : user.getAddress().getAddress().toString(); address = user.getAddress() == null ? "" : user.getAddress().toString(); - balance = Double.toString(user.getMoney()); + balance = Util.displayCurrency(user.getMoney(), ess); mails = Integer.toString(user.getMails().size()); world = user.getLocation() == null || user.getLocation().getWorld() == null ? "" : user.getLocation().getWorld().getName(); worldTime12 = DescParseTickFormat.format12(user.getWorld() == null ? 0 : user.getWorld().getTime()); diff --git a/Essentials/src/config.yml b/Essentials/src/config.yml index a766e0549..c5adec0b0 100644 --- a/Essentials/src/config.yml +++ b/Essentials/src/config.yml @@ -91,6 +91,32 @@ overridden-commands: disabled-commands: # - nick +# These commands will be shown to players with socialSpy enabled +# You can add commands from other plugins you may want to track or +# remove commands that are used for something you dont want to spy on +socialspy-commands: + - msg + - w + - r + - mail + - m + - t + - whisper + - emsg + - tell + - er + - reply + - ereply + - email + - action + - describe + - eme + - eaction + - edescribe + - etell + - ewhisper + - pm + # 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 you are using a supported permissions system. # If you are using an unsupported permissions system simply delete this section. @@ -351,6 +377,10 @@ sethome-multiple: # Set to 0 for no timeout tpa-accept-cancellation: 0 +# Set the maximum time /tempban can be used for in seconds. +# Set to -1 to disable, and essentials.tempban.unlimited can be used to override. +max-tempban-time: -1 + ############################################################ # +------------------------------------------------------+ # # | EssentialsEco | # diff --git a/Essentials/src/messages.properties b/Essentials/src/messages.properties index 8a17513cf..cec54fb85 100644 --- a/Essentials/src/messages.properties +++ b/Essentials/src/messages.properties @@ -466,3 +466,15 @@ teleportationEnabledFor=\u00a76Teleportation enabled for {0} teleportationDisabledFor=\u00a76Teleportation disabled for {0} kitOnce=\u00a74You can't use that kit again. fullStack=\u00a74You already have a full stack +oversizedTempban=\u00a74You may not ban a player for this period of time. +recipeNone=No recipes exist for {0} +invalidNumber=Invalid Number +recipeBadIndex=There is no recipe by that number +recipeNothing=nothing +recipe=\u00a76Recipe for \u00a7c{0}\u00a76 ({1} of {2}) +recipeFurnace=\u00a76Smelt \u00a7c{0} +recipeGrid=\u00a7{0}X \u00a76| \u00a7{1}X \u00a76| \u00a7{2}X +recipeGridItem=\ \u00a7{0}X \u00a76is \u00a7c{1} +recipeMore=\u00a76Type /{0} \u00a7c{1}\u00a76 <number> to see other recipes for \u00a7c{2} +recipeWhere=\u00a76Where: {0} +recipeShapeless=\u00a76Combine \u00a7c{0} diff --git a/Essentials/src/messages_cs.properties b/Essentials/src/messages_cs.properties index 5cc095f15..486c085cb 100644 --- a/Essentials/src/messages_cs.properties +++ b/Essentials/src/messages_cs.properties @@ -469,3 +469,15 @@ teleportationEnabledFor=\u00a76Teleportation enabled for {0} teleportationDisabledFor=\u00a76Teleportation disabled for {0} kitOnce=\u00a74You can't use that kit again. fullStack=\u00a74You already have a full stack +oversizedTempban=\u00a74You may not ban a player for this period of time. +recipeNone=No recipes exist for {0} +invalidNumber=Invalid Number +recipeBadIndex=There is no recipe by that number +recipeNothing=nothing +recipe=\u00a76Recipe for \u00a7c{0}\u00a76 ({1} of {2}) +recipeFurnace=\u00a76Smelt \u00a7c{0} +recipeGrid=\u00a7{0}X \u00a76| \u00a7{1}X \u00a76| \u00a7{2}X +recipeGridItem=\ \u00a7{0}X \u00a76is \u00a7c{1} +recipeMore=\u00a76Type /{0} \u00a7c{1}\u00a76 <number> to see other recipes for \u00a7c{2} +recipeWhere=\u00a76Where: {0} +recipeShapeless=\u00a76Combine \u00a7c{0} diff --git a/Essentials/src/messages_da.properties b/Essentials/src/messages_da.properties index 6beff781a..f69dc4ebb 100644 --- a/Essentials/src/messages_da.properties +++ b/Essentials/src/messages_da.properties @@ -466,3 +466,15 @@ teleportationEnabledFor=\u00a76Teleportation enabled for {0} teleportationDisabledFor=\u00a76Teleportation disabled for {0} kitOnce=\u00a74You can't use that kit again. fullStack=\u00a74You already have a full stack +oversizedTempban=\u00a74You may not ban a player for this period of time. +recipeNone=No recipes exist for {0} +invalidNumber=Invalid Number +recipeBadIndex=There is no recipe by that number +recipeNothing=nothing +recipe=\u00a76Recipe for \u00a7c{0}\u00a76 ({1} of {2}) +recipeFurnace=\u00a76Smelt \u00a7c{0} +recipeGrid=\u00a7{0}X \u00a76| \u00a7{1}X \u00a76| \u00a7{2}X +recipeGridItem=\ \u00a7{0}X \u00a76is \u00a7c{1} +recipeMore=\u00a76Type /{0} \u00a7c{1}\u00a76 <number> to see other recipes for \u00a7c{2} +recipeWhere=\u00a76Where: {0} +recipeShapeless=\u00a76Combine \u00a7c{0} diff --git a/Essentials/src/messages_de.properties b/Essentials/src/messages_de.properties index 4db624c6a..2d2284542 100644 --- a/Essentials/src/messages_de.properties +++ b/Essentials/src/messages_de.properties @@ -466,3 +466,15 @@ teleportationEnabledFor=\u00a76Teleportation enabled for {0} teleportationDisabledFor=\u00a76Teleportation disabled for {0} kitOnce=\u00a74You can't use that kit again. fullStack=\u00a74You already have a full stack +oversizedTempban=\u00a74You may not ban a player for this period of time. +recipeNone=No recipes exist for {0} +invalidNumber=Invalid Number +recipeBadIndex=There is no recipe by that number +recipeNothing=nothing +recipe=\u00a76Recipe for \u00a7c{0}\u00a76 ({1} of {2}) +recipeFurnace=\u00a76Smelt \u00a7c{0} +recipeGrid=\u00a7{0}X \u00a76| \u00a7{1}X \u00a76| \u00a7{2}X +recipeGridItem=\ \u00a7{0}X \u00a76is \u00a7c{1} +recipeMore=\u00a76Type /{0} \u00a7c{1}\u00a76 <number> to see other recipes for \u00a7c{2} +recipeWhere=\u00a76Where: {0} +recipeShapeless=\u00a76Combine \u00a7c{0} diff --git a/Essentials/src/messages_en.properties b/Essentials/src/messages_en.properties index 8a17513cf..cec54fb85 100644 --- a/Essentials/src/messages_en.properties +++ b/Essentials/src/messages_en.properties @@ -466,3 +466,15 @@ teleportationEnabledFor=\u00a76Teleportation enabled for {0} teleportationDisabledFor=\u00a76Teleportation disabled for {0} kitOnce=\u00a74You can't use that kit again. fullStack=\u00a74You already have a full stack +oversizedTempban=\u00a74You may not ban a player for this period of time. +recipeNone=No recipes exist for {0} +invalidNumber=Invalid Number +recipeBadIndex=There is no recipe by that number +recipeNothing=nothing +recipe=\u00a76Recipe for \u00a7c{0}\u00a76 ({1} of {2}) +recipeFurnace=\u00a76Smelt \u00a7c{0} +recipeGrid=\u00a7{0}X \u00a76| \u00a7{1}X \u00a76| \u00a7{2}X +recipeGridItem=\ \u00a7{0}X \u00a76is \u00a7c{1} +recipeMore=\u00a76Type /{0} \u00a7c{1}\u00a76 <number> to see other recipes for \u00a7c{2} +recipeWhere=\u00a76Where: {0} +recipeShapeless=\u00a76Combine \u00a7c{0} diff --git a/Essentials/src/messages_es.properties b/Essentials/src/messages_es.properties index 8d0ad7892..7915968fb 100644 --- a/Essentials/src/messages_es.properties +++ b/Essentials/src/messages_es.properties @@ -466,3 +466,15 @@ teleportationEnabledFor=\u00a76Teleportation enabled for {0} teleportationDisabledFor=\u00a76Teleportation disabled for {0} kitOnce=\u00a74You can't use that kit again. fullStack=\u00a74You already have a full stack +oversizedTempban=\u00a74You may not ban a player for this period of time. +recipeNone=No recipes exist for {0} +invalidNumber=Invalid Number +recipeBadIndex=There is no recipe by that number +recipeNothing=nothing +recipe=\u00a76Recipe for \u00a7c{0}\u00a76 ({1} of {2}) +recipeFurnace=\u00a76Smelt \u00a7c{0} +recipeGrid=\u00a7{0}X \u00a76| \u00a7{1}X \u00a76| \u00a7{2}X +recipeGridItem=\ \u00a7{0}X \u00a76is \u00a7c{1} +recipeMore=\u00a76Type /{0} \u00a7c{1}\u00a76 <number> to see other recipes for \u00a7c{2} +recipeWhere=\u00a76Where: {0} +recipeShapeless=\u00a76Combine \u00a7c{0} diff --git a/Essentials/src/messages_fi.properties b/Essentials/src/messages_fi.properties index fef0aeb78..05da0a0d6 100644 --- a/Essentials/src/messages_fi.properties +++ b/Essentials/src/messages_fi.properties @@ -466,3 +466,15 @@ teleportationEnabledFor=\u00a76Teleportation enabled for {0} teleportationDisabledFor=\u00a76Teleportation disabled for {0} kitOnce=\u00a74You can't use that kit again. fullStack=\u00a74You already have a full stack +oversizedTempban=\u00a74You may not ban a player for this period of time. +recipeNone=No recipes exist for {0} +invalidNumber=Invalid Number +recipeBadIndex=There is no recipe by that number +recipeNothing=nothing +recipe=\u00a76Recipe for \u00a7c{0}\u00a76 ({1} of {2}) +recipeFurnace=\u00a76Smelt \u00a7c{0} +recipeGrid=\u00a7{0}X \u00a76| \u00a7{1}X \u00a76| \u00a7{2}X +recipeGridItem=\ \u00a7{0}X \u00a76is \u00a7c{1} +recipeMore=\u00a76Type /{0} \u00a7c{1}\u00a76 <number> to see other recipes for \u00a7c{2} +recipeWhere=\u00a76Where: {0} +recipeShapeless=\u00a76Combine \u00a7c{0} diff --git a/Essentials/src/messages_fr.properties b/Essentials/src/messages_fr.properties index e5cfd4975..82566c31e 100644 --- a/Essentials/src/messages_fr.properties +++ b/Essentials/src/messages_fr.properties @@ -466,3 +466,15 @@ teleportationEnabledFor=\u00a76Teleportation enabled for {0} teleportationDisabledFor=\u00a76Teleportation disabled for {0} kitOnce=\u00a74You can't use that kit again. fullStack=\u00a74You already have a full stack +oversizedTempban=\u00a74You may not ban a player for this period of time. +recipeNone=No recipes exist for {0} +invalidNumber=Invalid Number +recipeBadIndex=There is no recipe by that number +recipeNothing=nothing +recipe=\u00a76Recipe for \u00a7c{0}\u00a76 ({1} of {2}) +recipeFurnace=\u00a76Smelt \u00a7c{0} +recipeGrid=\u00a7{0}X \u00a76| \u00a7{1}X \u00a76| \u00a7{2}X +recipeGridItem=\ \u00a7{0}X \u00a76is \u00a7c{1} +recipeMore=\u00a76Type /{0} \u00a7c{1}\u00a76 <number> to see other recipes for \u00a7c{2} +recipeWhere=\u00a76Where: {0} +recipeShapeless=\u00a76Combine \u00a7c{0} diff --git a/Essentials/src/messages_it.properties b/Essentials/src/messages_it.properties index f24899599..c8bcdd711 100644 --- a/Essentials/src/messages_it.properties +++ b/Essentials/src/messages_it.properties @@ -466,3 +466,15 @@ teleportationEnabledFor=\u00a76Teleportation enabled for {0} teleportationDisabledFor=\u00a76Teleportation disabled for {0} kitOnce=\u00a74You can't use that kit again. fullStack=\u00a74You already have a full stack +oversizedTempban=\u00a74You may not ban a player for this period of time. +recipeNone=No recipes exist for {0} +invalidNumber=Invalid Number +recipeBadIndex=There is no recipe by that number +recipeNothing=nothing +recipe=\u00a76Recipe for \u00a7c{0}\u00a76 ({1} of {2}) +recipeFurnace=\u00a76Smelt \u00a7c{0} +recipeGrid=\u00a7{0}X \u00a76| \u00a7{1}X \u00a76| \u00a7{2}X +recipeGridItem=\ \u00a7{0}X \u00a76is \u00a7c{1} +recipeMore=\u00a76Type /{0} \u00a7c{1}\u00a76 <number> to see other recipes for \u00a7c{2} +recipeWhere=\u00a76Where: {0} +recipeShapeless=\u00a76Combine \u00a7c{0} diff --git a/Essentials/src/messages_nl.properties b/Essentials/src/messages_nl.properties index 0c4fd2cd0..07c85443e 100644 --- a/Essentials/src/messages_nl.properties +++ b/Essentials/src/messages_nl.properties @@ -466,3 +466,15 @@ teleportationEnabledFor=\u00a76Teleportation enabled for {0} teleportationDisabledFor=\u00a76Teleportation disabled for {0} kitOnce=\u00a74You can't use that kit again. fullStack=\u00a74You already have a full stack +oversizedTempban=\u00a74You may not ban a player for this period of time. +recipeNone=No recipes exist for {0} +invalidNumber=Invalid Number +recipeBadIndex=There is no recipe by that number +recipeNothing=nothing +recipe=\u00a76Recipe for \u00a7c{0}\u00a76 ({1} of {2}) +recipeFurnace=\u00a76Smelt \u00a7c{0} +recipeGrid=\u00a7{0}X \u00a76| \u00a7{1}X \u00a76| \u00a7{2}X +recipeGridItem=\ \u00a7{0}X \u00a76is \u00a7c{1} +recipeMore=\u00a76Type /{0} \u00a7c{1}\u00a76 <number> to see other recipes for \u00a7c{2} +recipeWhere=\u00a76Where: {0} +recipeShapeless=\u00a76Combine \u00a7c{0} diff --git a/Essentials/src/messages_pl.properties b/Essentials/src/messages_pl.properties index 804784f19..4c666c1cc 100644 --- a/Essentials/src/messages_pl.properties +++ b/Essentials/src/messages_pl.properties @@ -466,3 +466,15 @@ teleportationEnabledFor=\u00a76Teleportation enabled for {0} teleportationDisabledFor=\u00a76Teleportation disabled for {0} kitOnce=\u00a74You can't use that kit again. fullStack=\u00a74You already have a full stack +oversizedTempban=\u00a74You may not ban a player for this period of time. +recipeNone=No recipes exist for {0} +invalidNumber=Invalid Number +recipeBadIndex=There is no recipe by that number +recipeNothing=nothing +recipe=\u00a76Recipe for \u00a7c{0}\u00a76 ({1} of {2}) +recipeFurnace=\u00a76Smelt \u00a7c{0} +recipeGrid=\u00a7{0}X \u00a76| \u00a7{1}X \u00a76| \u00a7{2}X +recipeGridItem=\ \u00a7{0}X \u00a76is \u00a7c{1} +recipeMore=\u00a76Type /{0} \u00a7c{1}\u00a76 <number> to see other recipes for \u00a7c{2} +recipeWhere=\u00a76Where: {0} +recipeShapeless=\u00a76Combine \u00a7c{0} diff --git a/Essentials/src/messages_pt.properties b/Essentials/src/messages_pt.properties index 4c039bc1c..8db1a6bc4 100644 --- a/Essentials/src/messages_pt.properties +++ b/Essentials/src/messages_pt.properties @@ -466,3 +466,15 @@ teleportationEnabledFor=\u00a76Teleportation enabled for {0} teleportationDisabledFor=\u00a76Teleportation disabled for {0} kitOnce=\u00a74You can't use that kit again. fullStack=\u00a74You already have a full stack +oversizedTempban=\u00a74You may not ban a player for this period of time. +recipeNone=No recipes exist for {0} +invalidNumber=Invalid Number +recipeBadIndex=There is no recipe by that number +recipeNothing=nothing +recipe=\u00a76Recipe for \u00a7c{0}\u00a76 ({1} of {2}) +recipeFurnace=\u00a76Smelt \u00a7c{0} +recipeGrid=\u00a7{0}X \u00a76| \u00a7{1}X \u00a76| \u00a7{2}X +recipeGridItem=\ \u00a7{0}X \u00a76is \u00a7c{1} +recipeMore=\u00a76Type /{0} \u00a7c{1}\u00a76 <number> to see other recipes for \u00a7c{2} +recipeWhere=\u00a76Where: {0} +recipeShapeless=\u00a76Combine \u00a7c{0} diff --git a/Essentials/src/messages_se.properties b/Essentials/src/messages_se.properties index b6017786b..fde632b89 100644 --- a/Essentials/src/messages_se.properties +++ b/Essentials/src/messages_se.properties @@ -466,3 +466,15 @@ teleportationEnabledFor=\u00a76Teleportation enabled for {0} teleportationDisabledFor=\u00a76Teleportation disabled for {0} kitOnce=\u00a74You can't use that kit again. fullStack=\u00a74You already have a full stack +oversizedTempban=\u00a74You may not ban a player for this period of time. +recipeNone=No recipes exist for {0} +invalidNumber=Invalid Number +recipeBadIndex=There is no recipe by that number +recipeNothing=nothing +recipe=\u00a76Recipe for \u00a7c{0}\u00a76 ({1} of {2}) +recipeFurnace=\u00a76Smelt \u00a7c{0} +recipeGrid=\u00a7{0}X \u00a76| \u00a7{1}X \u00a76| \u00a7{2}X +recipeGridItem=\ \u00a7{0}X \u00a76is \u00a7c{1} +recipeMore=\u00a76Type /{0} \u00a7c{1}\u00a76 <number> to see other recipes for \u00a7c{2} +recipeWhere=\u00a76Where: {0} +recipeShapeless=\u00a76Combine \u00a7c{0} diff --git a/Essentials/src/plugin.yml b/Essentials/src/plugin.yml index 95c7e943a..37ec60147 100644 --- a/Essentials/src/plugin.yml +++ b/Essentials/src/plugin.yml @@ -233,7 +233,7 @@ commands: msg: description: Sends a private message to the specified player. usage: /<command> <to> <message> - aliases: [m,t,emsg,tell,etell,whisper,ewhisper] + aliases: [w,m,t,emsg,tell,etell,whisper,ewhisper] mute: description: Mutes or unmutes a player. usage: /<command> <player> [datediff] @@ -278,6 +278,10 @@ commands: description: Displays the username of a user based on nick. usage: /<command> <nickname> aliases: [erealname] + recipe: + description: Displays how to craft items. + usage: /<command> <item> [number] + aliases: [method, formula, recipes, emethod, eformula, erecipes, erecipe] remove: description: Removes entities in your world usage: /<command> <drops|arrows|boats|minecarts|xp|paintings> [radius] @@ -454,4 +458,4 @@ commands: permissions: essentials.*: default: op - description: Give players with op everything by default
\ No newline at end of file + description: Give players with op everything by default diff --git a/Essentials/test/com/earth2me/essentials/FakeServer.java b/Essentials/test/com/earth2me/essentials/FakeServer.java index e8b8ce01c..5d2ff0c88 100644 --- a/Essentials/test/com/earth2me/essentials/FakeServer.java +++ b/Essentials/test/com/earth2me/essentials/FakeServer.java @@ -16,10 +16,7 @@ import org.bukkit.command.PluginCommand; import org.bukkit.entity.Player; import org.bukkit.event.inventory.InventoryType; import org.bukkit.help.HelpMap; -import org.bukkit.inventory.Inventory; -import org.bukkit.inventory.InventoryHolder; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.Recipe; +import org.bukkit.inventory.*; import org.bukkit.map.MapView; import org.bukkit.plugin.Plugin; import org.bukkit.plugin.PluginManager; @@ -807,4 +804,16 @@ public class FakeServer implements Server { throw new UnsupportedOperationException("Not supported yet."); } + + @Override + public String getShutdownMessage() + { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public ItemFactory getItemFactory() + { + throw new UnsupportedOperationException("Not supported yet."); + } } diff --git a/EssentialsGroupManager/nbproject/project.properties b/EssentialsGroupManager/nbproject/project.properties index 26d72fd8a..bc26273ba 100644 --- a/EssentialsGroupManager/nbproject/project.properties +++ b/EssentialsGroupManager/nbproject/project.properties @@ -40,13 +40,13 @@ dist.jar=${dist.dir}/EssentialsGroupManager.jar dist.javadoc.dir=${dist.dir}/javadoc endorsed.classpath= excludes= -file.reference.craftbukkit.jar=../lib/craftbukkit.jar +file.reference.bukkit.jar=../lib/bukkit.jar includes=** jar.archive.disabled=${jnlp.enabled} jar.compress=true jar.index=${jnlp.enabled} javac.classpath=\ - ${file.reference.craftbukkit.jar} + ${file.reference.bukkit.jar} # Space-separated list of extra javac options javac.compilerargs= javac.deprecation=false diff --git a/EssentialsGroupManager/src/Changelog.txt b/EssentialsGroupManager/src/Changelog.txt index 077ea9163..4ea195a5d 100644 --- a/EssentialsGroupManager/src/Changelog.txt +++ b/EssentialsGroupManager/src/Changelog.txt @@ -201,4 +201,6 @@ v 2.0: - Remove info node support from GlobalGroups. It should not have them as GlobalGroups are only permission collections.
- Change order of data in Users.yml to [name, Group, SubGroup, Permissions, Info nodes].
- Add alphabetically sorted user lists.
- - allWorldsDataList now returns fully mirrored worlds which are not identical mirrors (fixes the /manselect list).
\ No newline at end of file + - allWorldsDataList now returns fully mirrored worlds which are not identical mirrors (fixes the /manselect list).
+ - Add support for Rcon.
+ - Prevent GM commands from being used on CommandBlocks.
\ No newline at end of file diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java index 3daea93eb..fe7808238 100644 --- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java +++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java @@ -34,9 +34,11 @@ import org.anjocaido.groupmanager.utils.Tasks; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.OfflinePlayer; +import org.bukkit.command.BlockCommandSender; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.command.ConsoleCommandSender; +import org.bukkit.command.RemoteConsoleCommandSender; import org.bukkit.entity.Player; import org.bukkit.plugin.PluginDescriptionFile; import org.bukkit.plugin.ServicePriority; @@ -380,6 +382,12 @@ public class GroupManager extends JavaPlugin { Group senderGroup = null; User senderUser = null; boolean isOpOverride = config.isOpOverride(); + + // PREVENT GM COMMANDS BEING USED ON COMMANDBLOCKS + if (sender instanceof BlockCommandSender) { + sender.sendMessage(ChatColor.RED + "GM Commands can not be called from CommandBlocks"); + return true; + } if (sender.getClass().getName().equals("org.bukkit.craftbukkit.command.CraftBlockCommandSender")) { sender.sendMessage(ChatColor.RED + "GM Commands can not be called from CommandBlocks"); @@ -403,7 +411,7 @@ public class GroupManager extends JavaPlugin { if (isOpOverride || worldsHolder.getWorldPermissions(senderPlayer).has(senderPlayer, "groupmanager." + cmd.getName())) { playerCanDo = true; } - } else if (sender instanceof ConsoleCommandSender) { + } else if ((sender instanceof ConsoleCommandSender) || (sender instanceof RemoteConsoleCommandSender)) { if (!lastError.isEmpty() && !commandLabel.equalsIgnoreCase("manload")) { sender.sendMessage(ChatColor.RED + "All commands are locked due to an error." + ChatColor.BOLD + "" + ChatColor.UNDERLINE + "Check the log" + ChatColor.RESET + " and then try a '/manload'."); diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/worlds/WorldsHolder.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/worlds/WorldsHolder.java index 92fec7737..12a6a5150 100644 --- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/worlds/WorldsHolder.java +++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/worlds/WorldsHolder.java @@ -204,10 +204,10 @@ public class WorldsHolder { mirroredWorlds.add((String)key); } else - GroupManager.logger.log(Level.WARNING, "Mirroring error with " + (String)key + ". Recursive loop detected!"); + throw new IllegalStateException("Unknown mirroring format for " + (String)key); } else { - throw new IllegalStateException("Unknown mirroring format for " + (String)key); + GroupManager.logger.log(Level.WARNING, "Mirroring error with " + (String)key + ". Recursive loop detected!"); } } diff --git a/lib/bukkit.jar b/lib/bukkit.jar Binary files differindex 4b282ee2b..7abca416e 100644 --- a/lib/bukkit.jar +++ b/lib/bukkit.jar diff --git a/lib/craftbukkit.jar b/lib/craftbukkit.jar Binary files differindex beff3e4a8..6f375cc83 100644 --- a/lib/craftbukkit.jar +++ b/lib/craftbukkit.jar |