diff options
author | Maximusbarcz <maxim.baranek@gmail.com> | 2022-10-02 13:21:16 +0200 |
---|---|---|
committer | Maximusbarcz <maxim.baranek@gmail.com> | 2022-10-02 13:21:16 +0200 |
commit | 7281ea4ee14d85215707d6700efa7cf28300db41 (patch) | |
tree | 753a61c53c34f7821caa9f3fec712b3f62a5a11b /src/main | |
parent | 1b7f9bc4d7c6536f2d5c9528515ff25cdb292ce4 (diff) | |
download | ygasi-7281ea4ee14d85215707d6700efa7cf28300db41.tar.gz ygasi-7281ea4ee14d85215707d6700efa7cf28300db41.tar.bz2 ygasi-7281ea4ee14d85215707d6700efa7cf28300db41.zip |
Added Commands for viewing, adding and reseting skill points. Also added a /skilltree command for later
Diffstat (limited to 'src/main')
-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!"); } } |