From 632fc4bc5d39926e6e2b48cd8d664a37e711d264 Mon Sep 17 00:00:00 2001 From: LAX1DUDE Date: Fri, 15 Apr 2022 14:53:30 -0700 Subject: [PATCH] Fixed corrupt color code, fixed 'hide_down' flag for default server list --- .../java/net/md_5/bungee/api/ChatColor.java | 8 +++--- .../lax1dude/eaglercraft/ConfigConstants.java | 2 +- .../net/minecraft/src/GuiMultiplayer.java | 6 ++++- .../java/net/minecraft/src/GuiSlotServer.java | 2 +- .../java/net/minecraft/src/ServerData.java | 12 +++++++++ .../java/net/minecraft/src/ServerList.java | 27 ++++++++++--------- 6 files changed, 37 insertions(+), 20 deletions(-) diff --git a/eaglercraftbungee/src/main/java/net/md_5/bungee/api/ChatColor.java b/eaglercraftbungee/src/main/java/net/md_5/bungee/api/ChatColor.java index cda85ac..e09537a 100644 --- a/eaglercraftbungee/src/main/java/net/md_5/bungee/api/ChatColor.java +++ b/eaglercraftbungee/src/main/java/net/md_5/bungee/api/ChatColor.java @@ -12,7 +12,7 @@ public enum ChatColor { BLACK('0'), DARK_BLUE('1'), DARK_GREEN('2'), DARK_AQUA('3'), DARK_RED('4'), DARK_PURPLE('5'), GOLD('6'), GRAY('7'), DARK_GRAY('8'), BLUE('9'), GREEN('a'), AQUA('b'), RED('c'), LIGHT_PURPLE('d'), YELLOW('e'), WHITE('f'), MAGIC('k'), BOLD('l'), STRIKETHROUGH('m'), UNDERLINE('n'), ITALIC('o'), RESET('r'); - public static final char COLOR_CHAR = '§'; + public static final char COLOR_CHAR = '\u00A7'; private static final Pattern STRIP_COLOR_PATTERN; private static final Map BY_CHAR; private final char code; @@ -20,7 +20,7 @@ public enum ChatColor { private ChatColor(final char code) { this.code = code; - this.toString = new String(new char[] { '§', code }); + this.toString = new String(new char[] { '\u00A7', code }); } @Override @@ -39,7 +39,7 @@ public enum ChatColor { final char[] b = textToTranslate.toCharArray(); for (int i = 0; i < b.length - 1; ++i) { if (b[i] == altColorChar && "0123456789AaBbCcDdEeFfKkLlMmNnOoRr".indexOf(b[i + 1]) > -1) { - b[i] = '§'; + b[i] = '\u00A7'; b[i + 1] = Character.toLowerCase(b[i + 1]); } } @@ -51,7 +51,7 @@ public enum ChatColor { } static { - STRIP_COLOR_PATTERN = Pattern.compile("(?i)" + String.valueOf('§') + "[0-9A-FK-OR]"); + STRIP_COLOR_PATTERN = Pattern.compile("(?i)" + String.valueOf('\u00A7') + "[0-9A-FK-OR]"); BY_CHAR = new HashMap(); for (final ChatColor colour : values()) { ChatColor.BY_CHAR.put(colour.code, colour); diff --git a/src/main/java/net/lax1dude/eaglercraft/ConfigConstants.java b/src/main/java/net/lax1dude/eaglercraft/ConfigConstants.java index 96f9eee..938c240 100644 --- a/src/main/java/net/lax1dude/eaglercraft/ConfigConstants.java +++ b/src/main/java/net/lax1dude/eaglercraft/ConfigConstants.java @@ -4,7 +4,7 @@ public class ConfigConstants { public static boolean profanity = false; - public static final String version = "22w15a"; + public static final String version = "22w15b"; public static final String mainMenuString = "eaglercraft " + version; public static final String forkMe = "https://github.com/LAX1DUDE/eaglercraft"; diff --git a/src/main/java/net/minecraft/src/GuiMultiplayer.java b/src/main/java/net/minecraft/src/GuiMultiplayer.java index bce83ab..2abc147 100644 --- a/src/main/java/net/minecraft/src/GuiMultiplayer.java +++ b/src/main/java/net/minecraft/src/GuiMultiplayer.java @@ -255,7 +255,7 @@ public class GuiMultiplayer extends GuiScreen { this.mc.gameSettings.saveOptions(); } else { if (isShiftKeyDown() && par2 == 200) { - if (var3 > 0 && var3 < this.internetServerList.countServers()) { + if (var3 > ServerList.forcedServers.size() && var3 < this.internetServerList.countServers()) { this.internetServerList.swapServers(var3, var3 - 1); --this.selectedServer; @@ -361,6 +361,10 @@ public class GuiMultiplayer extends GuiScreen { } static int getSelectedServer(GuiMultiplayer par0GuiMultiplayer) { + int i = internetServerList.countServers(); + if(par0GuiMultiplayer.selectedServer >= i && par0GuiMultiplayer.selectedServer > 0) { + par0GuiMultiplayer.selectedServer = i - 1; + } return par0GuiMultiplayer.selectedServer; } diff --git a/src/main/java/net/minecraft/src/GuiSlotServer.java b/src/main/java/net/minecraft/src/GuiSlotServer.java index 2b64bc3..4e7b71e 100644 --- a/src/main/java/net/minecraft/src/GuiSlotServer.java +++ b/src/main/java/net/minecraft/src/GuiSlotServer.java @@ -41,7 +41,7 @@ class GuiSlotServer extends GuiSlot { if (par2 && var5) { GuiMultiplayer.func_74008_b(this.parentGui, par1); - } else if (var6 && GuiScreen.isShiftKeyDown() && var3 >= 0 && var3 < GuiMultiplayer.getInternetServerList(this.parentGui).countServers()) { + } else if (var6 && GuiScreen.isShiftKeyDown() && var3 > ServerList.forcedServers.size() && var3 < GuiMultiplayer.getInternetServerList(this.parentGui).countServers()) { GuiMultiplayer.getInternetServerList(this.parentGui).swapServers(var3, GuiMultiplayer.getSelectedServer(this.parentGui)); } } diff --git a/src/main/java/net/minecraft/src/ServerData.java b/src/main/java/net/minecraft/src/ServerData.java index 9505a3c..d68a11d 100644 --- a/src/main/java/net/minecraft/src/ServerData.java +++ b/src/main/java/net/minecraft/src/ServerData.java @@ -15,6 +15,9 @@ import net.minecraft.client.Minecraft; public class ServerData { public String serverName; public String serverIP; + private final int id; + + private static int idCounter = 0; /** * the string indicating number of players on and capacity of the server that is @@ -55,6 +58,15 @@ public class ServerData { this.serverName = par1Str; this.serverIP = par2Str; this.isDefault = isDefault; + this.id = ++idCounter; + } + + public int hashCode() { + return id; + } + + public boolean equals(Object o) { + return o instanceof ServerData && id == ((ServerData)o).id; } /** diff --git a/src/main/java/net/minecraft/src/ServerList.java b/src/main/java/net/minecraft/src/ServerList.java index 5d39abf..db2c410 100644 --- a/src/main/java/net/minecraft/src/ServerList.java +++ b/src/main/java/net/minecraft/src/ServerList.java @@ -79,8 +79,8 @@ public class ServerList { */ public void saveServerList() { NBTTagList servers = new NBTTagList(); - for(int i = forcedServers.size(); i < this.servers.size(); ++i) { - servers.appendTag(((ServerData) this.servers.get(i)).getNBTCompound()); + for(int i = forcedServers.size(); i < this.allServers.size(); ++i) { + servers.appendTag(((ServerData) this.allServers.get(i)).getNBTCompound()); } LocalStorageManager.gameSettingsStorage.setTag("servers", servers); LocalStorageManager.saveStorageG(); @@ -98,6 +98,7 @@ public class ServerList { */ public void removeServerData(int par1) { ServerData dat = this.servers.remove(par1); + this.allServers.remove(dat); if(dat != null) { dat.freeIcon(); } @@ -109,7 +110,8 @@ public class ServerList { public void addServerData(ServerData par1ServerData) { par1ServerData.pingSentTime = -1l; par1ServerData.hasPing = false; - this.servers.add(par1ServerData); + this.allServers.add(par1ServerData); + refreshServerPing(); } /** @@ -122,22 +124,21 @@ public class ServerList { /** * Takes two list indexes, and swaps their order around. */ - public void swapServers(int par1, int par2) { + public void swapServers(int par1, int par2) { // will be fixed eventually + /* ServerData var3 = this.getServerData(par1); - this.servers.set(par1, this.getServerData(par2)); + ServerData dat = this.getServerData(par2); + this.servers.set(par1, dat); this.servers.set(par2, var3); + int i = this.allServers.indexOf(dat); + this.allServers.set(par1, this.allServers.get(i)); + this.allServers.set(i, var3); this.saveServerList(); - } - - /** - * Sets the given index in the list to the given ServerData instance. - */ - public void setServer(int par1, ServerData par2ServerData) { - this.servers.set(par1, par2ServerData); + */ } public void freeServerIcons() { - for(ServerData dat : servers) { + for(ServerData dat : allServers) { if(dat.currentQuery != null && dat.currentQuery.isQueryOpen()) { dat.currentQuery.close(); }