當前位置: 首頁>>代碼示例>>Java>>正文


Java InventoryMoveItemEvent類代碼示例

本文整理匯總了Java中org.bukkit.event.inventory.InventoryMoveItemEvent的典型用法代碼示例。如果您正苦於以下問題:Java InventoryMoveItemEvent類的具體用法?Java InventoryMoveItemEvent怎麽用?Java InventoryMoveItemEvent使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


InventoryMoveItemEvent類屬於org.bukkit.event.inventory包,在下文中一共展示了InventoryMoveItemEvent類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onCraft

import org.bukkit.event.inventory.InventoryMoveItemEvent; //導入依賴的package包/類
@EventHandler
public void onCraft(InventoryMoveItemEvent e) {
	Bukkit.broadcastMessage(e.getDestination().getName());
	Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(SuperiorCraft.plugin, new Runnable() {
		@Override
		public void run() {
			for (CustomCraftingRecipe r : recipes) {
				if (r.check(e.getDestination().getContents(), e.getDestination())) {
					//System.out.println();
					r.onCraft(e);
					return;
				}
			}
		}
	}, 10);
}
 
開發者ID:GigaGamma,項目名稱:SuperiorCraft,代碼行數:17,代碼來源:CustomCrafting.java

示例2: 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

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: 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

示例8: 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

示例9: 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

示例10: 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

示例11: 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

示例12: onInventoryEvent

import org.bukkit.event.inventory.InventoryMoveItemEvent; //導入依賴的package包/類
@EventHandler
   public void onInventoryEvent(InventoryMoveItemEvent event) {

SyncHopper hopper = SyncManager.getManager().getHopper(event.getInitiator());

if (hopper != null) {
    hopper.transmit(event.getItem().clone(), event.getSource());
    return;
}
   }
 
開發者ID:AlexMl,項目名稱:SyncChest,代碼行數:11,代碼來源:InventoryMoveListener.java

示例13: 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

示例14: 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);
    }
}
 
開發者ID:CubeEngine,項目名稱:modules-extra,代碼行數:38,代碼來源:ListenerItemMove.java

示例15: onMoveItemToTrashCan

import org.bukkit.event.inventory.InventoryMoveItemEvent; //導入依賴的package包/類
@EventHandler
public void onMoveItemToTrashCan(InventoryMoveItemEvent event) {
    final TrashCan can = TrashCan.getTrashCan(event.getDestination());
    if (can != null) {
        Bukkit.getScheduler().runTask(plugin, new Runnable() {
            @Override
            public void run() {
                can.emptyTrash(false);
            }
        });
    }
}
 
開發者ID:desht,項目名稱:sensibletoolbox,代碼行數:13,代碼來源:TrashCanListener.java


注:本文中的org.bukkit.event.inventory.InventoryMoveItemEvent類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。