Merge remote-tracking branch 'origin/master'

This commit is contained in:
GeorgH93 2021-11-27 14:46:47 +01:00
commit 757c31f9b2
No known key found for this signature in database
GPG Key ID: D1630D37F9E4B3C8

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2020 GeorgH93
* Copyright (C) 2021 GeorgH93
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -54,7 +54,7 @@ public void run()
if(plugin.isDisabled(player) != WorldBlacklistMode.None) return;
if(player.getInventory().firstEmpty() == -1 && player.hasPermission(Permissions.USE) && player.hasPermission(Permissions.FULL_PICKUP))
{
// Only check loaded backpacks (loading them would take to much time for a repeating task, the backpack will be loaded async soon enough)
// Only check loaded backpacks (loading them would take too much time for a repeating task, the backpack will be loaded async soon enough)
Backpack backpack = (Backpack) plugin.getBackpackCachedOnly(player);
if(backpack == null)
{
@ -68,12 +68,16 @@ public void run()
Item item = (Item) entity;
if(!item.isDead() && item.getPickupDelay() <= 0)
{
if(itemFilter != null && itemFilter.isItemBlocked(item.getItemStack())) continue;
Map<Integer, ItemStack> full = backpack.addItems(item.getItemStack());
backpack.setChanged();
if(!full.isEmpty())
Map<Integer, ItemStack> leftover = player.getInventory().addItem(item.getItemStack());
if(!leftover.isEmpty())
{
item.setItemStack(full.get(0));
ItemStack itemStack = leftover.get(0);
if(itemStack == null || itemStack.getAmount() == 0 || (itemFilter != null && itemFilter.isItemBlocked(itemStack))) continue;
leftover = backpack.addItems(itemStack);
}
if(!leftover.isEmpty())
{
item.setItemStack(leftover.get(0));
}
else
{