use of org.spongepowered.common.interfaces.IMixinNetworkManager in project SpongeCommon by SpongePowered.
the class MixinNetHandlerHandshakeTCP method onProcessHandshakeStart.
@Inject(method = "processHandshake", at = @At(value = "HEAD"), cancellable = true)
public void onProcessHandshakeStart(C00Handshake packetIn, CallbackInfo ci) {
if (SpongeImpl.getGlobalConfig().getConfig().getBungeeCord().getIpForwarding() && packetIn.getRequestedState().equals(EnumConnectionState.LOGIN)) {
// ignore any extra data
String[] split = packetIn.ip.split("\00\\|", 2)[0].split("\00");
if (split.length == 3 || split.length == 4) {
packetIn.ip = split[0];
((IMixinNetworkManager) this.networkManager).setRemoteAddress(new InetSocketAddress(split[1], ((InetSocketAddress) this.networkManager.getRemoteAddress()).getPort()));
((IMixinNetworkManager) this.networkManager).setSpoofedUUID(UUIDTypeAdapter.fromString(split[2]));
if (split.length == 4) {
((IMixinNetworkManager) this.networkManager).setSpoofedProfile(gson.fromJson(split[3], Property[].class));
}
} else {
TextComponentString chatcomponenttext = new TextComponentString("If you wish to use IP forwarding, please enable it in your BungeeCord config as well!");
this.networkManager.sendPacket(new SPacketDisconnect(chatcomponenttext));
this.networkManager.closeChannel(chatcomponenttext);
}
}
}
use of org.spongepowered.common.interfaces.IMixinNetworkManager in project SpongeCommon by SpongePowered.
the class MixinNetHandlerHandshakeTCP method onProcessHandshake.
@Inject(method = "processHandshake", at = @At("HEAD"))
public void onProcessHandshake(C00Handshake packetIn, CallbackInfo ci) {
IMixinNetworkManager info = (IMixinNetworkManager) this.networkManager;
info.setVersion(packetIn.getProtocolVersion());
info.setVirtualHost(NetworkUtil.cleanVirtualHost(packetIn.ip), packetIn.port);
}
use of org.spongepowered.common.interfaces.IMixinNetworkManager in project SpongeCommon by SpongePowered.
the class MixinNetHandlerLoginServer method initUuid.
@Inject(method = "processLoginStart", at = @At(value = "FIELD", target = "Lnet/minecraft/server/network/NetHandlerLoginServer;" + "loginGameProfile:Lcom/mojang/authlib/GameProfile;", opcode = Opcodes.PUTFIELD, ordinal = 0, shift = At.Shift.AFTER))
public void initUuid(CallbackInfo ci) {
if (!this.server.isServerInOnlineMode()) {
UUID uuid;
if (((IMixinNetworkManager) this.networkManager).getSpoofedUUID() != null) {
uuid = ((IMixinNetworkManager) this.networkManager).getSpoofedUUID();
} else {
uuid = UUID.nameUUIDFromBytes(("OfflinePlayer:" + this.loginGameProfile.getName()).getBytes(Charsets.UTF_8));
}
this.loginGameProfile = new GameProfile(uuid, this.loginGameProfile.getName());
if (((IMixinNetworkManager) this.networkManager).getSpoofedProfile() != null) {
for (Property property : ((IMixinNetworkManager) this.networkManager).getSpoofedProfile()) {
this.loginGameProfile.getProperties().put(property.getName(), property);
}
}
}
}
Aggregations