| 37 | import java.util.Set; |
| 38 | |
| 39 | public class UIWindow implements Window, Listener { |
| 40 | private final Player viewer; |
| 41 | private final Map<Integer, Element> elements; |
| 42 | private WindowDecorator decorator; |
| 43 | private Callback<Window> eClose; |
| 44 | private WindowResolution resolution; |
| 45 | private String title; |
| 46 | private boolean visible; |
| 47 | private int viewportPosition; |
| 48 | private int viewportSize; |
| 49 | private int highestRow; |
| 50 | private String tag; |
| 51 | private Inventory inventory; |
| 52 | private int clickcheck; |
| 53 | private boolean doubleclicked; |
| 54 | |
| 55 | public UIWindow(Player viewer) { |
| 56 | clickcheck = 0; |
| 57 | doubleclicked = false; |
| 58 | this.viewer = viewer; |
| 59 | this.elements = new HashMap<>(); |
| 60 | setTitle(""); |
| 61 | setDecorator(new UIVoidDecorator()); |
| 62 | setResolution(WindowResolution.W9_H6); |
| 63 | setViewportHeight(clip(3, 1, getResolution().getMaxHeight()).intValue()); |
| 64 | setViewportPosition(0); |
| 65 | } |
| 66 | |
| 67 | @EventHandler(priority = EventPriority.HIGHEST) |
| 68 | public void on(InventoryClickEvent e) { |
| 69 | if (!e.getWhoClicked().equals(viewer)) { |
| 70 | return; |
| 71 | } |
| 72 | |
| 73 | if (!isVisible()) { |
| 74 | return; |
| 75 | } |
| 76 | |
| 77 | // 1.14 bukkit api change, removed getTitle() and getName() from Inventory.class |
| 78 | if (!viewer.getOpenInventory().getTitle().equals(title)) { |
| 79 | return; |
| 80 | } |
| 81 | |
| 82 | if (e.getClickedInventory() == null) { |
| 83 | return; |
| 84 | } |
| 85 | |
| 86 | if (!e.getView().getType().equals(getResolution().getType())) { |
| 87 | return; |
| 88 | } |
| 89 | |
| 90 | if (e.getClickedInventory().getType().equals(getResolution().getType())) { |
| 91 | Element element = getElement(getLayoutPosition(e.getSlot()), getLayoutRow(e.getSlot())); |
| 92 | |
| 93 | switch (e.getAction()) { |
| 94 | case CLONE_STACK: |
| 95 | case COLLECT_TO_CURSOR: |
| 96 | case DROP_ALL_CURSOR: |
nothing calls this directly
no outgoing calls
no test coverage detected