mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-11-22 18:45:29 +01:00
ItemAction tweak
This commit is contained in:
parent
cd550e634e
commit
ad442e4bd3
@ -62,6 +62,8 @@ public class ItemAction extends NPCShopAction {
|
||||
if (tooDamaged(toMatch))
|
||||
continue;
|
||||
for (int j = 0; j < items.size(); j++) {
|
||||
if (toMatch == null)
|
||||
break;
|
||||
ItemStack item = items.get(j);
|
||||
if (req.get(j) <= 0 || !matches(item, toMatch))
|
||||
continue;
|
||||
@ -75,6 +77,7 @@ public class ItemAction extends NPCShopAction {
|
||||
source.setItem(i, res);
|
||||
}
|
||||
req.set(j, remaining - taken);
|
||||
toMatch = res;
|
||||
}
|
||||
}
|
||||
return req.stream().collect(Collectors.summingInt(n -> n)) <= 0;
|
||||
@ -97,14 +100,6 @@ public class ItemAction extends NPCShopAction {
|
||||
return description;
|
||||
}
|
||||
|
||||
private boolean tooDamaged(ItemStack toMatch) {
|
||||
if (!requireUndamaged)
|
||||
return false;
|
||||
if (SpigotUtil.isUsing1_13API())
|
||||
return toMatch.getItemMeta() instanceof Damageable && ((Damageable) toMatch.getItemMeta()).getDamage() != 0;
|
||||
return toMatch.getDurability() == toMatch.getType().getMaxDurability();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxRepeats(Entity entity) {
|
||||
if (!(entity instanceof InventoryHolder))
|
||||
@ -216,6 +211,14 @@ public class ItemAction extends NPCShopAction {
|
||||
});
|
||||
}
|
||||
|
||||
private boolean tooDamaged(ItemStack toMatch) {
|
||||
if (!requireUndamaged)
|
||||
return false;
|
||||
if (SpigotUtil.isUsing1_13API())
|
||||
return toMatch.getItemMeta() instanceof Damageable && ((Damageable) toMatch.getItemMeta()).getDamage() != 0;
|
||||
return toMatch.getDurability() == toMatch.getType().getMaxDurability();
|
||||
}
|
||||
|
||||
@Menu(title = "Item editor", dimensions = { 4, 9 })
|
||||
public static class ItemActionEditor extends InventoryMenuPage {
|
||||
private ItemAction base;
|
||||
|
Loading…
Reference in New Issue
Block a user