From 3cf1720ddda44728852aac56d18caecaf40d765e Mon Sep 17 00:00:00 2001 From: gravityfox Date: Wed, 14 Sep 2016 02:57:40 -0700 Subject: [PATCH] Add server client remote channel checks. --- build.gradle | 2 +- .../sponge/foxcore/mod/FCClientNetworkManager.java | 5 +++++ .../sponge/foxcore/plugin/FCServerNetworkManager.java | 5 +++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 28a83ec..10d7c94 100644 --- a/build.gradle +++ b/build.gradle @@ -67,7 +67,7 @@ repositories { dependencies { compile "org.spongepowered:spongeapi:$spongeVersion" compile 'com.flowpowered:flow-math:1.0.2' - compile 'org.mapdb:mapdb:3.0.0' + compile 'org.mapdb:mapdb:3.0.1' //testCompile group: 'junit', name: 'junit', version: '4.11' } diff --git a/src/main/java/net/foxdenstudio/sponge/foxcore/mod/FCClientNetworkManager.java b/src/main/java/net/foxdenstudio/sponge/foxcore/mod/FCClientNetworkManager.java index 5277ba3..64accc1 100644 --- a/src/main/java/net/foxdenstudio/sponge/foxcore/mod/FCClientNetworkManager.java +++ b/src/main/java/net/foxdenstudio/sponge/foxcore/mod/FCClientNetworkManager.java @@ -33,6 +33,7 @@ import io.netty.channel.ChannelInboundHandlerAdapter; import net.foxdenstudio.sponge.foxcore.common.network.IClientPacket; import net.foxdenstudio.sponge.foxcore.common.network.IServerPacketListener; +import net.foxdenstudio.sponge.foxcore.plugin.FCServerNetworkManager; import net.minecraft.network.PacketBuffer; import net.minecraftforge.fml.common.network.ByteBufUtils; import net.minecraftforge.fml.common.network.FMLEmbeddedChannel; @@ -163,6 +164,10 @@ public void sendDebug() { fmlEmbeddedChannel.attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.TOSERVER); fmlEmbeddedChannel.writeAndFlush(new FMLProxyPacket(new PacketBuffer(byteBuf), "fox")).addListener(ChannelFutureListener.FIRE_EXCEPTION_ON_FAILURE); } + + public boolean hasServerChannel() { + return FCClientNetworkManager.this.serverChannelMapping.values().contains(this.name); + } } /** diff --git a/src/main/java/net/foxdenstudio/sponge/foxcore/plugin/FCServerNetworkManager.java b/src/main/java/net/foxdenstudio/sponge/foxcore/plugin/FCServerNetworkManager.java index 8efe8c9..eda21ef 100644 --- a/src/main/java/net/foxdenstudio/sponge/foxcore/plugin/FCServerNetworkManager.java +++ b/src/main/java/net/foxdenstudio/sponge/foxcore/plugin/FCServerNetworkManager.java @@ -194,6 +194,11 @@ public void sendDebug(Player player) { } } + public boolean hasClientChannel(Player player) { + PlayerConfig config = FCServerNetworkManager.this.playerConfigs.get(player); + return config != null && config.clientChannelMapping.values().contains(this.name); + } + } public class PlayerConfig {