WIP: Store modlist
This commit is contained in:
parent
fe69711818
commit
8455e5b0e0
|
|
@ -12,18 +12,20 @@ import org.adde0109.ambassador.velocity.VelocityForgeClientConnectionPhase;
|
||||||
import org.adde0109.ambassador.velocity.VelocityForgeHandshakeSessionHandler;
|
import org.adde0109.ambassador.velocity.VelocityForgeHandshakeSessionHandler;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
public class ForgeFML2ClientConnectionPhase implements VelocityForgeClientConnectionPhase {
|
public class ForgeFML2ClientConnectionPhase implements VelocityForgeClientConnectionPhase {
|
||||||
|
|
||||||
private final MinecraftConnection connection;
|
private final MinecraftConnection connection;
|
||||||
private boolean isResettable;
|
private boolean isResettable;
|
||||||
private ByteBuf modListData;
|
private Optional<ByteBuf> modListData = Optional.empty();
|
||||||
private Continuation whenComplete;
|
private Continuation whenComplete;
|
||||||
ForgeFML2ClientConnectionPhase(MinecraftConnection connection) {
|
ForgeFML2ClientConnectionPhase(MinecraftConnection connection) {
|
||||||
this.connection = connection;
|
this.connection = connection;
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public void handleLogin(ForgeHandshakeUtils.CachedServerHandshake handshake, Continuation continuation) {
|
public void handleLogin(ForgeHandshakeUtils.CachedServerHandshake handshake, Continuation continuation) {
|
||||||
|
this.whenComplete = continuation;
|
||||||
VelocityForgeHandshakeSessionHandler sessionHandler = new VelocityForgeHandshakeSessionHandler(this);
|
VelocityForgeHandshakeSessionHandler sessionHandler = new VelocityForgeHandshakeSessionHandler(this);
|
||||||
if(handshake == null) {
|
if(handshake == null) {
|
||||||
this.connection.write(new LoginPluginMessage(98,"fml:loginwrapper", Unpooled.wrappedBuffer(ForgeHandshakeUtils.generateResetPacket())));
|
this.connection.write(new LoginPluginMessage(98,"fml:loginwrapper", Unpooled.wrappedBuffer(ForgeHandshakeUtils.generateResetPacket())));
|
||||||
|
|
@ -44,8 +46,13 @@ public class ForgeFML2ClientConnectionPhase implements VelocityForgeClientConnec
|
||||||
public void handle(LoginPluginResponse packet, boolean lastMessage) {
|
public void handle(LoginPluginResponse packet, boolean lastMessage) {
|
||||||
if (packet.getId() == 98) {
|
if (packet.getId() == 98) {
|
||||||
isResettable = packet.isSuccess();
|
isResettable = packet.isSuccess();
|
||||||
} else {
|
} else if (packet.getId() == 1) {
|
||||||
modListData = packet.content().retain();
|
if (!packet.isSuccess()) {
|
||||||
|
//TODO: Write disconnect message to end user
|
||||||
|
connection.close();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
modListData = Optional.of(packet.content().retain());
|
||||||
}
|
}
|
||||||
if (lastMessage) {
|
if (lastMessage) {
|
||||||
whenComplete.resume();
|
whenComplete.resume();
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ import org.adde0109.ambassador.forge.ForgeHandshakeUtils;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
public interface VelocityForgeClientConnectionPhase extends ClientConnectionPhase {
|
public interface VelocityForgeClientConnectionPhase extends ClientConnectionPhase {
|
||||||
|
//TODO:Make class when PCF is done
|
||||||
|
|
||||||
default void handleLogin(@Nullable ForgeHandshakeUtils.CachedServerHandshake initialHandshake, Continuation continuation) {
|
default void handleLogin(@Nullable ForgeHandshakeUtils.CachedServerHandshake initialHandshake, Continuation continuation) {
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,8 +18,9 @@ public class VelocityForgeHandshakeSessionHandler implements MinecraftSessionHan
|
||||||
public boolean handle(LoginPluginResponse packet) {
|
public boolean handle(LoginPluginResponse packet) {
|
||||||
if (listenerList.removeIf(id -> id.equals(packet.getId()))) {
|
if (listenerList.removeIf(id -> id.equals(packet.getId()))) {
|
||||||
phase.handle(packet, listenerList.isEmpty());
|
phase.handle(packet, listenerList.isEmpty());
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
public void listen(int id) {
|
public void listen(int id) {
|
||||||
listenerList.add(id);
|
listenerList.add(id);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user