Fix #4792 TextComponentHelper handling for FakePlayers

This commit is contained in:
mezz 2018-03-11 14:58:58 -07:00
parent dc459d6b86
commit 752be6b526

View file

@ -21,6 +21,8 @@ package net.minecraftforge.server.command;
import io.netty.channel.Channel;
import net.minecraft.command.ICommandSender;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.network.NetHandlerPlayServer;
import net.minecraft.network.NetworkManager;
import net.minecraft.util.text.TextComponentBase;
import net.minecraft.util.text.TextComponentString;
import net.minecraft.util.text.TextComponentTranslation;
@ -49,8 +51,13 @@ public class TextComponentHelper
if (sender instanceof EntityPlayerMP)
{
EntityPlayerMP playerMP = (EntityPlayerMP) sender;
Channel channel = playerMP.connection.netManager.channel();
return !channel.attr(NetworkRegistry.FML_MARKER).get();
NetHandlerPlayServer connection = playerMP.connection;
if (connection != null)
{
NetworkManager netManager = connection.netManager;
Channel channel = netManager.channel();
return !channel.attr(NetworkRegistry.FML_MARKER).get();
}
}
return false;
}