Option to disable the automatic purge of entities (#1933)

This commit is contained in:
Brokkonaut 2019-01-25 19:16:29 +01:00 committed by Jeremy Wood
parent 07df8d0d09
commit d0180f05d5
4 changed files with 34 additions and 2 deletions

View File

@ -282,7 +282,9 @@ public class MVWorld implements MultiverseWorld {
}
world.setSpawnFlags(allowMonsters, allowAnimals);
}
plugin.getMVWorldManager().getTheWorldPurger().purgeWorld(MVWorld.this);
if (MultiverseCoreConfiguration.getInstance().isAutoPurgeEnabled()) {
plugin.getMVWorldManager().getTheWorldPurger().purgeWorld(MVWorld.this);
}
return super.validateChange(property, newValue, oldValue, object);
}
}

View File

@ -67,6 +67,8 @@ public class MultiverseCoreConfiguration extends SerializationConfig implements
private volatile boolean defaultportalsearch;
@Property
private volatile int portalsearchradius;
@Property
private volatile boolean autopurge;
public MultiverseCoreConfiguration() {
super();
@ -98,6 +100,7 @@ public class MultiverseCoreConfiguration extends SerializationConfig implements
silentstart = false;
defaultportalsearch = false;
portalsearchradius = 128;
autopurge = true;
// END CHECKSTYLE-SUPPRESSION: MagicNumberCheck
}
@ -332,4 +335,14 @@ public class MultiverseCoreConfiguration extends SerializationConfig implements
public int getPortalSearchRadius() {
return portalsearchradius;
}
@Override
public boolean isAutoPurgeEnabled() {
return autopurge;
}
@Override
public void setAutoPurgeEnabled(boolean autopurge) {
this.autopurge = autopurge;
}
}

View File

@ -199,4 +199,18 @@ public interface MultiverseCoreConfig extends ConfigurationSerializable {
* @return The portal search radius.
*/
int getPortalSearchRadius();
/**
* Gets whether or not the automatic purge of entities is enabled.
*
* @return True if automatic purge is enabled.
*/
boolean isAutoPurgeEnabled();
/**
* Sets whether or not the automatic purge of entities is enabled.
*
* @param autopurge True if automatic purge should be enabled.
*/
void setAutoPurgeEnabled(boolean autopurge);
}

View File

@ -10,6 +10,7 @@ package com.onarandombox.MultiverseCore.utils;
import com.dumptruckman.minecraft.util.Logging;
import com.onarandombox.MultiverseCore.MVWorld;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.MultiverseCoreConfiguration;
import com.onarandombox.MultiverseCore.WorldProperties;
import com.onarandombox.MultiverseCore.api.MVWorldManager;
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
@ -474,7 +475,9 @@ public class WorldManager implements MVWorldManager {
return false;
}
MVWorld world = new MVWorld(plugin, cbworld, mvworld);
this.worldPurger.purgeWorld(world);
if (MultiverseCoreConfiguration.getInstance().isAutoPurgeEnabled()) {
this.worldPurger.purgeWorld(world);
}
this.worlds.put(worldName, world);
return true;
}