• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java InventoryPickupItemEvent类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java DiskFileUpload类代码示例发布时间:2022-05-22
下一篇:
Java AnalysisProvider类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap