org.bukkit.event.player.PlayerInteractEntityEvent Java Examples

The following examples show how to use org.bukkit.event.player.PlayerInteractEntityEvent. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: EventRuleMatchModule.java    From ProjectAres with GNU Affero General Public License v3.0 7 votes vote down vote up
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void checkItemFrameRotate(PlayerInteractEntityEvent event) {
    if(event.getRightClicked() instanceof ItemFrame) {
        ItemFrame itemFrame = (ItemFrame) event.getRightClicked();
        if(itemFrame.getItem() != null) {
            // If frame contains an item, right-click will rotate it, which is handled as a "use" event
            this.handleUse(event, getHangingBlockState(itemFrame), this.match.getParticipant(event.getPlayer()));
        } else if(event.getPlayer().getItemInHand() != null) {
            // If the frame is empty and it's right clicked with an item, this will place the item in the frame,
            // which is handled as a "place" event, with the placed item as the block material
            BlockState blockState = BlockStateUtils.cloneWithMaterial(itemFrame.getLocation().getBlock(),
                                                                      event.getPlayer().getItemInHand().getData());
            this.handleHangingPlace(event, blockState, event.getPlayer());
        }
    }
}
 
Example #2
Source File: TNTSheepListener.java    From BedWars with GNU Lesser General Public License v3.0 6 votes vote down vote up
@EventHandler
public void onTNTSheepInteractOtherUser(PlayerInteractEntityEvent event) {
    Player player = event.getPlayer();
    if (Main.isPlayerInGame(player)) {
        GamePlayer gamePlayer = Main.getPlayerGameProfile(player);
        Game game = gamePlayer.getGame();

        Entity rightClicked = event.getRightClicked();
        Entity vehicle = rightClicked.getVehicle();
        List<SpecialItem> sheeps = game.getActivedSpecialItems(TNTSheep.class);
        for (SpecialItem item : sheeps) {
            if (item instanceof TNTSheep) {
                TNTSheep sheep = (TNTSheep) item;
                if (sheep.getEntity().equals(rightClicked) || sheep.getEntity().equals(vehicle)) {
                    event.setCancelled(true);
                    return;
                }
            }
        }
    }
}
 
Example #3
Source File: ExhibitionListener.java    From NyaaUtils with MIT License 6 votes vote down vote up
@EventHandler(priority = HIGHEST, ignoreCancelled = true)
public void onPlayerInteractItemFrame(PlayerInteractEntityEvent ev) {
    if (!(ev.getRightClicked() instanceof ItemFrame)) return;
    ItemFrame f = (ItemFrame) ev.getRightClicked();
    if (f.getItem() == null || f.getItem().getType() == Material.AIR) return;
    ExhibitionFrame fr = ExhibitionFrame.fromItemFrame(f);
    if (fr.isSet()) {
        new Message(I18n.format("user.exhibition.looking_at")).append(fr.getItemInFrame()).send(ev.getPlayer());
        ev.getPlayer().sendMessage(I18n.format("user.exhibition.provided_by", fr.getOwnerName()));
        for (String line : fr.getDescriptions()) {
            ev.getPlayer().sendMessage(line);
        }
        ev.setCancelled(true);
        if (fr.hasItem() && fr.getItemInFrame().getType() == Material.WRITTEN_BOOK) {
            ev.getPlayer().openBook(fr.getItemInFrame());
        }
    }
}
 
Example #4
Source File: StickInteractEvent.java    From StackMob-3 with GNU General Public License v3.0 6 votes vote down vote up
@EventHandler
public void onStickInteract(PlayerInteractEntityEvent event){
    Player player = event.getPlayer();
    Entity entity = event.getRightClicked();
    if(!(entity instanceof Mob)){
        return;
    }
    if(event.getHand() != EquipmentSlot.HAND) {
        return;
    }
    if (sm.getStickTools().isStackingStick(player.getInventory().getItemInMainHand())) {
        if (player.isSneaking()) {
            sm.getStickTools().toggleMode(player);
        } else {
            if(!(StackTools.hasValidMetadata(player, GlobalValues.STICK_MODE))){
                player.setMetadata(GlobalValues.STICK_MODE, new FixedMetadataValue(sm, 1));
            }
            sm.getStickTools().performAction(player, entity);
        }
    }
}
 
