From e0d263ba917180d4d5d70a28114576b1602a0965 Mon Sep 17 00:00:00 2001 From: anhgelus Date: Fri, 26 Jul 2024 23:56:07 +0000 Subject: fix(command): not good display name in feedback --- src/main/java/world/anhgelus/manhunt/Manhunt.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/main/java/world/anhgelus/manhunt/Manhunt.java b/src/main/java/world/anhgelus/manhunt/Manhunt.java index ec7aef3..181b3d9 100644 --- a/src/main/java/world/anhgelus/manhunt/Manhunt.java +++ b/src/main/java/world/anhgelus/manhunt/Manhunt.java @@ -5,6 +5,7 @@ import com.mojang.brigadier.builder.LiteralArgumentBuilder; import com.mojang.brigadier.builder.RequiredArgumentBuilder; import net.fabricmc.api.ModInitializer; import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback; +import net.fabricmc.fabric.api.entity.event.v1.ServerLivingEntityEvents; import net.fabricmc.fabric.api.entity.event.v1.ServerPlayerEvents; import net.fabricmc.fabric.api.event.lifecycle.v1.ServerEntityEvents; import net.minecraft.command.EntitySelector; @@ -63,7 +64,8 @@ public class Manhunt implements ModInitializer { if (player == null) return 2; map.put(source.getPlayer().getUuid(), tracked.getUuid()); updateCompass(player, tracked); - context.getSource().sendFeedback(() -> Text.literal("Tracking "+tracked.getDisplayName()), false); + assert tracked.getDisplayName() != null; + context.getSource().sendFeedback(() -> Text.literal("Tracking "+tracked.getDisplayName().getString()), false); return Command.SINGLE_SUCCESS; }) ); @@ -73,14 +75,16 @@ public class Manhunt implements ModInitializer { final var p = (ServerPlayerEntity) EntityArgumentType.getEntity(context, "player"); speedrunners.remove(p.getUuid()); hunters.add(p.getUuid()); - context.getSource().sendFeedback(() -> Text.literal(p.getDisplayName()+" added to hunter"), true); + assert p.getDisplayName() != null; + context.getSource().sendFeedback(() -> Text.literal(p.getDisplayName().getString()+" added to hunter"), true); return Command.SINGLE_SUCCESS; })) .then(LiteralArgumentBuilder.literal("speedrunner").executes(context -> { final var p = (ServerPlayerEntity) EntityArgumentType.getEntity(context, "player"); hunters.remove(p.getUuid()); speedrunners.add(p.getUuid()); - context.getSource().sendFeedback(() -> Text.literal(p.getDisplayName()+" added to speedrunner"), true); + assert p.getDisplayName() != null; + context.getSource().sendFeedback(() -> Text.literal(p.getDisplayName().getString()+" added to speedrunner"), true); return Command.SINGLE_SUCCESS; })); team.then(teamP); -- cgit v1.2.3