More changes

This commit is contained in:
catfoolyou 2025-02-03 14:42:55 -05:00
parent bb5893b322
commit 8d2f369bd3
11 changed files with 272 additions and 532 deletions

Binary file not shown.

Binary file not shown.

View File

@ -1,32 +1,30 @@
package net.minecraft.src; package net.minecraft.src;
import java.io.DataInputStream; import net.lax1dude.eaglercraft.ConfigConstants;
import java.io.DataOutputStream;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.util.Collections;
import java.util.List;
import net.lax1dude.eaglercraft.EaglerAdapter; import net.lax1dude.eaglercraft.EaglerAdapter;
import org.lwjgl.input.Keyboard; import net.lax1dude.eaglercraft.GuiNetworkSettingsButton;
import net.lax1dude.eaglercraft.GuiScreenConnectOption;
import net.lax1dude.eaglercraft.GuiScreenLANConnecting;
import net.lax1dude.eaglercraft.LANServerList;
import net.lax1dude.eaglercraft.LANServerList.LanServer;
import net.lax1dude.eaglercraft.RelayServer;
public class GuiMultiplayer extends GuiScreen public class GuiMultiplayer extends GuiScreen {
{
/** Number of outstanding ThreadPollServers threads */ /** Number of outstanding ThreadPollServers threads */
private static int threadsPending; private static int threadsPending = 0;
/** Lock object for use with synchronized() */ /** Lock object for use with synchronized() */
private static Object lock = new Object(); private static Object lock = new Object();
/** /**
* A reference to the screen object that created this. Used for navigating between screens. * A reference to the screen object that created this. Used for navigating
* between screens.
*/ */
private GuiScreen parentScreen; private GuiScreen parentScreen;
/** Slot container for the server list */ /** Slot container for the server list */
private GuiSlotServer serverSlotContainer; private GuiSlotServer serverSlotContainer;
private ServerList internetServerList; private static ServerList internetServerList = null;
/** Index of the currently selected server */ /** Index of the currently selected server */
private int selectedServer = -1; private int selectedServer = -1;
@ -39,38 +37,43 @@ public class GuiMultiplayer extends GuiScreen
private GuiButton buttonDelete; private GuiButton buttonDelete;
/** The 'Delete' button was clicked */ /** The 'Delete' button was clicked */
private boolean deleteClicked; private boolean deleteClicked = false;
/** The 'Add server' button was clicked */ /** The 'Add server' button was clicked */
private boolean addClicked; private boolean addClicked = false;
/** The 'Edit' button was clicked */ /** The 'Edit' button was clicked */
private boolean editClicked; private boolean editClicked = false;
/** The 'Direct Connect' button was clicked */ /** The 'Direct Connect' button was clicked */
private boolean directClicked; private boolean directClicked = false;
/** This GUI's lag tooltip text or null if no lag icon is being hovered. */ /** This GUI's lag tooltip text or null if no lag icon is being hovered. */
private String lagTooltip; private String lagTooltip = null;
/** Instance of ServerData. */ /** Instance of ServerData. */
private ServerData theServerData; private ServerData theServerData = null;
private LanServerList localNetworkServerList;
private ThreadLanServerFind localServerFindThread; private boolean hasInitialRefresh = false;
/** How many ticks this Gui is already opened */ /** How many ticks this Gui is already opened */
private int ticksOpened; private int ticksOpened;
private boolean field_74024_A; private static LANServerList lanServerList = null;
private List listofLanServers = Collections.emptyList();
private static long lastCooldown = 0l; private static long lastCooldown = 0l;
private static long lastRefresh = 0l; private static long lastRefresh = 0l;
private static int cooldownTimer = 0; private static int cooldownTimer = 0;
private static boolean isLockedOut = false; private static boolean isLockedOut = false;
public GuiMultiplayer(GuiScreen par1GuiScreen) private final GuiNetworkSettingsButton relaysButton;
{
public GuiMultiplayer(GuiScreen par1GuiScreen) {
this.parentScreen = par1GuiScreen; this.parentScreen = par1GuiScreen;
this.relaysButton = new GuiNetworkSettingsButton(this);
isLockedOut = false;
if(lanServerList != null) {
lanServerList.forceRefresh();
}
} }
public static void tickRefreshCooldown() { public static void tickRefreshCooldown() {
@ -103,32 +106,28 @@ public class GuiMultiplayer extends GuiScreen
/** /**
* Adds the buttons (and other controls) to the screen in question. * Adds the buttons (and other controls) to the screen in question.
*/ */
public void initGui() public void initGui() {
{ EaglerAdapter.enableRepeatEvents(true);
Keyboard.enableRepeatEvents(true);
this.buttonList.clear(); this.buttonList.clear();
if (!this.field_74024_A) if (!hasInitialRefresh) {
{ hasInitialRefresh = true;
this.field_74024_A = true; if(internetServerList == null) {
this.internetServerList = new ServerList(this.mc); internetServerList = new ServerList(this.mc);
this.internetServerList.loadServerList(); }else {
this.localNetworkServerList = new LanServerList(); if(testIfCanRefresh()) {
internetServerList.loadServerList();
try }
{ }
this.localServerFindThread = new ThreadLanServerFind(this.localNetworkServerList); if(lanServerList == null) {
this.localServerFindThread.start(); lanServerList = new LANServerList();
}else {
if(testIfCanRefresh()) {
lanServerList.forceRefresh();
} }
catch (Exception var2)
{
this.mc.getLogAgent().logWarning("Unable to start LAN server detection: " + var2.getMessage());
} }
this.serverSlotContainer = new GuiSlotServer(this); this.serverSlotContainer = new GuiSlotServer(this);
} } else {
else
{
this.serverSlotContainer.func_77207_a(this.width, this.height, 32, this.height - 64); this.serverSlotContainer.func_77207_a(this.width, this.height, 32, this.height - 64);
} }
@ -138,52 +137,45 @@ public class GuiMultiplayer extends GuiScreen
/** /**
* Populate the GuiScreen controlList * Populate the GuiScreen controlList
*/ */
public void initGuiControls() public void initGuiControls() {
{ StringTranslate var1 = StringTranslate.getInstance();
this.buttonList.add(this.field_96289_p = new GuiButton(7, this.width / 2 - 154, this.height - 28, 70, 20, StatCollector.translateToLocal("selectServer.edit"))); this.buttonList.add(this.field_96289_p = new GuiButton(7, this.width / 2 - 154, this.height - 28, 70, 20, var1.translateKey("selectServer.edit")));
this.buttonList.add(this.buttonDelete = new GuiButton(2, this.width / 2 - 74, this.height - 28, 70, 20, StatCollector.translateToLocal("selectServer.delete"))); this.buttonList.add(this.buttonDelete = new GuiButton(2, this.width / 2 - 74, this.height - 28, 70, 20, var1.translateKey("selectServer.delete")));
this.buttonList.add(this.buttonSelect = new GuiButton(1, this.width / 2 - 154, this.height - 52, 100, 20, StatCollector.translateToLocal("selectServer.select"))); this.buttonList.add(this.buttonSelect = new GuiButton(1, this.width / 2 - 154, this.height - 52, 100, 20, var1.translateKey("selectServer.select")));
this.buttonList.add(new GuiButton(4, this.width / 2 - 50, this.height - 52, 100, 20, StatCollector.translateToLocal("selectServer.direct"))); this.buttonList.add(new GuiButton(4, this.width / 2 - 50, this.height - 52, 100, 20, var1.translateKey("selectServer.direct")));
this.buttonList.add(new GuiButton(3, this.width / 2 + 4 + 50, this.height - 52, 100, 20, StatCollector.translateToLocal("selectServer.add"))); this.buttonList.add(new GuiButton(3, this.width / 2 + 4 + 50, this.height - 52, 100, 20, var1.translateKey("selectServer.add")));
this.buttonList.add(new GuiButton(8, this.width / 2 + 4, this.height - 28, 70, 20, StatCollector.translateToLocal("selectServer.refresh"))); this.buttonList.add(new GuiButton(8, this.width / 2 + 4, this.height - 28, 70, 20, var1.translateKey("selectServer.refresh")));
this.buttonList.add(new GuiButton(0, this.width / 2 + 4 + 76, this.height - 28, 75, 20, StatCollector.translateToLocal("gui.cancel"))); this.buttonList.add(new GuiButton(0, this.width / 2 + 4 + 76, this.height - 28, 75, 20, var1.translateKey("gui.cancel")));
boolean var1 = this.selectedServer >= 0 && this.selectedServer < this.serverSlotContainer.getSize(); boolean var2 = this.selectedServer >= 0 && this.selectedServer < this.serverSlotContainer.getSize();
this.buttonSelect.enabled = var1; this.buttonSelect.enabled = var2;
this.field_96289_p.enabled = var1; this.field_96289_p.enabled = var2;
this.buttonDelete.enabled = var1; this.buttonDelete.enabled = var2;
} }
/** /**
* Called from the main game loop to update the screen. * Called from the main game loop to update the screen.
*/ */
public void updateScreen() public void updateScreen() {
{
super.updateScreen(); super.updateScreen();
internetServerList.updateServerPing();
lanServerList.update();
++this.ticksOpened; ++this.ticksOpened;
if (this.localNetworkServerList.getWasUpdated())
{
this.listofLanServers = this.localNetworkServerList.getLanServers();
this.localNetworkServerList.setWasNotUpdated();
}
} }
/** /**
* Called when the screen is unloaded. Used to disable keyboard repeat events * Called when the screen is unloaded. Used to disable keyboard repeat events
*/ */
public void onGuiClosed() public void onGuiClosed() {
{ EaglerAdapter.enableRepeatEvents(false);
Keyboard.enableRepeatEvents(false);
if (this.localServerFindThread != null)
{
this.localServerFindThread.interrupt();
this.localServerFindThread = null;
} }
public ServerData getTheServerData() {
return this.theServerData = new ServerData(StatCollector.translateToLocal("selectServer.defaultName"), "", false);
} }
/** /**
* Fired when a control is clicked. This is the equivalent of ActionListener.actionPerformed(ActionEvent e). * Fired when a control is clicked. This is the equivalent of
* ActionListener.actionPerformed(ActionEvent e).
*/ */
protected void actionPerformed(GuiButton par1GuiButton) { protected void actionPerformed(GuiButton par1GuiButton) {
if (par1GuiButton.enabled) { if (par1GuiButton.enabled) {
@ -204,8 +196,7 @@ public class GuiMultiplayer extends GuiScreen
this.joinServer(this.selectedServer); this.joinServer(this.selectedServer);
} else if (par1GuiButton.id == 4) { } else if (par1GuiButton.id == 4) {
this.directClicked = true; this.directClicked = true;
//this.mc.displayGuiScreen(new GuiScreenConnectOption(this)); // FIX THIS this.mc.displayGuiScreen(new GuiScreenConnectOption(this));
System.out.println("fuck");
} else if (par1GuiButton.id == 3) { } else if (par1GuiButton.id == 3) {
this.addClicked = true; this.addClicked = true;
this.mc.displayGuiScreen(new GuiScreenAddServer(this, this.theServerData = new ServerData(StatCollector.translateToLocal("selectServer.defaultName"), "", false))); this.mc.displayGuiScreen(new GuiScreenAddServer(this, this.theServerData = new ServerData(StatCollector.translateToLocal("selectServer.defaultName"), "", false)));
@ -229,57 +220,44 @@ public class GuiMultiplayer extends GuiScreen
} }
} }
public void confirmClicked(boolean par1, int par2) public void confirmClicked(boolean par1, int par2) {
{ if (this.deleteClicked) {
if (this.deleteClicked)
{
this.deleteClicked = false; this.deleteClicked = false;
if (par1) if (par1) {
{ internetServerList.removeServerData(par2);
this.internetServerList.removeServerData(par2); internetServerList.saveServerList();
this.internetServerList.saveServerList();
this.selectedServer = -1; this.selectedServer = -1;
} }
this.mc.displayGuiScreen(this); this.mc.displayGuiScreen(this);
} } else if (this.directClicked) {
else if (this.directClicked)
{
this.directClicked = false; this.directClicked = false;
if (par1) if (par1) {
{
this.connectToServer(this.theServerData); this.connectToServer(this.theServerData);
} } else {
else
{
this.mc.displayGuiScreen(this); this.mc.displayGuiScreen(this);
} }
} } else if (this.addClicked) {
else if (this.addClicked)
{
this.addClicked = false; this.addClicked = false;
if (par1) if (par1) {
{ internetServerList.addServerData(this.theServerData);
this.internetServerList.addServerData(this.theServerData); internetServerList.saveServerList();
this.internetServerList.saveServerList();
this.selectedServer = -1; this.selectedServer = -1;
} }
this.mc.displayGuiScreen(this); this.mc.displayGuiScreen(this);
} } else if (this.editClicked) {
else if (this.editClicked)
{
this.editClicked = false; this.editClicked = false;
if (par1) if (par1) {
{
ServerData var3 = this.internetServerList.getServerData(this.selectedServer); ServerData var3 = this.internetServerList.getServerData(this.selectedServer);
var3.serverName = this.theServerData.serverName; var3.serverName = this.theServerData.serverName;
var3.serverIP = this.theServerData.serverIP; var3.serverIP = this.theServerData.serverIP;
var3.setHideAddress(this.theServerData.isHidingAddress()); var3.setHideAddress(this.theServerData.isHidingAddress());
var3.pingSentTime = -1l;
this.internetServerList.saveServerList(); this.internetServerList.saveServerList();
} }
@ -288,71 +266,97 @@ public class GuiMultiplayer extends GuiScreen
} }
/** /**
* Fired when a key is typed. This is the equivalent of KeyListener.keyTyped(KeyEvent e). * Fired when a key is typed. This is the equivalent of
* KeyListener.keyTyped(KeyEvent e).
*/ */
protected void keyTyped(char par1, int par2) protected void keyTyped(char par1, int par2) {
{
int var3 = this.selectedServer; int var3 = this.selectedServer;
if (par2 == 59) if (par2 == 59) {
{
this.mc.gameSettings.hideServerAddress = !this.mc.gameSettings.hideServerAddress; this.mc.gameSettings.hideServerAddress = !this.mc.gameSettings.hideServerAddress;
this.mc.gameSettings.saveOptions(); this.mc.gameSettings.saveOptions();
} } else {
else if (isShiftKeyDown() && par2 == 200) {
{ if (var3 > ServerList.forcedServers.size() && var3 < this.internetServerList.countServers()) {
if (isShiftKeyDown() && par2 == 200)
{
if (var3 > 0 && var3 < this.internetServerList.countServers())
{
this.internetServerList.swapServers(var3, var3 - 1); this.internetServerList.swapServers(var3, var3 - 1);
--this.selectedServer; --this.selectedServer;
if (var3 < this.internetServerList.countServers() - 1) if (var3 < this.internetServerList.countServers() - 1) {
{
this.serverSlotContainer.func_77208_b(-this.serverSlotContainer.slotHeight); this.serverSlotContainer.func_77208_b(-this.serverSlotContainer.slotHeight);
} }
} }
} } else if (isShiftKeyDown() && par2 == 208) {
else if (isShiftKeyDown() && par2 == 208) if (var3 < this.internetServerList.countServers() - 1) {
{
if (var3 >= 0 & var3 < this.internetServerList.countServers() - 1)
{
this.internetServerList.swapServers(var3, var3 + 1); this.internetServerList.swapServers(var3, var3 + 1);
++this.selectedServer; ++this.selectedServer;
if (var3 > 0) if (var3 > 0) {
{
this.serverSlotContainer.func_77208_b(this.serverSlotContainer.slotHeight); this.serverSlotContainer.func_77208_b(this.serverSlotContainer.slotHeight);
} }
} }
} } else if (par1 == 13) {
else if (par2 != 28 && par2 != 156) this.actionPerformed((GuiButton) this.buttonList.get(2));
{ } else {
super.keyTyped(par1, par2); super.keyTyped(par1, par2);
} }
else
{
this.actionPerformed((GuiButton)this.buttonList.get(2));
}
} }
} }
/** /**
* Draws the screen and all the components in it. * Draws the screen and all the components in it.
*/ */
public void drawScreen(int par1, int par2, float par3) public void drawScreen(int par1, int par2, float par3) {
{
this.lagTooltip = null; this.lagTooltip = null;
StringTranslate var4 = StringTranslate.getInstance();
this.drawDefaultBackground(); this.drawDefaultBackground();
boolean showAyonull = ConfigConstants.ayonullTitle != null && ConfigConstants.ayonullLink != null;
this.serverSlotContainer.top = showAyonull ? 42 : 32;
this.serverSlotContainer.drawScreen(par1, par2, par3); this.serverSlotContainer.drawScreen(par1, par2, par3);
this.drawCenteredString(this.fontRenderer, StatCollector.translateToLocal("multiplayer.title"), this.width / 2, 20, 16777215);
if(showAyonull) {
this.drawCenteredString(this.fontRenderer, ConfigConstants.ayonullTitle, this.width / 2, 12, 0xDDDD66);
String link = ConfigConstants.ayonullLink;
int linkWidth = fontRenderer.getStringWidth(link);
boolean mouseOver = par1 > (this.width - linkWidth) / 2 - 10 && par1 < (this.width + linkWidth) / 2 + 10 && par2 > 21 && par2 < 35;
this.drawString(this.fontRenderer, EnumChatFormatting.UNDERLINE + link, (this.width - linkWidth) / 2, 23, mouseOver ? 0xBBBBFF : 0x7777DD);
}else {
this.drawCenteredString(this.fontRenderer, var4.translateKey("multiplayer.title"), this.width / 2, 16, 16777215);
}
super.drawScreen(par1, par2, par3); super.drawScreen(par1, par2, par3);
if (this.lagTooltip != null) if (this.lagTooltip != null) {
{
this.func_74007_a(this.lagTooltip, par1, par2); this.func_74007_a(this.lagTooltip, par1, par2);
} }
if(isLockedOut) {
String canYouNot = "can you not";
int w = this.fontRenderer.getStringWidth(canYouNot);
drawRect((this.width - w - 4) / 2, this.height - 80, (this.width + w + 4) / 2, this.height - 70, 0xCC000000);
fontRenderer.drawStringWithShadow(canYouNot, (this.width - w) / 2, this.height - 79, 0xFFDD2222);
if(cooldownTimer < 3) {
isLockedOut = false;
}
}
relaysButton.drawScreen(par1, par2);
}
protected void mouseClicked(int par1, int par2, int par3) {
if (par3 == 0 && ConfigConstants.ayonullTitle != null && ConfigConstants.ayonullLink != null) {
int linkWidth = fontRenderer.getStringWidth(ConfigConstants.ayonullLink);
boolean mouseOver = par1 > (this.width - linkWidth) / 2 - 10 && par1 < (this.width + linkWidth) / 2 + 10 && par2 > 21 && par2 < 35;
if(mouseOver) {
EaglerAdapter.openLink(ConfigConstants.ayonullLink);
return;
}
}
relaysButton.mouseClicked(par1, par2, par3);
super.mouseClicked(par1, par2, par3);
} }
/** /**
@ -364,168 +368,48 @@ public class GuiMultiplayer extends GuiScreen
} else { } else {
par1 -= internetServerList.countServers(); par1 -= internetServerList.countServers();
/*if (par1 < lanServerList.countServers()) { // FIX THIS (later maybe) if (par1 < lanServerList.countServers()) {
LanServer var2 = lanServerList.getServer(par1); LanServer var2 = lanServerList.getServer(par1);
//connectToLAN("Connecting to '" + var2.getLanServerMotd() + "'...", var2.getLanServerCode(), var2.getLanServerRelay()); connectToLAN("Connecting to '" + var2.getLanServerMotd() + "'...", var2.getLanServerCode(), var2.getLanServerRelay());
}*/ }
} }
} }
private void connectToServer(ServerData par1ServerData) private void connectToServer(ServerData par1ServerData) {
{
this.mc.displayGuiScreen(new GuiConnecting(this, this.mc, par1ServerData)); this.mc.displayGuiScreen(new GuiConnecting(this, this.mc, par1ServerData));
} }
public ServerData getTheServerData() { private void connectToLAN(String text, String code, RelayServer uri) {
return this.theServerData = new ServerData(StatCollector.translateToLocal("selectServer.defaultName"), "", false); this.mc.loadingScreen.resetProgresAndWorkingMessage(text);
this.mc.displayGuiScreen(new GuiScreenLANConnecting(this, code, uri));
} }
private static void func_74017_b(ServerData par0ServerData) throws IOException protected void func_74007_a(String par1Str, int par2, int par3) {
{ if (par1Str != null) {
ServerAddress var1 = ServerAddress.func_78860_a(par0ServerData.serverIP); if(par1Str.indexOf('\n') >= 0) {
Socket var2 = null; String[] strs = par1Str.split("\n");
DataInputStream var3 = null; int var6 = 0;
DataOutputStream var4 = null; int full = 0;
for(int i = 0; i < strs.length; ++i) {
try strs[i] = strs[i].replace('\r', ' ').trim();
{ if(strs[i].length() > 0) {
var2 = new Socket(); int w = this.fontRenderer.getStringWidth(strs[i]);
var2.setSoTimeout(3000); if(w > var6) {
var2.setTcpNoDelay(true); var6 = w;
var2.setTrafficClass(18);
var2.connect(new InetSocketAddress(var1.getIP(), var1.getPort()), 3000);
var3 = new DataInputStream(var2.getInputStream());
var4 = new DataOutputStream(var2.getOutputStream());
Packet254ServerPing var5 = new Packet254ServerPing(78, var1.getIP(), var1.getPort());
var4.writeByte(var5.getPacketId());
var5.writePacketData(var4);
if (var3.read() != 255)
{
throw new IOException("Bad message");
} }
++full;
String var6 = Packet.readString(var3, 256);
char[] var7 = var6.toCharArray();
for (int var8 = 0; var8 < var7.length; ++var8)
{
if (var7[var8] != 167 && var7[var8] != 0 && ChatAllowedCharacters.allowedCharacters.indexOf(var7[var8]) < 0)
{
var7[var8] = 63;
} }
} }
int var4 = par2 + 12;
var6 = new String(var7); int var5 = par3 - 12;
int var9; this.drawGradientRect(var4 - 3, var5 - 3, var4 + var6 + 3, var5 + full * 9 + 2, -1073741824, -1073741824);
int var10; full = 0;
String[] var27; for(int i = 0; i < strs.length; ++i) {
if(strs[i].length() > 0) {
if (var6.startsWith("\u00a7") && var6.length() > 1) this.fontRenderer.drawStringWithShadow(strs[i], var4, var5 + 9 * full++, -1);
{
var27 = var6.substring(1).split("\u0000");
if (MathHelper.parseIntWithDefault(var27[0], 0) == 1)
{
par0ServerData.serverMOTD = var27[3];
par0ServerData.field_82821_f = MathHelper.parseIntWithDefault(var27[1], par0ServerData.field_82821_f);
par0ServerData.gameVersion = var27[2];
var9 = MathHelper.parseIntWithDefault(var27[4], 0);
var10 = MathHelper.parseIntWithDefault(var27[5], 0);
if (var9 >= 0 && var10 >= 0)
{
par0ServerData.populationInfo = EnumChatFormatting.GRAY + "" + var9 + "" + EnumChatFormatting.DARK_GRAY + "/" + EnumChatFormatting.GRAY + var10;
}
else
{
par0ServerData.populationInfo = "" + EnumChatFormatting.DARK_GRAY + "???";
} }
} }
else }else {
{
par0ServerData.gameVersion = "???";
par0ServerData.serverMOTD = "" + EnumChatFormatting.DARK_GRAY + "???";
par0ServerData.field_82821_f = 79;
par0ServerData.populationInfo = "" + EnumChatFormatting.DARK_GRAY + "???";
}
}
else
{
var27 = var6.split("\u00a7");
var6 = var27[0];
var9 = -1;
var10 = -1;
try
{
var9 = Integer.parseInt(var27[1]);
var10 = Integer.parseInt(var27[2]);
}
catch (Exception var25)
{
;
}
par0ServerData.serverMOTD = EnumChatFormatting.GRAY + var6;
if (var9 >= 0 && var10 > 0)
{
par0ServerData.populationInfo = EnumChatFormatting.GRAY + "" + var9 + "" + EnumChatFormatting.DARK_GRAY + "/" + EnumChatFormatting.GRAY + var10;
}
else
{
par0ServerData.populationInfo = "" + EnumChatFormatting.DARK_GRAY + "???";
}
par0ServerData.gameVersion = "1.3";
par0ServerData.field_82821_f = 77;
}
}
finally
{
try
{
if (var3 != null)
{
var3.close();
}
}
catch (Throwable var24)
{
;
}
try
{
if (var4 != null)
{
var4.close();
}
}
catch (Throwable var23)
{
;
}
try
{
if (var2 != null)
{
var2.close();
}
}
catch (Throwable var22)
{
;
}
}
}
protected void func_74007_a(String par1Str, int par2, int par3)
{
if (par1Str != null)
{
int var4 = par2 + 12; int var4 = par2 + 12;
int var5 = par3 - 12; int var5 = par3 - 12;
int var6 = this.fontRenderer.getStringWidth(par1Str); int var6 = this.fontRenderer.getStringWidth(par1Str);
@ -533,91 +417,78 @@ public class GuiMultiplayer extends GuiScreen
this.fontRenderer.drawStringWithShadow(par1Str, var4, var5, -1); this.fontRenderer.drawStringWithShadow(par1Str, var4, var5, -1);
} }
} }
static ServerList getInternetServerList(GuiMultiplayer par0GuiMultiplayer)
{
return par0GuiMultiplayer.internetServerList;
} }
static List getListOfLanServers(GuiMultiplayer par0GuiMultiplayer) static ServerList getInternetServerList(GuiMultiplayer par0GuiMultiplayer) {
{ return internetServerList;
return par0GuiMultiplayer.listofLanServers;
} }
static int getSelectedServer(GuiMultiplayer par0GuiMultiplayer) static LANServerList getListOfLanServers(GuiMultiplayer par0GuiMultiplayer) {
{ return lanServerList;
}
static int getSelectedServer(GuiMultiplayer par0GuiMultiplayer) {
int i = internetServerList.countServers() + lanServerList.countServers();
if(par0GuiMultiplayer.selectedServer >= i && par0GuiMultiplayer.selectedServer > 0) {
par0GuiMultiplayer.selectedServer = i - 1;
}
return par0GuiMultiplayer.selectedServer; return par0GuiMultiplayer.selectedServer;
} }
static int getAndSetSelectedServer(GuiMultiplayer par0GuiMultiplayer, int par1) static int getAndSetSelectedServer(GuiMultiplayer par0GuiMultiplayer, int par1) {
{
return par0GuiMultiplayer.selectedServer = par1; return par0GuiMultiplayer.selectedServer = par1;
} }
/** /**
* Return buttonSelect GuiButton * Return buttonSelect GuiButton
*/ */
static GuiButton getButtonSelect(GuiMultiplayer par0GuiMultiplayer) static GuiButton getButtonSelect(GuiMultiplayer par0GuiMultiplayer) {
{
return par0GuiMultiplayer.buttonSelect; return par0GuiMultiplayer.buttonSelect;
} }
/** /**
* Return buttonEdit GuiButton * Return buttonEdit GuiButton
*/ */
static GuiButton getButtonEdit(GuiMultiplayer par0GuiMultiplayer) static GuiButton getButtonEdit(GuiMultiplayer par0GuiMultiplayer) {
{
return par0GuiMultiplayer.field_96289_p; return par0GuiMultiplayer.field_96289_p;
} }
/** /**
* Return buttonDelete GuiButton * Return buttonDelete GuiButton
*/ */
static GuiButton getButtonDelete(GuiMultiplayer par0GuiMultiplayer) static GuiButton getButtonDelete(GuiMultiplayer par0GuiMultiplayer) {
{
return par0GuiMultiplayer.buttonDelete; return par0GuiMultiplayer.buttonDelete;
} }
static void func_74008_b(GuiMultiplayer par0GuiMultiplayer, int par1) static void func_74008_b(GuiMultiplayer par0GuiMultiplayer, int par1) {
{
par0GuiMultiplayer.joinServer(par1); par0GuiMultiplayer.joinServer(par1);
} }
static int getTicksOpened(GuiMultiplayer par0GuiMultiplayer) static int getTicksOpened(GuiMultiplayer par0GuiMultiplayer) {
{
return par0GuiMultiplayer.ticksOpened; return par0GuiMultiplayer.ticksOpened;
} }
/** /**
* Returns the lock object for use with synchronized() * Returns the lock object for use with synchronized()
*/ */
static Object getLock() static Object getLock() {
{
return lock; return lock;
} }
static int getThreadsPending() static int getThreadsPending() {
{
return threadsPending; return threadsPending;
} }
static int increaseThreadsPending() static int increaseThreadsPending() {
{
return threadsPending++; return threadsPending++;
} }
static void func_82291_a(ServerData par0ServerData) throws IOException static int decreaseThreadsPending() {
{
func_74017_b(par0ServerData);
}
static int decreaseThreadsPending()
{
return threadsPending--; return threadsPending--;
} }
static String getAndSetLagTooltip(GuiMultiplayer par0GuiMultiplayer, String par1Str) static String getAndSetLagTooltip(GuiMultiplayer par0GuiMultiplayer, String par1Str) {
{
return par0GuiMultiplayer.lagTooltip = par1Str; return par0GuiMultiplayer.lagTooltip = par1Str;
} }
} }

View File

@ -11,7 +11,7 @@ public abstract class GuiSlot
/** /**
* The width of the GuiScreen. Affects the container rendering, but not the overlays. * The width of the GuiScreen. Affects the container rendering, but not the overlays.
*/ */
private int width; int width;
/** /**
* The height of the GuiScreen. Affects the container rendering, but not the overlays or the scrolling. * The height of the GuiScreen. Affects the container rendering, but not the overlays or the scrolling.

View File

@ -1,53 +1,49 @@
package net.minecraft.src; package net.minecraft.src;
import net.lax1dude.eaglercraft.EaglerAdapter; import net.lax1dude.eaglercraft.EaglerAdapter;
import net.lax1dude.eaglercraft.IntegratedServer;
import net.lax1dude.eaglercraft.LANServerList.LanServer;
import net.lax1dude.eaglercraft.TextureLocation; import net.lax1dude.eaglercraft.TextureLocation;
import net.lax1dude.eaglercraft.EaglerAdapter;
import net.lax1dude.eaglercraft.adapter.Tessellator; import net.lax1dude.eaglercraft.adapter.Tessellator;
import net.minecraft.src.Minecraft;
class GuiSlotServer extends GuiSlot class GuiSlotServer extends GuiSlot {
{
/** Instance to the GUI this list is on. */ /** Instance to the GUI this list is on. */
final GuiMultiplayer parentGui; final GuiMultiplayer parentGui;
private static final TextureLocation defaultServerIcon = new TextureLocation("/gui/unknown_pack.png"); private static final TextureLocation defaultServerIcon = new TextureLocation("/gui/unknown_pack.png");
public GuiSlotServer(GuiMultiplayer par1GuiMultiplayer) public GuiSlotServer(GuiMultiplayer par1GuiMultiplayer) {
{
super(par1GuiMultiplayer.mc, par1GuiMultiplayer.width, par1GuiMultiplayer.height, 32, par1GuiMultiplayer.height - 64, 36); super(par1GuiMultiplayer.mc, par1GuiMultiplayer.width, par1GuiMultiplayer.height, 32, par1GuiMultiplayer.height - 64, 36);
this.parentGui = par1GuiMultiplayer; this.parentGui = par1GuiMultiplayer;
this.width = 128;
} }
/** /**
* Gets the size of the current slot list. * Gets the size of the current slot list.
*/ */
protected int getSize() protected int getSize() {
{ return GuiMultiplayer.getInternetServerList(this.parentGui).countServers() + GuiMultiplayer.getListOfLanServers(this.parentGui).countServers() + 1;
return GuiMultiplayer.getInternetServerList(this.parentGui).countServers() + GuiMultiplayer.getListOfLanServers(this.parentGui).size() + 1;
} }
/** /**
* the element in the slot that was clicked, boolean for wether it was double clicked or not * the element in the slot that was clicked, boolean for wether it was double
* clicked or not
*/ */
protected void elementClicked(int par1, boolean par2) protected void elementClicked(int par1, boolean par2) {
{ if (par1 < GuiMultiplayer.getInternetServerList(this.parentGui).countServers() + GuiMultiplayer.getListOfLanServers(this.parentGui).countServers()) {
if (par1 < GuiMultiplayer.getInternetServerList(this.parentGui).countServers() + GuiMultiplayer.getListOfLanServers(this.parentGui).size())
{
int var3 = GuiMultiplayer.getSelectedServer(this.parentGui); int var3 = GuiMultiplayer.getSelectedServer(this.parentGui);
GuiMultiplayer.getAndSetSelectedServer(this.parentGui, par1); GuiMultiplayer.getAndSetSelectedServer(this.parentGui, par1);
ServerData var4 = GuiMultiplayer.getInternetServerList(this.parentGui).countServers() > par1 ? GuiMultiplayer.getInternetServerList(this.parentGui).getServerData(par1) : null; ServerData var4 = GuiMultiplayer.getInternetServerList(this.parentGui).countServers() > par1 ? GuiMultiplayer.getInternetServerList(this.parentGui).getServerData(par1) : null;
boolean var5 = GuiMultiplayer.getSelectedServer(this.parentGui) >= 0 && GuiMultiplayer.getSelectedServer(this.parentGui) < this.getSize() && (var4 == null || var4.field_82821_f == 78); boolean var5 = GuiMultiplayer.getSelectedServer(this.parentGui) >= 0 && GuiMultiplayer.getSelectedServer(this.parentGui) < this.getSize() && (var4 == null || var4.field_82821_f == 61);
boolean var6 = GuiMultiplayer.getSelectedServer(this.parentGui) < GuiMultiplayer.getInternetServerList(this.parentGui).countServers(); boolean var6 = GuiMultiplayer.getSelectedServer(this.parentGui) < GuiMultiplayer.getInternetServerList(this.parentGui).countServers();
GuiMultiplayer.getButtonSelect(this.parentGui).enabled = var5; GuiMultiplayer.getButtonSelect(this.parentGui).enabled = var5;
GuiMultiplayer.getButtonEdit(this.parentGui).enabled = var6; GuiMultiplayer.getButtonEdit(this.parentGui).enabled = var6;
GuiMultiplayer.getButtonDelete(this.parentGui).enabled = var6; GuiMultiplayer.getButtonDelete(this.parentGui).enabled = var6;
if (par2 && var5) if (par2 && var5) {
{
GuiMultiplayer.func_74008_b(this.parentGui, par1); GuiMultiplayer.func_74008_b(this.parentGui, par1);
} } else if (var6 && GuiScreen.isShiftKeyDown() && var3 > ServerList.forcedServers.size() && var3 < GuiMultiplayer.getInternetServerList(this.parentGui).countServers()) {
else if (var6 && GuiScreen.isShiftKeyDown() && var3 >= 0 && var3 < GuiMultiplayer.getInternetServerList(this.parentGui).countServers())
{
GuiMultiplayer.getInternetServerList(this.parentGui).swapServers(var3, GuiMultiplayer.getSelectedServer(this.parentGui)); GuiMultiplayer.getInternetServerList(this.parentGui).swapServers(var3, GuiMultiplayer.getSelectedServer(this.parentGui));
} }
} }
@ -56,63 +52,66 @@ class GuiSlotServer extends GuiSlot
/** /**
* returns true if the element passed in is currently selected * returns true if the element passed in is currently selected
*/ */
protected boolean isSelected(int par1) protected boolean isSelected(int par1) {
{
return par1 == GuiMultiplayer.getSelectedServer(this.parentGui); return par1 == GuiMultiplayer.getSelectedServer(this.parentGui);
} }
/** /**
* return the height of the content being scrolled * return the height of the content being scrolled
*/ */
protected int getContentHeight() protected int getContentHeight() {
{
return this.getSize() * 36; return this.getSize() * 36;
} }
protected void drawBackground() protected void drawBackground() {
{
this.parentGui.drawDefaultBackground(); this.parentGui.drawDefaultBackground();
} }
protected void drawSlot(int par1, int par2, int par3, int par4, Tessellator par5Tessellator) protected void drawSlot(int par1, int par2, int par3, int par4, Tessellator par5Tessellator) {
{ if (par1 < GuiMultiplayer.getInternetServerList(this.parentGui).countServers()) {
if (par1 < GuiMultiplayer.getInternetServerList(this.parentGui).countServers()) try {
{
this.func_77247_d(par1, par2, par3, par4, par5Tessellator); this.func_77247_d(par1, par2, par3, par4, par5Tessellator);
}catch(Throwable t) {
} }
else if (par1 < GuiMultiplayer.getInternetServerList(this.parentGui).countServers() + GuiMultiplayer.getListOfLanServers(this.parentGui).size()) } else if (par1 < GuiMultiplayer.getInternetServerList(this.parentGui).countServers()
{ + GuiMultiplayer.getListOfLanServers(this.parentGui).countServers()) {
try {
this.func_77248_b(par1, par2, par3, par4, par5Tessellator); this.func_77248_b(par1, par2, par3, par4, par5Tessellator);
}catch(Throwable t) {
} }
else } else {
{
this.func_77249_c(par1, par2, par3, par4, par5Tessellator); this.func_77249_c(par1, par2, par3, par4, par5Tessellator);
} }
} }
private void func_77248_b(int par1, int par2, int par3, int par4, Tessellator par5Tessellator) private void func_77248_b(int par1, int par2, int par3, int par4, Tessellator par5Tessellator) {
{ LanServer var6 = (LanServer) GuiMultiplayer.getListOfLanServers(this.parentGui)
LanServer var6 = (LanServer)GuiMultiplayer.getListOfLanServers(this.parentGui).get(par1 - GuiMultiplayer.getInternetServerList(this.parentGui).countServers()); .getServer(par1 - GuiMultiplayer.getInternetServerList(this.parentGui).countServers());
this.parentGui.drawString(this.parentGui.fontRenderer, StatCollector.translateToLocal("lanServer.title"), par2 + 2, par3 + 1, 16777215); this.parentGui.drawString(this.parentGui.fontRenderer, StatCollector.translateToLocal("lanServer.title"),
this.parentGui.drawString(this.parentGui.fontRenderer, var6.getServerMotd(), par2 + 2, par3 + 12, 8421504); par2 + 2, par3 + 1, 16777215);
this.parentGui.drawString(this.parentGui.fontRenderer, var6.getLanServerMotd(), par2 + 2, par3 + 12, 8421504);
if (this.parentGui.mc.gameSettings.hideServerAddress) if (this.parentGui.mc.gameSettings.hideServerAddress) {
{ this.parentGui.drawString(this.parentGui.fontRenderer,
this.parentGui.drawString(this.parentGui.fontRenderer, StatCollector.translateToLocal("selectServer.hiddenAddress"), par2 + 2, par3 + 12 + 11, 3158064); StatCollector.translateToLocal("selectServer.hiddenAddress"), par2 + 2, par3 + 12 + 11, 3158064);
} } else {
else this.parentGui.drawString(this.parentGui.fontRenderer, var6.getLanServerCode(), par2 + 2, par3 + 12 + 11,
{ 0x558822);
this.parentGui.drawString(this.parentGui.fontRenderer, var6.getServerIpPort(), par2 + 2, par3 + 12 + 11, 3158064);
} }
} }
private void func_77249_c(int par1, int par2, int par3, int par4, Tessellator par5Tessellator) private void func_77249_c(int par1, int par2, int par3, int par4, Tessellator par5Tessellator) {
{ if(IntegratedServer.relayManager.count() == 0) {
this.parentGui.drawCenteredString(this.parentGui.fontRenderer, StatCollector.translateToLocal("lanServer.scanning"), this.parentGui.width / 2, par3 + 1, 16777215); this.parentGui.drawCenteredString(this.parentGui.fontRenderer,
StatCollector.translateToLocal("noRelay.noRelay1"), this.parentGui.width / 2, par3 + 6, 16777215);
this.parentGui.drawCenteredString(this.parentGui.fontRenderer,
StatCollector.translateToLocal("noRelay.noRelay2"), this.parentGui.width / 2, par3 + 18, 0xFFAAAAAA);
}else {
this.parentGui.drawCenteredString(this.parentGui.fontRenderer,
StatCollector.translateToLocal("lanServer.scanning"), this.parentGui.width / 2, par3 + 6, 16777215);
String var6; String var6;
switch (GuiMultiplayer.getTicksOpened(this.parentGui) / 3 % 4) switch (GuiMultiplayer.getTicksOpened(this.parentGui) / 3 % 4) {
{
case 0: case 0:
default: default:
var6 = "O o o"; var6 = "O o o";
@ -127,7 +126,8 @@ class GuiSlotServer extends GuiSlot
var6 = "o o O"; var6 = "o o O";
} }
this.parentGui.drawCenteredString(this.parentGui.fontRenderer, var6, this.parentGui.width / 2, par3 + 12, 8421504); this.parentGui.drawCenteredString(this.parentGui.fontRenderer, var6, this.parentGui.width / 2, par3 + 18, 8421504);
}
} }
private static final TextureLocation icons = new TextureLocation("/gui/icons.png"); private static final TextureLocation icons = new TextureLocation("/gui/icons.png");

View File

@ -1,131 +0,0 @@
package net.minecraft.src;
import java.io.IOException;
import java.net.ConnectException;
import java.net.SocketTimeoutException;
import java.net.UnknownHostException;
class ThreadPollServers extends Thread
{
/** An Instnace of ServerData. */
final ServerData pollServersServerData;
/** Slot container for the server list */
final GuiSlotServer serverSlotContainer;
ThreadPollServers(GuiSlotServer par1GuiSlotServer, ServerData par2ServerData)
{
this.serverSlotContainer = par1GuiSlotServer;
this.pollServersServerData = par2ServerData;
}
public void run()
{
boolean var27 = false;
label183:
{
label184:
{
label185:
{
label186:
{
label187:
{
try
{
var27 = true;
this.pollServersServerData.serverMOTD = EnumChatFormatting.DARK_GRAY + "Polling..";
long var1 = System.nanoTime();
GuiMultiplayer.func_82291_a(this.pollServersServerData);
long var3 = System.nanoTime();
this.pollServersServerData.pingToServer = (var3 - var1) / 1000000L;
var27 = false;
break label183;
}
catch (UnknownHostException var35)
{
this.pollServersServerData.pingToServer = -1L;
this.pollServersServerData.serverMOTD = EnumChatFormatting.DARK_RED + "Can\'t resolve hostname";
var27 = false;
break label184;
}
catch (SocketTimeoutException var36)
{
this.pollServersServerData.pingToServer = -1L;
this.pollServersServerData.serverMOTD = EnumChatFormatting.DARK_RED + "Can\'t reach server";
var27 = false;
}
catch (ConnectException var37)
{
this.pollServersServerData.pingToServer = -1L;
this.pollServersServerData.serverMOTD = EnumChatFormatting.DARK_RED + "Can\'t reach server";
var27 = false;
break label187;
}
catch (IOException var38)
{
this.pollServersServerData.pingToServer = -1L;
this.pollServersServerData.serverMOTD = EnumChatFormatting.DARK_RED + "Communication error";
var27 = false;
break label186;
}
catch (Exception var39)
{
this.pollServersServerData.pingToServer = -1L;
this.pollServersServerData.serverMOTD = "ERROR: " + var39.getClass();
var27 = false;
break label185;
}
finally
{
if (var27)
{
synchronized (GuiMultiplayer.getLock())
{
GuiMultiplayer.decreaseThreadsPending();
}
}
}
synchronized (GuiMultiplayer.getLock())
{
GuiMultiplayer.decreaseThreadsPending();
return;
}
}
synchronized (GuiMultiplayer.getLock())
{
GuiMultiplayer.decreaseThreadsPending();
return;
}
}
synchronized (GuiMultiplayer.getLock())
{
GuiMultiplayer.decreaseThreadsPending();
return;
}
}
synchronized (GuiMultiplayer.getLock())
{
GuiMultiplayer.decreaseThreadsPending();
return;
}
}
synchronized (GuiMultiplayer.getLock())
{
GuiMultiplayer.decreaseThreadsPending();
return;
}
}
synchronized (GuiMultiplayer.getLock())
{
GuiMultiplayer.decreaseThreadsPending();
}
}
}