3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-11-17 05:20:05 +01:00

Implemented getPlayer of OfflinePlayer

Dieser Commit ist enthalten in:
Nathan Adams 2011-10-11 14:52:07 +01:00
Ursprung fd57c7111c
Commit f4229fcadd
2 geänderte Dateien mit 18 neuen und 1 gelöschten Zeilen

Datei anzeigen

@ -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;
}
}

Datei anzeigen

@ -548,4 +548,8 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
return result;
}
public Player getPlayer() {
return this;
}
}