diff --git a/src/main/java/io/github/tanguygab/tabadditions/shared/features/layouts/Layout.java b/src/main/java/io/github/tanguygab/tabadditions/shared/features/layouts/Layout.java index 923e25b..93e6c39 100644 --- a/src/main/java/io/github/tanguygab/tabadditions/shared/features/layouts/Layout.java +++ b/src/main/java/io/github/tanguygab/tabadditions/shared/features/layouts/Layout.java @@ -1,5 +1,6 @@ package io.github.tanguygab.tabadditions.shared.features.layouts; +import com.mojang.authlib.properties.PropertyMap; import io.github.tanguygab.tabadditions.shared.ConfigType; import io.github.tanguygab.tabadditions.shared.PlatformType; import io.github.tanguygab.tabadditions.shared.TABAdditions; @@ -27,8 +28,8 @@ public class Layout { private final Map> playersets = new HashMap<>(); private final Map sorting = new HashMap<>(); - Map> skinsp = new HashMap<>(); - Map> skinss = new HashMap<>(); + Map> skinsp = new HashMap<>(); + Map> skinss = new HashMap<>(); public Layout(String name) { this.name = name; @@ -54,9 +55,9 @@ protected boolean isConditionMet(TabPlayer p) { protected void refreshPlaceholders() { if(!created) return; - Map skins = new HashMap<>(); ArrayList list = new ArrayList<>(players); for (TabPlayer p : list) { + Map skins = new HashMap<>(); for (Integer i : placeholders.keySet()) { PacketPlayOutPlayerInfo.PlayerInfoData fp = fakeplayers.get(i); Map slot = placeholders.get(i); @@ -71,14 +72,17 @@ protected void refreshPlaceholders() { } Object skin = null; - if (slot.containsKey("icon")) + String icon = ""; + if (slot.containsKey("icon")) { skin = TABAdditions.getInstance().getSkins().getIcon(slot.get("icon")+"", p); - if (!skinsp.containsKey(p) || (skin != null && skinsp.get(p).get(i) != skin)) { + icon = TABAdditions.getInstance().parsePlaceholders(slot.get("icon")+"",p); + } + if (!skinsp.containsKey(p) || (skin != null && !skinsp.get(p).get(i).equals(icon))) { p.sendCustomPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER, new PacketPlayOutPlayerInfo.PlayerInfoData(fp.uniqueId))); p.sendCustomPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, new PacketPlayOutPlayerInfo.PlayerInfoData(fp.name, fp.uniqueId, skin, 0, PacketPlayOutPlayerInfo.EnumGamemode.CREATIVE, IChatBaseComponent.fromColoredText(text)))); } else p.sendCustomPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.UPDATE_DISPLAY_NAME, new PacketPlayOutPlayerInfo.PlayerInfoData(fp.uniqueId, IChatBaseComponent.fromColoredText(text)))); - skins.put(i, skin); + skins.put(i, icon); p.sendCustomPacket(new PacketPlayOutScoreboardScore(PacketPlayOutScoreboardScore.Action.CHANGE, "TAB-YellowNumber", fp.name, 0)); } skinsp.put(p, skins); @@ -88,11 +92,11 @@ protected void refreshPlaceholders() { protected void refreshSets() { if(!created) return; - Map skins = new HashMap<>(); ArrayList list = new ArrayList<>(players); Map> playersets = new HashMap<>(this.playersets); for (TabPlayer p : list) { + Map skins = new HashMap<>(); for (Object set : playersets.keySet()) { List pset = playerSet(set); int inList = 0; @@ -118,20 +122,23 @@ protected void refreshSets() { if (pset.size() <= inList || vanished || pInSet == null) { String format = ""; Object skin = null; + String icon = ""; if (setConfig.containsKey("empty")) { - Map empty = (Map) setConfig.get("empty"); + Map empty = (Map) setConfig.get("empty"); if (empty.containsKey("text")) format = TABAdditions.getInstance().parsePlaceholders(empty.get("text"), p); - if (empty.containsKey("icon")) - skin = TABAdditions.getInstance().getSkins().getIcon(empty.get("icon")+"",p); + if (empty.containsKey("icon")) { + skin = TABAdditions.getInstance().getSkins().getIcon(empty.get("icon") + "", p); + icon = TABAdditions.getInstance().parsePlaceholders(empty.get("icon"), p); + } + if (!skinss.containsKey(p) || (!skinss.get(p).get(i).equals(icon))) { + p.sendCustomPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER, new PacketPlayOutPlayerInfo.PlayerInfoData(fp.uniqueId))); + p.sendCustomPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, new PacketPlayOutPlayerInfo.PlayerInfoData(fp.name, fp.uniqueId, skin, 0, PacketPlayOutPlayerInfo.EnumGamemode.CREATIVE, IChatBaseComponent.fromColoredText(format)))); + } else + p.sendCustomPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.UPDATE_DISPLAY_NAME, new PacketPlayOutPlayerInfo.PlayerInfoData(fp.uniqueId, IChatBaseComponent.fromColoredText(format)))); + skins.put(i, icon); + p.sendCustomPacket(new PacketPlayOutScoreboardScore(PacketPlayOutScoreboardScore.Action.CHANGE, "TAB-YellowNumber", fp.name, 0)); } - if (!skinss.containsKey(p) || (skinss.get(p).get(i) != skin)) { - p.sendCustomPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER, new PacketPlayOutPlayerInfo.PlayerInfoData(fp.uniqueId))); - p.sendCustomPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, new PacketPlayOutPlayerInfo.PlayerInfoData(fp.name, fp.uniqueId, skin, 0, PacketPlayOutPlayerInfo.EnumGamemode.CREATIVE, IChatBaseComponent.fromColoredText(format)))); - } else - p.sendCustomPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.UPDATE_DISPLAY_NAME, new PacketPlayOutPlayerInfo.PlayerInfoData(fp.uniqueId, IChatBaseComponent.fromColoredText(format)))); - skins.put(i,skin); - p.sendCustomPacket(new PacketPlayOutScoreboardScore(PacketPlayOutScoreboardScore.Action.CHANGE, "TAB-YellowNumber", fp.name, 0)); } else { String format = "%player%"; if (setConfig.containsKey("text")) format = setConfig.get("text")+""; @@ -153,15 +160,18 @@ protected void refreshSets() { catch (NumberFormatException ignored) {} Object skin = pInSet.getSkin(); - if (setConfig.containsKey("icon")) - skin = TABAdditions.getInstance().getSkins().getIcon(setConfig.get("icon")+"",pInSet); - if (!skinss.containsKey(p) || (skin != null && skinss.get(p).get(i) != skin)) { + String icon = "player-head:"+pInSet.getName(); + if (setConfig.containsKey("icon")) { + skin = TABAdditions.getInstance().getSkins().getIcon(setConfig.get("icon") + "", pInSet); + icon = TABAdditions.getInstance().parsePlaceholders(setConfig.get("icon")+"",pInSet); + } + if (!skinss.containsKey(p) || (skin != null && !skinss.get(p).get(i).equals(icon))) { p.sendCustomPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER, new PacketPlayOutPlayerInfo.PlayerInfoData(fp.uniqueId))); p.sendCustomPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, new PacketPlayOutPlayerInfo.PlayerInfoData(fp.name, fp.uniqueId, skin, 0, PacketPlayOutPlayerInfo.EnumGamemode.CREATIVE, IChatBaseComponent.fromColoredText(format)))); } else p.sendCustomPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.UPDATE_DISPLAY_NAME, new PacketPlayOutPlayerInfo.PlayerInfoData(fp.uniqueId, IChatBaseComponent.fromColoredText(format)))); - skins.put(i,skin); + skins.put(i,icon); p.sendCustomPacket(new PacketPlayOutScoreboardScore(PacketPlayOutScoreboardScore.Action.CHANGE, "TAB-YellowNumber", fp.name, yellownumber2)); diff --git a/src/main/java/io/github/tanguygab/tabadditions/shared/features/layouts/LayoutManager.java b/src/main/java/io/github/tanguygab/tabadditions/shared/features/layouts/LayoutManager.java index 3042389..0e16cb8 100644 --- a/src/main/java/io/github/tanguygab/tabadditions/shared/features/layouts/LayoutManager.java +++ b/src/main/java/io/github/tanguygab/tabadditions/shared/features/layouts/LayoutManager.java @@ -40,8 +40,8 @@ public void load() { for (Object layout : TABAdditions.getInstance().getConfig(ConfigType.LAYOUT).getConfigurationSection("layouts").keySet()) layouts.put(layout+"",new Layout(layout.toString())); togglecmd = TABAdditions.getInstance().getConfig(ConfigType.LAYOUT).getString("toggle-cmd","layout"); - refresh(); showLayoutAll(); + refresh(); } @Override @@ -114,14 +114,12 @@ public void showLayoutAll() { if (!TABAdditions.getInstance().checkBedrock(p)) toAdd.put(p,getLayout(p)); } - public void removeLayoutAll() { for (TabPlayer p : TAB.getInstance().getPlayers()) if (!TABAdditions.getInstance().checkBedrock(p)) toRemove.put(p,getLayout(p)); } - @Override public boolean onCommand(TabPlayer p, String msg) { if (msg.equals("/"+togglecmd) || msg.startsWith("/"+togglecmd+" ")) {