mirror of
https://github.com/lucko/LuckPerms.git
synced 2025-09-09 22:00:40 +02:00
Implement jar-in-jar loader system (#2899)
This fixes an issue that prevented LuckPerms from loading on Java 16
This commit is contained in:
@@ -63,13 +63,3 @@ shadowJar {
|
||||
artifacts {
|
||||
archives shadowJar
|
||||
}
|
||||
|
||||
// Only used occasionally for deployment - not needed for normal builds.
|
||||
/*
|
||||
apply plugin: 'signing'
|
||||
|
||||
signing {
|
||||
useGpgCmd()
|
||||
sign configurations.archives
|
||||
}
|
||||
*/
|
||||
|
@@ -27,9 +27,9 @@ package me.lucko.luckperms.sponge;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
|
||||
import me.lucko.luckperms.common.dependencies.classloader.PluginClassLoader;
|
||||
import me.lucko.luckperms.common.dependencies.classloader.ReflectionClassLoader;
|
||||
import me.lucko.luckperms.common.plugin.bootstrap.LuckPermsBootstrap;
|
||||
import me.lucko.luckperms.common.plugin.classpath.ClassPathAppender;
|
||||
import me.lucko.luckperms.common.plugin.classpath.ReflectionClassPathAppender;
|
||||
import me.lucko.luckperms.common.plugin.logging.PluginLogger;
|
||||
import me.lucko.luckperms.common.plugin.logging.Slf4jPluginLogger;
|
||||
import me.lucko.luckperms.common.plugin.scheduler.SchedulerAdapter;
|
||||
@@ -56,7 +56,6 @@ import org.spongepowered.api.scheduler.SpongeExecutorService;
|
||||
import org.spongepowered.api.scheduler.SynchronousExecutor;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.file.Path;
|
||||
import java.time.Instant;
|
||||
import java.util.ArrayList;
|
||||
@@ -95,9 +94,9 @@ public class LPSpongeBootstrap implements LuckPermsBootstrap {
|
||||
private final SchedulerAdapter schedulerAdapter;
|
||||
|
||||
/**
|
||||
* The plugin classloader
|
||||
* The plugin class path appender
|
||||
*/
|
||||
private final PluginClassLoader classLoader;
|
||||
private final ClassPathAppender classPathAppender;
|
||||
|
||||
/**
|
||||
* The plugin instance
|
||||
@@ -142,7 +141,7 @@ public class LPSpongeBootstrap implements LuckPermsBootstrap {
|
||||
this.logger = new Slf4jPluginLogger(logger);
|
||||
this.spongeScheduler = Sponge.getScheduler();
|
||||
this.schedulerAdapter = new SpongeSchedulerAdapter(this, this.spongeScheduler, syncExecutor, asyncExecutor);
|
||||
this.classLoader = new ReflectionClassLoader(this);
|
||||
this.classPathAppender = new ReflectionClassPathAppender(this);
|
||||
this.plugin = new LPSpongePlugin(this);
|
||||
}
|
||||
|
||||
@@ -159,8 +158,8 @@ public class LPSpongeBootstrap implements LuckPermsBootstrap {
|
||||
}
|
||||
|
||||
@Override
|
||||
public PluginClassLoader getPluginClassLoader() {
|
||||
return this.classLoader;
|
||||
public ClassPathAppender getClassPathAppender() {
|
||||
return this.classPathAppender;
|
||||
}
|
||||
|
||||
// lifecycle
|
||||
@@ -266,11 +265,6 @@ public class LPSpongeBootstrap implements LuckPermsBootstrap {
|
||||
return this.configDirectory.toAbsolutePath();
|
||||
}
|
||||
|
||||
@Override
|
||||
public InputStream getResourceStream(String path) {
|
||||
return getClass().getClassLoader().getResourceAsStream(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<Player> getPlayer(UUID uniqueId) {
|
||||
return getServer().flatMap(s -> s.getPlayer(uniqueId));
|
||||
|
@@ -41,7 +41,6 @@ import me.lucko.luckperms.common.sender.DummySender;
|
||||
import me.lucko.luckperms.common.sender.Sender;
|
||||
import me.lucko.luckperms.common.tasks.CacheHousekeepingTask;
|
||||
import me.lucko.luckperms.common.tasks.ExpireTemporaryTask;
|
||||
import me.lucko.luckperms.common.util.MoreFiles;
|
||||
import me.lucko.luckperms.sponge.calculator.SpongeCalculatorFactory;
|
||||
import me.lucko.luckperms.sponge.commands.SpongeParentCommand;
|
||||
import me.lucko.luckperms.sponge.context.SpongeContextManager;
|
||||
@@ -67,10 +66,6 @@ import net.luckperms.api.query.QueryOptions;
|
||||
import org.spongepowered.api.service.permission.PermissionDescription;
|
||||
import org.spongepowered.api.service.permission.PermissionService;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@@ -123,7 +118,7 @@ public class LPSpongePlugin extends AbstractLuckPermsPlugin {
|
||||
|
||||
@Override
|
||||
protected ConfigurationAdapter provideConfigurationAdapter() {
|
||||
return new SpongeConfigAdapter(this, resolveConfig());
|
||||
return new SpongeConfigAdapter(this, resolveConfig("luckperms.conf"));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -236,22 +231,6 @@ public class LPSpongePlugin extends AbstractLuckPermsPlugin {
|
||||
this.service.invalidateAllCaches();
|
||||
}
|
||||
|
||||
private Path resolveConfig() {
|
||||
Path path = this.bootstrap.getConfigDirectory().resolve("luckperms.conf");
|
||||
if (!Files.exists(path)) {
|
||||
try {
|
||||
MoreFiles.createDirectoriesIfNotExists(this.bootstrap.getConfigDirectory());
|
||||
try (InputStream is = getClass().getClassLoader().getResourceAsStream("luckperms.conf")) {
|
||||
Files.copy(is, path);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<QueryOptions> getQueryOptionsForUser(User user) {
|
||||
return this.bootstrap.getPlayer(user.getUniqueId()).map(player -> this.contextManager.getQueryOptions(player));
|
||||
@@ -273,7 +252,7 @@ public class LPSpongePlugin extends AbstractLuckPermsPlugin {
|
||||
return new DummySender(this, Sender.CONSOLE_UUID, Sender.CONSOLE_NAME) {
|
||||
@Override
|
||||
public void sendMessage(Component message) {
|
||||
LPSpongePlugin.this.bootstrap.getPluginLogger().info(LegacyComponentSerializer.legacySection().serialize(TranslationManager.render(message)));
|
||||
LPSpongePlugin.this.getLogger().info(LegacyComponentSerializer.legacySection().serialize(TranslationManager.render(message)));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
Reference in New Issue
Block a user