Fork of Poseidon providing Bukkit #1060 to older Beta versions (b1.0-b1.7.3)
at develop 129 lines 3.6 kB view raw
1package org.bukkit.craftbukkit.entity; 2 3import net.minecraft.server.EntityHuman; 4import org.bukkit.craftbukkit.CraftServer; 5import org.bukkit.craftbukkit.inventory.CraftInventoryPlayer; 6import org.bukkit.entity.HumanEntity; 7import org.bukkit.inventory.ItemStack; 8import org.bukkit.inventory.PlayerInventory; 9import org.bukkit.permissions.PermissibleBase; 10import org.bukkit.permissions.Permission; 11import org.bukkit.permissions.PermissionAttachment; 12import org.bukkit.permissions.PermissionAttachmentInfo; 13import org.bukkit.plugin.Plugin; 14 15import java.util.Set; 16 17//import org.bukkit.GameMode; 18 19public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity { 20 private CraftInventoryPlayer inventory; 21 protected final PermissibleBase perm = new PermissibleBase(this); 22 private boolean op; 23 24 public CraftHumanEntity(final CraftServer server, final EntityHuman entity) { 25 super(server, entity); 26 this.inventory = new CraftInventoryPlayer(entity.inventory); 27 } 28 29 public String getName() { 30 return getHandle().name; 31 } 32 33 @Override 34 public EntityHuman getHandle() { 35 return (EntityHuman) entity; 36 } 37 38 public void setHandle(final EntityHuman entity) { 39 super.setHandle((EntityHuman) entity); 40 this.entity = entity; 41 this.inventory = new CraftInventoryPlayer(entity.inventory); 42 } 43 44 public PlayerInventory getInventory() { 45 return inventory; 46 } 47 48 public ItemStack getItemInHand() { 49 return getInventory().getItemInHand(); 50 } 51 52 public void setItemInHand(ItemStack item) { 53 getInventory().setItemInHand(item); 54 } 55 56 @Override 57 public String toString() { 58 return "CraftHumanEntity{" + "id=" + getEntityId() + "name=" + getName() + '}'; 59 } 60 61 public boolean isSleeping() { 62 return getHandle().sleeping; 63 } 64 65 public int getSleepTicks() { 66 return getHandle().sleepTicks; 67 } 68 69 public boolean isOp() { 70 return op; 71 } 72 73 public boolean isPermissionSet(String name) { 74 return perm.isPermissionSet(name); 75 } 76 77 public boolean isPermissionSet(Permission perm) { 78 return this.perm.isPermissionSet(perm); 79 } 80 81 public boolean hasPermission(String name) { 82 return perm.hasPermission(name); 83 } 84 85 public boolean hasPermission(Permission perm) { 86 return this.perm.hasPermission(perm); 87 } 88 89 public PermissionAttachment addAttachment(Plugin plugin, String name, boolean value) { 90 return perm.addAttachment(plugin, name, value); 91 } 92 93 public PermissionAttachment addAttachment(Plugin plugin) { 94 return perm.addAttachment(plugin); 95 } 96 97 public PermissionAttachment addAttachment(Plugin plugin, String name, boolean value, int ticks) { 98 return perm.addAttachment(plugin, name, value, ticks); 99 } 100 101 public PermissionAttachment addAttachment(Plugin plugin, int ticks) { 102 return perm.addAttachment(plugin, ticks); 103 } 104 105 public void removeAttachment(PermissionAttachment attachment) { 106 perm.removeAttachment(attachment); 107 } 108 109 public void recalculatePermissions() { 110 perm.recalculatePermissions(); 111 } 112 113 public void setOp(boolean value) { 114 this.op = value; 115 perm.recalculatePermissions(); 116 } 117 118 public Set<PermissionAttachmentInfo> getEffectivePermissions() { 119 return perm.getEffectivePermissions(); 120 } 121 122// public GameMode getGameMode() { 123// return GameMode.SURVIVAL; 124// } 125// 126// public void setGameMode(GameMode mode) { 127// throw new UnsupportedOperationException("Not supported yet."); 128// } 129}