diff options
author | Nathan Adams <dinnerbone@dinnerbone.com> | 2011-10-11 14:52:07 +0100 |
---|---|---|
committer | Nathan Adams <dinnerbone@dinnerbone.com> | 2011-10-11 14:52:07 +0100 |
commit | f4229fcaddaa2efb5402ebf9c2647ba783c2f26c (patch) | |
tree | 9e8be7e29b66617b078c1cabd1f7ec340e677d87 /src | |
parent | fd57c7111c8739bc992cc5e637d428e118375a04 (diff) | |
download | craftbukkit-f4229fcaddaa2efb5402ebf9c2647ba783c2f26c.tar craftbukkit-f4229fcaddaa2efb5402ebf9c2647ba783c2f26c.tar.gz craftbukkit-f4229fcaddaa2efb5402ebf9c2647ba783c2f26c.tar.lz craftbukkit-f4229fcaddaa2efb5402ebf9c2647ba783c2f26c.tar.xz craftbukkit-f4229fcaddaa2efb5402ebf9c2647ba783c2f26c.zip |
Implemented getPlayer of OfflinePlayer
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/org/bukkit/craftbukkit/CraftOfflinePlayer.java | 15 | ||||
-rw-r--r-- | src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java | 4 |
2 files changed, 18 insertions, 1 deletions
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftOfflinePlayer.java b/src/main/java/org/bukkit/craftbukkit/CraftOfflinePlayer.java index c72b08aa..55b2f1ef 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftOfflinePlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftOfflinePlayer.java @@ -2,11 +2,13 @@ package org.bukkit.craftbukkit; import java.util.LinkedHashMap; import java.util.Map; +import net.minecraft.server.EntityPlayer; import org.bukkit.Bukkit; import org.bukkit.OfflinePlayer; import org.bukkit.Server; import org.bukkit.configuration.serialization.ConfigurationSerializable; import org.bukkit.configuration.serialization.SerializableAs; +import org.bukkit.entity.Player; @SerializableAs("Player") public class CraftOfflinePlayer implements OfflinePlayer, ConfigurationSerializable { @@ -19,7 +21,7 @@ public class CraftOfflinePlayer implements OfflinePlayer, ConfigurationSerializa } public boolean isOnline() { - return false; + return getPlayer() != null; } public String getName() { @@ -84,4 +86,15 @@ public class CraftOfflinePlayer implements OfflinePlayer, ConfigurationSerializa public String toString() { return getClass().getSimpleName() + "[name=" + name + "]"; } + + public Player getPlayer() { + for (Object obj: server.getHandle().players) { + EntityPlayer player = (EntityPlayer)obj; + if (player.name.equalsIgnoreCase(getName())) { + return (player.netServerHandler != null) ? player.netServerHandler.getPlayer() : null; + } + } + + return null; + } } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java index e43f4f0e..305d72a7 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java @@ -548,4 +548,8 @@ public class CraftPlayer extends CraftHumanEntity implements Player { return result; } + + public Player getPlayer() { + return this; + } } |