本文整理汇总了Java中org.bukkit.event.inventory.InventoryClickEvent.isCancelled方法的典型用法代码示例。如果您正苦于以下问题:Java InventoryClickEvent.isCancelled方法的具体用法?Java InventoryClickEvent.isCancelled怎么用?Java InventoryClickEvent.isCancelled使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.event.inventory.InventoryClickEvent
的用法示例。
在下文中一共展示了InventoryClickEvent.isCancelled方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onRepair
import org.bukkit.event.inventory.InventoryClickEvent; //导入方法依赖的package包/类
@EventHandler
public void onRepair(InventoryClickEvent event) {
if(event.isCancelled() || !(event.getWhoClicked() instanceof Player) || !(event.getInventory() instanceof AnvilInventory))
return;
InventoryView view = event.getView();
int rawSlot = event.getRawSlot();
if(rawSlot != view.convertSlot(rawSlot) || rawSlot != 2)
return;
ItemStack item = event.getInventory().getItem(0);
if(!plugin.getAbilityManager().hasAbility(item) || !plugin.getAbilityManager().isTemporaryItem(item))
return;
Ability ability = plugin.getAbilityManager().getAbility(item);
event.getInventory().setItem(0, plugin.getAbilityManager().removeItemLore(item, ability));
event.setCancelled(true);
}
示例2: inventoryClickEvent
import org.bukkit.event.inventory.InventoryClickEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGH)
public void inventoryClickEvent(final InventoryClickEvent event) {
if (!event.isCancelled()) {
if ( PermissionInterface.CheckEnabledWorld(event.getWhoClicked().getLocation()) ) {
if ((event.getInventory().getType() == InventoryType.DISPENSER) && (event.getRawSlot() == 4) && ((event.getCurrentItem().getTypeId() == 388) || (event.getCursor().getTypeId() == 388))) {
event.setCancelled(true);
}
}
}
}
示例3: onClick
import org.bukkit.event.inventory.InventoryClickEvent; //导入方法依赖的package包/类
@EventHandler
public void onClick(InventoryClickEvent e) {
if (e.isCancelled())
return;
if (!(e.getWhoClicked() instanceof Player)) {
return;
}
if (!Utils.isInArena((Player) e.getWhoClicked())) {
return;
}
if (e.getClickedInventory() == null) {
return;
}
e.setCancelled(true);
}
示例4: onClick
import org.bukkit.event.inventory.InventoryClickEvent; //导入方法依赖的package包/类
public boolean onClick(VPPlayer clicker, int slot, Long coolDownUntil, MenuLink ml,
InventoryClickEvent event) {
Icon icon = this.getIcon(clicker, slot);
if (icon != null) {
event.setCancelled(!icon.canMove(clicker));
long now = System.currentTimeMillis();
if (coolDownUntil == null || coolDownUntil < now) {
if(icon.closeOnClick())
clicker.getPlayer().closeInventory();
if(icon.onClick(clicker, event.getClick(), ml)){
return true;
}
}
}
if(!event.isCancelled()) {
if(event.getClick() == ClickType.DOUBLE_CLICK || event.getClick() == ClickType.SHIFT_LEFT || event.getClick() == ClickType.SHIFT_RIGHT || event.getClick() == ClickType.NUMBER_KEY) {
ItemStack item = event.getCurrentItem();
if(item != null && item.getType() != Material.AIR && MinecraftUtils.getExtra(item, Icon.FREEZE).equals("1"))
event.setCancelled(true);
else if(event.getClick() == ClickType.NUMBER_KEY){
item = event.getWhoClicked().getInventory().getItem(event.getHotbarButton());
if(item != null && item.getType() != Material.AIR && MinecraftUtils.getExtra(item, Icon.FREEZE).equals("1"))
event.setCancelled(true);
}
}
}
return false;
}
示例5: onArmorSlotClick
import org.bukkit.event.inventory.InventoryClickEvent; //导入方法依赖的package包/类
/**
* It happens when player click on armor slot
*/
private void onArmorSlotClick(InventoryClickEvent event, PlayerWrapper playerWrapper, final Slot slot,
ItemStack cursor, ItemStack currentItem) {
final Player player = playerWrapper.getPlayer().getPlayer();
final Inventory inventory = event.getInventory();
final int rawSlot = event.getRawSlot();
InventoryAction action = event.getAction();
ActionType actionType = ActionType.getTypeOfAction(action);
if (InventoryManager.validateArmor(player, action, slot, cursor) && playerWrapper.getInventoryView() != null) {
// Event of equip armor
InventoryClickEvent fakeEvent = new InventoryClickEvent(playerWrapper.getInventoryView(),
InventoryType.SlotType.ARMOR, InventoryUtils.getArmorSlotId(slot), event.getClick(), action);
Bukkit.getPluginManager().callEvent(fakeEvent);
if (fakeEvent.isCancelled()) {
event.setCancelled(true);
return;
}
InventoryManager.updateArmor(player, inventory, slot, rawSlot, action, currentItem, cursor);
if (actionType == ActionType.GET) {
inventory.setItem(rawSlot, slot.getCup());
} else if (slot.isCup(currentItem)) {
player.setItemOnCursor(new ItemStack(Material.AIR));
}
player.updateInventory();
}
if (actionType == ActionType.DROP) {
new BukkitRunnable() {
@Override
public void run() {
inventory.setItem(rawSlot, slot.getCup());
player.updateInventory();
}
}.runTaskLater(RPGInventory.getInstance(), 1);
} else {
event.setCancelled(true);
}
}