mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 05:06:44 +01:00
Make the chunk listener NOT delete all tile entities in the chunk
This commit is contained in:
parent
ec347f8738
commit
8c0f7b207e
@ -266,7 +266,7 @@ public class ChunkListener implements Listener {
|
||||
long start = System.currentTimeMillis();
|
||||
int i = 0;
|
||||
while (System.currentTimeMillis() - start < 250) {
|
||||
if (i >= tiles.length) {
|
||||
if (i >= tiles.length - Settings.Chunk_Processor.MAX_TILES) {
|
||||
Bukkit.getScheduler().cancelTask(TaskManager.tasks.get(currentIndex));
|
||||
TaskManager.tasks.remove(currentIndex);
|
||||
PlotSquared.debug("Successfully processed and unloaded chunk!");
|
||||
@ -287,11 +287,16 @@ public class ChunkListener implements Listener {
|
||||
Entity[] entities = chunk.getEntities();
|
||||
BlockState[] tiles = chunk.getTileEntities();
|
||||
if (entities.length > Settings.Chunk_Processor.MAX_ENTITIES) {
|
||||
for (Entity ent : entities) {
|
||||
if (!(ent instanceof Player)) {
|
||||
ent.remove();
|
||||
int toRemove = entities.length - Settings.Chunk_Processor.MAX_ENTITIES;
|
||||
int index = 0;
|
||||
while (toRemove > 0 && index < entities.length) {
|
||||
final Entity entity = entities[index++];
|
||||
if (!(entity instanceof Player)) {
|
||||
entity.remove();
|
||||
toRemove--;
|
||||
}
|
||||
}
|
||||
|
||||
PlotSquared.debug(
|
||||
"PlotSquared detected unsafe chunk and processed: " + (chunk.getX() << 4) + "," + (
|
||||
chunk.getX() << 4));
|
||||
@ -304,8 +309,9 @@ public class ChunkListener implements Listener {
|
||||
cleanChunk(chunk);
|
||||
return true;
|
||||
}
|
||||
for (BlockState tile : tiles) {
|
||||
tile.getBlock().setType(Material.AIR, false);
|
||||
|
||||
for (int i = 0 ; i < (tiles.length - Settings.Chunk_Processor.MAX_TILES); i++) {
|
||||
tiles[i].getBlock().setType(Material.AIR, false);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
Loading…
Reference in New Issue
Block a user