diff --git a/Essentials/src/com/earth2me/essentials/commands/Commanddelhome.java b/Essentials/src/com/earth2me/essentials/commands/Commanddelhome.java index ce891985e..c4d0a6946 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commanddelhome.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commanddelhome.java @@ -15,7 +15,7 @@ public class Commanddelhome extends EssentialsCommand } @Override - public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception + public void run(final Server server, final CommandSender sender, final String commandLabel, String[] args) throws Exception { if (args.length < 1) { @@ -24,7 +24,18 @@ public class Commanddelhome extends EssentialsCommand User user = ess.getUser(sender); String name; - final String[] expandedArg = args[0].split(":"); + String[] expandedArg; + + //Allowing both formats /sethome khobbits house | /sethome khobbits:house + final String[] nameParts = args[0].split(":"); + if (nameParts[0].length() != args[0].length()) + { + expandedArg = nameParts; + } + else + { + expandedArg = args; + } if (expandedArg.length > 1 && (user == null || user.isAuthorized("essentials.delhome.others"))) { @@ -41,9 +52,7 @@ public class Commanddelhome extends EssentialsCommand } //TODO: Think up a nice error message /* - * if (name.equalsIgnoreCase("bed")) { - * throw new Exception("You cannot remove the vanilla home point"); - * } + * if (name.equalsIgnoreCase("bed")) { throw new Exception("You cannot remove the vanilla home point"); } */ user.delHome(name.toLowerCase(Locale.ENGLISH)); sender.sendMessage(_("deleteHome", name)); diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandhome.java b/Essentials/src/com/earth2me/essentials/commands/Commandhome.java index 55bd75d0c..ebe57adf7 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandhome.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandhome.java @@ -7,6 +7,7 @@ import com.earth2me.essentials.Util; import java.util.List; import java.util.Locale; import org.bukkit.Location; +import org.bukkit.Material; import org.bukkit.Server; import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; @@ -57,10 +58,14 @@ public class Commandhome extends EssentialsCommand } catch (NotEnoughArgumentsException e) { + Location bed = player.getBedSpawnLocation(); + if (bed != null && bed.getBlock().getType() != Material.BED_BLOCK) + { + bed = null; + } final List homes = player.getHomes(); if (homes.isEmpty() && player.equals(user)) { - final Location bed = player.getBedSpawnLocation(); if (bed != null) { user.getTeleport().teleport(bed, charge, TeleportCause.COMMAND); @@ -79,7 +84,10 @@ public class Commandhome extends EssentialsCommand } else { - homes.add("bed"); + if (bed != null) + { + homes.add("bed"); + } user.sendMessage(_("homes", Util.joinList(homes))); } } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandsethome.java b/Essentials/src/com/earth2me/essentials/commands/Commandsethome.java index e7687fcfd..ec19ca678 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandsethome.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandsethome.java @@ -29,6 +29,9 @@ public class Commandsethome extends EssentialsCommand { if (user.isAuthorized("essentials.sethome.multiple")) { + if ("bed".equals(args[0].toLowerCase(Locale.ENGLISH))) { + throw new NotEnoughArgumentsException(); + } if ((user.isAuthorized("essentials.sethome.multiple.unlimited")) || (user.getHomes().size() < ess.getSettings().getHomeLimit(user)) || (user.getHomes().contains(args[0].toLowerCase(Locale.ENGLISH)))) { @@ -63,6 +66,9 @@ public class Commandsethome extends EssentialsCommand { name = "home"; } + if ("bed".equals(name.toLowerCase(Locale.ENGLISH))) { + throw new NotEnoughArgumentsException(); + } usersHome.setHome(name, user.getLocation()); } } diff --git a/Essentials/src/plugin.yml b/Essentials/src/plugin.yml index 2cb225390..7d8db28bb 100644 --- a/Essentials/src/plugin.yml +++ b/Essentials/src/plugin.yml @@ -3,7 +3,7 @@ name: Essentials main: com.earth2me.essentials.Essentials # Note to developers: This next line cannot change, or the automatic versioning system will break. version: TeamCity -website: http://ci.earth2me.net/ +website: http://tiny.cc/EssentialsCommands description: Provides an essential, core set of commands for Bukkit. authors: [Zenexer, ementalo, Aelux, Brettflan, KimKandor, snowleo, ceulemans, Xeology, KHobbits] commands: diff --git a/EssentialsChat/src/plugin.yml b/EssentialsChat/src/plugin.yml index cc129f825..6f899e33f 100644 --- a/EssentialsChat/src/plugin.yml +++ b/EssentialsChat/src/plugin.yml @@ -3,7 +3,7 @@ name: EssentialsChat main: com.earth2me.essentials.chat.EssentialsChat # Note to developers: This next line cannot change, or the automatic versioning system will break. version: TeamCity -website: http://www.earth2me.net:8001/ +website: http://tiny.cc/EssentialsCommands description: Provides chat control features for Essentials. Requires Permissions. authors: [Zenexer, ementalo, Aelux, Brettflan, KimKandor, snowleo, ceulemans, Xeology, KHobbits, Okamosy] depend: [Essentials] diff --git a/EssentialsGeoIP/src/plugin.yml b/EssentialsGeoIP/src/plugin.yml index 92fdc9963..adf75b83d 100644 --- a/EssentialsGeoIP/src/plugin.yml +++ b/EssentialsGeoIP/src/plugin.yml @@ -3,7 +3,7 @@ name: EssentialsGeoIP main: com.earth2me.essentials.geoip.EssentialsGeoIP # Note to developers: This next line cannot change, or the automatic versioning system will break. version: TeamCity -website: http://www.earth2me.net:8001/ +website: http://tiny.cc/EssentialsCommands description: Shows the country or city of a user on login and /whois. authors: [Zenexer, ementalo, Aelux, Brettflan, KimKandor, snowleo, ceulemans, Xeology] depend: [Essentials] \ No newline at end of file diff --git a/EssentialsGroupManager/src/Changelog.txt b/EssentialsGroupManager/src/Changelog.txt index 5155d6181..ef9a3a408 100644 --- a/EssentialsGroupManager/src/Changelog.txt +++ b/EssentialsGroupManager/src/Changelog.txt @@ -122,4 +122,6 @@ v 1.9: - Fixed subgroups (I broke earlier). - Check for a null player object in the PlayerTeleportEvent. - Trap errors in fetching the mirrors map. - - Fixed an infinite loop error when using '/manudel' on a logged in player. It caused setDefaultGroup to trigger a bukkit update when no GM User existed yet. \ No newline at end of file + - Fixed an infinite loop error when using '/manudel' on a logged in player. It caused setDefaultGroup to trigger a bukkit update when no GM User existed yet. + - do not allow inherited permissions to negate higher perms. + - Fixed a bug when pushing superperms in the wrong order. \ No newline at end of file diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/AnjoPermissionsHandler.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/AnjoPermissionsHandler.java index de42ce9c3..2e008e223 100644 --- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/AnjoPermissionsHandler.java +++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/AnjoPermissionsHandler.java @@ -134,14 +134,18 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface { groupPermArray = populatePerms(ph.getGroup(group).getPermissionList(), includeChildren); } - // Add all group permissions, unless negated by direct player perms. - for (String perm : groupPermArray) - if ((!playerPermArray.contains(perm)) && (!playerPermArray.contains("-" + perm))) + // Add all group permissions, unless negated by earlier permissions. + for (String perm : groupPermArray) { + boolean negated = (perm.startsWith("-")); + // Perm doesn't already exists and there is no negation for it + // or It's a negated perm where a normal perm doesn't exists (don't allow inheritance to negate higher perms) + if ((!negated && !playerPermArray.contains(perm) && !playerPermArray.contains("-" + perm)) + || (negated && !playerPermArray.contains(perm.substring(1)))) playerPermArray.add(perm); + } } - // Collections.sort(playerPermArray, - // StringPermissionComparator.getInstance()); + // Collections.sort(playerPermArray, StringPermissionComparator.getInstance()); return playerPermArray; } diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/BukkitPermissions.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/BukkitPermissions.java index 3ab2dbbeb..396b49583 100644 --- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/BukkitPermissions.java +++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/BukkitPermissions.java @@ -20,15 +20,15 @@ import java.lang.reflect.Field; import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; +import java.util.LinkedHashMap; import java.util.LinkedList; import java.util.List; +import java.util.ListIterator; import java.util.Map; import java.util.Set; import org.anjocaido.groupmanager.GroupManager; -//import org.anjocaido.groupmanager.data.User; import org.anjocaido.groupmanager.dataholder.OverloadedWorldHolder; -//import org.anjocaido.groupmanager.utils.PermissionCheckResult; import org.bukkit.Bukkit; import org.bukkit.entity.Player; @@ -46,7 +46,6 @@ import org.bukkit.event.server.PluginEnableEvent; import org.bukkit.permissions.Permission; import org.bukkit.permissions.PermissionAttachment; import org.bukkit.permissions.PermissionAttachmentInfo; -//import org.bukkit.permissions.PermissionDefault; import org.bukkit.plugin.PluginManager; @@ -54,12 +53,12 @@ import org.bukkit.plugin.PluginManager; * * BukkitPermissions overrides to force GM reponses to Superperms * - * @author ElgarL, originally based upon PermissionsEX implementation + * @author ElgarL */ public class BukkitPermissions { protected Map attachments = new HashMap(); - protected LinkedList registeredPermissions = new LinkedList(); + protected LinkedHashMap registeredPermissions = new LinkedHashMap(); protected GroupManager plugin; protected boolean dumpAllPermissions = true; protected boolean dumpMatchedPermissions = true; @@ -112,14 +111,10 @@ public class BukkitPermissions { public void collectPermissions() { registeredPermissions.clear(); - /* - for (Plugin bukkitPlugin : Bukkit.getServer().getPluginManager().getPlugins()) { - for (Permission permission : bukkitPlugin.getDescription().getPermissions()) - registeredPermissions.push(permission); + + for (Permission perm : Bukkit.getPluginManager().getPermissions()) { + registeredPermissions.put(perm.getName().toLowerCase(), perm); } - */ - - registeredPermissions = new LinkedList(Bukkit.getPluginManager().getPermissions()); } @@ -155,73 +150,22 @@ public class BukkitPermissions { OverloadedWorldHolder worldData = plugin.getWorldsHolder().getWorldData(world); Boolean value = false; - //User user = worldData.getUser(player.getName()); - - /* - // clear permissions - for (String permission : attachment.getPermissions().keySet()) - attachment.unsetPermission(permission); - */ - - /* - * find matching permissions - * - * and base bukkit perms if we are set to allow bukkit permissions to - * override. - */ - - /* - for (Permission permission : registeredPermissions) { - - PermissionCheckResult result = worldData.getPermissionsHandler().checkFullGMPermission(user, permission.getName(), false); - - // Only check bukkit override IF we don't have the permission - // directly. - if (result.resultType == PermissionCheckResult.Type.NOTFOUND) { - PermissionDefault permDefault = permission.getDefault(); - - if ((plugin.getGMConfig().isBukkitPermsOverride()) && ((permDefault == PermissionDefault.TRUE) - || ((permDefault == PermissionDefault.NOT_OP) && !player.isOp()) - || ((permDefault == PermissionDefault.OP) && player.isOp()))) { - value = true; - } else { - value = false; - } - } else if (result.resultType == PermissionCheckResult.Type.NEGATION) { - value = false; - } else { - value = true; - } - - // Set the root permission - if ((value == true) || (result.resultType == PermissionCheckResult.Type.NEGATION)) { - attachment.setPermission(permission, value); - } - } - */ // Add all permissions for this player (GM only) // child nodes will be calculated by Bukkit. - Set playerPermArray = worldData.getPermissionsHandler().getAllPlayersPermissions(player.getName(), false); - Map newPerms = new HashMap(); - - //Set hash = new HashSet(); - //for (String permission : playerPermArray) - // hash.add(permission); - + List playerPermArray = new ArrayList(worldData.getPermissionsHandler().getAllPlayersPermissions(player.getName(), false)); + LinkedHashMap newPerms = new LinkedHashMap(); + + // Sort the perm list by parent/child, so it will push to superperms correctly. + playerPermArray = sort(playerPermArray); + for (String permission : playerPermArray) { value = (!permission.startsWith("-")); - /* - if (!attachment.getPermissions().containsKey(permission)) { - attachment.setPermission(permission, value); - } - */ + newPerms.put((value? permission : permission.substring(1)), value); } - - //player.recalculatePermissions(); - + /** * This is put in place until such a time as Bukkit pull 466 is implemented * https://github.com/Bukkit/Bukkit/pull/466 @@ -241,6 +185,42 @@ public class BukkitPermissions { e.printStackTrace(); } } + + /** + * Sort a permission node list by parent/child + * + * @param permList + * @return List sorted for priority + */ + private List sort(List permList) { + + List result = new ArrayList(); + + for (String key : permList) { + String a = key.charAt(0) == '-'? key.substring(1):key; + Map allchildren = GroupManager.BukkitPermissions.getAllChildren(a, new HashSet()); + if (allchildren != null) { + + ListIterator itr = result.listIterator(); + + while (itr.hasNext()){ + String node = (String) itr.next(); + String b = node.charAt(0) == '-'? node.substring(1):node; + + // Insert the parent node before the child + if (allchildren.containsKey(b)) { + itr.set(key); + itr.add(node); + break; + } + } + } + if (!result.contains(key)) + result.add(key); + } + + return result; + } /** @@ -254,13 +234,12 @@ public class BukkitPermissions { List perms = new ArrayList(); - for (Permission permission : registeredPermissions) { - String name = permission.getName(); - if (!perms.contains(name)) { - perms.add(name); + for (String key : registeredPermissions.keySet()) { + if (!perms.contains(key)) { + perms.add(key); if (includeChildren) { - Map children = getAllChildren(name, new HashSet()); + Map children = getAllChildren(key, new HashSet()); if (children != null) { for (String node : children.keySet()) if (!perms.contains(node)) @@ -316,13 +295,13 @@ public class BukkitPermissions { * @return Map of child permissions */ public Map getChildren(String node) { - for (Permission permission : registeredPermissions) { - if (permission.getName().equalsIgnoreCase(node)) { - return permission.getChildren(); - } - } - return null; + Permission perm = registeredPermissions.get(node.toLowerCase()); + if (perm == null) + return null; + + return perm.getChildren(); + } /** diff --git a/EssentialsGroupManager/src/plugin.yml b/EssentialsGroupManager/src/plugin.yml index dc9b4c29c..65a5d4e95 100644 --- a/EssentialsGroupManager/src/plugin.yml +++ b/EssentialsGroupManager/src/plugin.yml @@ -1,7 +1,7 @@ name: GroupManager version: GMBuildVer (Phoenix) main: org.anjocaido.groupmanager.GroupManager -website: http://www.anjocaido.info/ +website: http://ess.khhq.net/wiki/Group_Manager description: Provides on-the-fly system for permissions system created by Nijikokun. But all in memory, and with flat-file saving schedule. authors: - AnjoCaido diff --git a/EssentialsProtect/src/com/earth2me/essentials/protect/EmergencyBlockListener.java b/EssentialsProtect/src/com/earth2me/essentials/protect/EmergencyBlockListener.java new file mode 100644 index 000000000..7ff17b381 --- /dev/null +++ b/EssentialsProtect/src/com/earth2me/essentials/protect/EmergencyBlockListener.java @@ -0,0 +1,36 @@ +package com.earth2me.essentials.protect; + +import org.bukkit.event.block.BlockBreakEvent; +import org.bukkit.event.block.BlockBurnEvent; +import org.bukkit.event.block.BlockFromToEvent; +import org.bukkit.event.block.BlockIgniteEvent; +import org.bukkit.event.block.BlockListener; + +@Deprecated +public class EmergencyBlockListener extends BlockListener +{ + + @Override + public void onBlockBurn(final BlockBurnEvent event) + { + event.setCancelled(true); + } + + @Override + public void onBlockIgnite(final BlockIgniteEvent event) + { + event.setCancelled(true); + } + + @Override + public void onBlockFromTo(final BlockFromToEvent event) + { + event.setCancelled(true); + } + + @Override + public void onBlockBreak(final BlockBreakEvent event) + { + event.setCancelled(true); + } +} diff --git a/EssentialsProtect/src/com/earth2me/essentials/protect/EmergencyEntityListener.java b/EssentialsProtect/src/com/earth2me/essentials/protect/EmergencyEntityListener.java new file mode 100644 index 000000000..08b04aae1 --- /dev/null +++ b/EssentialsProtect/src/com/earth2me/essentials/protect/EmergencyEntityListener.java @@ -0,0 +1,22 @@ +package com.earth2me.essentials.protect; + +import org.bukkit.event.entity.EntityDamageEvent; +import org.bukkit.event.entity.EntityExplodeEvent; +import org.bukkit.event.entity.EntityListener; + +@Deprecated +public class EmergencyEntityListener extends EntityListener +{ + + @Override + public void onEntityExplode(final EntityExplodeEvent event) + { + event.setCancelled(true); + } + + @Override + public void onEntityDamage(final EntityDamageEvent event) + { + event.setCancelled(true); + } +} diff --git a/EssentialsProtect/src/com/earth2me/essentials/protect/EmergencyPlayerListener.java b/EssentialsProtect/src/com/earth2me/essentials/protect/EmergencyPlayerListener.java new file mode 100644 index 000000000..169e9af79 --- /dev/null +++ b/EssentialsProtect/src/com/earth2me/essentials/protect/EmergencyPlayerListener.java @@ -0,0 +1,16 @@ +package com.earth2me.essentials.protect; + +import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.event.player.PlayerListener; + +@Deprecated +public class EmergencyPlayerListener extends PlayerListener +{ + + @Override + public void onPlayerJoin(PlayerJoinEvent event) + { + event.getPlayer().sendMessage("Essentials Protect is in emergency mode. Check your log for errors."); + } + +} diff --git a/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtect.java b/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtect.java index 983ba0f80..af80647a6 100644 --- a/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtect.java +++ b/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtect.java @@ -9,6 +9,8 @@ import java.util.logging.Level; import java.util.logging.LogRecord; import java.util.logging.Logger; import org.bukkit.entity.Player; +import org.bukkit.event.Event.Priority; +import org.bukkit.event.Event.Type; import org.bukkit.plugin.Plugin; import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.java.JavaPlugin; @@ -63,8 +65,22 @@ public class EssentialsProtect extends JavaPlugin implements IProtect private void enableEmergencyMode(final PluginManager pm) { - final EmergencyListener emListener = new EmergencyListener(); - pm.registerEvents(emListener, this); + //final EmergencyListener emListener = new EmergencyListener(); + //pm.registerEvents(emListener, this); + + //TODO: Remove deprecated listners in a few weeks. + + final EmergencyBlockListener emBlockListener = new EmergencyBlockListener(); + final EmergencyEntityListener emEntityListener = new EmergencyEntityListener(); + final EmergencyPlayerListener emPlayerListener = new EmergencyPlayerListener(); + pm.registerEvent(Type.PLAYER_JOIN, emPlayerListener, Priority.Low, this); + pm.registerEvent(Type.BLOCK_BURN, emBlockListener, Priority.Low, this); + pm.registerEvent(Type.BLOCK_IGNITE, emBlockListener, Priority.Low, this); + pm.registerEvent(Type.BLOCK_FROMTO, emBlockListener, Priority.Low, this); + pm.registerEvent(Type.BLOCK_BREAK, emBlockListener, Priority.Low, this); + pm.registerEvent(Type.ENTITY_DAMAGE, emEntityListener, Priority.Low, this); + pm.registerEvent(Type.ENTITY_EXPLODE, emEntityListener, Priority.Low, this); + for (Player player : getServer().getOnlinePlayers()) { player.sendMessage("Essentials Protect is in emergency mode. Check your log for errors."); diff --git a/EssentialsSpawn/src/com/earth2me/essentials/spawn/EssentialsSpawnPlayerListener.java b/EssentialsSpawn/src/com/earth2me/essentials/spawn/EssentialsSpawnPlayerListener.java index 7ec9ee043..b68b4e350 100644 --- a/EssentialsSpawn/src/com/earth2me/essentials/spawn/EssentialsSpawnPlayerListener.java +++ b/EssentialsSpawn/src/com/earth2me/essentials/spawn/EssentialsSpawnPlayerListener.java @@ -8,6 +8,7 @@ import java.util.logging.Level; import java.util.logging.Logger; import org.bukkit.Bukkit; import org.bukkit.Location; +import org.bukkit.Material; import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerRespawnEvent; @@ -33,10 +34,15 @@ public class EssentialsSpawnPlayerListener implements Listener if (ess.getSettings().getRespawnAtHome()) { - Location home = user.getHome(user.getLocation()); - if (home == null) + Location home; + final Location bed = user.getBedSpawnLocation(); + if (bed != null && bed.getBlock().getType() == Material.BED_BLOCK) { - home = user.getBedSpawnLocation(); + home = bed; + } + else + { + home = user.getHome(user.getLocation()); } if (home != null) { @@ -90,7 +96,7 @@ public class EssentialsSpawnPlayerListener implements Listener { return; } - + try { Location spawn = spawns.getSpawn(ess.getSettings().getNewbieSpawn()); diff --git a/EssentialsSpawn/src/plugin.yml b/EssentialsSpawn/src/plugin.yml index a91031fbe..2c9fca434 100644 --- a/EssentialsSpawn/src/plugin.yml +++ b/EssentialsSpawn/src/plugin.yml @@ -3,7 +3,7 @@ name: EssentialsSpawn main: com.earth2me.essentials.spawn.EssentialsSpawn # Note to developers: This next line cannot change, or the automatic versioning system will break. version: TeamCity -website: http://www.earth2me.net:8001/ +website: http://tiny.cc/EssentialsCommands description: Provides spawn control commands, utilizing Essentials. authors: [Zenexer, ementalo, Aelux, Brettflan, KimKandor, snowleo, ceulemans, Xeology, KHobbits] depend: [Essentials] diff --git a/EssentialsXMPP/src/plugin.yml b/EssentialsXMPP/src/plugin.yml index a193ba95f..2f65b857c 100644 --- a/EssentialsXMPP/src/plugin.yml +++ b/EssentialsXMPP/src/plugin.yml @@ -3,7 +3,7 @@ name: EssentialsXMPP main: com.earth2me.essentials.xmpp.EssentialsXMPP # Note to developers: This next line cannot change, or the automatic versioning system will break. version: TeamCity -website: http://www.earth2me.net:8001/ +website: http://ess.khhq.net/wiki/XMPP description: Provides xmpp communication. authors: - snowleo