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

30 lines
1.0 KiB
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.LiteralText;
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(new LiteralText("Reloaded the configuration"), true);
} catch(Exception e) {
source.sendFeedback(new LiteralText("Failed to reload the configuration"), true);
}
return 1;
}));
dispatcher.register(literalargumentbuilder);
}
}