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


Java PlayerItemHeldEvent类代码示例

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


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

示例1: onQuickSlotHeld

import org.bukkit.event.player.PlayerItemHeldEvent; //导入依赖的package包/类
@EventHandler
public void onQuickSlotHeld(PlayerItemHeldEvent event) {
    Player player = event.getPlayer();

    if (!InventoryManager.playerIsLoaded(player)) {
        return;
    }

    int slotId = event.getNewSlot();
    Slot slot = InventoryManager.getQuickSlot(slotId);
    if (slot != null && slot.isCup(player.getInventory().getItem(slotId))) {
        event.setCancelled(true);
        InventoryUtils.heldFreeSlot(player, slotId,
                (event.getPreviousSlot() + 1) % 9 == slotId ? InventoryUtils.SearchType.NEXT : InventoryUtils.SearchType.PREV);
    }
}
 
开发者ID:EndlessCodeGroup,项目名称:RPGInventory,代码行数:17,代码来源:InventoryListener.java

示例2: onTakeRune

import org.bukkit.event.player.PlayerItemHeldEvent; //导入依赖的package包/类
@EventHandler
public void onTakeRune(PlayerItemHeldEvent event) {
	Player player = event.getPlayer();
	if(plugin.getRuneManager().getEffect(player) != null && plugin.getRuneManager().getActiveRune(player) == null) {
		plugin.getRuneManager().removeEffect(event.getPlayer());
	}
	
	ItemStack item = event.getPlayer().getInventory().getItem(event.getNewSlot());
	if(item == null || item.getItemMeta() == null || !item.getType().equals(Material.ENCHANTED_BOOK)) {
		return;
	}
	
	Rune rune = plugin.getRuneManager().getRune(item.getItemMeta().getDisplayName().substring(2));
	if(rune == null) {
		return;
	}
	
	plugin.getRuneManager().startHoldingEffect(player, rune);
}
 
开发者ID:benNek,项目名称:AsgardAscension,代码行数:20,代码来源:RuneListener.java

示例3: onWeaponSwitch

import org.bukkit.event.player.PlayerItemHeldEvent; //导入依赖的package包/类
@EventHandler
public void onWeaponSwitch(PlayerItemHeldEvent e) {
	if (!player.getPlayer().isOnline()) {
		return;
	}
	
	if (!e.getPlayer().getUniqueId().equals(player.getPlayer().getUniqueId())) {
		return;
	}
	
	if (!(QuestManagerPlugin.questManagerPlugin.getPluginConfiguration().getWorlds()
			.contains(e.getPlayer().getWorld().getName()))) {
		return;
	}
	
	//not allowed to switch weapons, cheater!
	this.cancel();
	e.getPlayer().sendMessage(FADE_MESSAGE);
}
 
开发者ID:Dove-Bren,项目名称:QuestManager,代码行数:20,代码来源:Imbuement.java

示例4: onToolSwap

import org.bukkit.event.player.PlayerItemHeldEvent; //导入依赖的package包/类
@EventHandler
public void onToolSwap(PlayerItemHeldEvent e) {
	if (!e.getPlayer().getUniqueId().equals(player.getPlayer().getUniqueId())) {
		return;
	}
	
	if (!isWrongTool && !skill.isTool(e.getPlayer().getInventory().getItem(e.getNewSlot()))) {
		this.isWrongTool = true;
		e.getPlayer().sendMessage(WRONG_TOOL_MESSAGE);
		this.wrongItemTimeLeft = WRONG_TOOL_TIMEOUT;
		return;
	}
	
	if (skill.isTool(e.getPlayer().getInventory().getItem(e.getNewSlot()))) {
		this.isWrongTool = false;
		return;
	}
}
 
开发者ID:Dove-Bren,项目名称:QuestManager,代码行数:19,代码来源:ForgeSequence.java

示例5: onItemSwitch

import org.bukkit.event.player.PlayerItemHeldEvent; //导入依赖的package包/类
@EventHandler
public void onItemSwitch(PlayerItemHeldEvent e) {
	if (canChangeItems) {
		return;
	}
	
	if (!player.getPlayer().isOnline()) {
		return;
	}
	
	if (!e.getPlayer().getUniqueId().equals(player.getPlayer().getUniqueId())) {
		return;
	}
	
	if (!(QuestManagerPlugin.questManagerPlugin.getPluginConfiguration().getWorlds()
			.contains(e.getPlayer().getWorld().getName()))) {
		return;
	}
	
	//not allowed to switch weapons, cheater!
	doneCasting();
	e.getPlayer().sendMessage(DISTURBED_MESSAGE);
}
 
