mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-12-22 17:27:38 +00:00
Simplify command dispatch to ensure command order (#2131)
This commit is contained in:
parent
5cd9616507
commit
86acb1c4d4
@ -678,31 +678,26 @@ public final class PlatformCommandManager {
|
|||||||
|
|
||||||
Actor actor = event.getActor();
|
Actor actor = event.getActor();
|
||||||
String args = event.getArguments();
|
String args = event.getArguments();
|
||||||
TaskManager.taskManager().taskNow(() -> {
|
int space0 = args.indexOf(' ');
|
||||||
if (!Fawe.isMainThread()) {
|
String arg0 = space0 == -1 ? args : args.substring(0, space0);
|
||||||
Thread.currentThread().setName("FAWE Thread for player: " + actor.getName());
|
Optional<Command> optional = commandManager.getCommand(arg0);
|
||||||
|
if (optional.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Command cmd = optional.get();
|
||||||
|
PermissionCondition queued = cmd.getCondition().as(PermissionCondition.class).orElse(null);
|
||||||
|
if (queued != null && !queued.isQueued()) {
|
||||||
|
TaskManager.taskManager().taskNow(() -> handleCommandOnCurrentThread(event), Fawe.isMainThread());
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
actor.decline();
|
||||||
|
}
|
||||||
|
actor.runAction(() -> {
|
||||||
|
SessionKey key = actor.getSessionKey();
|
||||||
|
if (key.isActive()) {
|
||||||
|
PlatformCommandManager.this.handleCommandOnCurrentThread(event);
|
||||||
}
|
}
|
||||||
int space0 = args.indexOf(' ');
|
}, false, true);
|
||||||
String arg0 = space0 == -1 ? args : args.substring(0, space0);
|
|
||||||
Optional<Command> optional = commandManager.getCommand(arg0);
|
|
||||||
if (!optional.isPresent()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Command cmd = optional.get();
|
|
||||||
PermissionCondition queued = cmd.getCondition().as(PermissionCondition.class).orElse(null);
|
|
||||||
if (queued != null && !queued.isQueued()) {
|
|
||||||
handleCommandOnCurrentThread(event);
|
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
actor.decline();
|
|
||||||
}
|
|
||||||
actor.runAction(() -> {
|
|
||||||
SessionKey key = actor.getSessionKey();
|
|
||||||
if (key.isActive()) {
|
|
||||||
PlatformCommandManager.this.handleCommandOnCurrentThread(event);
|
|
||||||
}
|
|
||||||
}, false, true);
|
|
||||||
}, Fawe.isMainThread());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handleCommandOnCurrentThread(CommandEvent event) {
|
public void handleCommandOnCurrentThread(CommandEvent event) {
|
||||||
|
Loading…
Reference in New Issue
Block a user