Fabric platform updates (#2048)
- Increased Gradle max heap to 1 GB to avoid running out of heap space on build - Added Slimjar for runtime dependency management - Modified platform logger to parse JUL.Logger-format parameters to log4j format - Added logic to properly handle InvalidArgumentExceptions with commands - Updated loom to 0.9.+, fixes annoying console spam when building - Moved mod JSONs to fabric's resources folder to correctly add refmap key to mixins.json - Updated mappings & API Affected issues: - Fixed #2045
This commit is contained in:
parent
2b257d5373
commit
48f9a430c5
|
@ -1,5 +1,5 @@
|
|||
plugins {
|
||||
id 'fabric-loom' version '0.8-SNAPSHOT'
|
||||
id 'fabric-loom' version '0.9.+'
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
@ -10,7 +10,7 @@ dependencies {
|
|||
modImplementation('me.lucko:fabric-permissions-api:0.1-SNAPSHOT')
|
||||
|
||||
minecraft "com.mojang:minecraft:1.17.1"
|
||||
mappings "net.fabricmc:yarn:1.17.1+build.21:v2"
|
||||
mappings "net.fabricmc:yarn:1.17.1+build.35:v2"
|
||||
modImplementation "net.fabricmc:fabric-loader:0.11.6"
|
||||
|
||||
// Fabric API
|
||||
|
@ -23,16 +23,24 @@ dependencies {
|
|||
]
|
||||
|
||||
apiModules.forEach {
|
||||
modImplementation(fabricApi.module(it, "0.37.0+1.17"))
|
||||
modImplementation(fabricApi.module(it, "0.37.1+1.17"))
|
||||
}
|
||||
|
||||
testImplementation project(path: ":common", configuration: 'testArtifacts')
|
||||
|
||||
slim "mysql:mysql-connector-java:$mysqlVersion"
|
||||
slim "org.xerial:sqlite-jdbc:$sqliteVersion"
|
||||
}
|
||||
|
||||
compileJava {
|
||||
options.release = 16
|
||||
}
|
||||
|
||||
slimJar {
|
||||
relocate 'com.mysql', 'plan.com.mysql'
|
||||
relocate 'com.google.protobuf', 'plan.com.mysql.cj.x.google.protobuf'
|
||||
}
|
||||
|
||||
shadowJar {
|
||||
configurations = [project.configurations.shadow]
|
||||
exclude('net.fabricmc:*')
|
||||
|
@ -42,7 +50,6 @@ shadowJar {
|
|||
exclude 'org/apache/logging/**'
|
||||
}
|
||||
relocate 'dagger', 'plan.dagger'
|
||||
relocate 'com.mysql', 'plan.com.mysql'
|
||||
// Don't relocate SQLite since the org.sqlite.NativeDB class calls are not relocated properly
|
||||
// relocate 'org.sqlite', 'plan.org.sqlite'
|
||||
relocate 'javax.inject', 'plan.javax.inject'
|
||||
|
|
|
@ -25,19 +25,28 @@ import com.djrapitops.plan.gathering.ServerShutdownSave;
|
|||
import com.djrapitops.plan.settings.locale.Locale;
|
||||
import com.djrapitops.plan.settings.locale.lang.PluginLang;
|
||||
import com.djrapitops.plan.settings.theme.PlanColorScheme;
|
||||
import io.github.slimjar.app.builder.ApplicationBuilder;
|
||||
import io.github.slimjar.resolver.data.Repository;
|
||||
import net.fabricmc.api.DedicatedServerModInitializer;
|
||||
import net.fabricmc.fabric.api.command.v1.CommandRegistrationCallback;
|
||||
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents;
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
import net.minecraft.server.dedicated.MinecraftDedicatedServer;
|
||||
import net.playeranalytics.plan.commands.CommandManager;
|
||||
import net.playeranalytics.plan.identification.properties.FabricServerProperties;
|
||||
import net.playeranalytics.plugin.FabricPlatformLayer;
|
||||
import net.playeranalytics.plugin.PlatformAbstractionLayer;
|
||||
import net.playeranalytics.plugin.scheduling.RunnableFactory;
|
||||
import net.playeranalytics.plugin.server.PluginLogger;
|
||||
import net.playeranalytics.plugin.server.FabricPluginLogger;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URL;
|
||||
import java.nio.file.Paths;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.Collections;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.Future;
|
||||
|
@ -58,7 +67,7 @@ public class PlanFabric implements PlanPlugin, DedicatedServerModInitializer {
|
|||
private Locale locale;
|
||||
private ServerShutdownSave serverShutdownSave;
|
||||
|
||||
private PluginLogger pluginLogger;
|
||||
private FabricPluginLogger pluginLogger;
|
||||
private RunnableFactory runnableFactory;
|
||||
private PlatformAbstractionLayer abstractionLayer;
|
||||
|
||||
|
@ -85,9 +94,25 @@ public class PlanFabric implements PlanPlugin, DedicatedServerModInitializer {
|
|||
@Override
|
||||
public void onEnable() {
|
||||
abstractionLayer = new FabricPlatformLayer(this);
|
||||
pluginLogger = abstractionLayer.getPluginLogger();
|
||||
pluginLogger = (FabricPluginLogger) abstractionLayer.getPluginLogger();
|
||||
runnableFactory = abstractionLayer.getRunnableFactory();
|
||||
|
||||
pluginLogger.info("Loading dependencies, this might take a while...");
|
||||
try {
|
||||
ApplicationBuilder.appending("Plan")
|
||||
.logger((message, args) -> pluginLogger.info(message, args))
|
||||
// Use paper repository for downloading slimjar dependencies
|
||||
.internalRepositories(Collections.singletonList(new Repository(new URL("https://papermc.io/repo/repository/maven-public/"))))
|
||||
.downloadDirectoryPath(Paths.get(getDataFolder().getAbsolutePath()).resolve("libraries"))
|
||||
.build();
|
||||
} catch (IOException | ReflectiveOperationException | URISyntaxException | NoSuchAlgorithmException e) {
|
||||
String version = abstractionLayer.getPluginInformation().getVersion();
|
||||
pluginLogger.error(this.getClass().getSimpleName() + "-v" + version, e);
|
||||
pluginLogger.error("Plan failed to load its dependencies correctly!");
|
||||
pluginLogger.error("This error should be reported at https://github.com/plan-player-analytics/Plan/issues");
|
||||
onDisable();
|
||||
}
|
||||
|
||||
PlanFabricComponent component = DaggerPlanFabricComponent.builder()
|
||||
.plan(this)
|
||||
.abstractionLayer(abstractionLayer)
|
||||
|
@ -152,7 +177,7 @@ public class PlanFabric implements PlanPlugin, DedicatedServerModInitializer {
|
|||
|
||||
@Override
|
||||
public File getDataFolder() {
|
||||
return null;
|
||||
return FabricLoader.getInstance().getGameDir().resolve("mods").resolve("Plan").toFile();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -81,11 +81,15 @@ public class CommandManager {
|
|||
try {
|
||||
subcommand.getExecutor().accept((CMDSender) ctx.getSource(), new Arguments(getCommandArguments(ctx)));
|
||||
} catch (Exception e) {
|
||||
ctx.getSource().sendError(new LiteralText("An internal error occurred, see the console for details."));
|
||||
plugin.getSystem().getErrorLogger().error(e, ErrorContext.builder()
|
||||
.related(ctx.getSource().getClass())
|
||||
.related(subcommand.getPrimaryAlias() + " " + getCommandArguments(ctx))
|
||||
.build());
|
||||
if (e instanceof IllegalArgumentException) {
|
||||
ctx.getSource().sendError(new LiteralText(e.getMessage()));
|
||||
} else {
|
||||
ctx.getSource().sendError(new LiteralText("An internal error occurred, see the console for details."));
|
||||
plugin.getSystem().getErrorLogger().error(e, ErrorContext.builder()
|
||||
.related(ctx.getSource().getClass())
|
||||
.related(subcommand.getPrimaryAlias() + " " + getCommandArguments(ctx))
|
||||
.build());
|
||||
}
|
||||
}
|
||||
}).runTaskAsynchronously();
|
||||
return 1;
|
||||
|
|
|
@ -32,6 +32,12 @@ public class FabricPluginLogger implements PluginLogger {
|
|||
return this;
|
||||
}
|
||||
|
||||
public void info(String message, Object... args) {
|
||||
String replacedMsg = message.replaceAll("(?<=\\{).+?(?=\\})", "");
|
||||
String formattedMsg = "[Plan] " + replacedMsg;
|
||||
logger.info(formattedMsg, args);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PluginLogger warn(String message) {
|
||||
logger.warn("[Plan] " + message);
|
||||
|
|
|
@ -1 +1,2 @@
|
|||
org.gradle.jvmargs=-Xmx1024m
|
||||
slimjar.version=1.2.5
|
||||
|
|
Loading…
Reference in New Issue