本文整理匯總了Java中org.bukkit.event.inventory.InventoryMoveItemEvent.getItem方法的典型用法代碼示例。如果您正苦於以下問題:Java InventoryMoveItemEvent.getItem方法的具體用法?Java InventoryMoveItemEvent.getItem怎麽用?Java InventoryMoveItemEvent.getItem使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.bukkit.event.inventory.InventoryMoveItemEvent
的用法示例。
在下文中一共展示了InventoryMoveItemEvent.getItem方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: 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;
}
}
}
示例2: 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);
}
示例3: 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);
}
}
示例4: onItemMove
import org.bukkit.event.inventory.InventoryMoveItemEvent; //導入方法依賴的package包/類
@EventHandler
public void onItemMove(InventoryMoveItemEvent event)
{
Inventory source = event.getSource();
Inventory target = event.getDestination();
if (target == null || source == null)
{
this.module.getLog().warn("InventoryMoveItem has null {} -> {} This should never happen!", source, target);
return;
}
Location sourceLocation = this.getLocationForHolder(source.getHolder());
if (sourceLocation == null)
{
return;
}
Location targetLocation = this.getLocationForHolder(target.getHolder());
if (targetLocation == null)
{
return;
}
ItemMove action = this.newAction(ItemMove.class, targetLocation.getWorld());
if (action != null)
{
LoggingConfiguration config = this.getConfig(targetLocation.getWorld());
if (config.container.moveIgnore.contains(event.getItem().getType()))
{
return;
}
action.item = event.getItem();
action.setLocation(sourceLocation);
action.direction = sourceLocation.getBlock().getFace(targetLocation.getBlock());
action.fromContainer = new ContainerType(source.getHolder());
action.toContainer = new ContainerType(target.getHolder());
this.logAction(action);
}
}