Merge pull request #575 from lumien231/1.8

Save the mod list of players in their NetworkDispatcher
This commit is contained in:
LexManos 2015-01-16 14:40:06 -08:00
commit c7da6c703f
2 changed files with 20 additions and 1 deletions

View file

@ -41,11 +41,12 @@ enum FMLHandshakeServerState implements IHandshakeState<FMLHandshakeServerState>
} }
FMLHandshakeMessage.ModList client = (FMLHandshakeMessage.ModList)msg; FMLHandshakeMessage.ModList client = (FMLHandshakeMessage.ModList)msg;
NetworkDispatcher dispatcher = ctx.channel().attr(NetworkDispatcher.FML_DISPATCHER).get();
dispatcher.setModList(client.modList());
FMLLog.info("Client attempting to join with %d mods : %s", client.modListSize(), client.modListAsString()); FMLLog.info("Client attempting to join with %d mods : %s", client.modListSize(), client.modListAsString());
String result = FMLNetworkHandler.checkModList(client, Side.CLIENT); String result = FMLNetworkHandler.checkModList(client, Side.CLIENT);
if (result != null) if (result != null)
{ {
NetworkDispatcher dispatcher = ctx.channel().attr(NetworkDispatcher.FML_DISPATCHER).get();
dispatcher.rejectHandshake(result); dispatcher.rejectHandshake(result);
return ERROR; return ERROR;
} }

View file

@ -13,8 +13,10 @@ import io.netty.util.concurrent.GenericFutureListener;
import java.io.IOException; import java.io.IOException;
import java.net.SocketAddress; import java.net.SocketAddress;
import java.nio.channels.ClosedChannelException; import java.nio.channels.ClosedChannelException;
import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.Map;
import org.apache.logging.log4j.Level; import org.apache.logging.log4j.Level;
@ -85,6 +87,7 @@ public class NetworkDispatcher extends SimpleChannelInboundHandler<Packet> imple
private final EmbeddedChannel handshakeChannel; private final EmbeddedChannel handshakeChannel;
private NetHandlerPlayServer serverHandler; private NetHandlerPlayServer serverHandler;
private INetHandler netHandler; private INetHandler netHandler;
private Map<String,String> modList;
public NetworkDispatcher(NetworkManager manager) public NetworkDispatcher(NetworkManager manager)
{ {
@ -134,6 +137,11 @@ public class NetworkDispatcher extends SimpleChannelInboundHandler<Packet> imple
} }
} }
protected void setModList(Map<String,String> modList)
{
this.modList = modList;
}
private void insertIntoChannel() private void insertIntoChannel()
{ {
this.manager.channel().config().setAutoRead(false); this.manager.channel().config().setAutoRead(false);
@ -246,6 +254,16 @@ public class NetworkDispatcher extends SimpleChannelInboundHandler<Packet> imple
return netHandler; return netHandler;
} }
/**
* The mod list returned by this method is in no way reliable because it is provided by the client
*
* @return a map that will contain String keys and values listing all mods and their versions
*/
public Map<String,String> getModList()
{
return Collections.unmodifiableMap(modList);
}
@Override @Override
public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception
{ {