Spectator target

Discussion in 'Plugin Development' started by skales65, May 7, 2018.

Thread Status:
Not open for further replies.
  1. Offline

    skales65

    Hey guys. I am making plugin, where you play as mob (only move event and tp mob). I have set player's mode spectator, because you can't collide with that mob (mob is pushing player and tp to player again so it is infinite loop. I have tried "setCollidable" but didnt work anytime).

    I wanted to hit player with left click while you are in spectator mode. So question is-
    How to stop setting targeted player as spectator target? Or is there some event that is checking spectator targeting?

    Thanks for your time guys
     
  2. @skales65 There is a change I understand what you are trying to accomplish.

    I never tested this out by I have worked with it.
    Code:
    Player player = //player
    Entity target = //target
    EntityPlayer ep =((CraftPlayer)player).getHandle();
    
    /* Bukkit-1.12  */ ep.setSpectatorTarget(target)
    I hope this is what you are looking for.
    If you have any further questions, I'm willing to help :)
     
  3. Offline

    skales65

    @DanielTheDev
    I want to hit player (or mob) while I am in spectator mode. I have made it threw interact event but it check only click on block or in air(idk if I can do it threw it), not on mob. When you left click mob, you start spectating him. I want to hit him, not start spectating him.
     
  4. @skales65
    Check PlayerInteractEntityEvent and check if the gamemode is spectator if so cancel the event and give the player or mob damage, that could work
     
  5. Offline

    skales65

    @Blackwing_Forged
    I see that in PlayerInteractEntityEvent you can only check right click. It is no problem, but still if player clicks on entity with left button he will start to spectate him. Any ideas how to stop it?
     
  6. @skales65
    Maybe try EntityDamageByEntity see if that triggers then cancel and damage them
     
  7. Offline

    skales65

    @Blackwing_Forged
    I put sendMessage on the beggining of event. Triggered only on right click.
     
Thread Status:
Not open for further replies.

Share This Page