mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2025-01-23 23:32:58 +08:00
Fix StackOverFlow when execute /give all (#1878)
* Fix StackOverFlow when execute /give all * Use more proper code
This commit is contained in:
parent
c5d30c44eb
commit
be8fbcbc02
@ -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);
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user