summaryrefslogtreecommitdiffstats
path: root/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtect.java
diff options
context:
space:
mode:
authorsnowleo <schneeleo@gmail.com>2011-11-30 20:48:42 +0100
committersnowleo <schneeleo@gmail.com>2011-11-30 20:49:11 +0100
commit3888b08f6d406ae45e3b9fe308c48ba8631fea53 (patch)
treeb44e4573786d3ead3c9309224976ecbdd73c016c /EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtect.java
parentd127f535b2d21328e4ee107502fad31c4c34ca94 (diff)
downloadEssentials-3888b08f6d406ae45e3b9fe308c48ba8631fea53.tar
Essentials-3888b08f6d406ae45e3b9fe308c48ba8631fea53.tar.gz
Essentials-3888b08f6d406ae45e3b9fe308c48ba8631fea53.tar.lz
Essentials-3888b08f6d406ae45e3b9fe308c48ba8631fea53.tar.xz
Essentials-3888b08f6d406ae45e3b9fe308c48ba8631fea53.zip
If Essentials core fails to read one of the configs now, it will disable itself. If other modules detect that Essentials is not enabled, they will be disabled too. EssentialsProtect will go into emergency mode, canceling all events that could hurt your world. Fix the file and either restart or reload the server.
Diffstat (limited to 'EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtect.java')
-rw-r--r--EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtect.java29
1 files changed, 26 insertions, 3 deletions
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