diff options
| author | anhgelus <anhgelus.morhtuuzh@proton.me> | 2024-08-23 20:39:32 +0000 |
|---|---|---|
| committer | anhgelus <anhgelus.morhtuuzh@proton.me> | 2024-08-23 20:39:32 +0000 |
| commit | 32617ff3a18f966a445890d50c4b911817e162eb (patch) | |
| tree | 1569765d183101d294bcd57d4c63abde8821bb16 /src/main/java/world | |
| parent | 25e5c35509eac87c1091361390debbf32e49f16f (diff) | |
fix(command): no autocompletion for /molehunt moles
Diffstat (limited to 'src/main/java/world')
| -rw-r--r-- | src/main/java/world/anhgelus/molehunt/Game.java | 2 | ||||
| -rw-r--r-- | src/main/java/world/anhgelus/molehunt/Molehunt.java | 9 |
2 files changed, 8 insertions, 3 deletions
diff --git a/src/main/java/world/anhgelus/molehunt/Game.java b/src/main/java/world/anhgelus/molehunt/Game.java index 6101525..89ee9b3 100644 --- a/src/main/java/world/anhgelus/molehunt/Game.java +++ b/src/main/java/world/anhgelus/molehunt/Game.java @@ -158,7 +158,7 @@ public class Game { }
public boolean isAMole(ServerPlayerEntity player) {
- return moles.contains(player);
+ return hasStarted() && moles.contains(player);
}
public boolean gameWonByMoles() {
diff --git a/src/main/java/world/anhgelus/molehunt/Molehunt.java b/src/main/java/world/anhgelus/molehunt/Molehunt.java index 0ec3c3b..a07cb18 100644 --- a/src/main/java/world/anhgelus/molehunt/Molehunt.java +++ b/src/main/java/world/anhgelus/molehunt/Molehunt.java @@ -108,8 +108,13 @@ public class Molehunt implements ModInitializer { return Command.SINGLE_SUCCESS; }) )); - command.then(literal("moles").requires(source -> (game != null) && game.hasStarted() && game.isAMole(source.getPlayer())).executes(context -> { - context.getSource().sendFeedback(() -> Text.translatable("commands.molehunt.moles.list").append(" " + game.getMolesAsString()),false); + command.then(literal("moles").executes(context -> { + final var source = context.getSource(); + if (game == null || !game.isAMole(source.getPlayer())) { + source.sendFeedback(() -> Text.translatable("commands.molehunt.moles.list.deny"),false); + return Command.SINGLE_SUCCESS; + } + source.sendFeedback(() -> Text.translatable("commands.molehunt.moles.list").append(" " + game.getMolesAsString()),false); return Command.SINGLE_SUCCESS; })); command.then(literal("stop").requires(source -> source.hasPermissionLevel(1)).executes(context -> { |
