Added text to show teh fray amoutn when fray is added through command, yay!

This commit is contained in:
MalekiRe 2021-06-09 22:32:52 -07:00
parent ccb85e5060
commit 198b214d56

View file

@ -4,14 +4,19 @@ import com.mojang.brigadier.Command;
import com.mojang.brigadier.CommandDispatcher; import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.arguments.FloatArgumentType; import com.mojang.brigadier.arguments.FloatArgumentType;
import com.mojang.brigadier.arguments.IntegerArgumentType; import com.mojang.brigadier.arguments.IntegerArgumentType;
import net.minecraft.command.argument.ColorArgumentType;
import net.minecraft.command.argument.DimensionArgumentType; import net.minecraft.command.argument.DimensionArgumentType;
import net.minecraft.command.argument.Vec3ArgumentType; import net.minecraft.command.argument.Vec3ArgumentType;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.network.MessageType;
import net.minecraft.server.command.CommandManager; import net.minecraft.server.command.CommandManager;
import net.minecraft.server.command.ServerCommandSource; import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.server.world.ServerWorld; 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.EulerAngle;
import net.minecraft.util.math.Vec3d; import net.minecraft.util.math.Vec3d;
import org.dimdev.dimdoors.api.util.TeleportUtil; import org.dimdev.dimdoors.api.util.TeleportUtil;
@ -25,14 +30,15 @@ public class FrayCommand {
.argument("amount", IntegerArgumentType.integer()) .argument("amount", IntegerArgumentType.integer())
.executes(ctx -> { .executes(ctx -> {
ServerPlayerEntity player = ctx.getSource().getPlayer(); ServerPlayerEntity player = ctx.getSource().getPlayer();
return addFray(ctx.getSource(), Formatting.ITALIC, player, IntegerArgumentType.getInteger(ctx, "amount"));
return addFray(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); 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; return Command.SINGLE_SUCCESS;
} }
} }