Fixed Sided issue in PlayerHelper - caused crashes in SMP.

This commit is contained in:
WayofTime 2016-01-02 18:52:45 -05:00
parent 71421b7d88
commit 1c75d4f648

View file

@ -1,7 +1,9 @@
package WayofTime.bloodmagic.api.util.helper; package WayofTime.bloodmagic.api.util.helper;
import WayofTime.bloodmagic.api.Constants; import WayofTime.bloodmagic.api.Constants;
import com.google.common.base.Strings; import com.google.common.base.Strings;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.potion.Potion; import net.minecraft.potion.Potion;
@ -9,6 +11,8 @@ import net.minecraft.potion.PotionEffect;
import net.minecraft.server.MinecraftServer; import net.minecraft.server.MinecraftServer;
import net.minecraftforge.common.UsernameCache; import net.minecraftforge.common.UsernameCache;
import net.minecraftforge.common.util.FakePlayer; import net.minecraftforge.common.util.FakePlayer;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.relauncher.Side;
import java.util.UUID; import java.util.UUID;
import java.util.regex.Pattern; import java.util.regex.Pattern;
@ -24,7 +28,7 @@ public class PlayerHelper
public static EntityPlayer getPlayerFromUsername(String username) public static EntityPlayer getPlayerFromUsername(String username)
{ {
if (MinecraftServer.getServer() == null) if (FMLCommonHandler.instance().getEffectiveSide() == Side.CLIENT)
return null; return null;
return MinecraftServer.getServer().getConfigurationManager().getPlayerByUsername(username); return MinecraftServer.getServer().getConfigurationManager().getPlayerByUsername(username);