update to 1.9.4

This commit is contained in:
HoosierTransfer 2024-05-11 10:17:00 -04:00
parent 06f03a918c
commit 82665ab9d6
4 changed files with 778 additions and 697 deletions

Binary file not shown.

View File

@ -81,14 +81,21 @@ import net.md_5.bungee.api.event.ServerConnectEvent;
/**
* Copyright (c) 2022-2024 lax1dude. All Rights Reserved.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED.
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
@ -141,7 +148,8 @@ public class HttpWebSocketHandler extends ChannelInboundHandlerAdapter {
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
if (ctx.channel().isActive()) {
EaglerXBungee.logger().warning("[Yee][" + ctx.channel().remoteAddress() + "]: Exception Caught: " + cause.toString());
EaglerXBungee.logger()
.warning("[Yee][" + ctx.channel().remoteAddress() + "]: Exception Caught: " + cause.toString());
}
}
@ -162,7 +170,8 @@ public class HttpWebSocketHandler extends ChannelInboundHandlerAdapter {
BungeeCord bungus = BungeeCord.getInstance();
int limit = bungus.config.getPlayerLimit();
if (limit > 0 && bungus.getOnlineCount() >= limit) {
sendErrorCode(ctx, HandshakePacketTypes.SERVER_ERROR_CUSTOM_MESSAGE, bungus.getTranslation("proxy_full"))
sendErrorCode(ctx, HandshakePacketTypes.SERVER_ERROR_CUSTOM_MESSAGE,
bungus.getTranslation("proxy_full"))
.addListener(ChannelFutureListener.CLOSE);
connectionClosed = true;
return;
@ -177,7 +186,8 @@ public class HttpWebSocketHandler extends ChannelInboundHandlerAdapter {
}
if (i >= conf.getMaxPlayer()) {
sendErrorCode(ctx, HandshakePacketTypes.SERVER_ERROR_CUSTOM_MESSAGE, bungus.getTranslation("proxy_full"))
sendErrorCode(ctx, HandshakePacketTypes.SERVER_ERROR_CUSTOM_MESSAGE,
bungus.getTranslation("proxy_full"))
.addListener(ChannelFutureListener.CLOSE);
connectionClosed = true;
return;
@ -248,13 +258,14 @@ public class HttpWebSocketHandler extends ChannelInboundHandlerAdapter {
EaglerXBungee eaglerXBungee = EaglerXBungee.getEagler();
EaglerAuthConfig authConfig = eaglerXBungee.getConfig().getAuthConfig();
final int minecraftProtocolVersion = 47;
final int minecraftProtocolVersion = 110;
int eaglerLegacyProtocolVersion = buffer.readUnsignedByte();
if (eaglerLegacyProtocolVersion == 1) {
if (authConfig.isEnableAuthentication()) {
sendErrorCode(ctx, HandshakePacketTypes.SERVER_ERROR_CUSTOM_MESSAGE, "Please update your client to register on this server!")
sendErrorCode(ctx, HandshakePacketTypes.SERVER_ERROR_CUSTOM_MESSAGE,
"Please update your client to register on this server!")
.addListener(ChannelFutureListener.CLOSE);
return;
} else if (buffer.readUnsignedByte() != minecraftProtocolVersion) {
@ -267,7 +278,8 @@ public class HttpWebSocketHandler extends ChannelInboundHandlerAdapter {
String str = "Outdated Client";
buf.writeByte(str.length());
buf.writeCharSequence(str, StandardCharsets.US_ASCII);
ctx.writeAndFlush(new BinaryWebSocketFrame(buf)).addListener(ChannelFutureListener.CLOSE);
ctx.writeAndFlush(new BinaryWebSocketFrame(buf))
.addListener(ChannelFutureListener.CLOSE);
return;
}
} else if (eaglerLegacyProtocolVersion == 2) {
@ -320,12 +332,16 @@ public class HttpWebSocketHandler extends ChannelInboundHandlerAdapter {
boolean isClientProbablyOutdated = false;
if (!hasV2InList && !hasV3InList) {
versMisMatch = true;
isServerProbablyOutdated = minProtVers > 3 && maxProtVers > 3; //make sure to update VersionQueryHandler too
isServerProbablyOutdated = minProtVers > 3 && maxProtVers > 3; // make sure to update
// VersionQueryHandler
// too
isClientProbablyOutdated = minProtVers < 2 && maxProtVers < 2;
} else if (!has47InList) {
versMisMatch = true;
isServerProbablyOutdated = minGameVers > minecraftProtocolVersion && maxGameVers > minecraftProtocolVersion;
isClientProbablyOutdated = minGameVers < minecraftProtocolVersion && maxGameVers < minecraftProtocolVersion;
isServerProbablyOutdated = minGameVers > minecraftProtocolVersion
&& maxGameVers > minecraftProtocolVersion;
isClientProbablyOutdated = minGameVers < minecraftProtocolVersion
&& maxGameVers < minecraftProtocolVersion;
}
clientProtocolVersion = hasV3InList ? 3 : 2;
@ -342,14 +358,17 @@ public class HttpWebSocketHandler extends ChannelInboundHandlerAdapter {
buf.writeShort(1);
buf.writeShort(minecraftProtocolVersion); // want game version 47
String str = isClientProbablyOutdated ? "Outdated Client" : (isServerProbablyOutdated ? "Outdated Server" : "Unsupported Client Version");
String str = isClientProbablyOutdated ? "Outdated Client"
: (isServerProbablyOutdated ? "Outdated Server" : "Unsupported Client Version");
buf.writeByte(str.length());
buf.writeCharSequence(str, StandardCharsets.US_ASCII);
ctx.writeAndFlush(new BinaryWebSocketFrame(buf)).addListener(ChannelFutureListener.CLOSE);
ctx.writeAndFlush(new BinaryWebSocketFrame(buf))
.addListener(ChannelFutureListener.CLOSE);
return;
}
} else {
sendErrorCode(ctx, HandshakePacketTypes.SERVER_ERROR_CUSTOM_MESSAGE, "Legacy protocol version should always be '2' on post-snapshot clients")
sendErrorCode(ctx, HandshakePacketTypes.SERVER_ERROR_CUSTOM_MESSAGE,
"Legacy protocol version should always be '2' on post-snapshot clients")
.addListener(ChannelFutureListener.CLOSE);
return;
}
@ -390,7 +409,7 @@ public class HttpWebSocketHandler extends ChannelInboundHandlerAdapter {
final boolean final_useSnapshotFallbackProtocol = useSnapshotFallbackProtocol;
Runnable continueThread = () -> {
clientLoginState = HandshakePacketTypes.STATE_CLIENT_VERSION;
gameProtocolVersion = 47;
gameProtocolVersion = 110;
clientBrandString = eaglerBrand;
clientVersionString = eaglerVersionString;
@ -419,9 +438,12 @@ public class HttpWebSocketHandler extends ChannelInboundHandlerAdapter {
int meth = getAuthMethodId(authRequireEvent.getUseAuthType());
if (meth == -1) {
sendErrorCode(ctx, HandshakePacketTypes.SERVER_ERROR_CUSTOM_MESSAGE, "Unsupported authentication method resolved")
sendErrorCode(ctx, HandshakePacketTypes.SERVER_ERROR_CUSTOM_MESSAGE,
"Unsupported authentication method resolved")
.addListener(ChannelFutureListener.CLOSE);
EaglerXBungee.logger().severe("[" + localAddrString + "]: Disconnecting, unsupported AuthMethod: " + authRequireEvent.getUseAuthType());
EaglerXBungee.logger()
.severe("[" + localAddrString + "]: Disconnecting, unsupported AuthMethod: "
+ authRequireEvent.getUseAuthType());
return;
}
@ -447,52 +469,66 @@ public class HttpWebSocketHandler extends ChannelInboundHandlerAdapter {
authRequireEvent = new EaglercraftIsAuthRequiredEvent(conf, remoteAddress, origin,
clientAuth, clientAuthUsername, (reqAuthEvent) -> {
if (authRequireEvent.shouldKickUser()) {
sendErrorCode(ctx, HandshakePacketTypes.SERVER_ERROR_CUSTOM_MESSAGE, authRequireEvent.getKickMessage())
sendErrorCode(ctx, HandshakePacketTypes.SERVER_ERROR_CUSTOM_MESSAGE,
authRequireEvent.getKickMessage())
.addListener(ChannelFutureListener.CLOSE);
return;
}
AuthResponse resp = authRequireEvent.getAuthRequired();
if (resp == null) {
sendErrorCode(ctx, HandshakePacketTypes.SERVER_ERROR_CUSTOM_MESSAGE, "IsAuthRequiredEvent was not handled")
sendErrorCode(ctx, HandshakePacketTypes.SERVER_ERROR_CUSTOM_MESSAGE,
"IsAuthRequiredEvent was not handled")
.addListener(ChannelFutureListener.CLOSE);
EaglerXBungee.logger().severe("[" + localAddrString + "]: Disconnecting, no installed authentication system handled: " + authRequireEvent.toString());
EaglerXBungee.logger().severe("[" + localAddrString
+ "]: Disconnecting, no installed authentication system handled: "
+ authRequireEvent.toString());
return;
}
if (resp == AuthResponse.DENY) {
sendErrorCode(ctx, HandshakePacketTypes.SERVER_ERROR_CUSTOM_MESSAGE, authRequireEvent.getKickMessage())
sendErrorCode(ctx, HandshakePacketTypes.SERVER_ERROR_CUSTOM_MESSAGE,
authRequireEvent.getKickMessage())
.addListener(ChannelFutureListener.CLOSE);
return;
}
AuthMethod type = authRequireEvent.getUseAuthType();
if (type == null) {
sendErrorCode(ctx, HandshakePacketTypes.SERVER_ERROR_CUSTOM_MESSAGE, "IsAuthRequiredEvent was not fully handled")
sendErrorCode(ctx, HandshakePacketTypes.SERVER_ERROR_CUSTOM_MESSAGE,
"IsAuthRequiredEvent was not fully handled")
.addListener(ChannelFutureListener.CLOSE);
EaglerXBungee.logger().severe("[" + localAddrString + "]: Disconnecting, no authentication method provided by handler");
EaglerXBungee.logger().severe("[" + localAddrString
+ "]: Disconnecting, no authentication method provided by handler");
return;
}
int typeId = getAuthMethodId(type);
if (typeId == -1) {
sendErrorCode(ctx, HandshakePacketTypes.SERVER_ERROR_CUSTOM_MESSAGE, "Unsupported authentication method resolved")
sendErrorCode(ctx, HandshakePacketTypes.SERVER_ERROR_CUSTOM_MESSAGE,
"Unsupported authentication method resolved")
.addListener(ChannelFutureListener.CLOSE);
EaglerXBungee.logger().severe("[" + localAddrString + "]: Disconnecting, unsupported AuthMethod: " + type);
EaglerXBungee.logger().severe("[" + localAddrString
+ "]: Disconnecting, unsupported AuthMethod: " + type);
return;
}
if (!clientAuth && resp == AuthResponse.REQUIRE) {
sendErrorCode(ctx, HandshakePacketTypes.SERVER_ERROR_AUTHENTICATION_REQUIRED,
HandshakePacketTypes.AUTHENTICATION_REQUIRED + " [" + typeId + "] " + authRequireEvent.getAuthMessage())
sendErrorCode(ctx,
HandshakePacketTypes.SERVER_ERROR_AUTHENTICATION_REQUIRED,
HandshakePacketTypes.AUTHENTICATION_REQUIRED + " [" + typeId
+ "] " + authRequireEvent.getAuthMessage())
.addListener(ChannelFutureListener.CLOSE);
EaglerXBungee.logger().info("[" + localAddrString + "]: Displaying authentication screen");
EaglerXBungee.logger().info(
"[" + localAddrString + "]: Displaying authentication screen");
return;
} else {
if (authRequireEvent.getUseAuthType() == null) {
sendErrorCode(ctx, HandshakePacketTypes.SERVER_ERROR_CUSTOM_MESSAGE, "IsAuthRequiredEvent was not fully handled")
sendErrorCode(ctx, HandshakePacketTypes.SERVER_ERROR_CUSTOM_MESSAGE,
"IsAuthRequiredEvent was not fully handled")
.addListener(ChannelFutureListener.CLOSE);
EaglerXBungee.logger().severe("[" + localAddrString + "]: Disconnecting, no authentication method provided by handler");
EaglerXBungee.logger().severe("[" + localAddrString
+ "]: Disconnecting, no authentication method provided by handler");
return;
}
}
@ -558,8 +594,10 @@ public class HttpWebSocketHandler extends ChannelInboundHandlerAdapter {
String offlinePlayerStr = "OfflinePlayer:";
byte[] uuidHashGenerator = new byte[offlinePlayerStr.length() + clientAuthUsername.length];
System.arraycopy(offlinePlayerStr.getBytes(StandardCharsets.US_ASCII), 0, uuidHashGenerator, 0, offlinePlayerStr.length());
System.arraycopy(clientAuthUsername, 0, uuidHashGenerator, offlinePlayerStr.length(), clientAuthUsername.length);
System.arraycopy(offlinePlayerStr.getBytes(StandardCharsets.US_ASCII), 0, uuidHashGenerator, 0,
offlinePlayerStr.length());
System.arraycopy(clientAuthUsername, 0, uuidHashGenerator, offlinePlayerStr.length(),
clientAuthUsername.length);
clientUUID = UUID.nameUUIDFromBytes(uuidHashGenerator);
strlen = buffer.readUnsignedByte();
@ -605,26 +643,34 @@ public class HttpWebSocketHandler extends ChannelInboundHandlerAdapter {
try {
EaglercraftHandleAuthPasswordEvent handleEvent = new EaglercraftHandleAuthPasswordEvent(
conf, remoteAddress, authRequireEvent.getOriginHeader(), clientAuthUsername,
authRequireEvent.getSaltingData(), clientUsername, clientUUID, clientAuthPassword,
authRequireEvent.getSaltingData(), clientUsername, clientUUID,
clientAuthPassword,
authRequireEvent.getUseAuthType(), authRequireEvent.getAuthMessage(),
(Object) authRequireEvent.getAuthAttachment(), clientRequestedServer.toString(),
(Object) authRequireEvent.getAuthAttachment(),
clientRequestedServer.toString(),
(handleAuthEvent) -> {
if(handleAuthEvent.getLoginAllowed() != EaglercraftHandleAuthPasswordEvent.AuthResponse.ALLOW) {
sendLoginDenied(ctx, handleAuthEvent.getLoginDeniedMessage()).addListener(ChannelFutureListener.CLOSE);
if (handleAuthEvent
.getLoginAllowed() != EaglercraftHandleAuthPasswordEvent.AuthResponse.ALLOW) {
sendLoginDenied(ctx, handleAuthEvent.getLoginDeniedMessage())
.addListener(ChannelFutureListener.CLOSE);
return;
}
clientUsername = handleAuthEvent.getProfileUsername();
clientUUID = handleAuthEvent.getProfileUUID();
String texPropOverrideValue = handleAuthEvent.getApplyTexturesPropertyValue();
String texPropOverrideValue = handleAuthEvent
.getApplyTexturesPropertyValue();
if (texPropOverrideValue != null) {
String texPropOverrideSig = handleAuthEvent.getApplyTexturesPropertySignature();
texturesOverrideProperty = new Property("textures", texPropOverrideValue, texPropOverrideSig);
String texPropOverrideSig = handleAuthEvent
.getApplyTexturesPropertySignature();
texturesOverrideProperty = new Property("textures",
texPropOverrideValue, texPropOverrideSig);
}
overrideEaglerToVanillaSkins = handleAuthEvent.isOverrideEaglerToVanillaSkins();
overrideEaglerToVanillaSkins = handleAuthEvent
.isOverrideEaglerToVanillaSkins();
continueThread.run();
});
@ -660,7 +706,8 @@ public class HttpWebSocketHandler extends ChannelInboundHandlerAdapter {
if (clientLoginState == HandshakePacketTypes.STATE_CLIENT_LOGIN) {
if (profileData.size() > 12) {
sendErrorCode(ctx, HandshakePacketTypes.SERVER_ERROR_EXCESSIVE_PROFILE_DATA, "Too many profile data packets recieved")
sendErrorCode(ctx, HandshakePacketTypes.SERVER_ERROR_EXCESSIVE_PROFILE_DATA,
"Too many profile data packets recieved")
.addListener(ChannelFutureListener.CLOSE);
return;
}
@ -678,7 +725,8 @@ public class HttpWebSocketHandler extends ChannelInboundHandlerAdapter {
if (!profileData.containsKey(dataType)) {
profileData.put(dataType, readData);
} else {
sendErrorCode(ctx, HandshakePacketTypes.SERVER_ERROR_DUPLICATE_PROFILE_DATA, "Multiple profile data packets of the same type recieved")
sendErrorCode(ctx, HandshakePacketTypes.SERVER_ERROR_DUPLICATE_PROFILE_DATA,
"Multiple profile data packets of the same type recieved")
.addListener(ChannelFutureListener.CLOSE);
return;
}
@ -712,11 +760,12 @@ public class HttpWebSocketHandler extends ChannelInboundHandlerAdapter {
}
} catch (Throwable ex) {
if (ex instanceof EventException) {
EaglerXBungee.logger().log(Level.SEVERE, "[" + localAddrString + "]: Hanshake packet " + op + " caught an exception", ex.getCause());
EaglerXBungee.logger().log(Level.SEVERE,
"[" + localAddrString + "]: Hanshake packet " + op + " caught an exception", ex.getCause());
}
clientLoginState = HandshakePacketTypes.STATE_CLIENT_COMPLETE;
sendErrorCode(ctx, HandshakePacketTypes.SERVER_ERROR_INVALID_PACKET, op == -1 ?
"Invalid Packet" : "Invalid Packet #" + op)
sendErrorCode(ctx, HandshakePacketTypes.SERVER_ERROR_INVALID_PACKET,
op == -1 ? "Invalid Packet" : "Invalid Packet #" + op)
.addListener(ChannelFutureListener.CLOSE);
}
}
@ -742,7 +791,8 @@ public class HttpWebSocketHandler extends ChannelInboundHandlerAdapter {
}
if (i >= conf.getMaxPlayer()) {
sendErrorCode(ctx, HandshakePacketTypes.SERVER_ERROR_CUSTOM_MESSAGE, bungee.getTranslation("proxy_full"))
sendErrorCode(ctx, HandshakePacketTypes.SERVER_ERROR_CUSTOM_MESSAGE,
bungee.getTranslation("proxy_full"))
.addListener(ChannelFutureListener.CLOSE);
connectionClosed = true;
return;
@ -796,7 +846,8 @@ public class HttpWebSocketHandler extends ChannelInboundHandlerAdapter {
final BaseComponent[] reason = result.getCancelReasonComponents();
sendErrorCode(ctx, HandshakePacketTypes.SERVER_ERROR_CUSTOM_MESSAGE,
ComponentSerializer.toString(reason != null ? reason
: TextComponent.fromLegacyText(bungee.getTranslation("kick_message", new Object[0]))))
: TextComponent
.fromLegacyText(bungee.getTranslation("kick_message", new Object[0]))))
.addListener(ChannelFutureListener.CLOSE);
return;
}
@ -810,11 +861,14 @@ public class HttpWebSocketHandler extends ChannelInboundHandlerAdapter {
@Override
public void operationComplete(Future<Void> var1) throws Exception {
EaglerConnectionInstance eaglerCon = ctx.channel().attr(EaglerPipeline.CONNECTION_INSTANCE).get();
EaglerConnectionInstance eaglerCon = ctx.channel().attr(EaglerPipeline.CONNECTION_INSTANCE)
.get();
EaglerXBungee.logger().info("[" + ctx.channel().remoteAddress() + "]: Logged in as '" + usernameStr + "'");
EaglerXBungee.logger()
.info("[" + ctx.channel().remoteAddress() + "]: Logged in as '" + usernameStr + "'");
final UserConnection userCon = eaglerCon.userConnection = new UserConnection(bungee, ch, usernameStr, initialHandler);
final UserConnection userCon = eaglerCon.userConnection = new UserConnection(bungee, ch,
usernameStr, initialHandler);
userCon.setCompressionThreshold(-1);
try {
if (!userCon.init()) {
@ -842,21 +896,25 @@ public class HttpWebSocketHandler extends ChannelInboundHandlerAdapter {
pp.replace(HttpWebSocketHandler.this, "HandlerBoss", handler);
pp.addBefore("HandlerBoss", "ReadTimeoutHandler", new ReadTimeoutHandler((BungeeCord.getInstance()).config.getTimeout(), TimeUnit.MILLISECONDS));
pp.addBefore("HandlerBoss", "ReadTimeoutHandler", new ReadTimeoutHandler(
(BungeeCord.getInstance()).config.getTimeout(), TimeUnit.MILLISECONDS));
pp.addBefore("HandlerBoss", "EaglerMinecraftDecoder", new EaglerMinecraftDecoder(
EaglerBungeeProtocol.GAME, false, gameProtocolVersion));
pp.addBefore("HandlerBoss", "EaglerMinecraftByteBufEncoder", new EaglerMinecraftByteBufEncoder());
pp.addBefore("HandlerBoss", "EaglerMinecraftByteBufEncoder",
new EaglerMinecraftByteBufEncoder());
pp.addBefore("HandlerBoss", "EaglerMinecraftWrappedEncoder", new EaglerMinecraftWrappedEncoder());
pp.addBefore("HandlerBoss", "EaglerMinecraftWrappedEncoder",
new EaglerMinecraftWrappedEncoder());
pp.addBefore("HandlerBoss", "EaglerMinecraftEncoder", new EaglerMinecraftEncoder(
EaglerBungeeProtocol.GAME, true, gameProtocolVersion));
boolean doRegisterSkins = true;
EaglercraftRegisterSkinEvent registerSkinEvent = new EaglercraftRegisterSkinEvent(usernameStr, clientUUID);
EaglercraftRegisterSkinEvent registerSkinEvent = new EaglercraftRegisterSkinEvent(usernameStr,
clientUUID);
bungee.getPluginManager().callEvent(registerSkinEvent);
@ -876,7 +934,8 @@ public class HttpWebSocketHandler extends ChannelInboundHandlerAdapter {
} else {
String customUrl = registerSkinEvent.getForceSetUseURL();
if (customUrl != null) {
EaglerXBungee.getEagler().getSkinService().registerTextureToPlayerAssociation(customUrl, initialHandler.getUniqueId());
EaglerXBungee.getEagler().getSkinService().registerTextureToPlayerAssociation(
customUrl, initialHandler.getUniqueId());
doRegisterSkins = false;
overrideEaglerToVanillaSkins = false;
}
@ -886,21 +945,23 @@ public class HttpWebSocketHandler extends ChannelInboundHandlerAdapter {
EaglerBungeeConfig eaglerConf = EaglerXBungee.getEagler().getConfig();
if (texturesOverrideProperty != null) {
LoginResult oldProfile = initialHandler.getLoginProfile();
if (oldProfile == null) {
oldProfile = new LoginResult(initialHandler.getUniqueId().toString(), initialHandler.getName(), null);
oldProfile = new LoginResult(initialHandler.getUniqueId().toString(),
initialHandler.getName(), null);
initialHandler.setLoginProfile(oldProfile);
}
oldProfile.setProperties(new Property[] { texturesOverrideProperty, EaglerBungeeConfig.isEaglerProperty });
oldProfile.setProperties(
new Property[] { texturesOverrideProperty, EaglerBungeeConfig.isEaglerProperty });
} else {
if (!useExistingProp) {
String vanillaSkin = eaglerConf.getEaglerPlayersVanillaSkin();
if (vanillaSkin != null) {
LoginResult oldProfile = initialHandler.getLoginProfile();
if (oldProfile == null) {
oldProfile = new LoginResult(initialHandler.getUniqueId().toString(), initialHandler.getName(), null);
oldProfile = new LoginResult(initialHandler.getUniqueId().toString(),
initialHandler.getName(), null);
initialHandler.setLoginProfile(oldProfile);
}
oldProfile.setProperties(eaglerConf.getEaglerPlayersVanillaSkinProperties());
@ -916,14 +977,18 @@ public class HttpWebSocketHandler extends ChannelInboundHandlerAdapter {
for (int i = 0; i < props.length; ++i) {
if ("textures".equals(props[i].getName())) {
try {
String jsonStr = SkinPackets.bytesToAscii(Base64.decodeBase64(props[i].getValue()));
String jsonStr = SkinPackets
.bytesToAscii(Base64.decodeBase64(props[i].getValue()));
JsonObject json = (new JsonParser()).parse(jsonStr).getAsJsonObject();
JsonObject skinObj = json.getAsJsonObject("SKIN");
if (skinObj != null) {
JsonElement url = json.get("url");
if (url != null) {
String urlStr = SkinService.sanitizeTextureURL(url.getAsString());
EaglerXBungee.getEagler().getSkinService().registerTextureToPlayerAssociation(urlStr, initialHandler.getUniqueId());
String urlStr = SkinService
.sanitizeTextureURL(url.getAsString());
EaglerXBungee.getEagler().getSkinService()
.registerTextureToPlayerAssociation(urlStr,
initialHandler.getUniqueId());
}
}
doRegisterSkins = false;
@ -942,11 +1007,14 @@ public class HttpWebSocketHandler extends ChannelInboundHandlerAdapter {
SkinPackets.registerEaglerPlayer(clientUUID, profileData.get("skin_v1"),
EaglerXBungee.getEagler().getSkinService());
} catch (Throwable ex) {
SkinPackets.registerEaglerPlayerFallback(clientUUID, EaglerXBungee.getEagler().getSkinService());
EaglerXBungee.logger().info("[" + ctx.channel().remoteAddress() + "]: Invalid skin packet: " + ex.toString());
SkinPackets.registerEaglerPlayerFallback(clientUUID,
EaglerXBungee.getEagler().getSkinService());
EaglerXBungee.logger().info("[" + ctx.channel().remoteAddress()
+ "]: Invalid skin packet: " + ex.toString());
}
} else {
SkinPackets.registerEaglerPlayerFallback(clientUUID, EaglerXBungee.getEagler().getSkinService());
SkinPackets.registerEaglerPlayerFallback(clientUUID,
EaglerXBungee.getEagler().getSkinService());
}
}
@ -955,11 +1023,14 @@ public class HttpWebSocketHandler extends ChannelInboundHandlerAdapter {
CapePackets.registerEaglerPlayer(clientUUID, profileData.get("cape_v1"),
EaglerXBungee.getEagler().getCapeService());
} catch (Throwable ex) {
CapePackets.registerEaglerPlayerFallback(clientUUID, EaglerXBungee.getEagler().getCapeService());
EaglerXBungee.logger().info("[" + ctx.channel().remoteAddress() + "]: Invalid cape packet: " + ex.toString());
CapePackets.registerEaglerPlayerFallback(clientUUID,
EaglerXBungee.getEagler().getCapeService());
EaglerXBungee.logger().info("[" + ctx.channel().remoteAddress()
+ "]: Invalid cape packet: " + ex.toString());
}
} else {
CapePackets.registerEaglerPlayerFallback(clientUUID, EaglerXBungee.getEagler().getCapeService());
CapePackets.registerEaglerPlayerFallback(clientUUID,
EaglerXBungee.getEagler().getCapeService());
}
if (conf.getEnableVoiceChat()) {
@ -994,7 +1065,9 @@ public class HttpWebSocketHandler extends ChannelInboundHandlerAdapter {
bungee.getPluginManager().callEvent(login);
complete.done(login, null);
} catch (NoSuchMethodError err) {
bungee.getPluginManager().callEvent(PostLoginEvent.class.getDeclaredConstructor(ProxiedPlayer.class, ServerInfo.class, Callback.class).newInstance(userCon, server, complete));
bungee.getPluginManager().callEvent(PostLoginEvent.class
.getDeclaredConstructor(ProxiedPlayer.class, ServerInfo.class, Callback.class)
.newInstance(userCon, server, complete));
}
}
@ -1007,7 +1080,8 @@ public class HttpWebSocketHandler extends ChannelInboundHandlerAdapter {
final BaseComponent[] reason = var1.getCancelReasonComponents();
sendErrorCode(ctx, HandshakePacketTypes.SERVER_ERROR_CUSTOM_MESSAGE,
ComponentSerializer.toString(reason != null ? reason
: TextComponent.fromLegacyText(bungee.getTranslation("kick_message", new Object[0]))))
: TextComponent
.fromLegacyText(bungee.getTranslation("kick_message", new Object[0]))))
.addListener(ChannelFutureListener.CLOSE);
} else {
bungee.getPluginManager().callEvent(new LoginEvent(initialHandler, complete));
@ -1027,7 +1101,8 @@ public class HttpWebSocketHandler extends ChannelInboundHandlerAdapter {
if (connectionClosed) {
return;
}
if(!hasFirstPacket && (conf.isAllowMOTD() || conf.isAllowQuery()) && (str = str.toLowerCase()).startsWith("accept:")) {
if (!hasFirstPacket && (conf.isAllowMOTD() || conf.isAllowQuery())
&& (str = str.toLowerCase()).startsWith("accept:")) {
str = str.substring(7).trim();
hasFirstPacket = true;
hasBinaryConnection = false;
@ -1068,7 +1143,8 @@ public class HttpWebSocketHandler extends ChannelInboundHandlerAdapter {
if (queryRateLimit != RateLimitStatus.OK) {
final RateLimitStatus rateLimitTypeFinal = queryRateLimit;
ctx.writeAndFlush(new TextWebSocketFrame(
rateLimitTypeFinal == RateLimitStatus.LIMITED_NOW_LOCKED_OUT ? "{\"type\":\"locked\"}" : "{\"type\":\"blocked\"}"))
rateLimitTypeFinal == RateLimitStatus.LIMITED_NOW_LOCKED_OUT ? "{\"type\":\"locked\"}"
: "{\"type\":\"blocked\"}"))
.addListener(ChannelFutureListener.CLOSE);
connectionClosed = true;
return;
@ -1084,7 +1160,8 @@ public class HttpWebSocketHandler extends ChannelInboundHandlerAdapter {
}
if (handler != null) {
ctx.pipeline().replace(HttpWebSocketHandler.this, "HttpServerQueryHandler", handler);
ctx.pipeline().addBefore("HttpServerQueryHandler", "WriteTimeoutHandler", new WriteTimeoutHandler(5l, TimeUnit.SECONDS));
ctx.pipeline().addBefore("HttpServerQueryHandler", "WriteTimeoutHandler",
new WriteTimeoutHandler(5l, TimeUnit.SECONDS));
handler.beginHandleQuery(conf, ctx, str);
if (handler instanceof MOTDQueryHandler) {
EaglercraftMOTDEvent evt = new EaglercraftMOTDEvent((MOTDQueryHandler) handler);
@ -1142,7 +1219,8 @@ public class HttpWebSocketHandler extends ChannelInboundHandlerAdapter {
}
private ChannelFuture sendErrorWrong(ChannelHandlerContext ctx, int op, String state) {
return sendErrorCode(ctx, HandshakePacketTypes.SERVER_ERROR_WRONG_PACKET, "Wrong Packet #" + op + " in state '" + state + "'");
return sendErrorCode(ctx, HandshakePacketTypes.SERVER_ERROR_WRONG_PACKET,
"Wrong Packet #" + op + " in state '" + state + "'");
}
private ChannelFuture sendErrorCode(ChannelHandlerContext ctx, int code, String str) {

View File

@ -24,44 +24,45 @@ public enum EaglerBungeeProtocol {
HANDSHAKE {
{
TO_SERVER.registerPacket(Handshake.class, Handshake::new, map(ProtocolConstants.MINECRAFT_1_8, 0x00));
TO_SERVER.registerPacket(Handshake.class, Handshake::new, map(ProtocolConstants.MINECRAFT_1_9_4, 0x00));
}
},
// 0
GAME {
{
TO_CLIENT.registerPacket(KeepAlive.class, KeepAlive::new, map(ProtocolConstants.MINECRAFT_1_8, 0x00));
TO_CLIENT.registerPacket(Login.class, Login::new, map(ProtocolConstants.MINECRAFT_1_8, 0x01));
TO_CLIENT.registerPacket(Chat.class, Chat::new, map(ProtocolConstants.MINECRAFT_1_8, 0x02));
TO_CLIENT.registerPacket(Respawn.class, Respawn::new, map(ProtocolConstants.MINECRAFT_1_8, 0x07));
TO_CLIENT.registerPacket(KeepAlive.class, KeepAlive::new, map(ProtocolConstants.MINECRAFT_1_9_4, 0x1F));
TO_CLIENT.registerPacket(Login.class, Login::new, map(ProtocolConstants.MINECRAFT_1_9_4, 0x23));
TO_CLIENT.registerPacket(Chat.class, Chat::new, map(ProtocolConstants.MINECRAFT_1_9_4, 0x0F));
TO_CLIENT.registerPacket(Respawn.class, Respawn::new, map(ProtocolConstants.MINECRAFT_1_9_4, 0x33));
TO_CLIENT.registerPacket(PlayerListItem.class, // PlayerInfo
PlayerListItem::new, map(ProtocolConstants.MINECRAFT_1_8, 0x38));
PlayerListItem::new, map(ProtocolConstants.MINECRAFT_1_9_4, 0x2D));
TO_CLIENT.registerPacket(TabCompleteResponse.class, TabCompleteResponse::new,
map(ProtocolConstants.MINECRAFT_1_8, 0x3A));
map(ProtocolConstants.MINECRAFT_1_9_4, 0x0E));
TO_CLIENT.registerPacket(ScoreboardObjective.class, ScoreboardObjective::new,
map(ProtocolConstants.MINECRAFT_1_8, 0x3B));
map(ProtocolConstants.MINECRAFT_1_9_4, 0x3F));
TO_CLIENT.registerPacket(ScoreboardScore.class, ScoreboardScore::new,
map(ProtocolConstants.MINECRAFT_1_8, 0x3C));
map(ProtocolConstants.MINECRAFT_1_9_4, 0x42));
TO_CLIENT.registerPacket(ScoreboardDisplay.class, ScoreboardDisplay::new,
map(ProtocolConstants.MINECRAFT_1_8, 0x3D));
TO_CLIENT.registerPacket(Team.class, Team::new, map(ProtocolConstants.MINECRAFT_1_8, 0x3E));
map(ProtocolConstants.MINECRAFT_1_9_4, 0x38));
TO_CLIENT.registerPacket(Team.class, Team::new, map(ProtocolConstants.MINECRAFT_1_9_4, 0x41));
TO_CLIENT.registerPacket(PluginMessage.class, PluginMessage::new,
map(ProtocolConstants.MINECRAFT_1_8, 0x3F));
TO_CLIENT.registerPacket(Kick.class, Kick::new, map(ProtocolConstants.MINECRAFT_1_8, 0x40));
TO_CLIENT.registerPacket(Title.class, Title::new, map(ProtocolConstants.MINECRAFT_1_8, 0x45));
map(ProtocolConstants.MINECRAFT_1_9_4, 0x18));
TO_CLIENT.registerPacket(Kick.class, Kick::new, map(ProtocolConstants.MINECRAFT_1_9_4, 0x1A));
TO_CLIENT.registerPacket(Title.class, Title::new, map(ProtocolConstants.MINECRAFT_1_9_4, 0x45));
TO_CLIENT.registerPacket(PlayerListHeaderFooter.class, PlayerListHeaderFooter::new,
map(ProtocolConstants.MINECRAFT_1_8, 0x47));
TO_CLIENT.registerPacket(EntityStatus.class, EntityStatus::new, map(ProtocolConstants.MINECRAFT_1_8, 0x1A));
map(ProtocolConstants.MINECRAFT_1_9_4, 0x47));
TO_CLIENT.registerPacket(EntityStatus.class, EntityStatus::new,
map(ProtocolConstants.MINECRAFT_1_9_4, 0x1B));
TO_SERVER.registerPacket(KeepAlive.class, KeepAlive::new, map(ProtocolConstants.MINECRAFT_1_8, 0x00));
TO_SERVER.registerPacket(Chat.class, Chat::new, map(ProtocolConstants.MINECRAFT_1_8, 0x01));
TO_SERVER.registerPacket(KeepAlive.class, KeepAlive::new, map(ProtocolConstants.MINECRAFT_1_9_4, 0x0B));
TO_SERVER.registerPacket(Chat.class, Chat::new, map(ProtocolConstants.MINECRAFT_1_9_4, 0x02));
TO_SERVER.registerPacket(TabCompleteRequest.class, TabCompleteRequest::new,
map(ProtocolConstants.MINECRAFT_1_8, 0x14));
map(ProtocolConstants.MINECRAFT_1_9_4, 0x01));
TO_SERVER.registerPacket(ClientSettings.class, ClientSettings::new,
map(ProtocolConstants.MINECRAFT_1_8, 0x15));
map(ProtocolConstants.MINECRAFT_1_9_4, 0x04));
TO_SERVER.registerPacket(PluginMessage.class, PluginMessage::new,
map(ProtocolConstants.MINECRAFT_1_8, 0x17));
map(ProtocolConstants.MINECRAFT_1_9_4, 0x09));
}
},
// 1
@ -69,28 +70,30 @@ public enum EaglerBungeeProtocol {
{
TO_CLIENT.registerPacket(StatusResponse.class, StatusResponse::new,
map(ProtocolConstants.MINECRAFT_1_8, 0x00));
TO_CLIENT.registerPacket(PingPacket.class, PingPacket::new, map(ProtocolConstants.MINECRAFT_1_8, 0x01));
map(ProtocolConstants.MINECRAFT_1_9_4, 0x00));
TO_CLIENT.registerPacket(PingPacket.class, PingPacket::new, map(ProtocolConstants.MINECRAFT_1_9_4, 0x01));
TO_SERVER.registerPacket(StatusRequest.class, StatusRequest::new,
map(ProtocolConstants.MINECRAFT_1_8, 0x00));
TO_SERVER.registerPacket(PingPacket.class, PingPacket::new, map(ProtocolConstants.MINECRAFT_1_8, 0x01));
map(ProtocolConstants.MINECRAFT_1_9_4, 0x00));
TO_SERVER.registerPacket(PingPacket.class, PingPacket::new, map(ProtocolConstants.MINECRAFT_1_9_4, 0x01));
}
},
// 2
LOGIN {
{
TO_CLIENT.registerPacket(Kick.class, Kick::new, map(ProtocolConstants.MINECRAFT_1_8, 0x00));
TO_CLIENT.registerPacket(Kick.class, Kick::new, map(ProtocolConstants.MINECRAFT_1_9_4, 0x00));
TO_CLIENT.registerPacket(EncryptionRequest.class, EncryptionRequest::new,
map(ProtocolConstants.MINECRAFT_1_8, 0x01));
TO_CLIENT.registerPacket(LoginSuccess.class, LoginSuccess::new, map(ProtocolConstants.MINECRAFT_1_8, 0x02));
map(ProtocolConstants.MINECRAFT_1_9_4, 0x01));
TO_CLIENT.registerPacket(LoginSuccess.class, LoginSuccess::new,
map(ProtocolConstants.MINECRAFT_1_9_4, 0x02));
TO_CLIENT.registerPacket(SetCompression.class, SetCompression::new,
map(ProtocolConstants.MINECRAFT_1_8, 0x03));
map(ProtocolConstants.MINECRAFT_1_9_4, 0x03));
TO_SERVER.registerPacket(LoginRequest.class, LoginRequest::new, map(ProtocolConstants.MINECRAFT_1_8, 0x00));
TO_SERVER.registerPacket(LoginRequest.class, LoginRequest::new,
map(ProtocolConstants.MINECRAFT_1_9_4, 0x00));
TO_SERVER.registerPacket(EncryptionResponse.class, EncryptionResponse::new,
map(ProtocolConstants.MINECRAFT_1_8, 0x01));
map(ProtocolConstants.MINECRAFT_1_9_4, 0x01));
}
},
// 3

View File

@ -38,10 +38,10 @@ public class VersionQueryHandler extends EaglerQuerySimpleHandler {
handshakeVersions.add(3);
responseObj.add("handshakeVersions", handshakeVersions);
JsonArray protocolVersions = new JsonArray();
protocolVersions.add(47);
protocolVersions.add(110);
responseObj.add("protocolVersions", protocolVersions);
JsonArray gameVersions = new JsonArray();
gameVersions.add("1.8");
gameVersions.add("1.9.4");
responseObj.add("gameVersions", gameVersions);
JsonObject proxyInfo = new JsonObject();
proxyInfo.addProperty("brand", ProxyServer.getInstance().getName());