mirror of
https://github.com/EngineHub/WorldGuard.git
synced 2024-12-19 15:48:10 +01:00
Apply weather settings on world load.
This commit is contained in:
parent
89ce7312d1
commit
e6de06aae8
@ -169,7 +169,12 @@ public void onEnable() {
|
|||||||
(new WorldGuardBlockListener(this)).registerEvents();
|
(new WorldGuardBlockListener(this)).registerEvents();
|
||||||
(new WorldGuardEntityListener(this)).registerEvents();
|
(new WorldGuardEntityListener(this)).registerEvents();
|
||||||
(new WorldGuardWeatherListener(this)).registerEvents();
|
(new WorldGuardWeatherListener(this)).registerEvents();
|
||||||
(new WorldGuardWorldListener(this)).registerEvents();
|
|
||||||
|
// handle worlds separately to initialize already loaded worlds
|
||||||
|
WorldGuardWorldListener worldListener = (new WorldGuardWorldListener(this));
|
||||||
|
for (World world : getServer().getWorlds()) {
|
||||||
|
worldListener.initWorld(world);
|
||||||
|
}
|
||||||
|
|
||||||
// Check god mode for existing players, if any
|
// Check god mode for existing players, if any
|
||||||
for (Player player : getServer().getOnlinePlayers()) {
|
for (Player player : getServer().getOnlinePlayers()) {
|
||||||
|
@ -7,10 +7,12 @@
|
|||||||
|
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import org.bukkit.World;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
import org.bukkit.event.world.ChunkLoadEvent;
|
import org.bukkit.event.world.ChunkLoadEvent;
|
||||||
import org.bukkit.event.world.WorldListener;
|
import org.bukkit.event.world.WorldListener;
|
||||||
|
import org.bukkit.event.world.WorldLoadEvent;
|
||||||
import org.bukkit.plugin.PluginManager;
|
import org.bukkit.plugin.PluginManager;
|
||||||
|
|
||||||
public class WorldGuardWorldListener extends WorldListener {
|
public class WorldGuardWorldListener extends WorldListener {
|
||||||
@ -38,6 +40,7 @@ public void registerEvents() {
|
|||||||
// PluginManager pm = plugin.getServer().getPluginManager();
|
// PluginManager pm = plugin.getServer().getPluginManager();
|
||||||
|
|
||||||
registerEvent("CHUNK_LOAD", Event.Priority.Normal);
|
registerEvent("CHUNK_LOAD", Event.Priority.Normal);
|
||||||
|
registerEvent("WORLD_LOAD", Event.Priority.Normal);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -78,4 +81,26 @@ public void onChunkLoad(ChunkLoadEvent event) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when a world is loaded.
|
||||||
|
*/
|
||||||
|
public void onWorldLoad(WorldLoadEvent event) {
|
||||||
|
initWorld(event.getWorld());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void initWorld(World world) {
|
||||||
|
ConfigurationManager cfg = plugin.getGlobalStateManager();
|
||||||
|
WorldConfiguration wcfg = cfg.get(world);
|
||||||
|
if (wcfg.alwaysRaining && !wcfg.disableWeather) {
|
||||||
|
world.setStorm(true);
|
||||||
|
} else if (wcfg.disableWeather && !wcfg.alwaysRaining) {
|
||||||
|
world.setStorm(false);
|
||||||
|
}
|
||||||
|
if (wcfg.alwaysThundering && !wcfg.disableThunder) {
|
||||||
|
world.setThundering(true);
|
||||||
|
} else if (wcfg.disableThunder && !wcfg.alwaysThundering) {
|
||||||
|
world.setStorm(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user