Example #5
Source File: PetOwnerListener.java    From SonarPet with GNU General Public License v3.0 6 votes vote down vote up
@EventHandler
public void onPlayerInteractEntity(PlayerInteractEntityEvent event) {
    Player p = event.getPlayer();
    Entity e = event.getRightClicked();
    if (p.getItemInHand() != null && p.getItemInHand().isSimilar(SelectorLayout.getSelectorItem())) {
        SelectorLayout.getSelectorMenu().showTo(p);
        event.setCancelled(true);
        return;
    }

    if (ReflectionUtil.getEntityHandle(e) instanceof IEntityPet) {
        IPet pet = ((IEntityPet) ReflectionUtil.getEntityHandle(e)).getPet();
        event.setCancelled(true);
        PetInteractEvent iEvent = new PetInteractEvent(pet, p, PetInteractEvent.Action.RIGHT_CLICK, false);
        EchoPet.getPlugin().getServer().getPluginManager().callEvent(iEvent);
        if (!iEvent.isCancelled()) {
            pet.getEntityPet().onInteract(p);
            return;
        }
    }
}
 
Example #6
Source File: KissCommand.java    From MarriageMaster with GNU General Public License v3.0 6 votes vote down vote up
@EventHandler
public void onPlayerInteractEntity(PlayerInteractEntityEvent event)
{
	if((!MCVersion.isDualWieldingMC() || event.getHand().equals(EquipmentSlot.HAND)) && event.getPlayer().isSneaking() && event.getPlayer().hasPermission(Permissions.KISS) && event.getRightClicked() instanceof Player)
	{
		MarriagePlayer player = getMarriagePlugin().getPlayerData(event.getPlayer());
		Long time = wait.get(player);
		if(time == null || time < System.currentTimeMillis() - waitTime)
		{
			MarriagePlayer player2 = getMarriagePlugin().getPlayerData((Player) event.getRightClicked());
			if(player.isPartner(player2) && getMarriagePlugin().isInRangeSquared(event.getPlayer(), (Player) event.getRightClicked(), interactRange))
			{
				kiss(player, player2);
			}
		}
	}
}
 
Example #7
Source File: PlayerListener.java    From BedwarsRel with GNU General Public License v3.0 6 votes vote down vote up
@EventHandler
public void onInteractEntity(PlayerInteractEntityEvent iee) {
  Player p = iee.getPlayer();
  Game g = BedwarsRel.getInstance().getGameManager().getGameOfPlayer(p);
  if (g == null) {
    return;
  }

  if (g.getState() == GameState.WAITING) {
    iee.setCancelled(true);
    return;
  }

  if (g.getState() == GameState.RUNNING) {
    this.inGameInteractEntity(iee, g, p);
  }
}
 
Example #8
Source File: EntityListener.java    From RedProtect with GNU General Public License v3.0 6 votes vote down vote up
@EventHandler(ignoreCancelled = true)
public void onInteractEvent(PlayerInteractEntityEvent e) {
    RedProtect.get().logger.debug(LogLevel.ENTITY, "EntityListener - Is PlayerInteractEntityEvent");

    Player p = e.getPlayer();
    if (p == null) {
        return;
    }
    Location l = e.getRightClicked().getLocation();
    Region r = RedProtect.get().rm.getTopRegion(l);
    Entity et = e.getRightClicked();
    if (r != null && !r.canInteractPassives(p) && (et instanceof Animals || et instanceof Villager || et instanceof Golem || (et instanceof WaterMob && !r.canFish(p)))) {
        if (et instanceof Tameable) {
            Tameable tam = (Tameable) et;
            if (tam.isTamed() && tam.getOwner() != null && tam.getOwner().getName().equals(p.getName())) {
                return;
            }
        }
        e.setCancelled(true);
        RedProtect.get().lang.sendMessage(p, "entitylistener.region.cantinteract");
    }
}
 
Example #9
Source File: QuestItemHandler.java    From BetonQuest with GNU General Public License v3.0 6 votes vote down vote up
@EventHandler(ignoreCancelled = true)
public void onItemFrameClick(final 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;
        item = (event.getHand() == EquipmentSlot.HAND) ? event.getPlayer().getInventory().getItemInMainHand()
                : event.getPlayer().getInventory().getItemInOffHand();

        final String playerID = PlayerConverter.getID(event.getPlayer());
        if (Journal.isJournal(playerID, item) || Utils.isQuestItem(item)) {
            event.setCancelled(true);
        }
    }
}
 
