1
0
minecraft-tweaks-2a03/src/main/java/party/_2a03/mc/command/ConfigCommand.java

30 lines
1022 B
Java
Raw Normal View History

2020-01-07 15:53:42 +00:00
package party._2a03.mc.command;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import net.minecraft.server.command.CommandManager;
import net.minecraft.server.command.ServerCommandSource;
2022-06-12 03:58:16 +00:00
import net.minecraft.text.Text;
2020-08-17 01:22:31 +00:00
import party._2a03.mc.util.Config;
2020-01-07 15:53:42 +00:00
public class ConfigCommand {
public static void register(CommandDispatcher<ServerCommandSource> dispatcher) {
LiteralArgumentBuilder<ServerCommandSource> literalargumentbuilder = CommandManager.literal("config").requires(ctx -> {
return ctx.hasPermissionLevel(2);
});
literalargumentbuilder.then(CommandManager.literal("reload").executes(ctx -> {
ServerCommandSource source = ctx.getSource();
try {
Config.loadConfig();
2023-06-11 21:48:04 +00:00
source.sendFeedback(() -> Text.of("Reloaded the configuration"), true);
2020-01-07 15:53:42 +00:00
} catch(Exception e) {
2023-06-11 21:48:04 +00:00
source.sendFeedback(() -> Text.of("Failed to reload the configuration"), true);
2020-01-07 15:53:42 +00:00
}
return 1;
}));
dispatcher.register(literalargumentbuilder);
}
}