當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。