当前位置: 首页>>代码示例>>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;未经允许,请勿转载。