Fix some ClassCastExceptions incorrectly being logged in FML handshake. (#4972)
This commit is contained in:
parent
19de6cf97e
commit
80724a52d3
2 changed files with 17 additions and 17 deletions
|
@ -129,7 +129,7 @@ enum FMLHandshakeClientState implements IHandshakeState<FMLHandshakeClientState>
|
||||||
WAITINGSERVERCOMPLETE
|
WAITINGSERVERCOMPLETE
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public void accept(final ChannelHandlerContext ctx, final FMLHandshakeMessage msg, final Consumer<? super FMLHandshakeClientState> cons)
|
public void accept(ChannelHandlerContext ctx, FMLHandshakeMessage msg, Consumer<? super FMLHandshakeClientState> cons)
|
||||||
{
|
{
|
||||||
FMLHandshakeMessage.RegistryData pkt = (FMLHandshakeMessage.RegistryData)msg;
|
FMLHandshakeMessage.RegistryData pkt = (FMLHandshakeMessage.RegistryData)msg;
|
||||||
Map<ResourceLocation, ForgeRegistry.Snapshot> snap = ctx.channel().attr(NetworkDispatcher.FML_GAMEDATA_SNAPSHOT).get();
|
Map<ResourceLocation, ForgeRegistry.Snapshot> snap = ctx.channel().attr(NetworkDispatcher.FML_GAMEDATA_SNAPSHOT).get();
|
||||||
|
@ -156,21 +156,18 @@ enum FMLHandshakeClientState implements IHandshakeState<FMLHandshakeClientState>
|
||||||
|
|
||||||
//Do the remapping on the Client's thread in case things are reset while the client is running. We stall the network thread until this is finished which can cause the IO thread to time out... Not sure if we can do anything about that.
|
//Do the remapping on the Client's thread in case things are reset while the client is running. We stall the network thread until this is finished which can cause the IO thread to time out... Not sure if we can do anything about that.
|
||||||
final Map<ResourceLocation, ForgeRegistry.Snapshot> snap_f = snap;
|
final Map<ResourceLocation, ForgeRegistry.Snapshot> snap_f = snap;
|
||||||
Futures.getUnchecked(Minecraft.getMinecraft().addScheduledTask(() ->
|
Multimap<ResourceLocation, ResourceLocation> locallyMissing = Futures.getUnchecked(Minecraft.getMinecraft().addScheduledTask(() -> GameData.injectSnapshot(snap_f, false, false)));
|
||||||
|
if (!locallyMissing.isEmpty())
|
||||||
{
|
{
|
||||||
Multimap<ResourceLocation, ResourceLocation> locallyMissing = GameData.injectSnapshot(snap_f, false, false);
|
cons.accept(ERROR);
|
||||||
if (!locallyMissing.isEmpty())
|
NetworkDispatcher dispatcher = ctx.channel().attr(NetworkDispatcher.FML_DISPATCHER).get();
|
||||||
{
|
dispatcher.rejectHandshake("Fatally missing registry entries");
|
||||||
cons.accept(ERROR);
|
FMLLog.log.fatal("Failed to connect to server: there are {} missing registry items", locallyMissing.size());
|
||||||
NetworkDispatcher dispatcher = ctx.channel().attr(NetworkDispatcher.FML_DISPATCHER).get();
|
locallyMissing.asMap().forEach((key, value) -> FMLLog.log.debug("Missing {} Entries: {}", key, value));
|
||||||
dispatcher.rejectHandshake("Fatally missing registry entries");
|
return;
|
||||||
FMLLog.log.fatal("Failed to connect to server: there are {} missing registry items", locallyMissing.size());
|
}
|
||||||
locallyMissing.asMap().forEach((key, value) -> FMLLog.log.debug("Missing {} Entries: {}", key, value));
|
cons.accept(PENDINGCOMPLETE);
|
||||||
return;
|
ctx.writeAndFlush(new FMLHandshakeMessage.HandshakeAck(ordinal())).addListener(ChannelFutureListener.FIRE_EXCEPTION_ON_FAILURE);
|
||||||
}
|
|
||||||
cons.accept(PENDINGCOMPLETE);
|
|
||||||
ctx.writeAndFlush(new FMLHandshakeMessage.HandshakeAck(ordinal())).addListener(ChannelFutureListener.FIRE_EXCEPTION_ON_FAILURE);
|
|
||||||
}));
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
PENDINGCOMPLETE
|
PENDINGCOMPLETE
|
||||||
|
|
|
@ -28,14 +28,16 @@ import io.netty.util.AttributeKey;
|
||||||
public class HandshakeMessageHandler<S extends Enum<S> & IHandshakeState<S>> extends SimpleChannelInboundHandler<FMLHandshakeMessage> {
|
public class HandshakeMessageHandler<S extends Enum<S> & IHandshakeState<S>> extends SimpleChannelInboundHandler<FMLHandshakeMessage> {
|
||||||
private static final AttributeKey<IHandshakeState<?>> STATE = AttributeKey.valueOf("fml:handshake-state");
|
private static final AttributeKey<IHandshakeState<?>> STATE = AttributeKey.valueOf("fml:handshake-state");
|
||||||
private final AttributeKey<S> fmlHandshakeState;
|
private final AttributeKey<S> fmlHandshakeState;
|
||||||
private S initialState;
|
private final S initialState;
|
||||||
private Class<S> stateType;
|
private final S errorState;
|
||||||
|
private final Class<S> stateType;
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public HandshakeMessageHandler(Class<S> stateType)
|
public HandshakeMessageHandler(Class<S> stateType)
|
||||||
{
|
{
|
||||||
fmlHandshakeState = (AttributeKey<S>) ((Object)STATE);
|
fmlHandshakeState = (AttributeKey<S>) ((Object)STATE);
|
||||||
initialState = Enum.valueOf(stateType, "START");
|
initialState = Enum.valueOf(stateType, "START");
|
||||||
|
errorState = Enum.valueOf(stateType, "ERROR");
|
||||||
this.stateType = stateType;
|
this.stateType = stateType;
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
|
@ -71,6 +73,7 @@ public class HandshakeMessageHandler<S extends Enum<S> & IHandshakeState<S>> ext
|
||||||
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception
|
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception
|
||||||
{
|
{
|
||||||
FMLLog.log.error("HandshakeMessageHandler exception", cause);
|
FMLLog.log.error("HandshakeMessageHandler exception", cause);
|
||||||
|
ctx.channel().attr(fmlHandshakeState).set(errorState);
|
||||||
super.exceptionCaught(ctx, cause);
|
super.exceptionCaught(ctx, cause);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue