From c6e309f02732eb79a24db6780c4f8f718fac2a29 Mon Sep 17 00:00:00 2001 From: anhgelus Date: Fri, 23 Aug 2024 14:01:38 +0000 Subject: feat(config): hot reload with /molehunt reload --- src/main/java/world/anhgelus/molehunt/Molehunt.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/main/java/world/anhgelus/molehunt/Molehunt.java b/src/main/java/world/anhgelus/molehunt/Molehunt.java index 79903e2..4a728a0 100644 --- a/src/main/java/world/anhgelus/molehunt/Molehunt.java +++ b/src/main/java/world/anhgelus/molehunt/Molehunt.java @@ -29,7 +29,7 @@ public class Molehunt implements ModInitializer { public static final String MOD_ID = "molehunt"; public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID); - public static final Config CONFIG = new Config(MOD_ID); + public static Config CONFIG = new Config(MOD_ID); public Game game; @@ -81,6 +81,17 @@ public class Molehunt implements ModInitializer { return Command.SINGLE_SUCCESS; })); + command.then(literal("reload").requires(source -> source.hasPermissionLevel(1)).executes(context -> { + if (game != null && game.hasStarted()) { + game.end(); + game = null; + } + CONFIG = new Config(MOD_ID); + context.getSource().getServer().getPlayerManager().getPlayerList().forEach(p -> { + ServerPlayNetworking.send(p, new ConfigPayload(CONFIG.showNametags, CONFIG.showSkins, CONFIG.showTab)); + }); + return Command.SINGLE_SUCCESS; + })); CommandRegistrationCallback.EVENT.register((dispatcher, registryAccess, environment) -> dispatcher.register(command)); -- cgit v1.2.3