本文整理汇总了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);
}
}
}
示例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);
}
}
示例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);
}
}
}
示例4: ItemEntityInteractEvent
import org.bukkit.event.player.PlayerInteractEntityEvent; //导入方法依赖的package包/类
public ItemEntityInteractEvent(PlayerInteractEntityEvent evt) {
this(evt.getPlayer(), evt.getHand(), ItemUsage.RIGHT_CLICK_ENTITY, evt);
}
示例5: isMainHandInteraction
import org.bukkit.event.player.PlayerInteractEntityEvent; //导入方法依赖的package包/类
@Override
public boolean isMainHandInteraction(PlayerInteractEntityEvent event) {
return event.getHand() == EquipmentSlot.HAND;
}