当前位置: 首页>>代码示例>>Java>>正文


Java InventoryMoveItemEvent.setCancelled方法代码示例

本文整理汇总了Java中org.bukkit.event.inventory.InventoryMoveItemEvent.setCancelled方法的典型用法代码示例。如果您正苦于以下问题:Java InventoryMoveItemEvent.setCancelled方法的具体用法?Java InventoryMoveItemEvent.setCancelled怎么用?Java InventoryMoveItemEvent.setCancelled使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.bukkit.event.inventory.InventoryMoveItemEvent的用法示例。


在下文中一共展示了InventoryMoveItemEvent.setCancelled方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onItemMove

import org.bukkit.event.inventory.InventoryMoveItemEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onItemMove(InventoryMoveItemEvent e) {
    if (config.hopper_protection) {
        if ((e.getSource().getType().equals(InventoryType.CHEST)) && (!e.getInitiator().getType().equals(InventoryType.PLAYER))) {

            if (e.getSource().getHolder() instanceof DoubleChest) {
                DoubleChest dc = (DoubleChest) e.getSource().getHolder();
                Chest r = (Chest) dc.getRightSide();
                Chest l = (Chest) dc.getLeftSide();

                if (shopUtils.isShop(r.getLocation()) || shopUtils.isShop(l.getLocation())) e.setCancelled(true);

            } else if (e.getSource().getHolder() instanceof Chest) {
                Chest c = (Chest) e.getSource().getHolder();

                if (shopUtils.isShop(c.getLocation())) e.setCancelled(true);
            }

        }
    }
}
 
开发者ID:EpicEricEE,项目名称:ShopChest,代码行数:22,代码来源:ChestProtectListener.java

示例2: onInventoryMove

import org.bukkit.event.inventory.InventoryMoveItemEvent; //导入方法依赖的package包/类
@EventHandler
public void onInventoryMove(InventoryMoveItemEvent event) {
    if (!cratesPlus.getConfigHandler().isDisableKeySwapping())
        return;
    String title;
    ItemStack item = event.getItem();

    for (Map.Entry<String, Crate> crate : cratesPlus.getConfigHandler().getCrates().entrySet()) {
        if (!(crate.getValue() instanceof KeyCrate)) {
            continue;
        }
        KeyCrate keyCrate = (KeyCrate) crate.getValue();
        Key key = keyCrate.getKey();
        if (key == null)
            continue;
        title = key.getName();

        if (item.hasItemMeta() && item.getItemMeta().hasDisplayName() && item.getItemMeta().getDisplayName().contains(title)) {
            // Send message?
            event.setCancelled(true);
            return;
        }
    }
}
 
开发者ID:ConnorLinfoot,项目名称:CratesPlus,代码行数:25,代码来源:BlockListeners.java

示例3: onInventoryMoveItemEvent

import org.bukkit.event.inventory.InventoryMoveItemEvent; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true)
public void onInventoryMoveItemEvent(InventoryMoveItemEvent event) {
    Block from = getInventoryBlockOrNull(event.getSource());
    Block to = getInventoryBlockOrNull(event.getDestination());

    if (from != null) {
        if (isProtectedForRedstone(from)) {
            event.setCancelled(true);
            return;
        }
    }
    if (to != null) {
        if (isProtectedForRedstone(to)) {
            event.setCancelled(true);
            return;
        }
    }
}
 
开发者ID:rutgerkok,项目名称:BlockLocker,代码行数:19,代码来源:InteractListener.java

示例4: onInventoryMoveItemEvent

import org.bukkit.event.inventory.InventoryMoveItemEvent; //导入方法依赖的package包/类
/**
 * Prevent hoppers from removing or inserting items in death chests
 * @param event
 */
@EventHandler
public void onInventoryMoveItemEvent(InventoryMoveItemEvent event) {

	// get inventories involved in event
	Inventory destination = event.getDestination();
	Inventory source = event.getSource();
	
	// if source inventory is a death chest, cancel event and return
	if (inventoryIsDeathChest(source)) {
		event.setCancelled(true);
		return;
	}
	
	// if destination is a death chest and prevent-item-placement is true, cancel event and return
	if (inventoryIsDeathChest(destination) && plugin.getConfig().getBoolean("prevent-item-placement")) {
		event.setCancelled(true);
		return;
	}
}
 
开发者ID:tim-savage,项目名称:SavageDeathChest,代码行数:24,代码来源:InventoryEventListener.java

示例5: onInventoryMove

import org.bukkit.event.inventory.InventoryMoveItemEvent; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true)
public void onInventoryMove(InventoryMoveItemEvent event) {
	ItemStack item = event.getItem();
	
	try {
		ExchangeRule.parseRuleBlock(item);
	}
	catch(ExchangeRuleParseException e) {
		try {
			ExchangeRule.parseBulkRuleBlock(item);
		}
		catch(ExchangeRuleParseException e2) {
			return;
		}
	}
	
	event.setCancelled(true);
}
 
