First idea implementation
This commit is contained in:
parent
c8801dbb8c
commit
b0f0a4deb5
13 changed files with 243 additions and 79 deletions
|
|
@ -481,6 +481,7 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
|
|||
boolean rslt = permissions.hasOfflinePermission(player, perm);
|
||||
return rslt;
|
||||
}
|
||||
private final Object[] lock = {};
|
||||
/**
|
||||
* Render processor helper - used by code running on render threads to request chunk snapshot cache from server/sync thread
|
||||
*/
|
||||
|
|
@ -514,46 +515,64 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
|
|||
final MapChunkCache cc = c;
|
||||
|
||||
while(!cc.isDoneLoading()) {
|
||||
Future<Boolean> f = core.getServer().callSyncMethod(new Callable<Boolean>() {
|
||||
public Boolean call() throws Exception {
|
||||
boolean exhausted = true;
|
||||
|
||||
if (prev_tick != cur_tick) {
|
||||
prev_tick = cur_tick;
|
||||
cur_tick_starttime = System.nanoTime();
|
||||
}
|
||||
if(chunks_in_cur_tick > 0) {
|
||||
boolean done = false;
|
||||
while (!done) {
|
||||
int cnt = chunks_in_cur_tick;
|
||||
if (cnt > 5) cnt = 5;
|
||||
chunks_in_cur_tick -= cc.loadChunks(cnt);
|
||||
exhausted = (chunks_in_cur_tick == 0) || ((System.nanoTime() - cur_tick_starttime) > perTickLimit);
|
||||
done = exhausted || cc.isDoneLoading();
|
||||
if (BukkitVersionHelper.helper.isUnsafeAsync()) {
|
||||
Future<Boolean> f = core.getServer().callSyncMethod(new Callable<Boolean>() {
|
||||
public Boolean call() throws Exception {
|
||||
boolean exhausted = true;
|
||||
|
||||
if (prev_tick != cur_tick) {
|
||||
prev_tick = cur_tick;
|
||||
cur_tick_starttime = System.nanoTime();
|
||||
}
|
||||
if (chunks_in_cur_tick > 0) {
|
||||
boolean done = false;
|
||||
while (!done) {
|
||||
int cnt = chunks_in_cur_tick;
|
||||
if (cnt > 5) cnt = 5;
|
||||
chunks_in_cur_tick -= cc.loadChunks(cnt);
|
||||
exhausted = (chunks_in_cur_tick == 0) || ((System.nanoTime() - cur_tick_starttime) > perTickLimit);
|
||||
done = exhausted || cc.isDoneLoading();
|
||||
}
|
||||
}
|
||||
return exhausted;
|
||||
}
|
||||
return exhausted;
|
||||
});
|
||||
if (f == null) {
|
||||
return null;
|
||||
}
|
||||
Boolean delay;
|
||||
try {
|
||||
delay = f.get();
|
||||
} catch (CancellationException cx) {
|
||||
return null;
|
||||
} catch (InterruptedException cx) {
|
||||
return null;
|
||||
} catch (ExecutionException ex) {
|
||||
Log.severe("Exception while fetching chunks: ", ex.getCause());
|
||||
return null;
|
||||
} catch (Exception ix) {
|
||||
Log.severe(ix);
|
||||
return null;
|
||||
}
|
||||
|
||||
if ((delay != null) && delay.booleanValue()) {
|
||||
try {
|
||||
Thread.sleep(25);
|
||||
} catch (InterruptedException ix) {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
synchronized (lock) {
|
||||
if (prev_tick != cur_tick) {
|
||||
prev_tick = cur_tick;
|
||||
cur_tick_starttime = System.nanoTime();
|
||||
}
|
||||
cc.loadChunks(Integer.MAX_VALUE);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
if (f == null) {
|
||||
return null;
|
||||
}
|
||||
Boolean delay;
|
||||
try {
|
||||
delay = f.get();
|
||||
} catch (CancellationException cx) {
|
||||
return null;
|
||||
} catch (InterruptedException cx) {
|
||||
return null;
|
||||
} catch (ExecutionException ex) {
|
||||
Log.severe("Exception while fetching chunks: ", ex.getCause());
|
||||
return null;
|
||||
} catch (Exception ix) {
|
||||
Log.severe(ix);
|
||||
return null;
|
||||
}
|
||||
if((delay != null) && delay.booleanValue()) {
|
||||
try { Thread.sleep(25); } catch (InterruptedException ix) {}
|
||||
}
|
||||
}
|
||||
/* If cancelled due to world unload return nothing */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue