org.bukkit.event.inventory.InventoryInteractEvent Java Examples

The following examples show how to use org.bukkit.event.inventory.InventoryInteractEvent. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GuiActionHandler.java    From FunnyGuilds with Apache License 2.0 5 votes vote down vote up
@EventHandler
public void onInteract(final InventoryInteractEvent e) {
    if (GuiWindow.getWindow(e.getView().getTitle()) != null) {
        if (e.getInventory().getType().equals(InventoryType.CHEST)) {
            e.setResult(Event.Result.DENY);
        }
    }
}
 
Example #2
Source File: DragTypeReq.java    From black with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean control(final InventoryInteractEvent event) {
    if (event instanceof InventoryDragEvent) {
        return ((InventoryDragEvent) event).getType() == dragType;
    } else {
        return false;
    }
}
 
Example #3
Source File: SlotReq.java    From black with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean control(final InventoryInteractEvent event) {
    if (event instanceof InventoryClickEvent) {
        return ((InventoryClickEvent) event).getSlot() == slot;
    } else {
        return ((InventoryDragEvent) event).getInventorySlots().contains(slot);
    }
}
 
Example #4
Source File: AddedItemReq.java    From black with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean control(final InventoryInteractEvent event) {
    if (event instanceof InventoryDragEvent) {
        return ((InventoryDragEvent) event).getNewItems().values()
            .stream().anyMatch(this.item::equals);
    }
    return false;
}
 
Example #5
Source File: DraggedElementReq.java    From black with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean control(final InventoryInteractEvent event) {
    if (event instanceof InventoryClickEvent) {
        return false;
    } else {
        return element.is(((InventoryDragEvent) event).getCursor());
    }
}
 
Example #6
Source File: BasicPane.java    From black with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void accept(final InventoryInteractEvent event) {
    forEachSlot((y, x) -> {
        if (new SlotReq(locX + x + (locY + y) * 9).control(event)) {
            paneElements[y][x].accept(event);
        }
    });
}
 
Example #7
Source File: ClickedItemReq.java    From black with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean control(final InventoryInteractEvent event) {
    if (event instanceof InventoryClickEvent) {
        return ((InventoryClickEvent) event).getCurrentItem().equals(item);
    } else {
        return false;
    }
}
 
Example #8
Source File: HotbarButtonReq.java    From black with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean control(final InventoryInteractEvent event) {
    if (event instanceof InventoryClickEvent) {
        return ((InventoryClickEvent) event).getHotbarButton() == button;
    } else {
        return false;
    }
}
 
Example #9
Source File: OrReq.java    From black with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean control(final InventoryInteractEvent event) {
    for (final Requirement req : reqs) {
        if (req.control(event)) {
            return true;
        }
    }
    return false;
}
 
Example #10
Source File: ClickedCursorItemReq.java    From black with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean control(final InventoryInteractEvent event) {
    if (event instanceof InventoryClickEvent) {
        return ((InventoryClickEvent) event).getCursor().equals(item);
    } else {
        return false;
    }
}
 
Example #11
Source File: ClickTypeReq.java    From black with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean control(final InventoryInteractEvent event) {
    if (event instanceof InventoryClickEvent) {
        return ((InventoryClickEvent) event).getClick() == clickType;
    } else {
        return false;
    }
}
 
Example #12
Source File: ClickedCursorElementReq.java    From black with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean control(final InventoryInteractEvent event) {
    if (event instanceof InventoryClickEvent) {
        return element.is(((InventoryClickEvent) event).getCursor());
    } else {
        return false;
    }
}
 
Example #13
Source File: DraggedItemReq.java    From black with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean control(final InventoryInteractEvent event) {
    if (event instanceof InventoryClickEvent) {
        return false;
    } else {
        return ((InventoryDragEvent) event).getOldCursor().equals(item);
    }
}
 
