當前位置: 首頁>>代碼示例>>Java>>正文


Java PlayerInteractEntityEvent.getHand方法代碼示例

本文整理匯總了Java中org.bukkit.event.player.PlayerInteractEntityEvent.getHand方法的典型用法代碼示例。如果您正苦於以下問題:Java PlayerInteractEntityEvent.getHand方法的具體用法?Java PlayerInteractEntityEvent.getHand怎麽用?Java PlayerInteractEntityEvent.getHand使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.bukkit.event.player.PlayerInteractEntityEvent的用法示例。


在下文中一共展示了PlayerInteractEntityEvent.getHand方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onItemFrameClick

import org.bukkit.event.player.PlayerInteractEntityEvent; //導入方法依賴的package包/類
@SuppressWarnings("deprecation")
   @EventHandler
public void onItemFrameClick(PlayerInteractEntityEvent event) {
	if (event.getPlayer().getGameMode() == GameMode.CREATIVE) {
		return;
	}
	// this prevents the journal from being placed inside of item frame
	if (event.getRightClicked() instanceof ItemFrame) {
		ItemStack item = null;
		try {
		    item = (event.getHand() == EquipmentSlot.HAND) ? event.getPlayer().getInventory().getItemInMainHand() : event.getPlayer().getInventory().getItemInOffHand();
		} catch (LinkageError e) {
		    item = event.getPlayer().getItemInHand();
		}
		String playerID = PlayerConverter.getID(event.getPlayer());
		if (Journal.isJournal(playerID, item) || Utils.isQuestItem(item)) {
			event.setCancelled(true);
		}
	}
}
 
開發者ID:Co0sh,項目名稱:BetonQuest,代碼行數:21,代碼來源:QuestItemHandler.java

示例2: onPlayerInteractEntityEvent

import org.bukkit.event.player.PlayerInteractEntityEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerInteractEntityEvent(PlayerInteractEntityEvent event) {
	// On Minecraft versions from 1.9 onwards, this event is fired twice, one for each hand. Need additional check.
	if (version >= 9 && event.getHand() != EquipmentSlot.HAND) {
		return;
	}

	if (!(event.getRightClicked() instanceof Tameable) || ((Tameable) event.getRightClicked()).getOwner() == null
			|| !plugin.getEnableDisableCommand().isEnabled()) {
		return;
	}

	AnimalTamer currentOwner = ((Tameable) event.getRightClicked()).getOwner();
	// Has the player clicked on one of his own pets?
	boolean isOwner = event.getPlayer().getName().equals(currentOwner.getName());
	// Retrieve new owner from the map and delete corresponding entry.
	Player newOwner = plugin.getSetOwnerCommand().collectPendingSetOwnershipRequest(event.getPlayer());
	// Has the player requested to free one of his pets?
	boolean freePet = plugin.getFreeCommand().collectPendingFreeRequest(event.getPlayer());

	// Cannot change ownership or free pet if not owner and no bypass permission.
	if ((newOwner != null || freePet) && !isOwner && !event.getPlayer().hasPermission("petmaster.admin")) {
		event.getPlayer().sendMessage(plugin.getChatHeader() + plugin.getPluginLang()
				.getString("not-owner", "You do not own this pet!").replace("PLAYER", event.getPlayer().getName()));
		return;
	}

	if (newOwner != null) {
		changeOwner(event, currentOwner, newOwner);
	} else if (freePet) {
		freePet(event, currentOwner);
	} else if ((displayToOwner || !isOwner) && event.getPlayer().hasPermission("petmaster.showowner")) {
		displayHologramAndMessage(event, currentOwner);
	}
}
 
開發者ID:PyvesB,項目名稱:PetMaster,代碼行數:36,代碼來源:PlayerInteractListener.java

示例3: onPlayerClickPlayer

import org.bukkit.event.player.PlayerInteractEntityEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.HIGH)
public void onPlayerClickPlayer(PlayerInteractEntityEvent event) {
	if(ConfigManager.getServerVersion().isNewerThan(ConfigManager.ServerVersion.MINECRAFT_1_8_R3) && event.getHand() == EquipmentSlot.OFF_HAND) {
		return;
	}

	Player player = event.getPlayer();
	if((event.getRightClicked() instanceof Player) && player.isSneaking()) {
		if(Permission.NOVAGUILDS_PLAYERINFO.has(player)) {
			NovaPlayer nCPlayer = PlayerManager.getPlayer(event.getRightClicked());
			plugin.getPlayerManager().sendPlayerInfo(player, nCPlayer);
		}
	}
}
 
開發者ID:MarcinWieczorek,項目名稱:NovaGuilds,代碼行數:15,代碼來源:PlayerInfoListener.java

示例4: ItemEntityInteractEvent

import org.bukkit.event.player.PlayerInteractEntityEvent; //導入方法依賴的package包/類
public ItemEntityInteractEvent(PlayerInteractEntityEvent evt) {
    this(evt.getPlayer(), evt.getHand(), ItemUsage.RIGHT_CLICK_ENTITY, evt);
}
 
開發者ID:Kneesnap,項目名稱:Kineticraft,代碼行數:4,代碼來源:ItemEntityInteractEvent.java

示例5: isMainHandInteraction

import org.bukkit.event.player.PlayerInteractEntityEvent; //導入方法依賴的package包/類
@Override
public boolean isMainHandInteraction(PlayerInteractEntityEvent event) {
	return event.getHand() == EquipmentSlot.HAND;
}
 
開發者ID:nisovin,項目名稱:Shopkeepers,代碼行數:5,代碼來源:NMSHandler.java


注:本文中的org.bukkit.event.player.PlayerInteractEntityEvent.getHand方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。