mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2025-12-15 08:25:21 +01:00
Add more events
This commit is contained in:
41
src/main/java/emu/grasscutter/plugin/api/ServerHook.java
Normal file
41
src/main/java/emu/grasscutter/plugin/api/ServerHook.java
Normal file
@@ -0,0 +1,41 @@
|
||||
package emu.grasscutter.plugin.api;
|
||||
|
||||
import emu.grasscutter.game.GenshinPlayer;
|
||||
import emu.grasscutter.server.game.GameServer;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Hooks into the {@link GameServer} class, adding convenient ways to do certain things.
|
||||
*/
|
||||
public final class ServerHook {
|
||||
private static ServerHook instance;
|
||||
private final GameServer server;
|
||||
|
||||
/**
|
||||
* Gets the server hook instance.
|
||||
* @return A {@link ServerHook} singleton.
|
||||
*/
|
||||
public static ServerHook getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Hooks into a server.
|
||||
* @param server The server to hook into.
|
||||
*/
|
||||
public ServerHook(GameServer server) {
|
||||
this.server = server;
|
||||
|
||||
instance = this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets all online players.
|
||||
* @return Players connected to the server.
|
||||
*/
|
||||
public List<GenshinPlayer> getOnlinePlayers() {
|
||||
return new LinkedList<>(this.server.getPlayers().values());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user