Properly handle reloads on Spigot.
The code is getting uglier and uglier ...
Dieser Commit ist enthalten in:
Ursprung
a4f81e5e9f
Commit
47a5382709
@ -22,6 +22,7 @@ import java.lang.reflect.Method;
|
|||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.concurrent.Callable;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
@ -272,38 +273,57 @@ public final class PacketFilterManager implements ProtocolManager, ListenerInvok
|
|||||||
delayed.setAsynchronousManager(asyncManager);
|
delayed.setAsynchronousManager(asyncManager);
|
||||||
asyncManager.setManager(delayed);
|
asyncManager.setManager(delayed);
|
||||||
|
|
||||||
Futures.addCallback(BukkitFutures.nextEvent(library, WorldInitEvent.class), new FutureCallback<WorldInitEvent>() {
|
final Callable<Object> registerSpigot = new Callable<Object>() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(WorldInitEvent event) {
|
public Object call() throws Exception {
|
||||||
// Nevermind
|
// Now we are probably able to check for Netty
|
||||||
if (delayed.isClosed())
|
InjectedServerConnection inspector = new InjectedServerConnection(reporter, null, server, null);
|
||||||
return;
|
Object connection = inspector.getServerConnection();
|
||||||
|
|
||||||
try {
|
// Use netty if we have a non-standard ServerConnection class
|
||||||
// Now we are probably able to check for Netty
|
boolean useNetty = !MinecraftReflection.isMinecraftObject(connection);
|
||||||
InjectedServerConnection inspector = new InjectedServerConnection(reporter, null, server, null);
|
|
||||||
Object connection = inspector.getServerConnection();
|
|
||||||
|
|
||||||
// Use netty if we have a non-standard ServerConnection class
|
// Switch to the standard manager
|
||||||
boolean useNetty = !MinecraftReflection.isMinecraftObject(connection);
|
delayed.setDelegate(new PacketFilterManager(
|
||||||
|
classLoader, server, library, asyncManager, mcVersion, unhookTask, reporter, useNetty)
|
||||||
|
);
|
||||||
|
|
||||||
// Switch to the standard manager
|
// Reference this manager directly
|
||||||
delayed.setDelegate(new PacketFilterManager(
|
asyncManager.setManager(delayed.getDelegate());
|
||||||
classLoader, server, library, asyncManager, mcVersion, unhookTask, reporter, useNetty)
|
return null;
|
||||||
);
|
}
|
||||||
// Reference this manager directly
|
};
|
||||||
asyncManager.setManager(delayed.getDelegate());
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
// If the server hasn't loaded yet - wait
|
||||||
onFailure(e);
|
if (server.getWorlds().size() == 0) {
|
||||||
|
Futures.addCallback(BukkitFutures.nextEvent(library, WorldInitEvent.class), new FutureCallback<WorldInitEvent>() {
|
||||||
|
@Override
|
||||||
|
public void onSuccess(WorldInitEvent event) {
|
||||||
|
// Nevermind
|
||||||
|
if (delayed.isClosed())
|
||||||
|
return;
|
||||||
|
|
||||||
|
try {
|
||||||
|
registerSpigot.call();
|
||||||
|
} catch (Exception e) {
|
||||||
|
onFailure(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(Throwable error) {
|
public void onFailure(Throwable error) {
|
||||||
reporter.reportWarning(PacketFilterManager.class, Report.newBuilder(REPORT_TEMPORARY_EVENT_ERROR).error(error));
|
reporter.reportWarning(PacketFilterManager.class, Report.newBuilder(REPORT_TEMPORARY_EVENT_ERROR).error(error));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
} else {
|
||||||
|
// Do it now
|
||||||
|
try {
|
||||||
|
registerSpigot.call();
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
|
||||||
// Let plugins use this version instead
|
// Let plugins use this version instead
|
||||||
return delayed;
|
return delayed;
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren