From 437d3b41b891a13c2f683a292ff10a7c48126ed5 Mon Sep 17 00:00:00 2001 From: ElgarL Date: Tue, 8 Nov 2011 13:03:32 +0000 Subject: [PATCH 1/7] Remove bperms nodes which shouldn't be in globalGroups --- EssentialsGroupManager/src/globalgroups.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/EssentialsGroupManager/src/globalgroups.yml b/EssentialsGroupManager/src/globalgroups.yml index 43c225b6a..9662baf43 100644 --- a/EssentialsGroupManager/src/globalgroups.yml +++ b/EssentialsGroupManager/src/globalgroups.yml @@ -142,11 +142,6 @@ groups: g:bukkit_admin: permissions: - - bPermissions.admin - - bPermissions.demote.admin - - bPermissions.gui - - bPermissions.iplock.lock - - bPermissions.promote.admin - bukkit.broadcast - bukkit.broadcast.admin - bukkit.command From cd897890be57a6162ee0281a476de3f58f998882 Mon Sep 17 00:00:00 2001 From: snowleo Date: Fri, 11 Nov 2011 03:27:01 +0100 Subject: [PATCH 2/7] Fix #1106 GeoIP announces players who are hidden, on join. --- .../essentials/geoip/EssentialsGeoIPPlayerListener.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EssentialsGeoIP/src/com/earth2me/essentials/geoip/EssentialsGeoIPPlayerListener.java b/EssentialsGeoIP/src/com/earth2me/essentials/geoip/EssentialsGeoIPPlayerListener.java index 5a6553f0e..8926f77e8 100644 --- a/EssentialsGeoIP/src/com/earth2me/essentials/geoip/EssentialsGeoIPPlayerListener.java +++ b/EssentialsGeoIP/src/com/earth2me/essentials/geoip/EssentialsGeoIPPlayerListener.java @@ -79,7 +79,7 @@ public class EssentialsGeoIPPlayerListener extends PlayerListener implements ICo { u.setGeoLocation(sb.toString()); } - if (config.getBoolean("show-on-login", true)) + if (config.getBoolean("show-on-login", true) && !u.isHidden()) { for (Player player : event.getPlayer().getServer().getOnlinePlayers()) { From b619a54105d93319f6adfbacecf5ac892ce66734 Mon Sep 17 00:00:00 2001 From: KHobbits Date: Mon, 14 Nov 2011 10:11:23 +0000 Subject: [PATCH 3/7] Prevent client crash on 'Free air' --- Essentials/src/com/earth2me/essentials/signs/SignFree.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Essentials/src/com/earth2me/essentials/signs/SignFree.java b/Essentials/src/com/earth2me/essentials/signs/SignFree.java index 8939f4bea..8a7c27fe7 100644 --- a/Essentials/src/com/earth2me/essentials/signs/SignFree.java +++ b/Essentials/src/com/earth2me/essentials/signs/SignFree.java @@ -4,7 +4,9 @@ import com.earth2me.essentials.IEssentials; import com.earth2me.essentials.InventoryWorkaround; import com.earth2me.essentials.Trade; import com.earth2me.essentials.User; +import com.earth2me.essentials.Util; import net.minecraft.server.InventoryPlayer; +import org.bukkit.Material; import org.bukkit.craftbukkit.inventory.CraftInventoryPlayer; import org.bukkit.inventory.ItemStack; @@ -27,6 +29,11 @@ public class SignFree extends EssentialsSign protected boolean onSignInteract(final ISign sign, final User player, final String username, final IEssentials ess) throws SignException { final ItemStack item = getItemStack(sign.getLine(1), 1, ess); + if (item.getType() == Material.AIR) + { + throw new SignException(Util.format("cantSpawnItem", "Air")); + } + item.setAmount(item.getType().getMaxStackSize()*9*4); final CraftInventoryPlayer inv = new CraftInventoryPlayer(new InventoryPlayer(player.getHandle())); inv.clear(); From f4e22a17db5cf86fbf972f1584fcc2858af75022 Mon Sep 17 00:00:00 2001 From: ElgarL Date: Tue, 15 Nov 2011 18:17:18 +0000 Subject: [PATCH 4/7] Added comments to groups.yml for global groups --- EssentialsGroupManager/src/groups.yml | 8 ++++++++ .../dataholder/WorldDataHolder.java | 19 +++++++++++++++++-- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/EssentialsGroupManager/src/groups.yml b/EssentialsGroupManager/src/groups.yml index ac4abeb4a..81fb4f030 100644 --- a/EssentialsGroupManager/src/groups.yml +++ b/EssentialsGroupManager/src/groups.yml @@ -1,3 +1,11 @@ +# Group inheritance +# any inherited groups prefixed with a g: are global groups +# These groups are defined in the globalgroups.yml +# and can be inherited in any worlds groups/users.yml. +# +# Groups without the g: prefix are groups local to this world +# and defined in the this groups.yml file. + groups: Default: default: true diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/WorldDataHolder.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/WorldDataHolder.java index 8f5fad5cf..e8e01967f 100644 --- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/WorldDataHolder.java +++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/WorldDataHolder.java @@ -881,6 +881,7 @@ public class WorldDataHolder { Map root = new HashMap(); Map groupsMap = new HashMap(); + root.put("groups", groupsMap); for (String groupKey : ph.groups.keySet()) { Group group = ph.groups.get(groupKey); @@ -910,10 +911,24 @@ public class WorldDataHolder { opt.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK); final Yaml yaml = new Yaml(opt); try { - yaml.dump(root, new OutputStreamWriter(new FileOutputStream(groupsFile), "UTF-8")); + OutputStreamWriter out = new OutputStreamWriter(new FileOutputStream(groupsFile), "UTF-8"); + + String newLine = System.getProperty("line.separator"); + + out.write("# Group inheritance" + newLine); + out.write("# any inherited groups prefixed with a g: are global groups" + newLine); + out.write("# These groups are defined in the globalgroups.yml" + newLine); + out.write("# and can be inherited in any worlds groups/users.yml." + newLine); + out.write("#" + newLine); + out.write("# Groups without the g: prefix are groups local to this world" + newLine); + out.write("# and defined in the this groups.yml file." + newLine); + out.write(newLine); + + yaml.dump(root, out); } catch (UnsupportedEncodingException ex) { } catch (FileNotFoundException ex) { - } + } catch (IOException e) { + } } // Update the LastModified time. From d2f3bf94ae54e4ae4451f033de96a1d5a529ca33 Mon Sep 17 00:00:00 2001 From: snowleo Date: Tue, 15 Nov 2011 22:47:02 +0100 Subject: [PATCH 5/7] Prevent that players are teleported to offline players using /tpa and players that lost their tpahere permission --- .../essentials/commands/Commandtpaccept.java | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtpaccept.java b/Essentials/src/com/earth2me/essentials/commands/Commandtpaccept.java index 043f23172..fd9eeaa84 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.OfflinePlayer; import com.earth2me.essentials.Trade; import org.bukkit.Server; import com.earth2me.essentials.User; @@ -14,34 +15,36 @@ public class Commandtpaccept extends EssentialsCommand } @Override - public void run(Server server, User user, String commandLabel, String[] args) throws Exception + public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception { - User p = user.getTeleportRequest(); - if (p == null) + final User target = user.getTeleportRequest(); + if (target == null + || target.getBase() instanceof OfflinePlayer + || (user.isTeleportRequestHere() && !target.isAuthorized("essentials.tpahere"))) { throw new Exception(Util.i18n("noPendingRequest")); } - Trade charge = new Trade(this.getName(), ess); + final Trade charge = new Trade(this.getName(), ess); if (user.isTeleportRequestHere()) { charge.isAffordableFor(user); } else { - charge.isAffordableFor(p); + charge.isAffordableFor(target); } user.sendMessage(Util.i18n("requestAccepted")); - p.sendMessage(Util.format("requestAcceptedFrom", user.getDisplayName())); - + target.sendMessage(Util.format("requestAcceptedFrom", user.getDisplayName())); + if (user.isTeleportRequestHere()) { - user.getTeleport().teleport(p, charge); + user.getTeleport().teleport(target, charge); } else { - p.getTeleport().teleport(user, charge); + target.getTeleport().teleport(user, charge); } user.requestTeleport(null, false); } From cccebdd62e72937ab0f7d2304d592eefce758cbb Mon Sep 17 00:00:00 2001 From: snowleo Date: Tue, 15 Nov 2011 22:49:23 +0100 Subject: [PATCH 6/7] null the Essentials object in static EcoApi, so it doesn't leak on /reload. TODO: Make the eco api non-static --- Essentials/src/com/earth2me/essentials/Essentials.java | 1 + 1 file changed, 1 insertion(+) diff --git a/Essentials/src/com/earth2me/essentials/Essentials.java b/Essentials/src/com/earth2me/essentials/Essentials.java index a571483f6..392321f9f 100644 --- a/Essentials/src/com/earth2me/essentials/Essentials.java +++ b/Essentials/src/com/earth2me/essentials/Essentials.java @@ -221,6 +221,7 @@ public class Essentials extends JavaPlugin implements IEssentials @Override public void onDisable() { + Economy.setEss(null); Trade.closeLog(); } From 27ee7efde5c3ae65ce2dd98bc0b6b201d751683e Mon Sep 17 00:00:00 2001 From: snowleo Date: Tue, 15 Nov 2011 22:50:09 +0100 Subject: [PATCH 7/7] Cleanup of the /tree commands --- .../src/com/earth2me/essentials/Util.java | 19 ++++++++++++++++++- .../essentials/commands/Commandbigtree.java | 11 +++-------- .../essentials/commands/Commandtree.java | 9 +++------ 3 files changed, 24 insertions(+), 15 deletions(-) diff --git a/Essentials/src/com/earth2me/essentials/Util.java b/Essentials/src/com/earth2me/essentials/Util.java index c1b0ed7bf..067c8115f 100644 --- a/Essentials/src/com/earth2me/essentials/Util.java +++ b/Essentials/src/com/earth2me/essentials/Util.java @@ -28,6 +28,8 @@ import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.World; import org.bukkit.block.Block; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; public class Util @@ -221,6 +223,7 @@ public class Util // The player can stand inside these materials private static final Set AIR_MATERIALS = new HashSet(); + private static final HashSet AIR_MATERIALS_TARGET = new HashSet(); static { AIR_MATERIALS.add(Material.AIR.getId()); @@ -256,7 +259,21 @@ public class Util AIR_MATERIALS.add(Material.MELON_STEM.getId()); AIR_MATERIALS.add(Material.VINE.getId()); //TODO: Add 1.9 materials - + + for (Integer integer : AIR_MATERIALS) + { + AIR_MATERIALS_TARGET.add(integer.byteValue()); + } + AIR_MATERIALS_TARGET.add((byte)Material.WATER.getId()); + AIR_MATERIALS_TARGET.add((byte)Material.STATIONARY_WATER.getId()); + } + + public static Location getTarget(final LivingEntity entity) throws Exception { + final Block block = entity.getTargetBlock(AIR_MATERIALS_TARGET, 300); + if (block == null) { + throw new Exception("Not targeting a block"); + } + return block.getLocation(); } public static Location getSafeDestination(final Location loc) throws Exception diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandbigtree.java b/Essentials/src/com/earth2me/essentials/commands/Commandbigtree.java index ded3ffdaf..c6cf83df4 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandbigtree.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandbigtree.java @@ -1,6 +1,5 @@ package com.earth2me.essentials.commands; -import com.earth2me.essentials.TargetBlock; import org.bukkit.Server; import org.bukkit.TreeType; import com.earth2me.essentials.User; @@ -31,14 +30,10 @@ public class Commandbigtree extends EssentialsCommand { throw new NotEnoughArgumentsException(); } - - final int[] ignore = - { - 8, 9 - }; - final Location loc = (new TargetBlock(user, 300, 0.2, ignore)).getTargetBlock().getLocation(); + + final Location loc = Util.getTarget(user); final Location safeLocation = Util.getSafeDestination(loc); - final boolean success = user.getWorld().generateTree(safeLocation, (TreeType)tree); + final boolean success = user.getWorld().generateTree(safeLocation, tree); if (success) { user.sendMessage(Util.i18n("bigTreeSuccess")); diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtree.java b/Essentials/src/com/earth2me/essentials/commands/Commandtree.java index 8013453ab..26bc9a8ee 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandtree.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandtree.java @@ -1,13 +1,10 @@ package com.earth2me.essentials.commands; -import com.earth2me.essentials.TargetBlock; import org.bukkit.Location; import org.bukkit.Server; import org.bukkit.TreeType; import com.earth2me.essentials.User; import com.earth2me.essentials.Util; -import org.bukkit.Material; -import org.bukkit.block.Block; public class Commandtree extends EssentialsCommand @@ -20,7 +17,7 @@ public class Commandtree extends EssentialsCommand @Override public void run(Server server, User user, String commandLabel, String[] args) throws Exception { - Object tree = new Object(); + TreeType tree; if (args.length < 1) { throw new NotEnoughArgumentsException(); @@ -46,9 +43,9 @@ public class Commandtree extends EssentialsCommand { 8, 9 }; - final Location loc = (new TargetBlock(user, 300, 0.2, ignore)).getTargetBlock().getLocation(); + final Location loc = Util.getTarget(user); final Location safeLocation = Util.getSafeDestination(loc); - final boolean success = user.getWorld().generateTree(safeLocation, (TreeType)tree); + final boolean success = user.getWorld().generateTree(safeLocation, tree); if (success) { user.sendMessage(Util.i18n("treeSpawned"));