mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-28 03:48:01 +01:00
Hook onto the server, and added player
By: Dinnerbone <dinnerbone@dinnerbone.com>
This commit is contained in:
parent
8d095d827c
commit
f24de1b5e4
25
paper-server/src/org/bukkit/craftbukkit/CraftPlayer.java
Normal file
25
paper-server/src/org/bukkit/craftbukkit/CraftPlayer.java
Normal file
@ -0,0 +1,25 @@
|
||||
|
||||
package org.bukkit.craftbukkit;
|
||||
|
||||
import net.minecraft.server.fi;
|
||||
import org.bukkit.Player;
|
||||
|
||||
public class CraftPlayer implements Player {
|
||||
private fi player;
|
||||
private final String name;
|
||||
private final CraftServer server;
|
||||
|
||||
public CraftPlayer(CraftServer serv, fi handle) {
|
||||
player = handle;
|
||||
name = player.aw;
|
||||
server = serv;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public boolean isOnline() {
|
||||
return server.server.g(name);
|
||||
}
|
||||
}
|
@ -1,25 +1,51 @@
|
||||
|
||||
package org.bukkit.craftbukkit;
|
||||
|
||||
import org.bukkit.Server;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import org.bukkit.*;
|
||||
import net.minecraft.server.*;
|
||||
|
||||
public class CraftServer implements Server {
|
||||
private final String name = "CraftBucket";
|
||||
private String version;
|
||||
MinecraftServer server;
|
||||
private final String serverName = "CraftBucket";
|
||||
private final String serverVersion;
|
||||
private final HashMap<String, Player> playerCache = new HashMap<String, Player>();
|
||||
|
||||
protected CraftServer(MinecraftServer instance, String ver) {
|
||||
server = instance;
|
||||
version = ver;
|
||||
protected final MinecraftServer console;
|
||||
protected final hl server;
|
||||
|
||||
public CraftServer(MinecraftServer instance, String ver) {
|
||||
serverVersion = ver;
|
||||
|
||||
console = instance;
|
||||
server = console.f;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
return serverName;
|
||||
}
|
||||
|
||||
public String getVersion() {
|
||||
return version;
|
||||
return serverVersion;
|
||||
}
|
||||
|
||||
public Player[] getOnlinePlayers() {
|
||||
List<fi> online = server.b;
|
||||
Player[] players = new Player[online.size()];
|
||||
|
||||
for (int i = 0; i < players.length; i++) {
|
||||
String name = online.get(i).aw;
|
||||
|
||||
if (playerCache.containsKey(name)) {
|
||||
players[i] = playerCache.get(name);
|
||||
} else {
|
||||
players[i] = new CraftPlayer(this, online.get(i));
|
||||
playerCache.put(name, players[i]);
|
||||
}
|
||||
}
|
||||
|
||||
return players;
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user