aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoranhgelus <anhgelus.morhtuuzh@proton.me>2024-08-23 20:39:32 +0000
committeranhgelus <anhgelus.morhtuuzh@proton.me>2024-08-23 20:39:32 +0000
commit32617ff3a18f966a445890d50c4b911817e162eb (patch)
tree1569765d183101d294bcd57d4c63abde8821bb16
parent25e5c35509eac87c1091361390debbf32e49f16f (diff)
fix(command): no autocompletion for /molehunt moles
-rw-r--r--src/client/resources/assets/molehunt/lang/en_us.json3
-rw-r--r--src/client/resources/assets/molehunt/lang/fr_fr.json3
-rw-r--r--src/main/java/world/anhgelus/molehunt/Game.java2
-rw-r--r--src/main/java/world/anhgelus/molehunt/Molehunt.java9
4 files changed, 12 insertions, 5 deletions
diff --git a/src/client/resources/assets/molehunt/lang/en_us.json b/src/client/resources/assets/molehunt/lang/en_us.json
index 73cbe97..fb5f1fa 100644
--- a/src/client/resources/assets/molehunt/lang/en_us.json
+++ b/src/client/resources/assets/molehunt/lang/en_us.json
@@ -3,11 +3,12 @@
"commands.molehunt.timer.show": "Showing Molehunt timer.",
"commands.molehunt.timer.hide": "Hiding Molehunt timer.",
"commands.molehunt.moles.list": "List of moles:",
+ "commands.molehunt.moles.list.deny": "You can't see the list of moles.",
"commands.molehunt.stop.success": "The Molehunt game has been stopped.",
"molehunt.game.end.suspense.title": "§eAnd the winners are...",
"molehunt.game.end.winners.moles.title": "§cThe Moles!",
"molehunt.game.end.winners.survivors.title": "§aNot the Moles!",
- "molehunt.game.end.winners.subtitle": "§6The Moles were",
+ "molehunt.game.end.winners.subtitle": "§6The Moles were ",
"molehunt.game.start.suspense": "§eYou are...",
"molehunt.game.start.mole.title": "§cThe Mole!",
"molehunt.game.start.mole.subtitle": "§eGet the list of moles with §6/molehunt moles",
diff --git a/src/client/resources/assets/molehunt/lang/fr_fr.json b/src/client/resources/assets/molehunt/lang/fr_fr.json
index c5c87d4..5a47c07 100644
--- a/src/client/resources/assets/molehunt/lang/fr_fr.json
+++ b/src/client/resources/assets/molehunt/lang/fr_fr.json
@@ -3,11 +3,12 @@
"commands.molehunt.timer.show": "Affiche le timer.",
"commands.molehunt.timer.hide": "Cache le timer.",
"commands.molehunt.moles.list": "Liste des taupes:",
+ "commands.molehunt.moles.list.deny": "Vous ne pouvez pas voir la liste des taupes.",
"commands.molehunt.stop.success": "La partie de Molehunt a été stoppée.",
"molehunt.game.end.suspense.title": "§eEt les gagnants sont...",
"molehunt.game.end.winners.moles.title": "§cLes Taupes !",
"molehunt.game.end.winners.survivors.title": "§aPas les Taupes !",
- "molehunt.game.end.winners.subtitle": "§Les Taupes sont",
+ "molehunt.game.end.winners.subtitle": "§Les Taupes sont ",
"molehunt.game.start.suspense": "§eVous êtes...",
"molehunt.game.start.mole.title": "§cLa Taupe !",
"molehunt.game.start.mole.subtitle": "§eRécupérer la liste des taupes avec §6/molehunt moles",
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 -> {