Example #10
Source File: TNTSheepListener.java    From BedWars with GNU Lesser General Public License v3.0 6 votes vote down vote up
@EventHandler
public void onTNTSheepInteractOtherUser(PlayerInteractEntityEvent event) {
    Player player = event.getPlayer();
    if (Main.isPlayerInGame(player)) {
        GamePlayer gamePlayer = Main.getPlayerGameProfile(player);
        Game game = gamePlayer.getGame();

        Entity rightClicked = event.getRightClicked();
        Entity vehicle = rightClicked.getVehicle();
        List<SpecialItem> sheeps = game.getActivedSpecialItems(TNTSheep.class);
        for (SpecialItem item : sheeps) {
            if (item instanceof TNTSheep) {
                TNTSheep sheep = (TNTSheep) item;
                if (sheep.getEntity().equals(rightClicked) || sheep.getEntity().equals(vehicle)) {
                    event.setCancelled(true);
                    return;
                }
            }
        }
    }
}
 
Example #11
Source File: TestIronGolemListener.java    From Slimefun4 with GNU General Public License v3.0 6 votes vote down vote up
private PlayerInteractEntityEvent callIronGolemEvent(EquipmentSlot hand, ItemStack itemInHand) {
    // Fake Player with an Iron Ingot
    Player player = server.addPlayer();

    if (hand == EquipmentSlot.HAND) {
        player.getInventory().setItemInMainHand(itemInHand);
    }
    else {
        player.getInventory().setItemInOffHand(itemInHand);
    }

    // Fake Iron Golem
    IronGolem golem = Mockito.mock(IronGolem.class);
    Mockito.when(golem.getType()).thenReturn(EntityType.IRON_GOLEM);

    // Fake Event
    PlayerInteractEntityEvent event = new PlayerInteractEntityEvent(player, golem, hand);
    listener.onIronGolemHeal(event);
    return event;
}
 
Example #12
Source File: TNTSheepListener.java    From BedwarsRel with GNU General Public License v3.0 5 votes vote down vote up
@EventHandler(priority = EventPriority.HIGHEST)
public void onInteractOtherUser(PlayerInteractEntityEvent event) {
  if (event.getPlayer() == null) {
    return;
  }

  Player player = event.getPlayer();
  Game game = BedwarsRel.getInstance().getGameManager().getGameOfPlayer(player);

  if (game == null) {
    return;
  }

  if (game.getState() != GameState.RUNNING) {
    return;
  }

  if (event.getRightClicked() == null) {
    return;
  }

  if (event.getRightClicked() instanceof ITNTSheep) {
    event.setCancelled(true);
    return;
  }

  if (event.getRightClicked().getVehicle() != null
      && event.getRightClicked().getVehicle() instanceof ITNTSheep) {
    event.setCancelled(true);
    return;
  }
}
 
Example #13
Source File: LivingEntityShopListener.java    From Shopkeepers with GNU General Public License v3.0 5 votes vote down vote up
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = false)
void onEntityInteract(PlayerInteractEntityEvent event) {
	if (!(event.getRightClicked() instanceof LivingEntity)) return;
	LivingEntity shopEntity = (LivingEntity) event.getRightClicked();
	Player player = event.getPlayer();
	String playerName = player.getName();
	Log.debug("Player " + playerName + " is interacting with entity at " + shopEntity.getLocation());
	Shopkeeper shopkeeper = plugin.getShopkeeperByEntity(shopEntity); // also check for citizens npc shopkeepers

	if (event.isCancelled() && !Settings.bypassShopInteractionBlocking) {
		Log.debug("  Cancelled by another plugin");
	} else if (shopkeeper != null) {
		// only trigger shopkeeper interaction for main-hand events:
		if (NMSManager.getProvider().isMainHandInteraction(event)) {
			shopkeeper.onPlayerInteraction(player);
		}

		// if citizens npc: don't cancel the event, let Citizens perform other actions as appropriate
		if (shopkeeper.getShopObject().getObjectType() != DefaultShopObjectTypes.CITIZEN()) {
			// always cancel interactions with shopkeepers, to prevent any default behavior:
			event.setCancelled(true);

			// update inventory in case interaction would trigger feeding normally:
			player.updateInventory();
		}
	} else {
		Log.debug("  Non-shopkeeper");
	}
}
 
