DPOH-VAR

mc: class SkullBlockEdit

Nov 20th, 2012
284
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.70 KB | None | 0 0
  1. package me.dpohvar.varscript.utils.minecraft;
  2.  
  3. import net.minecraft.server.NBTTagCompound;
  4. import net.minecraft.server.TileEntity;
  5. import net.minecraft.server.TileEntitySkull;
  6. import org.bukkit.block.Block;
  7. import org.bukkit.craftbukkit.CraftWorld;
  8. import org.bukkit.craftbukkit.inventory.CraftItemStack;
  9. import org.bukkit.inventory.ItemStack;
  10.  
  11. /**
  12.  * Created by IntelliJ IDEA.
  13.  * User: DPOH-VAR
  14.  * Date: 10.08.12
  15.  * Time: 22:35
  16.  * To change this template use File | Settings | File Templates.
  17.  */
  18. public class SkullBlockEdit {
  19.     public final Block block;
  20.  
  21.     public SkullBlockEdit(Block block){
  22.         this.block = block;
  23.     }
  24.  
  25.     public String getOwner(){
  26.         TileEntity tile = ((CraftWorld) block.getWorld()).getTileEntityAt(block.getX(), block.getY(), block.getZ());
  27.         if(tile==null) return null;
  28.         NBTTagCompound compound = new NBTTagCompound();
  29.         tile.b(compound);
  30.         if(!compound.hasKey("ExtraType")) return null;
  31.         return compound.getString("ExtraType");
  32.     }
  33.  
  34.     public SkullBlockEdit setOwner(String owner){
  35.         TileEntity tile = ((CraftWorld) block.getWorld()).getTileEntityAt(block.getX(), block.getY(), block.getZ());
  36.         NBTTagCompound compound = new NBTTagCompound();
  37.         tile.b(compound);
  38.         compound.setString("ExtraType",owner);
  39.         tile.a(compound);
  40.         return this;
  41.     }
  42.  
  43.     public SkullBlockEdit removeOwner(){
  44.         TileEntity tile = ((CraftWorld) block.getWorld()).getTileEntityAt(block.getX(), block.getY(), block.getZ());
  45.         NBTTagCompound compound = new NBTTagCompound();
  46.         tile.b(compound);
  47.         compound.remove("ExtraType");
  48.         tile.a(compound);
  49.         return this;
  50.     }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment