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


Java PlayerItemHeldEvent.isCancelled方法代码示例

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


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

示例1: a

import org.bukkit.event.player.PlayerItemHeldEvent; //导入方法依赖的package包/类
public void a(PacketPlayInHeldItemSlot packetplayinhelditemslot) {
    // CraftBukkit start
    if (this.player.dead) return;

    if (packetplayinhelditemslot.c() >= 0 && packetplayinhelditemslot.c() < PlayerInventory.getHotbarSize()) {
        PlayerItemHeldEvent event = new PlayerItemHeldEvent(this.getPlayer(), this.player.inventory.itemInHandIndex, packetplayinhelditemslot.c());
        this.server.getPluginManager().callEvent(event);
        if (event.isCancelled()) {
            this.sendPacket(new PacketPlayOutHeldItemSlot(this.player.inventory.itemInHandIndex));
            this.player.v();
            return;
        }
        // CraftBukkit end

        this.player.inventory.itemInHandIndex = packetplayinhelditemslot.c();
        this.player.v();
    } else {
        c.warn(this.player.getName() + " tried to set an invalid carried item");
        this.disconnect("Nope!"); // CraftBukkit
    }
}
 
开发者ID:OvercastNetwork,项目名称:CraftBukkit,代码行数:22,代码来源:PlayerConnection.java

示例2: onItemHeld

import org.bukkit.event.player.PlayerItemHeldEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST)
public void onItemHeld(PlayerItemHeldEvent event) {
	if (event.isCancelled()) {
		return;
	}
	
	ItemStack stack = event.getPlayer().getItemInHand();
	if (stack == null) {
		return;
	}

	LoreMaterial material = LoreMaterial.getMaterial(stack);
	if (material != null) {
		material.onHold(event);
	}
}
 
开发者ID:netizen539,项目名称:civcraft,代码行数:17,代码来源:CustomItemManager.java

示例3: a

import org.bukkit.event.player.PlayerItemHeldEvent; //导入方法依赖的package包/类
public void a(Packet16BlockItemSwitch packet16blockitemswitch) {
    // CraftBukkit start
    if (this.player.dead) return;

    if (packet16blockitemswitch.itemInHandIndex >= 0 && packet16blockitemswitch.itemInHandIndex < PlayerInventory.getHotbarSize()) {
        PlayerItemHeldEvent event = new PlayerItemHeldEvent(this.getPlayer(), this.player.inventory.itemInHandIndex, packet16blockitemswitch.itemInHandIndex);
        this.server.getPluginManager().callEvent(event);
        if (event.isCancelled()) {
            this.sendPacket(new Packet16BlockItemSwitch(this.player.inventory.itemInHandIndex));
            this.player.u();
            return;
        }
        // CraftBukkit end

        this.player.inventory.itemInHandIndex = packet16blockitemswitch.itemInHandIndex;
        this.player.u();
    } else {
        this.minecraftServer.getLogger().warning(this.player.getName() + " tried to set an invalid carried item");
        this.disconnect("Nope!"); // CraftBukkit
    }
}
 
开发者ID:AlmuraDev,项目名称:Almura-Server,代码行数:22,代码来源:PlayerConnection.java

示例4: a

import org.bukkit.event.player.PlayerItemHeldEvent; //导入方法依赖的package包/类
public void a(PacketPlayInHeldItemSlot packetplayinhelditemslot) {
    // CraftBukkit start
    if (this.player.dead) return;

    if (packetplayinhelditemslot.c() >= 0 && packetplayinhelditemslot.c() < PlayerInventory.getHotbarSize()) {
        PlayerItemHeldEvent event = new PlayerItemHeldEvent(this.getPlayer(), this.player.inventory.itemInHandIndex, packetplayinhelditemslot.c());
        this.server.getPluginManager().callEvent(event);
        if (event.isCancelled()) {
            this.sendPacket(new PacketPlayOutHeldItemSlot(this.player.inventory.itemInHandIndex));
            this.player.v();
            return;
        }
        // CraftBukkit end

        this.player.inventory.itemInHandIndex = packetplayinhelditemslot.c();
        this.player.v();
    } else {
        c.warn(this.player.getName() + " tried to set an invalid carried item");
        this.disconnect("Invalid hotbar selection (Hacking?)"); // CraftBukkit //Spigot "Nope" -> Descriptive reason
    }
}
 
开发者ID:pvginkel,项目名称:Tweakkit-Server,代码行数:22,代码来源:PlayerConnection.java

示例5: a

