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


Java PlayerItemHeldEvent类代码示例

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


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

示例1: equipItem

import cn.nukkit.event.player.PlayerItemHeldEvent; //导入依赖的package包/类
/**
 * Called when a client equips a hotbar inventorySlot. This method should not be used by plugins.
 * This method will call PlayerItemHeldEvent.
 *
 * @param slot hotbar slot Number of the hotbar slot to equip.
 * @return boolean if the equipment change was successful, false if not.
 */
public boolean equipItem(int slot) {
    if (!isHotbarSlot(slot)) {
        this.sendContents((Player) this.getHolder());
        return false;
    }

    if (this.getHolder() instanceof Player) {
        PlayerItemHeldEvent ev = new PlayerItemHeldEvent((Player) this.getHolder(), this.getItem(slot), slot);
        this.getHolder().getLevel().getServer().getPluginManager().callEvent(ev);

        if (ev.isCancelled()) {
            this.sendContents(this.getViewers());
            return false;
        }
    }

    this.setHeldItemIndex(slot, false);
    return true;
}
 
开发者ID:Rsplwe,项目名称:Nukkit-Java9,代码行数:27,代码来源:PlayerInventory.java

示例2: chin

import cn.nukkit.event.player.PlayerItemHeldEvent; //导入依赖的package包/类
@EventHandler
public void chin(PlayerItemHeldEvent event){
Player player = event.getPlayer();
Item item =event.getItem();
String iname =item.getCustomName();
Config gunlangjpn =Main.gunlangjpn;
if(gunlangjpn.exists(iname.trim())){
	int kindid = gunlangjpn.getInt(iname.trim());
	if(cgun.containsKey(player.getName()+"-"+kindid)){
		int c = cgun.get(player.getName()+"-"+kindid);
		player.sendPopup(lj.usebu_remaining+c);
	}

	if(kindid >1000){
		hgun.put(player.getName(),true);
	}else if(hgun.containsKey(player.getName())){
		hgun.remove(player.getName());
	}
}else{
	if(hgun.containsKey(player.getName())){
		hgun.remove(player.getName());
	}
}
}
 
开发者ID:haniokasai,项目名称:NuclearGunWars-plugin,代码行数:25,代码来源:gunsys.java

示例3: setHeldItemSlot

import cn.nukkit.event.player.PlayerItemHeldEvent; //导入依赖的package包/类
public void setHeldItemSlot(int slot) {
    if (slot >= -1 && slot < this.getSize()) {
        Item item = this.getItem(slot);

        int itemIndex = this.getHeldItemIndex();

        if (this.getHolder() instanceof Player) {
            PlayerItemHeldEvent ev = new PlayerItemHeldEvent((Player) this.getHolder(), item, slot, itemIndex);
            Server.getInstance().getPluginManager().callEvent(ev);
            if (ev.isCancelled()) {
                this.sendContents((Player) this.getHolder());
                return;
            }
        }

        this.setHotbarSlotIndex(itemIndex, slot);
    }
}
 
开发者ID:FrontierDevs,项目名称:Jenisys3,代码行数:19,代码来源:PlayerInventory.java

示例4: onEquipmentChange

import cn.nukkit.event.player.PlayerItemHeldEvent; //导入依赖的package包/类
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onEquipmentChange(PlayerItemHeldEvent event){
	Player player = event.getPlayer();
	Item item = event.getItem();
	
	if(this.status == STATUS_ONGOING){
		if(item.getId() == GUN_ITEM_ID){
			if(containers.containsKey(player.getName())){
				containers.get(player.getName()).startShoot();
			}
		}else{
			if(containers.containsKey(player.getName())){
				containers.get(player.getName()).stopShoot();
			}
		}
	}
}
 
开发者ID:onebone,项目名称:MineCombat-Nukkit,代码行数:18,代码来源:MineCombat.java

示例5: onItemHold

import cn.nukkit.event.player.PlayerItemHeldEvent; //导入依赖的package包/类
@EventHandler
public void onItemHold(PlayerItemHeldEvent event){
	if(!this.manager.isAuthenticated(event.getPlayer())){
		event.setCancelled();

		if(this.getConfig().get("message.send-login", true)){
			this.sendLoginMessage(event.getPlayer());
		}
	}
}
 
开发者ID:onebone,项目名称:GateKeeper,代码行数:11,代码来源:GateKeeper.java

示例6: onPlayerItemHoldEvent

import cn.nukkit.event.player.PlayerItemHeldEvent; //导入依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerItemHoldEvent(final PlayerItemHeldEvent event) {
    Player nukkitPlayer = event.getPlayer();
    if (nukkitPlayer.isSneaking()) {
        return;
    }
    FawePlayer<Object> fp = FawePlayer.wrap(nukkitPlayer);
    com.sk89q.worldedit.entity.Player player = fp.getPlayer();
    LocalSession session = fp.getSession();
    Tool tool = session.getTool(player);
    if (tool instanceof ScrollTool) {
        final int slot = event.getInventorySlot();
        final int oldSlot = event.getSlot();
        final int ri;
        if ((((slot - oldSlot) <= 4) && ((slot - oldSlot) > 0)) || (((slot - oldSlot) < -4))) {
            ri = 1;
        } else {
            ri = -1;
        }
        ScrollTool scrollable = (ScrollTool) tool;
        if (scrollable.increment(player, ri)) {
            final PlayerInventory inv = nukkitPlayer.getInventory();
            final Item item = inv.getItem(slot);
            final Item newItem = inv.getItem(oldSlot);
            inv.setItem(slot, newItem);
            inv.setItem(oldSlot, item);
            inv.sendContents(nukkitPlayer);
        }
    }
}
 
开发者ID:boy0001,项目名称:FastAsyncWorldedit,代码行数:31,代码来源:BrushListener.java


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