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
e1c0b4a9
Commit
e1c0b4a9
authored
Apr 28, 2022
by
yangjiahao
Committed by
memetrollsXD
Apr 29, 2022
Browse files
改进了clear命令的逻辑,使他在不输入uid时默认为当前玩家。
parent
352801b8
Changes
1
Show whitespace changes
Inline
Side-by-side
src/main/java/emu/grasscutter/command/commands/ClearCommand.java
View file @
e1c0b4a9
...
...
@@ -18,19 +18,21 @@ public final class ClearCommand implements CommandHandler {
@Override
public
void
execute
(
Player
sender
,
List
<
String
>
args
)
{
int
target
;
String
cmdSwitch
=
""
;
if
(
sender
==
null
)
{
CommandHandler
.
sendMessage
(
null
,
"Run this command in-game."
);
return
;
}
String
cmdSwitch
=
args
.
get
(
1
);
Inventory
playerInventory
=
sender
.
getInventory
();
try
{
if
(
args
.
size
()
==
1
)
{
cmdSwitch
=
args
.
get
(
0
);
target
=
sender
.
getUid
();
}
else
{
cmdSwitch
=
args
.
get
(
1
);
target
=
Integer
.
parseInt
(
args
.
get
(
0
));
}
Player
targetPlayer
=
Grasscutter
.
getGameServer
().
getPlayerByUid
(
target
);
if
(
targetPlayer
==
null
)
{
target
=
sender
.
getUid
();
}
else
{
switch
(
cmdSwitch
)
{
case
"wp"
->
{
playerInventory
.
getItems
().
values
().
stream
()
...
...
@@ -61,31 +63,36 @@ public final class ClearCommand implements CommandHandler {
.
filter
(
item1
->
item1
.
getLevel
()
==
1
&&
item1
.
getExp
()
==
0
)
.
filter
(
item1
->
!
item1
.
isLocked
()
&&
!
item1
.
isEquipped
())
.
forEach
(
item1
->
playerInventory
.
removeItem
(
item1
,
item1
.
getCount
()));
sender
.
dropMessage
(
"Cleared artifacts for "
+
targetPlayer
.
getNickname
()
+
" ."
);
playerInventory
.
getItems
().
values
().
stream
()
.
filter
(
item2
->
item2
.
getItemType
()
==
ItemType
.
ITEM_MATERIAL
)
.
filter
(
item2
->
!
item2
.
isLocked
()
&&
!
item2
.
isEquipped
())
.
forEach
(
item2
->
playerInventory
.
removeItem
(
item2
,
item2
.
getCount
()));
sender
.
dropMessage
(
"Cleared materials for "
+
targetPlayer
.
getNickname
()
+
" ."
);
playerInventory
.
getItems
().
values
().
stream
()
.
filter
(
item3
->
item3
.
getItemType
()
==
ItemType
.
ITEM_WEAPON
)
.
filter
(
item3
->
item3
.
getLevel
()
==
1
&&
item3
.
getExp
()
==
0
)
.
filter
(
item3
->
!
item3
.
isLocked
()
&&
!
item3
.
isEquipped
())
.
forEach
(
item3
->
playerInventory
.
removeItem
(
item3
,
item3
.
getCount
()));
sender
.
dropMessage
(
"Cleared weapons for "
+
targetPlayer
.
getNickname
()
+
" ."
);
playerInventory
.
getItems
().
values
().
stream
()
.
filter
(
item4
->
item4
.
getItemType
()
==
ItemType
.
ITEM_FURNITURE
)
.
filter
(
item4
->
!
item4
.
isLocked
()
&&
!
item4
.
isEquipped
())
.
forEach
(
item4
->
playerInventory
.
removeItem
(
item4
,
item4
.
getCount
()));
sender
.
dropMessage
(
"Cleared furniture for "
+
targetPlayer
.
getNickname
()
+
" ."
);
playerInventory
.
getItems
().
values
().
stream
()
.
filter
(
item5
->
item5
.
getItemType
()
==
ItemType
.
ITEM_DISPLAY
)
.
filter
(
item5
->
!
item5
.
isLocked
()
&&
!
item5
.
isEquipped
())
.
forEach
(
item5
->
playerInventory
.
removeItem
(
item5
,
item5
.
getCount
()));
sender
.
dropMessage
(
"Cleared displays for "
+
targetPlayer
.
getNickname
()
+
" ."
);
playerInventory
.
getItems
().
values
().
stream
()
.
filter
(
item6
->
item6
.
getItemType
()
==
ItemType
.
ITEM_VIRTUAL
)
.
filter
(
item6
->
!
item6
.
isLocked
()
&&
!
item6
.
isEquipped
())
.
forEach
(
item6
->
playerInventory
.
removeItem
(
item6
,
item6
.
getCount
()));
sender
.
dropMessage
(
"Cleared virtuals for "
+
targetPlayer
.
getNickname
()
+
" ."
);
sender
.
dropMessage
(
"Cleared everything for "
+
targetPlayer
.
getNickname
()
+
" ."
);
}
}
}
}
catch
(
NumberFormatException
ignored
)
{
// TODO: Parse from item name using GM Handbook.
CommandHandler
.
sendMessage
(
sender
,
"Invalid playerId."
);
...
...
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