mirror of
https://github.com/Multiverse/Multiverse-Core.git
synced 2025-02-16 20:41:59 +01:00
Fix weather and spawning
This commit is contained in:
parent
5278eccad2
commit
f519639893
@ -7,6 +7,7 @@
|
||||
|
||||
package com.onarandombox.MultiverseCore.listeners;
|
||||
|
||||
import com.dumptruckman.minecraft.util.Logging;
|
||||
import com.onarandombox.MultiverseCore.inject.InjectableListener;
|
||||
import com.onarandombox.MultiverseCore.worldnew.WorldManager;
|
||||
import com.onarandombox.MultiverseCore.worldnew.WorldPurger;
|
||||
@ -96,7 +97,10 @@ public class MVEntityListener implements InjectableListener {
|
||||
|
||||
worldManager.getMVWorld(event.getEntity().getWorld())
|
||||
.peek((world) -> {
|
||||
event.setCancelled(this.worldPurger.shouldWeKillThisCreature(world, event.getEntity()));
|
||||
if (this.worldPurger.shouldWeKillThisCreature(world, event.getEntity())) {
|
||||
Logging.finer("Cancelling Creature Spawn Event for: " + event.getEntity());
|
||||
event.setCancelled(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -55,9 +55,7 @@ public class MVWorld extends OfflineWorld {
|
||||
if (spawnLocation == null || spawnLocation instanceof NullLocation) {
|
||||
SpawnLocation newLocation = new SpawnLocation(readSpawnFromWorld(world));
|
||||
worldConfig.setSpawnLocation(newLocation);
|
||||
world.setSpawnLocation(newLocation.getBlockX(), newLocation.getBlockY(), newLocation.getBlockZ());
|
||||
}
|
||||
worldConfig.getSpawnLocation().setWorld(world);
|
||||
}
|
||||
|
||||
private Location readSpawnFromWorld(World world) { // TODO: Refactor... this is copy pasted and bad
|
||||
|
@ -53,7 +53,8 @@ public class WorldConfigNodes {
|
||||
if (world == null) { return; }
|
||||
world.getBukkitWorld().peek(world -> {
|
||||
if (!world.isClearWeather() && !newValue) {
|
||||
world.setClearWeatherDuration(-1);
|
||||
world.setThundering(false);
|
||||
world.setStorm(false);
|
||||
}
|
||||
});
|
||||
})
|
||||
@ -164,6 +165,13 @@ public class WorldConfigNodes {
|
||||
public final ConfigNode<Location> SPAWN_LOCATION = node(ConfigNode.builder("spawn-location", Location.class)
|
||||
.defaultValue(new NullLocation())
|
||||
.name("spawn-location")
|
||||
.onSetValue((oldValue, newValue) -> {
|
||||
if (world == null) { return; }
|
||||
world.getBukkitWorld().peek(world -> {
|
||||
world.setSpawnLocation(newValue.getBlockX(), newValue.getBlockY(), newValue.getBlockZ());
|
||||
newValue.setWorld(world);
|
||||
});
|
||||
})
|
||||
.build());
|
||||
|
||||
public final ConfigNode<Boolean> SPAWNING_ANIMALS = node(ConfigNode.builder("spawning.animals.spawn", Boolean.class)
|
||||
|
Loading…
Reference in New Issue
Block a user