From 0cb936f15eb7ec1fd50a366e859137336028eb5f Mon Sep 17 00:00:00 2001 From: anhgelus Date: Sat, 31 Aug 2024 17:02:19 +0000 Subject: fix(game): spectator cannot get list of moles --- src/main/java/world/anhgelus/molehunt/Molehunt.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/main/java/world/anhgelus/molehunt/Molehunt.java b/src/main/java/world/anhgelus/molehunt/Molehunt.java index abce46b..c2b8b4f 100644 --- a/src/main/java/world/anhgelus/molehunt/Molehunt.java +++ b/src/main/java/world/anhgelus/molehunt/Molehunt.java @@ -145,14 +145,20 @@ public class Molehunt implements ModInitializer { throw (new SimpleCommandExceptionType(Text.translatable("commands.molehunt.error.game_not_started"))).create(); } - var source = context.getSource(); + final var source = context.getSource(); + final var player = source.getPlayer(); + assert player != null; - if (game.isAMole(source.getPlayer())) { + if (game.isAMole(player)) { source.sendFeedback( () -> Text.translatable("commands.molehunt.role.mole") .append("\n\n") .append(Text.translatable("commands.molehunt.role.mole.list", game.getMolesAsString())), false); + } else if (player.isSpectator()) { + source.sendFeedback( + () -> Text.translatable("commands.molehunt.role.survivor.mole_count", game.getMoles().size()), + false); } else { source.sendFeedback( () -> Text.translatable("commands.molehunt.role.survivor") -- cgit v1.2.3