1.10.2 Click on the player you are watching

Discussion in 'Spigot Plugin Development' started by SoCoolMen, Mar 18, 2020.

  1. Hi, i'm french sorry for mistakes.
    I'm new in plugin dev and I make a games, but I need to create a vote system and for that I would like a system when you look a player and you right click on him he have one more vote.
    I don't have idea how to use vector and get player.
    Thanks :)
  2. Create a Map<UUID, UUID> and on PlayerInteractEvent do a scan with player.getTargetEntity(). If you don't need more than normal range, let the trigger be PlayerInteractAtEntityEvent.
    The map represents key UUID of the player who voted, and value UUID of who he voted for. To get the total votes on a specific UUID, simply loop through map.values() and increment if UUID matches.
  3. Nice thanks i look for that !
  4. I don't have getTargetEntity() ?
  5. My bad, seems to be a paper-only feature. PlayerInteractAtEntityEvent is not though.
    A getTargetEntity-function is not that hard to implement since you have getNearbyEntities(x, y, z):
    base = the players eye location.
    e = the entity location
    So e - base will give you a vector, which you then can normalize and compare to the players direction.
  6. Oh ok but i'm bad in vector lol, isn't possible with
    PlayerInteractAtEntityEvent with high range?