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