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


Java InventoryPickupItemEvent.setCancelled方法代码示例

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


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

示例1: onItemPickup

import cn.nukkit.event.inventory.InventoryPickupItemEvent; //导入方法依赖的package包/类
@EventHandler (ignoreCancelled = true)
public void onItemPickup(InventoryPickupItemEvent event){
	if(event.getInventory().getHolder() instanceof Player){
		Player player = (Player) event.getInventory().getHolder();
		EntityItem item = event.getItem();
		
		long now = System.currentTimeMillis();
		Long[] lastPickup = this.manager.getLastPickup(player);
		
		if(lastPickup == null || (lastPickup[1] == item.getId() && now - lastPickup[0] > 2000) || lastPickup[1] != item.getId()){
			Land land;
			if((land = this.provider.findLand(item)) != null && !land.getOption("pickup", false)){
				if(!(land.hasPermission(player) || player.hasPermission("economyland.admin.pickup"))){
					event.setCancelled(true);
					
					if(lastPickup != null && now - lastPickup[0] > 2000){
						player.sendMessage(this.getMessage("pickup-forbidden", new Object[]{
								land.getId(), land.getOwner()
						}));
					}
					
					this.manager.setLastPickup(player, item);
				}
			}
		}else{
			event.setCancelled(true);
		}
	}
}
 
开发者ID:EconomyS,项目名称:EconomyLand,代码行数:30,代码来源:EconomyLand.java

示例2: onPickup

import cn.nukkit.event.inventory.InventoryPickupItemEvent; //导入方法依赖的package包/类
@EventHandler
public void onPickup(InventoryPickupItemEvent event){
	InventoryHolder holder = event.getInventory().getHolder();
	if(holder instanceof Player){
		Player player = (Player)holder;
		if(this.status == STATUS_ONGOING){
			if(containers.containsKey(player.getName())){
				containers.get(player.getName()).getGun().addAmmo(30);
			}
		}
	}
	event.getItem().kill();
	event.setCancelled();
}
 
开发者ID:onebone,项目名称:MineCombat-Nukkit,代码行数:15,代码来源:MineCombat.java

示例3: onPickup

import cn.nukkit.event.inventory.InventoryPickupItemEvent; //导入方法依赖的package包/类
@EventHandler
public void onPickup(InventoryPickupItemEvent event){
	InventoryHolder holder = event.getInventory().getHolder();
	if(holder instanceof Player){
		Player player = (Player)holder;
		if(!this.manager.isAuthenticated(player)){
			event.setCancelled();
		}
	}
}
 
开发者ID:onebone,项目名称:GateKeeper,代码行数:11,代码来源:GateKeeper.java

示例4: onInventoryPickupItem

import cn.nukkit.event.inventory.InventoryPickupItemEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST)
public void onInventoryPickupItem(InventoryPickupItemEvent event){
	if(event.getItem() instanceof EntityOwnedItem && event.getInventory().getHolder() instanceof Player && !((EntityOwnedItem) event.getItem()).canPickUp((Player) event.getInventory().getHolder())){
		event.setCancelled();
	}
}
 
开发者ID:if-Team,项目名称:Nukkit-Plugins,代码行数:7,代码来源:ItemEventListener.java


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