mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2025-01-10 04:32:53 +08:00
fix giveall doesn't give everything (#2210)
* fix giveall doesn't give everything * avoid unnecessary failure to add items by catching exception earlier * switch to use grasscutter logger * use debug()
This commit is contained in:
parent
47172c995f
commit
6b3f19e588
@ -133,13 +133,9 @@ public class Inventory extends BasePlayerManager implements Iterable<GameItem> {
|
|||||||
for (var item : items) {
|
for (var item : items) {
|
||||||
if (item.getItemId() == 0) continue;
|
if (item.getItemId() == 0) continue;
|
||||||
GameItem result = null;
|
GameItem result = null;
|
||||||
try {
|
|
||||||
// putItem might throw exception
|
|
||||||
// ignore that exception and continue
|
|
||||||
result = putItem(item);
|
result = putItem(item);
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
this.triggerAddItemEvents(result);
|
this.triggerAddItemEvents(result);
|
||||||
changedItems.add(result);
|
changedItems.add(result);
|
||||||
@ -155,6 +151,7 @@ public class Inventory extends BasePlayerManager implements Iterable<GameItem> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void triggerAddItemEvents(GameItem result) {
|
private void triggerAddItemEvents(GameItem result) {
|
||||||
|
try {
|
||||||
getPlayer()
|
getPlayer()
|
||||||
.getBattlePassManager()
|
.getBattlePassManager()
|
||||||
.triggerMission(
|
.triggerMission(
|
||||||
@ -162,15 +159,22 @@ public class Inventory extends BasePlayerManager implements Iterable<GameItem> {
|
|||||||
getPlayer()
|
getPlayer()
|
||||||
.getQuestManager()
|
.getQuestManager()
|
||||||
.queueEvent(QuestContent.QUEST_CONTENT_OBTAIN_ITEM, result.getItemId(), result.getCount());
|
.queueEvent(QuestContent.QUEST_CONTENT_OBTAIN_ITEM, result.getItemId(), result.getCount());
|
||||||
|
} catch (Exception e) {
|
||||||
|
Grasscutter.getLogger().debug("triggerAddItemEvents failed", e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void triggerRemItemEvents(GameItem item, int removeCount) {
|
private void triggerRemItemEvents(GameItem item, int removeCount) {
|
||||||
|
try {
|
||||||
getPlayer()
|
getPlayer()
|
||||||
.getBattlePassManager()
|
.getBattlePassManager()
|
||||||
.triggerMission(WatcherTriggerType.TRIGGER_COST_MATERIAL, item.getItemId(), removeCount);
|
.triggerMission(WatcherTriggerType.TRIGGER_COST_MATERIAL, item.getItemId(), removeCount);
|
||||||
getPlayer()
|
getPlayer()
|
||||||
.getQuestManager()
|
.getQuestManager()
|
||||||
.queueEvent(QuestContent.QUEST_CONTENT_ITEM_LESS_THAN, item.getItemId(), item.getCount());
|
.queueEvent(QuestContent.QUEST_CONTENT_ITEM_LESS_THAN, item.getItemId(), item.getCount());
|
||||||
|
} catch (Exception e) {
|
||||||
|
Grasscutter.getLogger().debug("triggerRemItemEvents failed", e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addItemParams(Collection<ItemParam> items) {
|
public void addItemParams(Collection<ItemParam> items) {
|
||||||
@ -193,8 +197,11 @@ public class Inventory extends BasePlayerManager implements Iterable<GameItem> {
|
|||||||
// Dont add items that dont have a valid item definition.
|
// Dont add items that dont have a valid item definition.
|
||||||
var data = item.getItemData();
|
var data = item.getItemData();
|
||||||
if (data == null) return null;
|
if (data == null) return null;
|
||||||
|
try {
|
||||||
this.player.getProgressManager().addItemObtainedHistory(item.getItemId(), item.getCount());
|
this.player.getProgressManager().addItemObtainedHistory(item.getItemId(), item.getCount());
|
||||||
|
} catch (Exception e) {
|
||||||
|
Grasscutter.getLogger().debug("addItemObtainedHistory failed", e);
|
||||||
|
}
|
||||||
|
|
||||||
if (data.isUseOnGain()) {
|
if (data.isUseOnGain()) {
|
||||||
var params = new UseItemParams(this.player, data.getUseTarget());
|
var params = new UseItemParams(this.player, data.getUseTarget());
|
||||||
|
Loading…
Reference in New Issue
Block a user