本文整理汇总了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);
}
}
}
示例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();
}
示例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();
}
}
}
示例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();
}
}