diff options
6 files changed, 28 insertions, 26 deletions
diff --git a/spark-forge/build.gradle b/spark-forge/build.gradle index affc907..8229963 100644 --- a/spark-forge/build.gradle +++ b/spark-forge/build.gradle @@ -14,7 +14,7 @@ plugins { apply plugin: 'net.minecraftforge.gradle' minecraft { - mappings channel: 'snapshot', version: '20200723-1.16.1' + mappings channel: 'snapshot', version: '20200916-1.16.2' accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg') } @@ -38,7 +38,7 @@ configurations { } dependencies { - minecraft 'net.minecraftforge:forge:1.16.2-33.0.45' + minecraft 'net.minecraftforge:forge:1.16.3-34.1.25' shade project(':spark-common') } diff --git a/spark-forge/src/main/java/me/lucko/spark/forge/ForgeCommandSender.java b/spark-forge/src/main/java/me/lucko/spark/forge/ForgeCommandSender.java index 4aad23a..5ee55f7 100644 --- a/spark-forge/src/main/java/me/lucko/spark/forge/ForgeCommandSender.java +++ b/spark-forge/src/main/java/me/lucko/spark/forge/ForgeCommandSender.java @@ -62,7 +62,7 @@ public class ForgeCommandSender extends AbstractCommandSender<ICommandSource> { @Override public void sendMessage(Component message) { - IFormattableTextComponent component = ITextComponent.Serializer.func_240643_a_(GsonComponentSerializer.INSTANCE.serialize(message)); + IFormattableTextComponent component = ITextComponent.Serializer.getComponentFromJson(GsonComponentSerializer.INSTANCE.serialize(message)); super.delegate.sendMessage(component, Util.DUMMY_UUID); } diff --git a/spark-forge/src/main/java/me/lucko/spark/forge/ForgeSparkMod.java b/spark-forge/src/main/java/me/lucko/spark/forge/ForgeSparkMod.java index 4fa0274..e4e7c49 100644 --- a/spark-forge/src/main/java/me/lucko/spark/forge/ForgeSparkMod.java +++ b/spark-forge/src/main/java/me/lucko/spark/forge/ForgeSparkMod.java @@ -23,6 +23,7 @@ package me.lucko.spark.forge; import me.lucko.spark.forge.plugin.ForgeClientSparkPlugin; import me.lucko.spark.forge.plugin.ForgeServerSparkPlugin; import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.event.RegisterCommandsEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.ExtensionPoint; import net.minecraftforge.fml.ModContainer; @@ -30,7 +31,6 @@ import net.minecraftforge.fml.ModLoadingContext; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; -import net.minecraftforge.fml.event.server.FMLServerStartingEvent; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import net.minecraftforge.fml.loading.FMLPaths; import net.minecraftforge.fml.network.FMLNetworkConstants; @@ -45,8 +45,10 @@ public class ForgeSparkMod { private Path configDirectory; public ForgeSparkMod() { - FMLJavaModLoadingContext.get().getModEventBus().register(this); + FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setup); + FMLJavaModLoadingContext.get().getModEventBus().addListener(this::clientInit); MinecraftForge.EVENT_BUS.register(this); + ModLoadingContext.get().registerExtensionPoint(ExtensionPoint.DISPLAYTEST, () -> Pair.of(() -> FMLNetworkConstants.IGNORESERVERONLY, (a, b) -> true)); } @@ -54,18 +56,16 @@ public class ForgeSparkMod { return this.container.getModInfo().getVersion().toString(); } - @SubscribeEvent public void setup(FMLCommonSetupEvent e) { this.container = ModLoadingContext.get().getActiveContainer(); this.configDirectory = FMLPaths.CONFIGDIR.get().resolve(this.container.getModId()); } @SubscribeEvent - public void serverInit(FMLServerStartingEvent e) { + public void registerCommands(RegisterCommandsEvent e) { ForgeServerSparkPlugin.register(this, e); } - @SubscribeEvent public void clientInit(FMLClientSetupEvent e) { ForgeClientSparkPlugin.register(this, e); } diff --git a/spark-forge/src/main/java/me/lucko/spark/forge/plugin/ForgeServerSparkPlugin.java b/spark-forge/src/main/java/me/lucko/spark/forge/plugin/ForgeServerSparkPlugin.java index c7a4475..3433e3b 100644 --- a/spark-forge/src/main/java/me/lucko/spark/forge/plugin/ForgeServerSparkPlugin.java +++ b/spark-forge/src/main/java/me/lucko/spark/forge/plugin/ForgeServerSparkPlugin.java @@ -44,38 +44,39 @@ import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.RegisterCommandsEvent; import net.minecraftforge.event.TickEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; -import net.minecraftforge.fml.event.server.FMLServerStartingEvent; +import net.minecraftforge.fml.event.server.FMLServerStoppingEvent; +import net.minecraftforge.fml.server.ServerLifecycleHooks; import net.minecraftforge.server.permission.DefaultPermissionLevel; import net.minecraftforge.server.permission.PermissionAPI; import java.util.Arrays; import java.util.concurrent.CompletableFuture; +import java.util.function.Supplier; import java.util.stream.Stream; public class ForgeServerSparkPlugin extends ForgeSparkPlugin implements Command<CommandSource>, SuggestionProvider<CommandSource> { - public static void register(ForgeSparkMod mod, FMLServerStartingEvent event) { - final MinecraftServer minecraftServer = event.getServer(); - - ForgeServerSparkPlugin plugin = new ForgeServerSparkPlugin(mod, minecraftServer); + public static void register(ForgeSparkMod mod, RegisterCommandsEvent event) { + ForgeServerSparkPlugin plugin = new ForgeServerSparkPlugin(mod, ServerLifecycleHooks::getCurrentServer); MinecraftForge.EVENT_BUS.register(plugin); + CommandDispatcher<CommandSource> dispatcher = event.getDispatcher(); + registerCommands(dispatcher, plugin, plugin, "spark"); PermissionAPI.registerNode("spark", DefaultPermissionLevel.OP, "Access to the spark command"); } - private final MinecraftServer server; + @SubscribeEvent + public void onDisable(FMLServerStoppingEvent event) { + this.platform.disable(); + } + + private final Supplier<MinecraftServer> server; - public ForgeServerSparkPlugin(ForgeSparkMod mod, MinecraftServer server) { + public ForgeServerSparkPlugin(ForgeSparkMod mod, Supplier<MinecraftServer> server) { super(mod); this.server = server; } - @SubscribeEvent - public void onRegisterCommands(RegisterCommandsEvent e) { - CommandDispatcher<CommandSource> dispatcher = e.getDispatcher(); - registerCommands(dispatcher, this, this, "spark"); - } - @Override public int run(CommandContext<CommandSource> context) throws CommandSyntaxException { String[] args = processArgs(context); @@ -124,8 +125,8 @@ public class ForgeServerSparkPlugin extends ForgeSparkPlugin implements Command< @Override public Stream<ForgeCommandSender> getSendersWithPermission(String permission) { return Stream.concat( - this.server.getPlayerList().getPlayers().stream().filter(player -> hasPermission(player, permission)), - Stream.of(this.server) + this.server.get().getPlayerList().getPlayers().stream().filter(player -> hasPermission(player, permission)), + Stream.of(this.server.get()) ).map(sender -> new ForgeCommandSender(sender, this)); } diff --git a/spark-forge/src/main/resources/META-INF/mods.toml b/spark-forge/src/main/resources/META-INF/mods.toml index 80db546..dd65d4a 100644 --- a/spark-forge/src/main/resources/META-INF/mods.toml +++ b/spark-forge/src/main/resources/META-INF/mods.toml @@ -1,6 +1,7 @@ modLoader="javafml" -loaderVersion="[28,)" +loaderVersion="[34,)" authors="Luck, sk89q" +license="GPLv3" [[mods]] modId="spark" @@ -11,6 +12,6 @@ description="${pluginDescription}" [[dependencies.spark]] modId="forge" mandatory=true - versionRange="[28,)" + versionRange="[34,)" ordering="NONE" side="BOTH" diff --git a/spark-forge/src/main/resources/pack.mcmeta b/spark-forge/src/main/resources/pack.mcmeta index 6a06fe5..7db1a8f 100644 --- a/spark-forge/src/main/resources/pack.mcmeta +++ b/spark-forge/src/main/resources/pack.mcmeta @@ -1,6 +1,6 @@ { "pack": { "description": "spark resources", - "pack_format": 5 + "pack_format": 6 } }
\ No newline at end of file |