diff --git a/src/main/java/net/saltymc/eaa/commands/TagCommand.java b/src/main/java/net/saltymc/eaa/commands/TagCommand.java index 0035fda..dccca2c 100644 --- a/src/main/java/net/saltymc/eaa/commands/TagCommand.java +++ b/src/main/java/net/saltymc/eaa/commands/TagCommand.java @@ -1,21 +1,20 @@ package net.saltymc.eaa.commands; +import com.mojang.brigadier.Message; import com.mojang.brigadier.arguments.IntegerArgumentType; import com.mojang.brigadier.arguments.StringArgumentType; import com.mojang.brigadier.builder.LiteralArgumentBuilder; import com.mojang.brigadier.context.CommandContext; import net.fabricmc.fabric.api.client.command.v1.FabricClientCommandSource; -import net.minecraft.client.network.PlayerListEntry; import net.minecraft.client.toast.SystemToast; import net.minecraft.command.argument.EntityArgumentType; import net.minecraft.text.Text; +import net.saltymc.eaa.custom.ping.PingColors; import net.saltymc.eaa.util.database.DB_Player; import net.saltymc.eaa.util.database.DB_Tag; import net.saltymc.eaa.util.mojangApi.PlayerInfo; -import java.util.Collection; - import static net.fabricmc.fabric.api.client.command.v1.ClientCommandManager.argument; import static net.fabricmc.fabric.api.client.command.v1.ClientCommandManager.literal; @@ -61,4 +60,30 @@ public class TagCommand extends EaaModCommand{ .executes(this) ))); } + + public static CustomText getScoreboardTag(String uuid){ + + return new CustomText(Text.of("[NaN]"), PingColors.COLOR_GREY); + + } + + public static class CustomText { + private final Text text; + private final int color; + + + public CustomText(Text text, int color) { + this.text = text; + this.color = color; + } + + public Text getText() { + return text; + } + + public int getColor() { + return color; + } + } + } diff --git a/src/main/java/net/saltymc/eaa/custom/ping/CustomPlayerListHud.java b/src/main/java/net/saltymc/eaa/custom/ping/CustomPlayerListHud.java index 5a877b8..713964d 100644 --- a/src/main/java/net/saltymc/eaa/custom/ping/CustomPlayerListHud.java +++ b/src/main/java/net/saltymc/eaa/custom/ping/CustomPlayerListHud.java @@ -7,6 +7,7 @@ import com.mojang.blaze3d.systems.RenderSystem; import java.util.Comparator; import java.util.Iterator; import java.util.List; + import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.client.MinecraftClient; @@ -25,6 +26,7 @@ import net.minecraft.scoreboard.Team; import net.minecraft.text.OrderedText; import net.minecraft.text.Text; import net.minecraft.world.GameMode; +import net.saltymc.eaa.commands.TagCommand; /** * By: https://github.com/vladmarica/better-ping-display-fabric/ @@ -158,11 +160,17 @@ public final class CustomPlayerListHud { aa += 9; } + int offset_tag_playername = aa; + TagCommand.CustomText playerTAG = TagCommand.getScoreboardTag(player.getProfile().getId().toString()); + mc.textRenderer.drawWithShadow(stack, playerTAG.getText(), (float)aa, (float)ab, playerTAG.getColor()); + offset_tag_playername += mc.textRenderer.getWidth(playerTAG.getText().asOrderedText()) + 2; + + Text playerName = hud.getPlayerName(player); if (player.getGameMode() == GameMode.SPECTATOR) { - mc.textRenderer.drawWithShadow(stack, playerName, (float)aa, (float)ab, -1862270977); + mc.textRenderer.drawWithShadow(stack, playerName, (float)offset_tag_playername, (float)ab, -1862270977); } else { - mc.textRenderer.drawWithShadow(stack, playerName, (float)aa, (float)ab, -1); + mc.textRenderer.drawWithShadow(stack, playerName, (float)offset_tag_playername, (float)ab, -1); } if (obj != null && player.getGameMode() != GameMode.SPECTATOR) { diff --git a/src/main/java/net/saltymc/eaa/custom/ping/PingColors.java b/src/main/java/net/saltymc/eaa/custom/ping/PingColors.java index cd16328..6521f62 100644 --- a/src/main/java/net/saltymc/eaa/custom/ping/PingColors.java +++ b/src/main/java/net/saltymc/eaa/custom/ping/PingColors.java @@ -7,8 +7,8 @@ import net.minecraft.util.math.MathHelper; */ public class PingColors { public static final int PING_START = 0; - public static final int PING_MID = 150; - public static final int PING_END = 300; + public static final int PING_MID = 50; + public static final int PING_END = 100; public static final int COLOR_GREY = 0x535353; public static final int COLOR_START = 0x00E676; diff --git a/src/main/java/net/saltymc/eaa/custom/ping/PingConfig.java b/src/main/java/net/saltymc/eaa/custom/ping/PingConfig.java index ff17d77..6c99430 100644 --- a/src/main/java/net/saltymc/eaa/custom/ping/PingConfig.java +++ b/src/main/java/net/saltymc/eaa/custom/ping/PingConfig.java @@ -1,14 +1,7 @@ package net.saltymc.eaa.custom.ping; -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.annotations.Expose; import net.saltymc.eaa.EaaMod; -import java.io.File; -import java.io.FileReader; -import java.io.FileWriter; -import java.io.IOException; import java.io.Serializable; public class PingConfig { @@ -64,44 +57,10 @@ public class PingConfig { return this.renderPingBars; } - public static ConfigData loadConfigFile(File configFile) throws IOException { - FileReader reader = null; - try { - Gson gson = new Gson(); - reader = new FileReader(configFile); - return gson.fromJson(reader, ConfigData.class); - } - finally { - if (reader != null) { - reader.close(); - } - } - } - - public static void writeConfigFile(File configFile, ConfigData data) throws IOException { - FileWriter writer = null; - try { - Gson gson = new GsonBuilder().setPrettyPrinting().create(); - writer = new FileWriter(configFile); - writer.write(gson.toJson(data)); - } finally { - if (writer != null) { - writer.close(); - } - } - } - public static class ConfigData implements Serializable { - @Expose private boolean autoColorPingText = true; - - @Expose private boolean renderPingBars = false; - - @Expose private String pingTextColor = "#A0A0A0"; - - @Expose private String pingTextFormatString = "%dms"; } } \ No newline at end of file