Skip to content

Commit

Permalink
Add server client remote channel checks.
Browse files Browse the repository at this point in the history
  • Loading branch information
gravityfox committed Sep 14, 2016
1 parent 823ac20 commit 3cf1720
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 3cf1720

Please sign in to comment.