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
be8fbcbc
Unverified
Commit
be8fbcbc
authored
Oct 20, 2022
by
iTruth
Committed by
GitHub
Oct 20, 2022
Browse files
Fix StackOverFlow when execute /give all (#1878)
* Fix StackOverFlow when execute /give all * Use more proper code
parent
c5d30c44
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/main/java/emu/grasscutter/game/inventory/Inventory.java
View file @
be8fbcbc
...
...
@@ -140,7 +140,14 @@ public class Inventory extends BasePlayerManager implements Iterable<GameItem> {
List
<
GameItem
>
changedItems
=
new
ArrayList
<>();
for
(
var
item
:
items
)
{
if
(
item
.
getItemId
()
==
0
)
continue
;
GameItem
result
=
putItem
(
item
);
GameItem
result
=
null
;
try
{
// putItem might throws exception
// ignore that exception and continue
result
=
putItem
(
item
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
if
(
result
!=
null
)
{
getPlayer
().
getBattlePassManager
().
triggerMission
(
WatcherTriggerType
.
TRIGGER_OBTAIN_MATERIAL_NUM
,
result
.
getItemId
(),
result
.
getCount
());
changedItems
.
add
(
result
);
...
...
src/main/java/emu/grasscutter/game/props/ItemUseAction/ItemUseGainCostume.java
View file @
be8fbcbc
...
...
@@ -2,6 +2,8 @@ package emu.grasscutter.game.props.ItemUseAction;
import
emu.grasscutter.game.props.ItemUseOp
;
import
emu.grasscutter.data.GameData
;
public
class
ItemUseGainCostume
extends
ItemUseInt
{
@Override
public
ItemUseOp
getItemUseOp
()
{
...
...
@@ -14,7 +16,9 @@ public class ItemUseGainCostume extends ItemUseInt {
@Override
public
boolean
useItem
(
UseItemParams
params
)
{
params
.
player
.
getInventory
().
addItem
(
this
.
i
);
// TODO: Currently this returns false for all virtual items - need to have a proper success/fail
if
(
GameData
.
getAvatarCostumeDataMap
().
containsKey
(
this
.
i
))
{
params
.
player
.
addCostume
(
this
.
i
);
}
return
true
;
}
}
src/main/java/emu/grasscutter/game/props/ItemUseAction/ItemUseGainFlycloak.java
View file @
be8fbcbc
...
...
@@ -2,6 +2,8 @@ package emu.grasscutter.game.props.ItemUseAction;
import
emu.grasscutter.game.props.ItemUseOp
;
import
emu.grasscutter.data.GameData
;
public
class
ItemUseGainFlycloak
extends
ItemUseInt
{
@Override
public
ItemUseOp
getItemUseOp
()
{
...
...
@@ -14,7 +16,9 @@ public class ItemUseGainFlycloak extends ItemUseInt {
@Override
public
boolean
useItem
(
UseItemParams
params
)
{
params
.
player
.
getInventory
().
addItem
(
this
.
i
);
// TODO: Currently this returns false for all virtual items - need to have a proper success/fail
if
(
GameData
.
getAvatarFlycloakDataMap
().
containsKey
(
this
.
i
))
{
params
.
player
.
addFlycloak
(
this
.
i
);
}
return
true
;
}
}
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