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
dd10dcc0
Commit
dd10dcc0
authored
Aug 25, 2022
by
AnimeGitB
Browse files
Fix HelpCommand missing aliases
parent
466488ca
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/main/java/emu/grasscutter/command/CommandMap.java
View file @
dd10dcc0
...
...
@@ -83,7 +83,7 @@ public final class CommandMap {
return
new
LinkedList
<>(
this
.
annotations
.
values
());
}
public
Hash
Map
<
String
,
Command
>
getAnnotations
()
{
public
Map
<
String
,
Command
>
getAnnotations
()
{
return
new
LinkedHashMap
<>(
this
.
annotations
);
}
...
...
@@ -96,8 +96,8 @@ public final class CommandMap {
return
new
LinkedList
<>(
this
.
commands
.
values
());
}
public
Hash
Map
<
String
,
CommandHandler
>
getHandlers
()
{
return
new
LinkedHashMap
<>(
this
.
commands
)
;
public
Map
<
String
,
CommandHandler
>
getHandlers
()
{
return
this
.
commands
;
}
/**
...
...
src/main/java/emu/grasscutter/command/commands/HelpCommand.java
View file @
dd10dcc0
...
...
@@ -46,25 +46,25 @@ public final class HelpCommand implements CommandHandler {
@Override
public
void
execute
(
Player
player
,
Player
targetPlayer
,
List
<
String
>
args
)
{
Account
account
=
(
player
==
null
)
?
null
:
player
.
getAccount
();
Map
<
String
,
CommandHandler
>
handlers
=
CommandMap
.
getInstance
()
.
getHandlers
()
;
var
commandMap
=
CommandMap
.
getInstance
();
List
<
String
>
commands
=
new
ArrayList
<>();
List
<
String
>
commands_no_permission
=
new
ArrayList
<>();
if
(
args
.
isEmpty
())
{
for
(
String
key
:
handlers
.
keySet
())
{
CommandHandler
command
=
handlers
.
get
(
key
);
commandMap
.
getHandlers
().
forEach
((
key
,
command
)
->
{
Command
annotation
=
command
.
getClass
().
getAnnotation
(
Command
.
class
);
if
(
player
==
null
||
account
.
hasPermission
(
annotation
.
permission
()))
{
commands
.
add
(
createCommand
(
player
,
command
,
args
));
}
else
if
(
SHOW_COMMANDS_WITHOUT_PERMISSIONS
)
{
commands_no_permission
.
add
(
createCommand
(
player
,
command
,
args
));
}
}
}
);
CommandHandler
.
sendTranslatedMessage
(
player
,
"commands.help.available_commands"
);
}
else
{
String
command_str
=
args
.
remove
(
0
).
toLowerCase
();
CommandHandler
command
=
handlers
.
get
(
command_str
);
CommandHandler
command
=
commandMap
.
getHandler
(
command_str
);
if
(
command
==
null
)
{
CommandHandler
.
sendTranslatedMessage
(
player
,
"commands.generic.command_exist_error"
);
CommandHandler
.
sendMessage
(
player
,
"Command: "
+
command_str
);
return
;
}
else
{
Command
annotation
=
command
.
getClass
().
getAnnotation
(
Command
.
class
);
...
...
@@ -75,9 +75,8 @@ public final class HelpCommand implements CommandHandler {
}
}
}
for
(
String
s
:
commands
)
CommandHandler
.
sendMessage
(
player
,
s
);
for
(
String
s
:
commands_no_permission
)
CommandHandler
.
sendMessage
(
player
,
s
+
"\n\t"
+
translate
(
player
,
"commands.help.warn_player_has_no_permission"
));
final
String
suf
=
"\n\t"
+
translate
(
player
,
"commands.help.warn_player_has_no_permission"
);
commands
.
forEach
(
s
->
CommandHandler
.
sendMessage
(
player
,
s
));
commands_no_permission
.
forEach
(
s
->
CommandHandler
.
sendMessage
(
player
,
s
+
suf
));
}
}
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