diff options
-rw-r--r-- | src/main/java/dev/mayaqq/ygasi/CommandRegistry.java | 50 | ||||
-rw-r--r-- | src/main/java/dev/mayaqq/ygasi/ygasi.java | 1 |
2 files changed, 51 insertions, 0 deletions
diff --git a/src/main/java/dev/mayaqq/ygasi/CommandRegistry.java b/src/main/java/dev/mayaqq/ygasi/CommandRegistry.java new file mode 100644 index 0000000..47deb24 --- /dev/null +++ b/src/main/java/dev/mayaqq/ygasi/CommandRegistry.java @@ -0,0 +1,50 @@ +package dev.mayaqq.ygasi; + +import com.mojang.brigadier.arguments.IntegerArgumentType; +import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback; +import net.minecraft.command.argument.EntityArgumentType; +import net.minecraft.server.command.CommandManager; +import net.minecraft.server.network.ServerPlayerEntity; +import net.minecraft.stat.Stats; +import net.minecraft.text.Text; + +import static dev.mayaqq.ygasi.StatRegistry.SKILL_POINTS; +import static net.minecraft.server.command.CommandManager.literal; + +public class CommandRegistry { + public static void RegisterCommands() { + CommandRegistrationCallback.EVENT.register((dispatcher, registryAccess, environment) -> dispatcher.register(literal("skilltree") + .executes(context -> { + context.getSource().sendMessage(Text.literal("Surely this opened a skilltree that is definitely implemented...")); + + return 1; + }))); + CommandRegistrationCallback.EVENT.register((dispatcher, registryAccess, environment) -> dispatcher.register(literal("ygasi") + .requires(source -> source.hasPermissionLevel(4)) + .then(literal("reset") + .then(CommandManager.argument("target", EntityArgumentType.player()) + .executes(context -> { + ServerPlayerEntity player = EntityArgumentType.getPlayer(context, "target"); + player.resetStat(Stats.CUSTOM.getOrCreateStat(SKILL_POINTS)); + context.getSource().sendMessage(Text.literal("§aSkill Points reset to 0 for " + player.getEntityName() + ".")); + return 1; + }))) + .then(literal("add") + .then(CommandManager.argument("target", EntityArgumentType.player()) + .then(CommandManager.argument("amount", IntegerArgumentType.integer()) + .executes(context -> { + ServerPlayerEntity player = EntityArgumentType.getPlayer(context, "target"); + player.increaseStat(SKILL_POINTS, IntegerArgumentType.getInteger(context, "amount")); + context.getSource().sendMessage(Text.literal("§aSkill Points increased by " + IntegerArgumentType.getInteger(context, "amount") + " for " + player.getEntityName() + ".")); + return 1; + })))) + .then(literal("get") + .then(CommandManager.argument("target", EntityArgumentType.player()) + .executes(context -> { + ServerPlayerEntity player = EntityArgumentType.getPlayer(context, "target"); + context.getSource().sendMessage(Text.literal("§a" + player.getEntityName() + " has " + player.getStatHandler().getStat(Stats.CUSTOM.getOrCreateStat(SKILL_POINTS)) + " Unspent Skill Points.")); + return 1; + }))) + )); + } +} diff --git a/src/main/java/dev/mayaqq/ygasi/ygasi.java b/src/main/java/dev/mayaqq/ygasi/ygasi.java index 185ae6e..ab08648 100644 --- a/src/main/java/dev/mayaqq/ygasi/ygasi.java +++ b/src/main/java/dev/mayaqq/ygasi/ygasi.java @@ -10,6 +10,7 @@ public class ygasi implements ModInitializer { @Override public void onInitialize() { StatRegistry.skillRegister(); + CommandRegistry.RegisterCommands(); LOGGER.info("You've got a skill issue!"); } } |