Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
ziqian zhang
Grasscutter
Commits
a62520f9
Commit
a62520f9
authored
Apr 30, 2022
by
Magix
Committed by
GitHub
Apr 30, 2022
Browse files
Merge pull request #381 from Coooookies/development
Show the player's UID with the `/list` command
parents
c442039f
8ce79ed3
Changes
1
Show whitespace changes
Inline
Side-by-side
src/main/java/emu/grasscutter/command/commands/ListCommand.java
View file @
a62520f9
...
@@ -8,19 +8,42 @@ import emu.grasscutter.game.player.Player;
...
@@ -8,19 +8,42 @@ import emu.grasscutter.game.player.Player;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
@Command
(
label
=
"list"
,
description
=
"List online players"
)
@Command
(
label
=
"list"
,
usage
=
"list [uid]"
,
description
=
"List online players"
,
aliases
=
{
"players"
})
public
final
class
ListCommand
implements
CommandHandler
{
public
final
class
ListCommand
implements
CommandHandler
{
@Override
@Override
public
void
execute
(
Player
sender
,
List
<
String
>
args
)
{
public
void
execute
(
Player
sender
,
List
<
String
>
args
)
{
Map
<
Integer
,
Player
>
playersMap
=
Grasscutter
.
getGameServer
().
getPlayers
();
Map
<
Integer
,
Player
>
playersMap
=
Grasscutter
.
getGameServer
().
getPlayers
();
boolean
needUID
=
false
;
if
(
args
.
size
()
>
0
)
{
needUID
=
args
.
get
(
0
).
equals
(
"uid"
);
}
CommandHandler
.
sendMessage
(
sender
,
String
.
format
(
"There are %s player(s) online:"
,
playersMap
.
size
()));
CommandHandler
.
sendMessage
(
sender
,
String
.
format
(
"There are %s player(s) online:"
,
playersMap
.
size
()));
if
(
playersMap
.
size
()
!=
0
)
{
if
(
playersMap
.
size
()
!=
0
)
{
StringBuilder
playerSet
=
new
StringBuilder
();
StringBuilder
playerSet
=
new
StringBuilder
();
playersMap
.
values
().
forEach
(
player
->
boolean
finalNeedUID
=
needUID
;
playerSet
.
append
(
player
.
getNickname
()).
append
(
", "
));
playersMap
.
values
().
forEach
(
player
->
{
playerSet
.
append
(
player
.
getNickname
());
if
(
finalNeedUID
)
{
if
(
sender
!=
null
)
{
playerSet
.
append
(
" <color=green>("
)
.
append
(
player
.
getUid
())
.
append
(
")</color>"
);
}
else
{
playerSet
.
append
(
" ("
)
.
append
(
player
.
getUid
())
.
append
(
")"
);
}
}
playerSet
.
append
(
", "
);
});
String
players
=
playerSet
.
toString
();
String
players
=
playerSet
.
toString
();
CommandHandler
.
sendMessage
(
sender
,
players
.
substring
(
0
,
players
.
length
()
-
2
));
CommandHandler
.
sendMessage
(
sender
,
players
.
substring
(
0
,
players
.
length
()
-
2
));
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment