mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-25 02:17:35 +01:00
Implemented getPlayer of OfflinePlayer
This commit is contained in:
parent
fd57c7111c
commit
f4229fcadd
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -548,4 +548,8 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public Player getPlayer() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user