Example #14
Source File: CustomItemListener.java    From NBTEditor with GNU General Public License v3.0 5 votes vote down vote up
@EventHandler
private void playerInteractEntity(PlayerInteractEntityEvent event) {
	Player player = event.getPlayer();
	ItemStack item = player.getInventory().getItemInMainHand();
	CustomItem customItem = CustomItemManager.getCustomItem(item);

	if (customItem != null) {
		if (verifyCustomItem(customItem, event.getPlayer(), false)) {
			event.setCancelled(true);
			customItem.onInteractEntity(event, new PlayerDetails(item, event.getPlayer()));
		}
	}
}
 
Example #15
Source File: InteractListener.java    From AnimatedFrames with MIT License 5 votes vote down vote up
public void listenForEntityInteract(Player player, Callback<PlayerInteractEntityEvent> callback) {
	if (callback == null) { return; }
	if (player != null) {
		entityInteractMap.put(player.getUniqueId(), callback);
	} else {
		callback.call(null);
	}
}
 
Example #16
Source File: ObserverModule.java    From CardinalPGM with MIT License 5 votes vote down vote up
@EventHandler(ignoreCancelled = true)
public void onPlayerInteractEntity(PlayerInteractEntityEvent event) {
    if (testObserver(event.getPlayer())) {
        if (event.getRightClicked() instanceof Player && !event.getPlayer().isSneaking()){
            if (event.getHand().equals(EquipmentSlot.HAND)) openInventory(event.getPlayer(), (Player) event.getRightClicked(), false);
        } else if (event.getRightClicked() instanceof ItemFrame) {
            event.setCancelled(true);
        }
    }
}
 
Example #17
Source File: ListenerEntities.java    From CombatLogX with GNU General Public License v3.0 5 votes vote down vote up
@EventHandler(priority= EventPriority.HIGH, ignoreCancelled=true)
public void onInteract(PlayerInteractEntityEvent e) {
    FileConfiguration config = this.expansion.getConfig("cheat-prevention.yml");
    if(!config.getBoolean("prevent-entity-interaction")) return;

    Player player = e.getPlayer();
    ICombatManager manager = this.plugin.getCombatManager();
    if(!manager.isInCombat(player)) return;

    e.setCancelled(true);
    String message = this.plugin.getLanguageMessageColoredWithPrefix("cheat-prevention.no-entity-interaction");
    this.plugin.sendMessage(player, message);
}
 
Example #18
Source File: IronGolemListener.java    From Slimefun4 with GNU General Public License v3.0 5 votes vote down vote up
@EventHandler
public void onIronGolemHeal(PlayerInteractEntityEvent e) {
    if (e.getRightClicked().getType() == EntityType.IRON_GOLEM) {
        PlayerInventory inv = e.getPlayer().getInventory();
        ItemStack item = null;

        if (e.getHand() == EquipmentSlot.HAND) {
            item = inv.getItemInMainHand();
        }
        else if (e.getHand() == EquipmentSlot.OFF_HAND) {
            item = inv.getItemInOffHand();
        }

        if (item != null && item.getType() == Material.IRON_INGOT) {
            SlimefunItem sfItem = SlimefunItem.getByItem(item);

            if (sfItem != null && !(sfItem instanceof VanillaItem)) {
                e.setCancelled(true);
                SlimefunPlugin.getLocalization().sendMessage(e.getPlayer(), "messages.no-iron-golem-heal");

                // This is just there to update the Inventory...
                // Somehow cancelling it isn't enough.
                if (e.getHand() == EquipmentSlot.HAND) {
                    inv.setItemInMainHand(item);
                }
                else if (e.getHand() == EquipmentSlot.OFF_HAND) {
                    inv.setItemInOffHand(item);
                }
            }
        }
    }
}
 
Example #19
Source File: TestIronGolemListener.java    From Slimefun4 with GNU General Public License v3.0 5 votes vote down vote up
@Test
public void testWithIron() {
    // This should heal the Iron Golem
    ItemStack item = new ItemStack(Material.IRON_INGOT);

    PlayerInteractEntityEvent event = callIronGolemEvent(EquipmentSlot.HAND, item);
    Assertions.assertFalse(event.isCancelled());

    PlayerInteractEntityEvent event2 = callIronGolemEvent(EquipmentSlot.OFF_HAND, item);
    Assertions.assertFalse(event2.isCancelled());
}
 
