2024-09-25 23:23:29 +05:00

36 lines
1.5 KiB
Java

package ru.bitheaven.donpayinteg.command;
import com.mojang.brigadier.arguments.IntegerArgumentType;
import com.mojang.brigadier.arguments.StringArgumentType;
import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback;
import net.minecraft.server.command.CommandManager;
import net.minecraft.text.Text;
import ru.bitheaven.donpayinteg.config.Config;
import ru.bitheaven.donpayinteg.config.ConfigHandler;
public class DPI {
public DPI() {
throw new AssertionError();
}
public static void register() {
CommandRegistrationCallback.EVENT.register((((dispatcher, registryAccess, environment) ->
{
dispatcher.register(CommandManager.literal("dpi")
.then(CommandManager.literal("set_token")
.then(CommandManager.argument("token", StringArgumentType.string())
.executes(context -> {
String token = StringArgumentType.getString(context, "token");
Config config = ConfigHandler.load();
config.setDonpayToken(token);
ConfigHandler.save(config);
context.getSource().sendFeedback(() -> Text.literal("DonatePay token set!"), false);
return 1;
})))
);
})));
}
}