mirror of
https://github.com/TotalFreedomMC/TF-PlotSquared.git
synced 2024-12-23 00:15:06 +00:00
Make the chunk listener NOT delete all tile entities in the chunk
This commit is contained in:
parent
ec347f8738
commit
8c0f7b207e
1 changed files with 12 additions and 6 deletions
|
@ -266,7 +266,7 @@ public class ChunkListener implements Listener {
|
||||||
long start = System.currentTimeMillis();
|
long start = System.currentTimeMillis();
|
||||||
int i = 0;
|
int i = 0;
|
||||||
while (System.currentTimeMillis() - start < 250) {
|
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));
|
Bukkit.getScheduler().cancelTask(TaskManager.tasks.get(currentIndex));
|
||||||
TaskManager.tasks.remove(currentIndex);
|
TaskManager.tasks.remove(currentIndex);
|
||||||
PlotSquared.debug("Successfully processed and unloaded chunk!");
|
PlotSquared.debug("Successfully processed and unloaded chunk!");
|
||||||
|
@ -287,11 +287,16 @@ public class ChunkListener implements Listener {
|
||||||
Entity[] entities = chunk.getEntities();
|
Entity[] entities = chunk.getEntities();
|
||||||
BlockState[] tiles = chunk.getTileEntities();
|
BlockState[] tiles = chunk.getTileEntities();
|
||||||
if (entities.length > Settings.Chunk_Processor.MAX_ENTITIES) {
|
if (entities.length > Settings.Chunk_Processor.MAX_ENTITIES) {
|
||||||
for (Entity ent : entities) {
|
int toRemove = entities.length - Settings.Chunk_Processor.MAX_ENTITIES;
|
||||||
if (!(ent instanceof Player)) {
|
int index = 0;
|
||||||
ent.remove();
|
while (toRemove > 0 && index < entities.length) {
|
||||||
|
final Entity entity = entities[index++];
|
||||||
|
if (!(entity instanceof Player)) {
|
||||||
|
entity.remove();
|
||||||
|
toRemove--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PlotSquared.debug(
|
PlotSquared.debug(
|
||||||
"PlotSquared detected unsafe chunk and processed: " + (chunk.getX() << 4) + "," + (
|
"PlotSquared detected unsafe chunk and processed: " + (chunk.getX() << 4) + "," + (
|
||||||
chunk.getX() << 4));
|
chunk.getX() << 4));
|
||||||
|
@ -304,8 +309,9 @@ public class ChunkListener implements Listener {
|
||||||
cleanChunk(chunk);
|
cleanChunk(chunk);
|
||||||
return true;
|
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;
|
return false;
|
||||||
|
|
Loading…
Reference in a new issue