本文整理汇总了Java中org.bukkit.event.inventory.InventoryInteractEvent类的典型用法代码示例。如果您正苦于以下问题:Java InventoryInteractEvent类的具体用法?Java InventoryInteractEvent怎么用?Java InventoryInteractEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
InventoryInteractEvent类属于org.bukkit.event.inventory包,在下文中一共展示了InventoryInteractEvent类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onInventoryMoveItem
import org.bukkit.event.inventory.InventoryInteractEvent; //导入依赖的package包/类
@EventHandler
public void onInventoryMoveItem(InventoryInteractEvent event) {
//System.out.println("E");
if (openchests.containsKey(event.getInventory())) {
System.out.println("move");
openchests.get(event.getInventory()).getInventory().setContents(event.getInventory().getContents());
openchests.remove(event.getInventory());
} else {
for (int i = 0; i < openchests.size(); i++) {
Chest c = ((List<Chest>) openchests.values()).get(i);
if (c.getInventory().equals(event.getInventory())) {
((List<Inventory>) openchests.keySet()).get(i).setContents(event.getInventory().getContents());
}
}
}
}
示例2: BasicMenu
import org.bukkit.event.inventory.InventoryInteractEvent; //导入依赖的package包/类
public BasicMenu(final Minigame minigame, int rows, String title, final EventListener<InventoryClickEvent> onClick) {
Validate.notNull(minigame, "Minigame cannot be null");
Validate.isTrue(rows >= 1 && rows <= 9, "Rows must be an integer between 1-9, inclusive");
this.size = rows * 9;
if (title == null)
title = "";
this.inv = Bukkit.createInventory(null, size, title);
if (onClick != null) {
minigame.listenEvent(new EventListener<InventoryInteractEvent>() {
@Override
public void onEvent(InventoryInteractEvent event) {
HumanEntity human = event.getWhoClicked();
if (!(human instanceof Player) || !minigame.isPlaying(((Player) human)))
return;
if (!(event instanceof InventoryClickEvent)) {
event.setCancelled(true);
return;
}
InventoryClickEvent e = (InventoryClickEvent) event;
if (inv.equals(e.getClickedInventory()))
onClick.onEvent(e);
}
});
}
}
示例3: onInteract
import org.bukkit.event.inventory.InventoryInteractEvent; //导入依赖的package包/类
@EventHandler
public void onInteract(InventoryInteractEvent e) {
if(GUIWindow.windows.containsKey(e.getInventory().getTitle())){
e.setResult(Event.Result.DENY);
e.setCancelled(true);
}
}
示例4: onInventoryInteract
import org.bukkit.event.inventory.InventoryInteractEvent; //导入依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
public void onInventoryInteract(InventoryInteractEvent e) {
Player player = (Player) e.getWhoClicked();
if (plugin.pm.isGhost(player)) {
e.setCancelled(true);
player.closeInventory();
}
}
示例5: onInventoryInteract
import org.bukkit.event.inventory.InventoryInteractEvent; //导入依赖的package包/类
@EventHandler
public void onInventoryInteract(InventoryInteractEvent event) {
Player clicker = (Player) event.getWhoClicked();
Inventory view = event.getInventory();
if ((view.equals(clicker))) {
event.setCancelled(true);
}
}
示例6: onInventoryInteract
import org.bukkit.event.inventory.InventoryInteractEvent; //导入依赖的package包/类
@EventHandler
public void onInventoryInteract(InventoryInteractEvent event)
{
if (!event.getWhoClicked().isOp())
event.setCancelled(true);
}
示例7: PagedMenu
import org.bukkit.event.inventory.InventoryInteractEvent; //导入依赖的package包/类
public PagedMenu(final MinigameShell minigame, int pageRows, int pages, String title, final ItemStack backItem, final ItemStack nextItem, final EventListener<InventoryClickEvent> onClick) {
Validate.notNull(minigame, "Minigame cannot be null");
Validate.isTrue(pageRows > 0 && pageRows <= 9, "There must be between 1-9 rows, inclusive, per page");
Validate.isTrue(pages > 0, "There must be at least 1 page");
if (title == null)
title = "";
Validate.notNull(backItem, "The \"back\" item cannot be null");
Validate.notNull(nextItem, "The \"next\" item cannot be null");
this.invs = new Inventory[pages];
this.backItem = backItem;
this.nextItem = nextItem;
this.shell = minigame;
for (int i = 0; i < pages; i++)
this.invs[i] = Bukkit.createInventory(null, pageRows * 9, String.format(title, i + 1));
if (onClick != null) {
EventListener<InventoryInteractEvent> listener = new EventListener<InventoryInteractEvent>() {
@Override
public void onEvent(InventoryInteractEvent event) {
HumanEntity human = event.getWhoClicked();
if (minigame != null && minigame instanceof Minigame)
if (!(human instanceof Player) || !((Minigame) minigame).isPlaying(((Player) human)))
return;
if (!(event instanceof InventoryClickEvent)) {
event.setCancelled(true);
return;
}
InventoryClickEvent e = (InventoryClickEvent) event;
for (int i = 0; i < invs.length; i++) {
if (invs[i].equals(e.getClickedInventory())) {
ItemStack item = e.getCurrentItem();
Player player = (Player) human;
if (backItem.equals(item))
player.openInventory(invs[i - 1]);
else if (nextItem.equals(item))
player.openInventory(invs[i + 1]);
else
onClick.onEvent(e);
}
}
}
};
// if we have a minigame instance, lets create the menu listeners based off of it
if (minigame instanceof Minigame)
((Minigame) minigame).listenEvent(listener);
else
// otherwise, we can use a generic empty shell (warning: persists until plugin deactivates!!!!!)
MinigameManager.getMinigameManager().addListener(shell, InventoryInteractEvent.class, listener);
}
}
示例8: onInventoryInteract
import org.bukkit.event.inventory.InventoryInteractEvent; //导入依赖的package包/类
@EventHandler
public void onInventoryInteract(InventoryInteractEvent event) {
if (event.getInventory().getHolder() instanceof Block) {
processEvent(event, (Player) event.getWhoClicked());
}
}
示例9: onInventoryAction
import org.bukkit.event.inventory.InventoryInteractEvent; //导入依赖的package包/类
@EventHandler
public void onInventoryAction(final InventoryInteractEvent event) {
if (event.getInventory().getHolder() instanceof InfoInventory) {
event.setResult(Event.Result.DENY);
}
}
示例10: onInventoryInteract
import org.bukkit.event.inventory.InventoryInteractEvent; //导入依赖的package包/类
public void onInventoryInteract(InventoryInteractEvent event) {
event.setCancelled(true);
}
示例11: eventTrigger
import org.bukkit.event.inventory.InventoryInteractEvent; //导入依赖的package包/类
@Override
public void eventTrigger(Event event) {
if(event.getEventName().equalsIgnoreCase("playerjoinevent")){
eh.onPlayerJoin((PlayerJoinEvent)event);
}
else if(event.getEventName().equalsIgnoreCase("playerdropitemevent")){
eh.onPlayerDrop((PlayerDropItemEvent)event);
}
else if(event.getEventName().equalsIgnoreCase("playerinteractevent")){
eh.onPlayerInteract((PlayerInteractEvent)event);
}
else if(event.getEventName().equalsIgnoreCase("inventoryclickevent")){
eh.onInventoryClick((InventoryClickEvent)event);
}
else if(event.getEventName().equalsIgnoreCase("playertoggleflightevent")){
eh.onPlayerToggleFlight((PlayerToggleFlightEvent)event);
}
else if(event.getEventName().equalsIgnoreCase("playermoveevent")){
eh.onPlayerMove((PlayerMoveEvent)event);
}
else if(event.getEventName().equalsIgnoreCase("playerdropitemevent")){
eh.onPlayerDrop((PlayerDropItemEvent) event);
}
else if(event.getEventName().equalsIgnoreCase("playerinteractentityevent")){
eh.onPlayerInteractEntity((PlayerInteractEntityEvent) event);
}
else if(event.getEventName().equalsIgnoreCase("entitydamagebyentityevent")){
eh.onEntityDamageByEntity((EntityDamageByEntityEvent) event);
}
else if(event.getEventName().equalsIgnoreCase("playerquitevent")){
eh.onPlayerLeave((PlayerQuitEvent) event);
}
else if(event.getEventName().equalsIgnoreCase("foodlevelchangeevent")){
eh.onFoodLevelChange((FoodLevelChangeEvent) event);
}
else if(event.getEventName().equalsIgnoreCase("entitydamageevent")){
eh.onEntityDamage((EntityDamageEvent) event);
}
else if(event.getEventName().equalsIgnoreCase("weatherchangeevent")){
eh.onWeatherChange((WeatherChangeEvent) event);
}
else if(event.getEventName().equalsIgnoreCase("inventoryinteractevent")){
eh.onInventoryInteract((InventoryInteractEvent) event);
}
else if(event.getEventName().equalsIgnoreCase("worldloadevent")){
eh.onWorldLoad((WorldLoadEvent) event);
}
}
示例12: onInteract
import org.bukkit.event.inventory.InventoryInteractEvent; //导入依赖的package包/类
public void onInteract(InventoryInteractEvent e) {
if (e.getWhoClicked() instanceof Player) {
e.getWhoClicked().getLocation().getWorld().getName();
}
}