mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-11-22 10:36:10 +01:00
Extra sanity checks in shop trait
This commit is contained in:
parent
7f9b4c629c
commit
00eef79dc9
@ -1000,11 +1000,15 @@ public class ShopTrait extends Trait {
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onInventoryClick(InventoryClickEvent evt) {
|
public void onInventoryClick(InventoryClickEvent evt) {
|
||||||
if (!evt.getView().equals(view))
|
if (!evt.getView().equals(view) || evt.getSlotType() != SlotType.RESULT)
|
||||||
return;
|
|
||||||
if (evt.getSlotType() != SlotType.RESULT)
|
|
||||||
return;
|
return;
|
||||||
evt.setCancelled(true);
|
evt.setCancelled(true);
|
||||||
|
if (selectedTrade == -1)
|
||||||
|
return;
|
||||||
|
if (!trades.containsKey(selectedTrade)) {
|
||||||
|
Messaging.severe("Invalid trade selection", selectedTrade, "from", evt.getWhoClicked());
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (!evt.getAction().name().contains("PICKUP")
|
if (!evt.getAction().name().contains("PICKUP")
|
||||||
|| (evt.getCursor() != null && evt.getCursor().getType() != Material.AIR))
|
|| (evt.getCursor() != null && evt.getCursor().getType() != Material.AIR))
|
||||||
return;
|
return;
|
||||||
|
@ -192,6 +192,14 @@ public class ItemAction extends NPCShopAction {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void sanityCheck() {
|
||||||
|
if (metaFilter.size() > 0) {
|
||||||
|
for (ItemStack item : items) {
|
||||||
|
metaMatches(item, item, metaFilter);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private String stringify(ItemStack item) {
|
private String stringify(ItemStack item) {
|
||||||
if (SUPPORT_TRANSLATABLE) {
|
if (SUPPORT_TRANSLATABLE) {
|
||||||
return BukkitComponentSerializer.legacy().serialize(Component.text(item.getAmount() + " ")
|
return BukkitComponentSerializer.legacy().serialize(Component.text(item.getAmount() + " ")
|
||||||
@ -311,6 +319,7 @@ public class ItemAction extends NPCShopAction {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
base.items = items;
|
base.items = items;
|
||||||
|
base.sanityCheck();
|
||||||
callback.accept(items.isEmpty() ? null : base);
|
callback.accept(items.isEmpty() ? null : base);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user