Save the mod list of players in their NetworkDispatcher (Make it accessable for mods)
This commit is contained in:
parent
5b07c7fead
commit
6f19fd1513
2 changed files with 20 additions and 1 deletions
|
@ -41,11 +41,12 @@ enum FMLHandshakeServerState implements IHandshakeState<FMLHandshakeServerState>
|
|||
}
|
||||
|
||||
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());
|
||||
String result = FMLNetworkHandler.checkModList(client, Side.CLIENT);
|
||||
if (result != null)
|
||||
{
|
||||
NetworkDispatcher dispatcher = ctx.channel().attr(NetworkDispatcher.FML_DISPATCHER).get();
|
||||
dispatcher.rejectHandshake(result);
|
||||
return ERROR;
|
||||
}
|
||||
|
|
|
@ -13,8 +13,10 @@ import io.netty.util.concurrent.GenericFutureListener;
|
|||
import java.io.IOException;
|
||||
import java.net.SocketAddress;
|
||||
import java.nio.channels.ClosedChannelException;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.logging.log4j.Level;
|
||||
|
||||
|
@ -85,6 +87,7 @@ public class NetworkDispatcher extends SimpleChannelInboundHandler<Packet> imple
|
|||
private final EmbeddedChannel handshakeChannel;
|
||||
private NetHandlerPlayServer serverHandler;
|
||||
private INetHandler netHandler;
|
||||
private Map<String,String> modList;
|
||||
|
||||
public NetworkDispatcher(NetworkManager manager)
|
||||
{
|
||||
|
@ -133,6 +136,11 @@ public class NetworkDispatcher extends SimpleChannelInboundHandler<Packet> imple
|
|||
this.completeServerSideConnection(ConnectionType.VANILLA);
|
||||
}
|
||||
}
|
||||
|
||||
protected void setModList(Map<String,String> modList)
|
||||
{
|
||||
this.modList = modList;
|
||||
}
|
||||
|
||||
private void insertIntoChannel()
|
||||
{
|
||||
|
@ -245,6 +253,16 @@ public class NetworkDispatcher extends SimpleChannelInboundHandler<Packet> imple
|
|||
{
|
||||
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
|
||||
public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception
|
||||
|
|
Loading…
Reference in a new issue