Fixed: blockbreak in threaded mode requires cached value...
This commit is contained in:
parent
bd83e5b7cd
commit
9061e18db9
4 changed files with 17 additions and 8 deletions
|
@ -90,9 +90,10 @@ public class ModBlockStates extends CoreModule<LimitedCreative> {
|
|||
}
|
||||
@Override
|
||||
public void onDisable() {
|
||||
model.onDisable();
|
||||
if (model != null)
|
||||
model.onDisable();
|
||||
super.onDisable();
|
||||
if (model instanceof Listener)
|
||||
if (model != null && model instanceof Listener)
|
||||
listeners.removeListener((Listener) model);
|
||||
model = null;
|
||||
}
|
||||
|
|
|
@ -132,11 +132,6 @@ public class ThreadedModel extends AbstractModel implements DBModel, Listener {
|
|||
}
|
||||
@Override
|
||||
public boolean isRestricted(Block block) {
|
||||
HasBlockState has = getMetaBlock(block);
|
||||
if (!has.set) {
|
||||
BlockState state = threads.callUpdate(block);
|
||||
return state != null ? state.isRestricted() : false;
|
||||
}
|
||||
return getMetaBlock(block).restricted;
|
||||
}
|
||||
|
||||
|
|
|
@ -19,6 +19,9 @@ import de.jaschastarke.minecraft.limitedcreative.blockstate.ThreadedModel;
|
|||
|
||||
public class ThreadLink {
|
||||
private static final int BATCH_ACTION_LENGTH = 10;
|
||||
private static final int QUEUE_ACCESS_WARNING_DURATION = 5;
|
||||
private static final int COUNT_WARNING_QUEUE = 5;
|
||||
private static final int COUNT_ERROR_QUEUE = 20;
|
||||
private Stack<Action> updateQueue = new Stack<Action>();
|
||||
|
||||
private boolean shutdown = false;
|
||||
|
@ -59,6 +62,11 @@ public class ThreadLink {
|
|||
synchronized (updateQueue) {
|
||||
while (updateQueue.isEmpty() && !shutdown)
|
||||
updateQueue.wait();
|
||||
if (updateQueue.size() > (BATCH_ACTION_LENGTH * COUNT_ERROR_QUEUE)) {
|
||||
getLog().severe("Extrem large DB-Queue in " + Thread.currentThread().getName() + ": " + updateQueue.size());
|
||||
} else if (updateQueue.size() > (BATCH_ACTION_LENGTH * COUNT_WARNING_QUEUE)) {
|
||||
getLog().warn("Large DB-Queue in " + Thread.currentThread().getName() + ": " + updateQueue.size());
|
||||
}
|
||||
for (int i = 0; i < BATCH_ACTION_LENGTH && !updateQueue.isEmpty(); i++) {
|
||||
acts.add(updateQueue.pop());
|
||||
}
|
||||
|
@ -95,10 +103,15 @@ public class ThreadLink {
|
|||
|
||||
|
||||
public void queueUpdate(Block block) {
|
||||
long l = System.currentTimeMillis();
|
||||
synchronized (updateQueue) {
|
||||
updateQueue.add(new UpdateBlockStateAction(block));
|
||||
updateQueue.notify();
|
||||
}
|
||||
long l2 = System.currentTimeMillis();
|
||||
if (l2 - l > QUEUE_ACCESS_WARNING_DURATION) {
|
||||
getLog().warn("queueUpdate-action took to long: " + (l - 2) + "ms");
|
||||
}
|
||||
}
|
||||
|
||||
public BlockState callUpdate(Block block) {
|
||||
|
|
|
@ -170,7 +170,7 @@ public class CustomRegionManager {
|
|||
|
||||
public String getRegionsHash(Location loc) {
|
||||
StringBuilder hash = new StringBuilder(loc.getWorld().getName());
|
||||
List<String> idlist = getWGGlobalManager().get(loc.getWorld()).getApplicableRegionsIDs(BukkitUtil.toVector(loc));
|
||||
List<String> idlist = getWGManager(loc.getWorld()).getApplicableRegionsIDs(BukkitUtil.toVector(loc));
|
||||
if (idlist.size() > 0) {
|
||||
hash.append("#");
|
||||
String[] ids = idlist.toArray(new String[idlist.size()]);
|
||||
|
|
Loading…
Reference in a new issue