Example #20
Source File: TestIronGolemListener.java    From Slimefun4 with GNU General Public License v3.0 5 votes vote down vote up
@Test
public void testWithSlimefunIron() {
    SlimefunItem slimefunItem = TestUtilities.mockSlimefunItem(plugin, "SLIMEFUN_IRON", new CustomItem(Material.IRON_INGOT, "&cSlimefun Iron"));
    slimefunItem.register(plugin);

    // The Event should be cancelled, we do not wanna use Slimefun Items for this
    PlayerInteractEntityEvent event = callIronGolemEvent(EquipmentSlot.HAND, slimefunItem.getItem());
    Assertions.assertTrue(event.isCancelled());

    PlayerInteractEntityEvent event2 = callIronGolemEvent(EquipmentSlot.OFF_HAND, slimefunItem.getItem());
    Assertions.assertTrue(event2.isCancelled());
}
 
Example #21
Source File: EntityInteractObjective.java    From BetonQuest with GNU General Public License v3.0 5 votes vote down vote up
@EventHandler(ignoreCancelled = true)
public void onRightClick(PlayerInteractEntityEvent e) {
    boolean success = onInteract(e.getPlayer(), e.getRightClicked());
    if (success && cancel) {
        e.setCancelled(true);
    }
}
 
Example #22
Source File: EntityNMSSlime.java    From HolographicDisplays with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean damageEntity(DamageSource damageSource, float amount) {
	if (damageSource instanceof EntityDamageSource) {
		EntityDamageSource entityDamageSource = (EntityDamageSource) damageSource;
		if (entityDamageSource.getEntity() instanceof EntityPlayer) {
			Bukkit.getPluginManager().callEvent(new PlayerInteractEntityEvent(((EntityPlayer) entityDamageSource.getEntity()).getBukkitEntity(), getBukkitEntity())); // Bukkit takes care of the exceptions
		}
	}
	return false;
}
 
Example #23
Source File: EntityNMSSlime.java    From HolographicDisplays with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean damageEntity(DamageSource damageSource, float amount) {
	if (damageSource instanceof EntityDamageSource) {
		EntityDamageSource entityDamageSource = (EntityDamageSource) damageSource;
		if (entityDamageSource.getEntity() instanceof EntityPlayer) {
			Bukkit.getPluginManager().callEvent(new PlayerInteractEntityEvent(((EntityPlayer) entityDamageSource.getEntity()).getBukkitEntity(), getBukkitEntity())); // Bukkit takes care of the exceptions
		}
	}
	return false;
}
 
Example #24
Source File: TestIronGolemListener.java    From Slimefun4 with GNU General Public License v3.0 5 votes vote down vote up
@Test
public void testWithVanillaIron() {
    VanillaItem item = TestUtilities.mockVanillaItem(plugin, Material.IRON_INGOT, true);
    item.register(plugin);

    PlayerInteractEntityEvent event = callIronGolemEvent(EquipmentSlot.HAND, item.getItem());
    Assertions.assertFalse(event.isCancelled());

    PlayerInteractEntityEvent event2 = callIronGolemEvent(EquipmentSlot.OFF_HAND, item.getItem());
    Assertions.assertFalse(event2.isCancelled());
}
 
Example #25
Source File: PlayerInteractListener.java    From PetMaster with GNU General Public License v3.0 5 votes vote down vote up
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerInteractEntityEvent(PlayerInteractEntityEvent event) {
	if (shouldHandleEvent(event)) {
		Tameable tameable = (Tameable) event.getRightClicked();
		AnimalTamer currentOwner = tameable.getOwner();
		if (currentOwner == null || currentOwner.getName() == null) {
			return;
		}
		// Has the player clicked on one of his own pets?
		Player player = event.getPlayer();
		boolean isOwner = player.getUniqueId().equals(currentOwner.getUniqueId());
		// Retrieve new owner from the map and delete corresponding entry.
		Player newOwner = plugin.getSetOwnerCommand().collectPendingSetOwnershipRequest(player);
		// Has the player requested to free one of his pets?
		boolean freePet = plugin.getFreeCommand().collectPendingFreeRequest(player);

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

		if (newOwner != null) {
			changeOwner(player, currentOwner, newOwner, tameable);
		} else if (freePet) {
			freePet(player, currentOwner, tameable);
		} else if ((displayToOwner || !isOwner) && player.hasPermission("petmaster.showowner")) {
			displayHologramAndMessage(player, currentOwner, tameable);
		}
	}
}
 
