mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-08-16 08:15:50 +00:00
update slimjar
This commit is contained in:
parent
b0ca0e3617
commit
76a6f1465a
@ -436,7 +436,6 @@ public class Iris extends VolmitPlugin implements Listener {
|
||||
|
||||
public Iris() {
|
||||
instance = this;
|
||||
SlimJar.debug(IrisSettings.get().getSentry().isDebug());
|
||||
SlimJar.load(getDataFolder("cache", "libraries"));
|
||||
}
|
||||
|
||||
|
@ -23,7 +23,6 @@ import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.util.io.IO;
|
||||
import com.volmit.iris.util.json.JSONException;
|
||||
import com.volmit.iris.util.json.JSONObject;
|
||||
import com.volmit.iris.util.misc.SlimJar;
|
||||
import com.volmit.iris.util.misc.getHardware;
|
||||
import com.volmit.iris.util.plugin.VolmitSender;
|
||||
import lombok.AllArgsConstructor;
|
||||
@ -87,7 +86,6 @@ public class IrisSettings {
|
||||
Iris.error("Configuration Error in settings.json! " + ee.getClass().getSimpleName() + ": " + ee.getMessage());
|
||||
}
|
||||
}
|
||||
SlimJar.debug(settings.general.debug);
|
||||
|
||||
return settings;
|
||||
}
|
||||
|
@ -21,19 +21,16 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
import java.util.function.BiFunction;
|
||||
import java.util.function.Function;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class SlimJar {
|
||||
private static final String NAME = "Iris";
|
||||
private static final Logger LOGGER = Logger.getLogger(NAME);
|
||||
private static final ReentrantLock lock = new ReentrantLock();
|
||||
private static final AtomicBoolean loaded = new AtomicBoolean();
|
||||
private static final boolean DEBUG = Boolean.getBoolean("iris.debug-slimjar");
|
||||
private static final boolean DISABLE_REMAPPER = Boolean.getBoolean("iris.disable-remapper");
|
||||
|
||||
public static void debug(boolean debug) {
|
||||
LOGGER.setLevel(debug ? Level.FINE : Level.INFO);
|
||||
}
|
||||
private static final ReentrantLock lock = new ReentrantLock();
|
||||
private static final AtomicBoolean loaded = new AtomicBoolean();
|
||||
|
||||
public static void load(@Nullable File localRepository) {
|
||||
if (loaded.get()) return;
|
||||
@ -49,7 +46,8 @@ public class SlimJar {
|
||||
load(localRepository.toPath(), new ProcessLogger() {
|
||||
@Override
|
||||
public void info(@NotNull String message, @Nullable Object... args) {
|
||||
LOGGER.fine(message.formatted(args));
|
||||
if (!DEBUG) return;
|
||||
LOGGER.info(message.formatted(args));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -59,7 +57,8 @@ public class SlimJar {
|
||||
|
||||
@Override
|
||||
public void debug(@NotNull String message, @Nullable Object... args) {
|
||||
LOGGER.fine(message.formatted(args));
|
||||
if (!DEBUG) return;
|
||||
LOGGER.info(message.formatted(args));
|
||||
}
|
||||
});
|
||||
LOGGER.info("Libraries loaded successfully!");
|
||||
@ -82,15 +81,16 @@ public class SlimJar {
|
||||
|
||||
private static void loadSpigot(Path downloadPath, ProcessLogger logger) throws Throwable {
|
||||
var current = SlimJar.class.getClassLoader();
|
||||
var libraryLoader = current.getClass().getDeclaredField("libraryLoader");
|
||||
libraryLoader.setAccessible(true);
|
||||
if (!ClassLoader.class.isAssignableFrom(libraryLoader.getType())) throw new IllegalStateException("Failed to find library loader");
|
||||
var libraryLoaderField = current.getClass().getDeclaredField("libraryLoader");
|
||||
libraryLoaderField.setAccessible(true);
|
||||
if (!ClassLoader.class.isAssignableFrom(libraryLoaderField.getType())) throw new IllegalStateException("Failed to find library loader");
|
||||
final var libraryLoader = (ClassLoader) libraryLoaderField.get(current);
|
||||
|
||||
final var pair = findRemapper();
|
||||
final var remapper = pair.getA();
|
||||
final var factory = pair.getB();
|
||||
|
||||
final var libraries = factory.apply(new URL[0], current.getParent());
|
||||
final var libraries = factory.apply(new URL[0], libraryLoader == null ? current.getParent() : libraryLoader);
|
||||
final var injecting = InjectableFactory.create(downloadPath, List.of(Repository.central()), libraries);
|
||||
|
||||
ApplicationBuilder.injecting(NAME, new Injectable() {
|
||||
@ -119,7 +119,7 @@ public class SlimJar {
|
||||
.logger(logger)
|
||||
.build();
|
||||
|
||||
libraryLoader.set(current, libraries);
|
||||
libraryLoaderField.set(current, libraries);
|
||||
}
|
||||
|
||||
private static Pair<Function<List<Path>, List<Path>>, BiFunction<URL[], ClassLoader, URLClassLoader>> findRemapper() {
|
||||
|
@ -5,7 +5,7 @@
|
||||
[versions]
|
||||
# Plugins
|
||||
shadow = "9.0.0-rc1" # https://plugins.gradle.org/plugin/com.gradleup.shadow
|
||||
slimjar = "2.0.8" # https://plugins.gradle.org/plugin/de.crazydev22.slimjar
|
||||
slimjar = "2.1.0" # https://plugins.gradle.org/plugin/de.crazydev22.slimjar
|
||||
download = "5.6.0" # https://plugins.gradle.org/plugin/de.undercouch.download
|
||||
runPaper = "2.3.1" # https://plugins.gradle.org/plugin/xyz.jpenilla.run-paper
|
||||
sentryPlugin = "5.8.0" # https://github.com/getsentry/sentry-android-gradle-plugin
|
||||
|
Loading…
x
Reference in New Issue
Block a user