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;
import java.io.DataInputStream;
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.ConfigConstants;
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 */
private static int threadsPending;
private static int threadsPending = 0;
/** Lock object for use with synchronized() */
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;
/** Slot container for the server list */
private GuiSlotServer serverSlotContainer;
private ServerList internetServerList;
private static ServerList internetServerList = null;
/** Index of the currently selected server */
private int selectedServer = -1;
@ -39,38 +37,43 @@ public class GuiMultiplayer extends GuiScreen
private GuiButton buttonDelete;
/** The 'Delete' button was clicked */
private boolean deleteClicked;
private boolean deleteClicked = false;
/** The 'Add server' button was clicked */
private boolean addClicked;
private boolean addClicked = false;
/** The 'Edit' button was clicked */
private boolean editClicked;
private boolean editClicked = false;
/** 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. */
private String lagTooltip;
private String lagTooltip = null;
/** Instance of ServerData. */
private ServerData theServerData;
private LanServerList localNetworkServerList;
private ThreadLanServerFind localServerFindThread;
private ServerData theServerData = null;
private boolean hasInitialRefresh = false;
/** How many ticks this Gui is already opened */
private int ticksOpened;
private boolean field_74024_A;
private List listofLanServers = Collections.emptyList();
private static LANServerList lanServerList = null;
private static long lastCooldown = 0l;
private static long lastRefresh = 0l;
private static int cooldownTimer = 0;
private static boolean isLockedOut = false;
public GuiMultiplayer(GuiScreen par1GuiScreen)
{
private final GuiNetworkSettingsButton relaysButton;
public GuiMultiplayer(GuiScreen par1GuiScreen) {
this.parentScreen = par1GuiScreen;
this.relaysButton = new GuiNetworkSettingsButton(this);
isLockedOut = false;
if(lanServerList != null) {
lanServerList.forceRefresh();
}
}
public static void tickRefreshCooldown() {
@ -103,32 +106,28 @@ public class GuiMultiplayer extends GuiScreen
/**
* Adds the buttons (and other controls) to the screen in question.
*/
public void initGui()
{
Keyboard.enableRepeatEvents(true);
public void initGui() {
EaglerAdapter.enableRepeatEvents(true);
this.buttonList.clear();
if (!this.field_74024_A)
{
this.field_74024_A = true;
this.internetServerList = new ServerList(this.mc);
this.internetServerList.loadServerList();
this.localNetworkServerList = new LanServerList();
try
{
this.localServerFindThread = new ThreadLanServerFind(this.localNetworkServerList);
this.localServerFindThread.start();
if (!hasInitialRefresh) {
hasInitialRefresh = true;
if(internetServerList == null) {
internetServerList = new ServerList(this.mc);
}else {
if(testIfCanRefresh()) {
internetServerList.loadServerList();
}
}
catch (Exception var2)
{
this.mc.getLogAgent().logWarning("Unable to start LAN server detection: " + var2.getMessage());
if(lanServerList == null) {
lanServerList = new LANServerList();
}else {
if(testIfCanRefresh()) {
lanServerList.forceRefresh();
}
}
this.serverSlotContainer = new GuiSlotServer(this);
}
else
{
} else {
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
*/
public void initGuiControls()
{
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.buttonDelete = new GuiButton(2, this.width / 2 - 74, this.height - 28, 70, 20, StatCollector.translateToLocal("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(new GuiButton(4, this.width / 2 - 50, this.height - 52, 100, 20, StatCollector.translateToLocal("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(8, this.width / 2 + 4, this.height - 28, 70, 20, StatCollector.translateToLocal("selectServer.refresh")));
this.buttonList.add(new GuiButton(0, this.width / 2 + 4 + 76, this.height - 28, 75, 20, StatCollector.translateToLocal("gui.cancel")));
boolean var1 = this.selectedServer >= 0 && this.selectedServer < this.serverSlotContainer.getSize();
this.buttonSelect.enabled = var1;
this.field_96289_p.enabled = var1;
this.buttonDelete.enabled = var1;
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, var1.translateKey("selectServer.edit")));
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, var1.translateKey("selectServer.select")));
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, var1.translateKey("selectServer.add")));
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, var1.translateKey("gui.cancel")));
boolean var2 = this.selectedServer >= 0 && this.selectedServer < this.serverSlotContainer.getSize();
this.buttonSelect.enabled = var2;
this.field_96289_p.enabled = var2;
this.buttonDelete.enabled = var2;
}
/**
* Called from the main game loop to update the screen.
*/
public void updateScreen()
{
public void updateScreen() {
super.updateScreen();
internetServerList.updateServerPing();
lanServerList.update();
++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
*/
public void onGuiClosed()
{
Keyboard.enableRepeatEvents(false);
public void onGuiClosed() {
EaglerAdapter.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) {
if (par1GuiButton.enabled) {
@ -204,8 +196,7 @@ public class GuiMultiplayer extends GuiScreen
this.joinServer(this.selectedServer);
} else if (par1GuiButton.id == 4) {
this.directClicked = true;
//this.mc.displayGuiScreen(new GuiScreenConnectOption(this)); // FIX THIS
System.out.println("fuck");
this.mc.displayGuiScreen(new GuiScreenConnectOption(this));
} else if (par1GuiButton.id == 3) {
this.addClicked = true;
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)
{
if (this.deleteClicked)
{
public void confirmClicked(boolean par1, int par2) {
if (this.deleteClicked) {
this.deleteClicked = false;
if (par1)
{
this.internetServerList.removeServerData(par2);
this.internetServerList.saveServerList();
if (par1) {
internetServerList.removeServerData(par2);
internetServerList.saveServerList();
this.selectedServer = -1;
}
this.mc.displayGuiScreen(this);
}
else if (this.directClicked)
{
} else if (this.directClicked) {
this.directClicked = false;
if (par1)
{
if (par1) {
this.connectToServer(this.theServerData);
}
else
{
} else {
this.mc.displayGuiScreen(this);
}
}
else if (this.addClicked)
{
} else if (this.addClicked) {
this.addClicked = false;
if (par1)
{
this.internetServerList.addServerData(this.theServerData);
this.internetServerList.saveServerList();
if (par1) {
internetServerList.addServerData(this.theServerData);
internetServerList.saveServerList();
this.selectedServer = -1;
}
this.mc.displayGuiScreen(this);
}
else if (this.editClicked)
{
} else if (this.editClicked) {
this.editClicked = false;
if (par1)
{
if (par1) {
ServerData var3 = this.internetServerList.getServerData(this.selectedServer);
var3.serverName = this.theServerData.serverName;
var3.serverIP = this.theServerData.serverIP;
var3.setHideAddress(this.theServerData.isHidingAddress());
var3.pingSentTime = -1l;
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;
if (par2 == 59)
{
if (par2 == 59) {
this.mc.gameSettings.hideServerAddress = !this.mc.gameSettings.hideServerAddress;
this.mc.gameSettings.saveOptions();
}
else
{
if (isShiftKeyDown() && par2 == 200)
{
if (var3 > 0 && var3 < this.internetServerList.countServers())
{
} else {
if (isShiftKeyDown() && par2 == 200) {
if (var3 > ServerList.forcedServers.size() && var3 < this.internetServerList.countServers()) {
this.internetServerList.swapServers(var3, var3 - 1);
--this.selectedServer;
if (var3 < this.internetServerList.countServers() - 1)
{
if (var3 < this.internetServerList.countServers() - 1) {
this.serverSlotContainer.func_77208_b(-this.serverSlotContainer.slotHeight);
}
}
}
else if (isShiftKeyDown() && par2 == 208)
{
if (var3 >= 0 & var3 < this.internetServerList.countServers() - 1)
{
} else if (isShiftKeyDown() && par2 == 208) {
if (var3 < this.internetServerList.countServers() - 1) {
this.internetServerList.swapServers(var3, var3 + 1);
++this.selectedServer;
if (var3 > 0)
{
if (var3 > 0) {
this.serverSlotContainer.func_77208_b(this.serverSlotContainer.slotHeight);
}
}
}
else if (par2 != 28 && par2 != 156)
{
} else if (par1 == 13) {
this.actionPerformed((GuiButton) this.buttonList.get(2));
} else {
super.keyTyped(par1, par2);
}
else
{
this.actionPerformed((GuiButton)this.buttonList.get(2));
}
}
}
/**
* 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;
StringTranslate var4 = StringTranslate.getInstance();
this.drawDefaultBackground();
boolean showAyonull = ConfigConstants.ayonullTitle != null && ConfigConstants.ayonullLink != null;
this.serverSlotContainer.top = showAyonull ? 42 : 32;
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);
if (this.lagTooltip != null)
{
if (this.lagTooltip != null) {
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,260 +368,127 @@ public class GuiMultiplayer extends GuiScreen
} else {
par1 -= internetServerList.countServers();
/*if (par1 < lanServerList.countServers()) { // FIX THIS (later maybe)
if (par1 < lanServerList.countServers()) {
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));
}
public ServerData getTheServerData() {
return this.theServerData = new ServerData(StatCollector.translateToLocal("selectServer.defaultName"), "", false);
private void connectToLAN(String text, String code, RelayServer uri) {
this.mc.loadingScreen.resetProgresAndWorkingMessage(text);
this.mc.displayGuiScreen(new GuiScreenLANConnecting(this, code, uri));
}
private static void func_74017_b(ServerData par0ServerData) throws IOException
{
ServerAddress var1 = ServerAddress.func_78860_a(par0ServerData.serverIP);
Socket var2 = null;
DataInputStream var3 = null;
DataOutputStream var4 = null;
try
{
var2 = new Socket();
var2.setSoTimeout(3000);
var2.setTcpNoDelay(true);
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");
}
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;
}
}
var6 = new String(var7);
int var9;
int var10;
String[] var27;
if (var6.startsWith("\u00a7") && var6.length() > 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 + "???";
protected void func_74007_a(String par1Str, int par2, int par3) {
if (par1Str != null) {
if(par1Str.indexOf('\n') >= 0) {
String[] strs = par1Str.split("\n");
int var6 = 0;
int full = 0;
for(int i = 0; i < strs.length; ++i) {
strs[i] = strs[i].replace('\r', ' ').trim();
if(strs[i].length() > 0) {
int w = this.fontRenderer.getStringWidth(strs[i]);
if(w > var6) {
var6 = w;
}
++full;
}
}
else
{
par0ServerData.gameVersion = "???";
par0ServerData.serverMOTD = "" + EnumChatFormatting.DARK_GRAY + "???";
par0ServerData.field_82821_f = 79;
par0ServerData.populationInfo = "" + EnumChatFormatting.DARK_GRAY + "???";
int var4 = par2 + 12;
int var5 = par3 - 12;
this.drawGradientRect(var4 - 3, var5 - 3, var4 + var6 + 3, var5 + full * 9 + 2, -1073741824, -1073741824);
full = 0;
for(int i = 0; i < strs.length; ++i) {
if(strs[i].length() > 0) {
this.fontRenderer.drawStringWithShadow(strs[i], var4, var5 + 9 * full++, -1);
}
}
}
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)
{
;
}else {
int var4 = par2 + 12;
int var5 = par3 - 12;
int var6 = this.fontRenderer.getStringWidth(par1Str);
this.drawGradientRect(var4 - 3, var5 - 3, var4 + var6 + 3, var5 + 8 + 3, -1073741824, -1073741824);
this.fontRenderer.drawStringWithShadow(par1Str, var4, var5, -1);
}
}
}
protected void func_74007_a(String par1Str, int par2, int par3)
{
if (par1Str != null)
{
int var4 = par2 + 12;
int var5 = par3 - 12;
int var6 = this.fontRenderer.getStringWidth(par1Str);
this.drawGradientRect(var4 - 3, var5 - 3, var4 + var6 + 3, var5 + 8 + 3, -1073741824, -1073741824);
this.fontRenderer.drawStringWithShadow(par1Str, var4, var5, -1);
static ServerList getInternetServerList(GuiMultiplayer par0GuiMultiplayer) {
return internetServerList;
}
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;
}
}
static ServerList getInternetServerList(GuiMultiplayer par0GuiMultiplayer)
{
return par0GuiMultiplayer.internetServerList;
}
static List getListOfLanServers(GuiMultiplayer par0GuiMultiplayer)
{
return par0GuiMultiplayer.listofLanServers;
}
static int getSelectedServer(GuiMultiplayer par0GuiMultiplayer)
{
return par0GuiMultiplayer.selectedServer;
}
static int getAndSetSelectedServer(GuiMultiplayer par0GuiMultiplayer, int par1)
{
static int getAndSetSelectedServer(GuiMultiplayer par0GuiMultiplayer, int par1) {
return par0GuiMultiplayer.selectedServer = par1;
}
/**
* Return buttonSelect GuiButton
*/
static GuiButton getButtonSelect(GuiMultiplayer par0GuiMultiplayer)
{
static GuiButton getButtonSelect(GuiMultiplayer par0GuiMultiplayer) {
return par0GuiMultiplayer.buttonSelect;
}
/**
* Return buttonEdit GuiButton
*/
static GuiButton getButtonEdit(GuiMultiplayer par0GuiMultiplayer)
{
static GuiButton getButtonEdit(GuiMultiplayer par0GuiMultiplayer) {
return par0GuiMultiplayer.field_96289_p;
}
/**
* Return buttonDelete GuiButton
*/
static GuiButton getButtonDelete(GuiMultiplayer par0GuiMultiplayer)
{
static GuiButton getButtonDelete(GuiMultiplayer par0GuiMultiplayer) {
return par0GuiMultiplayer.buttonDelete;
}
static void func_74008_b(GuiMultiplayer par0GuiMultiplayer, int par1)
{
static void func_74008_b(GuiMultiplayer par0GuiMultiplayer, int par1) {
par0GuiMultiplayer.joinServer(par1);
}
static int getTicksOpened(GuiMultiplayer par0GuiMultiplayer)
{
static int getTicksOpened(GuiMultiplayer par0GuiMultiplayer) {
return par0GuiMultiplayer.ticksOpened;
}
/**
* Returns the lock object for use with synchronized()
*/
static Object getLock()
{
static Object getLock() {
return lock;
}
static int getThreadsPending()
{
static int getThreadsPending() {
return threadsPending;
}
static int increaseThreadsPending()
{
static int increaseThreadsPending() {
return threadsPending++;
}
static void func_82291_a(ServerData par0ServerData) throws IOException
{
func_74017_b(par0ServerData);
}
static int decreaseThreadsPending()
{
static int decreaseThreadsPending() {
return threadsPending--;
}
static String getAndSetLagTooltip(GuiMultiplayer par0GuiMultiplayer, String par1Str)
{
static String getAndSetLagTooltip(GuiMultiplayer par0GuiMultiplayer, String 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.
*/
private int width;
int width;
/**
* 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;
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.EaglerAdapter;
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. */
final GuiMultiplayer parentGui;
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);
this.parentGui = par1GuiMultiplayer;
this.width = 128;
}
/**
* Gets the size of the current slot list.
*/
protected int getSize()
{
return GuiMultiplayer.getInternetServerList(this.parentGui).countServers() + GuiMultiplayer.getListOfLanServers(this.parentGui).size() + 1;
protected int getSize() {
return GuiMultiplayer.getInternetServerList(this.parentGui).countServers() + GuiMultiplayer.getListOfLanServers(this.parentGui).countServers() + 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)
{
if (par1 < GuiMultiplayer.getInternetServerList(this.parentGui).countServers() + GuiMultiplayer.getListOfLanServers(this.parentGui).size())
{
protected void elementClicked(int par1, boolean par2) {
if (par1 < GuiMultiplayer.getInternetServerList(this.parentGui).countServers() + GuiMultiplayer.getListOfLanServers(this.parentGui).countServers()) {
int var3 = GuiMultiplayer.getSelectedServer(this.parentGui);
GuiMultiplayer.getAndSetSelectedServer(this.parentGui, par1);
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();
GuiMultiplayer.getButtonSelect(this.parentGui).enabled = var5;
GuiMultiplayer.getButtonEdit(this.parentGui).enabled = var6;
GuiMultiplayer.getButtonDelete(this.parentGui).enabled = var6;
if (par2 && var5)
{
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));
}
}
@ -56,78 +52,82 @@ class GuiSlotServer extends GuiSlot
/**
* 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 the height of the content being scrolled
*/
protected int getContentHeight()
{
protected int getContentHeight() {
return this.getSize() * 36;
}
protected void drawBackground()
{
protected void drawBackground() {
this.parentGui.drawDefaultBackground();
}
protected void drawSlot(int par1, int par2, int par3, int par4, Tessellator par5Tessellator)
{
if (par1 < GuiMultiplayer.getInternetServerList(this.parentGui).countServers())
{
this.func_77247_d(par1, par2, par3, par4, par5Tessellator);
}
else if (par1 < GuiMultiplayer.getInternetServerList(this.parentGui).countServers() + GuiMultiplayer.getListOfLanServers(this.parentGui).size())
{
this.func_77248_b(par1, par2, par3, par4, par5Tessellator);
}
else
{
protected void drawSlot(int par1, int par2, int par3, int par4, Tessellator par5Tessellator) {
if (par1 < GuiMultiplayer.getInternetServerList(this.parentGui).countServers()) {
try {
this.func_77247_d(par1, par2, par3, par4, par5Tessellator);
}catch(Throwable t) {
}
} else if (par1 < GuiMultiplayer.getInternetServerList(this.parentGui).countServers()
+ GuiMultiplayer.getListOfLanServers(this.parentGui).countServers()) {
try {
this.func_77248_b(par1, par2, par3, par4, par5Tessellator);
}catch(Throwable t) {
}
} else {
this.func_77249_c(par1, par2, par3, par4, par5Tessellator);
}
}
private void func_77248_b(int par1, int par2, int par3, int par4, Tessellator par5Tessellator)
{
LanServer var6 = (LanServer)GuiMultiplayer.getListOfLanServers(this.parentGui).get(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, var6.getServerMotd(), par2 + 2, par3 + 12, 8421504);
private void func_77248_b(int par1, int par2, int par3, int par4, Tessellator par5Tessellator) {
LanServer var6 = (LanServer) GuiMultiplayer.getListOfLanServers(this.parentGui)
.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, var6.getLanServerMotd(), par2 + 2, par3 + 12, 8421504);
if (this.parentGui.mc.gameSettings.hideServerAddress)
{
this.parentGui.drawString(this.parentGui.fontRenderer, StatCollector.translateToLocal("selectServer.hiddenAddress"), par2 + 2, par3 + 12 + 11, 3158064);
}
else
{
this.parentGui.drawString(this.parentGui.fontRenderer, var6.getServerIpPort(), par2 + 2, par3 + 12 + 11, 3158064);
if (this.parentGui.mc.gameSettings.hideServerAddress) {
this.parentGui.drawString(this.parentGui.fontRenderer,
StatCollector.translateToLocal("selectServer.hiddenAddress"), par2 + 2, par3 + 12 + 11, 3158064);
} else {
this.parentGui.drawString(this.parentGui.fontRenderer, var6.getLanServerCode(), par2 + 2, par3 + 12 + 11,
0x558822);
}
}
private void func_77249_c(int par1, int par2, int par3, int par4, Tessellator par5Tessellator)
{
this.parentGui.drawCenteredString(this.parentGui.fontRenderer, StatCollector.translateToLocal("lanServer.scanning"), this.parentGui.width / 2, par3 + 1, 16777215);
String var6;
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("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;
switch (GuiMultiplayer.getTicksOpened(this.parentGui) / 3 % 4)
{
case 0:
default:
var6 = "O o o";
break;
switch (GuiMultiplayer.getTicksOpened(this.parentGui) / 3 % 4) {
case 0:
default:
var6 = "O o o";
break;
case 1:
case 3:
var6 = "o O o";
break;
case 1:
case 3:
var6 = "o O o";
break;
case 2:
var6 = "o o O";
case 2:
var6 = "o o O";
}
this.parentGui.drawCenteredString(this.parentGui.fontRenderer, var6, this.parentGui.width / 2, par3 + 18, 8421504);
}
this.parentGui.drawCenteredString(this.parentGui.fontRenderer, var6, this.parentGui.width / 2, par3 + 12, 8421504);
}
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();
}
}
}