Mirror von
https://github.com/PaperMC/Velocity.git
synchronisiert 2024-11-06 00:00:47 +01:00
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();
|
||||
|
||||
eventManager.fire(new ProxyShutdownEvent());
|
||||
try {
|
||||
if (!eventManager.shutdown() || !scheduler.shutdown()) {
|
||||
logger.error("Your plugins took over 10 seconds to shut down.");
|
||||
@ -366,6 +365,8 @@ public class VelocityServer implements ProxyServer {
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
|
||||
eventManager.fireShutdownEvent();
|
||||
|
||||
shutdown = true;
|
||||
|
||||
if (explicitExit) {
|
||||
|
@ -8,6 +8,7 @@ import com.velocitypowered.api.event.EventHandler;
|
||||
import com.velocitypowered.api.event.EventManager;
|
||||
import com.velocitypowered.api.event.PostOrder;
|
||||
import com.velocitypowered.api.event.Subscribe;
|
||||
import com.velocitypowered.api.event.proxy.ProxyShutdownEvent;
|
||||
import com.velocitypowered.api.plugin.PluginManager;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.URL;
|
||||
@ -121,19 +122,23 @@ public class VelocityEventManager implements EventManager {
|
||||
|
||||
CompletableFuture<E> eventFuture = new CompletableFuture<>();
|
||||
service.execute(() -> {
|
||||
PostResult result = bus.post(event);
|
||||
if (!result.exceptions().isEmpty()) {
|
||||
logger.error("Some errors occurred whilst posting event {}.", event);
|
||||
int i = 0;
|
||||
for (Throwable exception : result.exceptions().values()) {
|
||||
logger.error("#{}: \n", ++i, exception);
|
||||
}
|
||||
}
|
||||
fireEvent(event);
|
||||
eventFuture.complete(event);
|
||||
});
|
||||
return eventFuture;
|
||||
}
|
||||
|
||||
private void fireEvent(Object event) {
|
||||
PostResult result = bus.post(event);
|
||||
if (!result.exceptions().isEmpty()) {
|
||||
logger.error("Some errors occurred whilst posting event {}.", event);
|
||||
int i = 0;
|
||||
for (Throwable exception : result.exceptions().values()) {
|
||||
logger.error("#{}: \n", ++i, exception);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void unregisterHandler(EventHandler<?> handler) {
|
||||
bus.unregister(s -> s instanceof KyoriToVelocityHandler
|
||||
&& ((KyoriToVelocityHandler<?>) s).handler == handler);
|
||||
@ -169,6 +174,11 @@ public class VelocityEventManager implements EventManager {
|
||||
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> {
|
||||
|
||||
@Override
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren