Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
G
Grasscutter
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
ziqian zhang
Grasscutter
Commits
47d8fd3c
Commit
47d8fd3c
authored
3 years ago
by
KingRainbow44
Browse files
Options
Downloads
Patches
Plain Diff
Add `get` methods to the server hook
parent
d4f9820e
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/emu/grasscutter/plugin/api/ServerHook.java
+28
-0
28 additions, 0 deletions
src/main/java/emu/grasscutter/plugin/api/ServerHook.java
with
28 additions
and
0 deletions
src/main/java/emu/grasscutter/plugin/api/ServerHook.java
+
28
−
0
View file @
47d8fd3c
package
emu.grasscutter.plugin.api
;
package
emu.grasscutter.plugin.api
;
import
emu.grasscutter.command.Command
;
import
emu.grasscutter.command.CommandHandler
;
import
emu.grasscutter.game.GenshinPlayer
;
import
emu.grasscutter.game.GenshinPlayer
;
import
emu.grasscutter.server.dispatch.DispatchServer
;
import
emu.grasscutter.server.dispatch.DispatchServer
;
import
emu.grasscutter.server.game.GameServer
;
import
emu.grasscutter.server.game.GameServer
;
...
@@ -35,6 +37,20 @@ public final class ServerHook {
...
@@ -35,6 +37,20 @@ public final class ServerHook {
instance
=
this
;
instance
=
this
;
}
}
/**
* @return The game server.
*/
public
GameServer
getGameServer
()
{
return
this
.
gameServer
;
}
/**
* @return The dispatch server.
*/
public
DispatchServer
getDispatchServer
()
{
return
this
.
dispatchServer
;
}
/**
/**
* Gets all online players.
* Gets all online players.
* @return Players connected to the server.
* @return Players connected to the server.
...
@@ -42,4 +58,16 @@ public final class ServerHook {
...
@@ -42,4 +58,16 @@ public final class ServerHook {
public
List
<
GenshinPlayer
>
getOnlinePlayers
()
{
public
List
<
GenshinPlayer
>
getOnlinePlayers
()
{
return
new
LinkedList
<>(
this
.
gameServer
.
getPlayers
().
values
());
return
new
LinkedList
<>(
this
.
gameServer
.
getPlayers
().
values
());
}
}
/**
* Registers a command to the {@link emu.grasscutter.command.CommandMap}.
* @param handler The command handler.
*/
public
void
registerCommand
(
CommandHandler
handler
)
{
Class
<?
extends
CommandHandler
>
clazz
=
handler
.
getClass
();
if
(!
clazz
.
isAnnotationPresent
(
Command
.
class
))
throw
new
IllegalArgumentException
(
"Command handler must be annotated with @Command."
);
Command
commandData
=
clazz
.
getAnnotation
(
Command
.
class
);
this
.
gameServer
.
getCommandMap
().
registerCommand
(
commandData
.
label
(),
handler
);
}
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment