diff options
author | Maximusbarcz <maxim.baranek@gmail.com> | 2023-01-15 18:40:24 +0100 |
---|---|---|
committer | Maximusbarcz <maxim.baranek@gmail.com> | 2023-01-15 18:40:24 +0100 |
commit | d115e4365d0a5a492a55e56a7a4dcf034419e1b4 (patch) | |
tree | e9aec4f8b180c4a6b90d194f31e95a8df8863bb4 /src/main/java/dev/mayaqq/ygasi/registry/CommandRegistry.java | |
parent | 5bcb1830298caad87a63f44c4e7f1553074cf4c8 (diff) | |
download | ygasi-d115e4365d0a5a492a55e56a7a4dcf034419e1b4.tar.gz ygasi-d115e4365d0a5a492a55e56a7a4dcf034419e1b4.tar.bz2 ygasi-d115e4365d0a5a492a55e56a7a4dcf034419e1b4.zip |
More stuff! The Mercenary gui is basically done other than the translations, I tried and failed to add modrinth publishing thing to gradle, I redid some stuff, I added stuff, I removed stuff and mainly... I broke the reset command (it works but says it broke) and I have no idea how to fix it!
Diffstat (limited to 'src/main/java/dev/mayaqq/ygasi/registry/CommandRegistry.java')
-rw-r--r-- | src/main/java/dev/mayaqq/ygasi/registry/CommandRegistry.java | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/src/main/java/dev/mayaqq/ygasi/registry/CommandRegistry.java b/src/main/java/dev/mayaqq/ygasi/registry/CommandRegistry.java index 781ef4d..2b29a3c 100644 --- a/src/main/java/dev/mayaqq/ygasi/registry/CommandRegistry.java +++ b/src/main/java/dev/mayaqq/ygasi/registry/CommandRegistry.java @@ -1,5 +1,6 @@ package dev.mayaqq.ygasi.registry; +import com.mojang.brigadier.CommandDispatcher; import com.mojang.brigadier.arguments.IntegerArgumentType; import com.mojang.brigadier.context.CommandContext; import dev.mayaqq.ygasi.gui.*; @@ -15,6 +16,7 @@ import net.minecraft.util.Formatting; import java.io.File; +import static dev.mayaqq.ygasi.Ygasi.LOGGER; import static dev.mayaqq.ygasi.registry.StatRegistry.SKILL_POINTS; import static dev.mayaqq.ygasi.registry.StatRegistry.SKILL_POINTS_TOTAL; import static net.minecraft.server.command.CommandManager.literal; @@ -53,12 +55,19 @@ public class CommandRegistry { .requires(source -> source.hasPermissionLevel(4)) .then(literal("skillpoints") .then(literal("reset") - .then(CommandManager.argument("target", EntityArgumentType.player()) + .then(CommandManager.argument("targets", EntityArgumentType.players()) .executes(context -> { - ServerPlayerEntity player = EntityArgumentType.getPlayer(context, "target"); - player.resetStat(Stats.CUSTOM.getOrCreateStat(SKILL_POINTS)); - player.resetStat(Stats.CUSTOM.getOrCreateStat(StatRegistry.SKILL_POINTS_TOTAL)); - player.sendMessage(Text.translatable("commands.ygasi.skillpoints.reset", player.getEntityName()).formatted(Formatting.GREEN)); + for (int i = 0; i <= EntityArgumentType.getPlayers(context, "targets").size(); i++) { + ServerPlayerEntity[] players = EntityArgumentType.getPlayers(context, "targets").toArray(new ServerPlayerEntity[0]); + ResetGui.reset(players[i]); + } + String players; + if (EntityArgumentType.getPlayers(context, "targets").size() == 1) { + players = EntityArgumentType.getPlayers(context, "targets").toArray()[0].toString(); + } else { + players = EntityArgumentType.getPlayers(context, "targets").size() + " players"; + } + context.getSource().sendMessage(Text.translatable("commands.ygasi.skillpoints.reset", players).formatted(Formatting.GREEN)); return 1; }))) .then(literal("add") @@ -69,14 +78,14 @@ public class CommandRegistry { ServerPlayerEntity player = EntityArgumentType.getPlayer(context, "target"); player.increaseStat(SKILL_POINTS, amount); player.increaseStat(SKILL_POINTS_TOTAL, amount); - player.sendMessage(Text.translatable("commands.ygasi.skillpoints.add", amount, player.getName()).formatted(Formatting.GREEN)); + context.getSource().sendMessage(Text.translatable("commands.ygasi.skillpoints.add", amount, player.getName()).formatted(Formatting.GREEN)); return 1; })))) .then(literal("get") .then(CommandManager.argument("target", EntityArgumentType.player()) .executes(context -> { ServerPlayerEntity player = EntityArgumentType.getPlayer(context, "target"); - player.sendMessage(Text.translatable("commands.ygasi.skillpoints.get", player.getEntityName(), player.getStatHandler().getStat(Stats.CUSTOM.getOrCreateStat(SKILL_POINTS)), player.getStatHandler().getStat(Stats.CUSTOM.getOrCreateStat(SKILL_POINTS_TOTAL))).formatted(Formatting.GREEN)); + context.getSource().sendMessage(Text.translatable("commands.ygasi.skillpoints.get", player.getEntityName(), player.getStatHandler().getStat(Stats.CUSTOM.getOrCreateStat(SKILL_POINTS)), player.getStatHandler().getStat(Stats.CUSTOM.getOrCreateStat(SKILL_POINTS_TOTAL))).formatted(Formatting.GREEN)); return 1; })))) .then(literal("config") |