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 | c584d74852b219b8f217a909aa124e3a0c63c30a (patch) | |
tree | 3899ba3e0ed1a611a160c2aad351b2f43f3fd30d | |
parent | 6e82419c1573b7f8ee912862cedc65e83af2b93d (diff) | |
download | Essentials-c584d74852b219b8f217a909aa124e3a0c63c30a.tar Essentials-c584d74852b219b8f217a909aa124e3a0c63c30a.tar.gz Essentials-c584d74852b219b8f217a909aa124e3a0c63c30a.tar.lz Essentials-c584d74852b219b8f217a909aa124e3a0c63c30a.tar.xz Essentials-c584d74852b219b8f217a909aa124e3a0c63c30a.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(); + } + } } |