开发者ID:gmlaxfanatic,项目名称:ItemExchange,代码行数:19,代码来源:ItemExchangeListener.java

示例6: onHopper

import org.bukkit.event.inventory.InventoryMoveItemEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onHopper(InventoryMoveItemEvent e) {
	if (cm.isAntiNetherHopper) {
		if (e.getInitiator().getHolder() instanceof Hopper) {
			Hopper hopper = (Hopper) e.getInitiator().getHolder();
			if (hopper.getWorld().getEnvironment() == World.Environment.NETHER) {
				e.setCancelled(true);
			}
		}
	}
}
 
开发者ID:jiongjionger,项目名称:NeverLag,代码行数:12,代码来源:AntiNetherHopper.java

示例7: onInventoryMoveItem

import org.bukkit.event.inventory.InventoryMoveItemEvent; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGH)
public void onInventoryMoveItem(InventoryMoveItemEvent event) {
    if (plugin.getEotwHandler().isEndOfTheWorld())
        return;
    InventoryHolder holder = event.getSource().getHolder();

    // Have to do this hackery since Bukkit doesn't
    // provide an API for us to do this
    Collection<Block> sourceBlocks;
    if (holder instanceof Chest) {
        sourceBlocks = Collections.singletonList(((Chest) holder).getBlock());
    } else if (holder instanceof DoubleChest) {
        DoubleChest doubleChest = (DoubleChest) holder;
        sourceBlocks = Lists.newArrayList(((Chest) doubleChest.getLeftSide()).getBlock(), ((Chest) doubleChest.getRightSide()).getBlock());
    } else {
        return;
    }

    for (Block block : sourceBlocks) {
        if (isSubclaimable(block)) {
            Collection<Sign> attachedSigns = getAttachedSigns(block);
            for (Sign attachedSign : attachedSigns) {
                String[] lines = attachedSign.getLines();
                if (lines[0].equals(SignSubclaimListener.SUBCLAIM_CONVERSION_PREFIX)) {
                    event.setCancelled(true);
                    break;
                }
            }
        }
    }
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:32,代码来源:SignSubclaimListener.java

示例8: onMove

import org.bukkit.event.inventory.InventoryMoveItemEvent; //导入方法依赖的package包/类
@EventHandler
public void onMove(InventoryMoveItemEvent e) {
	if (e.getSource() == null) return;
	if (e.getSource().getTitle() == null) return;
	if (e.getSource().getTitle().equals(CC(Main.finalconfig.getString("atm_title")))) {
		e.setCancelled(true);
	}
}
 
开发者ID:mastercake10,项目名称:TimeIsMoney,代码行数:9,代码来源:ATM.java

示例9: onIgnitionChamberItemMove

import org.bukkit.event.inventory.InventoryMoveItemEvent; //导入方法依赖的package包/类
/**
 * Listens to InventoryMoveItemEvent to handle IGNITION_CHAMBER.
 * @param e InventoryMoveItemEvent
 * @since 4.1.11
 */
@EventHandler
public void onIgnitionChamberItemMove(InventoryMoveItemEvent e) {
	if (e.getInitiator().getHolder() instanceof Hopper) {
		if (BlockStorage.check(((Hopper) e.getInitiator().getHolder()).getBlock(), "IGNITION_CHAMBER")) {
			e.setCancelled(true);
		}
	}
}
 
开发者ID:TheBusyBiscuit,项目名称:Slimefun4,代码行数:14,代码来源:ItemListener.java

示例10: onInventoryMoveItemEvent

import org.bukkit.event.inventory.InventoryMoveItemEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled=true)
public void onInventoryMoveItemEvent(InventoryMoveItemEvent event) {
    Inventory initiator = event.getInitiator();
    Inventory dest = event.getDestination();
    Inventory source = event.getSource();
    
    //Prevent items from being pulled out by other hopper
if(plugin.getConfig().getBoolean("preventitempull")){
    if(plugin.checkNames(source.getName()) && initiator != source){ 
        event.setCancelled(true);        
    }
}

    if(plugin.checkNames(initiator.getName())){   
        if(!initiator.contains(event.getItem().getType())) {
            
            event.setCancelled(true);
            
            //Try to move items in other slots
            if(dest != initiator) {
                for(int slot=1; slot < initiator.getSize(); slot++) {
                    if(this.MoveItem(initiator, slot, dest) == true){break;}
               }                
            }            
        }
    }
}
 
开发者ID:poiNt3D,项目名称:SortingHopper,代码行数:28,代码来源:HopperListener.java

示例11: onInventoryMoveItemEvent

