Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package me.dpohvar.varscript.utils.minecraft;
- import net.minecraft.server.NBTTagCompound;
- import net.minecraft.server.TileEntity;
- import net.minecraft.server.TileEntitySkull;
- import org.bukkit.block.Block;
- import org.bukkit.craftbukkit.CraftWorld;
- import org.bukkit.craftbukkit.inventory.CraftItemStack;
- import org.bukkit.inventory.ItemStack;
- /**
- * Created by IntelliJ IDEA.
- * User: DPOH-VAR
- * Date: 10.08.12
- * Time: 22:35
- * To change this template use File | Settings | File Templates.
- */
- public class SkullBlockEdit {
- public final Block block;
- public SkullBlockEdit(Block block){
- this.block = block;
- }
- public String getOwner(){
- TileEntity tile = ((CraftWorld) block.getWorld()).getTileEntityAt(block.getX(), block.getY(), block.getZ());
- if(tile==null) return null;
- NBTTagCompound compound = new NBTTagCompound();
- tile.b(compound);
- if(!compound.hasKey("ExtraType")) return null;
- return compound.getString("ExtraType");
- }
- public SkullBlockEdit setOwner(String owner){
- TileEntity tile = ((CraftWorld) block.getWorld()).getTileEntityAt(block.getX(), block.getY(), block.getZ());
- NBTTagCompound compound = new NBTTagCompound();
- tile.b(compound);
- compound.setString("ExtraType",owner);
- tile.a(compound);
- return this;
- }
- public SkullBlockEdit removeOwner(){
- TileEntity tile = ((CraftWorld) block.getWorld()).getTileEntityAt(block.getX(), block.getY(), block.getZ());
- NBTTagCompound compound = new NBTTagCompound();
- tile.b(compound);
- compound.remove("ExtraType");
- tile.a(compound);
- return this;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment