mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-29 16:46:45 +01:00
Fixes #162
This commit is contained in:
parent
3a40614bb2
commit
da4bf3b8b9
@ -171,13 +171,19 @@ public class BukkitHybridUtils extends HybridUtils {
|
|||||||
|
|
||||||
private static boolean UPDATE = false;
|
private static boolean UPDATE = false;
|
||||||
private int task;
|
private int task;
|
||||||
|
private long last;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean scheduleRoadUpdate(final String world) {
|
public boolean scheduleRoadUpdate(final String world) {
|
||||||
if (BukkitHybridUtils.UPDATE) {
|
if (BukkitHybridUtils.UPDATE) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
BukkitHybridUtils.UPDATE = true;
|
||||||
final List<ChunkLoc> regions = ChunkManager.manager.getChunkChunks(world);
|
final List<ChunkLoc> regions = ChunkManager.manager.getChunkChunks(world);
|
||||||
|
return scheduleRoadUpdate(world, regions);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean scheduleRoadUpdate(final String world, final List<ChunkLoc> regions) {
|
||||||
final List<ChunkLoc> chunks = new ArrayList<ChunkLoc>();
|
final List<ChunkLoc> chunks = new ArrayList<ChunkLoc>();
|
||||||
final Plugin plugin = BukkitMain.THIS;
|
final Plugin plugin = BukkitMain.THIS;
|
||||||
this.task = Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() {
|
this.task = Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() {
|
||||||
@ -196,15 +202,37 @@ public class BukkitHybridUtils extends HybridUtils {
|
|||||||
PlotSquared.log(" - Remaining: " + regions.size());
|
PlotSquared.log(" - Remaining: " + regions.size());
|
||||||
chunks.addAll(getChunks(regions.get(0)));
|
chunks.addAll(getChunks(regions.get(0)));
|
||||||
regions.remove(0);
|
regions.remove(0);
|
||||||
|
System.gc();
|
||||||
}
|
}
|
||||||
if (chunks.size() > 0) {
|
if (chunks.size() > 0) {
|
||||||
long diff = System.currentTimeMillis() + 50;
|
long diff = System.currentTimeMillis() + 25;
|
||||||
while (System.currentTimeMillis() < diff) {
|
if (System.currentTimeMillis() - last > 1000 && last != 0) {
|
||||||
ChunkLoc chunk = chunks.get(0);
|
last = 0;
|
||||||
chunks.remove(0);
|
PlotSquared.log(C.PREFIX.s() + "Detected low TPS. Rescheduling in 1 minute");
|
||||||
regenerateRoad(world, chunk);
|
while (chunks.size() > 0) {
|
||||||
|
ChunkLoc chunk = chunks.get(0);
|
||||||
|
chunks.remove(0);
|
||||||
|
regenerateRoad(world, chunk);
|
||||||
|
ChunkManager.manager.unloadChunk(world, chunk);
|
||||||
|
}
|
||||||
|
Bukkit.getScheduler().cancelTask(BukkitHybridUtils.this.task);
|
||||||
|
TaskManager.runTaskLater(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
scheduleRoadUpdate(world, regions);
|
||||||
|
}
|
||||||
|
}, 1200);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
if (System.currentTimeMillis() - last < 50) {
|
||||||
|
while (System.currentTimeMillis() < diff) {
|
||||||
|
ChunkLoc chunk = chunks.get(0);
|
||||||
|
chunks.remove(0);
|
||||||
|
regenerateRoad(world, chunk);
|
||||||
|
ChunkManager.manager.unloadChunk(world, chunk);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
last = System.currentTimeMillis();
|
||||||
}
|
}
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
final ChunkLoc loc = regions.get(0);
|
final ChunkLoc loc = regions.get(0);
|
||||||
@ -221,7 +249,7 @@ public class BukkitHybridUtils extends HybridUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, 20, 20);
|
}, 1, 1);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -277,7 +277,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (Settings.TELEPORT_ON_LOGIN) {
|
if (Settings.TELEPORT_ON_LOGIN) {
|
||||||
BukkitUtil.teleportPlayer(player, MainUtil.getPlotHomeDefault(plot));
|
MainUtil.teleportPlayer(pp, pp.getLocation(), plot);
|
||||||
MainUtil.sendMessage(pp, C.TELEPORTED_TO_ROAD);
|
MainUtil.sendMessage(pp, C.TELEPORTED_TO_ROAD);
|
||||||
}
|
}
|
||||||
plotEntry(player, plot);
|
plotEntry(player, plot);
|
||||||
|
Loading…
Reference in New Issue
Block a user