From 1f98fe710f4649f27789dddbfdbc380e7b01583f Mon Sep 17 00:00:00 2001 From: Necrodoom Date: Fri, 28 Dec 2012 19:05:54 +0200 Subject: derp - fix tempban permission check --- Essentials/src/com/earth2me/essentials/commands/Commandtempban.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtempban.java b/Essentials/src/com/earth2me/essentials/commands/Commandtempban.java index 97aa2ea3b..fd959472c 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandtempban.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandtempban.java @@ -47,7 +47,7 @@ public class Commandtempban extends EssentialsCommand 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")) + if(maxBanLength > 0 && ((banTimestamp - GregorianCalendar.getInstance().getTimeInMillis()) > maxBanLength) && !(ess.getUser(sender).isAuthorized("essentials.tempban.unlimited"))) { sender.sendMessage(_("oversizedTempban")); throw new NoChargeException(); -- cgit v1.2.3 From 62832ad43a277dad1db0330395ea84a513aed54d Mon Sep 17 00:00:00 2001 From: Xefir Date: Sat, 12 May 2012 15:14:36 +0200 Subject: Added SimplyPerms Handler --- .../essentials/perm/PermissionsHandler.java | 11 +++++ .../essentials/perm/SimplyPermsHandler.java | 53 ++++++++++++++++++++++ 2 files changed, 64 insertions(+) create mode 100644 Essentials/src/com/earth2me/essentials/perm/SimplyPermsHandler.java diff --git a/Essentials/src/com/earth2me/essentials/perm/PermissionsHandler.java b/Essentials/src/com/earth2me/essentials/perm/PermissionsHandler.java index ab2332528..c5653b0ad 100644 --- a/Essentials/src/com/earth2me/essentials/perm/PermissionsHandler.java +++ b/Essentials/src/com/earth2me/essentials/perm/PermissionsHandler.java @@ -134,6 +134,17 @@ public class PermissionsHandler implements IPermissionsHandler return; } + final Plugin simplyPermsPlugin = pluginManager.getPlugin("SimplyPerms"); + if (simplyPermsPlugin != null && simplyPermsPlugin.isEnabled()) + { + if (!(handler instanceof SimplyPermsHandler)) + { + LOGGER.log(Level.INFO, "Essentials: Using SimplyPerms based permissions."); + handler = new SimplyPermsHandler(simplyPermsPlugin); + } + return; + } + final Plugin privPlugin = pluginManager.getPlugin("Privileges"); if (privPlugin != null && privPlugin.isEnabled()) { diff --git a/Essentials/src/com/earth2me/essentials/perm/SimplyPermsHandler.java b/Essentials/src/com/earth2me/essentials/perm/SimplyPermsHandler.java new file mode 100644 index 000000000..cdd9ffa93 --- /dev/null +++ b/Essentials/src/com/earth2me/essentials/perm/SimplyPermsHandler.java @@ -0,0 +1,53 @@ +package com.earth2me.essentials.perm; + +import java.util.List; + +import net.crystalyx.bukkit.simplyperms.SimplyAPI; +import net.crystalyx.bukkit.simplyperms.SimplyPlugin; + +import org.bukkit.entity.Player; +import org.bukkit.plugin.Plugin; + +public class SimplyPermsHandler extends SuperpermsHandler { + + private final transient SimplyAPI api; + + public SimplyPermsHandler(final Plugin plugin) { + this.api = ((SimplyPlugin) plugin).getAPI(); + } + + @Override + public String getGroup(final Player base) + { + final List groups = api.getPlayerGroups(base.getName()); + if (groups == null || groups.isEmpty()) return null; + return groups.get(0); + } + + @Override + public List getGroups(final Player base) + { + return api.getPlayerGroups(base.getName()); + } + + @Override + public boolean inGroup(final Player base, final String group) + { + final List groups = api.getPlayerGroups(base.getName()); + for (String group1 : groups) + { + if (group1.equalsIgnoreCase(group)) + { + return true; + } + } + return false; + } + + @Override + public boolean canBuild(Player base, String group) + { + return hasPermission(base, "essentials.build") || hasPermission(base, "permissions.allow.build"); + } + +} -- cgit v1.2.3 From 93db8bc7c1590f6cc7269bee07ff3da58da27365 Mon Sep 17 00:00:00 2001 From: Chris Ward Date: Sat, 29 Dec 2012 11:26:44 +1100 Subject: Add SimplyPerms to classpath --- Essentials/nbproject/project.properties | 4 +++- lib/SimplyPerms.jar | Bin 0 -> 90589 bytes 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 lib/SimplyPerms.jar diff --git a/Essentials/nbproject/project.properties b/Essentials/nbproject/project.properties index 40b0ae9b6..f749b8553 100644 --- a/Essentials/nbproject/project.properties +++ b/Essentials/nbproject/project.properties @@ -78,6 +78,7 @@ file.reference.PermissionsBukkit-1.2.jar=../lib/PermissionsBukkit-1.2.jar file.reference.PermissionsEx.jar=../lib/PermissionsEx.jar file.reference.Privileges.jar=..\\lib\\Privileges.jar file.reference.Vault.jar=../lib/Vault.jar +file.reference.SimplyPerms.jar=../lib/SimplyPerms.jar includes=** jar.archive.disabled=${jnlp.enabled} jar.compress=true @@ -97,7 +98,8 @@ javac.classpath=\ ${file.reference.bukkit.jar}:\ ${file.reference.Vault.jar}:\ ${file.reference.Privileges.jar}:\ - ${file.reference.bpermissions2.jar} + ${file.reference.bpermissions2.jar}:\ + ${file.reference.SimplyPerms.jar} # Space-separated list of extra javac options javac.compilerargs=-Xlint:unchecked javac.deprecation=false diff --git a/lib/SimplyPerms.jar b/lib/SimplyPerms.jar new file mode 100644 index 000000000..c7c5ec64e Binary files /dev/null and b/lib/SimplyPerms.jar differ -- cgit v1.2.3 From 3a789bdcfe26c6dba4651a0f32138011fc4bd0b7 Mon Sep 17 00:00:00 2001 From: KHobbits Date: Sat, 29 Dec 2012 02:00:48 +0000 Subject: Fix string match error on none existing user (/ban). --- Essentials/src/com/earth2me/essentials/commands/Commandban.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandban.java b/Essentials/src/com/earth2me/essentials/commands/Commandban.java index 3c31469e3..776f4ab55 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandban.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandban.java @@ -71,7 +71,7 @@ public class Commandban extends EssentialsCommand server.getLogger().log(Level.INFO, _("playerBanned", senderName, user.getName(), banReason)); if (nomatch) { - sender.sendMessage(_("userUnknown", user.getName())); + sender.sendMessage(_("userUnknown", args[0])); } for (Player onlinePlayer : server.getOnlinePlayers()) -- cgit v1.2.3 From 0755fbf089130db9616acd52e267a0536ce77c82 Mon Sep 17 00:00:00 2001 From: KHobbits Date: Sat, 29 Dec 2012 06:29:16 +0000 Subject: Update bukkit to 1.4.6-R0.1 bukkit: 1652 cb: 2561 --- .../src/com/earth2me/essentials/OfflinePlayer.java | 6 ++++++ lib/bukkit.jar | Bin 4820949 -> 4829571 bytes lib/craftbukkit.jar | Bin 12472010 -> 12531025 bytes 3 files changed, 6 insertions(+) diff --git a/Essentials/src/com/earth2me/essentials/OfflinePlayer.java b/Essentials/src/com/earth2me/essentials/OfflinePlayer.java index a47b32582..4e61177c9 100644 --- a/Essentials/src/com/earth2me/essentials/OfflinePlayer.java +++ b/Essentials/src/com/earth2me/essentials/OfflinePlayer.java @@ -1150,4 +1150,10 @@ public class OfflinePlayer implements Player { throw new UnsupportedOperationException("Not supported yet."); } + + @Override + public void setTexturePack(String string) + { + throw new UnsupportedOperationException("Not supported yet."); + } } diff --git a/lib/bukkit.jar b/lib/bukkit.jar index 7abca416e..4d9d59cf2 100644 Binary files a/lib/bukkit.jar and b/lib/bukkit.jar differ diff --git a/lib/craftbukkit.jar b/lib/craftbukkit.jar index 6f375cc83..e7b6ea107 100644 Binary files a/lib/craftbukkit.jar and b/lib/craftbukkit.jar differ -- cgit v1.2.3 From 03445e5b9b20e09583a17b2e08f2f64ec70e2f37 Mon Sep 17 00:00:00 2001 From: KHobbits Date: Sat, 29 Dec 2012 06:43:26 +0000 Subject: Fix home functionality bugs: /home not using bed when enabled /home not giving teleport warning --- .../src/com/earth2me/essentials/Teleport.java | 67 ++++++++++++---------- .../earth2me/essentials/commands/Commandhome.java | 2 +- 2 files changed, 38 insertions(+), 31 deletions(-) diff --git a/Essentials/src/com/earth2me/essentials/Teleport.java b/Essentials/src/com/earth2me/essentials/Teleport.java index 241a8328d..fc1a2cc04 100644 --- a/Essentials/src/com/earth2me/essentials/Teleport.java +++ b/Essentials/src/com/earth2me/essentials/Teleport.java @@ -16,30 +16,30 @@ import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; public class Teleport implements Runnable, ITeleport { private static final double MOVE_CONSTANT = 0.3; - - + + private class Target { private final Location location; private final String name; - + Target(Location location) { this.location = location; this.name = null; } - + Target(Player entity) { this.name = entity.getName(); this.location = null; } - + public Location getLocation() { if (this.name != null) { - + return ess.getServer().getPlayerExact(name).getLocation(); } return location; @@ -63,12 +63,12 @@ public class Teleport implements Runnable, ITeleport private final IEssentials ess; private static final Logger logger = Logger.getLogger("Minecraft"); private TeleportCause cause; - + private void initTimer(long delay, Target target, Trade chargeFor, TeleportCause cause) { initTimer(delay, user, target, chargeFor, cause, false); } - + private void initTimer(long delay, IUser teleportUser, Target target, Trade chargeFor, TeleportCause cause, boolean respawn) { this.started = System.currentTimeMillis(); @@ -83,11 +83,11 @@ public class Teleport implements Runnable, ITeleport this.cause = cause; this.respawn = respawn; } - + @Override public void run() { - + if (user == null || !user.isOnline() || user.getLocation() == null) { cancel(false); @@ -98,7 +98,7 @@ public class Teleport implements Runnable, ITeleport cancel(false); return; } - + if (!user.isAuthorized("essentials.teleport.timer.move") && (Math.round(teleportUser.getLocation().getX() * MOVE_CONSTANT) != initX || Math.round(teleportUser.getLocation().getY() * MOVE_CONSTANT) != initY @@ -119,10 +119,12 @@ public class Teleport implements Runnable, ITeleport teleportUser.sendMessage(_("teleportationCommencing")); try { - if (respawn) { + if (respawn) + { teleportUser.getTeleport().respawn(cause); } - else { + else + { teleportUser.getTeleport().now(teleportTarget, cause); } cancel(false); @@ -146,13 +148,13 @@ public class Teleport implements Runnable, ITeleport } } } - + public Teleport(IUser user, IEssentials ess) { this.user = user; this.ess = ess; } - + public void cooldown(boolean check) throws Exception { final Calendar time = new GregorianCalendar(); @@ -168,7 +170,7 @@ public class Teleport implements Runnable, ITeleport // When was the last teleport used? final Long lastTime = user.getLastTeleportTimestamp(); - + if (lastTime > time.getTimeInMillis()) { // This is to make sure time didn't get messed up on last kit use. @@ -225,7 +227,7 @@ public class Teleport implements Runnable, ITeleport } now(new Target(loc), cause); } - + public void now(Player entity, boolean cooldown, TeleportCause cause) throws Exception { if (cooldown) @@ -234,7 +236,7 @@ public class Teleport implements Runnable, ITeleport } now(new Target(entity), cause); } - + private void now(Target target, TeleportCause cause) throws Exception { cancel(false); @@ -249,21 +251,21 @@ public class Teleport implements Runnable, ITeleport { teleport(loc, chargeFor, TeleportCause.PLUGIN); } - + public void teleport(Location loc, Trade chargeFor, TeleportCause cause) throws Exception { teleport(new Target(loc), chargeFor, cause); } - + public void teleport(Player entity, Trade chargeFor, TeleportCause cause) throws Exception { teleport(new Target(entity), chargeFor, cause); } - + private void teleport(Target target, Trade chargeFor, TeleportCause cause) throws Exception { double delay = ess.getSettings().getTeleportDelay(); - + if (chargeFor != null) { chargeFor.isAffordableFor(user); @@ -279,11 +281,11 @@ public class Teleport implements Runnable, ITeleport } return; } - + cancel(false); warnUser(user, delay); initTimer((long)(delay * 1000.0), target, chargeFor, cause); - + teleTimer = ess.scheduleSyncRepeatingTask(this, 10, 10); } @@ -292,7 +294,7 @@ public class Teleport implements Runnable, ITeleport { Target target = new Target(user); double delay = ess.getSettings().getTeleportDelay(); - + if (chargeFor != null) { chargeFor.isAffordableFor(user); @@ -308,13 +310,13 @@ public class Teleport implements Runnable, ITeleport } return; } - + cancel(false); warnUser(otherUser, delay); initTimer((long)(delay * 1000.0), otherUser, target, chargeFor, cause, false); teleTimer = ess.scheduleSyncRepeatingTask(this, 10, 10); } - + private void warnUser(final IUser user, final double delay) { Calendar c = new GregorianCalendar(); @@ -342,22 +344,27 @@ public class Teleport implements Runnable, ITeleport } return; } - + cancel(false); + warnUser(user, delay); initTimer((long)(delay * 1000.0), user, null, chargeFor, cause, true); teleTimer = ess.scheduleSyncRepeatingTask(this, 10, 10); } - + public void respawn(TeleportCause cause) throws Exception { final Player player = user.getBase(); Location bed = player.getBedSpawnLocation(); - if (bed != null && bed.getBlock().getType() != Material.BED_BLOCK) + if (bed != null && bed.getBlock().getType() == Material.BED_BLOCK) { now(new Target(bed), cause); } else { + if (ess.getSettings().isDebug()) + { + ess.getLogger().info("Could not find bed spawn, forcing respawn event."); + } final PlayerRespawnEvent pre = new PlayerRespawnEvent(player, player.getWorld().getSpawnLocation(), false); ess.getServer().getPluginManager().callEvent(pre); now(new Target(pre.getRespawnLocation()), cause); diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandhome.java b/Essentials/src/com/earth2me/essentials/commands/Commandhome.java index 293dbfb6d..a5d355415 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandhome.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandhome.java @@ -69,7 +69,7 @@ public class Commandhome extends EssentialsCommand } else if (homes.isEmpty()) { - throw new Exception(player == user ? _("noHomeSet") : _("noHomeSetPlayer")); + throw new Exception(_("noHomeSetPlayer")); } else if (homes.size() == 1 && player.equals(user)) { -- cgit v1.2.3 From bbb478c51f3fd4139d0d3ce884a2efc7119b1d83 Mon Sep 17 00:00:00 2001 From: KHobbits Date: Sat, 29 Dec 2012 06:55:48 +0000 Subject: Lets clean up the recipe window on player quit, just in case. --- .../src/com/earth2me/essentials/EssentialsPlayerListener.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java b/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java index 8887955a4..78e29012a 100644 --- a/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java +++ b/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java @@ -131,6 +131,10 @@ public class EssentialsPlayerListener implements Listener { user.setLastLocation(); } + if (user.isRecipeSee()) + { + user.getPlayer().getOpenInventory().getTopInventory().clear(); + } user.updateActivity(false); user.dispose(); } @@ -563,7 +567,7 @@ public class EssentialsPlayerListener implements Listener if (event.getView().getTopInventory().getType() == InventoryType.WORKBENCH) { final User user = ess.getUser(event.getPlayer()); - if(user.isRecipeSee()) + if (user.isRecipeSee()) { user.setRecipeSee(false); event.getView().getTopInventory().clear(); -- cgit v1.2.3 From fc89867e4aa83e4124363431c1cf326ba8315a17 Mon Sep 17 00:00:00 2001 From: KHobbits Date: Sat, 29 Dec 2012 07:35:26 +0000 Subject: Ignore self damage in teleport entity protection. --- Essentials/src/com/earth2me/essentials/EssentialsEntityListener.java | 2 +- .../earth2me/essentials/protect/EssentialsProtectEntityListener.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Essentials/src/com/earth2me/essentials/EssentialsEntityListener.java b/Essentials/src/com/earth2me/essentials/EssentialsEntityListener.java index e93c61952..74a8654a0 100644 --- a/Essentials/src/com/earth2me/essentials/EssentialsEntityListener.java +++ b/Essentials/src/com/earth2me/essentials/EssentialsEntityListener.java @@ -75,7 +75,7 @@ public class EssentialsEntityListener implements Listener event.setCancelled(true); } - if (attacker.hasInvulnerabilityAfterTeleport() || defender.hasInvulnerabilityAfterTeleport()) + if (!attacker.equals(defender) && (attacker.hasInvulnerabilityAfterTeleport() || defender.hasInvulnerabilityAfterTeleport())) { event.setCancelled(true); } diff --git a/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectEntityListener.java b/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectEntityListener.java index 1ca9519ce..4770248b9 100644 --- a/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectEntityListener.java +++ b/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectEntityListener.java @@ -233,7 +233,7 @@ public class EssentialsProtectEntityListener implements Listener event.setCancelled(true); return; } - + // This code will prevent explosions near protected rails, signs or protected chests // TODO: Use protect db instead of this code -- cgit v1.2.3 From 69ad186839c0dfee24ad9e79c83ffad848f0bfe6 Mon Sep 17 00:00:00 2001 From: KHobbits Date: Sat, 29 Dec 2012 07:47:07 +0000 Subject: Add aliases for new thorns enchantment. --- Essentials/src/com/earth2me/essentials/Enchantments.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Essentials/src/com/earth2me/essentials/Enchantments.java b/Essentials/src/com/earth2me/essentials/Enchantments.java index 875fd72e7..07e095771 100644 --- a/Essentials/src/com/earth2me/essentials/Enchantments.java +++ b/Essentials/src/com/earth2me/essentials/Enchantments.java @@ -44,6 +44,12 @@ public class Enchantments ENCHANTMENTS.put("unbreaking", Enchantment.DURABILITY); ALIASENCHANTMENTS.put("d", Enchantment.DURABILITY); + ENCHANTMENTS.put("thorns", Enchantment.THORNS); + ENCHANTMENTS.put("highcrit", Enchantment.THORNS); + ALIASENCHANTMENTS.put("thorn", Enchantment.THORNS); + ALIASENCHANTMENTS.put("highercrit", Enchantment.THORNS); + ALIASENCHANTMENTS.put("t", Enchantment.THORNS); + ENCHANTMENTS.put("fireaspect", Enchantment.FIRE_ASPECT); ENCHANTMENTS.put("fire", Enchantment.FIRE_ASPECT); ALIASENCHANTMENTS.put("meleefire", Enchantment.FIRE_ASPECT); @@ -129,7 +135,7 @@ public class Enchantments ALIASENCHANTMENTS.put("infinite", Enchantment.ARROW_INFINITE); ALIASENCHANTMENTS.put("unlimited", Enchantment.ARROW_INFINITE); ALIASENCHANTMENTS.put("unlimitedarrows", Enchantment.ARROW_INFINITE); - ALIASENCHANTMENTS.put("ai", Enchantment.ARROW_INFINITE); + ALIASENCHANTMENTS.put("ai", Enchantment.ARROW_INFINITE); } public static Enchantment getByName(String name) { -- cgit v1.2.3 From d551e8c6d235d73b536ddaab92431ac42e735ab2 Mon Sep 17 00:00:00 2001 From: KHobbits Date: Sat, 29 Dec 2012 07:58:28 +0000 Subject: Make /enchant only show valid enchantments for the item. --- Essentials/src/com/earth2me/essentials/commands/Commandenchant.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandenchant.java b/Essentials/src/com/earth2me/essentials/commands/Commandenchant.java index 579be06ff..212539385 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandenchant.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandenchant.java @@ -35,7 +35,7 @@ public class Commandenchant extends EssentialsCommand for (Map.Entry entry : Enchantments.entrySet()) { final String enchantmentName = entry.getValue().getName().toLowerCase(Locale.ENGLISH); - if (enchantmentslist.contains(enchantmentName) || user.isAuthorized("essentials.enchant." + enchantmentName)) + if (enchantmentslist.contains(enchantmentName) || (user.isAuthorized("essentials.enchant." + enchantmentName) && entry.getValue().canEnchantItem(stack))) { enchantmentslist.add(entry.getKey()); //enchantmentslist.add(enchantmentName); -- cgit v1.2.3 From ed88f8aa060eda90228b39bc075f1600c7a929d7 Mon Sep 17 00:00:00 2001 From: KHobbits Date: Sat, 29 Dec 2012 08:35:52 +0000 Subject: Allow unsafe enchantments in /item /give /kit and /enchant Needs enabled in config file manually. --- .../src/com/earth2me/essentials/ISettings.java | 2 ++ Essentials/src/com/earth2me/essentials/Kit.java | 32 ++++++++++++++-------- .../src/com/earth2me/essentials/Settings.java | 6 ++++ .../essentials/commands/Commandenchant.java | 12 ++++++-- .../earth2me/essentials/commands/Commandgive.java | 14 +++++++++- .../earth2me/essentials/commands/Commanditem.java | 17 ++++++++---- Essentials/src/config.yml | 4 +++ 7 files changed, 67 insertions(+), 20 deletions(-) diff --git a/Essentials/src/com/earth2me/essentials/ISettings.java b/Essentials/src/com/earth2me/essentials/ISettings.java index a261c80bb..c58ffa8e7 100644 --- a/Essentials/src/com/earth2me/essentials/ISettings.java +++ b/Essentials/src/com/earth2me/essentials/ISettings.java @@ -151,6 +151,8 @@ public interface ISettings extends IConf Set getNoGodWorlds(); boolean getUpdateBedAtDaytime(); + + boolean allowUnsafeEnchantments(); boolean getRepairEnchanted(); diff --git a/Essentials/src/com/earth2me/essentials/Kit.java b/Essentials/src/com/earth2me/essentials/Kit.java index fcd1b4932..0611cafec 100644 --- a/Essentials/src/com/earth2me/essentials/Kit.java +++ b/Essentials/src/com/earth2me/essentials/Kit.java @@ -34,12 +34,13 @@ public class Kit { throw new Exception(_("kitError"), ex); } - + } - + public static void checkTime(final User user, final String kitName, final Map els) throws Exception { - if (user.isAuthorized("essentials.kit.exemptdelay")) { + if (user.isAuthorized("essentials.kit.exemptdelay")) + { return; } @@ -55,7 +56,7 @@ public class Kit // When was the last kit used? final long lastTime = user.getKitTimestamp(kitName); - + if (lastTime < earliestLong || lastTime == 0L) { user.setKitTimestamp(kitName, time.getTimeInMillis()); @@ -80,15 +81,15 @@ public class Kit throw new NoChargeException(); } } - + public static List getItems(final User user, final Map kit) throws Exception { if (kit == null) { throw new Exception(_("kitError2")); } - - + + try { return (List)kit.get("items"); @@ -99,7 +100,7 @@ public class Kit throw new Exception(_("kitErrorHelp"), e); } } - + public static void expandItems(final IEssentials ess, final User user, final List items) throws Exception { try @@ -107,7 +108,7 @@ public class Kit boolean spew = false; for (String d : items) { - if (d.startsWith(ess.getSettings().getCurrencySymbol())) + if (d.startsWith(ess.getSettings().getCurrencySymbol())) { Double value = Double.parseDouble(d.substring(ess.getSettings().getCurrencySymbol().length()).trim()); Trade t = new Trade(value, ess); @@ -119,7 +120,7 @@ public class Kit final int id = Material.getMaterial(Integer.parseInt(item[0])).getId(); final short data = item.length > 1 ? Short.parseShort(item[1]) : 0; final int amount = parts.length > 1 ? Integer.parseInt(parts[1]) : 1; - + final ItemStack stack = new ItemStack(id, amount, data); if (parts.length > 2) { @@ -146,7 +147,14 @@ public class Kit } try { - stack.addEnchantment(enchantment, level); + if (ess.getSettings().allowUnsafeEnchantments()) + { + stack.addUnsafeEnchantment(enchantment, level); + } + else + { + stack.addEnchantment(enchantment, level); + } } catch (Exception ex) { @@ -154,7 +162,7 @@ public class Kit } } } - + final Map overfilled; if (user.isAuthorized("essentials.oversizedstacks")) { diff --git a/Essentials/src/com/earth2me/essentials/Settings.java b/Essentials/src/com/earth2me/essentials/Settings.java index d3c6b49d5..8eaa2a57c 100644 --- a/Essentials/src/com/earth2me/essentials/Settings.java +++ b/Essentials/src/com/earth2me/essentials/Settings.java @@ -856,6 +856,12 @@ public class Settings implements ISettings { return config.getBoolean("repair-enchanted", true); } + + @Override + public boolean allowUnsafeEnchantments() + { + return config.getBoolean("unsafe-enchantments", false); + } @Override public boolean isWorldTeleportPermissions() diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandenchant.java b/Essentials/src/com/earth2me/essentials/commands/Commandenchant.java index 212539385..c338090aa 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandenchant.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandenchant.java @@ -56,7 +56,8 @@ public class Commandenchant extends EssentialsCommand } } final Enchantment enchantment = getEnchantment(args[0], user); - if (level < 0 || level > enchantment.getMaxLevel()) + final boolean allowUnsafe = ess.getSettings().allowUnsafeEnchantments() && user.isAuthorized("essentials.enchant.allowunsafe"); + if (level < 0 || (!allowUnsafe && level > enchantment.getMaxLevel())) { level = enchantment.getMaxLevel(); } @@ -66,7 +67,14 @@ public class Commandenchant extends EssentialsCommand } else { - stack.addEnchantment(enchantment, level); + if (allowUnsafe) + { + stack.addUnsafeEnchantment(enchantment, level); + } + else + { + stack.addEnchantment(enchantment, level); + } } user.getInventory().setItemInHand(stack); user.updateInventory(); diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandgive.java b/Essentials/src/com/earth2me/essentials/commands/Commandgive.java index c4e26d9a8..c9dde4688 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandgive.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandgive.java @@ -81,7 +81,19 @@ public class Commandgive extends EssentialsCommand { level = enchantment.getMaxLevel(); } - stack.addEnchantment(enchantment, level); + boolean allowUnsafe = ess.getSettings().allowUnsafeEnchantments(); + if (allowUnsafe && sender instanceof Player && !ess.getUser(sender).isAuthorized("essentials.enchant.allowunsafe")) + { + allowUnsafe = false; + } + if (allowUnsafe) + { + stack.addUnsafeEnchantment(enchantment, level); + } + else + { + stack.addEnchantment(enchantment, level); + } } } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commanditem.java b/Essentials/src/com/earth2me/essentials/commands/Commanditem.java index d14b04d2a..a5c59deb6 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commanditem.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commanditem.java @@ -16,7 +16,7 @@ public class Commanditem extends EssentialsCommand { super("item"); } - + @Override public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception { @@ -25,7 +25,7 @@ public class Commanditem extends EssentialsCommand throw new NotEnoughArgumentsException(); } final ItemStack stack = ess.getItemDb().get(args[0]); - + final String itemname = stack.getType().toString().toLowerCase(Locale.ENGLISH).replace("_", ""); if (ess.getSettings().permissionBasedItemSpawn() ? (!user.isAuthorized("essentials.itemspawn.item-all") @@ -69,7 +69,14 @@ public class Commanditem extends EssentialsCommand { level = enchantment.getMaxLevel(); } - stack.addEnchantment(enchantment, level); + if (ess.getSettings().allowUnsafeEnchantments() && user.isAuthorized("essentials.enchant.allowunsafe")) + { + stack.addUnsafeEnchantment(enchantment, level); + } + else + { + stack.addEnchantment(enchantment, level); + } } } } @@ -77,12 +84,12 @@ public class Commanditem extends EssentialsCommand { throw new NotEnoughArgumentsException(); } - + if (stack.getType() == Material.AIR) { throw new Exception(_("cantSpawnItem", "Air")); } - + final String displayName = stack.getType().toString().toLowerCase(Locale.ENGLISH).replace('_', ' '); user.sendMessage(_("itemSpawn", stack.getAmount(), displayName)); if (user.isAuthorized("essentials.oversizedstacks")) diff --git a/Essentials/src/config.yml b/Essentials/src/config.yml index 3b03a9560..0a532ab34 100644 --- a/Essentials/src/config.yml +++ b/Essentials/src/config.yml @@ -334,6 +334,10 @@ oversized-stacksize: 64 # essentials.repair.enchanted repair-enchanted: true +# Allow 'unsafe' enchantments in kits and item spawning. +# Warning: Mixing and overleveling some enchantments can cause issues with clients, servers and plugins. +unsafe-enchantments: false + #Do you want essentials to keep track of previous location for /back in the teleport listener? #If you set this to true any plugin that uses teleport will have the previous location registered. register-back-in-listener: false -- cgit v1.2.3 From 3725a5e6d4f08a8609fa98f72b0180dcdf4afc49 Mon Sep 17 00:00:00 2001 From: KHobbits Date: Sat, 29 Dec 2012 08:40:03 +0000 Subject: Set default tpa timeout to 2 minutes. --- Essentials/src/com/earth2me/essentials/Settings.java | 2 +- Essentials/src/config.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Essentials/src/com/earth2me/essentials/Settings.java b/Essentials/src/com/earth2me/essentials/Settings.java index 8eaa2a57c..95123d051 100644 --- a/Essentials/src/com/earth2me/essentials/Settings.java +++ b/Essentials/src/com/earth2me/essentials/Settings.java @@ -929,7 +929,7 @@ public class Settings implements ISettings @Override public long getTpaAcceptCancellation() { - return config.getLong("tpa-accept-cancellation", 0); + return config.getLong("tpa-accept-cancellation", 120); } @Override diff --git a/Essentials/src/config.yml b/Essentials/src/config.yml index 0a532ab34..10247ab09 100644 --- a/Essentials/src/config.yml +++ b/Essentials/src/config.yml @@ -383,7 +383,7 @@ sethome-multiple: # Set timeout in seconds for players to accept tpa before request is cancelled. # Set to 0 for no timeout -tpa-accept-cancellation: 0 +tpa-accept-cancellation: 120 ############################################################ # +------------------------------------------------------+ # -- cgit v1.2.3 From 3dcdad2233490b43dbbab41418ce5c0e80b2e421 Mon Sep 17 00:00:00 2001 From: KHobbits Date: Sat, 29 Dec 2012 09:00:42 +0000 Subject: Hide a few more duplicate enchantments from /enchant --- Essentials/src/com/earth2me/essentials/Enchantments.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Essentials/src/com/earth2me/essentials/Enchantments.java b/Essentials/src/com/earth2me/essentials/Enchantments.java index 07e095771..ef9cfc5bd 100644 --- a/Essentials/src/com/earth2me/essentials/Enchantments.java +++ b/Essentials/src/com/earth2me/essentials/Enchantments.java @@ -20,7 +20,7 @@ public class Enchantments ENCHANTMENTS.put("alldamage", Enchantment.DAMAGE_ALL); ALIASENCHANTMENTS.put("alldmg", Enchantment.DAMAGE_ALL); ENCHANTMENTS.put("sharpness", Enchantment.DAMAGE_ALL); - ENCHANTMENTS.put("sharp", Enchantment.DAMAGE_ALL); + ALIASENCHANTMENTS.put("sharp", Enchantment.DAMAGE_ALL); ALIASENCHANTMENTS.put("dal", Enchantment.DAMAGE_ALL); ENCHANTMENTS.put("ardmg", Enchantment.DAMAGE_ARTHROPODS); @@ -40,7 +40,7 @@ public class Enchantments ALIASENCHANTMENTS.put("ds", Enchantment.DIG_SPEED); ENCHANTMENTS.put("durability", Enchantment.DURABILITY); - ENCHANTMENTS.put("dura", Enchantment.DURABILITY); + ALIASENCHANTMENTS.put("dura", Enchantment.DURABILITY); ENCHANTMENTS.put("unbreaking", Enchantment.DURABILITY); ALIASENCHANTMENTS.put("d", Enchantment.DURABILITY); @@ -89,7 +89,7 @@ public class Enchantments ALIASENCHANTMENTS.put("fallprotection", Enchantment.PROTECTION_FALL); ENCHANTMENTS.put("fallprot", Enchantment.PROTECTION_FALL); ENCHANTMENTS.put("featherfall", Enchantment.PROTECTION_FALL); - ENCHANTMENTS.put("featherfalling", Enchantment.PROTECTION_FALL); + ALIASENCHANTMENTS.put("featherfalling", Enchantment.PROTECTION_FALL); ALIASENCHANTMENTS.put("pfa", Enchantment.PROTECTION_FALL); ALIASENCHANTMENTS.put("fireprotection", Enchantment.PROTECTION_FIRE); -- cgit v1.2.3 From 9ecb501e005bbd1d7723d0680b40cd85810af41b Mon Sep 17 00:00:00 2001 From: Alexander Schepp Date: Sun, 30 Dec 2012 00:23:04 +0100 Subject: Use the right formatter in XMPP --- EssentialsXMPP/src/com/earth2me/essentials/xmpp/XMPPManager.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/EssentialsXMPP/src/com/earth2me/essentials/xmpp/XMPPManager.java b/EssentialsXMPP/src/com/earth2me/essentials/xmpp/XMPPManager.java index 673ef3377..582c8cbef 100644 --- a/EssentialsXMPP/src/com/earth2me/essentials/xmpp/XMPPManager.java +++ b/EssentialsXMPP/src/com/earth2me/essentials/xmpp/XMPPManager.java @@ -11,6 +11,7 @@ import java.util.logging.Handler; import java.util.logging.Level; import java.util.logging.LogRecord; import java.util.logging.Logger; +import java.util.logging.SimpleFormatter; import org.bukkit.entity.Player; import org.jivesoftware.smack.*; import org.jivesoftware.smack.Roster.SubscriptionMode; @@ -22,6 +23,7 @@ import org.jivesoftware.smack.util.StringUtils; public class XMPPManager extends Handler implements MessageListener, ChatManagerListener, IConf { private static final Logger LOGGER = Logger.getLogger("Minecraft"); + private static final SimpleFormatter formatter = new SimpleFormatter(); private final transient EssentialsConf config; private transient XMPPConnection connection; private transient ChatManager chatManager; @@ -262,7 +264,7 @@ public class XMPPManager extends Handler implements MessageListener, ChatManager XMPPManager.this.startChat(user); for (LogRecord logRecord : copy) { - final String message = String.format("[" + logRecord.getLevel().getLocalizedName() + "] " + logRecord.getMessage(), logRecord.getParameters()); + final String message = formatter.format(logRecord); if (!XMPPManager.this.sendMessage(user, Util.stripLogColorFormat(message))) { failedUsers.add(user); -- cgit v1.2.3 From a1b2773bf570e5d262c7bab9162b9baf84f93b5a Mon Sep 17 00:00:00 2001 From: KHobbits Date: Sun, 30 Dec 2012 03:31:05 +0000 Subject: Reorganize entity listener --- .../essentials/EssentialsEntityListener.java | 48 ++++++++++------------ 1 file changed, 22 insertions(+), 26 deletions(-) diff --git a/Essentials/src/com/earth2me/essentials/EssentialsEntityListener.java b/Essentials/src/com/earth2me/essentials/EssentialsEntityListener.java index 74a8654a0..a0d3d091f 100644 --- a/Essentials/src/com/earth2me/essentials/EssentialsEntityListener.java +++ b/Essentials/src/com/earth2me/essentials/EssentialsEntityListener.java @@ -30,44 +30,40 @@ public class EssentialsEntityListener implements Listener { final Entity eAttack = event.getDamager(); final Entity eDefend = event.getEntity(); - if (eDefend instanceof Player && eAttack instanceof Player) + if (eAttack instanceof Player) { - final User defender = ess.getUser(eDefend); final User attacker = ess.getUser(eAttack); - onPlayerVsPlayerDamage(event, defender, attacker); - onPlayerVsPlayerPowertool(event, defender, attacker); - } - else if (eDefend instanceof Player && eAttack instanceof Projectile) - { - Entity shooter = ((Projectile)event.getDamager()).getShooter(); - if (shooter instanceof Player) + if (eDefend instanceof Player) { - final User defender = ess.getUser(eDefend); - final User attacker = ess.getUser(shooter); - onPlayerVsPlayerDamage(event, defender, attacker); - onPlayerVsPlayerPowertool(event, defender, attacker); + onPlayerVsPlayerDamage(event, (Player)eDefend, attacker); } - } - else if (eAttack instanceof Player) - { - final User player = ess.getUser(eAttack); - player.updateActivity(true); - if (eDefend instanceof Ageable) + else if (eDefend instanceof Ageable) { - final ItemStack hand = player.getItemInHand(); + final ItemStack hand = attacker.getItemInHand(); if (hand != null && hand.getType() == Material.MILK_BUCKET) { ((Ageable)eDefend).setBaby(); hand.setType(Material.BUCKET); - player.setItemInHand(hand); - player.updateInventory(); + attacker.setItemInHand(hand); + attacker.updateInventory(); event.setCancelled(true); } } + attacker.updateActivity(true); + } + else if (eAttack instanceof Projectile && eDefend instanceof Player) + { + Entity shooter = ((Projectile)event.getDamager()).getShooter(); + if (shooter instanceof Player) + { + final User attacker = ess.getUser(shooter); + onPlayerVsPlayerDamage(event, (Player)eDefend, attacker); + attacker.updateActivity(true); + } } } - private void onPlayerVsPlayerDamage(final EntityDamageByEntityEvent event, final User defender, final User attacker) + private void onPlayerVsPlayerDamage(final EntityDamageByEntityEvent event, final Player defender, final User attacker) { if (ess.getSettings().getLoginAttackDelay() > 0 && !attacker.isAuthorized("essentials.pvpdelay.exempt") && (System.currentTimeMillis() < (attacker.getLastLogin() + ess.getSettings().getLoginAttackDelay()))) @@ -75,7 +71,7 @@ public class EssentialsEntityListener implements Listener event.setCancelled(true); } - if (!attacker.equals(defender) && (attacker.hasInvulnerabilityAfterTeleport() || defender.hasInvulnerabilityAfterTeleport())) + if (!defender.equals(attacker.getBase()) && (attacker.hasInvulnerabilityAfterTeleport() || ess.getUser(defender).hasInvulnerabilityAfterTeleport())) { event.setCancelled(true); } @@ -90,10 +86,10 @@ public class EssentialsEntityListener implements Listener event.setCancelled(true); } - attacker.updateActivity(true); + onPlayerVsPlayerPowertool(event, defender, attacker); } - private void onPlayerVsPlayerPowertool(final EntityDamageByEntityEvent event, final User defender, final User attacker) + private void onPlayerVsPlayerPowertool(final EntityDamageByEntityEvent event, final Player defender, final User attacker) { final List commandList = attacker.getPowertool(attacker.getItemInHand()); if (commandList != null && !commandList.isEmpty()) -- cgit v1.2.3 From cbc1aeacbeaa2cf4c3f716026e8a672ea6806827 Mon Sep 17 00:00:00 2001 From: KHobbits Date: Sun, 30 Dec 2012 04:32:20 +0000 Subject: Implement event toggle. --- .../src/com/earth2me/essentials/signs/EssentialsSign.java | 6 ++++++ .../src/com/earth2me/essentials/signs/SignBlockListener.java | 12 ++++++------ .../com/earth2me/essentials/signs/SignEntityListener.java | 4 ++-- .../com/earth2me/essentials/signs/SignPlayerListener.java | 2 +- .../src/com/earth2me/essentials/signs/SignProtection.java | 6 ++++++ 5 files changed, 21 insertions(+), 9 deletions(-) diff --git a/Essentials/src/com/earth2me/essentials/signs/EssentialsSign.java b/Essentials/src/com/earth2me/essentials/signs/EssentialsSign.java index e5f125cf8..aeecf5368 100644 --- a/Essentials/src/com/earth2me/essentials/signs/EssentialsSign.java +++ b/Essentials/src/com/earth2me/essentials/signs/EssentialsSign.java @@ -17,6 +17,7 @@ import org.bukkit.inventory.ItemStack; public class EssentialsSign { private static final Set EMPTY_SET = new HashSet(); + protected transient final String signName; public EssentialsSign(final String signName) @@ -258,6 +259,11 @@ public class EssentialsSign { return EMPTY_SET; } + + public boolean areHeavyEventRequired() + { + return false; + } protected final void validateTrade(final ISign sign, final int index, final IEssentials ess) throws SignException { diff --git a/Essentials/src/com/earth2me/essentials/signs/SignBlockListener.java b/Essentials/src/com/earth2me/essentials/signs/SignBlockListener.java index 517c313cc..a48ca3924 100644 --- a/Essentials/src/com/earth2me/essentials/signs/SignBlockListener.java +++ b/Essentials/src/com/earth2me/essentials/signs/SignBlockListener.java @@ -65,7 +65,7 @@ public class SignBlockListener implements Listener } for (EssentialsSign sign : ess.getSettings().enabledSigns()) { - if (sign.getBlocks().contains(block.getType()) + if (sign.areHeavyEventRequired() && sign.getBlocks().contains(block.getType()) && !sign.onBlockBreak(block, player, ess)) { LOGGER.log(Level.INFO, "A block was protected by a sign."); @@ -148,7 +148,7 @@ public class SignBlockListener implements Listener } for (EssentialsSign sign : ess.getSettings().enabledSigns()) { - if (sign.getBlocks().contains(block.getType()) + if (sign.areHeavyEventRequired() && sign.getBlocks().contains(block.getType()) && !sign.onBlockPlace(block, event.getPlayer(), ess)) { event.setCancelled(true); @@ -176,7 +176,7 @@ public class SignBlockListener implements Listener } for (EssentialsSign sign : ess.getSettings().enabledSigns()) { - if (sign.getBlocks().contains(block.getType()) + if (sign.areHeavyEventRequired() && sign.getBlocks().contains(block.getType()) && !sign.onBlockBurn(block, ess)) { event.setCancelled(true); @@ -204,7 +204,7 @@ public class SignBlockListener implements Listener } for (EssentialsSign sign : ess.getSettings().enabledSigns()) { - if (sign.getBlocks().contains(block.getType()) + if (sign.areHeavyEventRequired() && sign.getBlocks().contains(block.getType()) && !sign.onBlockIgnite(block, ess)) { event.setCancelled(true); @@ -233,7 +233,7 @@ public class SignBlockListener implements Listener } for (EssentialsSign sign : ess.getSettings().enabledSigns()) { - if (sign.getBlocks().contains(block.getType()) + if (sign.areHeavyEventRequired() && sign.getBlocks().contains(block.getType()) && !sign.onBlockPush(block, ess)) { event.setCancelled(true); @@ -264,7 +264,7 @@ public class SignBlockListener implements Listener } for (EssentialsSign sign : ess.getSettings().enabledSigns()) { - if (sign.getBlocks().contains(block.getType()) + if (sign.areHeavyEventRequired() && sign.getBlocks().contains(block.getType()) && !sign.onBlockPush(block, ess)) { event.setCancelled(true); diff --git a/Essentials/src/com/earth2me/essentials/signs/SignEntityListener.java b/Essentials/src/com/earth2me/essentials/signs/SignEntityListener.java index edc5b856d..bb188f94f 100644 --- a/Essentials/src/com/earth2me/essentials/signs/SignEntityListener.java +++ b/Essentials/src/com/earth2me/essentials/signs/SignEntityListener.java @@ -39,7 +39,7 @@ public class SignEntityListener implements Listener } for (EssentialsSign sign : ess.getSettings().enabledSigns()) { - if (sign.getBlocks().contains(block.getType())) + if (sign.areHeavyEventRequired() && sign.getBlocks().contains(block.getType())) { event.setCancelled(!sign.onBlockExplode(block, ess)); return; @@ -67,7 +67,7 @@ public class SignEntityListener implements Listener } for (EssentialsSign sign : ess.getSettings().enabledSigns()) { - if (sign.getBlocks().contains(block.getType()) + if (sign.areHeavyEventRequired() && sign.getBlocks().contains(block.getType()) && !sign.onBlockBreak(block, ess)) { event.setCancelled(true); diff --git a/Essentials/src/com/earth2me/essentials/signs/SignPlayerListener.java b/Essentials/src/com/earth2me/essentials/signs/SignPlayerListener.java index 12296b023..35fa03f3f 100644 --- a/Essentials/src/com/earth2me/essentials/signs/SignPlayerListener.java +++ b/Essentials/src/com/earth2me/essentials/signs/SignPlayerListener.java @@ -77,7 +77,7 @@ public class SignPlayerListener implements Listener { for (EssentialsSign sign : ess.getSettings().enabledSigns()) { - if (sign.getBlocks().contains(block.getType()) + if (sign.areHeavyEventRequired() && sign.getBlocks().contains(block.getType()) && !sign.onBlockInteract(block, event.getPlayer(), ess)) { event.setCancelled(true); diff --git a/Essentials/src/com/earth2me/essentials/signs/SignProtection.java b/Essentials/src/com/earth2me/essentials/signs/SignProtection.java index 1ea26c859..b5a679324 100644 --- a/Essentials/src/com/earth2me/essentials/signs/SignProtection.java +++ b/Essentials/src/com/earth2me/essentials/signs/SignProtection.java @@ -241,6 +241,12 @@ public class SignProtection extends EssentialsSign { return protectedBlocks; } + + @Override + public boolean areHeavyEventRequired() + { + return true; + } @Override protected boolean onBlockPlace(final Block block, final User player, final String username, final IEssentials ess) throws SignException -- cgit v1.2.3 From 6c3b2076ffc64782b17be6bfb905acd02a624798 Mon Sep 17 00:00:00 2001 From: KHobbits Date: Mon, 31 Dec 2012 01:08:39 +0000 Subject: Allow unbanning players who do not have valid userdata --- .../src/com/earth2me/essentials/commands/Commandunban.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandunban.java b/Essentials/src/com/earth2me/essentials/commands/Commandunban.java index dda1475d0..439e715e5 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandunban.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandunban.java @@ -2,6 +2,7 @@ package com.earth2me.essentials.commands; import static com.earth2me.essentials.I18n._; import com.earth2me.essentials.User; +import org.bukkit.OfflinePlayer; import org.bukkit.Server; import org.bukkit.command.CommandSender; @@ -23,12 +24,19 @@ public class Commandunban extends EssentialsCommand try { - final User player = getPlayer(server, args, 0, true); - player.setBanned(false); + final User user = getPlayer(server, args, 0, true); + user.setBanned(false); sender.sendMessage(_("unbannedPlayer")); } catch (NoSuchFieldException e) { + final OfflinePlayer player = server.getOfflinePlayer(args[0]); + if (player.isBanned()) { + player.setBanned(false); + sender.sendMessage(_("unbannedPlayer")); + return; + } + throw new Exception(_("playerNotFound"), e); } } -- cgit v1.2.3 From 4cec7fe5c143f5fbb7f73533c3af89df0e0849a2 Mon Sep 17 00:00:00 2001 From: KHobbits Date: Mon, 31 Dec 2012 05:43:05 +0000 Subject: Use bukkit api for chat user list --- .../src/com/earth2me/essentials/chat/EssentialsChatPlayer.java | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChatPlayer.java b/EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChatPlayer.java index 2324c65d9..8ca1e0726 100644 --- a/EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChatPlayer.java +++ b/EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChatPlayer.java @@ -134,14 +134,10 @@ public abstract class EssentialsChatPlayer implements Listener return; } - for (Player onlinePlayer : server.getOnlinePlayers()) + for (Player onlinePlayer : event.getRecipients()) { String type = _("chatTypeLocal"); final User onlineUser = ess.getUser(onlinePlayer); - if (onlineUser.isIgnoredPlayer(sender)) - { - continue; - } if (!onlineUser.equals(sender)) { boolean abort = false; -- cgit v1.2.3 From 8e3ee8576e10c07daa6850fe0ff9c03e783884dd Mon Sep 17 00:00:00 2001 From: KHobbits Date: Mon, 31 Dec 2012 05:44:20 +0000 Subject: Unregister unused events. --- .../src/com/earth2me/essentials/Essentials.java | 70 +++++++++++++--------- .../essentials/EssentialsBlockListener.java | 3 +- .../essentials/EssentialsPlayerListener.java | 18 ++++-- Essentials/src/com/earth2me/essentials/Jails.java | 22 +++++-- .../essentials/signs/SignBlockListener.java | 8 +++ .../essentials/signs/SignEntityListener.java | 2 + .../essentials/signs/SignPlayerListener.java | 12 ++-- 7 files changed, 92 insertions(+), 43 deletions(-) diff --git a/Essentials/src/com/earth2me/essentials/Essentials.java b/Essentials/src/com/earth2me/essentials/Essentials.java index 49c09fe90..0aca8bb88 100644 --- a/Essentials/src/com/earth2me/essentials/Essentials.java +++ b/Essentials/src/com/earth2me/essentials/Essentials.java @@ -50,6 +50,7 @@ import org.bukkit.command.PluginCommand; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; +import org.bukkit.event.HandlerList; import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.world.WorldLoadEvent; @@ -176,6 +177,8 @@ public class Essentials extends JavaPlugin implements IEssentials itemDb = new ItemDb(this); confList.add(itemDb); execTimer.mark("Init(Worth/ItemDB)"); + jails = new Jails(this); + confList.add(jails); reload(); } catch (YAMLException exception) @@ -207,6 +210,39 @@ public class Essentials extends JavaPlugin implements IEssentials backup = new Backup(this); permissionsHandler = new PermissionsHandler(this, settings.useBukkitPermissions()); alternativeCommandsHandler = new AlternativeCommandsHandler(this); + + timer = new EssentialsTimer(this); + getScheduler().scheduleSyncRepeatingTask(this, timer, 100, 100); + + Economy.setEss(this); + execTimer.mark("RegHandler"); + + final MetricsStarter metricsStarter = new MetricsStarter(this); + if (metricsStarter.getStart() != null && metricsStarter.getStart() == true) + { + getScheduler().scheduleAsyncDelayedTask(this, metricsStarter, 1); + } + else if (metricsStarter.getStart() != null && metricsStarter.getStart() == false) + { + final MetricsListener metricsListener = new MetricsListener(this, metricsStarter); + pm.registerEvents(metricsListener, this); + } + + final String timeroutput = execTimer.end(); + if (getSettings().isDebug()) + { + LOGGER.log(Level.INFO, "Essentials load " + timeroutput); + } + } + + private void registerListeners(PluginManager pm) { + HandlerList.unregisterAll(this); + + if (getSettings().isDebug()) + { + LOGGER.log(Level.INFO, "Registering Listeners"); + } + final EssentialsPluginListener serverListener = new EssentialsPluginListener(this); pm.registerEvents(serverListener, this); confList.add(serverListener); @@ -231,35 +267,10 @@ public class Essentials extends JavaPlugin implements IEssentials final EssentialsWorldListener worldListener = new EssentialsWorldListener(this); pm.registerEvents(worldListener, this); - - //TODO: Check if this should be here, and not above before reload() - jails = new Jails(this); - confList.add(jails); - + pm.registerEvents(tntListener, this); - - timer = new EssentialsTimer(this); - getScheduler().scheduleSyncRepeatingTask(this, timer, 100, 100); - - Economy.setEss(this); - execTimer.mark("RegListeners"); - - final MetricsStarter metricsStarter = new MetricsStarter(this); - if (metricsStarter.getStart() != null && metricsStarter.getStart() == true) - { - getScheduler().scheduleAsyncDelayedTask(this, metricsStarter, 1); - } - else if (metricsStarter.getStart() != null && metricsStarter.getStart() == false) - { - final MetricsListener metricsListener = new MetricsListener(this, metricsStarter); - pm.registerEvents(metricsListener, this); - } - - final String timeroutput = execTimer.end(); - if (getSettings().isDebug()) - { - LOGGER.log(Level.INFO, "Essentials load " + timeroutput); - } + + jails.resetListener(); } @Override @@ -291,6 +302,9 @@ public class Essentials extends JavaPlugin implements IEssentials } i18n.updateLocale(settings.getLocale()); + + final PluginManager pm = getServer().getPluginManager(); + registerListeners(pm); } @Override diff --git a/Essentials/src/com/earth2me/essentials/EssentialsBlockListener.java b/Essentials/src/com/earth2me/essentials/EssentialsBlockListener.java index 0c6bec0fe..c5c35d901 100644 --- a/Essentials/src/com/earth2me/essentials/EssentialsBlockListener.java +++ b/Essentials/src/com/earth2me/essentials/EssentialsBlockListener.java @@ -28,8 +28,7 @@ public class EssentialsBlockListener implements Listener return; } final User user = ess.getUser(event.getPlayer()); - final boolean unlimitedForUser = user.hasUnlimited(is); - if (unlimitedForUser && user.getGameMode() == GameMode.SURVIVAL) + if (user.hasUnlimited(is) && user.getGameMode() == GameMode.SURVIVAL) { ess.scheduleSyncDelayedTask( new Runnable() diff --git a/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java b/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java index 78e29012a..c1b5132f4 100644 --- a/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java +++ b/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java @@ -76,10 +76,20 @@ public class EssentialsPlayerListener implements Listener @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public void onPlayerMove(final PlayerMoveEvent event) { - if ((!ess.getSettings().cancelAfkOnMove() && !ess.getSettings().getFreezeAfkPlayers()) - || event.getFrom().getBlockX() == event.getTo().getBlockX() - && event.getFrom().getBlockZ() == event.getTo().getBlockZ() - && event.getFrom().getBlockY() == event.getTo().getBlockY()) + if (!ess.getSettings().cancelAfkOnMove() && !ess.getSettings().getFreezeAfkPlayers()) + { + event.getHandlers().unregister(ess); + + if (ess.getSettings().isDebug()) + { + LOGGER.log(Level.INFO, "Unregistering move listener"); + } + + return; + } + if (event.getFrom().getBlockX() == event.getTo().getBlockX() + && event.getFrom().getBlockZ() == event.getTo().getBlockZ() + && event.getFrom().getBlockY() == event.getTo().getBlockY()) { return; } diff --git a/Essentials/src/com/earth2me/essentials/Jails.java b/Essentials/src/com/earth2me/essentials/Jails.java index 0aa90e08c..740ae0bff 100644 --- a/Essentials/src/com/earth2me/essentials/Jails.java +++ b/Essentials/src/com/earth2me/essentials/Jails.java @@ -44,6 +44,10 @@ public class Jails extends AsyncStorageObjectHolder 0) - { - registerListeners(); - } + checkRegister(); } @Override public void finishWrite() { - if (enabled == false) + checkRegister(); + } + + public void resetListener() + { + enabled = false; + checkRegister(); + } + + private void checkRegister() + { + if (enabled == false && getCount() > 0) { registerListeners(); } diff --git a/Essentials/src/com/earth2me/essentials/signs/SignBlockListener.java b/Essentials/src/com/earth2me/essentials/signs/SignBlockListener.java index a48ca3924..ef14f7818 100644 --- a/Essentials/src/com/earth2me/essentials/signs/SignBlockListener.java +++ b/Essentials/src/com/earth2me/essentials/signs/SignBlockListener.java @@ -32,6 +32,7 @@ public class SignBlockListener implements Listener { if (ess.getSettings().areSignsDisabled()) { + event.getHandlers().unregister(ess); return; } @@ -80,6 +81,7 @@ public class SignBlockListener implements Listener { if (ess.getSettings().areSignsDisabled()) { + event.getHandlers().unregister(ess); return; } User user = ess.getUser(event.getPlayer()); @@ -105,6 +107,7 @@ public class SignBlockListener implements Listener { if (ess.getSettings().areSignsDisabled()) { + event.getHandlers().unregister(ess); return; } @@ -129,6 +132,7 @@ public class SignBlockListener implements Listener { if (ess.getSettings().areSignsDisabled()) { + event.getHandlers().unregister(ess); return; } @@ -162,6 +166,7 @@ public class SignBlockListener implements Listener { if (ess.getSettings().areSignsDisabled()) { + event.getHandlers().unregister(ess); return; } @@ -190,6 +195,7 @@ public class SignBlockListener implements Listener { if (ess.getSettings().areSignsDisabled()) { + event.getHandlers().unregister(ess); return; } @@ -218,6 +224,7 @@ public class SignBlockListener implements Listener { if (ess.getSettings().areSignsDisabled()) { + event.getHandlers().unregister(ess); return; } @@ -248,6 +255,7 @@ public class SignBlockListener implements Listener { if (ess.getSettings().areSignsDisabled()) { + event.getHandlers().unregister(ess); return; } diff --git a/Essentials/src/com/earth2me/essentials/signs/SignEntityListener.java b/Essentials/src/com/earth2me/essentials/signs/SignEntityListener.java index bb188f94f..97bf0fa58 100644 --- a/Essentials/src/com/earth2me/essentials/signs/SignEntityListener.java +++ b/Essentials/src/com/earth2me/essentials/signs/SignEntityListener.java @@ -24,6 +24,7 @@ public class SignEntityListener implements Listener { if (ess.getSettings().areSignsDisabled()) { + event.getHandlers().unregister(ess); return; } @@ -53,6 +54,7 @@ public class SignEntityListener implements Listener { if (ess.getSettings().areSignsDisabled()) { + event.getHandlers().unregister(ess); return; } diff --git a/Essentials/src/com/earth2me/essentials/signs/SignPlayerListener.java b/Essentials/src/com/earth2me/essentials/signs/SignPlayerListener.java index 35fa03f3f..90f0333cb 100644 --- a/Essentials/src/com/earth2me/essentials/signs/SignPlayerListener.java +++ b/Essentials/src/com/earth2me/essentials/signs/SignPlayerListener.java @@ -25,11 +25,15 @@ public class SignPlayerListener implements Listener //Right clicking signs with a block in hand, can now fire cancelled events. //This is because when the block place is cancelled (for example not enough space for the block to be placed), //the event will be marked as cancelled, thus preventing 30% of sign purchases. - @EventHandler(priority = EventPriority.LOW) public void onPlayerInteract(final PlayerInteractEvent event) { - if (ess.getSettings().areSignsDisabled() || (event.getAction() != Action.RIGHT_CLICK_BLOCK && event.getAction() != Action.RIGHT_CLICK_AIR)) + if (ess.getSettings().areSignsDisabled()) + { + event.getHandlers().unregister(ess); + return; + } + if (event.getAction() != Action.RIGHT_CLICK_BLOCK && event.getAction() != Action.RIGHT_CLICK_AIR) { return; } @@ -62,10 +66,10 @@ public class SignPlayerListener implements Listener final int mat = block.getTypeId(); if (mat == Material.SIGN_POST.getId() || mat == Material.WALL_SIGN.getId()) { - final Sign csign = (Sign)block.getState(); + final String csign = ((Sign)block.getState()).getLine(0); for (EssentialsSign sign : ess.getSettings().enabledSigns()) { - if (csign.getLine(0).equalsIgnoreCase(sign.getSuccessName())) + if (csign.equalsIgnoreCase(sign.getSuccessName())) { sign.onSignInteract(block, event.getPlayer(), ess); event.setCancelled(true); -- cgit v1.2.3 From b5dd0fc67127b7f7011cc30c5b37312879a2021a Mon Sep 17 00:00:00 2001 From: KHobbits Date: Mon, 31 Dec 2012 12:15:51 +0000 Subject: Don't unregister all listeners. --- .../earth2me/essentials/EssentialsPlayerListener.java | 2 +- .../com/earth2me/essentials/signs/SignBlockListener.java | 16 ++++++++-------- .../earth2me/essentials/signs/SignEntityListener.java | 4 ++-- .../earth2me/essentials/signs/SignPlayerListener.java | 2 +- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java b/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java index c1b5132f4..d06b30aee 100644 --- a/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java +++ b/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java @@ -78,7 +78,7 @@ public class EssentialsPlayerListener implements Listener { if (!ess.getSettings().cancelAfkOnMove() && !ess.getSettings().getFreezeAfkPlayers()) { - event.getHandlers().unregister(ess); + event.getHandlers().unregister(this); if (ess.getSettings().isDebug()) { diff --git a/Essentials/src/com/earth2me/essentials/signs/SignBlockListener.java b/Essentials/src/com/earth2me/essentials/signs/SignBlockListener.java index ef14f7818..ab914c629 100644 --- a/Essentials/src/com/earth2me/essentials/signs/SignBlockListener.java +++ b/Essentials/src/com/earth2me/essentials/signs/SignBlockListener.java @@ -32,7 +32,7 @@ public class SignBlockListener implements Listener { if (ess.getSettings().areSignsDisabled()) { - event.getHandlers().unregister(ess); + event.getHandlers().unregister(this); return; } @@ -81,7 +81,7 @@ public class SignBlockListener implements Listener { if (ess.getSettings().areSignsDisabled()) { - event.getHandlers().unregister(ess); + event.getHandlers().unregister(this); return; } User user = ess.getUser(event.getPlayer()); @@ -107,7 +107,7 @@ public class SignBlockListener implements Listener { if (ess.getSettings().areSignsDisabled()) { - event.getHandlers().unregister(ess); + event.getHandlers().unregister(this); return; } @@ -132,7 +132,7 @@ public class SignBlockListener implements Listener { if (ess.getSettings().areSignsDisabled()) { - event.getHandlers().unregister(ess); + event.getHandlers().unregister(this); return; } @@ -166,7 +166,7 @@ public class SignBlockListener implements Listener { if (ess.getSettings().areSignsDisabled()) { - event.getHandlers().unregister(ess); + event.getHandlers().unregister(this); return; } @@ -195,7 +195,7 @@ public class SignBlockListener implements Listener { if (ess.getSettings().areSignsDisabled()) { - event.getHandlers().unregister(ess); + event.getHandlers().unregister(this); return; } @@ -224,7 +224,7 @@ public class SignBlockListener implements Listener { if (ess.getSettings().areSignsDisabled()) { - event.getHandlers().unregister(ess); + event.getHandlers().unregister(this); return; } @@ -255,7 +255,7 @@ public class SignBlockListener implements Listener { if (ess.getSettings().areSignsDisabled()) { - event.getHandlers().unregister(ess); + event.getHandlers().unregister(this); return; } diff --git a/Essentials/src/com/earth2me/essentials/signs/SignEntityListener.java b/Essentials/src/com/earth2me/essentials/signs/SignEntityListener.java index 97bf0fa58..fbbd1cd8c 100644 --- a/Essentials/src/com/earth2me/essentials/signs/SignEntityListener.java +++ b/Essentials/src/com/earth2me/essentials/signs/SignEntityListener.java @@ -24,7 +24,7 @@ public class SignEntityListener implements Listener { if (ess.getSettings().areSignsDisabled()) { - event.getHandlers().unregister(ess); + event.getHandlers().unregister(this); return; } @@ -54,7 +54,7 @@ public class SignEntityListener implements Listener { if (ess.getSettings().areSignsDisabled()) { - event.getHandlers().unregister(ess); + event.getHandlers().unregister(this); return; } diff --git a/Essentials/src/com/earth2me/essentials/signs/SignPlayerListener.java b/Essentials/src/com/earth2me/essentials/signs/SignPlayerListener.java index 90f0333cb..b447ed9dd 100644 --- a/Essentials/src/com/earth2me/essentials/signs/SignPlayerListener.java +++ b/Essentials/src/com/earth2me/essentials/signs/SignPlayerListener.java @@ -30,7 +30,7 @@ public class SignPlayerListener implements Listener { if (ess.getSettings().areSignsDisabled()) { - event.getHandlers().unregister(ess); + event.getHandlers().unregister(this); return; } if (event.getAction() != Action.RIGHT_CLICK_BLOCK && event.getAction() != Action.RIGHT_CLICK_AIR) -- cgit v1.2.3 From 5c9d3c6b1aa8b19ec5223226ea1859509483b3c0 Mon Sep 17 00:00:00 2001 From: Chris Ward Date: Tue, 1 Jan 2013 02:26:04 +1100 Subject: Fix recipe NPE/failed display in game --- .../com/earth2me/essentials/commands/Commandrecipe.java | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandrecipe.java b/Essentials/src/com/earth2me/essentials/commands/Commandrecipe.java index e5c69a88b..4325f13d8 100755 --- a/Essentials/src/com/earth2me/essentials/commands/Commandrecipe.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandrecipe.java @@ -97,11 +97,18 @@ public class Commandrecipe extends EssentialsCommand 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 e : ((ShapedRecipe)recipe).getIngredientMap().entrySet()) - { - e.getValue().setAmount(0); - view.setItem(shapeMap.indexOf(e.getKey()), e.getValue()); + 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]); + if(item == null) + { + continue; + } + item.setAmount(0); + view.getTopInventory().setItem(j * 3 + k + 1, item); + } } } -- cgit v1.2.3 From e572e7c94cae5a783ff6f02081839c8fcc72d938 Mon Sep 17 00:00:00 2001 From: gravypod Date: Mon, 31 Dec 2012 10:44:28 -0500 Subject: Store ingredient map and recipe shape --- .../src/com/earth2me/essentials/commands/Commandrecipe.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandrecipe.java b/Essentials/src/com/earth2me/essentials/commands/Commandrecipe.java index 4325f13d8..57294e53c 100755 --- a/Essentials/src/com/earth2me/essentials/commands/Commandrecipe.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandrecipe.java @@ -97,11 +97,13 @@ public class Commandrecipe extends EssentialsCommand final User user = ess.getUser(sender); user.setRecipeSee(true); final InventoryView view = user.openWorkbench(null, true); - for (int j = 0; j < recipe.getShape().length; j++) + final String[] recipeShape = recipe.getShape(); + final Map ingredientMap = recipe.getIngredientMap(); + for (int j = 0; j < recipeShape.length; j++) { - for (int k = 0; k < recipe.getShape()[j].length(); k++) + for (int k = 0; k < recipeShape[j].length(); k++) { - ItemStack item = recipe.getIngredientMap().get(recipe.getShape()[j].toCharArray()[k]); + final ItemStack item = ingredientMap.get(recipeShape[j].toCharArray()[k]); if(item == null) { continue; @@ -110,7 +112,6 @@ public class Commandrecipe extends EssentialsCommand view.getTopInventory().setItem(j * 3 + k + 1, item); } } - } else { @@ -193,4 +194,4 @@ public class Commandrecipe extends EssentialsCommand } return type.toString().replace("_", " ").toLowerCase(Locale.ENGLISH); } -} \ No newline at end of file +} -- cgit v1.2.3 From 555bb76428ae513f733f9d34b084b38d745b327d Mon Sep 17 00:00:00 2001 From: KHobbits Date: Tue, 1 Jan 2013 18:39:23 +0000 Subject: Cleanup --- .../essentials/EssentialsPlayerListener.java | 33 +++++++++++++++++----- .../essentials/commands/Commandinvsee.java | 17 ++++++++++- 2 files changed, 42 insertions(+), 8 deletions(-) diff --git a/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java b/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java index d06b30aee..9a309ea6c 100644 --- a/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java +++ b/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java @@ -26,6 +26,7 @@ import org.bukkit.event.inventory.InventoryType; import org.bukkit.event.player.*; import org.bukkit.event.player.PlayerLoginEvent.Result; import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; +import org.bukkit.inventory.Inventory; import org.bukkit.inventory.InventoryHolder; import org.bukkit.inventory.ItemStack; @@ -528,10 +529,13 @@ public class EssentialsPlayerListener implements Listener @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) public void onInventoryClickEvent(final InventoryClickEvent event) { - if (event.getView().getTopInventory().getType() == InventoryType.PLAYER) + final Inventory top = event.getView().getTopInventory(); + final InventoryType type = top.getType(); + + if (type == InventoryType.PLAYER) { final User user = ess.getUser(event.getWhoClicked()); - final InventoryHolder invHolder = event.getView().getTopInventory().getHolder(); + final InventoryHolder invHolder = top.getHolder(); if (invHolder != null && invHolder instanceof HumanEntity) { final User invOwner = ess.getUser((HumanEntity)invHolder); @@ -543,7 +547,7 @@ public class EssentialsPlayerListener implements Listener } } } - else if (event.getView().getTopInventory().getType() == InventoryType.ENDER_CHEST) + else if (type == InventoryType.ENDER_CHEST) { final User user = ess.getUser(event.getWhoClicked()); if (user.isEnderSee() && (!user.isAuthorized("essentials.enderchest.modify"))) @@ -551,7 +555,7 @@ public class EssentialsPlayerListener implements Listener event.setCancelled(true); } } - else if (event.getView().getTopInventory().getType() == InventoryType.WORKBENCH) + else if (type == InventoryType.WORKBENCH) { User user = ess.getUser(event.getWhoClicked()); if (user.isRecipeSee()) @@ -559,22 +563,32 @@ public class EssentialsPlayerListener implements Listener event.setCancelled(true); } } + else if (type == InventoryType.CHEST && top.getSize() == 9) + { + User user = ess.getUser(event.getWhoClicked()); + if (user.isInvSee()) + { + event.setCancelled(true); + } + } } @EventHandler(priority = EventPriority.MONITOR) public void onInventoryCloseEvent(final InventoryCloseEvent event) { - if (event.getView().getTopInventory().getType() == InventoryType.PLAYER) + final Inventory top = event.getView().getTopInventory(); + final InventoryType type = top.getType(); + if (type == InventoryType.PLAYER) { final User user = ess.getUser(event.getPlayer()); user.setInvSee(false); } - else if (event.getView().getTopInventory().getType() == InventoryType.ENDER_CHEST) + else if (type == InventoryType.ENDER_CHEST) { final User user = ess.getUser(event.getPlayer()); user.setEnderSee(false); } - if (event.getView().getTopInventory().getType() == InventoryType.WORKBENCH) + else if (type == InventoryType.WORKBENCH) { final User user = ess.getUser(event.getPlayer()); if (user.isRecipeSee()) @@ -583,6 +597,11 @@ public class EssentialsPlayerListener implements Listener event.getView().getTopInventory().clear(); } } + else if (type == InventoryType.CHEST && top.getSize() == 9) + { + final User user = ess.getUser(event.getPlayer()); + user.setInvSee(false); + } } @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandinvsee.java b/Essentials/src/com/earth2me/essentials/commands/Commandinvsee.java index 3964dbe67..29f69c22a 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandinvsee.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandinvsee.java @@ -2,6 +2,7 @@ package com.earth2me.essentials.commands; import com.earth2me.essentials.User; import org.bukkit.Server; +import org.bukkit.inventory.Inventory; public class Commandinvsee extends EssentialsCommand @@ -10,6 +11,8 @@ public class Commandinvsee extends EssentialsCommand { super("invsee"); } + + //This method has a hidden param, which if given will display the armour slots. #easteregg @Override protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception @@ -18,8 +21,20 @@ public class Commandinvsee extends EssentialsCommand { throw new NotEnoughArgumentsException(); } + final User invUser = getPlayer(server, args, 0); + Inventory inv; + + if (args.length > 1) + { + inv = server.createInventory(user, 9, "Equipped"); + inv.setContents(invUser.getInventory().getArmorContents()); + } + else + { + inv = invUser.getInventory(); + } + user.openInventory(inv); user.setInvSee(true); - user.openInventory(invUser.getInventory()); } } -- cgit v1.2.3 From b5e559ff66b5500e92d48c43429f92a8964e0faf Mon Sep 17 00:00:00 2001 From: KHobbits Date: Tue, 1 Jan 2013 19:34:32 +0000 Subject: More cleanup --- .../essentials/EssentialsPlayerListener.java | 38 +++++++++++++++++++--- .../essentials/commands/Commandinvsee.java | 6 ++-- 2 files changed, 36 insertions(+), 8 deletions(-) diff --git a/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java b/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java index 9a309ea6c..f8e530548 100644 --- a/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java +++ b/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java @@ -544,6 +544,7 @@ public class EssentialsPlayerListener implements Listener || !invOwner.isOnline())) { event.setCancelled(true); + user.updateInventory(); } } } @@ -565,10 +566,28 @@ public class EssentialsPlayerListener implements Listener } else if (type == InventoryType.CHEST && top.getSize() == 9) { - User user = ess.getUser(event.getWhoClicked()); - if (user.isInvSee()) + final User user = ess.getUser(event.getWhoClicked()); + final InventoryHolder invHolder = top.getHolder(); + if (invHolder != null && invHolder instanceof HumanEntity) { - event.setCancelled(true); + final User invOwner = ess.getUser((HumanEntity)invHolder); + + if (user.isInvSee() && (!user.isAuthorized("essentials.invsee.modify") + || invOwner.isAuthorized("essentials.invsee.preventmodify") + || !invOwner.isOnline() + || (event.getSlot() > 3 && event.getSlot() < 9))) + { + event.setCancelled(true); + user.updateInventory(); + } + else + { + final ItemStack[] contents = + { + top.getItem(0), top.getItem(1), top.getItem(2), top.getItem(3) + }; + invOwner.getInventory().setArmorContents(contents); + } } } } @@ -599,8 +618,17 @@ public class EssentialsPlayerListener implements Listener } else if (type == InventoryType.CHEST && top.getSize() == 9) { - final User user = ess.getUser(event.getPlayer()); - user.setInvSee(false); + final InventoryHolder invHolder = top.getHolder(); + if (invHolder != null && invHolder instanceof HumanEntity) + { + final User user = ess.getUser(event.getPlayer()); + final ItemStack[] contents = + { + top.getItem(0), top.getItem(1), top.getItem(2), top.getItem(3), + }; + ((HumanEntity)invHolder).getInventory().setArmorContents(contents); + user.setInvSee(false); + } } } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandinvsee.java b/Essentials/src/com/earth2me/essentials/commands/Commandinvsee.java index 29f69c22a..1f9083351 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandinvsee.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandinvsee.java @@ -12,7 +12,7 @@ public class Commandinvsee extends EssentialsCommand super("invsee"); } - //This method has a hidden param, which if given will display the armour slots. #easteregg + //This method has a hidden param, which if given will display the equip slots. #easteregg @Override protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception @@ -25,9 +25,9 @@ public class Commandinvsee extends EssentialsCommand final User invUser = getPlayer(server, args, 0); Inventory inv; - if (args.length > 1) + if (args.length > 1 && user.isAuthorized("essentials.invsee.equip")) { - inv = server.createInventory(user, 9, "Equipped"); + inv = server.createInventory(invUser, 9, "Equipped"); inv.setContents(invUser.getInventory().getArmorContents()); } else -- cgit v1.2.3 From ca25c710107eac9e526c861b3d25fbbdc9813f60 Mon Sep 17 00:00:00 2001 From: KHobbits Date: Tue, 1 Jan 2013 19:48:08 +0000 Subject: Cleanup cleanup. --- .../essentials/EssentialsPlayerListener.java | 26 ++-------------------- 1 file changed, 2 insertions(+), 24 deletions(-) diff --git a/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java b/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java index f8e530548..6946bf4ae 100644 --- a/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java +++ b/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java @@ -568,26 +568,9 @@ public class EssentialsPlayerListener implements Listener { final User user = ess.getUser(event.getWhoClicked()); final InventoryHolder invHolder = top.getHolder(); - if (invHolder != null && invHolder instanceof HumanEntity) + if (invHolder != null && invHolder instanceof HumanEntity && user.isInvSee()) { - final User invOwner = ess.getUser((HumanEntity)invHolder); - - if (user.isInvSee() && (!user.isAuthorized("essentials.invsee.modify") - || invOwner.isAuthorized("essentials.invsee.preventmodify") - || !invOwner.isOnline() - || (event.getSlot() > 3 && event.getSlot() < 9))) - { - event.setCancelled(true); - user.updateInventory(); - } - else - { - final ItemStack[] contents = - { - top.getItem(0), top.getItem(1), top.getItem(2), top.getItem(3) - }; - invOwner.getInventory().setArmorContents(contents); - } + event.setCancelled(true); } } } @@ -622,11 +605,6 @@ public class EssentialsPlayerListener implements Listener if (invHolder != null && invHolder instanceof HumanEntity) { final User user = ess.getUser(event.getPlayer()); - final ItemStack[] contents = - { - top.getItem(0), top.getItem(1), top.getItem(2), top.getItem(3), - }; - ((HumanEntity)invHolder).getInventory().setArmorContents(contents); user.setInvSee(false); } } -- cgit v1.2.3 From 63e622374d778a8f14e8b73fa3b38a53aea1eb55 Mon Sep 17 00:00:00 2001 From: KHobbits Date: Tue, 1 Jan 2013 21:12:26 +0000 Subject: New perm: essentials.vanish.effect - People with this effect will get the potion effect applied while vanished. --- Essentials/src/com/earth2me/essentials/User.java | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/Essentials/src/com/earth2me/essentials/User.java b/Essentials/src/com/earth2me/essentials/User.java index bb1e290f4..6fce1c087 100644 --- a/Essentials/src/com/earth2me/essentials/User.java +++ b/Essentials/src/com/earth2me/essentials/User.java @@ -12,6 +12,8 @@ import org.bukkit.Location; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; public class User extends UserData implements Comparable, IReplyTo, IUser @@ -536,7 +538,7 @@ public class User extends UserData implements Comparable, IReplyTo, IUser setDisplayNick(); final String msg = _("userIsNotAway", getDisplayName()); if (!msg.isEmpty()) - { + { ess.broadcastMessage(this, msg); } } @@ -573,7 +575,7 @@ public class User extends UserData implements Comparable, IReplyTo, IUser setDisplayNick(); final String msg = _("userIsAway", getDisplayName()); if (!msg.isEmpty()) - { + { ess.broadcastMessage(this, msg); } } @@ -685,6 +687,10 @@ public class User extends UserData implements Comparable, IReplyTo, IUser } setHidden(true); ess.getVanishedPlayers().add(getName()); + if (isAuthorized("essentials.vanish.effect")) + { + this.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, Integer.MAX_VALUE, 1, false)); + } } else { @@ -694,6 +700,10 @@ public class User extends UserData implements Comparable, IReplyTo, IUser } setHidden(false); ess.getVanishedPlayers().remove(getName()); + if (isAuthorized("essentials.vanish.effect")) + { + this.removePotionEffect(PotionEffectType.INVISIBILITY); + } } } @@ -737,7 +747,7 @@ public class User extends UserData implements Comparable, IReplyTo, IUser @Override public boolean isIgnoreExempt() { - return this.isAuthorized("essentials.chat.ignoreexempt"); + return this.isAuthorized("essentials.chat.ignoreexempt"); } public boolean isRecipeSee() -- cgit v1.2.3 From c6dd921f0c91006e360067abf6fe349da031eca4 Mon Sep 17 00:00:00 2001 From: KHobbits Date: Tue, 1 Jan 2013 22:00:53 +0000 Subject: New permission: essentials.fly.safelogin - Players with this command will automatically switch to fly mode if they login whilst floating in the air. --- .../earth2me/essentials/EssentialsPlayerListener.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java b/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java index 6946bf4ae..9b4585112 100644 --- a/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java +++ b/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java @@ -15,6 +15,7 @@ import java.util.logging.Logger; import org.bukkit.GameMode; import org.bukkit.Location; import org.bukkit.Material; +import org.bukkit.World; import org.bukkit.entity.HumanEntity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -238,6 +239,24 @@ public class EssentialsPlayerListener implements Listener user.sendMessage(_("youHaveNewMail", mail.size())); } } + if (user.isAuthorized("essentials.fly.safelogin")) + { + final World world = user.getLocation().getWorld(); + final int x = user.getLocation().getBlockX(); + int y = user.getLocation().getBlockY(); + final int z = user.getLocation().getBlockZ(); + while (Util.isBlockUnsafe(world, x, y, z) && y > -1) + { + y--; + } + + if (user.getLocation().getBlockY() - y > 1 || y < 0) + { + user.setAllowFlight(true); + user.setFlying(true); + user.sendMessage(_("flyMode", _("enabled"), user.getDisplayName())); + } + } } // Makes the compass item ingame always point to the first essentials home. #EasterEgg -- cgit v1.2.3