LAN ready for testing

This commit is contained in:
LAX1DUDE 2022-08-19 01:34:04 -07:00
parent 1e7c5a7493
commit 3d9df11058
32 changed files with 34461 additions and 33644 deletions

View file

@ -1,2 +1,6 @@
@echo off
java -jar CompilePackage.jar "../lwjgl-rundir/resources" "../javascript/assets.epk"
title epkcompiler
echo compiling, please wait...
java -jar CompilePackage.jar "../lwjgl-rundir/resources" "../javascript/assets.epk"
echo finished compiling epk
pause

Binary file not shown.

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load diff

File diff suppressed because one or more lines are too long

View file

@ -259,12 +259,28 @@ directConnect.serverJoin=Connect to Server
directConnect.lanWorldJoin=Join World
directConnect.lanWorldRelay=Network Settings
lanServer.pauseMenu0=Sharing to LAN
lanServer.pauseMenu1=Relay URL:
lanServer.pauseMenu2=Join Code:
lanServer.worldName=World Name:
lanServer.hidden=Hidden:
lanServer.hideCode=hide details
lanServer.showCode=show details
lanServer.opened=LAN world opened on $relay$, join code is §a$code$
lanServer.closed=LAN world closed
lanServer.pleaseWait=Please Wait...
lanServer.relayDisconnected=Error: connection to LAN relay was lost, you must re-share the world to invide more people
networkSettings.title=LAN World Relay Servers
networkSettings.add=Add Relay
networkSettings.delete=Delete Relay
networkSettings.default=Set Primary
networkSettings.refresh=Refresh
networkSettings.loadDefaults=Load Defaults
networkSettings.relayTimeout=Connection Timeout:
networkSettings.relayTimeoutChange=change
networkSettings.relayTimeoutTitle=Change Connection Timeout
addRelay.title=Add New Relay
addRelay.name=Relay Comment
@ -274,8 +290,13 @@ addRelay.primary=Set Primary
addRelay.removeText1=Do you want to remove this relay?
noRelay.title=No Relays are Configured!
noRelay.titleFail=No Working Relays Available!
noRelay.noRelay1=LAN Unavailable: No Relays Configured!
noRelay.noRelay2=Click '§nNetwork Settings§r' to fix
noRelay.worldNotFound1=Could not locate '§c$code$§r'!
noRelay.worldNotFound2=Make sure to add the '§f$code$§r' world's relay URL
noRelay.worldNotFound3=to the relay list 'Network Settings' to connect
noRelay.worldFail=Failed to connect to '$code$'!
multiplayer.title=Play Multiplayer
multiplayer.connect=Connect

View file

