Advertisement
DPOH-VAR

mc: class SkullEdit

Nov 20th, 2012
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.19 KB | None | 0 0
  1. package me.dpohvar.varscript.utils.minecraft;
  2.  
  3. import net.minecraft.server.NBTTagCompound;
  4. import org.bukkit.craftbukkit.inventory.CraftItemStack;
  5. import org.bukkit.inventory.ItemStack;
  6.  
  7. import java.nio.ByteBuffer;
  8.  
  9. /**
  10.  * Created by IntelliJ IDEA.
  11.  * User: DPOH-VAR
  12.  * Date: 10.08.12
  13.  * Time: 22:35
  14.  * To change this template use File | Settings | File Templates.
  15.  */
  16. public class SkullEdit {
  17.     public final ItemStack item;
  18.     private NBTTagCompound tagData;
  19.  
  20.     public SkullEdit(ItemStack s){
  21.         this.item = s;
  22.         net.minecraft.server.ItemStack i = ((CraftItemStack) s).getHandle();
  23.         if (i.tag == null) {
  24.             tagData = new NBTTagCompound();
  25.             i.tag = tagData;
  26.         } else {
  27.             tagData = i.tag;
  28.         }
  29.     }
  30.  
  31.     public String getOwner(){
  32.         if (!tagData.hasKey("SkullOwner")) return null;
  33.         return tagData.getString("SkullOwner");
  34.     }
  35.  
  36.     public SkullEdit setOwner(String owner){
  37.         if(owner==null)return removeOwner();
  38.         tagData.setString("SkullOwner",owner);
  39.         return this;
  40.     }
  41.  
  42.     public SkullEdit removeOwner(){
  43.         tagData.remove("SkullOwner");
  44.         return this;
  45.     }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement