diff options
author | snowleo <schneeleo@gmail.com> | 2012-01-14 23:13:58 +0100 |
---|---|---|
committer | snowleo <schneeleo@gmail.com> | 2012-01-14 23:13:58 +0100 |
commit | 543a85e13e2840ec7454c2b31a3265f2c5b64846 (patch) | |
tree | 11d742d0d44b1800dc2fd6d56010b6cc6804f310 | |
parent | 31844275d7985d113ea190aca1c52b2f52261f4d (diff) | |
download | Essentials-543a85e13e2840ec7454c2b31a3265f2c5b64846.tar Essentials-543a85e13e2840ec7454c2b31a3265f2c5b64846.tar.gz Essentials-543a85e13e2840ec7454c2b31a3265f2c5b64846.tar.lz Essentials-543a85e13e2840ec7454c2b31a3265f2c5b64846.tar.xz Essentials-543a85e13e2840ec7454c2b31a3265f2c5b64846.zip |
Temporary fix for Spawns and Jails when Worlds are loaded after Essentials.
This will be replaced by BetterLocation fix in 3.0 branch.
-rw-r--r-- | Essentials/src/com/earth2me/essentials/Essentials.java | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/Essentials/src/com/earth2me/essentials/Essentials.java b/Essentials/src/com/earth2me/essentials/Essentials.java index fe550279e..223363c3a 100644 --- a/Essentials/src/com/earth2me/essentials/Essentials.java +++ b/Essentials/src/com/earth2me/essentials/Essentials.java @@ -49,6 +49,9 @@ import org.bukkit.event.Event.Priority; import org.bukkit.event.Event.Type; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerListener; +import org.bukkit.event.world.WorldListener; +import org.bukkit.event.world.WorldLoadEvent; +import org.bukkit.event.world.WorldUnloadEvent; import org.bukkit.plugin.InvalidDescriptionException; import org.bukkit.plugin.Plugin; import org.bukkit.plugin.PluginDescriptionFile; @@ -242,6 +245,10 @@ public class Essentials extends JavaPlugin implements IEssentials pm.registerEvent(Type.ENTITY_DEATH, entityListener, Priority.Lowest, this); pm.registerEvent(Type.ENTITY_REGAIN_HEALTH, entityListener, Priority.Lowest, this); pm.registerEvent(Type.FOOD_LEVEL_CHANGE, entityListener, Priority.Lowest, this); + + final EssentialsWorldListener worldListener = new EssentialsWorldListener(this); + pm.registerEvent(Type.WORLD_LOAD, worldListener, Priority.Monitor, this); + pm.registerEvent(Type.WORLD_UNLOAD, worldListener, Priority.Monitor, this); //TODO: Check if this should be here, and not above before reload() jails = new Jails(this); @@ -594,4 +601,32 @@ public class Essentials extends JavaPlugin implements IEssentials { return i18n; } + + private static class EssentialsWorldListener extends WorldListener implements Runnable { + private transient final IEssentials ess; + + public EssentialsWorldListener(IEssentials ess) + { + this.ess = ess; + } + + + @Override + public void onWorldLoad(WorldLoadEvent event) + { + ess.scheduleSyncDelayedTask(this); + } + + @Override + public void onWorldUnload(WorldUnloadEvent event) + { + ess.scheduleSyncDelayedTask(this); + } + + @Override + public void run() + { + ess.reload(); + } + } } |