Fixed corrupt color code, fixed 'hide_down' flag for default server list

This commit is contained in:
LAX1DUDE 2022-04-15 14:53:30 -07:00
parent 5e17fe9cc0
commit 632fc4bc5d
6 changed files with 37 additions and 20 deletions

View File

@ -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<Character, ChatColor> 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<Character, ChatColor>();
for (final ChatColor colour : values()) {
ChatColor.BY_CHAR.put(colour.code, colour);

View File

@ -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";

View File

@ -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;
}

View File

@ -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));
}
}

View File

@ -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;
}
/**

View File

@ -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();
}