Example #26
Source File: EntityInspectorTool.java    From NBTEditor with GNU General Public License v3.0 5 votes vote down vote up
@Override
public  void onInteractEntity(PlayerInteractEntityEvent event, PlayerDetails details) {
	Player player = event.getPlayer();
	Entity entity = event.getRightClicked();
	if (EntityNBT.isValidType(entity.getType())) {
		EntityNBT entityNBT = EntityNBT.fromEntity(entity);
		player.sendMessage(ChatColor.YELLOW + "Information about " + EntityTypeMap.getName(entity.getType()) + "");
		for (NBTVariableContainer container : entityNBT.getAllVariables()) {
			player.sendMessage("" + ChatColor.LIGHT_PURPLE + ChatColor.ITALIC + container.getName() + ":");
			for (String name : container.getVariableNames()) {
				String value = container.getVariable(name).get();
				player.sendMessage("  " + ChatColor.AQUA + name + ": " + ChatColor.WHITE + (value != null ? value : ChatColor.ITALIC + "none"));
			}
		}
		player.sendMessage(ChatColor.YELLOW + "Extra information:");

		boolean extra = false;
		if (entityNBT.getEntityType() == EntityType.VILLAGER) {
			player.sendMessage("" + ChatColor.LIGHT_PURPLE + ChatColor.ITALIC + "Trades done:");
			int i = 1;
			for (VillagerOffersVariable.Offer offer : ((VillagerOffersVariable) entityNBT.getVariable("Offers")).getOffers()) {
				player.sendMessage("  " + ChatColor.AQUA + "trade " + i + ": " + ChatColor.WHITE + offer.uses);
				++i;
			}
			extra = true;
		}
		if (!extra) {
			player.sendMessage("none");
		}
		event.setCancelled(true);
	} else {
		player.sendMessage(ChatColor.RED + "Not a valid entity!");
	}
}
 
Example #27
Source File: EntityNMSSlime.java    From HolographicDisplays with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean damageEntity(DamageSource damageSource, float amount) {
	if (damageSource instanceof EntityDamageSource) {
		EntityDamageSource entityDamageSource = (EntityDamageSource) damageSource;
		if (entityDamageSource.getEntity() instanceof EntityPlayer) {
			Bukkit.getPluginManager().callEvent(new PlayerInteractEntityEvent(((EntityPlayer) entityDamageSource.getEntity()).getBukkitEntity(), getBukkitEntity())); // Bukkit takes care of the exceptions
		}
	}
	return false;
}
 
Example #28
Source File: PlayerInfoListener.java    From NovaGuilds with GNU General Public License v3.0 5 votes vote down vote up
@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);
		}
	}
}
 
Example #29
Source File: EntityNMSSlime.java    From HolographicDisplays with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean damageEntity(DamageSource damageSource, float amount) {
	if (damageSource instanceof EntityDamageSource) {
		EntityDamageSource entityDamageSource = (EntityDamageSource) damageSource;
		if (entityDamageSource.getEntity() instanceof EntityPlayer) {
			Bukkit.getPluginManager().callEvent(new PlayerInteractEntityEvent(((EntityPlayer) entityDamageSource.getEntity()).getBukkitEntity(), getBukkitEntity())); // Bukkit takes care of the exceptions
		}
	}
	return false;
}
 
Example #30
Source File: Listeners.java    From PlayerVaults with GNU General Public License v3.0 5 votes vote down vote up
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onInteractEntity(PlayerInteractEntityEvent event) {
    Player player = event.getPlayer();
    EntityType type = event.getRightClicked().getType();
    if ((type == EntityType.VILLAGER || type == EntityType.MINECART) && PlayerVaults.getInstance().getInVault().containsKey(player.getUniqueId().toString())) {
        event.setCancelled(true);
    }
}