mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-12-23 01:37:37 +00:00
Correctly queue edits
Synchronising on the LocalSession ends up being dangerous as it's a craftbukkit thread, leading to blocking issues if something goes wrong in an edit, made worse by the fact craftbukkit threads like to interfere with each other sometimes, and also cause OOMs and hanging when there are too many of them.
This commit is contained in:
parent
a64a1ab09e
commit
2c27b9c02a
@ -79,8 +79,8 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
|
|||||||
private final Map<String, Object> meta;
|
private final Map<String, Object> meta;
|
||||||
|
|
||||||
// Queue for async tasks
|
// Queue for async tasks
|
||||||
private AtomicInteger runningCount = new AtomicInteger();
|
private final AtomicInteger runningCount = new AtomicInteger();
|
||||||
private AsyncNotifyQueue asyncNotifyQueue = new AsyncNotifyQueue(
|
private final AsyncNotifyQueue asyncNotifyQueue = new AsyncNotifyQueue(
|
||||||
(thread, throwable) -> {
|
(thread, throwable) -> {
|
||||||
while (throwable.getCause() != null) {
|
while (throwable.getCause() != null) {
|
||||||
throwable = throwable.getCause();
|
throwable = throwable.getCause();
|
||||||
|
@ -189,11 +189,11 @@ public interface Actor extends Identifiable, SessionOwner, Subject, MapMetadatab
|
|||||||
*/
|
*/
|
||||||
default boolean confirm() {
|
default boolean confirm() {
|
||||||
InterruptableCondition confirm = deleteMeta("cmdConfirm");
|
InterruptableCondition confirm = deleteMeta("cmdConfirm");
|
||||||
if (confirm != null) {
|
if (confirm == null) {
|
||||||
confirm.signal();;
|
return false;
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
return false;
|
queueAction(confirm::signal);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -649,13 +649,12 @@ public final class PlatformCommandManager {
|
|||||||
} else {
|
} else {
|
||||||
actor.decline();
|
actor.decline();
|
||||||
}
|
}
|
||||||
LocalSession session = worldEdit.getSessionManager().get(actor);
|
actor.runAction(() -> {
|
||||||
synchronized (session) {
|
|
||||||
SessionKey key = actor.getSessionKey();
|
SessionKey key = actor.getSessionKey();
|
||||||
if (key.isActive()) {
|
if (key.isActive()) {
|
||||||
PlatformCommandManager.this.handleCommandOnCurrentThread(event);
|
PlatformCommandManager.this.handleCommandOnCurrentThread(event);
|
||||||
}
|
}
|
||||||
}
|
}, false, true);
|
||||||
}, Fawe.isMainThread());
|
}, Fawe.isMainThread());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -437,7 +437,7 @@ public class PlatformManager {
|
|||||||
Tool tool = session.getTool(player);
|
Tool tool = session.getTool(player);
|
||||||
if (tool instanceof DoubleActionTraceTool && tool.canUse(player)) {
|
if (tool instanceof DoubleActionTraceTool && tool.canUse(player)) {
|
||||||
player.runAsyncIfFree(() -> reset((DoubleActionTraceTool) tool).actSecondary(queryCapability(Capability.WORLD_EDITING),
|
player.runAsyncIfFree(() -> reset((DoubleActionTraceTool) tool).actSecondary(queryCapability(Capability.WORLD_EDITING),
|
||||||
getConfiguration(), player, session));
|
getConfiguration(), player, session));
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -450,7 +450,7 @@ public class PlatformManager {
|
|||||||
if (tool instanceof TraceTool && tool.canUse(player)) {
|
if (tool instanceof TraceTool && tool.canUse(player)) {
|
||||||
//todo this needs to be fixed so the event is canceled after actPrimary is used and returns true
|
//todo this needs to be fixed so the event is canceled after actPrimary is used and returns true
|
||||||
player.runAction(() -> reset((TraceTool) tool).actPrimary(queryCapability(Capability.WORLD_EDITING),
|
player.runAction(() -> reset((TraceTool) tool).actPrimary(queryCapability(Capability.WORLD_EDITING),
|
||||||
getConfiguration(), player, session), false, true);
|
getConfiguration(), player, session), false, true);
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user