From 198b214d56a5d34c9c981ea893102a7e1d92992e Mon Sep 17 00:00:00 2001 From: MalekiRe Date: Wed, 9 Jun 2021 22:32:52 -0700 Subject: [PATCH] Added text to show teh fray amoutn when fray is added through command, yay! --- .../org/dimdev/dimdoors/command/FrayCommand.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/dimdev/dimdoors/command/FrayCommand.java b/src/main/java/org/dimdev/dimdoors/command/FrayCommand.java index dbc3f566..c06ee4b5 100644 --- a/src/main/java/org/dimdev/dimdoors/command/FrayCommand.java +++ b/src/main/java/org/dimdev/dimdoors/command/FrayCommand.java @@ -4,14 +4,19 @@ import com.mojang.brigadier.Command; import com.mojang.brigadier.CommandDispatcher; import com.mojang.brigadier.arguments.FloatArgumentType; import com.mojang.brigadier.arguments.IntegerArgumentType; +import net.minecraft.command.argument.ColorArgumentType; import net.minecraft.command.argument.DimensionArgumentType; import net.minecraft.command.argument.Vec3ArgumentType; import net.minecraft.entity.Entity; import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.network.MessageType; import net.minecraft.server.command.CommandManager; import net.minecraft.server.command.ServerCommandSource; import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.server.world.ServerWorld; +import net.minecraft.text.LiteralText; +import net.minecraft.text.Text; +import net.minecraft.util.Formatting; import net.minecraft.util.math.EulerAngle; import net.minecraft.util.math.Vec3d; import org.dimdev.dimdoors.api.util.TeleportUtil; @@ -25,14 +30,15 @@ public class FrayCommand { .argument("amount", IntegerArgumentType.integer()) .executes(ctx -> { ServerPlayerEntity player = ctx.getSource().getPlayer(); - - return addFray(player, IntegerArgumentType.getInteger(ctx, "amount")); + return addFray(ctx.getSource(), Formatting.ITALIC, player, IntegerArgumentType.getInteger(ctx, "amount")); }) ) ); } - private static int addFray(PlayerEntity player, int amount) { + private static int addFray(ServerCommandSource source, Formatting formatting, PlayerEntity player, int amount) { PlayerModifiersComponent.incrementFray(player, amount); + final Text text = new LiteralText("added : " + amount + " player now has : " + PlayerModifiersComponent.getFray(player)).formatted(formatting); + source.getMinecraftServer().getPlayerManager().broadcastChatMessage(text, MessageType.CHAT, player.getUuid()); return Command.SINGLE_SUCCESS; } }