diff options
| -rw-r--r-- | README.md | 2 | ||||
| -rw-r--r-- | src/main/java/world/anhgelus/molehunt/Molehunt.java | 13 |
2 files changed, 14 insertions, 1 deletions
@@ -30,6 +30,8 @@ skin file](src/client/resources/assets/molehunt/textures/skin.png)). Also, more server-side values can be changed in the configuration file, located in your server config directory.
+Config hot reloadable with `/molehunt reload`
+
## Technologies
- Java 21
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)); |
