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


Java InventoryPickupItemEvent类代码示例

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


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

示例1: onCollideWithPlayer

import cn.nukkit.event.inventory.InventoryPickupItemEvent; //导入依赖的package包/类
@Override
public void onCollideWithPlayer(Player player) {
    if(this.getPickupDelay() > 0) {
        return;
    }

    Item item = this.getItem();
    PlayerInventory playerInventory = player.getInventory();

    if(!(item instanceof Item) || (player.isSurvival() && !playerInventory.canAddItem(item))) {
        return;
    }

    InventoryPickupItemEvent ev;
    this.server.getPluginManager().callEvent(ev = new InventoryPickupItemEvent(playerInventory, this));
    if(ev.isCancelled()) {
        return;
    }

    TakeItemEntityPacket pk = new TakeItemEntityPacket();
    pk.entityRuntimeId = player.getId();
    pk.target = this.getId();
    Server.broadcastPacket(this.getViewers().values(), pk);

    playerInventory.addItem(item);
    this.kill();
}
 
开发者ID:JupiterDevelopmentTeam,项目名称:Jupiter,代码行数:28,代码来源:EntityItem.java

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

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

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

示例5: 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类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。