mirror of
				https://github.com/IntellectualSites/PlotSquared.git
				synced 2025-11-04 03:03:43 +01:00 
			
		
		
		
	Optimizations
This commit is contained in:
		@@ -137,7 +137,6 @@ public class ChunkManager {
 | 
				
			|||||||
        index.increment();
 | 
					        index.increment();
 | 
				
			||||||
        final int relX = newPos.getBlockX() - pos1.getBlockX();
 | 
					        final int relX = newPos.getBlockX() - pos1.getBlockX();
 | 
				
			||||||
        final int relZ = newPos.getBlockZ() - pos1.getBlockZ();
 | 
					        final int relZ = newPos.getBlockZ() - pos1.getBlockZ();
 | 
				
			||||||
        System.out.print(relX + "," + relZ);
 | 
					 | 
				
			||||||
        final RegionWrapper region = new RegionWrapper(pos1.getBlockX(), pos2.getBlockX(), pos1.getBlockZ(), pos2.getBlockZ());
 | 
					        final RegionWrapper region = new RegionWrapper(pos1.getBlockX(), pos2.getBlockX(), pos1.getBlockZ(), pos2.getBlockZ());
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
        final World world = pos1.getWorld();
 | 
					        final World world = pos1.getWorld();
 | 
				
			||||||
@@ -177,20 +176,20 @@ public class ChunkManager {
 | 
				
			|||||||
        final int loadTask = Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() {
 | 
					        final int loadTask = Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() {
 | 
				
			||||||
            @Override
 | 
					            @Override
 | 
				
			||||||
            public void run() {
 | 
					            public void run() {
 | 
				
			||||||
 | 
					                long start = System.currentTimeMillis();
 | 
				
			||||||
 | 
					                while (System.currentTimeMillis() - start < 25) {
 | 
				
			||||||
                    if (toGenerate.size() == 0) {
 | 
					                    if (toGenerate.size() == 0) {
 | 
				
			||||||
                        Bukkit.getScheduler().cancelTask(tasks.get(currentIndex));
 | 
					                        Bukkit.getScheduler().cancelTask(tasks.get(currentIndex));
 | 
				
			||||||
                        tasks.remove(currentIndex);
 | 
					                        tasks.remove(currentIndex);
 | 
				
			||||||
                        TaskManager.runTask(new Runnable() {
 | 
					                        TaskManager.runTask(new Runnable() {
 | 
				
			||||||
                            @Override
 | 
					                            @Override
 | 
				
			||||||
                            public void run() {
 | 
					                            public void run() {
 | 
				
			||||||
                            System.out.print("================== SETTING BLOCKS ===================");
 | 
					 | 
				
			||||||
                                index.increment();
 | 
					                                index.increment();
 | 
				
			||||||
                                // Copy entities
 | 
					                                // Copy entities
 | 
				
			||||||
                                initMaps();
 | 
					                                initMaps();
 | 
				
			||||||
                                for (int x = c3x; x <= c4x; x ++) {
 | 
					                                for (int x = c3x; x <= c4x; x ++) {
 | 
				
			||||||
                                    for (int z = c3z; z <= c4z; z ++) {
 | 
					                                    for (int z = c3z; z <= c4z; z ++) {
 | 
				
			||||||
                                        Chunk chunk = world.getChunkAt(x, z);
 | 
					                                        Chunk chunk = world.getChunkAt(x, z);
 | 
				
			||||||
                                    System.out.print("SAVING ENTITIES: " + chunk);
 | 
					 | 
				
			||||||
                                        chunks.add(chunk);
 | 
					                                        chunks.add(chunk);
 | 
				
			||||||
                                        chunk.load(false);
 | 
					                                        chunk.load(false);
 | 
				
			||||||
                                        saveEntitiesIn(chunk, region);
 | 
					                                        saveEntitiesIn(chunk, region);
 | 
				
			||||||
@@ -204,11 +203,9 @@ public class ChunkManager {
 | 
				
			|||||||
                                final Integer task = Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() {
 | 
					                                final Integer task = Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() {
 | 
				
			||||||
                                    @Override
 | 
					                                    @Override
 | 
				
			||||||
                                    public void run() {
 | 
					                                    public void run() {
 | 
				
			||||||
                                    System.out.print(" - " + mx.intValue());
 | 
					 | 
				
			||||||
                                        long start = System.currentTimeMillis();
 | 
					                                        long start = System.currentTimeMillis();
 | 
				
			||||||
                                    while (System.currentTimeMillis() - start < 20) {
 | 
					                                        while (System.currentTimeMillis() - start < 25) {
 | 
				
			||||||
                                            int x = mx.intValue();
 | 
					                                            int x = mx.intValue();
 | 
				
			||||||
                                        System.out.print(x);
 | 
					 | 
				
			||||||
                                            for (int z = sz; z <= ez; z++) {
 | 
					                                            for (int z = sz; z <= ez; z++) {
 | 
				
			||||||
                                                saveBlocks(world, maxY, x, z);
 | 
					                                                saveBlocks(world, maxY, x, z);
 | 
				
			||||||
                                                for (int y = 1; y <= maxY; y++) {
 | 
					                                                for (int y = 1; y <= maxY; y++) {
 | 
				
			||||||
@@ -219,7 +216,7 @@ public class ChunkManager {
 | 
				
			|||||||
                                                }
 | 
					                                                }
 | 
				
			||||||
                                            }
 | 
					                                            }
 | 
				
			||||||
                                            mx.increment();
 | 
					                                            mx.increment();
 | 
				
			||||||
                                        if (x + 1 == ex) { // done!
 | 
					                                            if (x == ex) { // done!
 | 
				
			||||||
                                                restoreBlocks(world, relX, relZ);
 | 
					                                                restoreBlocks(world, relX, relZ);
 | 
				
			||||||
                                                AbstractSetBlock.setBlockManager.update(chunks);
 | 
					                                                AbstractSetBlock.setBlockManager.update(chunks);
 | 
				
			||||||
                                                for (Chunk chunk : chunks) {
 | 
					                                                for (Chunk chunk : chunks) {
 | 
				
			||||||
@@ -233,6 +230,7 @@ public class ChunkManager {
 | 
				
			|||||||
                                        }
 | 
					                                        }
 | 
				
			||||||
                                    };
 | 
					                                    };
 | 
				
			||||||
                                }, 1, 1);
 | 
					                                }, 1, 1);
 | 
				
			||||||
 | 
					                                
 | 
				
			||||||
                                tasks.put(currentIndex, task);
 | 
					                                tasks.put(currentIndex, task);
 | 
				
			||||||
                            }
 | 
					                            }
 | 
				
			||||||
                        });
 | 
					                        });
 | 
				
			||||||
@@ -242,7 +240,7 @@ public class ChunkManager {
 | 
				
			|||||||
                    toGenerate.remove(0);
 | 
					                    toGenerate.remove(0);
 | 
				
			||||||
                    chunk.load(true);
 | 
					                    chunk.load(true);
 | 
				
			||||||
                    chunks.add(chunk);
 | 
					                    chunks.add(chunk);
 | 
				
			||||||
                System.out.print("GENERATING CHUNK: " + chunk);
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }, 1l, 1l);
 | 
					        }, 1l, 1l);
 | 
				
			||||||
        tasks.put(currentIndex, loadTask);
 | 
					        tasks.put(currentIndex, loadTask);
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user