import org.bukkit.event.player.PlayerItemHeldEvent; //导入方法依赖的package包/类
public void a(PacketPlayInHeldItemSlot packetplayinhelditemslot) {
    PlayerConnectionUtils.ensureMainThread(packetplayinhelditemslot, this, this.player.x());
    if (this.player.dead) return; // CraftBukkit
    if (packetplayinhelditemslot.a() >= 0 && packetplayinhelditemslot.a() < PlayerInventory.getHotbarSize()) {
        PlayerItemHeldEvent event = new PlayerItemHeldEvent(this.getPlayer(), this.player.inventory.itemInHandIndex, packetplayinhelditemslot.a());
        this.server.getPluginManager().callEvent(event);
        if (event.isCancelled()) {
            this.sendPacket(new PacketPlayOutHeldItemSlot(this.player.inventory.itemInHandIndex));
            this.player.resetIdleTimer();
            return;
        }
        // CraftBukkit end
        this.player.inventory.itemInHandIndex = packetplayinhelditemslot.a();
        this.player.resetIdleTimer();
    } else {
        PlayerConnection.LOGGER.warn(this.player.getName() + " tried to set an invalid carried item");
        this.disconnect("Invalid hotbar selection (Hacking?)"); // CraftBukkit //Spigot "Nope" -> Descriptive reason
    }
}
 
开发者ID:bergerkiller,项目名称:SpigotSource,代码行数:20,代码来源:PlayerConnection.java

示例6: a

import org.bukkit.event.player.PlayerItemHeldEvent; //导入方法依赖的package包/类
public void a(Packet16BlockItemSwitch packet16blockitemswitch) {
    // CraftBukkit start
    if (this.player.dead) return;

    if (packet16blockitemswitch.itemInHandIndex >= 0 && packet16blockitemswitch.itemInHandIndex < PlayerInventory.getHotbarSize()) {
        PlayerItemHeldEvent event = new PlayerItemHeldEvent(this.getPlayer(), this.player.inventory.itemInHandIndex, packet16blockitemswitch.itemInHandIndex);
        this.server.getPluginManager().callEvent(event);
        if (event.isCancelled()) {
            this.sendPacket(new Packet16BlockItemSwitch(this.player.inventory.itemInHandIndex));
            return;
        }
        // CraftBukkit end

        this.player.inventory.itemInHandIndex = packet16blockitemswitch.itemInHandIndex;
    } else {
        this.minecraftServer.getLogger().warning(this.player.name + " tried to set an invalid carried item");
        this.disconnect("Nope!"); // CraftBukkit
    }
}
 
开发者ID:didoupimpon,项目名称:Craft-city,代码行数:20,代码来源:PlayerConnection.java

示例7: onHeld

import org.bukkit.event.player.PlayerItemHeldEvent; //导入方法依赖的package包/类
@EventHandler
public void onHeld(PlayerItemHeldEvent e) {
    if (e.isCancelled()) {
        return;
    }
    if (!Utils.isInArena(e.getPlayer())) {
        return;
    }
    if (e.getNewSlot() == 0) {
        return;
    }
    if (e.getNewSlot() >= 2 && e.getNewSlot() <= 4) {
        int slot = e.getNewSlot();
        Player p = e.getPlayer();
        PlayerInventory inv = p.getInventory();
        ItemStack item = inv.getItem(slot).clone();
        item.setAmount(1);
        if (SkillManager.getInstance().isSkillSelector(item)) {
            Skill skill = SkillManager.getInstance().getSkillBySelector(item);
            if(skill.getSkillType().equals(SkillType.ITEM)){
                inv.setItem(0, skill.getShow());
            }
            else{
                Class<?> skillClazz=skill.getClass();
                try {
                    Method method =skillClazz.getMethod("doUpgrade",Player.class);
                    if(method!=null){
                        method.invoke(SkillManager.getInstance().getSkillByName(skill.getName()),p);
                    }
                } catch (Exception e1) {
                    e1.printStackTrace();
                }
            }
            inv.setItem(2, ItemManager.getForbidden(3));
            inv.setItem(3, ItemManager.getForbidden(4));
            inv.setItem(4, ItemManager.getForbidden(5));
        }
    }
    e.setCancelled(true);
}
 
开发者ID:Soldier233,项目名称:ArchersBattle,代码行数:41,代码来源:InventoryListener.java

示例8: processHeldItemChange

import org.bukkit.event.player.PlayerItemHeldEvent; //导入方法依赖的package包/类
public void processHeldItemChange(C09PacketHeldItemChange p_147355_1_)
{
    // CraftBukkit start
    if (this.playerEntity.isDead)
    {
        return;
    }

    if (p_147355_1_.func_149614_c() >= 0 && p_147355_1_.func_149614_c() < InventoryPlayer.getHotbarSize())
    {
        PlayerItemHeldEvent event = new PlayerItemHeldEvent(this.getPlayerB(), this.playerEntity.inventory.currentItem, p_147355_1_.func_149614_c());
        this.server.getPluginManager().callEvent(event);

        if (event.isCancelled())
        {
            this.sendPacket(new S09PacketHeldItemChange(this.playerEntity.inventory.currentItem));
            this.playerEntity.func_143004_u();
            return;
        }

        // CraftBukkit end
        this.playerEntity.inventory.currentItem = p_147355_1_.func_149614_c();
        this.playerEntity.func_143004_u();
    }
    else
    {
        logger.warn(this.playerEntity.getCommandSenderName() + " tried to set an invalid carried item");
        this.kickPlayerFromServer("Nope!"); // CraftBukkit
    }
}
 
开发者ID:xtrafrancyz,项目名称:Cauldron,代码行数:31,代码来源:NetHandlerPlayServer.java


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