Dazing/stunning a player?

Discussion in 'Plugin Development' started by theguynextdoor, Jan 22, 2012.

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

    theguynextdoor

    I was wondering if it would be possible to daze or stun a player for a second or 2.

    I had a quick think and the only 2 ways i could think of were,

    1) Add them to an array list and then check on player move if they are in the array list and cancel the move event, and use bukkit scheduler to take the player out of the array list

    2) teleport them to the same location (a couple of times?).

    Other than those ways i don't know exactly how i would stun or daze a player. Any ideas on a better way to do this?
     
  2. Offline

    tomjw64

    Maybe use some MobEffects, some of them really mess with player sight and speed and will give you the stunning effect you want.
     
    iKeirNez likes this.
  3. Offline

    hammale

    Check out my DrugMeUp over @ bukkitDev. It's open src and u can probably find something there that wrks :D
     
    iKeirNez likes this.
  4. Offline

    DomovoiButler

    Code:Java
    1. Map<Player, Long> tsbs = new HashMap()<Player, Long>; //timeStartedBeingStunned
    2.  
    3.  
    4. public void someMethodThatAddsPlayerToTheHashMap(){
    5. if(somethingSomething){
    6. tsbs.add(entityPlayer, System.currentTimeMillis())
    7. }
    8. }
    9.  
    10. public void onPlayerMove(PlayerMoveEvent e){
    11. if(tsbs.containsKey(e.getPlayer())){
    12. if(stunFor==1){
    13. if(System.currentTimeMillis>(tsbs.get(e.getPlayer)+1000)){
    14. tsbs.remove(e.getPlayer());
    15. return;
    16. }
    17. e.setCancelled(true);
    18. }else if(stunFor==2){
    19. if(System.currentTimeMillis>(tsbs.get(e.getPlayer)+2000)){
    20. tsbs.remove(e.getPlayer());
    21. return;
    22. }
    23. e.setCancelled(true);
    24. }
    25. }
    26. }


    havent tested it but im trying to say, just use hashmaps
     
  5. Offline

    theguynextdoor

    Your plugin sure has some nice effects, maybe abit OP for my use. But i do say i will keep some of them in mind for later use. I love the blind one.

    For now i will simply set the players pitch to 90 or -90, that should mess with the player enough during combat.
     
  6. Offline

    hammale

    lol yeah :p
     
Thread Status:
Not open for further replies.

Share This Page