(1.2.0) Fixed various issues with the plugin

This commit is contained in:
lax1dude 2024-05-18 17:01:53 -07:00
parent 4bd1aebd04
commit 32fda35ace
11 changed files with 88 additions and 14 deletions

View File

@ -67,6 +67,7 @@ public class EaglerXBungee extends Plugin {
private static EaglerXBungee instance = null; private static EaglerXBungee instance = null;
private EaglerBungeeConfig conf = null; private EaglerBungeeConfig conf = null;
private EventLoopGroup eventLoopGroup; private EventLoopGroup eventLoopGroup;
private EventLoopGroup eventLoopGroupBoss;
private Collection<Channel> openChannels; private Collection<Channel> openChannels;
private Timer closeInactiveConnections = null; private Timer closeInactiveConnections = null;
private Timer skinServiceTasks = null; private Timer skinServiceTasks = null;
@ -103,6 +104,7 @@ public class EaglerXBungee extends Plugin {
} catch (NoSuchFieldError e) { } catch (NoSuchFieldError e) {
try { try {
eventLoopGroup = (EventLoopGroup) BungeeCord.class.getField("workerEventLoopGroup").get(getProxy()); eventLoopGroup = (EventLoopGroup) BungeeCord.class.getField("workerEventLoopGroup").get(getProxy());
eventLoopGroupBoss = (EventLoopGroup) BungeeCord.class.getField("bossEventLoopGroup").get(getProxy());
} catch (IllegalAccessException | NoSuchFieldException ex) { } catch (IllegalAccessException | NoSuchFieldException ex) {
throw new RuntimeException(ex); throw new RuntimeException(ex);
} }
@ -273,9 +275,13 @@ public class EaglerXBungee extends Plugin {
ServerBootstrap bootstrap = new ServerBootstrap(); ServerBootstrap bootstrap = new ServerBootstrap();
bootstrap.option(ChannelOption.SO_REUSEADDR, true) bootstrap.option(ChannelOption.SO_REUSEADDR, true)
.childOption(ChannelOption.TCP_NODELAY, true) .childOption(ChannelOption.TCP_NODELAY, true)
.channel(PipelineUtils.getServerChannel(addr)) .channel(PipelineUtils.getServerChannel(addr));
.group(eventLoopGroup) if(eventLoopGroupBoss != null) {
.childAttr(EaglerPipeline.LISTENER, confData) bootstrap.group(eventLoopGroupBoss, eventLoopGroup);
}else {
bootstrap.group(eventLoopGroup);
}
bootstrap.childAttr(EaglerPipeline.LISTENER, confData)
.attr(EaglerPipeline.LOCAL_ADDRESS, addr) .attr(EaglerPipeline.LOCAL_ADDRESS, addr)
.localAddress(addr) .localAddress(addr)
.childHandler(EaglerPipeline.SERVER_CHILD) .childHandler(EaglerPipeline.SERVER_CHILD)

View File

@ -0,0 +1,63 @@
package net.lax1dude.eaglercraft.v1_8.plugin.gateway_bungeecord.api.event;
import java.util.UUID;
import net.md_5.bungee.api.plugin.Event;
/**
* Copyright (c) 2024 lax1dude. All Rights Reserved.
*
* 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)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*/
public class EaglercraftRegisterCapeEvent extends Event {
private final String username;
private final UUID uuid;
private byte[] customTex = null;
public EaglercraftRegisterCapeEvent(String username, UUID uuid) {
this.username = username;
this.uuid = uuid;
}
public String getUsername() {
return username;
}
public UUID getUuid() {
return uuid;
}
public void setForceUsePreset(int p) {
customTex = new byte[5];
customTex[0] = (byte)1;
customTex[1] = (byte)(p >> 24);
customTex[2] = (byte)(p >> 16);
customTex[3] = (byte)(p >> 8);
customTex[4] = (byte)(p & 0xFF);
}
public void setForceUseCustom(byte[] tex) {
customTex = new byte[1 + tex.length];
customTex[0] = (byte)2;
System.arraycopy(tex, 0, customTex, 1, tex.length);
}
public void setForceUseCustomByPacket(byte[] packet) {
customTex = packet;
}
public byte[] getForceSetUseCustomPacket() {
return customTex;
}
}

View File

@ -26,7 +26,6 @@ public class EaglercraftRegisterSkinEvent extends Event {
private final UUID uuid; private final UUID uuid;
private Property useMojangProfileProperty = null; private Property useMojangProfileProperty = null;
private boolean useLoginResultTextures = false; private boolean useLoginResultTextures = false;
private int presetId = -1;
private byte[] customTex = null; private byte[] customTex = null;
private String customURL = null; private String customURL = null;
@ -38,7 +37,6 @@ public class EaglercraftRegisterSkinEvent extends Event {
public void setForceUseMojangProfileProperty(Property prop) { public void setForceUseMojangProfileProperty(Property prop) {
useMojangProfileProperty = prop; useMojangProfileProperty = prop;
useLoginResultTextures = false; useLoginResultTextures = false;
presetId = -1;
customTex = null; customTex = null;
customURL = null; customURL = null;
} }
@ -46,7 +44,6 @@ public class EaglercraftRegisterSkinEvent extends Event {
public void setForceUseLoginResultObjectTextures(boolean b) { public void setForceUseLoginResultObjectTextures(boolean b) {
useMojangProfileProperty = null; useMojangProfileProperty = null;
useLoginResultTextures = b; useLoginResultTextures = b;
presetId = -1;
customTex = null; customTex = null;
customURL = null; customURL = null;
} }
@ -54,7 +51,6 @@ public class EaglercraftRegisterSkinEvent extends Event {
public void setForceUsePreset(int p) { public void setForceUsePreset(int p) {
useMojangProfileProperty = null; useMojangProfileProperty = null;
useLoginResultTextures = false; useLoginResultTextures = false;
presetId = p;
customTex = new byte[5]; customTex = new byte[5];
customTex[0] = (byte)1; customTex[0] = (byte)1;
customTex[1] = (byte)(p >> 24); customTex[1] = (byte)(p >> 24);
@ -67,7 +63,6 @@ public class EaglercraftRegisterSkinEvent extends Event {
public void setForceUseCustom(int model, byte[] tex) { public void setForceUseCustom(int model, byte[] tex) {
useMojangProfileProperty = null; useMojangProfileProperty = null;
useLoginResultTextures = false; useLoginResultTextures = false;
presetId = -1;
customTex = new byte[2 + tex.length]; customTex = new byte[2 + tex.length];
customTex[0] = (byte)2; customTex[0] = (byte)2;
customTex[1] = (byte)model; customTex[1] = (byte)model;
@ -78,7 +73,6 @@ public class EaglercraftRegisterSkinEvent extends Event {
public void setForceUseCustomByPacket(byte[] packet) { public void setForceUseCustomByPacket(byte[] packet) {
useMojangProfileProperty = null; useMojangProfileProperty = null;
useLoginResultTextures = false; useLoginResultTextures = false;
presetId = -1;
customTex = packet; customTex = packet;
customURL = null; customURL = null;
} }
@ -86,7 +80,6 @@ public class EaglercraftRegisterSkinEvent extends Event {
public void setForceUseURL(String url) { public void setForceUseURL(String url) {
useMojangProfileProperty = null; useMojangProfileProperty = null;
useLoginResultTextures = false; useLoginResultTextures = false;
presetId = -1;
customTex = null; customTex = null;
customURL = url; customURL = url;
} }

View File

@ -35,6 +35,7 @@ public interface MOTDConnection {
} }
void sendToUser(); void sendToUser();
void setKeepAlive(boolean enable);
String getLine1(); String getLine1();
String getLine2(); String getLine2();

View File

@ -43,6 +43,7 @@ import net.lax1dude.eaglercraft.v1_8.plugin.gateway_bungeecord.api.event.Eaglerc
import net.lax1dude.eaglercraft.v1_8.plugin.gateway_bungeecord.api.event.EaglercraftIsAuthRequiredEvent.AuthMethod; import net.lax1dude.eaglercraft.v1_8.plugin.gateway_bungeecord.api.event.EaglercraftIsAuthRequiredEvent.AuthMethod;
import net.lax1dude.eaglercraft.v1_8.plugin.gateway_bungeecord.api.event.EaglercraftIsAuthRequiredEvent.AuthResponse; import net.lax1dude.eaglercraft.v1_8.plugin.gateway_bungeecord.api.event.EaglercraftIsAuthRequiredEvent.AuthResponse;
import net.lax1dude.eaglercraft.v1_8.plugin.gateway_bungeecord.api.event.EaglercraftMOTDEvent; import net.lax1dude.eaglercraft.v1_8.plugin.gateway_bungeecord.api.event.EaglercraftMOTDEvent;
import net.lax1dude.eaglercraft.v1_8.plugin.gateway_bungeecord.api.event.EaglercraftRegisterCapeEvent;
import net.lax1dude.eaglercraft.v1_8.plugin.gateway_bungeecord.api.event.EaglercraftRegisterSkinEvent; import net.lax1dude.eaglercraft.v1_8.plugin.gateway_bungeecord.api.event.EaglercraftRegisterSkinEvent;
import net.lax1dude.eaglercraft.v1_8.plugin.gateway_bungeecord.auth.DefaultAuthSystem; import net.lax1dude.eaglercraft.v1_8.plugin.gateway_bungeecord.auth.DefaultAuthSystem;
import net.lax1dude.eaglercraft.v1_8.plugin.gateway_bungeecord.command.CommandConfirmCode; import net.lax1dude.eaglercraft.v1_8.plugin.gateway_bungeecord.command.CommandConfirmCode;
@ -950,6 +951,15 @@ public class HttpWebSocketHandler extends ChannelInboundHandlerAdapter {
} }
} }
EaglercraftRegisterCapeEvent registerCapeEvent = new EaglercraftRegisterCapeEvent(usernameStr, clientUUID);
bungee.getPluginManager().callEvent(registerCapeEvent);
byte[] forceCape = registerCapeEvent.getForceSetUseCustomPacket();
if(forceCape != null) {
profileData.put("cape_v1", forceCape);
}
if(profileData.containsKey("cape_v1")) { if(profileData.containsKey("cape_v1")) {
try { try {
CapePackets.registerEaglerPlayer(clientUUID, profileData.get("cape_v1"), CapePackets.registerEaglerPlayer(clientUUID, profileData.get("cape_v1"),
@ -1085,6 +1095,7 @@ public class HttpWebSocketHandler extends ChannelInboundHandlerAdapter {
if(handler != null) { if(handler != null) {
ctx.pipeline().replace(HttpWebSocketHandler.this, "HttpServerQueryHandler", handler); 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));
ctx.channel().attr(EaglerPipeline.CONNECTION_INSTANCE).get().hasBeenForwarded = true;
handler.beginHandleQuery(conf, ctx, str); handler.beginHandleQuery(conf, ctx, str);
if(handler instanceof MOTDQueryHandler) { if(handler instanceof MOTDQueryHandler) {
EaglercraftMOTDEvent evt = new EaglercraftMOTDEvent((MOTDQueryHandler)handler); EaglercraftMOTDEvent evt = new EaglercraftMOTDEvent((MOTDQueryHandler)handler);

View File

@ -62,7 +62,7 @@ public class EaglerDrivers {
EaglerXBungee.logger().severe("Invalid JDBC driver path: " + address); EaglerXBungee.logger().severe("Invalid JDBC driver path: " + address);
throw new ExceptionInInitializerError(ex); throw new ExceptionInInitializerError(ex);
} }
classLoader = new URLClassLoader(new URL[] { driverURL }, ClassLoader.getSystemClassLoader()); classLoader = URLClassLoader.newInstance(new URL[] { driverURL }, ClassLoader.getSystemClassLoader());
driversJARs.put(address, classLoader); driversJARs.put(address, classLoader);
} }

View File

@ -1,5 +1,5 @@
name: EaglercraftXBungee name: EaglercraftXBungee
main: net.lax1dude.eaglercraft.v1_8.plugin.gateway_bungeecord.EaglerXBungee main: net.lax1dude.eaglercraft.v1_8.plugin.gateway_bungeecord.EaglerXBungee
version: 1.1.1 version: 1.2.0
description: Plugin to allow EaglercraftX 1.8 players to join your network, or allow EaglercraftX 1.8 players to use your network as a proxy to join other networks description: Plugin to allow EaglercraftX 1.8 players to join your network, or allow EaglercraftX 1.8 players to use your network as a proxy to join other networks
author: lax1dude author: lax1dude

View File

@ -1 +1 @@
1.1.1 1.2.0

View File

@ -1 +1 @@
{"pluginName":"EaglercraftXBungee","pluginVersion":"1.1.1","pluginButton":"Download \"EaglerXBungee-1.1.1.jar\"","pluginFilename":"EaglerXBungee.zip"} {"pluginName":"EaglercraftXBungee","pluginVersion":"1.2.0","pluginButton":"Download \"EaglerXBungee-1.2.0.jar\"","pluginFilename":"EaglerXBungee.zip"}