Fix command queuing from console
This commit is contained in:
parent
cf27decdb4
commit
7eb83c000b
@ -269,21 +269,18 @@ public abstract class FawePlayer<T> extends Metadatable {
|
|||||||
|
|
||||||
// Queue for async tasks
|
// Queue for async tasks
|
||||||
private AtomicInteger runningCount = new AtomicInteger();
|
private AtomicInteger runningCount = new AtomicInteger();
|
||||||
private SimpleAsyncNotifyQueue asyncNotifyQueue = new SimpleAsyncNotifyQueue(new Thread.UncaughtExceptionHandler() {
|
private SimpleAsyncNotifyQueue asyncNotifyQueue = new SimpleAsyncNotifyQueue((t, e) -> {
|
||||||
@Override
|
while (e.getCause() != null) {
|
||||||
public void uncaughtException(Thread t, Throwable e) {
|
e = e.getCause();
|
||||||
while (e.getCause() != null) {
|
}
|
||||||
e = e.getCause();
|
if (e instanceof WorldEditException) {
|
||||||
}
|
sendMessage(BBC.getPrefix() + e.getLocalizedMessage());
|
||||||
if (e instanceof WorldEditException) {
|
} else {
|
||||||
sendMessage(BBC.getPrefix() + e.getLocalizedMessage());
|
FaweException fe = FaweException.get(e);
|
||||||
|
if (fe != null) {
|
||||||
|
sendMessage(fe.getMessage());
|
||||||
} else {
|
} else {
|
||||||
FaweException fe = FaweException.get(e);
|
e.printStackTrace();
|
||||||
if (fe != null) {
|
|
||||||
sendMessage(fe.getMessage());
|
|
||||||
} else {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -4,9 +4,9 @@ import com.boydti.fawe.util.TaskManager;
|
|||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
|
||||||
public abstract class AsyncNotifyQueue {
|
public abstract class AsyncNotifyQueue {
|
||||||
private Object lock = new Object();
|
protected Object lock = new Object();
|
||||||
private final Runnable task;
|
protected final Runnable task;
|
||||||
private final AtomicBoolean running = new AtomicBoolean();
|
protected final AtomicBoolean running = new AtomicBoolean();
|
||||||
|
|
||||||
public AsyncNotifyQueue() {
|
public AsyncNotifyQueue() {
|
||||||
this.task = new Runnable() {
|
this.task = new Runnable() {
|
||||||
@ -25,7 +25,7 @@ public abstract class AsyncNotifyQueue {
|
|||||||
|
|
||||||
public void queue(Runnable queueTask) {
|
public void queue(Runnable queueTask) {
|
||||||
synchronized (lock) {
|
synchronized (lock) {
|
||||||
queueTask.run();
|
if (queueTask != null) queueTask.run();
|
||||||
if (!running.get()) {
|
if (!running.get()) {
|
||||||
running.set(true);
|
running.set(true);
|
||||||
TaskManager.IMP.async(task);
|
TaskManager.IMP.async(task);
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package com.boydti.fawe.object.task;
|
package com.boydti.fawe.object.task;
|
||||||
|
|
||||||
|
import com.boydti.fawe.util.TaskManager;
|
||||||
|
|
||||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||||
|
|
||||||
public class SimpleAsyncNotifyQueue extends AsyncNotifyQueue {
|
public class SimpleAsyncNotifyQueue extends AsyncNotifyQueue {
|
||||||
@ -27,6 +29,16 @@ public class SimpleAsyncNotifyQueue extends AsyncNotifyQueue {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void queue(Runnable queueTask) {
|
||||||
|
synchronized (lock) {
|
||||||
|
if (queueTask != null) tasks.add(queueTask);
|
||||||
|
if (!running.get()) {
|
||||||
|
running.set(true);
|
||||||
|
TaskManager.IMP.async(task);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public int getSize() {
|
public int getSize() {
|
||||||
return tasks.size();
|
return tasks.size();
|
||||||
}
|
}
|
||||||
|
@ -467,7 +467,7 @@ public final class CommandManager {
|
|||||||
public void run() {
|
public void run() {
|
||||||
handleCommandOnCurrentThread(finalEvent);
|
handleCommandOnCurrentThread(finalEvent);
|
||||||
}
|
}
|
||||||
}, true, false)) {
|
}, false, true)) {
|
||||||
BBC.WORLDEDIT_COMMAND_LIMIT.send(fp);
|
BBC.WORLDEDIT_COMMAND_LIMIT.send(fp);
|
||||||
}
|
}
|
||||||
finalEvent.setCancelled(true);
|
finalEvent.setCancelled(true);
|
||||||
|
Loading…
Reference in New Issue
Block a user