aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/world
diff options
context:
space:
mode:
authoranhgelus <anhgelus.morhtuuzh@proton.me>2024-08-23 14:01:38 +0000
committeranhgelus <anhgelus.morhtuuzh@proton.me>2024-08-23 14:01:38 +0000
commitc6e309f02732eb79a24db6780c4f8f718fac2a29 (patch)
treea6e226a969b652b1d1399483f7da69cb78d973cd /src/main/java/world
parenta638839550837f43216b02a9bdee359a24814f37 (diff)
feat(config): hot reload with /molehunt reload
Diffstat (limited to 'src/main/java/world')
-rw-r--r--src/main/java/world/anhgelus/molehunt/Molehunt.java13
1 files changed, 12 insertions, 1 deletions
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));