diff options
Diffstat (limited to 'src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/util')
-rw-r--r-- | src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/util/Ico.java | 50 | ||||
-rw-r--r-- | src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/util/StrMan.java | 64 |
2 files changed, 114 insertions, 0 deletions
diff --git a/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/util/Ico.java b/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/util/Ico.java new file mode 100644 index 00000000..a9f8e22f --- /dev/null +++ b/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/util/Ico.java @@ -0,0 +1,50 @@ +package me.xmrvizzy.skyblocker.skyblock.tabhud.util; + +import net.minecraft.item.ItemStack; +import net.minecraft.item.Items; + +public class Ico { + public static final ItemStack MAP = new ItemStack(Items.FILLED_MAP); + public static final ItemStack NTAG = new ItemStack(Items.NAME_TAG); + public static final ItemStack EMERALD = new ItemStack(Items.EMERALD); + public static final ItemStack CLOCK = new ItemStack(Items.CLOCK); + public static final ItemStack DIASWORD = new ItemStack(Items.DIAMOND_SWORD); + public static final ItemStack DBUSH = new ItemStack(Items.DEAD_BUSH); + public static final ItemStack VILLAGER = new ItemStack(Items.VILLAGER_SPAWN_EGG); + public static final ItemStack MOREGOLD = new ItemStack(Items.GOLDEN_APPLE); + public static final ItemStack COMPASS = new ItemStack(Items.COMPASS); + public static final ItemStack SUGAR = new ItemStack(Items.SUGAR); + public static final ItemStack HOE = new ItemStack(Items.IRON_HOE); + public static final ItemStack GOLD = new ItemStack(Items.GOLD_INGOT); + public static final ItemStack BONE = new ItemStack(Items.BONE); + public static final ItemStack SIGN = new ItemStack(Items.OAK_SIGN); + public static final ItemStack FISH_ROD = new ItemStack(Items.FISHING_ROD); + public static final ItemStack SWORD = new ItemStack(Items.IRON_SWORD); + public static final ItemStack LANTERN = new ItemStack(Items.LANTERN); + public static final ItemStack COOKIE = new ItemStack(Items.COOKIE); + public static final ItemStack POTION = new ItemStack(Items.POTION); + public static final ItemStack BARRIER = new ItemStack(Items.BARRIER); + public static final ItemStack PLAYER = new ItemStack(Items.PLAYER_HEAD); + public static final ItemStack WATER = new ItemStack(Items.WATER_BUCKET); + public static final ItemStack LEATHER = new ItemStack(Items.LEATHER); + public static final ItemStack MITHRIL = new ItemStack(Items.PRISMARINE_CRYSTALS); + public static final ItemStack REDSTONE = new ItemStack(Items.REDSTONE); + public static final ItemStack FIRE = new ItemStack(Items.CAMPFIRE); + public static final ItemStack STRING = new ItemStack(Items.STRING); + public static final ItemStack WITHER = new ItemStack(Items.WITHER_SKELETON_SKULL); + public static final ItemStack FLESH = new ItemStack(Items.ROTTEN_FLESH); + public static final ItemStack DRAGON = new ItemStack(Items.DRAGON_HEAD); + public static final ItemStack DIAMOND = new ItemStack(Items.DIAMOND); + public static final ItemStack ICE = new ItemStack(Items.ICE); + public static final ItemStack CHEST = new ItemStack(Items.CHEST); + public static final ItemStack COMMAND = new ItemStack(Items.COMMAND_BLOCK); + public static final ItemStack SKULL = new ItemStack(Items.SKELETON_SKULL); + public static final ItemStack BOOK = new ItemStack(Items.WRITABLE_BOOK); + public static final ItemStack FURNACE = new ItemStack(Items.FURNACE); + public static final ItemStack CHESTPLATE = new ItemStack(Items.IRON_CHESTPLATE); + public static final ItemStack B_ROD = new ItemStack(Items.BLAZE_ROD); + public static final ItemStack BOW = new ItemStack(Items.BOW); + public static final ItemStack COPPER = new ItemStack(Items.COPPER_INGOT); + public static final ItemStack COMPOSTER = new ItemStack(Items.COMPOSTER); + public static final ItemStack SAPLING = new ItemStack(Items.OAK_SAPLING); +} diff --git a/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/util/StrMan.java b/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/util/StrMan.java new file mode 100644 index 00000000..8cd77ac2 --- /dev/null +++ b/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/util/StrMan.java @@ -0,0 +1,64 @@ +package me.xmrvizzy.skyblocker.skyblock.tabhud.util; + +import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import net.minecraft.client.network.PlayerListEntry; +import net.minecraft.text.Text; +import net.minecraft.util.Formatting; + +public class StrMan { + + private static final Logger LOGGER = LoggerFactory.getLogger(StrMan.class.getName()); + private static final Text ERROR_TXT = Text.literal("[ERROR]").formatted(Formatting.RED, Formatting.BOLD); + + public static Text stdEntry(List<PlayerListEntry> ple, int idx, String entryName, Formatting contentFmt) { + Text txt = ple.get(idx).getDisplayName(); + if (txt == null) { + return ERROR_TXT; + } + String src = txt.getString(); + src = src.substring(src.indexOf(':') + 1); + return StrMan.stdEntry(src, entryName, contentFmt); + } + + public static Text stdEntry(String entryContent, String entryName, Formatting contentFmt) { + return Text.literal(entryName).append(Text.literal(entryContent).formatted(contentFmt)); + } + + public static Text plainEntry(List<PlayerListEntry> ple, int idx) { + Text txt = ple.get(idx).getDisplayName(); + if (txt == null) { + return ERROR_TXT; + } + return Text.of(txt.getString().trim()); + } + + public static Matcher regexAt(List<PlayerListEntry> ple, int idx, Pattern p) { + Text txt = ple.get(idx).getDisplayName(); + if (txt == null) { + return null; + } + String str = txt.getString(); + Matcher m = p.matcher(str); + if (!m.matches()) { + LOGGER.error("ERROR: Regex {} failed for input \"{}\"", p.pattern(), str); + return null; + } else { + return m; + } + } + + public static String strAt(List<PlayerListEntry> ple, int idx) { + Text txt = ple.get(idx).getDisplayName(); + if (txt == null) { + return null; + } + return txt.getString(); + } + +} |