summaryrefslogtreecommitdiffstats
path: root/EssentialsProtect/src
diff options
context:
space:
mode:
Diffstat (limited to 'EssentialsProtect/src')
-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/EmergencyPlayerListener.java16
-rw-r--r--EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtect.java29
-rw-r--r--EssentialsProtect/src/plugin.yml2
5 files changed, 101 insertions, 4 deletions
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..479d2eda6
--- /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;
+
+
+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..a220f07d5
--- /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;
+
+
+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..e92325946
--- /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;
+
+
+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 897112cb6..13e931f8d 100644
--- a/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtect.java
+++ b/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtect.java
@@ -51,6 +51,14 @@ public class EssentialsProtect extends JavaPlugin implements IConf, IProtect
{
final PluginManager pm = this.getServer().getPluginManager();
ess = (IEssentials)pm.getPlugin("Essentials");
+ if (!this.getDescription().getVersion().equals(ess.getDescription().getVersion()))
+ {
+ LOGGER.log(Level.WARNING, _("versionMismatchAll"));
+ }
+ if (!ess.isEnabled()) {
+ enableEmergencyMode(pm);
+ return;
+ }
final EssentialsProtectPlayerListener playerListener = new EssentialsProtectPlayerListener(this);
pm.registerEvent(Type.PLAYER_INTERACT, playerListener, Priority.Low, this);
@@ -79,11 +87,26 @@ public class EssentialsProtect extends JavaPlugin implements IConf, IProtect
reloadConfig();
ess.addReloadListener(this);
- if (!this.getDescription().getVersion().equals(ess.getDescription().getVersion()))
+ LOGGER.info(_("loadinfo", this.getDescription().getName(), this.getDescription().getVersion(), "essentials team"));
+ }
+
+ 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);
+ for (Player player : getServer().getOnlinePlayers())
{
- LOGGER.log(Level.WARNING, _("versionMismatchAll"));
+ player.sendMessage("Essentials Protect is in emergency mode. Check your log for errors.");
}
- LOGGER.info(_("loadinfo", this.getDescription().getName(), this.getDescription().getVersion(), "essentials team"));
+ LOGGER.log(Level.SEVERE, "Essentials not installed or failed to load. Essenials Protect is in emergency mode now.");
}
@Override
diff --git a/EssentialsProtect/src/plugin.yml b/EssentialsProtect/src/plugin.yml
index 31fc1ae99..770d51e64 100644
--- a/EssentialsProtect/src/plugin.yml
+++ b/EssentialsProtect/src/plugin.yml
@@ -6,4 +6,4 @@ version: TeamCity
website: http://www.earth2me.net:8001/
description: Provides protection for various parts of the world.
authors: [Zenexer, ementalo, Aelux, Brettflan, KimKandor, snowleo, ceulemans, Xeology]
-depend: [Essentials] \ No newline at end of file
+softdepend: [Essentials] \ No newline at end of file