Add /hg reload command to refresh configs and messages

This commit is contained in:
akastijn 2026-05-30 19:57:02 +02:00
parent c969873e0a
commit 161344b30c
3 changed files with 45 additions and 0 deletions

View File

@ -2,6 +2,7 @@ package com.alttd.hunger_games.commands;
import com.alttd.hunger_games.Main;
import com.alttd.hunger_games.commands.subcommands.Register;
import com.alttd.hunger_games.commands.subcommands.Reload;
import com.alttd.hunger_games.commands.subcommands.RoundState;
import com.alttd.hunger_games.commands.subcommands.StartRound;
import com.alttd.hunger_games.config.Messages;
@ -35,6 +36,7 @@ public class BaseCommand implements CommandExecutor, TabExecutor {
command.setAliases(List.of("hg"));
subCommands = new ArrayList<>(List.of(
new Reload(main),
new RoundState(roundService),
new Register(playerService),
new StartRound(round)

View File

@ -0,0 +1,39 @@
package com.alttd.hunger_games.commands.subcommands;
import com.alttd.hunger_games.Main;
import com.alttd.hunger_games.commands.SubCommand;
import com.alttd.hunger_games.config.Messages;
import org.bukkit.command.CommandSender;
import java.util.List;
public class Reload extends SubCommand {
private final Main main;
public Reload(Main main) {
this.main = main;
}
@Override
public boolean onCommand(CommandSender commandSender, String[] args) {
main.reloadConfigs();
commandSender.sendRichMessage(Messages.GENERIC.RELOAD_SUCCESS);
return true;
}
@Override
public String getName() {
return "reload";
}
@Override
public List<String> getTabComplete(CommandSender commandSender, String[] args) {
return List.of();
}
@Override
public String getHelpMessage() {
return Messages.HELP.RELOAD;
}
}

View File

@ -29,6 +29,7 @@ public class Messages extends AbstractConfig {
public static String ROUND_STATE = "<green>Show the current round state: <gold>/hg roundstate</gold></green>";
public static String REGISTER = "<green>Register a player for the game: <gold>/hg register <player></gold></green>";
public static String START_ROUND = "<green>Start the game: <gold>/hg start</gold></green>";
public static String RELOAD = "<green>Reload config and messages: <gold>/hg reload</gold></green>";
@SuppressWarnings("unused")
private static void load() {
@ -37,6 +38,7 @@ public class Messages extends AbstractConfig {
ROUND_STATE = config.getString(prefix, "round-state", ROUND_STATE);
REGISTER = config.getString(prefix, "register", REGISTER);
START_ROUND = config.getString(prefix, "start", START_ROUND);
RELOAD = config.getString(prefix, "reload", RELOAD);
}
}
@ -46,12 +48,14 @@ public class Messages extends AbstractConfig {
public static String NO_PERMISSION = "<red><hover:show_text:'<red><permission></red>'>You don't have permission for this command</hover></red>";
public static String PLAYER_ONLY = "<red>This command can only be executed as a player</red>";
public static String PLAYER_NOT_FOUND = "<red>Unable to find online player <player></red>";
public static String RELOAD_SUCCESS = "<green>Config and messages have been reloaded.</green>";
@SuppressWarnings("unused")
private static void load() {
NO_PERMISSION = config.getString(prefix, "no-permission", NO_PERMISSION);
PLAYER_ONLY = config.getString(prefix, "player-only", PLAYER_ONLY);
PLAYER_NOT_FOUND = config.getString(prefix, "player-only", PLAYER_NOT_FOUND);
RELOAD_SUCCESS = config.getString(prefix, "reload-success", RELOAD_SUCCESS);
}
}