mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-26 10:01:36 +01:00
Don't crash the server if Mixin can't be loaded due to identical file names inside the JAR file.
But please spam the console.
This commit is contained in:
parent
9b9565dbbd
commit
2b5d67a3ca
@ -7,6 +7,7 @@ import net.minestom.server.extras.selfmodification.mixins.MixinServiceMinestom;
|
|||||||
import org.spongepowered.asm.launch.MixinBootstrap;
|
import org.spongepowered.asm.launch.MixinBootstrap;
|
||||||
import org.spongepowered.asm.launch.platform.CommandLineOptions;
|
import org.spongepowered.asm.launch.platform.CommandLineOptions;
|
||||||
import org.spongepowered.asm.mixin.Mixins;
|
import org.spongepowered.asm.mixin.Mixins;
|
||||||
|
import org.spongepowered.asm.service.ServiceNotAvailableError;
|
||||||
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
@ -21,7 +22,12 @@ public final class Bootstrap {
|
|||||||
try {
|
try {
|
||||||
ClassLoader classLoader = MinestomRootClassLoader.getInstance();
|
ClassLoader classLoader = MinestomRootClassLoader.getInstance();
|
||||||
startMixin(args);
|
startMixin(args);
|
||||||
MinestomRootClassLoader.getInstance().addCodeModifier(new MixinCodeModifier());
|
try {
|
||||||
|
MinestomRootClassLoader.getInstance().addCodeModifier(new MixinCodeModifier());
|
||||||
|
} catch (RuntimeException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
System.err.println("Failed to add MixinCodeModifier, mixins will not be injected. Check the log entries above to debug.");
|
||||||
|
}
|
||||||
|
|
||||||
ExtensionManager.loadCodeModifiersEarly();
|
ExtensionManager.loadCodeModifiersEarly();
|
||||||
|
|
||||||
@ -47,7 +53,16 @@ public final class Bootstrap {
|
|||||||
// hacks required to pass custom arguments
|
// hacks required to pass custom arguments
|
||||||
Method start = MixinBootstrap.class.getDeclaredMethod("start");
|
Method start = MixinBootstrap.class.getDeclaredMethod("start");
|
||||||
start.setAccessible(true);
|
start.setAccessible(true);
|
||||||
if (!((boolean) start.invoke(null))) {
|
try {
|
||||||
|
if (!((boolean) start.invoke(null))) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} catch (ServiceNotAvailableError e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
System.err.println("Failed to load Mixin, see error above.");
|
||||||
|
System.err.println("It is possible you simply have two files with identical names inside your server jar. " +
|
||||||
|
"Check your META-INF/services directory inside your Minestom implementation and merge files with identical names inside META-INF/services.");
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,6 +13,7 @@ import org.jetbrains.annotations.Nullable;
|
|||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.spongepowered.asm.mixin.Mixins;
|
import org.spongepowered.asm.mixin.Mixins;
|
||||||
|
import org.spongepowered.asm.service.ServiceNotAvailableError;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.lang.reflect.Constructor;
|
import java.lang.reflect.Constructor;
|
||||||
@ -499,8 +500,13 @@ public class ExtensionManager {
|
|||||||
}
|
}
|
||||||
if (!extension.getMixinConfig().isEmpty()) {
|
if (!extension.getMixinConfig().isEmpty()) {
|
||||||
final String mixinConfigFile = extension.getMixinConfig();
|
final String mixinConfigFile = extension.getMixinConfig();
|
||||||
Mixins.addConfiguration(mixinConfigFile);
|
try {
|
||||||
LOGGER.info("Found mixin in extension {}: {}", extension.getName(), mixinConfigFile);
|
Mixins.addConfiguration(mixinConfigFile);
|
||||||
|
LOGGER.info("Found mixin in extension {}: {}", extension.getName(), mixinConfigFile);
|
||||||
|
} catch (ServiceNotAvailableError e) {
|
||||||
|
MinecraftServer.getExceptionManager().handleException(e);
|
||||||
|
LOGGER.error("Could not load Mixin configuration: "+mixinConfigFile);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
MinecraftServer.getExceptionManager().handleException(e);
|
MinecraftServer.getExceptionManager().handleException(e);
|
||||||
|
Loading…
Reference in New Issue
Block a user