mirror of
https://github.com/Multiverse/Multiverse-Core.git
synced 2024-11-22 10:36:06 +01:00
Non-default worlds will now no longer initially load their spawn chunks if keepSpawnInMemory is false. Fixes #1079
This commit is contained in:
parent
8ea639eba8
commit
21aaf4a03e
@ -73,6 +73,7 @@ import com.onarandombox.MultiverseCore.listeners.MVPlayerListener;
|
||||
import com.onarandombox.MultiverseCore.listeners.MVPluginListener;
|
||||
import com.onarandombox.MultiverseCore.listeners.MVPortalListener;
|
||||
import com.onarandombox.MultiverseCore.listeners.MVWeatherListener;
|
||||
import com.onarandombox.MultiverseCore.listeners.MVWorldInitListener;
|
||||
import com.onarandombox.MultiverseCore.listeners.MVWorldListener;
|
||||
import com.onarandombox.MultiverseCore.utils.AnchorManager;
|
||||
import com.onarandombox.MultiverseCore.utils.MVMessaging;
|
||||
@ -266,6 +267,8 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
||||
*/
|
||||
@Override
|
||||
public void onEnable() {
|
||||
getServer().getPluginManager().registerEvents(new MVWorldInitListener(this), this);
|
||||
|
||||
this.messaging = new MVMessaging();
|
||||
this.banker = new AllPay(this, LOG_TAG + " ");
|
||||
this.vaultHandler = new VaultHandler(this);
|
||||
|
@ -62,12 +62,17 @@ public class WorldProperties extends SerializationConfig {
|
||||
PROPERTY_ALIASES.put("allowfly", "allowFlight");
|
||||
}
|
||||
|
||||
private final boolean keepSpawnFallback;
|
||||
|
||||
public WorldProperties(Map<String, Object> values) {
|
||||
super(values);
|
||||
Object keepSpawnObject = values.get("keepSpawnInMemory");
|
||||
keepSpawnFallback = keepSpawnObject == null || Boolean.parseBoolean(keepSpawnObject.toString());
|
||||
}
|
||||
|
||||
public WorldProperties() {
|
||||
super();
|
||||
keepSpawnFallback = true;
|
||||
}
|
||||
|
||||
public WorldProperties(final boolean fixSpawn, final Environment environment) {
|
||||
@ -76,6 +81,7 @@ public class WorldProperties extends SerializationConfig {
|
||||
this.adjustSpawn = false;
|
||||
}
|
||||
setScaling(getDefaultScale(environment));
|
||||
keepSpawnFallback = true;
|
||||
}
|
||||
|
||||
void setMVWorld(MVWorld world) {
|
||||
@ -525,6 +531,9 @@ public class WorldProperties extends SerializationConfig {
|
||||
}
|
||||
|
||||
public boolean isKeepingSpawnInMemory() {
|
||||
if (keepSpawnInMemory == null) {
|
||||
return keepSpawnFallback;
|
||||
}
|
||||
return this.keepSpawnInMemory.get();
|
||||
}
|
||||
|
||||
|
@ -9,7 +9,6 @@ package com.onarandombox.MultiverseCore.api;
|
||||
|
||||
import com.onarandombox.MultiverseCore.utils.PurgeWorlds;
|
||||
import com.onarandombox.MultiverseCore.utils.SimpleWorldPurger;
|
||||
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.World.Environment;
|
||||
import org.bukkit.WorldType;
|
||||
@ -287,4 +286,6 @@ public interface MVWorldManager {
|
||||
* @return True if success, false if fail.
|
||||
*/
|
||||
boolean regenWorld(String name, boolean useNewSeed, boolean randomSeed, String seed);
|
||||
|
||||
boolean isKeepingSpawnInMemory(World world);
|
||||
}
|
||||
|
@ -0,0 +1,29 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.listeners;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.world.WorldInitEvent;
|
||||
|
||||
public class MVWorldInitListener implements Listener {
|
||||
|
||||
MultiverseCore plugin;
|
||||
|
||||
public MVWorldInitListener(MultiverseCore plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void initWorld(WorldInitEvent event) {
|
||||
if (!plugin.getMVWorldManager().isKeepingSpawnInMemory(event.getWorld())) {
|
||||
event.getWorld().setKeepSpawnInMemory(false);
|
||||
}
|
||||
}
|
||||
}
|
@ -710,6 +710,11 @@ public class WorldManager implements MVWorldManager {
|
||||
|
||||
private static final char SEPARATOR = '\uF8FF';
|
||||
|
||||
public boolean isKeepingSpawnInMemory(World world) {
|
||||
WorldProperties properties = worldsFromTheConfig.get(world.getName());
|
||||
return properties == null || properties.isKeepingSpawnInMemory();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user