diff options
Diffstat (limited to 'Essentials/src/com/earth2me/essentials/OfflinePlayer.java')
-rw-r--r-- | Essentials/src/com/earth2me/essentials/OfflinePlayer.java | 295 |
1 files changed, 214 insertions, 81 deletions
diff --git a/Essentials/src/com/earth2me/essentials/OfflinePlayer.java b/Essentials/src/com/earth2me/essentials/OfflinePlayer.java index 8e50aa1bd..097c4c883 100644 --- a/Essentials/src/com/earth2me/essentials/OfflinePlayer.java +++ b/Essentials/src/com/earth2me/essentials/OfflinePlayer.java @@ -1,29 +1,18 @@ package com.earth2me.essentials; +import com.earth2me.essentials.craftbukkit.OfflineBedLocation; +import static com.earth2me.essentials.I18n._; import java.net.InetSocketAddress; import java.util.HashSet; import java.util.List; import java.util.Set; import java.util.UUID; import lombok.Delegate; -import org.bukkit.Achievement; -import org.bukkit.Effect; -import org.bukkit.GameMode; -import org.bukkit.Instrument; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.Note; -import org.bukkit.Server; -import org.bukkit.Statistic; -import org.bukkit.World; +import org.bukkit.*; import org.bukkit.block.Block; -import org.bukkit.entity.Arrow; -import org.bukkit.entity.Egg; -import org.bukkit.entity.Entity; -import org.bukkit.entity.Player; -import org.bukkit.entity.Snowball; -import org.bukkit.entity.Vehicle; +import org.bukkit.entity.*; import org.bukkit.event.entity.EntityDamageEvent; +import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.PlayerInventory; import org.bukkit.map.MapView; @@ -37,11 +26,11 @@ import org.bukkit.util.Vector; public class OfflinePlayer implements Player { private final transient IEssentials ess; - private Location location = new Location(null, 0, 0, 0, 0, 0); - private World world; - private UUID uniqueId = UUID.randomUUID(); - @Delegate(types=org.bukkit.OfflinePlayer.class) - private final org.bukkit.OfflinePlayer base; + private transient Location location = new Location(null, 0, 0, 0, 0, 0); + private transient World world; + private final transient UUID uniqueId = UUID.randomUUID(); + @Delegate(types = org.bukkit.OfflinePlayer.class) + private transient org.bukkit.OfflinePlayer base; public OfflinePlayer(final String name, final IEssentials ess) { @@ -66,77 +55,93 @@ public class OfflinePlayer implements Player { } + @Override public void setCompassTarget(Location lctn) { } + @Override public InetSocketAddress getAddress() { return null; } + @Override public void kickPlayer(String string) { } + @Override public PlayerInventory getInventory() { return null; } + @Override public ItemStack getItemInHand() { return null; } + @Override public void setItemInHand(ItemStack is) { } + @Override public int getHealth() { return 0; } + @Override public void setHealth(int i) { } + @Override public Egg throwEgg() { return null; } + @Override public Snowball throwSnowball() { return null; } + @Override public Arrow shootArrow() { return null; } + @Override public boolean isInsideVehicle() { return false; } + @Override public boolean leaveVehicle() { return false; } + @Override public Vehicle getVehicle() { return null; } + @Override public Location getLocation() { return location; } + @Override public World getWorld() { return world; @@ -156,11 +161,13 @@ public class OfflinePlayer implements Player { } + @Override public int getEntityId() { return -1; } + @Override public boolean performCommand(String string) { return false; @@ -171,91 +178,109 @@ public class OfflinePlayer implements Player return false; } + @Override public int getRemainingAir() { - throw new UnsupportedOperationException(Util.i18n("notSupportedYet")); + throw new UnsupportedOperationException(_("notSupportedYet")); } + @Override public void setRemainingAir(int i) { - throw new UnsupportedOperationException(Util.i18n("notSupportedYet")); + throw new UnsupportedOperationException(_("notSupportedYet")); } + @Override public int getMaximumAir() { - throw new UnsupportedOperationException(Util.i18n("notSupportedYet")); + throw new UnsupportedOperationException(_("notSupportedYet")); } + @Override public void setMaximumAir(int i) { - throw new UnsupportedOperationException(Util.i18n("notSupportedYet")); + throw new UnsupportedOperationException(_("notSupportedYet")); } + @Override public boolean isSneaking() { return false; } + @Override public void setSneaking(boolean bln) { - throw new UnsupportedOperationException(Util.i18n("notSupportedYet")); + throw new UnsupportedOperationException(_("notSupportedYet")); } + @Override public void updateInventory() { - throw new UnsupportedOperationException(Util.i18n("notSupportedYet")); + throw new UnsupportedOperationException(_("notSupportedYet")); } + @Override public void chat(String string) { - throw new UnsupportedOperationException(Util.i18n("notSupportedYet")); + throw new UnsupportedOperationException(_("notSupportedYet")); } + @Override public double getEyeHeight() { - throw new UnsupportedOperationException(Util.i18n("notSupportedYet")); + throw new UnsupportedOperationException(_("notSupportedYet")); } + @Override public double getEyeHeight(boolean bln) { - throw new UnsupportedOperationException(Util.i18n("notSupportedYet")); + throw new UnsupportedOperationException(_("notSupportedYet")); } + @Override public List<Block> getLineOfSight(HashSet<Byte> hs, int i) { - throw new UnsupportedOperationException(Util.i18n("notSupportedYet")); + throw new UnsupportedOperationException(_("notSupportedYet")); } + @Override public Block getTargetBlock(HashSet<Byte> hs, int i) { - throw new UnsupportedOperationException(Util.i18n("notSupportedYet")); + throw new UnsupportedOperationException(_("notSupportedYet")); } + @Override public List<Block> getLastTwoTargetBlocks(HashSet<Byte> hs, int i) { - throw new UnsupportedOperationException(Util.i18n("notSupportedYet")); + throw new UnsupportedOperationException(_("notSupportedYet")); } + @Override public int getFireTicks() { - throw new UnsupportedOperationException(Util.i18n("notSupportedYet")); + throw new UnsupportedOperationException(_("notSupportedYet")); } + @Override public int getMaxFireTicks() { - throw new UnsupportedOperationException(Util.i18n("notSupportedYet")); + throw new UnsupportedOperationException(_("notSupportedYet")); } + @Override public void setFireTicks(int i) { - throw new UnsupportedOperationException(Util.i18n("notSupportedYet")); + throw new UnsupportedOperationException(_("notSupportedYet")); } + @Override public void remove() { - throw new UnsupportedOperationException(Util.i18n("notSupportedYet")); + throw new UnsupportedOperationException(_("notSupportedYet")); } + @Override public Server getServer() { return ess == null ? null : ess.getServer(); @@ -263,308 +288,367 @@ public class OfflinePlayer implements Player public Vector getMomentum() { - throw new UnsupportedOperationException(Util.i18n("notSupportedYet")); + throw new UnsupportedOperationException(_("notSupportedYet")); } public void setMomentum(Vector vector) { - throw new UnsupportedOperationException(Util.i18n("notSupportedYet")); + throw new UnsupportedOperationException(_("notSupportedYet")); } + @Override public void setVelocity(Vector vector) { - throw new UnsupportedOperationException(Util.i18n("notSupportedYet")); + throw new UnsupportedOperationException(_("notSupportedYet")); } + @Override public Vector getVelocity() { - throw new UnsupportedOperationException(Util.i18n("notSupportedYet")); + throw new UnsupportedOperationException(_("notSupportedYet")); } + @Override public void damage(int i) { - throw new UnsupportedOperationException(Util.i18n("notSupportedYet")); + throw new UnsupportedOperationException(_("notSupportedYet")); } + @Override public void damage(int i, Entity entity) { - throw new UnsupportedOperationException(Util.i18n("notSupportedYet")); + throw new UnsupportedOperationException(_("notSupportedYet")); } + @Override public Location getEyeLocation() { - throw new UnsupportedOperationException(Util.i18n("notSupportedYet")); + throw new UnsupportedOperationException(_("notSupportedYet")); } + @Override public void sendRawMessage(String string) { - throw new UnsupportedOperationException(Util.i18n("notSupportedYet")); + throw new UnsupportedOperationException(_("notSupportedYet")); } + @Override public Location getCompassTarget() { - throw new UnsupportedOperationException(Util.i18n("notSupportedYet")); + throw new UnsupportedOperationException(_("notSupportedYet")); } + @Override public int getMaximumNoDamageTicks() { - throw new UnsupportedOperationException(Util.i18n("notSupportedYet")); + throw new UnsupportedOperationException(_("notSupportedYet")); } + @Override public void setMaximumNoDamageTicks(int i) { - throw new UnsupportedOperationException(Util.i18n("notSupportedYet")); + throw new UnsupportedOperationException(_("notSupportedYet")); } + @Override public int getLastDamage() { - throw new UnsupportedOperationException(Util.i18n("notSupportedYet")); + throw new UnsupportedOperationException(_("notSupportedYet")); } + @Override public void setLastDamage(int i) { - throw new UnsupportedOperationException(Util.i18n("notSupportedYet")); + throw new UnsupportedOperationException(_("notSupportedYet")); } + @Override public int getNoDamageTicks() { - throw new UnsupportedOperationException(Util.i18n("notSupportedYet")); + throw new UnsupportedOperationException(_("notSupportedYet")); } + @Override public void setNoDamageTicks(int i) { - throw new UnsupportedOperationException(Util.i18n("notSupportedYet")); + throw new UnsupportedOperationException(_("notSupportedYet")); } + @Override public boolean teleport(Location lctn) { - throw new UnsupportedOperationException(Util.i18n("notSupportedYet")); + throw new UnsupportedOperationException(_("notSupportedYet")); } + @Override public boolean teleport(Entity entity) { - throw new UnsupportedOperationException(Util.i18n("notSupportedYet")); + throw new UnsupportedOperationException(_("notSupportedYet")); } + @Override public Entity getPassenger() { - throw new UnsupportedOperationException(Util.i18n("notSupportedYet")); + throw new UnsupportedOperationException(_("notSupportedYet")); } + @Override public boolean setPassenger(Entity entity) { - throw new UnsupportedOperationException(Util.i18n("notSupportedYet")); + throw new UnsupportedOperationException(_("notSupportedYet")); } + @Override public boolean isEmpty() { - throw new UnsupportedOperationException(Util.i18n("notSupportedYet")); + throw new UnsupportedOperationException(_("notSupportedYet")); } + @Override public boolean eject() { - throw new UnsupportedOperationException(Util.i18n("notSupportedYet")); + throw new UnsupportedOperationException(_("notSupportedYet")); } + @Override public void saveData() { - throw new UnsupportedOperationException(Util.i18n("notSupportedYet")); + throw new UnsupportedOperationException(_("notSupportedYet")); } + @Override public void loadData() { - throw new UnsupportedOperationException(Util.i18n("notSupportedYet")); + throw new UnsupportedOperationException(_("notSupportedYet")); } + @Override public boolean isSleeping() { - throw new UnsupportedOperationException(Util.i18n("notSupportedYet")); + throw new UnsupportedOperationException(_("notSupportedYet")); } + @Override public int getSleepTicks() { - throw new UnsupportedOperationException(Util.i18n("notSupportedYet")); + throw new UnsupportedOperationException(_("notSupportedYet")); } + @Override public List<Entity> getNearbyEntities(double d, double d1, double d2) { - throw new UnsupportedOperationException(Util.i18n("notSupportedYet")); + throw new UnsupportedOperationException(_("notSupportedYet")); } + @Override public boolean isDead() { - throw new UnsupportedOperationException(Util.i18n("notSupportedYet")); + throw new UnsupportedOperationException(_("notSupportedYet")); } + @Override public float getFallDistance() { - throw new UnsupportedOperationException(Util.i18n("notSupportedYet")); + throw new UnsupportedOperationException(_("notSupportedYet")); } + @Override public void setFallDistance(float f) { - throw new UnsupportedOperationException(Util.i18n("notSupportedYet")); + throw new UnsupportedOperationException(_("notSupportedYet")); } + @Override public void setSleepingIgnored(boolean bln) { - throw new UnsupportedOperationException(Util.i18n("notSupportedYet")); + throw new UnsupportedOperationException(_("notSupportedYet")); } + @Override public boolean isSleepingIgnored() { - throw new UnsupportedOperationException(Util.i18n("notSupportedYet")); + throw new UnsupportedOperationException(_("notSupportedYet")); } + @Override public void awardAchievement(Achievement a) { - throw new UnsupportedOperationException(Util.i18n("notSupportedYet")); + throw new UnsupportedOperationException(_("notSupportedYet")); } + @Override public void incrementStatistic(Statistic ststc) { - throw new UnsupportedOperationException(Util.i18n("notSupportedYet")); + throw new UnsupportedOperationException(_("notSupportedYet")); } + @Override public void incrementStatistic(Statistic ststc, int i) { - throw new UnsupportedOperationException(Util.i18n("notSupportedYet")); + throw new UnsupportedOperationException(_("notSupportedYet")); } + @Override public void incrementStatistic(Statistic ststc, Material mtrl) { - throw new UnsupportedOperationException(Util.i18n("notSupportedYet")); + throw new UnsupportedOperationException(_("notSupportedYet")); } + @Override public void incrementStatistic(Statistic ststc, Material mtrl, int i) { - throw new UnsupportedOperationException(Util.i18n("notSupportedYet")); + throw new UnsupportedOperationException(_("notSupportedYet")); } + @Override public void playNote(Location lctn, byte b, byte b1) { - throw new UnsupportedOperationException(Util.i18n("notSupportedYet")); + throw new UnsupportedOperationException(_("notSupportedYet")); } + @Override public void sendBlockChange(Location lctn, Material mtrl, byte b) { - throw new UnsupportedOperationException(Util.i18n("notSupportedYet")); + throw new UnsupportedOperationException(_("notSupportedYet")); } + @Override public void sendBlockChange(Location lctn, int i, byte b) { - throw new UnsupportedOperationException(Util.i18n("notSupportedYet")); + throw new UnsupportedOperationException(_("notSupportedYet")); } + @Override public void setLastDamageCause(EntityDamageEvent ede) { - throw new UnsupportedOperationException(Util.i18n("notSupportedYet")); + throw new UnsupportedOperationException(_("notSupportedYet")); } + @Override public EntityDamageEvent getLastDamageCause() { - throw new UnsupportedOperationException(Util.i18n("notSupportedYet")); + throw new UnsupportedOperationException(_("notSupportedYet")); } + @Override public void playEffect(Location lctn, Effect effect, int i) { - throw new UnsupportedOperationException(Util.i18n("notSupportedYet")); + throw new UnsupportedOperationException(_("notSupportedYet")); } + @Override public boolean sendChunkChange(Location lctn, int i, int i1, int i2, byte[] bytes) { return true; } + @Override public UUID getUniqueId() { return uniqueId; } + @Override public void playNote(Location lctn, Instrument i, Note note) { throw new UnsupportedOperationException("Not supported yet."); } + @Override public void setPlayerTime(long l, boolean bln) { throw new UnsupportedOperationException("Not supported yet."); } + @Override public long getPlayerTime() { throw new UnsupportedOperationException("Not supported yet."); } + @Override public long getPlayerTimeOffset() { throw new UnsupportedOperationException("Not supported yet."); } + @Override public boolean isPlayerTimeRelative() { throw new UnsupportedOperationException("Not supported yet."); } + @Override public void resetPlayerTime() { throw new UnsupportedOperationException("Not supported yet."); } + @Override public boolean isPermissionSet(String string) { return false; } + @Override public boolean isPermissionSet(Permission prmsn) { return false; } + @Override public boolean hasPermission(String string) { return false; } + @Override public boolean hasPermission(Permission prmsn) { return false; } + @Override public PermissionAttachment addAttachment(Plugin plugin, String string, boolean bln) { throw new UnsupportedOperationException("Not supported yet."); } + @Override public PermissionAttachment addAttachment(Plugin plugin) { throw new UnsupportedOperationException("Not supported yet."); } + @Override public PermissionAttachment addAttachment(Plugin plugin, String string, boolean bln, int i) { throw new UnsupportedOperationException("Not supported yet."); } + @Override public PermissionAttachment addAttachment(Plugin plugin, int i) { throw new UnsupportedOperationException("Not supported yet."); } + @Override public void removeAttachment(PermissionAttachment pa) { throw new UnsupportedOperationException("Not supported yet."); } + @Override public void recalculatePermissions() { } + @Override public Set<PermissionAttachmentInfo> getEffectivePermissions() { throw new UnsupportedOperationException("Not supported yet."); } - + @Override public void sendMap(MapView mv) { @@ -658,7 +742,7 @@ public class OfflinePlayer implements Player @Override public Location getBedSpawnLocation() { - throw new UnsupportedOperationException("Not supported yet."); + return OfflineBedLocation.getBedLocation(base.getName(), ess); } @Override @@ -696,4 +780,53 @@ public class OfflinePlayer implements Player { throw new UnsupportedOperationException("Not supported yet."); } + + @Override + public int getMaxHealth() + { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void giveExp(int i) + { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public float getExp() + { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setExp(float f) + { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean teleport(Location lctn, TeleportCause tc) + { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean teleport(Entity entity, TeleportCause tc) + { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Player getKiller() + { + throw new UnsupportedOperationException("Not supported yet."); + } + + void setName(final String name) + { + if (!this.base.getName().equalsIgnoreCase(name)) { + this.base = ess.getServer().getOfflinePlayer(name); + } + } } |