@ -114,9 +114,13 @@ public class EaglerSPRelay extends WebSocketServer {
logger.info("Shutting down...");
instance.stop();
System.exit(0);
}else if(s.equalsIgnoreCase("reset")) {
logger.info("Clearing all ratelimits");
if(pingRateLimiter != null) pingRateLimiter.reset();
if(worldRateLimiter != null) worldRateLimiter.reset();
}else {
logger.info("Unknown command: {}", s);
logger.info("Type 'stop' to exit, 'reload' to reload config");
logger.info("Type 'stop' to exit" + ((worldRateLimiter != null || pingRateLimiter != null) ? ", 'reset' to clear ratelimits" : ""));
}
}
@ -149,7 +153,7 @@ public class EaglerSPRelay extends WebSocketServer {
@Override
public void onStart() {
logger.info("Listening on {}", getAddress());
logger.info("Type 'stop' to exit");
logger.info("Type 'stop' to exit" + ((worldRateLimiter != null || pingRateLimiter != null) ? ", 'reset' to clear ratelimits" : ""));
}
@Override
@ -284,6 +288,9 @@ public class EaglerSPRelay extends WebSocketServer {
"The join code is the wrong length, it should be " + config.getCodeLength() + " chars long")));
arg0.close();
}else {
if(!config.isCodeMixCase()) {
code = code.toLowerCase();
}
EaglerSPServer srv;
synchronized(serverCodes) {
srv = serverCodes.get(code);
@ -424,30 +431,30 @@ public class EaglerSPRelay extends WebSocketServer {
synchronized(clientConnections) {
cl = clientConnections.remove(arg0);
}
synchronized(clientAddressSets) {
List<EaglerSPClient> lst = clientAddressSets.get(cl.address);
if(lst != null) {
lst.remove(cl);
if(lst.size() == 0) {
clientAddressSets.remove(cl.address);
if(cl != null) {
synchronized(clientAddressSets) {
List<EaglerSPClient> lst = clientAddressSets.get(cl.address);
if(lst != null) {
lst.remove(cl);
if(lst.size() == 0) {
clientAddressSets.remove(cl.address);
}
}
}
}
if(cl != null) {
logger.debug("[{}]: Client closed, id: {}", (String) arg0.getAttachment(), cl.id);
synchronized(clientIds) {
clientIds.remove(cl.id);
}
cl.server.handleClientDisconnect(cl);
}else {
logger.debug("[{}]: Connection Closed: {} ", (String) arg0.getAttachment());
logger.debug("[{}]: Connection Closed", (String) arg0.getAttachment());
}
}
}
@Override
public void onError(WebSocket arg0, Exception arg1) {
logger.error("[{}]: Exception thrown: {}", (String) arg0.getAttachment(), arg1.toString());
logger.error("[{}]: Exception thrown: {}", (arg0 == null ? "SERVER" : (String) arg0.getAttachment()), arg1.toString());
logger.debug(arg1);
arg0.close();
}

View file

@ -15,7 +15,7 @@ public class EaglerSPRelayConfig {
private String address = "0.0.0.0";
private int port = 6699;
private int codeLength = 5;
private String codeChars = "abcdefghijklmnopqrstuvwxyz0123456789$%&*+?!";
private String codeChars = "abcdefghijklmnopqrstuvwxyz0123456789";
private boolean codeMixCase = false;
private int connectionsPerIP = 128;
@ -60,8 +60,10 @@ public class EaglerSPRelayConfig {
try(BufferedReader reader = new BufferedReader(new FileReader(conf))) {
String s;
while((s = reader.readLine()) != null) {
String[] ss = s.trim().split("=", 2);
String[] ss = s.trim().split(":", 2);
if(ss.length == 2) {
ss[0] = ss[0].trim();
ss[1] = ss[1].trim();
if(ss[0].equalsIgnoreCase("port")) {
try {
port = Integer.parseInt(ss[1]);
@ -278,26 +280,27 @@ public class EaglerSPRelayConfig {
public void save(File conf) {
try(PrintWriter w = new PrintWriter(new FileOutputStream(conf))) {
w.println("address=" + address);
w.println("port=" + port);
w.println("code-length=" + codeLength);
w.println("code-chars=" + codeChars);
w.println("code-mix-case=" + codeMixCase);
w.println("connections-per-ip=" + connectionsPerIP);
w.println("ping-ratelimit-enable=" + pingRateLimitEnable);
w.println("ping-ratelimit-period=" + pingRateLimitPeriod);
w.println("ping-ratelimit-limit=" + pingRateLimitLimit);
w.println("ping-ratelimit-lockout-limit=" + pingRateLimitLockoutLimit);
w.println("ping-ratelimit-lockout-duration=" + pingRateLimitLockoutDuration);
w.println("worlds-per-ip=" + worldsPerIP);
w.println("world-ratelimit-enable=" + openRateLimitEnable);
w.println("world-ratelimit-period=" + openRateLimitPeriod);
w.println("world-ratelimit-limit=" + openRateLimitLimit);
w.println("world-ratelimit-lockout-limit=" + openRateLimitLockoutLimit);
w.println("world-ratelimit-lockout-duration=" + openRateLimitLockoutDuration);
w.println("origin-whitelist=" + originWhitelist);
w.println("enable-real-ip-header=" + enableRealIpHeader);
w.print("server-comment=" + serverComment);
w.println("[EaglerSPRelay]");
w.println("address: " + address);
w.println("port: " + port);
w.println("code-length: " + codeLength);
w.println("code-chars: " + codeChars);
w.println("code-mix-case: " + codeMixCase);
w.println("connections-per-ip: " + connectionsPerIP);
w.println("ping-ratelimit-enable: " + pingRateLimitEnable);
w.println("ping-ratelimit-period: " + pingRateLimitPeriod);
w.println("ping-ratelimit-limit: " + pingRateLimitLimit);
w.println("ping-ratelimit-lockout-limit: " + pingRateLimitLockoutLimit);
w.println("ping-ratelimit-lockout-duration: " + pingRateLimitLockoutDuration);
w.println("worlds-per-ip: " + worldsPerIP);
w.println("world-ratelimit-enable: " + openRateLimitEnable);
w.println("world-ratelimit-period: " + openRateLimitPeriod);
w.println("world-ratelimit-limit: " + openRateLimitLimit);
w.println("world-ratelimit-lockout-limit: " + openRateLimitLockoutLimit);
w.println("world-ratelimit-lockout-duration: " + openRateLimitLockoutDuration);
w.println("origin-whitelist: " + originWhitelist);
w.println("enable-real-ip-header: " + enableRealIpHeader);
w.print("server-comment: " + serverComment);
}catch(IOException t) {
EaglerSPRelay.logger.error("Failed to write config file: {}", conf.getAbsoluteFile());
EaglerSPRelay.logger.error(t);

View file

@ -89,7 +89,7 @@ public class IPacket {
if(j < 0) {
return null;
}
ret[i] = (char)is.read();
ret[i] = (char)j;
}
return new String(ret);
}

View file

@ -1,26 +0,0 @@
package net.minecraft.src;
import net.minecraft.server.MinecraftServer;
public class CommandServerPublishLocal extends CommandBase {
public String getCommandName() {
return "publish";
}
/**
* Return the required permission level for this command.
*/
public int getRequiredPermissionLevel() {
return 4;
}
public void processCommand(ICommandSender par1ICommandSender, String[] par2ArrayOfStr) {
String var3 = MinecraftServer.getServer().shareToLAN(EnumGameType.SURVIVAL, false);
if (var3 != null) {
notifyAdmins(par1ICommandSender, "commands.publish.started", new Object[] { var3 });
} else {
notifyAdmins(par1ICommandSender, "commands.publish.failed", new Object[0]);
}
}
}

View file

@ -29,7 +29,6 @@ public class ServerCommandManager extends CommandHandler implements IAdminComman
this.registerCommand(new CommandClearInventory());
this.registerCommand(new ServerCommandTestFor());
this.registerCommand(new ServerCommandScoreboard());
this.registerCommand(new CommandServerPublishLocal());
CommandBase.setAdminCommander(this);
}

View file

@ -37,9 +37,9 @@ public class GuiScreenAddRelay extends GuiScreen {
this.buttonList.add(new GuiButton(1, this.width / 2 - 100, this.height / 4 + 120 + 12 + sslOff, var1.translateKey("gui.cancel")));
this.buttonList.add(new GuiButton(2, this.width / 2 - 100, 142, var1.translateKey("addRelay.primary") + ": " + var1.translateKey("gui.no")));
this.serverName = new GuiTextField(this.fontRenderer, this.width / 2 - 100, 106, 200, 20);
this.serverName.setFocused(true);
this.serverAddress = new GuiTextField(this.fontRenderer, this.width / 2 - 100, 66, 200, 20);
this.serverAddress.setMaxStringLength(128);
this.serverAddress.setFocused(true);
((GuiButton) this.buttonList.get(0)).enabled = this.serverAddress.getText().length() > 0 && this.serverAddress.getText().split(":").length > 0 && this.serverName.getText().length() > 0;
this.parentGui.addNewName = IntegratedServer.relayManager.makeNewRelayName();
this.parentGui.addNewAddr = "";

View file

@ -0,0 +1,71 @@
package net.lax1dude.eaglercraft;
import net.minecraft.client.Minecraft;
import net.minecraft.src.GuiButton;
import net.minecraft.src.GuiScreen;
import net.minecraft.src.GuiSlider2;
import net.minecraft.src.StringTranslate;
public class GuiScreenChangeRelayTimeout extends GuiScreen {
private GuiScreen parent;
private GuiSlider2 slider;
private String title;
public GuiScreenChangeRelayTimeout(GuiScreen parent) {
this.parent = parent;
}
public void initGui() {
StringTranslate ts = StringTranslate.getInstance();
title = ts.translateKey("networkSettings.relayTimeoutTitle");
buttonList.clear();
buttonList.add(new GuiButton(0, width / 2 - 100, height / 3 + 55, ts.translateKey("gui.cancel")));
buttonList.add(new GuiButton(1, width / 2 - 100, height / 3 + 85, ts.translateKey("gui.done")));
slider = new GuiSlider2(0, width / 2 - 100, height / 3 + 10, 200, 20, (mc.gameSettings.relayTimeout - 1) / 14.0f, 1.0f) {
public boolean mousePressed(Minecraft par1Minecraft, int par2, int par3) {
if(super.mousePressed(par1Minecraft, par2, par3)) {
this.displayString = "" + (int)((sliderValue * 14.0f) + 1.0f) + "s";
return true;
}else {
return false;
}
}
public void mouseDragged(Minecraft par1Minecraft, int par2, int par3) {
super.mouseDragged(par1Minecraft, par2, par3);
this.displayString = "" + (int)((sliderValue * 14.0f) + 1.0f) + "s";
}
};
slider.displayString = "" + mc.gameSettings.relayTimeout + "s";
}
public void actionPerformed(GuiButton btn) {
if(btn.id == 0) {
mc.displayGuiScreen(parent);
}else if(btn.id == 1) {
mc.gameSettings.relayTimeout = (int)((slider.sliderValue * 14.0f) + 1.0f);
mc.gameSettings.saveOptions();
mc.displayGuiScreen(parent);
}
}
public void drawScreen(int par1, int par2, float par3) {
drawDefaultBackground();
drawCenteredString(fontRenderer, title, width / 2, height / 3 - 20, 0xFFFFFF);
slider.drawButton(mc, par1, par2);
super.drawScreen(par1, par2, par3);
}
public void mouseClicked(int mx, int my, int button) {
slider.mousePressed(mc, mx, my);
super.mouseClicked(mx, my, button);
}
public void mouseMovedOrUp(int par1, int par2, int par3) {
if(par3 == 0) {
slider.mouseReleased(par1, par2);
}
super.mouseMovedOrUp(par1, par2, par3);
}
}

View file

@ -37,7 +37,7 @@ public class GuiScreenConnectOption extends GuiScreen {
}else if(par1GuiButton.id == 2) {
GuiScreen scn = new GuiScreenLANConnect(guiScreen);
if(IntegratedServer.relayManager.count() == 0) {
mc.displayGuiScreen(new GuiScreenNoRelays(guiScreen));
mc.displayGuiScreen(new GuiScreenNoRelays(guiScreen, "noRelay.title"));
}else {
mc.displayGuiScreen(scn);
}

View file

@ -28,17 +28,17 @@ public class GuiScreenLANConnect extends GuiScreen {
this.codeTextField.setMaxStringLength(48);
this.codeTextField.setFocused(true);
this.codeTextField.setText(lastCode);
((GuiButton) this.buttonList.get(0)).enabled = this.codeTextField.getText().length() > 0;
((GuiButton) this.buttonList.get(0)).enabled = this.codeTextField.getText().trim().length() > 0;
}
public void onGuiClosed() {
EaglerAdapter.enableRepeatEvents(false);
lastCode = this.codeTextField.getText();
lastCode = this.codeTextField.getText().trim();
}
protected void keyTyped(char par1, int par2) {
if (this.codeTextField.textboxKeyTyped(par1, par2)) {
((GuiButton) this.buttonList.get(0)).enabled = this.codeTextField.getText().length() > 0;
((GuiButton) this.buttonList.get(0)).enabled = this.codeTextField.getText().trim().length() > 0;
} else if (par2 == 28) {
this.actionPerformed((GuiButton) this.buttonList.get(0));
}
@ -67,6 +67,8 @@ public class GuiScreenLANConnect extends GuiScreen {
protected void actionPerformed(GuiButton par1GuiButton) {
if(par1GuiButton.id == 1) {
mc.displayGuiScreen(parent);
}else if(par1GuiButton.id == 0) {
mc.displayGuiScreen(new GuiScreenLANConnecting(parent, this.codeTextField.getText().trim()));
}
}

View file

@ -0,0 +1,67 @@
package net.lax1dude.eaglercraft;
import java.io.IOException;
import net.minecraft.src.GuiDisconnected;
import net.minecraft.src.GuiScreen;
import net.minecraft.src.LoadingScreenRenderer;
import net.minecraft.src.NetClientHandler;
import net.minecraft.src.Packet2ClientProtocol;
import net.minecraft.src.StringTranslate;
public class GuiScreenLANConnecting extends GuiScreen {
private final GuiScreen parent;
private final String code;
private boolean completed = false;
public GuiScreenLANConnecting(GuiScreen parent, String code) {
this.parent = parent;
this.code = code;
}
public boolean doesGuiPauseGame() {
return false;
}
public void drawScreen(int par1, int par2, float par3) {
this.drawDefaultBackground();
StringTranslate st = StringTranslate.getInstance();
if(completed) {
String message = st.translateKey("connect.authorizing");
this.drawString(fontRenderer, message, (this.width - this.fontRenderer.getStringWidth(message)) / 2, this.height / 3 + 10, 0xFFFFFF);
}else {
LoadingScreenRenderer ls = mc.loadingScreen;
String message = st.translateKey("lanServer.pleaseWait");
this.drawString(fontRenderer, message, (this.width - this.fontRenderer.getStringWidth(message)) / 2, this.height / 3 + 10, 0xFFFFFF);
RelayServerSocket sock = IntegratedServer.relayManager.getWorkingRelay((str) -> ls.resetProgresAndWorkingMessage("Connecting: " + str), 0x02, code);
if(sock == null) {
this.mc.displayGuiScreen(new GuiScreenNoRelays(parent, st.translateKey("noRelay.worldNotFound1").replace("$code$", code),
st.translateKey("noRelay.worldNotFound2").replace("$code$", code), st.translateKey("noRelay.worldNotFound3")));
return;
}
LANClientNetworkManager netMgr = LANClientNetworkManager.connectToWorld(sock, code, sock.getURI());
if(netMgr == null) {
this.mc.displayGuiScreen(new GuiDisconnected(parent, "connect.failed", "disconnect.genericReason", "noRelay.worldFail", ""));
return;
}
completed = true;
try {
NetClientHandler netHandler = new NetClientHandler(mc, netMgr);
this.mc.setNetManager(netMgr);
netHandler.addToSendQueue(new Packet2ClientProtocol(61, EaglerProfile.username, "127.0.0.1", mc.gameSettings.renderDistance));
} catch (IOException e) {
this.mc.displayGuiScreen(new GuiDisconnected(parent, "connect.failed", "disconnect.genericReason", "could not create nethandler", ""));
e.printStackTrace();
return;
}
}
}
}

View file

@ -7,9 +7,22 @@ import net.minecraft.src.StringTranslate;
public class GuiScreenNoRelays extends GuiScreen {
private GuiScreen parent;
private String title1;
private String title2;
private String title3;
public GuiScreenNoRelays(GuiScreen parent) {
public GuiScreenNoRelays(GuiScreen parent, String title) {
this.parent = parent;
this.title1 = title;
this.title2 = null;
this.title3 = null;
}
public GuiScreenNoRelays(GuiScreen parent, String title1, String title2, String title3) {
this.parent = parent;
this.title1 = title1;
this.title2 = title2;
this.title3 = title3;
}
public void initGui() {
@ -22,7 +35,13 @@ public class GuiScreenNoRelays extends GuiScreen {
public void drawScreen(int par1, int par2, float par3) {
StringTranslate var4 = StringTranslate.getInstance();
this.drawDefaultBackground();
this.drawCenteredString(this.fontRenderer, var4.translateKey("noRelay.title"), this.width / 2, this.height / 4 - 60 + 70, 16777215);
this.drawCenteredString(this.fontRenderer, var4.translateKey(title1), this.width / 2, this.height / 4 - 60 + 70, 16777215);
if(title2 != null) {
this.drawCenteredString(this.fontRenderer, var4.translateKey(title2), this.width / 2, this.height / 4 - 60 + 80, 0xCCCCCC);
}
if(title3 != null) {
this.drawCenteredString(this.fontRenderer, var4.translateKey(title3), this.width / 2, this.height / 4 - 60 + 90, 0xCCCCCC);
}
super.drawScreen(par1, par2, par3);
}

View file

@ -22,6 +22,8 @@ public class GuiScreenRelay extends GuiScreen {
private String tooltipString = null;
private long lastRefresh = 0l;
public GuiScreenRelay(GuiScreen screen) {
this.screen = screen;
}
@ -56,6 +58,7 @@ public class GuiScreenRelay extends GuiScreen {
public void actionPerformed(GuiButton btn) {
if(btn.id == 0) {
IntegratedServer.relayManager.save();
mc.displayGuiScreen(screen);
} else if(btn.id == 1) {
addingNew = true;
@ -74,9 +77,20 @@ public class GuiScreenRelay extends GuiScreen {
selected = 0;
}
} else if(btn.id == 4) {
slots.relayManager.ping();
long millis = System.currentTimeMillis();
if(millis - lastRefresh > 700l) {
lastRefresh = millis;
slots.relayManager.ping();
}
lastRefresh += 60l;
} else if(btn.id == 5) {
slots.relayManager.loadDefaults();
long millis = System.currentTimeMillis();
if(millis - lastRefresh > 700l) {
lastRefresh = millis;
slots.relayManager.ping();
}
lastRefresh += 60l;
}
}
@ -110,9 +124,38 @@ public class GuiScreenRelay extends GuiScreen {
tooltipString = null;
}
this.drawCenteredString(this.fontRenderer, var4.translateKey("networkSettings.title"), this.width / 2, 16, 16777215);
this.drawCenteredString(fontRenderer, var4.translateKey("networkSettings.title"), this.width / 2, 16, 16777215);
String str = var4.translateKey("networkSettings.relayTimeout") + " " + mc.gameSettings.relayTimeout;
int w = fontRenderer.getStringWidth(str);
this.drawString(fontRenderer, str, 3, 3, 0xDDDDDD);
EaglerAdapter.glPushMatrix();
EaglerAdapter.glTranslatef(w + 7, 4, 0.0f);
EaglerAdapter.glScalef(0.75f, 0.75f, 0.75f);
str = EnumChatFormatting.UNDERLINE + var4.translateKey("networkSettings.relayTimeoutChange");
int w2 = fontRenderer.getStringWidth(str);
boolean b = par1 > w + 5 && par1 < w + 7 + w2 * 3 / 4 && par2 > 3 && par2 < 11;
this.drawString(fontRenderer, EnumChatFormatting.UNDERLINE + var4.translateKey("networkSettings.relayTimeoutChange"), 0, 0, b ? 0xCCCCCC : 0x999999);
EaglerAdapter.glPopMatrix();
super.drawScreen(par1, par2, par3);
}
protected void mouseClicked(int par1, int par2, int par3) {
super.mouseClicked(par1, par2, par3);
if(par3 == 0) {
StringTranslate var4 = StringTranslate.getInstance();
String str = var4.translateKey("networkSettings.relayTimeout") + " " + mc.gameSettings.relayTimeout;
int w = fontRenderer.getStringWidth(str);
str = var4.translateKey("networkSettings.relayTimeoutChange");
int w2 = fontRenderer.getStringWidth(str);
if(par1 > w + 5 && par1 < w + 7 + w2 * 3 / 4 && par2 > 3 && par2 < 11) {
this.mc.displayGuiScreen(new GuiScreenChangeRelayTimeout(this));
this.mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F);
}
}
}
void setToolTip(String str) {
tooltipString = str;

View file

@ -120,6 +120,7 @@ public class IntegratedServer {
statusState = IntegratedState.WORLD_UNLOADING;
sendIPCPacket(new IPCPacket01StopServer());
}
IntegratedServerLAN.closeLAN();
}
public static void autoSave() {
@ -258,6 +259,9 @@ public class IntegratedServer {
public static void processICP() {
if(!EaglerAdapter.isIntegratedServerAlive()) {
if(IntegratedServerLAN.isHostingLAN()) {
IntegratedServerLAN.closeLAN();
}
return;
}
@ -389,6 +393,10 @@ public class IntegratedServer {
t.printStackTrace();
}
}
if(IntegratedServerLAN.isHostingLAN()) {
IntegratedServerLAN.updateLANServer();
}
}
public static void sendIPCPacket(IPCPacketBase pkt) {

View file

@ -12,8 +12,11 @@ import net.lax1dude.eaglercraft.sp.relay.pkt.*;
public class IntegratedServerLAN {
private static RelayServerSocket lanRelaySocket = null;
private static String currentCode = null;
public static String shareToLAN(Consumer<String> progressCallback, String worldName, boolean worldHidden) {
currentCode = null;
RelayServerSocket sock = IntegratedServer.relayManager.getWorkingRelay((str) -> progressCallback.accept("Connecting: " + str),
IntegratedServer.preferredRelayVersion, worldName + (worldHidden ? ";1" : ";0"));
if(sock == null) {
@ -45,7 +48,7 @@ public class IntegratedServerLAN {
servers.add(srv.getICEString());
}
EaglerAdapter.serverLANInitializeServer(servers.toArray(new String[servers.size()]));
return code;
return currentCode = code;
}else {
System.err.println("Relay [" + sock.getURI() + "] unexpected packet: " + pkt.getClass().getSimpleName());
closeLAN();
@ -62,11 +65,20 @@ public class IntegratedServerLAN {
return null;
}
}
public static String getCurrentURI() {
return lanRelaySocket == null ? "<disconnected>" : lanRelaySocket.getURI();
}
public static String getCurrentCode() {
return currentCode == null ? "<undefined>" : currentCode;
}
public static void closeLAN() {
if(lanRelaySocket != null) {
lanRelaySocket.close();
lanRelaySocket = null;
currentCode = null;
}
cleanupLAN();
}
@ -142,6 +154,7 @@ public class IntegratedServerLAN {
}
if(lanRelaySocket.isClosed()) {
lanRelaySocket = null;
currentCode = null;
cleanupLAN();
}else {
Iterator<LANClient> itr = clients.values().iterator();

View file

@ -39,7 +39,7 @@ public class LANClientNetworkManager implements INetworkManager {
public static LANClientNetworkManager connectToWorld(RelayServerSocket sock, String displayCode, String displayRelay) {
EaglerAdapter.clearLANClientState();
int connectState = -1;
int connectState = PRE;
IPacket pkt;
mainLoop: while(!sock.isClosed()) {
if((pkt = sock.readPacket()) != null) {
@ -245,36 +245,43 @@ public class LANClientNetworkManager implements INetworkManager {
@Override
public void processReadPackets() {
/*
* Alright some really weird shit is up with TeaVM here, if you put the try/catch
* around the full inner body of the while loop, the compiler fails with no error
* message, just a vague stack trace. But making a multi-catch around just
* readPacketData and processPacket has no issues
*
* You'e welcome for the two hours of my time and single line changes I made
* in a fuck ton of irrelevant files leading up to this bullshit revelation
*/
if(this.theNetHandler != null) {
byte[] data;
while((data = EaglerAdapter.clientLANReadPacket()) != null) {
ByteArrayInputStream bai = new ByteArrayInputStream(data);
int pktId = bai.read();
if(pktId == -1) {
System.err.println("Recieved invalid '-1' packet");
continue;
}
Packet pkt = Packet.getNewPacket(pktId);
if(pkt == null) {
System.err.println("Recieved invalid '" + pktId + "' packet");
continue;
}
try {
ByteArrayInputStream bai = new ByteArrayInputStream(data);
int pktId = bai.read();
if(pktId == -1) {
System.err.println("Recieved invalid '-1' packet");
continue;
}
Packet pkt = Packet.getNewPacket(pktId);
if(pkt == null) {
System.err.println("Recieved invalid '" + pktId + "' packet");
continue;
}
pkt.readPacketData(new DataInputStream(bai));
try {
pkt.processPacket(theNetHandler);
}catch(Throwable t) {
System.err.println("Could not process minecraft packet 0x" + Integer.toHexString(pkt.getPacketId()) + " class '" + pkt.getClass().getSimpleName() + "' from remote LAN world");
t.printStackTrace();
}
pkt.processPacket(theNetHandler);
}catch(IOException ex) {
System.err.println("Could not deserialize a " + data.length + " byte long minecraft packet of type '" + (data.length <= 0 ? -1 : (int)(data[0] & 0xFF)) + "' from remote LAN world");
}catch(Throwable t) {
System.err.println("Could not process minecraft packet 0x" + Integer.toHexString(pkt.getPacketId()) + " class '" + pkt.getClass().getSimpleName() + "' from remote LAN world");
t.printStackTrace();
}
}
}

View file

@ -1,6 +1,7 @@
package net.lax1dude.eaglercraft;
import net.lax1dude.eaglercraft.RelayQuery.VersionMismatch;
import net.minecraft.client.Minecraft;
public class RelayServer {
@ -114,7 +115,7 @@ public class RelayServer {
}
public RelayServerSocket openSocket() {
return EaglerAdapter.openRelayConnection(address);
return EaglerAdapter.openRelayConnection(address, Minecraft.getMinecraft().gameSettings.relayTimeout * 1000);
}
}

View file

@ -85,7 +85,7 @@ public class IPacket {
if(j < 0) {
return null;
}
ret[i] = (char)is.read();
ret[i] = (char)j;
}
return new String(ret);
}

View file

@ -36,7 +36,7 @@ public class IPacket00Handshake extends IPacket {
@Override
public int packetLength() {
return 1 + (connectionCode != null ? 1 + connectionCode.length() : 0);
return 1 + 1 + (connectionCode != null ? 1 + connectionCode.length() : 0);
}
}

View file

@ -13,6 +13,7 @@ import net.lax1dude.eaglercraft.GuiScreenSingleplayerConnecting;
import net.lax1dude.eaglercraft.GuiScreenSingleplayerLoading;
import net.lax1dude.eaglercraft.GuiVoiceOverlay;
import net.lax1dude.eaglercraft.IntegratedServer;
import net.lax1dude.eaglercraft.IntegratedServerLAN;
import net.lax1dude.eaglercraft.LocalStorageManager;
import net.lax1dude.eaglercraft.Voice;
import net.lax1dude.eaglercraft.WorkerNetworkManager;
@ -76,6 +77,7 @@ import net.minecraft.src.RenderManager;
import net.minecraft.src.ScaledResolution;
import net.minecraft.src.ServerData;
import net.minecraft.src.SoundManager;
import net.minecraft.src.StatCollector;
import net.minecraft.src.StatStringFormatKeyInv;
import net.minecraft.src.StringTranslate;
import net.minecraft.src.TextureManager;
@ -237,6 +239,8 @@ public class Minecraft implements Runnable {
private int messageOnLoginCounter = 0;
public boolean lanState = false;
public Minecraft() {
this.tempDisplayHeight = 480;
this.fullscreen = false;
@ -490,26 +494,6 @@ public class Minecraft implements Runnable {
}
}
}
/*
t1 = System.currentTimeMillis();
for(int i = 0; i < 8; i++) {
float f = 1.0f - ((float)(System.currentTimeMillis() - t1) / 136f);
f = 0.25f + f * f * 0.75f;
EaglerAdapter.glClearColor(f, f, f, 1.0F);
EaglerAdapter.glClear(EaglerAdapter.GL_COLOR_BUFFER_BIT | EaglerAdapter.GL_DEPTH_BUFFER_BIT);
EaglerAdapter.glFlush();
EaglerAdapter.updateDisplay();
long t = t1 + 17 + 17*i - System.currentTimeMillis();
if(t > 0) {
try {
Thread.sleep(t);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
*/
EaglerAdapter.glClear(EaglerAdapter.GL_COLOR_BUFFER_BIT | EaglerAdapter.GL_DEPTH_BUFFER_BIT);
showWarningText();
@ -1155,13 +1139,21 @@ public class Minecraft implements Runnable {
this.mcProfiler.startSection("stats");
this.mcProfiler.endStartSection("gui");
this.isGamePaused = this.isSingleplayer() && this.theWorld != null && this.thePlayer != null && this.currentScreen != null && this.currentScreen.doesGuiPauseGame();
this.isGamePaused = this.isSingleplayer() && this.theWorld != null && this.thePlayer != null && this.currentScreen != null
&& this.currentScreen.doesGuiPauseGame() && !IntegratedServerLAN.isHostingLAN();
if(wasPaused != isGamePaused) {
IntegratedServer.setPaused(this.isGamePaused);
wasPaused = isGamePaused;
}
if(lanState && !IntegratedServerLAN.isHostingLAN()) {
lanState = false;
if(thePlayer != null) {
thePlayer.sendChatToPlayer(EnumChatFormatting.RED + StatCollector.translateToLocal("lanServer.relayDisconnected"));
}
}
if (!this.isGamePaused) {
this.ingameGUI.updateTick();
}
@ -1590,6 +1582,7 @@ public class Minecraft implements Runnable {
if (this.texturePackList.getIsDownloading()) {
this.texturePackList.onDownloadFinished();
}
this.lanState = false;
IntegratedServer.unloadWorld();
this.setServerData((ServerData) null);
this.integratedServerIsRunning = false;
@ -1650,26 +1643,6 @@ public class Minecraft implements Runnable {
public void setNetManager(INetworkManager nm) {
this.myNetworkManager = nm;
}
/*
public void installResource(String par1Str, File par2File) {
int var3 = par1Str.indexOf("/");
String var4 = par1Str.substring(0, var3);
par1Str = par1Str.substring(var3 + 1);
if (var4.equalsIgnoreCase("sound3")) {
this.sndManager.addSound(par1Str, par2File);
} else if (var4.equalsIgnoreCase("streaming")) {
this.sndManager.addStreaming(par1Str, par2File);
} else if (!var4.equalsIgnoreCase("music") && !var4.equalsIgnoreCase("newmusic")) {
if (var4.equalsIgnoreCase("lang")) {
StringTranslate.getInstance().func_94519_a(par1Str, par2File);
}
} else {
this.sndManager.addMusic(par1Str, par2File);
}
}
*/
/**
* A String of renderGlobal.getDebugInfoRenders

View file

@ -1,6 +1,7 @@
package net.minecraft.src;
import net.lax1dude.eaglercraft.EaglerAdapter;
import net.lax1dude.eaglercraft.IntegratedServer;
import net.lax1dude.eaglercraft.LocalStorageManager;
import net.minecraft.client.Minecraft;
@ -140,6 +141,9 @@ public class GameSettings {
public float voiceListenVolume = 0.5f;
public float voiceSpeakVolume = 0.5f;
public int voicePTTKey = 47;
public boolean hideJoinCode = false;
public int relayTimeout = 4;
public GameSettings(Minecraft par1Minecraft) {
this.keyBindings = new KeyBinding[] { this.keyBindAttack, this.keyBindUseItem, this.keyBindForward, this.keyBindLeft, this.keyBindBack, this.keyBindRight, this.keyBindJump, this.keyBindSneak, this.keyBindDrop, this.keyBindInventory,
@ -528,6 +532,8 @@ public class GameSettings {
if(yee.hasKey("voicePTTKey")) voicePTTKey = yee.getInteger("voicePTTKey");
if(yee.hasKey("voiceListenRadius")) voiceListenRadius = yee.getInteger("voiceListenRadius");
if(yee.hasKey("difficulty")) difficulty = yee.getByte("difficulty");
if(yee.hasKey("hideJoinCode")) hideJoinCode = yee.getBoolean("hideJoinCode");
if(yee.hasKey("relayTimeout")) relayTimeout = yee.getByte("relayTimeout");
if(voiceListenRadius < 5) voiceListenRadius = 5;
else if(voiceListenRadius > 22) voiceListenRadius = 22;
@ -541,6 +547,8 @@ public class GameSettings {
}
KeyBinding.resetKeyBindingArrayAndHash();
IntegratedServer.relayManager.load(LocalStorageManager.gameSettingsStorage.getTagList("relays"));
}
}
@ -602,6 +610,8 @@ public class GameSettings {
yee.setInteger("voicePTTKey", voicePTTKey);
yee.setInteger("voiceListenRadius", voiceListenRadius);
yee.setByte("difficulty", (byte)difficulty);
yee.setBoolean("hideJoinCode", hideJoinCode);
yee.setByte("relayTimeout", (byte)relayTimeout);
for (int var4 = 0; var4 < this.keyBindings.length; ++var4) {
yee.setInteger(keyBindings[var4].keyDescription, keyBindings[var4].keyCode);

View file

@ -3,6 +3,7 @@ package net.minecraft.src;
import net.lax1dude.eaglercraft.AbortedException;
import net.lax1dude.eaglercraft.ConfigConstants;
import net.lax1dude.eaglercraft.EaglerAdapter;
import net.lax1dude.eaglercraft.GuiScreenNoRelays;
import net.lax1dude.eaglercraft.GuiScreenSkinCapeSettings;
import net.lax1dude.eaglercraft.GuiVoiceMenu;
import net.lax1dude.eaglercraft.IntegratedServer;
@ -66,12 +67,19 @@ public class GuiIngameMenu extends GuiScreen {
case 7:
if (IntegratedServerLAN.isHostingLAN()) {
this.mc.lanState = false;
IntegratedServerLAN.closeLAN();
IntegratedServer.configureLAN(this.mc.theWorld.getWorldInfo().getGameType(), false);
this.mc.thePlayer.sendChatToPlayer(StatCollector.translateToLocal("lanServer.closed"));
this.mc.displayGuiScreen((GuiScreen) null);
this.mc.setIngameFocus();
this.mc.sndManager.resumeAllSounds();
} else {
this.mc.displayGuiScreen(new GuiShareToLan(this));
if(IntegratedServer.relayManager.count() == 0) {
this.mc.displayGuiScreen(new GuiScreenNoRelays(this, "noRelay.title"));
}else {
this.mc.displayGuiScreen(new GuiShareToLan(this));
}
}
break;
@ -98,9 +106,9 @@ public class GuiIngameMenu extends GuiScreen {
this.drawDefaultBackground();
this.drawCenteredString(this.fontRenderer, "Game menu", this.width / 2, 40, 16777215);
super.drawScreen(par1, par2, par3);
StringTranslate var1 = StringTranslate.getInstance();
if(par1 >= 3 && par1 < 123 && par2 >= 3 && par2 < 23) {
int c = 0xCCCC66;
StringTranslate var1 = StringTranslate.getInstance();
EaglerAdapter.glPushMatrix();
EaglerAdapter.glTranslatef(126.0f, 6.0f, 0.0f);
EaglerAdapter.glScalef(0.8f, 0.8f, 0.8f);
@ -108,9 +116,40 @@ public class GuiIngameMenu extends GuiScreen {
this.drawString(fontRenderer, var1.translateKey("menu.skinCapeSettingsNote1"), 0, 9, c);
EaglerAdapter.glPopMatrix();
}
drawString(fontRenderer, "Eaglercraft: " + ConfigConstants.version, 6, 27, 0x999999);
if(IntegratedServerLAN.isHostingLAN()) {
String str = var1.translateKey("lanServer.pauseMenu0");
drawString(fontRenderer, str, 6, 52, 0xFFFF55);
if(mc.gameSettings.hideJoinCode) {
EaglerAdapter.glPushMatrix();
EaglerAdapter.glTranslatef(7.0f, 67.0f, 0.0f);
EaglerAdapter.glScalef(0.75f, 0.75f, 0.75f);
str = var1.translateKey("lanServer.showCode");
int w = fontRenderer.getStringWidth(str);
boolean hover = par1 > 6 && par1 < 8 + w * 3 / 4 && par2 > 66 && par2 < 67 + 8;
drawString(fontRenderer, EnumChatFormatting.UNDERLINE + str, 0, 0, hover ? 0xEEEEAA : 0xCCCC55);
EaglerAdapter.glPopMatrix();
}else {
int w = fontRenderer.getStringWidth(str);
EaglerAdapter.glPushMatrix();
EaglerAdapter.glTranslatef(6 + w + 3, 53, 0.0f);
EaglerAdapter.glScalef(0.75f, 0.75f, 0.75f);
str = var1.translateKey("lanServer.hideCode");
int w2 = fontRenderer.getStringWidth(str);
boolean hover = par1 > 6 + w + 2 && par1 < 6 + w + 3 + w2 * 3 / 4 && par2 > 53 - 1 && par2 < 53 + 6;
drawString(fontRenderer, EnumChatFormatting.UNDERLINE + str, 0, 0, hover ? 0xEEEEAA : 0xCCCC55);
EaglerAdapter.glPopMatrix();
drawString(fontRenderer, EnumChatFormatting.GRAY + var1.translateKey("lanServer.pauseMenu1") + " " +
EnumChatFormatting.RESET + IntegratedServerLAN.getCurrentURI(), 6, 67, 0xFFFFFF);
drawString(fontRenderer, EnumChatFormatting.GRAY + var1.translateKey("lanServer.pauseMenu2") + " " +
EnumChatFormatting.RESET + IntegratedServerLAN.getCurrentCode(), 6, 77, 0xFFFFFF);
}
}
try {
if(!mc.isSingleplayer()) {
if(voiceMenu.isBlockingInput()) {
@ -149,6 +188,30 @@ public class GuiIngameMenu extends GuiScreen {
if(!mc.isSingleplayer()) {
voiceMenu.mouseClicked(par1, par2, par3);
}
if(par3 == 0) {
StringTranslate var1 = StringTranslate.getInstance();
if(mc.gameSettings.hideJoinCode) {
String str = var1.translateKey("lanServer.showCode");
int w = fontRenderer.getStringWidth(str);
if(par1 > 6 && par1 < 8 + w * 3 / 4 && par2 > 66 && par2 < 67 + 8) {
mc.gameSettings.hideJoinCode = false;
mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F);
mc.gameSettings.saveOptions();
}
}else {
String str = var1.translateKey("lanServer.pauseMenu0");
int w = fontRenderer.getStringWidth(str);
str = var1.translateKey("lanServer.hideCode");
int w2 = fontRenderer.getStringWidth(str);
if(par1 > 6 + w + 2 && par1 < 6 + w + 3 + w2 * 3 / 4 && par2 > 53 - 1 && par2 < 53 + 6) {
mc.gameSettings.hideJoinCode = true;
mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F);
mc.gameSettings.saveOptions();
}
}
}
super.mouseClicked(par1, par2, par3);
}catch(AbortedException ex) {
}

View file

@ -1,5 +1,7 @@
package net.minecraft.src;
import net.lax1dude.eaglercraft.GuiNetworkSettingsButton;
import net.lax1dude.eaglercraft.GuiScreenNoRelays;
import net.lax1dude.eaglercraft.IntegratedServer;
import net.lax1dude.eaglercraft.IntegratedServerLAN;
@ -11,6 +13,7 @@ public class GuiShareToLan extends GuiScreen {
private final GuiScreen parentScreen;
private GuiButton buttonAllowCommandsToggle;
private GuiButton buttonGameMode;
private GuiButton buttonHiddenToggle;
/**
* The currently selected game mode. One of 'survival', 'creative', or
@ -20,9 +23,16 @@ public class GuiShareToLan extends GuiScreen {
/** True if 'Allow Cheats' is currently enabled */
private boolean allowCommands;
private final GuiNetworkSettingsButton relaysButton;
private boolean hiddenToggle;
private GuiTextField codeTextField;
public GuiShareToLan(GuiScreen par1GuiScreen) {
this.parentScreen = par1GuiScreen;
this.relaysButton = new GuiNetworkSettingsButton(this);
}
/**
@ -34,10 +44,16 @@ public class GuiShareToLan extends GuiScreen {
StatCollector.translateToLocal("lanServer.start")));
this.buttonList.add(new GuiButton(102, this.width / 2 + 5, this.height - 28, 150, 20,
StatCollector.translateToLocal("gui.cancel")));
this.buttonList.add(this.buttonGameMode = new GuiButton(104, this.width / 2 - 155, 100, 150, 20,
this.buttonList.add(this.buttonGameMode = new GuiButton(104, this.width / 2 - 155, 160, 150, 20,
StatCollector.translateToLocal("selectWorld.gameMode")));
this.buttonList.add(this.buttonAllowCommandsToggle = new GuiButton(103, this.width / 2 + 5, 100, 150, 20,
this.buttonList.add(this.buttonAllowCommandsToggle = new GuiButton(103, this.width / 2 + 5, 160, 150, 20,
StatCollector.translateToLocal("selectWorld.allowCommands")));
this.buttonList.add(this.buttonHiddenToggle = new GuiButton(105, this.width / 2 - 75, 190, 150, 20,
StatCollector.translateToLocal("lanServer.hidden")));
this.codeTextField = new GuiTextField(this.fontRenderer, this.width / 2 - 100, 100, 200, 20);
this.codeTextField.setText(mc.thePlayer.username + "'s World");
this.codeTextField.setFocused(true);
this.codeTextField.setMaxStringLength(252);
this.func_74088_g();
}
@ -46,6 +62,8 @@ public class GuiShareToLan extends GuiScreen {
+ StatCollector.translateToLocal("selectWorld.gameMode." + this.gameMode);
this.buttonAllowCommandsToggle.displayString = StatCollector.translateToLocal("selectWorld.allowCommands")
+ " ";
this.buttonHiddenToggle.displayString = StatCollector.translateToLocal("lanServer.hidden")
+ " ";
if (this.allowCommands) {
this.buttonAllowCommandsToggle.displayString = this.buttonAllowCommandsToggle.displayString
@ -54,6 +72,14 @@ public class GuiShareToLan extends GuiScreen {
this.buttonAllowCommandsToggle.displayString = this.buttonAllowCommandsToggle.displayString
+ StatCollector.translateToLocal("options.off");
}
if(this.hiddenToggle) {
this.buttonHiddenToggle.displayString = this.buttonHiddenToggle.displayString
+ StatCollector.translateToLocal("options.on");
} else {
this.buttonHiddenToggle.displayString = this.buttonHiddenToggle.displayString
+ StatCollector.translateToLocal("options.off");
}
}
/**
@ -76,23 +102,29 @@ public class GuiShareToLan extends GuiScreen {
} else if (par1GuiButton.id == 103) {
this.allowCommands = !this.allowCommands;
this.func_74088_g();
} else if (par1GuiButton.id == 104) {
this.hiddenToggle = !this.hiddenToggle;
this.func_74088_g();
} else if (par1GuiButton.id == 101) {
String worldName = this.codeTextField.getText().trim();
if(worldName.length() == 0) {
worldName = mc.thePlayer.username + "'s World";
}
if(worldName.length() >= 252) {
worldName = worldName.substring(0, 252);
}
this.mc.displayGuiScreen((GuiScreen) null);
LoadingScreenRenderer ls = mc.loadingScreen;
IntegratedServer.configureLAN(EnumGameType.getByName(this.gameMode), this.allowCommands);
String code = IntegratedServerLAN.shareToLAN((str) -> ls.displayProgressMessage(str), null, false);
//TODO: handle code success or failure, redirect to relay list on failure, on success store code and relay and display in pause menu
//TODO: must call IntegratedServer.configureLAN(mc.theWorld.getGameType(), false); when world is closed
String var3;
String code = IntegratedServerLAN.shareToLAN((str) -> ls.resetProgresAndWorkingMessage(str), worldName, hiddenToggle);
if (code != null) {
var3 = StatCollector.translateToLocalFormatted("commands.publish.started", code);
this.mc.ingameGUI.getChatGUI().printChatMessage(StringTranslate.getInstance().translateKey("lanServer.opened")
.replace("$relay$", IntegratedServerLAN.getCurrentURI()).replace("$code$", code));
this.mc.lanState = true;
} else {
var3 = StatCollector.translateToLocal("commands.publish.failed");
IntegratedServer.configureLAN(mc.theWorld.getWorldInfo().getGameType(), false);
this.mc.displayGuiScreen(new GuiScreenNoRelays(this, "noRelay.titleFail"));
}
this.mc.ingameGUI.getChatGUI().printChatMessage(var3);
}
}
@ -103,8 +135,29 @@ public class GuiShareToLan extends GuiScreen {
this.drawDefaultBackground();
this.drawCenteredString(this.fontRenderer, StatCollector.translateToLocal("lanServer.title"), this.width / 2,
50, 16777215);
this.drawCenteredString(this.fontRenderer, StatCollector.translateToLocal("lanServer.worldName"), this.width / 2,
82, 16777215);
this.drawCenteredString(this.fontRenderer, StatCollector.translateToLocal("lanServer.otherPlayers"),
this.width / 2, 82, 16777215);
this.width / 2, 142, 16777215);
super.drawScreen(par1, par2, par3);
this.relaysButton.drawScreen(par1, par2);
this.codeTextField.drawTextBox();
}
public void mouseClicked(int par1, int par2, int par3) {
super.mouseClicked(par1, par2, par3);
this.relaysButton.mouseClicked(par1, par2, par3);
this.codeTextField.mouseClicked(par1, par2, par3);
}
protected void keyTyped(char c, int k) {
super.keyTyped(c, k);
this.codeTextField.textboxKeyTyped(c, k);
}
public void updateScreen() {
super.updateScreen();
this.codeTextField.updateCursorCounter();
}
}

View file

@ -55,6 +55,11 @@ public class NetClientHandler extends NetHandler {
/** RNG. */
EaglercraftRandom rand = new EaglercraftRandom();
public NetClientHandler(Minecraft par1Minecraft, INetworkManager mgr) throws IOException {
this.mc = par1Minecraft;
this.netManager = mgr;
}
public NetClientHandler(Minecraft par1Minecraft, String channel) throws IOException {
this.mc = par1Minecraft;
this.netManager = IntegratedServer.openConnection(channel, this);

View file

@ -13,7 +13,6 @@ import org.json.JSONObject;
import net.lax1dude.eaglercraft.Base64;
import net.lax1dude.eaglercraft.ConfigConstants;
import net.lax1dude.eaglercraft.EaglerAdapter;
import net.lax1dude.eaglercraft.IntegratedServer;
import net.lax1dude.eaglercraft.LocalStorageManager;
import net.lax1dude.eaglercraft.RelayEntry;
import net.lax1dude.eaglercraft.ServerQuery.QueryResponse;
@ -164,7 +163,6 @@ public class ServerList {
this.servers.add(dat);
this.allServers.add(dat);
}
IntegratedServer.relayManager.load(LocalStorageManager.gameSettingsStorage.getTagList("relays"));
}
/**

View file

@ -3467,7 +3467,7 @@ public class EaglerAdapterImpl2 {
private final List<Throwable> exceptions = new LinkedList();
private final List<IPacket> packets = new LinkedList();
private RelayServerSocketImpl(String uri) {
private RelayServerSocketImpl(String uri, int timeout) {
this.uri = uri;
WebSocket s = null;
try {
@ -3525,6 +3525,17 @@ public class EaglerAdapterImpl2 {
closed = true;
}
});
Window.setTimeout(new TimerHandler() {
@Override
public void onTimer() {
if(!open && !closed) {
closed = true;
sock.close();
}
}
}, timeout);
}
@Override
@ -3669,7 +3680,7 @@ public class EaglerAdapterImpl2 {
}
public static final RelayServerSocket openRelayConnection(String addr) {
public static final RelayServerSocket openRelayConnection(String addr, int timeout) {
long millis = System.currentTimeMillis();
Long l = relayQueryBlocked.get(addr);
@ -3682,7 +3693,7 @@ public class EaglerAdapterImpl2 {
return new RelayServerSocketRatelimitDummy(RateLimit.BLOCKED);
}
return new RelayServerSocketImpl(addr);
return new RelayServerSocketImpl(addr, timeout);
}
private static EaglercraftLANClient rtcLANClient = null;
@ -3759,9 +3770,7 @@ public class EaglerAdapterImpl2 {
}
public static final void clientLANSendPacket(byte[] pkt) {
ArrayBuffer arr = ArrayBuffer.create(pkt.length);
Uint8Array.create(arr).set(pkt);
rtcLANClient.sendPacketToServer(arr);
rtcLANClient.sendPacketToServer(convertToArrayBuffer(pkt));
}
public static final byte[] clientLANReadPacket() {