mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-08-14 23:57:35 +00:00
Cleanup adding/removing players
This commit is contained in:
parent
295d8d5256
commit
ba21acc9c8
4 changed files with 42 additions and 34 deletions
|
@ -29,6 +29,7 @@ import org.geysermc.api.command.CommandMap;
|
|||
import org.geysermc.api.logger.Logger;
|
||||
import org.geysermc.api.plugin.PluginManager;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
|
||||
public interface Connector {
|
||||
|
@ -61,6 +62,13 @@ public interface Connector {
|
|||
*/
|
||||
ScheduledExecutorService getGeneralThreadPool();
|
||||
|
||||
/**
|
||||
* Returns a collection of the connected players
|
||||
*
|
||||
* @return a collection of the connected players
|
||||
*/
|
||||
Collection<Player> getConnectedPlayers();
|
||||
|
||||
/**
|
||||
* Shuts down the connector
|
||||
*/
|
||||
|
|
|
@ -29,6 +29,7 @@ import org.geysermc.api.command.CommandMap;
|
|||
import org.geysermc.api.logger.Logger;
|
||||
import org.geysermc.api.plugin.PluginManager;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
@ -36,8 +37,6 @@ import java.util.UUID;
|
|||
import java.util.concurrent.ScheduledExecutorService;
|
||||
|
||||
public class Geyser {
|
||||
private static final Map<Object, Player> players = new HashMap<>();
|
||||
|
||||
|
||||
private static Connector connector;
|
||||
|
||||
|
@ -94,23 +93,15 @@ public class Geyser {
|
|||
* @return the amount of online players
|
||||
*/
|
||||
public static int getPlayerCount() {
|
||||
return players.size();
|
||||
return connector.getConnectedPlayers().size();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a player
|
||||
* @param p The player to add
|
||||
* Returns a collection of the connected players
|
||||
*
|
||||
* @return a collection of the connected players
|
||||
*/
|
||||
public static void addPlayer(Player p) {
|
||||
players.put(Objects.requireNonNull(Objects.requireNonNull(Objects.requireNonNull(p, "player").getAuthenticationData(), "authData").getUUID(), "player uuid"), p);
|
||||
players.put(Objects.requireNonNull(Objects.requireNonNull(Objects.requireNonNull(p, "player").getAuthenticationData(), "authData").getName(), "player name"), p);
|
||||
}
|
||||
|
||||
/**
|
||||
* Disconnect a player
|
||||
* @param p The player to remove/disconnect
|
||||
*/
|
||||
public static void removePlayer(Player p) {
|
||||
players.remove(Objects.requireNonNull(Objects.requireNonNull(Objects.requireNonNull(p, "player").getAuthenticationData(), "authData").getName(), "player name"));
|
||||
public static Collection<Player> getConnectedPlayers() {
|
||||
return connector.getConnectedPlayers();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue