WIP: New Phase
This commit is contained in:
parent
26e320f034
commit
55bb6df100
|
|
@ -1,4 +1,4 @@
|
|||
package org.adde0109.ambassador.velocity;
|
||||
package org.adde0109.ambassador.forge;
|
||||
|
||||
import com.velocitypowered.api.util.GameProfile;
|
||||
import com.velocitypowered.proxy.config.PlayerInfoForwarding;
|
||||
|
|
@ -6,7 +6,7 @@ import com.velocitypowered.proxy.connection.ConnectionType;
|
|||
import com.velocitypowered.proxy.connection.MinecraftConnection;
|
||||
import com.velocitypowered.proxy.connection.backend.BackendConnectionPhase;
|
||||
import com.velocitypowered.proxy.connection.client.ClientConnectionPhase;
|
||||
import org.adde0109.ambassador.velocity.ForgeClientConnectionPhase;
|
||||
import org.adde0109.ambassador.forge.ForgeFML2ClientConnectionPhase;
|
||||
|
||||
public class ForgeConnectionType implements ConnectionType {
|
||||
|
||||
|
|
@ -17,7 +17,7 @@ public class ForgeConnectionType implements ConnectionType {
|
|||
|
||||
@Override
|
||||
public ClientConnectionPhase getInitialClientPhase() {
|
||||
return new ForgeClientConnectionPhase(connection);
|
||||
return new ForgeFML2ClientConnectionPhase(connection);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
package org.adde0109.ambassador.forge;
|
||||
|
||||
import com.velocitypowered.proxy.connection.MinecraftConnection;
|
||||
import com.velocitypowered.proxy.connection.client.ClientConnectionPhase;
|
||||
import com.velocitypowered.proxy.connection.client.ConnectedPlayer;
|
||||
import com.velocitypowered.proxy.protocol.packet.LoginPluginMessage;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import org.adde0109.ambassador.velocity.VelocityForgeClientConnectionPhase;
|
||||
import org.adde0109.ambassador.velocity.VelocityForgeHandshakeSessionHandler;
|
||||
|
||||
public class ForgeFML2ClientConnectionPhase implements VelocityForgeClientConnectionPhase {
|
||||
|
||||
private final MinecraftConnection connection;
|
||||
ForgeFML2ClientConnectionPhase(MinecraftConnection connection) {
|
||||
this.connection = connection;
|
||||
}
|
||||
@Override
|
||||
public void handleLogin(ForgeHandshakeUtils.CachedServerHandshake handshake) {
|
||||
this.connection.setSessionHandler(new VelocityForgeHandshakeSessionHandler());
|
||||
if(handshake == null) {
|
||||
this.connection.write(new LoginPluginMessage(98,"fml:loginwrapper", Unpooled.wrappedBuffer(ForgeHandshakeUtils.generateResetPacket())));
|
||||
} else {
|
||||
this.connection.delayedWrite(new LoginPluginMessage(1,"fml:loginwrapper", Unpooled.wrappedBuffer(handshake.modListPacket)));
|
||||
for (int i = 0;i<handshake.otherPackets.size();i++) {
|
||||
this.connection.delayedWrite(new LoginPluginMessage(i+2,"fml:loginwrapper", Unpooled.wrappedBuffer(handshake.otherPackets.get(i))));
|
||||
}
|
||||
this.connection.flush();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2,7 +2,6 @@ package org.adde0109.ambassador.forge;
|
|||
|
||||
import com.velocitypowered.api.event.Continuation;
|
||||
import com.velocitypowered.api.event.Subscribe;
|
||||
import com.velocitypowered.api.event.permission.PermissionsSetupEvent;
|
||||
import com.velocitypowered.api.event.player.KickedFromServerEvent;
|
||||
import com.velocitypowered.api.event.player.ServerLoginPluginMessageEvent;
|
||||
import com.velocitypowered.api.proxy.Player;
|
||||
|
|
@ -14,14 +13,12 @@ import java.util.HashMap;
|
|||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
import com.velocitypowered.proxy.connection.client.ConnectedPlayer;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.TranslatableComponent;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import org.adde0109.ambassador.Ambassador;
|
||||
import org.adde0109.ambassador.velocity.ForgeClientConnectionPhase;
|
||||
|
||||
public class ForgeHandshakeHandler {
|
||||
|
||||
|
|
@ -40,14 +37,8 @@ public class ForgeHandshakeHandler {
|
|||
|
||||
|
||||
|
||||
public void handleLogin(ConnectedPlayer player, ForgeClientConnectionPhase phase, Continuation continuation) {
|
||||
getInitialHandshake(player).whenComplete((msg,ex) -> {
|
||||
if (ex != null) {
|
||||
//SEND RESET PACKET
|
||||
} else {
|
||||
//SEND MODLIST
|
||||
}
|
||||
});
|
||||
public void handleLogin(ConnectedPlayer player, ForgeFML2ClientConnectionPhase phase, Continuation continuation) {
|
||||
getInitialHandshake(player).whenComplete((msg,ex) -> phase.handleLogin(msg));
|
||||
}
|
||||
|
||||
private CompletableFuture<ForgeHandshakeUtils.CachedServerHandshake> getInitialHandshake(ConnectedPlayer player) {
|
||||
|
|
|
|||
|
|
@ -1,15 +0,0 @@
|
|||
package org.adde0109.ambassador.velocity;
|
||||
|
||||
import com.velocitypowered.api.event.Continuation;
|
||||
import com.velocitypowered.proxy.connection.MinecraftConnection;
|
||||
import com.velocitypowered.proxy.connection.client.ClientConnectionPhase;
|
||||
import com.velocitypowered.proxy.connection.client.ConnectedPlayer;
|
||||
|
||||
public class ForgeClientConnectionPhase implements ClientConnectionPhase {
|
||||
|
||||
ForgeClientConnectionPhase(MinecraftConnection connection) {
|
||||
}
|
||||
public void handleLogin() {
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -5,6 +5,7 @@ import com.velocitypowered.api.event.Subscribe;
|
|||
import com.velocitypowered.api.event.permission.PermissionsSetupEvent;
|
||||
import com.velocitypowered.proxy.connection.client.ConnectedPlayer;
|
||||
import org.adde0109.ambassador.Ambassador;
|
||||
import org.adde0109.ambassador.forge.ForgeFML2ClientConnectionPhase;
|
||||
|
||||
public class VelocityEventHandler {
|
||||
|
||||
|
|
@ -20,7 +21,7 @@ public class VelocityEventHandler {
|
|||
continuation.resume();
|
||||
return;
|
||||
}
|
||||
if (!(player.getPhase() instanceof ForgeClientConnectionPhase phase)) {
|
||||
if (!(player.getPhase() instanceof ForgeFML2ClientConnectionPhase phase)) {
|
||||
continuation.resume();
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,10 @@
|
|||
package org.adde0109.ambassador.velocity;
|
||||
|
||||
import com.velocitypowered.proxy.connection.client.ClientConnectionPhase;
|
||||
import org.adde0109.ambassador.forge.ForgeHandshakeUtils;
|
||||
|
||||
public interface VelocityForgeClientConnectionPhase extends ClientConnectionPhase {
|
||||
default void handleLogin(ForgeHandshakeUtils.CachedServerHandshake handshake) {
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -1,6 +1,11 @@
|
|||
package org.adde0109.ambassador.velocity;
|
||||
|
||||
import com.velocitypowered.proxy.connection.MinecraftSessionHandler;
|
||||
import com.velocitypowered.proxy.protocol.packet.LoginPluginResponse;
|
||||
|
||||
public class VelocityForgeHandshakeSessionHandler implements MinecraftSessionHandler {
|
||||
@Override
|
||||
public boolean handle(LoginPluginResponse packet) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import com.velocitypowered.proxy.protocol.MinecraftPacket;
|
|||
import com.velocitypowered.proxy.protocol.StateRegistry;
|
||||
import com.velocitypowered.proxy.protocol.packet.Handshake;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import org.adde0109.ambassador.forge.ForgeConnectionType;
|
||||
|
||||
public class VelocityHandshakeSessionHandler implements MinecraftSessionHandler {
|
||||
private final HandshakeSessionHandler original;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user