Example #14
Source File: ClickedElementReq.java    From black with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean control(final InventoryInteractEvent event) {
    if (event instanceof InventoryClickEvent) {
        return element.is(((InventoryClickEvent) event).getCurrentItem());
    } else {
        return false;
    }
}
 
Example #15
Source File: AddedElementReq.java    From black with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean control(final InventoryInteractEvent event) {
    if (event instanceof InventoryDragEvent) {
        return ((InventoryDragEvent) event).getNewItems().values()
            .stream().anyMatch(element::is);
    }
    return false;
}
 
Example #16
Source File: DragTarget.java    From black with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void handle(final InventoryInteractEvent event) {
    if (event instanceof InventoryDragEvent &&
            Arrays.stream(reqs).allMatch(req -> req.control(event))) {

        handler.accept(new ElementDragEvent((InventoryDragEvent) event));
    }
}
 
Example #17
Source File: BasicElement.java    From black with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void accept(final InventoryInteractEvent event) {
    if (elementReq.control(event)) {
        for (final Target target : targets) {
            target.handle(event);
        }
    }
}
 
Example #18
Source File: BasicTarget.java    From black with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void handle(final InventoryInteractEvent event) {
    for (final Requirement req : reqs) {
        if (!req.control(event)) {
            return;
        }
    }
    handler.accept(new ElementBasicEvent(event));
}
 
Example #19
Source File: ClickTarget.java    From black with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void handle(final InventoryInteractEvent event) {
    if (event instanceof InventoryClickEvent &&
            Arrays.stream(reqs).allMatch(req -> req.control(event))) {

        handler.accept(new ElementClickEvent((InventoryClickEvent) event));
    }
}
 
Example #20
Source File: LivePane.java    From black with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void accept(final InventoryInteractEvent event) {
    for (final Pane frame : frames) {
        frame.accept(event);
    }
}
 
Example #21
Source File: TSafePane.java    From black with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void accept(final InventoryInteractEvent event) {
    basePane.accept(event);
}
 
Example #22
Source File: TSafePage.java    From black with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void accept(final InventoryInteractEvent event) {
    synchronized (basePage) {
        basePage.accept(event);
    }
}
 
Example #23
Source File: ChestPage.java    From black with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void accept(final InventoryInteractEvent event) {
    new ArrayList<>(panes).forEach(pane -> pane.accept(event));
}
 
Example #24
Source File: CloseInformerPage.java    From black with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void accept(final InventoryInteractEvent event) {
    basePage.accept(event);
}
 
Example #25
Source File: ClickReq.java    From black with GNU General Public License v3.0 4 votes vote down vote up
@Override
public boolean control(final InventoryInteractEvent event) {
    return event instanceof InventoryClickEvent;
}
 
Example #26
Source File: PlayerReq.java    From black with GNU General Public License v3.0 4 votes vote down vote up
@Override
public boolean control(final InventoryInteractEvent event) {
    return event.getWhoClicked().getUniqueId().equals(player.getUniqueId());
}
 
Example #27
Source File: CustomInventoryListener.java    From QuickShop-Reremake with GNU General Public License v3.0 4 votes vote down vote up
@EventHandler(ignoreCancelled = true)
public void invEvent(InventoryInteractEvent e) {
    if (e.getInventory().getHolder() instanceof QuickShopPreviewInventoryHolder) {
        e.setCancelled(true);
    }
}
 
Example #28
Source File: DragReq.java    From black with GNU General Public License v3.0 4 votes vote down vote up
@Override
public boolean control(final InventoryInteractEvent event) {
    return event instanceof InventoryDragEvent;
}
 
Example #29
Source File: TSafeElement.java    From black with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void accept(final InventoryInteractEvent event) {
    baseElement.accept(event);
}
 
Example #30
Source File: LiveElement.java    From black with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void accept(final InventoryInteractEvent event) {
    for (final Element frame : frames) {
        frame.accept(event);
    }
}