diff --git a/README.md b/README.md index b917c8a..9ddcd5b 100644 --- a/README.md +++ b/README.md @@ -55,7 +55,7 @@ If you would like to invite other players to join your singleplayer world and pl Once you press "Start Shared World", EaglercraftX 1.8 will give you a "join code" (usually 5 letters) to share with your friends. On a different device, go the "Multiplayer" screen and press "Direct Connect" and press "Join Shared World", enter the join code given to you when you started the shared world and press "Join World". Given a few seconds, the client should successfully be able to join your shared world from any other device on the internet that also has unrestricted internet access. If it does not work, check the "Network Settings" screen and make sure you and your friends all have the same set of shared world relay URLs configured or your clients will not be able to find each other. -If you would like to host your own relay, the JAR file and instructions can be downloaded from the "Network Settings" screen in the client. EaglercraftX 1.8 uses the same "LAN world" relay server that is used by Eaglercraft 1.5.2, if you would like the relay source code find a random copy of the Eaglercraft 1.5.2 source code and it should be located in the "sp-relay" folder. The relay has not been updated since then, it has only been renamed from "LAN world relay" to "Shared world relay". +If you would like to host your own relay, the JAR file and instructions can be downloaded from the "Network Settings" screen in the client. EaglercraftX 1.8 uses the same "LAN world" relay server that is used by Eaglercraft 1.5.2, however there have been several bug fixes. The current version is available in the `sp-relay/SharedWorldRelay` folder. ## PBR Shaders diff --git a/sp-relay/SharedWorldRelay/SharedWorldRelay-Latest.jar b/sp-relay/SharedWorldRelay/SharedWorldRelay-Latest.jar index 615b4ef..1363573 100644 Binary files a/sp-relay/SharedWorldRelay/SharedWorldRelay-Latest.jar and b/sp-relay/SharedWorldRelay/SharedWorldRelay-Latest.jar differ diff --git a/sp-relay/SharedWorldRelay/src/main/java/net/lax1dude/eaglercraft/v1_8/sp/relay/server/Constants.java b/sp-relay/SharedWorldRelay/src/main/java/net/lax1dude/eaglercraft/v1_8/sp/relay/server/Constants.java index ec52aab..d443fcb 100644 --- a/sp-relay/SharedWorldRelay/src/main/java/net/lax1dude/eaglercraft/v1_8/sp/relay/server/Constants.java +++ b/sp-relay/SharedWorldRelay/src/main/java/net/lax1dude/eaglercraft/v1_8/sp/relay/server/Constants.java @@ -17,7 +17,7 @@ package net.lax1dude.eaglercraft.v1_8.sp.relay.server; */ public class Constants { - public static final String versionName = "1.0"; + public static final String versionName = "1.1"; public static final String versionBrand = "lax1dude"; public static final int protocolVersion = 1; diff --git a/sp-relay/SharedWorldRelay/src/main/java/net/lax1dude/eaglercraft/v1_8/sp/relay/server/EaglerSPClient.java b/sp-relay/SharedWorldRelay/src/main/java/net/lax1dude/eaglercraft/v1_8/sp/relay/server/EaglerSPClient.java index 51aa590..bc758d6 100644 --- a/sp-relay/SharedWorldRelay/src/main/java/net/lax1dude/eaglercraft/v1_8/sp/relay/server/EaglerSPClient.java +++ b/sp-relay/SharedWorldRelay/src/main/java/net/lax1dude/eaglercraft/v1_8/sp/relay/server/EaglerSPClient.java @@ -41,17 +41,17 @@ public class EaglerSPClient { } public void send(RelayPacket packet) { - if(this.socket.isOpen()) { + if(socket.isOpen()) { try { - this.socket.send(RelayPacket.writePacket(packet, EaglerSPRelay.logger)); + socket.send(RelayPacket.writePacket(packet, EaglerSPRelay.logger)); }catch(IOException ex) { - EaglerSPRelay.logger.debug("Error sending data to {}", (String) this.socket.getAttachment()); + EaglerSPRelay.logger.debug("Error sending data to {}", socket.getAttachment()); EaglerSPRelay.logger.debug(ex); disconnect(RelayPacketFEDisconnectClient.TYPE_INTERNAL_ERROR, "Internal Server Error"); - this.socket.close(); + socket.close(); } }else { - EaglerSPRelay.logger.debug("WARNING: Tried to send data to {} after the connection closed.", (String) this.socket.getAttachment()); + EaglerSPRelay.logger.debug("WARNING: Tried to send data to {} after the connection closed.", socket.getAttachment()); } } @@ -60,21 +60,21 @@ public class EaglerSPClient { if(LoginState.assertEquals(this, LoginState.RECIEVED_DESCRIPTION)) { state = LoginState.SENT_ICE_CANDIDATE; server.handleClientICECandidate(this, (RelayPacket03ICECandidate)packet); - EaglerSPRelay.logger.debug("[{}][Client -> Relay -> Server] PKT 0x03: ICECandidate", (String) socket.getAttachment()); + EaglerSPRelay.logger.debug("[{}][Client -> Relay -> Server] PKT 0x03: ICECandidate", socket.getAttachment()); } return true; }else if(packet instanceof RelayPacket04Description) { if(LoginState.assertEquals(this, LoginState.INIT)) { state = LoginState.SENT_DESCRIPTION; server.handleClientDescription(this, (RelayPacket04Description)packet); - EaglerSPRelay.logger.debug("[{}][Client -> Relay -> Server] PKT 0x04: Description", (String) socket.getAttachment()); + EaglerSPRelay.logger.debug("[{}][Client -> Relay -> Server] PKT 0x04: Description", socket.getAttachment()); } return true; }else if(packet instanceof RelayPacket05ClientSuccess) { if(LoginState.assertEquals(this, LoginState.RECIEVED_ICE_CANIDATE)) { state = LoginState.FINISHED; server.handleClientSuccess(this, (RelayPacket05ClientSuccess)packet); - EaglerSPRelay.logger.debug("[{}][Client -> Relay -> Server] PKT 0x05: ClientSuccess", (String) socket.getAttachment()); + EaglerSPRelay.logger.debug("[{}][Client -> Relay -> Server] PKT 0x05: ClientSuccess", socket.getAttachment()); disconnect(RelayPacketFEDisconnectClient.TYPE_FINISHED_SUCCESS, "Successful connection"); } return true; @@ -82,7 +82,7 @@ public class EaglerSPClient { if(LoginState.assertEquals(this, LoginState.RECIEVED_ICE_CANIDATE)) { state = LoginState.FINISHED; server.handleClientFailure(this, (RelayPacket06ClientFailure)packet); - EaglerSPRelay.logger.debug("[{}][Client -> Relay -> Server] PKT 0x05: ClientFailure", (String) socket.getAttachment()); + EaglerSPRelay.logger.debug("[{}][Client -> Relay -> Server] PKT 0x05: ClientFailure", socket.getAttachment()); disconnect(RelayPacketFEDisconnectClient.TYPE_FINISHED_FAILED, "Failed connection"); } return true; @@ -109,11 +109,11 @@ public class EaglerSPClient { if (code != RelayPacketFEDisconnectClient.TYPE_FINISHED_SUCCESS) server.send(pkt); serverNotifiedOfClose = true; } - if(this.socket.isOpen()) { + if(socket.isOpen()) { send(pkt); socket.close(); } - EaglerSPRelay.logger.debug("[{}][Relay -> Client] PKT 0xFE: #{} {}", (String) socket.getAttachment(), code, reason); + EaglerSPRelay.logger.debug("[{}][Relay -> Client] PKT 0xFE: #{} {}", socket.getAttachment(), code, reason); } public static final int clientCodeLength = 16; diff --git a/sp-relay/SharedWorldRelay/src/main/java/net/lax1dude/eaglercraft/v1_8/sp/relay/server/EaglerSPRelay.java b/sp-relay/SharedWorldRelay/src/main/java/net/lax1dude/eaglercraft/v1_8/sp/relay/server/EaglerSPRelay.java index 42fdc5b..fc4a7b7 100644 --- a/sp-relay/SharedWorldRelay/src/main/java/net/lax1dude/eaglercraft/v1_8/sp/relay/server/EaglerSPRelay.java +++ b/sp-relay/SharedWorldRelay/src/main/java/net/lax1dude/eaglercraft/v1_8/sp/relay/server/EaglerSPRelay.java @@ -202,7 +202,7 @@ public class EaglerSPRelay extends WebSocketServer { } if(totalCons >= config.getConnectionsPerIP()) { - logger.debug("[{}]: Too many connections are open on this address", (String) arg0.getAttachment()); + logger.debug("[{}]: Too many connections are open on this address", arg0.getAttachment()); arg0.send(RelayPacketFEDisconnectClient.ratelimitPacketTooMany); arg0.close(); return; @@ -231,7 +231,7 @@ public class EaglerSPRelay extends WebSocketServer { RelayPacket00Handshake ipkt = (RelayPacket00Handshake)pkt; if(ipkt.connectionVersion != Constants.protocolVersion) { logger.debug("[{}]: Connected with unsupported protocol version: {} (supported " - + "version: {})", (String) arg0.getAttachment(), ipkt.connectionVersion, Constants.protocolVersion); + + "version: {})", arg0.getAttachment(), ipkt.connectionVersion, Constants.protocolVersion); if(ipkt.connectionVersion < Constants.protocolVersion) { arg0.send(RelayPacket.writePacket(new RelayPacketFFErrorCode(RelayPacketFFErrorCode.TYPE_PROTOCOL_VERSION, "Outdated Client! (v" + Constants.protocolVersion + " req)"), EaglerSPRelay.logger)); @@ -244,21 +244,21 @@ public class EaglerSPRelay extends WebSocketServer { } if(ipkt.connectionType == 0x01) { if(!rateLimit(worldRateLimiter, arg0, waiting.address)) { - logger.debug("[{}]: Got world ratelimited", (String) arg0.getAttachment()); + logger.debug("[{}]: Got world ratelimited", arg0.getAttachment()); return; } synchronized(serverAddressSets) { List lst = serverAddressSets.get(waiting.address); if(lst != null) { if(lst.size() >= config.getWorldsPerIP()) { - logger.debug("[{}]: Too many worlds are open on this address", (String) arg0.getAttachment()); + logger.debug("[{}]: Too many worlds are open on this address", arg0.getAttachment()); arg0.send(RelayPacketFEDisconnectClient.ratelimitPacketTooMany); arg0.close(); return; } } } - logger.debug("[{}]: Connected as a server", (String) arg0.getAttachment()); + logger.debug("[{}]: Connected as a server", arg0.getAttachment()); EaglerSPServer srv; synchronized(serverCodes) { int j = 0; @@ -266,7 +266,7 @@ public class EaglerSPRelay extends WebSocketServer { do { if(++j > 100) { logger.error("Error: relay is running out of codes!"); - logger.error("Closing connection to {}", (String) arg0.getAttachment()); + logger.error("Closing connection to {}", arg0.getAttachment()); arg0.send(RelayPacket.writePacket(new RelayPacketFFErrorCode(RelayPacketFFErrorCode.TYPE_INTERNAL_ERROR, "Internal Server Error"), EaglerSPRelay.logger)); arg0.close(); @@ -278,7 +278,7 @@ public class EaglerSPRelay extends WebSocketServer { serverCodes.put(code, srv); ipkt.connectionCode = code; arg0.send(RelayPacket.writePacket(ipkt, EaglerSPRelay.logger)); - logger.debug("[{}][Relay -> Server] PKT 0x00: Assign join code: {}", (String) arg0.getAttachment(), code); + logger.debug("[{}][Relay -> Server] PKT 0x00: Assign join code: {}", arg0.getAttachment(), code); } synchronized(serverConnections) { serverConnections.put(arg0, srv); @@ -292,15 +292,15 @@ public class EaglerSPRelay extends WebSocketServer { lst.add(srv); } srv.send(new RelayPacket01ICEServers(EaglerSPRelayConfigRelayList.relayServers)); - logger.debug("[{}][Relay -> Server] PKT 0x01: Send ICE server list to server", (String) arg0.getAttachment()); + logger.debug("[{}][Relay -> Server] PKT 0x01: Send ICE server list to server", arg0.getAttachment()); }else { if(!rateLimit(pingRateLimiter, arg0, waiting.address)) { - logger.debug("[{}]: Got ping ratelimited", (String) arg0.getAttachment()); + logger.debug("[{}]: Got ping ratelimited", arg0.getAttachment()); return; } if(ipkt.connectionType == 0x02) { String code = ipkt.connectionCode; - logger.debug("[{}]: Connected as a client, requested server code: {}", (String) arg0.getAttachment(), code); + logger.debug("[{}]: Connected as a client, requested server code: {}", arg0.getAttachment(), code); if(code.length() != config.getCodeLength()) { logger.debug("The code '{}' is invalid because it's the wrong length, disconnecting", code); arg0.send(RelayPacket.writePacket(new RelayPacketFFErrorCode(RelayPacketFFErrorCode.TYPE_CODE_LENGTH, @@ -345,14 +345,14 @@ public class EaglerSPRelay extends WebSocketServer { lst.add(cl); } cl.send(new RelayPacket01ICEServers(EaglerSPRelayConfigRelayList.relayServers)); - logger.debug("[{}][Relay -> Client] PKT 0x01: Send ICE server list to client", (String) arg0.getAttachment()); + logger.debug("[{}][Relay -> Client] PKT 0x01: Send ICE server list to client", arg0.getAttachment()); } }else if(ipkt.connectionType == 0x03) { - logger.debug("[{}]: Pinging the server", (String) arg0.getAttachment()); + logger.debug("[{}]: Pinging the server", arg0.getAttachment()); arg0.send(RelayPacket.writePacket(new RelayPacket69Pong(Constants.protocolVersion, config.getComment(), Constants.versionBrand), EaglerSPRelay.logger)); arg0.close(); }else if(ipkt.connectionType == 0x04) { - logger.debug("[{}]: Polling the server for other worlds", (String) arg0.getAttachment()); + logger.debug("[{}]: Polling the server for other worlds", arg0.getAttachment()); if(config.isEnableShowLocals()) { arg0.send(RelayPacket.writePacket(new RelayPacket07LocalWorlds(getLocalWorlds(waiting.address)), EaglerSPRelay.logger)); }else { @@ -360,7 +360,7 @@ public class EaglerSPRelay extends WebSocketServer { } arg0.close(); }else { - logger.debug("[{}]: Unknown connection type: {}", (String) arg0.getAttachment(), ipkt.connectionType); + logger.debug("[{}]: Unknown connection type: {}", arg0.getAttachment(), ipkt.connectionType); arg0.send(RelayPacket.writePacket(new RelayPacketFFErrorCode(RelayPacketFFErrorCode.TYPE_ILLEGAL_OPERATION, "Unexpected Init Packet"), EaglerSPRelay.logger)); arg0.close(); @@ -368,7 +368,7 @@ public class EaglerSPRelay extends WebSocketServer { } }else { logger.debug("[{}]: Pending connection did not send a 0x00 packet to identify " - + "as a client or server", (String) arg0.getAttachment()); + + "as a client or server", arg0.getAttachment()); arg0.send(RelayPacket.writePacket(new RelayPacketFFErrorCode(RelayPacketFFErrorCode.TYPE_ILLEGAL_OPERATION, "Unexpected Init Packet"), EaglerSPRelay.logger)); arg0.close(); @@ -380,7 +380,7 @@ public class EaglerSPRelay extends WebSocketServer { } if(srv != null) { if(!srv.handle(pkt)) { - logger.debug("[{}]: Server sent invalid packet: {}", (String) arg0.getAttachment(), pkt.getClass().getSimpleName()); + logger.debug("[{}]: Server sent invalid packet: {}", arg0.getAttachment(), pkt.getClass().getSimpleName()); arg0.send(RelayPacket.writePacket(new RelayPacketFFErrorCode(RelayPacketFFErrorCode.TYPE_INVALID_PACKET, "Invalid Packet Recieved"), EaglerSPRelay.logger)); arg0.close(); @@ -392,13 +392,13 @@ public class EaglerSPRelay extends WebSocketServer { } if(cl != null) { if(!cl.handle(pkt)) { - logger.debug("[{}]: Client sent invalid packet: {}", (String) arg0.getAttachment(), pkt.getClass().getSimpleName()); + logger.debug("[{}]: Client sent invalid packet: {}", arg0.getAttachment(), pkt.getClass().getSimpleName()); arg0.send(RelayPacket.writePacket(new RelayPacketFFErrorCode(RelayPacketFFErrorCode.TYPE_INVALID_PACKET, "Invalid Packet Recieved"), EaglerSPRelay.logger)); arg0.close(); } }else { - logger.debug("[{}]: Connection has no client/server attached to it!", (String) arg0.getAttachment()); + logger.debug("[{}]: Connection has no client/server attached to it!", arg0.getAttachment()); arg0.send(RelayPacket.writePacket(new RelayPacketFFErrorCode(RelayPacketFFErrorCode.TYPE_ILLEGAL_OPERATION, "Internal Server Error"), EaglerSPRelay.logger)); arg0.close(); @@ -406,14 +406,14 @@ public class EaglerSPRelay extends WebSocketServer { } } }catch(Throwable t) { - logger.error("[{}]: Failed to handle binary frame: {}", (String) arg0.getAttachment(), t); + logger.error("[{}]: Failed to handle binary frame: {}", arg0.getAttachment(), t); arg0.close(); } } @Override public void onMessage(WebSocket arg0, String arg1) { - logger.debug("[{}]: Sent a text frame, disconnecting", (String) arg0.getAttachment()); + logger.debug("[{}]: Sent a text frame, disconnecting", arg0.getAttachment()); arg0.close(); } @@ -424,7 +424,7 @@ public class EaglerSPRelay extends WebSocketServer { srv = serverConnections.remove(arg0); } if(srv != null) { - logger.debug("[{}]: Server closed, code: {}", (String) arg0.getAttachment(), srv.code); + logger.debug("[{}]: Server closed, code: {}", arg0.getAttachment(), srv.code); synchronized(serverCodes) { serverCodes.remove(srv.code); } @@ -445,7 +445,7 @@ public class EaglerSPRelay extends WebSocketServer { while(itr.hasNext()) { EaglerSPClient cl = itr.next(); if(cl.server == srv) { - logger.debug("[{}]: Disconnecting client: {} (id: ", (String) cl.socket.getAttachment(), cl.id); + logger.debug("[{}]: Disconnecting client: {} (id: {})", cl.socket.getAttachment(), cl.id); cl.socket.close(); } } @@ -464,22 +464,22 @@ public class EaglerSPRelay extends WebSocketServer { } } } - logger.debug("[{}]: Client closed, id: {}", (String) arg0.getAttachment(), cl.id); + logger.debug("[{}]: Client closed, id: {}", 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", arg0.getAttachment()); } } } @Override public void onError(WebSocket arg0, Exception arg1) { - logger.error("[{}]: Exception thrown: {}", (arg0 == null ? "SERVER" : (String) arg0.getAttachment()), arg1.toString()); + logger.error("[{}]: Exception thrown: {}", (arg0 == null ? "SERVER" : arg0.getAttachment()), arg1.toString()); logger.debug(arg1); - arg0.close(); + if(arg0 != null) arg0.close(); } private List getLocalWorlds(String addr) { diff --git a/sp-relay/SharedWorldRelay/src/main/java/net/lax1dude/eaglercraft/v1_8/sp/relay/server/EaglerSPServer.java b/sp-relay/SharedWorldRelay/src/main/java/net/lax1dude/eaglercraft/v1_8/sp/relay/server/EaglerSPServer.java index 7e7686c..c019b21 100644 --- a/sp-relay/SharedWorldRelay/src/main/java/net/lax1dude/eaglercraft/v1_8/sp/relay/server/EaglerSPServer.java +++ b/sp-relay/SharedWorldRelay/src/main/java/net/lax1dude/eaglercraft/v1_8/sp/relay/server/EaglerSPServer.java @@ -52,21 +52,21 @@ public class EaglerSPServer { } public void send(RelayPacket packet) { - if(this.socket.isOpen()) { + if(socket.isOpen()) { try { - this.socket.send(RelayPacket.writePacket(packet, EaglerSPRelay.logger)); + socket.send(RelayPacket.writePacket(packet, EaglerSPRelay.logger)); }catch(IOException ex) { - EaglerSPRelay.logger.debug("Error sending data to {}", this.serverAddress); + EaglerSPRelay.logger.debug("Error sending data to {}", serverAddress); EaglerSPRelay.logger.debug(ex); try { - this.socket.send(RelayPacket.writePacket(new RelayPacketFFErrorCode(RelayPacketFFErrorCode.TYPE_INTERNAL_ERROR, + socket.send(RelayPacket.writePacket(new RelayPacketFFErrorCode(RelayPacketFFErrorCode.TYPE_INTERNAL_ERROR, "Internal Server Error"), EaglerSPRelay.logger)); }catch(IOException ex2) { } - this.socket.close(); + socket.close(); } }else { - EaglerSPRelay.logger.debug("WARNING: Tried to send data to {} after the connection closed.", this.serverAddress); + EaglerSPRelay.logger.debug("WARNING: Tried to send data to {} after the connection closed.", serverAddress); } } @@ -78,10 +78,10 @@ public class EaglerSPServer { if(LoginState.assertEquals(cl, LoginState.SENT_ICE_CANDIDATE)) { cl.state = LoginState.RECIEVED_ICE_CANIDATE; cl.handleServerICECandidate(packet); - EaglerSPRelay.logger.debug("[{}][Server -> Relay -> Client] PKT 0x03: ICECandidate", (String) cl.socket.getAttachment()); + EaglerSPRelay.logger.debug("[{}][Server -> Relay -> Client] PKT 0x03: ICECandidate", cl.socket.getAttachment()); } }else { - this.socket.send(RelayPacket.writePacket(new RelayPacketFFErrorCode(RelayPacketFFErrorCode.TYPE_UNKNOWN_CLIENT, + socket.send(RelayPacket.writePacket(new RelayPacketFFErrorCode(RelayPacketFFErrorCode.TYPE_UNKNOWN_CLIENT, "Unknown Client ID: " + packet.peerId), EaglerSPRelay.logger)); } return true; @@ -92,10 +92,10 @@ public class EaglerSPServer { if(LoginState.assertEquals(cl, LoginState.SENT_DESCRIPTION)) { cl.state = LoginState.RECIEVED_DESCRIPTION; cl.handleServerDescription(packet); - EaglerSPRelay.logger.debug("[{}][Server -> Relay -> Client] PKT 0x04: Description", (String) cl.socket.getAttachment()); + EaglerSPRelay.logger.debug("[{}][Server -> Relay -> Client] PKT 0x04: Description", cl.socket.getAttachment()); } }else { - this.socket.send(RelayPacket.writePacket(new RelayPacketFFErrorCode(RelayPacketFFErrorCode.TYPE_UNKNOWN_CLIENT, + socket.send(RelayPacket.writePacket(new RelayPacketFFErrorCode(RelayPacketFFErrorCode.TYPE_UNKNOWN_CLIENT, "Unknown Client ID: " + packet.peerId), EaglerSPRelay.logger)); } return true; @@ -104,10 +104,10 @@ public class EaglerSPServer { EaglerSPClient cl = clients.get(packet.clientId); if(cl != null) { cl.handleServerDisconnectClient(packet); - EaglerSPRelay.logger.debug("[{}][Server -> Relay -> Client] PKT 0xFE: Disconnect: {}: {}", (String) cl.socket.getAttachment(), + EaglerSPRelay.logger.debug("[{}][Server -> Relay -> Client] PKT 0xFE: Disconnect: {}: {}", cl.socket.getAttachment(), packet.code, packet.reason); }else { - this.socket.send(RelayPacket.writePacket(new RelayPacketFFErrorCode(RelayPacketFFErrorCode.TYPE_UNKNOWN_CLIENT, + socket.send(RelayPacket.writePacket(new RelayPacketFFErrorCode(RelayPacketFFErrorCode.TYPE_UNKNOWN_CLIENT, "Unknown Client ID: " + packet.clientId), EaglerSPRelay.logger)); } return true;