add new Tag, Use Style instead of Textformating, implement grade indicator, fix offset
This commit is contained in:
parent
9af6f4c073
commit
dead4f21a8
7 changed files with 62 additions and 29 deletions
|
@ -8,7 +8,7 @@ org.gradle.jvmargs=-Xmx1G
|
|||
loader_version=0.11.3
|
||||
|
||||
# Mod Properties
|
||||
mod_version = 1.0.1
|
||||
mod_version = 1.0.2
|
||||
maven_group = net.saltymc.eaa
|
||||
archives_base_name = EAA_MOD
|
||||
|
||||
|
|
|
@ -27,7 +27,6 @@ import net.minecraft.text.OrderedText;
|
|||
import net.minecraft.text.Text;
|
||||
import net.minecraft.world.GameMode;
|
||||
import net.saltymc.eaa.function.TagFunction;
|
||||
import net.saltymc.eaa.util.database.DB_Tag;
|
||||
|
||||
/**
|
||||
* By: https://github.com/vladmarica/better-ping-display-fabric/
|
||||
|
@ -165,9 +164,11 @@ public final class CustomPlayerListHud {
|
|||
* PLAYER TAG
|
||||
*/
|
||||
int offset_tag_playername = aa;
|
||||
DB_Tag.Type playerTAG = TagFunction.getScoreboardTag(player.getProfile().getId().toString());
|
||||
mc.textRenderer.drawWithShadow(stack, playerTAG.getTag(), (float)aa, (float)ab, playerTAG.getColor());
|
||||
offset_tag_playername += mc.textRenderer.getWidth(playerTAG.getTag()) + 2;
|
||||
TagDTO playerTAG = TagFunction.getScoreboardTag(player.getProfile().getId().toString());
|
||||
mc.textRenderer.drawWithShadow(stack, playerTAG.getType().getTag(), (float)aa, (float)ab, playerTAG.getType().getColor());
|
||||
offset_tag_playername += mc.textRenderer.getWidth(playerTAG.getType().getTag()) + 1;
|
||||
mc.textRenderer.drawWithShadow(stack,"|", (float) offset_tag_playername, (float) ab, playerTAG.getGradeColor());
|
||||
offset_tag_playername += mc.textRenderer.getWidth("|") + 2;
|
||||
|
||||
|
||||
Text playerName = hud.getPlayerName(player);
|
||||
|
@ -178,7 +179,7 @@ public final class CustomPlayerListHud {
|
|||
}
|
||||
|
||||
if (obj != null && player.getGameMode() != GameMode.SPECTATOR) {
|
||||
int ag = aa + i + 1;
|
||||
int ag = offset_tag_playername + i + 1;
|
||||
ah = ag + q;
|
||||
if (ah - ag > 5) {
|
||||
PlayerListHudUtil.renderScoreboardObjective(hud, stack, obj, ab, gameProfile.getName(), ag, ah, player);
|
||||
|
|
|
@ -33,7 +33,7 @@ public class PingColors {
|
|||
computeOffset(PING_MID, PING_END, Math.min(ping, PING_END)));
|
||||
}
|
||||
|
||||
static float computeOffset(int start, int end, int value) {
|
||||
public static float computeOffset(int start, int end, int value) {
|
||||
float offset = (value - start) / (float) ( end - start);
|
||||
return MathHelper.clamp(offset, 0.0F, 1.0F);
|
||||
}
|
||||
|
|
33
src/main/java/net/saltymc/eaa/custom/ping/TagDTO.java
Normal file
33
src/main/java/net/saltymc/eaa/custom/ping/TagDTO.java
Normal file
|
@ -0,0 +1,33 @@
|
|||
package net.saltymc.eaa.custom.ping;
|
||||
|
||||
import net.saltymc.eaa.util.database.DB_Tag;
|
||||
|
||||
import static net.saltymc.eaa.custom.ping.PingColors.computeOffset;
|
||||
|
||||
public class TagDTO {
|
||||
final int gradeColor;
|
||||
final DB_Tag.Type type;
|
||||
|
||||
public TagDTO(int grade, DB_Tag.Type type) {
|
||||
this.gradeColor = calcGradient(grade);
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public int getGradeColor() {
|
||||
return gradeColor;
|
||||
}
|
||||
|
||||
public DB_Tag.Type getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
private static int calcGradient(int grade){
|
||||
if (grade < 1)
|
||||
return 0xaaaaaa;
|
||||
|
||||
return ColorUtil.interpolate(
|
||||
0xffffff,
|
||||
0x0000aa,
|
||||
computeOffset(0, 10, grade));
|
||||
}
|
||||
}
|
|
@ -4,7 +4,9 @@ import net.fabricmc.fabric.api.client.command.v1.FabricClientCommandSource;
|
|||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.toast.SystemToast;
|
||||
import net.minecraft.text.LiteralText;
|
||||
import net.minecraft.text.Style;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.text.TextColor;
|
||||
import net.minecraft.util.Formatting;
|
||||
import net.saltymc.eaa.util.database.DB_Player;
|
||||
import net.saltymc.eaa.util.database.DB_Tag;
|
||||
|
@ -57,7 +59,7 @@ public class CheckFunction {
|
|||
|
||||
source.sendFeedback(new LiteralText(dateformat.format(curr.getTagDate())).formatted(Formatting.GRAY)
|
||||
.append(new LiteralText(" | "))
|
||||
.append(new LiteralText(curr.getType().getTag()).formatted(curr.getType().getFormatting()))
|
||||
.append(new LiteralText(curr.getType().getTag()).setStyle(Style.EMPTY.withColor(TextColor.fromRgb(curr.getType().getColor()))))
|
||||
.append(new LiteralText(" (" + curr.getGrade() + ") ").formatted(getScaleFormat(curr.getGrade())))
|
||||
);
|
||||
}
|
||||
|
@ -71,7 +73,7 @@ public class CheckFunction {
|
|||
}
|
||||
}
|
||||
|
||||
private static Formatting getScaleFormat(int grade){
|
||||
public static Formatting getScaleFormat(int grade){
|
||||
if (grade <= 5)
|
||||
return Formatting.WHITE;
|
||||
else if (grade < 9)
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
package net.saltymc.eaa.function;
|
||||
|
||||
import net.fabricmc.fabric.api.client.command.v1.FabricClientCommandSource;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.toast.SystemToast;
|
||||
import net.minecraft.text.Text;
|
||||
import net.saltymc.eaa.custom.ping.TagDTO;
|
||||
import net.saltymc.eaa.util.database.DB_Player;
|
||||
import net.saltymc.eaa.util.database.DB_Tag;
|
||||
import net.saltymc.eaa.util.mojangApi.PlayerInfo;
|
||||
|
@ -23,16 +23,18 @@ public class TagFunction {
|
|||
}
|
||||
}
|
||||
|
||||
public static DB_Tag.Type getScoreboardTag(String uuid){
|
||||
if (player_tags.containsKey(uuid))
|
||||
return player_tags.get(uuid).getType();
|
||||
else {
|
||||
public static TagDTO getScoreboardTag(String uuid){
|
||||
if (player_tags.containsKey(uuid)) {
|
||||
DB_Tag tag = player_tags.get(uuid);
|
||||
return new TagDTO(tag.getGrade(), tag.getType());
|
||||
|
||||
} else {
|
||||
if (free) {
|
||||
free = false;
|
||||
loadPlayer(uuid, false);
|
||||
}
|
||||
}
|
||||
return DB_Tag.Type.NOTLOADED;
|
||||
return new TagDTO(-1, DB_Tag.Type.NOTLOADED);
|
||||
}
|
||||
|
||||
public static void tagPlayer(String player, DB_Tag.Type tag, int grade, FabricClientCommandSource source){
|
||||
|
|
|
@ -96,31 +96,30 @@ public class DB_Tag {
|
|||
|
||||
public enum Type {
|
||||
HACKER(
|
||||
"HAX", "PLayer who hacks", 0xaa0000, Formatting.RED
|
||||
"HAX", "PLayer who hacks", 0xaa0000
|
||||
), FRIENDLY(
|
||||
"FND", "Player you like", 0x55ff55, Formatting.GREEN
|
||||
"FND", "Player you like", 0x55ff55
|
||||
), GOODPLAYER(
|
||||
"PRO", "Fair player with good skill", 0xffaa00, Formatting.GOLD
|
||||
"PRO", "Fair player with good skill", 0xffaa00
|
||||
), IDIOT(
|
||||
"BAD", "Person who is annoying and bad", 0x55ffff, Formatting.AQUA
|
||||
"A$$", "Person who is annoying and bad", 0x55ffff
|
||||
), NOOB(
|
||||
"BAD", "Person with low skill", 0xff55ff
|
||||
), NOTTAGGED(
|
||||
"NaN", "Player is not tagged", 0x555555, Formatting.DARK_GRAY
|
||||
"NaN", "Player is not tagged", 0x555555
|
||||
), NOTLOADED(
|
||||
"---", "PLayer not loaded", 0xffffff, Formatting.WHITE
|
||||
"---", "PLayer not loaded", 0xffffff
|
||||
);
|
||||
|
||||
String tag, description;
|
||||
int color;
|
||||
Formatting formatting;
|
||||
|
||||
Type(String tag, String description, int color, Formatting formatting){
|
||||
Type(String tag, String description, int color){
|
||||
this.tag = tag;
|
||||
this.description = description;
|
||||
this.color = color;
|
||||
this.formatting = formatting;
|
||||
}
|
||||
|
||||
|
||||
public String getTag() {
|
||||
return tag;
|
||||
}
|
||||
|
@ -132,9 +131,5 @@ public class DB_Tag {
|
|||
public int getColor() {
|
||||
return color;
|
||||
}
|
||||
|
||||
public Formatting getFormatting(){
|
||||
return formatting;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue