mirror of
https://github.com/Melledy/Grasscutter.git
synced 2024-11-25 13:01:03 +00:00
Little update to item giving handling (#2363)
* Little update to HandlerItemGivingReq.java GIVING_METHOD_GROUP is used in cooking girl's quest * Send the giving packet at the start of relogs, even if encountered before. * Make item checking not exact You can have more items in your inventory than what you are submitting.
This commit is contained in:
parent
2b64814534
commit
f955bb1e16
@ -216,14 +216,14 @@ public class Inventory extends BasePlayerManager implements Iterable<GameItem> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks to see if the player has the item in their inventory. This is exact.
|
||||
* Checks to see if the player has the item in their inventory. This is not exact.
|
||||
*
|
||||
* @param items A map of item game IDs to their count.
|
||||
* @return True if the player has the items, false otherwise.
|
||||
*/
|
||||
public boolean hasAllItems(Collection<ItemParam> items) {
|
||||
for (var item : items) {
|
||||
if (!this.hasItem(item.getItemId(), item.getCount(), true)) return false;
|
||||
if (!this.hasItem(item.getItemId(), item.getCount(), false)) return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -101,21 +101,16 @@ public final class QuestManager extends BasePlayerManager {
|
||||
* Attempts to add the giving action.
|
||||
*
|
||||
* @param givingId The giving action ID.
|
||||
* @throws IllegalStateException If the giving action is already active.
|
||||
*/
|
||||
public void addGiveItemAction(int givingId) throws IllegalStateException {
|
||||
var progress = this.player.getPlayerProgress();
|
||||
var givings = progress.getItemGivings();
|
||||
|
||||
// Check if the action is already present.
|
||||
if (givings.containsKey(givingId)) {
|
||||
throw new IllegalStateException("Giving action " + givingId + " is already active.");
|
||||
}
|
||||
|
||||
// Add the action.
|
||||
// Check if the action is not present.
|
||||
if (!givings.containsKey(givingId)) {
|
||||
givings.put(givingId, ItemGiveRecord.resolve(givingId));
|
||||
// Save the givings.
|
||||
player.save();
|
||||
}
|
||||
|
||||
this.sendGivingRecords();
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ public final class HandlerItemGivingReq extends PacketHandler {
|
||||
questManager.queueEvent(QuestContent.QUEST_CONTENT_FINISH_ITEM_GIVING, giveId, 0);
|
||||
questManager.queueEvent(QuestCond.QUEST_COND_ITEM_GIVING_FINISHED, giveId, 0);
|
||||
}
|
||||
case GIVING_METHOD_VAGUE_GROUP -> {
|
||||
case GIVING_METHOD_VAGUE_GROUP, GIVING_METHOD_GROUP -> {
|
||||
var matchedGroups = new ArrayList<Integer>();
|
||||
var givenItems = new HashMap<Integer, Integer>();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user