geforkt von Mirrors/Velocity
Fire ProxyShutdownEvent _after_ the event manager thread pool shuts down
Fixes #177
Dieser Commit ist enthalten in:
Ursprung
5ccf22c5c4
Commit
fa9d5f6499
@ -356,7 +356,6 @@ public class VelocityServer implements ProxyServer {
|
|||||||
|
|
||||||
this.cm.shutdown();
|
this.cm.shutdown();
|
||||||
|
|
||||||
eventManager.fire(new ProxyShutdownEvent());
|
|
||||||
try {
|
try {
|
||||||
if (!eventManager.shutdown() || !scheduler.shutdown()) {
|
if (!eventManager.shutdown() || !scheduler.shutdown()) {
|
||||||
logger.error("Your plugins took over 10 seconds to shut down.");
|
logger.error("Your plugins took over 10 seconds to shut down.");
|
||||||
@ -366,6 +365,8 @@ public class VelocityServer implements ProxyServer {
|
|||||||
Thread.currentThread().interrupt();
|
Thread.currentThread().interrupt();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
eventManager.fireShutdownEvent();
|
||||||
|
|
||||||
shutdown = true;
|
shutdown = true;
|
||||||
|
|
||||||
if (explicitExit) {
|
if (explicitExit) {
|
||||||
|
@ -8,6 +8,7 @@ import com.velocitypowered.api.event.EventHandler;
|
|||||||
import com.velocitypowered.api.event.EventManager;
|
import com.velocitypowered.api.event.EventManager;
|
||||||
import com.velocitypowered.api.event.PostOrder;
|
import com.velocitypowered.api.event.PostOrder;
|
||||||
import com.velocitypowered.api.event.Subscribe;
|
import com.velocitypowered.api.event.Subscribe;
|
||||||
|
import com.velocitypowered.api.event.proxy.ProxyShutdownEvent;
|
||||||
import com.velocitypowered.api.plugin.PluginManager;
|
import com.velocitypowered.api.plugin.PluginManager;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
@ -121,6 +122,13 @@ public class VelocityEventManager implements EventManager {
|
|||||||
|
|
||||||
CompletableFuture<E> eventFuture = new CompletableFuture<>();
|
CompletableFuture<E> eventFuture = new CompletableFuture<>();
|
||||||
service.execute(() -> {
|
service.execute(() -> {
|
||||||
|
fireEvent(event);
|
||||||
|
eventFuture.complete(event);
|
||||||
|
});
|
||||||
|
return eventFuture;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void fireEvent(Object event) {
|
||||||
PostResult result = bus.post(event);
|
PostResult result = bus.post(event);
|
||||||
if (!result.exceptions().isEmpty()) {
|
if (!result.exceptions().isEmpty()) {
|
||||||
logger.error("Some errors occurred whilst posting event {}.", event);
|
logger.error("Some errors occurred whilst posting event {}.", event);
|
||||||
@ -129,9 +137,6 @@ public class VelocityEventManager implements EventManager {
|
|||||||
logger.error("#{}: \n", ++i, exception);
|
logger.error("#{}: \n", ++i, exception);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
eventFuture.complete(event);
|
|
||||||
});
|
|
||||||
return eventFuture;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void unregisterHandler(EventHandler<?> handler) {
|
private void unregisterHandler(EventHandler<?> handler) {
|
||||||
@ -169,6 +174,11 @@ public class VelocityEventManager implements EventManager {
|
|||||||
return service.awaitTermination(10, TimeUnit.SECONDS);
|
return service.awaitTermination(10, TimeUnit.SECONDS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void fireShutdownEvent() {
|
||||||
|
// We shut down the proxy already, so the fact this executes in the main thread is irrelevant.
|
||||||
|
fireEvent(new ProxyShutdownEvent());
|
||||||
|
}
|
||||||
|
|
||||||
private static class VelocityMethodScanner implements MethodScanner<Object> {
|
private static class VelocityMethodScanner implements MethodScanner<Object> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren