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
c926fe32
Commit
c926fe32
authored
Nov 03, 2022
by
AnimeGitB
Browse files
Refactor command kwarg parsing
parent
e8930e92
Changes
1
Show whitespace changes
Inline
Side-by-side
src/main/java/emu/grasscutter/command/CommandHelpers.java
View file @
c926fe32
...
@@ -33,21 +33,18 @@ public class CommandHelpers {
...
@@ -33,21 +33,18 @@ public class CommandHelpers {
}
}
public
static
<
T
>
List
<
String
>
parseIntParameters
(
List
<
String
>
args
,
@Nonnull
T
params
,
Map
<
Pattern
,
BiConsumer
<
T
,
Integer
>>
map
)
{
public
static
<
T
>
List
<
String
>
parseIntParameters
(
List
<
String
>
args
,
@Nonnull
T
params
,
Map
<
Pattern
,
BiConsumer
<
T
,
Integer
>>
map
)
{
for
(
int
i
=
args
.
size
()
-
1
;
i
>=
0
;
i
--)
{
args
.
removeIf
(
arg
->
{
String
arg
=
arg
s
.
get
(
i
)
.
toLowerCase
();
var
arg
L
=
arg
.
toLowerCase
();
boolean
deleteArg
=
false
;
boolean
deleteArg
=
false
;
int
argNum
;
for
(
var
entry
:
map
.
entrySet
())
{
for
(
var
entry
:
map
.
entrySet
())
{
if
((
argNum
=
matchIntOrNeg
(
entry
.
getKey
(),
arg
))
!=
-
1
)
{
int
argNum
=
matchIntOrNeg
(
entry
.
getKey
(),
argL
);
if
(
argNum
!=
-
1
)
{
entry
.
getValue
().
accept
(
params
,
argNum
);
entry
.
getValue
().
accept
(
params
,
argNum
);
deleteArg
=
true
;
deleteArg
=
true
;
break
;
}
}
if
(
deleteArg
)
{
args
.
remove
(
i
);
}
}
}
}
return
deleteArg
;
});
return
args
;
return
args
;
}
}
}
}
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