summaryrefslogtreecommitdiffstats
path: root/EssentialsProtect/src/com/earth2me/essentials
diff options
context:
space:
mode:
authorsnowleo <schneeleo@gmail.com>2012-01-20 05:20:37 +0100
committersnowleo <schneeleo@gmail.com>2012-01-20 05:20:37 +0100
commit3315019203f6ac217bcc8fc751e5067fa3b147c0 (patch)
tree28e2695fb1eb37eff4ec76549a64ec819019ca10 /EssentialsProtect/src/com/earth2me/essentials
parent6ff7e6fd254a105364bcf30a054748adcf6005a1 (diff)
downloadEssentials-3315019203f6ac217bcc8fc751e5067fa3b147c0.tar
Essentials-3315019203f6ac217bcc8fc751e5067fa3b147c0.tar.gz
Essentials-3315019203f6ac217bcc8fc751e5067fa3b147c0.tar.lz
Essentials-3315019203f6ac217bcc8fc751e5067fa3b147c0.tar.xz
Essentials-3315019203f6ac217bcc8fc751e5067fa3b147c0.zip
Update for new CraftBukkit Event Code
EssentialsSpawn can't be updated yet, because the new event system lacks dynamic priorities.
Diffstat (limited to 'EssentialsProtect/src/com/earth2me/essentials')
-rw-r--r--EssentialsProtect/src/com/earth2me/essentials/protect/EmergencyBlockListener.java36
-rw-r--r--EssentialsProtect/src/com/earth2me/essentials/protect/EmergencyEntityListener.java22
-rw-r--r--EssentialsProtect/src/com/earth2me/essentials/protect/EmergencyListener.java58
-rw-r--r--EssentialsProtect/src/com/earth2me/essentials/protect/EmergencyPlayerListener.java16
-rw-r--r--EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtect.java12
-rw-r--r--EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectBlockListener.java22
-rw-r--r--EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectEntityListener.java17
-rw-r--r--EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectPlayerListener.java8
-rw-r--r--EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectWeatherListener.java12
9 files changed, 95 insertions, 108 deletions
diff --git a/EssentialsProtect/src/com/earth2me/essentials/protect/EmergencyBlockListener.java b/EssentialsProtect/src/com/earth2me/essentials/protect/EmergencyBlockListener.java
deleted file mode 100644
index 479d2eda6..000000000
--- a/EssentialsProtect/src/com/earth2me/essentials/protect/EmergencyBlockListener.java
+++ /dev/null
@@ -1,36 +0,0 @@
-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;
-
-
-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
deleted file mode 100644
index a220f07d5..000000000
--- a/EssentialsProtect/src/com/earth2me/essentials/protect/EmergencyEntityListener.java
+++ /dev/null
@@ -1,22 +0,0 @@
-package com.earth2me.essentials.protect;
-
-import org.bukkit.event.entity.EntityDamageEvent;
-import org.bukkit.event.entity.EntityExplodeEvent;
-import org.bukkit.event.entity.EntityListener;
-
-
-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/EmergencyListener.java b/EssentialsProtect/src/com/earth2me/essentials/protect/EmergencyListener.java
new file mode 100644
index 000000000..5f9253c55
--- /dev/null
+++ b/EssentialsProtect/src/com/earth2me/essentials/protect/EmergencyListener.java
@@ -0,0 +1,58 @@
+package com.earth2me.essentials.protect;
+
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.EventPriority;
+import org.bukkit.event.Listener;
+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.entity.EntityDamageEvent;
+import org.bukkit.event.entity.EntityExplodeEvent;
+import org.bukkit.event.player.PlayerJoinEvent;
+
+
+public class EmergencyListener implements Listener
+{
+ @EventHandler(priority = EventPriority.LOW)
+ public void onBlockBurn(final BlockBurnEvent event)
+ {
+ event.setCancelled(true);
+ }
+
+ @EventHandler(priority = EventPriority.LOW)
+ public void onBlockIgnite(final BlockIgniteEvent event)
+ {
+ event.setCancelled(true);
+ }
+
+ @EventHandler(priority = EventPriority.LOW)
+ public void onBlockFromTo(final BlockFromToEvent event)
+ {
+ event.setCancelled(true);
+ }
+
+ @EventHandler(priority = EventPriority.LOW)
+ public void onBlockBreak(final BlockBreakEvent event)
+ {
+ event.setCancelled(true);
+ }
+
+ @EventHandler(priority = EventPriority.LOW)
+ public void onPlayerJoin(final PlayerJoinEvent event)
+ {
+ event.getPlayer().sendMessage("Essentials Protect is in emergency mode. Check your log for errors.");
+ }
+
+ @EventHandler(priority = EventPriority.LOW)
+ public void onEntityExplode(final EntityExplodeEvent event)
+ {
+ event.setCancelled(true);
+ }
+
+ @EventHandler(priority = EventPriority.LOW)
+ 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
deleted file mode 100644
index e92325946..000000000
--- a/EssentialsProtect/src/com/earth2me/essentials/protect/EmergencyPlayerListener.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package com.earth2me.essentials.protect;
-
-import org.bukkit.event.player.PlayerJoinEvent;
-import org.bukkit.event.player.PlayerListener;
-
-
-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 e313298cd..095296531 100644
--- a/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtect.java
+++ b/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtect.java
@@ -78,16 +78,8 @@ public class EssentialsProtect extends JavaPlugin implements IProtect
private void enableEmergencyMode(final PluginManager pm)
{
- 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);
+ final EmergencyListener emListener = new EmergencyListener();
+ pm.registerEvents(emListener, this);
for (Player player : getServer().getOnlinePlayers())
{
player.sendMessage("Essentials Protect is in emergency mode. Check your log for errors.");
diff --git a/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectBlockListener.java b/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectBlockListener.java
index a1d16af25..c193561db 100644
--- a/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectBlockListener.java
+++ b/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectBlockListener.java
@@ -9,10 +9,13 @@ import java.util.List;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.EventPriority;
+import org.bukkit.event.Listener;
import org.bukkit.event.block.*;
-public class EssentialsProtectBlockListener extends BlockListener
+public class EssentialsProtectBlockListener implements Listener
{
final private transient IProtect prot;
final private transient IEssentials ess;
@@ -23,7 +26,7 @@ public class EssentialsProtectBlockListener extends BlockListener
this.ess = prot.getEssentialsConnect().getEssentials();
}
- @Override
+ @EventHandler(priority = EventPriority.HIGHEST)
public void onBlockPlace(final BlockPlaceEvent event)
{
if (event.isCancelled())
@@ -93,7 +96,7 @@ public class EssentialsProtectBlockListener extends BlockListener
}
}
- @Override
+ @EventHandler(priority = EventPriority.HIGHEST)
public void onBlockIgnite(BlockIgniteEvent event)
{
if (event.isCancelled())
@@ -144,7 +147,7 @@ public class EssentialsProtectBlockListener extends BlockListener
}
}
- @Override
+ @EventHandler(priority = EventPriority.HIGHEST)
public void onBlockFromTo(final BlockFromToEvent event)
{
if (event.isCancelled())
@@ -185,7 +188,7 @@ public class EssentialsProtectBlockListener extends BlockListener
}
}
- @Override
+ @EventHandler(priority = EventPriority.HIGHEST)
public void onBlockBurn(final BlockBurnEvent event)
{
if (event.isCancelled())
@@ -221,7 +224,7 @@ public class EssentialsProtectBlockListener extends BlockListener
BlockFace.SELF
};
- @Override
+ @EventHandler(priority = EventPriority.HIGHEST)
public void onBlockBreak(final BlockBreakEvent event)
{
if (event.isCancelled())
@@ -319,7 +322,7 @@ public class EssentialsProtectBlockListener extends BlockListener
}
}
- @Override
+ @EventHandler(priority = EventPriority.HIGHEST)
public void onBlockPistonExtend(BlockPistonExtendEvent event)
{
if (event.isCancelled())
@@ -372,7 +375,7 @@ public class EssentialsProtectBlockListener extends BlockListener
}
}
- @Override
+ @EventHandler(priority = EventPriority.HIGHEST)
public void onBlockPistonRetract(BlockPistonRetractEvent event)
{
if (event.isCancelled() || !event.isSticky())
@@ -460,7 +463,8 @@ public class EssentialsProtectBlockListener extends BlockListener
}
}
}
- if (prot.getSettingBool(ProtectConfig.protect_rails)) {
+ if (prot.getSettingBool(ProtectConfig.protect_rails))
+ {
if (type == Material.RAILS || type == Material.POWERED_RAIL || type == Material.DETECTOR_RAIL)
{
return prot.getStorage().isProtected(block, user.getName());
diff --git a/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectEntityListener.java b/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectEntityListener.java
index 89167b2b9..40167ec41 100644
--- a/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectEntityListener.java
+++ b/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectEntityListener.java
@@ -8,12 +8,15 @@ import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.*;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.EventPriority;
+import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.entity.EntityTargetEvent.TargetReason;
import org.bukkit.event.entity.*;
-public class EssentialsProtectEntityListener extends EntityListener
+public class EssentialsProtectEntityListener implements Listener
{
private final transient IProtect prot;
private final transient IEssentials ess;
@@ -24,7 +27,7 @@ public class EssentialsProtectEntityListener extends EntityListener
this.ess = prot.getEssentialsConnect().getEssentials();
}
- @Override
+ @EventHandler(priority = EventPriority.HIGHEST)
public void onEntityDamage(final EntityDamageEvent event)
{
if (event.isCancelled())
@@ -189,7 +192,7 @@ public class EssentialsProtectEntityListener extends EntityListener
}
}
- @Override
+ @EventHandler(priority = EventPriority.HIGHEST)
public void onEntityExplode(final EntityExplodeEvent event)
{
if (event.isCancelled())
@@ -261,7 +264,7 @@ public class EssentialsProtectEntityListener extends EntityListener
}
}
- @Override
+ @EventHandler(priority = EventPriority.HIGHEST)
public void onCreatureSpawn(final CreatureSpawnEvent event)
{
if (event.getEntity() instanceof Player)
@@ -288,7 +291,7 @@ public class EssentialsProtectEntityListener extends EntityListener
}
}
- @Override
+ @EventHandler(priority = EventPriority.HIGHEST)
public void onEntityTarget(final EntityTargetEvent event)
{
if (event.isCancelled())
@@ -314,7 +317,7 @@ public class EssentialsProtectEntityListener extends EntityListener
}
}
- @Override
+ @EventHandler(priority = EventPriority.HIGHEST)
public void onExplosionPrime(ExplosionPrimeEvent event)
{
if ((event.getEntity() instanceof Fireball || event.getEntity() instanceof SmallFireball)
@@ -324,7 +327,7 @@ public class EssentialsProtectEntityListener extends EntityListener
}
}
- @Override
+ @EventHandler(priority = EventPriority.HIGHEST)
public void onEndermanPickup(EndermanPickupEvent event)
{
if (event.isCancelled())
diff --git a/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectPlayerListener.java b/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectPlayerListener.java
index ad7831a53..6b49e70d8 100644
--- a/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectPlayerListener.java
+++ b/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectPlayerListener.java
@@ -5,13 +5,15 @@ import com.earth2me.essentials.IEssentials;
import com.earth2me.essentials.User;
import org.bukkit.Material;
import org.bukkit.block.Block;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.EventPriority;
+import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;
-import org.bukkit.event.player.PlayerListener;
import org.bukkit.inventory.ItemStack;
-public class EssentialsProtectPlayerListener extends PlayerListener
+public class EssentialsProtectPlayerListener implements Listener
{
private final transient IProtect prot;
private final transient IEssentials ess;
@@ -22,7 +24,7 @@ public class EssentialsProtectPlayerListener extends PlayerListener
this.ess = prot.getEssentialsConnect().getEssentials();
}
- @Override
+ @EventHandler(priority = EventPriority.HIGHEST)
public void onPlayerInteract(final PlayerInteractEvent event)
{
// Do not return if cancelled, because the interact event has 2 cancelled states.
diff --git a/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectWeatherListener.java b/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectWeatherListener.java
index e81efc72b..1b8dd19ff 100644
--- a/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectWeatherListener.java
+++ b/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectWeatherListener.java
@@ -1,12 +1,14 @@
package com.earth2me.essentials.protect;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.EventPriority;
+import org.bukkit.event.Listener;
import org.bukkit.event.weather.LightningStrikeEvent;
import org.bukkit.event.weather.ThunderChangeEvent;
import org.bukkit.event.weather.WeatherChangeEvent;
-import org.bukkit.event.weather.WeatherListener;
-public class EssentialsProtectWeatherListener extends WeatherListener
+public class EssentialsProtectWeatherListener implements Listener
{
private final transient IProtect prot;
@@ -15,7 +17,7 @@ public class EssentialsProtectWeatherListener extends WeatherListener
this.prot = prot;
}
- @Override
+ @EventHandler(priority = EventPriority.HIGHEST)
public void onWeatherChange(final WeatherChangeEvent event)
{
if (!event.isCancelled()
@@ -27,7 +29,7 @@ public class EssentialsProtectWeatherListener extends WeatherListener
}
- @Override
+ @EventHandler(priority = EventPriority.HIGHEST)
public void onLightningStrike(final LightningStrikeEvent event)
{
if (!event.isCancelled()
@@ -37,7 +39,7 @@ public class EssentialsProtectWeatherListener extends WeatherListener
}
}
- @Override
+ @EventHandler(priority = EventPriority.HIGHEST)
public void onThunderChange(final ThunderChangeEvent event)
{
if (!event.isCancelled()