import org.bukkit.event.inventory.InventoryMoveItemEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onInventoryMoveItemEvent(InventoryMoveItemEvent event) {
    Inventory inventory = event.getDestination();

    if (!(inventory instanceof BrewerInventory)) {
        return;
    }

    InventoryHolder holder = inventory.getHolder();

    if (!(holder instanceof BrewingStand)) {
        return;
    }

    ItemStack item = event.getItem();

    if (Config.getInstance().getPreventHopperTransferIngredients() && item.getType() != Material.POTION) {
        event.setCancelled(true);
        return;
    }

    if (Config.getInstance().getPreventHopperTransferBottles() && item.getType() == Material.POTION) {
        event.setCancelled(true);
        return;
    }

    if (Config.getInstance().getEnabledForHoppers() && AlchemyPotionBrewer.isValidIngredient(null, item)) {
        AlchemyPotionBrewer.scheduleCheck(null, (BrewingStand) holder);
    }
}
 
开发者ID:Pershonkey,项目名称:McMMOPlus,代码行数:31,代码来源:InventoryListener.java

示例12: onItemMove

import org.bukkit.event.inventory.InventoryMoveItemEvent; //导入方法依赖的package包/类
@EventHandler
public void onItemMove(InventoryMoveItemEvent event) {
	try {
		if (event.getDestination() != null && event.getDestination().equals(this.inventory)) {
			event.setCancelled(true);
		}
		if (event.getSource() != null && event.getSource().equals(this.inventory)) {
			event.setCancelled(true);
		}
	}
	catch (final Exception e) { CraftoMessenger.report(this, "Failed to handle item move event!", e); }
}
 
开发者ID:Craftolution,项目名称:CraftoPlugin,代码行数:13,代码来源:Menu.java

示例13: onInventoryMoveItemEvent

import org.bukkit.event.inventory.InventoryMoveItemEvent; //导入方法依赖的package包/类
/** 
 * Event handler to watch whenever a container tries to move an item to another container.
 * Hoppers for example are the only thing that triggers this so far.
 * If the item being moved is not allowed in the destination container, then the event will be canceled to prevent the move.
 *
 *  @param event InventoryMoveItemEvent containing data about the event given by the system. We care about hoppers being the receiving end of the transfer.
 */
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled=true)
public void onInventoryMoveItemEvent(InventoryMoveItemEvent event) {
    //Get destination container
    InventoryHolder destHolder = event.getDestination().getHolder();
    
    //since we only care about hoppers, then ignore everything else
    if (destHolder instanceof Hopper) {
        //Get the location of the hopper in question.  
        Block hopperBlock = ((Hopper) destHolder).getBlock();

        //Get the cache, if any, for the hopper location.
        String cache = plugin.knownHoppersCache_Get(hopperBlock);

        //get the itemStack that was moved and convert it to a String for comparison
        String eventItemInformation = plugin.GetItemInformationForInventory(event.getItem(), false);
                    
        //debug if requested
        if (plugin.debugLevel_get() > 0) plugin.getLogger().info("Testing item (" + eventItemInformation + ") in hopper (" + hopperBlock.getLocation().toString() + ") against allowed:" + cache);
        
        //do the actual filtering
        if (cache.length() > 0)
            //we have a cache to compare against
            if (!cache.contains(eventItemInformation))
                //the item is not allowed in the hopper
                event.setCancelled(true);
    }
}
 
开发者ID:TheNut,项目名称:HopperFilterSimplified,代码行数:35,代码来源:HfsBlockListener.java

示例14: onInventoryMoveItem

import org.bukkit.event.inventory.InventoryMoveItemEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.NORMAL)
public void onInventoryMoveItem (InventoryMoveItemEvent event)
  {
    if ( ! (event.getInitiator() instanceof PlayerInventory)
        || ! (event.getDestination() instanceof BrewerInventory))
      return;
    if (event.getItem().getType() != Material.QUARTZ)
      return;
    event.setCancelled(true);
    int amount = event.getItem().getAmount();
    ItemStack[] inv = event.getInitiator().getContents();
    for (int i = 0; i < inv.length; i++)
      {
        ItemStack item = inv[i];
        if (item.getType() != Material.QUARTZ)
          continue;
        if (item.getAmount() == amount)
          {
            inv[i] = null;
          }
        else
          {
            item.setAmount(item.getAmount() - amount);
          }
      }
    event.getInitiator().setContents(inv);
    event.getDestination().setItem(3,
        new ItemStack(Material.QUARTZ, amount));
  }
 
开发者ID:DiGitHubCap,项目名称:Merlin,代码行数:30,代码来源:PlayerListener.java

示例15: onInventoryMoveItem

import org.bukkit.event.inventory.InventoryMoveItemEvent; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true)
void onInventoryMoveItem(InventoryMoveItemEvent event) {
	if (event.getSource() != null) {
		InventoryHolder holder = event.getSource().getHolder();
		if (holder != null && holder instanceof Chest) {
			Block block = ((Chest) holder).getBlock();
			if (plugin.getProtectedChests().isChestProtected(block, null)) {
				event.setCancelled(true);
			}
		}
	}
}
 
开发者ID:nisovin,项目名称:Shopkeepers,代码行数:13,代码来源:ChestProtectListener.java


注:本文中的org.bukkit.event.inventory.InventoryMoveItemEvent.setCancelled方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。