blob: aa6a12b56e186d0aa3b682d19aa18712d818ffdd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
package darkknight.jewelrycraft.util;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.integrated.IntegratedServer;
import cpw.mods.fml.common.FMLCommonHandler;
/**
* Code taken from OpenBlocks
*/
public class PlayerUtils
{
public static boolean isPlayerOp(String username)
{
username = username.toLowerCase();
MinecraftServer server = FMLCommonHandler.instance().getSidedDelegate().getServer();
// SP and LAN
if (server.isSinglePlayer()) {
if (server instanceof IntegratedServer) return server.getServerOwner().equals(username);
return server.getConfigurationManager().getOps().contains(username);
}
// SMP
return server.getConfigurationManager().getOps().contains(username);
}
public static NBTTagCompound getModPlayerPersistTag(EntityPlayer player, String modName)
{
NBTTagCompound tag = player.getEntityData();
NBTTagCompound persistTag = null;
if (tag.hasKey(EntityPlayer.PERSISTED_NBT_TAG))
{
persistTag = tag.getCompoundTag(EntityPlayer.PERSISTED_NBT_TAG);
} else
{
persistTag = new NBTTagCompound();
tag.setTag(EntityPlayer.PERSISTED_NBT_TAG, persistTag);
}
NBTTagCompound modTag = null;
if (persistTag.hasKey(modName))
{
modTag = persistTag.getCompoundTag(modName);
} else
{
modTag = new NBTTagCompound();
persistTag.setTag(modName, modTag);
}
return modTag;
}
}
|