summaryrefslogtreecommitdiff
path: root/common/darkknight/jewelrycraft/util/PlayerUtils.java
diff options
context:
space:
mode:
authorOnyxDarkKnight <sor1n.iliutza16@gmail.com>2014-03-30 22:59:36 +0300
committerOnyxDarkKnight <sor1n.iliutza16@gmail.com>2014-03-30 22:59:36 +0300
commit9d0d74a3ba0aeca9f1130d1228fa4b9ef08d19d6 (patch)
tree86c2e6f3fc80cb4473b9044bdc00d0a2a082ad1b /common/darkknight/jewelrycraft/util/PlayerUtils.java
parent5fce447142b3c0f4a214ca7eb208d9e5c25e6377 (diff)
Added a gui! Yaaay!
Diffstat (limited to 'common/darkknight/jewelrycraft/util/PlayerUtils.java')
-rw-r--r--common/darkknight/jewelrycraft/util/PlayerUtils.java57
1 files changed, 57 insertions, 0 deletions
diff --git a/common/darkknight/jewelrycraft/util/PlayerUtils.java b/common/darkknight/jewelrycraft/util/PlayerUtils.java
new file mode 100644
index 0000000..65b8a17
--- /dev/null
+++ b/common/darkknight/jewelrycraft/util/PlayerUtils.java
@@ -0,0 +1,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.setCompoundTag(EntityPlayer.PERSISTED_NBT_TAG, persistTag);
+ }
+
+ NBTTagCompound modTag = null;
+ if (persistTag.hasKey(modName))
+ {
+ modTag = persistTag.getCompoundTag(modName);
+ } else
+ {
+ modTag = new NBTTagCompound();
+ persistTag.setCompoundTag(modName, modTag);
+ }
+
+ return modTag;
+ }
+} \ No newline at end of file