World loading performance improvement

This commit is contained in:
Daniel Saukel 2019-06-16 06:09:52 +02:00
parent 5a0723b145
commit cd2ee3421f
2 changed files with 18 additions and 0 deletions

View File

@ -187,6 +187,14 @@ public class DWorldCache {
return editWorlds;
}
/**
* @param world the world
* @return true if the world is a DXL instance, false if not
*/
public boolean isInstance(World world) {
return world.getName().startsWith("DXL_");
}
/**
* @param name the name of the map; can either be the resource name or the instance name
* @return if a map with this name exists

View File

@ -23,6 +23,7 @@ import de.erethon.caliburn.mob.ExMob;
import de.erethon.dungeonsxl.DungeonsXL;
import de.erethon.dungeonsxl.game.Game;
import java.util.Set;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
@ -41,6 +42,7 @@ import org.bukkit.event.hanging.HangingBreakEvent;
import org.bukkit.event.player.PlayerArmorStandManipulateEvent;
import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.event.weather.WeatherChangeEvent;
import org.bukkit.event.world.WorldInitEvent;
/**
* @author Daniel Saukel, Frank Baumann, Milan Albrecht
@ -55,6 +57,14 @@ public class DWorldListener implements Listener {
dWorlds = plugin.getDWorldCache();
}
@EventHandler(priority = EventPriority.HIGHEST)
public void onInit(WorldInitEvent event) {
World world = event.getWorld();
if (dWorlds.isInstance(world)) {
world.setKeepSpawnInMemory(false);
}
}
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public void onBlockBreak(BlockBreakEvent event) {
Block block = event.getBlock();