开发者ID:Dove-Bren,项目名称:QuestManager,代码行数:24,代码来源:ChargeAction.java

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

示例7: onMapHold

import org.bukkit.event.player.PlayerItemHeldEvent; //导入依赖的package包/类
/**
 * Make sure all player held maps have triangle overlays. (todo: make sure all maps on item frames do as well)
 * There seem to be some bugs around this. It doesn't always take on the first try.
 */
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled=true)
public void onMapHold(final PlayerItemHeldEvent event) {
    Player player = event.getPlayer();
    ItemStack itemInHand = player.getInventory().getItem(event.getNewSlot());
    if (itemInHand == null) return;
    if (!Material.MAP.equals(itemInHand.getType())) {
        return;
    }
    if (!player.getWorld().equals(getBeaconzWorld())) {
        return;
    }
    @SuppressWarnings("deprecation")
    MapView map = Bukkit.getMap(itemInHand.getDurability());
    for (MapRenderer renderer : map.getRenderers()) {
        if (renderer instanceof TerritoryMapRenderer) {
            return;
        }
    }
    map.addRenderer(new TerritoryMapRenderer(getBeaconzPlugin()));
}
 
开发者ID:tastybento,项目名称:beaconz,代码行数:25,代码来源:BeaconLinkListener.java

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

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

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

示例11: onItemHeld

import org.bukkit.event.player.PlayerItemHeldEvent; //导入依赖的package包/类
@Override
public void onItemHeld(PlayerItemHeldEvent event) {
    int delta = event.getNewSlot() - event.getPreviousSlot();
    if (delta == 0) {
        return;
    } else if (delta >= 6) {
        delta -= 9;
    } else if (delta <= -6) {
        delta += 9;
    }
    delta = (delta > 0) ? 1 : -1;
    int o = getMode().ordinal() + delta;
    if (o < 0) {
        o = Mode.values().length - 1;
    } else if (o >= Mode.values().length) {
        o = 0;
    }
    setMode(Mode.values()[o]);
    event.getPlayer().setItemInHand(toItemStack());
}
 
开发者ID:desht,项目名称:sensibletoolbox,代码行数:21,代码来源:MultiBuilder.java

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

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

示例14: onItemHeld

import org.bukkit.event.player.PlayerItemHeldEvent; //导入依赖的package包/类
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
void onItemHeld(PlayerItemHeldEvent event) {
	Player player = event.getPlayer();
	if (player.getGameMode() == GameMode.CREATIVE) return;
	ItemStack newItemInHand = player.getInventory().getItem(event.getNewSlot());
	if (!Settings.isShopCreationItem(newItemInHand)) {
		return;
	}

	if (!ShopkeepersPlugin.getInstance().hasCreatePermission(player)) {
		// player cannot create any shopkeeper at all
		return;
	}

	// print info message about usage:
	Utils.sendMessage(player, Settings.msgCreationItemSelected);
}
 
开发者ID:nisovin,项目名称:Shopkeepers,代码行数:18,代码来源:CreateListener.java

示例15: onEditBook

import org.bukkit.event.player.PlayerItemHeldEvent; //导入依赖的package包/类
@EventHandler
public void onEditBook(PlayerItemHeldEvent event){
	
	//Get player and the action
	Player player = event.getPlayer();
	EpicPlayer epicPlayer = EpicSystem.getEpicPlayer(player.getUniqueId());	
	ItemStack inHand = player.getInventory().getItem(event.getNewSlot());

	if(inHand != null && inHand.getType() == Material.WRITTEN_BOOK){
		
		BookMeta book = (BookMeta)inHand.getItemMeta();
		if(book.hasTitle() && book.getTitle().equalsIgnoreCase("Quest Book")){
			
			//Open zeh quest book!
			inHand.setItemMeta(SetQuestBookPages(epicPlayer, book));
		}
	}
}
 
开发者ID:Randehh,项目名称:EpicQuest,代码行数:19,代码来源:OpenBookListener.java


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