1
0
minecraft-tweaks-2a03/src/main/java/party/_2a03/mc/command/ConfigCommand.java
2023-06-11 14:48:04 -07:00

30 lines
1022 B
Java

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;
import net.minecraft.text.Text;
import party._2a03.mc.util.Config;
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();
source.sendFeedback(() -> Text.of("Reloaded the configuration"), true);
} catch(Exception e) {
source.sendFeedback(() -> Text.of("Failed to reload the configuration"), true);
}
return 1;
}));
dispatcher.register(literalargumentbuilder);
}
}