From 999d922fb972651fd45f4cccb42d76f29da1e8ce Mon Sep 17 00:00:00 2001 From: ElgarL Date: Fri, 11 Jan 2013 00:53:48 +0000 Subject: [PATCH 1/3] Store a plugin and server reference. --- .../anjocaido/groupmanager/GroupManager.java | 2 +- .../groupmanager/events/GMGroupEvent.java | 5 ++-- .../groupmanager/events/GMSystemEvent.java | 6 ++--- .../groupmanager/events/GMUserEvent.java | 5 ++-- .../events/GroupManagerEventHandler.java | 27 ++++++++++++------- 5 files changed, 24 insertions(+), 21 deletions(-) diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java index e8e157d1d..8298988e6 100644 --- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java +++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java @@ -88,7 +88,7 @@ public class GroupManager extends JavaPlugin { /* * Initialize the event handler */ - setGMEventHandler(new GroupManagerEventHandler(this.getServer())); + setGMEventHandler(new GroupManagerEventHandler(this)); onEnable(false); } diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/events/GMGroupEvent.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/events/GMGroupEvent.java index b0e5e1755..fe7c98640 100644 --- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/events/GMGroupEvent.java +++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/events/GMGroupEvent.java @@ -2,7 +2,6 @@ package org.anjocaido.groupmanager.events; import org.anjocaido.groupmanager.GroupManager; import org.anjocaido.groupmanager.data.Group; -import org.bukkit.Bukkit; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; @@ -75,12 +74,12 @@ public class GMGroupEvent extends Event { public void schedule(final GMGroupEvent event) { synchronized (GroupManager.getGMEventHandler().getServer()) { - if (Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(Bukkit.getPluginManager().getPlugin("GroupManager"), new Runnable() { + if (GroupManager.getGMEventHandler().getServer().getScheduler().scheduleSyncDelayedTask(GroupManager.getGMEventHandler().getPlugin(), new Runnable() { @Override public void run() { - Bukkit.getServer().getPluginManager().callEvent(event); + GroupManager.getGMEventHandler().getServer().getPluginManager().callEvent(event); } }, 1) == -1) GroupManager.logger.warning("Could not schedule GM Event."); diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/events/GMSystemEvent.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/events/GMSystemEvent.java index b89db6147..a04190d99 100644 --- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/events/GMSystemEvent.java +++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/events/GMSystemEvent.java @@ -1,7 +1,6 @@ package org.anjocaido.groupmanager.events; import org.anjocaido.groupmanager.GroupManager; -import org.bukkit.Server; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; @@ -30,7 +29,6 @@ public class GMSystemEvent extends Event { ////////////////////////////// protected Action action; - protected Server server; public GMSystemEvent(Action action) { @@ -51,12 +49,12 @@ public class GMSystemEvent extends Event { public void schedule(final GMSystemEvent event) { synchronized (GroupManager.getGMEventHandler().getServer()) { - if (server.getScheduler().scheduleSyncDelayedTask(server.getPluginManager().getPlugin("GroupManager"), new Runnable() { + if (GroupManager.getGMEventHandler().getServer().getScheduler().scheduleSyncDelayedTask(GroupManager.getGMEventHandler().getPlugin(), new Runnable() { @Override public void run() { - server.getPluginManager().callEvent(event); + GroupManager.getGMEventHandler().getServer().getPluginManager().callEvent(event); } }, 1) == -1) GroupManager.logger.warning("Could not schedule GM Event."); diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/events/GMUserEvent.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/events/GMUserEvent.java index b4392a3e1..12c9baa0e 100644 --- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/events/GMUserEvent.java +++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/events/GMUserEvent.java @@ -2,7 +2,6 @@ package org.anjocaido.groupmanager.events; import org.anjocaido.groupmanager.GroupManager; import org.anjocaido.groupmanager.data.User; -import org.bukkit.Bukkit; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; @@ -75,12 +74,12 @@ public class GMUserEvent extends Event { public void schedule(final GMUserEvent event) { synchronized (GroupManager.getGMEventHandler().getServer()) { - if (Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(Bukkit.getPluginManager().getPlugin("GroupManager"), new Runnable() { + if (GroupManager.getGMEventHandler().getServer().getScheduler().scheduleSyncDelayedTask(GroupManager.getGMEventHandler().getPlugin(), new Runnable() { @Override public void run() { - Bukkit.getServer().getPluginManager().callEvent(event); + GroupManager.getGMEventHandler().getServer().getPluginManager().callEvent(event); } }, 1) == -1) GroupManager.logger.warning("Could not schedule GM Event."); diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/events/GroupManagerEventHandler.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/events/GroupManagerEventHandler.java index dd24dffdb..d0df57aa7 100644 --- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/events/GroupManagerEventHandler.java +++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/events/GroupManagerEventHandler.java @@ -1,5 +1,6 @@ package org.anjocaido.groupmanager.events; +import org.anjocaido.groupmanager.GroupManager; import org.anjocaido.groupmanager.data.Group; import org.anjocaido.groupmanager.data.User; import org.bukkit.Server; @@ -12,10 +13,15 @@ import org.bukkit.Server; */ public class GroupManagerEventHandler { - protected Server server; + private final Server server; + private final GroupManager plugin; - public GroupManagerEventHandler(Server server) { - this.server = server; + + public GroupManagerEventHandler(GroupManager plugin) { + + this.plugin = plugin; + this.server = plugin.getServer(); + } protected void callEvent(GMGroupEvent event) { @@ -58,6 +64,14 @@ public class GroupManagerEventHandler { callEvent(new GMSystemEvent(action)); } + /** + * @return the plugin + */ + public GroupManager getPlugin() { + + return plugin; + } + /** * @return the server */ @@ -67,11 +81,4 @@ public class GroupManagerEventHandler { } - /** - * @param server the server to set - */ - public void setServer(Server server) { - - this.server = server; - } } \ No newline at end of file From f3812786d0c0eb416f62f1a58f9b4d317954bce3 Mon Sep 17 00:00:00 2001 From: Chris Ward Date: Fri, 11 Jan 2013 21:54:52 +1100 Subject: [PATCH 2/3] Fixes Item Frames being linked to Paintings when breaking --- .../EssentialsAntiBuildListener.java | 23 +++++++++++++++---- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/EssentialsAntiBuild/src/com/earth2me/essentials/antibuild/EssentialsAntiBuildListener.java b/EssentialsAntiBuild/src/com/earth2me/essentials/antibuild/EssentialsAntiBuildListener.java index 76089505c..67995c955 100644 --- a/EssentialsAntiBuild/src/com/earth2me/essentials/antibuild/EssentialsAntiBuildListener.java +++ b/EssentialsAntiBuild/src/com/earth2me/essentials/antibuild/EssentialsAntiBuildListener.java @@ -7,6 +7,7 @@ import java.util.logging.Level; import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.entity.Entity; +import org.bukkit.entity.EntityType; import org.bukkit.entity.HumanEntity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -151,14 +152,26 @@ public class EssentialsAntiBuildListener implements Listener if (entity instanceof Player) { final User user = ess.getUser(entity); - if (prot.getSettingBool(AntiBuildConfig.disable_build) && !user.canBuild() && !user.isAuthorized("essentials.build") - && !metaPermCheck(user, "break", Material.PAINTING.getId())) + final EntityType type = event.getEntity().getType(); + final boolean warn = ess.getSettings().warnOnBuildDisallow(); + if (prot.getSettingBool(AntiBuildConfig.disable_build) && !user.canBuild() && !user.isAuthorized("essentials.build")) { - if (ess.getSettings().warnOnBuildDisallow()) + if (type == EntityType.PAINTING && !metaPermCheck(user, "break", Material.PAINTING.getId())) { - user.sendMessage(_("antiBuildBreak", Material.PAINTING.toString())); + if (warn) + { + user.sendMessage(_("antiBuildBreak", Material.PAINTING.toString())); + } + event.setCancelled(true); + } + else if(type == EntityType.ITEM_FRAME && !metaPermCheck(user, "break", Material.ITEM_FRAME.getId())) + { + if (warn) + { + user.sendMessage(_("antiBuildBreak", Material.ITEM_FRAME.toString())); + } + event.setCancelled(true); } - event.setCancelled(true); } } } From 01e78cd6664e7d33a2c502cc1f1631650908a3ef Mon Sep 17 00:00:00 2001 From: Necrodoom Date: Fri, 11 Jan 2013 19:10:32 +0200 Subject: [PATCH 3/3] /me shakes fist at Khobbits fixes e6aeefb12d23b8517557e444de5e81467adc2415 whitespace --- Essentials/src/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Essentials/src/config.yml b/Essentials/src/config.yml index 10247ab09..4453f355c 100644 --- a/Essentials/src/config.yml +++ b/Essentials/src/config.yml @@ -247,7 +247,7 @@ enabledSigns: #- spawnmob #- repair #- time - #- weather + #- weather # How many times per second can Essentials signs be interacted with per player. # Values should be between 1-20, 20 being virtually no lag protection.