3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-12-26 08:10:09 +01:00

Only print reload info when needed, add additional log message after shutdown

Thanks to its name and dependency order, ViaVersion will generally be the last plugin to be disabled and has occasionally been blamed for other plugins stalling server shutdown
Dieser Commit ist enthalten in:
Nassim Jahnke 2024-08-03 20:35:22 +02:00
Ursprung 040f85659d
Commit 462a10363c
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: EF6771C01F6EF02F
6 geänderte Dateien mit 40 neuen und 2 gelöschten Zeilen

Datei anzeigen

@ -215,4 +215,13 @@ public interface ViaPlatform<T> {
* @return whether the platform has a plugin/mod with the given name * @return whether the platform has a plugin/mod with the given name
*/ */
boolean hasPlugin(String name); boolean hasPlugin(String name);
/**
* Returns whether the platform might be reloading.
*
* @return whether the platform might be reloading
*/
default boolean couldBeReloading() {
return true;
}
} }

Datei anzeigen

@ -30,4 +30,9 @@ public interface ViaServerProxyPlatform<T> extends ViaPlatform<T> {
* @return protocol detector service * @return protocol detector service
*/ */
ProtocolDetectorService protocolDetectorService(); ProtocolDetectorService protocolDetectorService();
@Override
default boolean couldBeReloading() {
return false;
}
} }

Datei anzeigen

@ -268,6 +268,11 @@ public class ViaVersionPlugin extends JavaPlugin implements ViaPlatform<Player>
return getServer().getPluginManager().getPlugin(name) != null; return getServer().getPluginManager().getPlugin(name) != null;
} }
@Override
public boolean couldBeReloading() {
return !(PaperViaInjector.PAPER_IS_STOPPING_METHOD && Bukkit.isStopping());
}
public boolean isLateBind() { public boolean isLateBind() {
return lateBind; return lateBind;
} }

Datei anzeigen

@ -28,6 +28,7 @@ public final class PaperViaInjector {
public static final boolean PAPER_INJECTION_METHOD = hasPaperInjectionMethod(); public static final boolean PAPER_INJECTION_METHOD = hasPaperInjectionMethod();
public static final boolean PAPER_PROTOCOL_METHOD = hasServerProtocolMethod(); public static final boolean PAPER_PROTOCOL_METHOD = hasServerProtocolMethod();
public static final boolean PAPER_PACKET_LIMITER = hasPacketLimiter(); public static final boolean PAPER_PACKET_LIMITER = hasPacketLimiter();
public static final boolean PAPER_IS_STOPPING_METHOD = hasIsStoppingMethod();
private PaperViaInjector() { private PaperViaInjector() {
} }
@ -76,6 +77,15 @@ public final class PaperViaInjector {
return hasClass("io.papermc.paper.network.ChannelInitializeListener"); return hasClass("io.papermc.paper.network.ChannelInitializeListener");
} }
private static boolean hasIsStoppingMethod() {
try {
Bukkit.class.getDeclaredMethod("isStopping");
return true;
} catch (final NoSuchMethodException e) {
return false;
}
}
private static boolean hasPacketLimiter() { private static boolean hasPacketLimiter() {
return hasClass("com.destroystokyo.paper.PaperConfig$PacketLimit") || hasClass("io.papermc.paper.configuration.GlobalConfiguration$PacketLimiter"); return hasClass("com.destroystokyo.paper.PaperConfig$PacketLimit") || hasClass("io.papermc.paper.configuration.GlobalConfiguration$PacketLimiter");
} }

Datei anzeigen

@ -210,8 +210,10 @@ public class ViaManagerImpl implements ViaManager {
} }
public void destroy() { public void destroy() {
// Uninject if (platform.couldBeReloading()) {
platform.getLogger().info("ViaVersion is disabling, if this is a reload and you experience issues consider rebooting."); platform.getLogger().info("ViaVersion is disabling. If this is a reload and you experience issues, please reboot instead.");
}
try { try {
injector.uninject(); injector.uninject();
} catch (Exception e) { } catch (Exception e) {
@ -220,6 +222,8 @@ public class ViaManagerImpl implements ViaManager {
loader.unload(); loader.unload();
scheduler.shutdown(); scheduler.shutdown();
platform.getLogger().info("ViaVersion has been disabled; uninjected the platform shut down the scheduler.");
} }
private void checkJavaVersion() { // Stolen from Paper private void checkJavaVersion() { // Stolen from Paper

Datei anzeigen

@ -136,4 +136,9 @@ public final class TestPlatform implements ViaPlatform {
public boolean hasPlugin(final String name) { public boolean hasPlugin(final String name) {
return false; return false;
} }
@Override
public boolean couldBeReloading() {
return false;
}
} }