Need to refresh a timer when player hits the ground. [Not working]

Discussion in 'Plugin Development' started by 22vortex22, Dec 30, 2013.

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

    22vortex22

    Hey guys, I am currently working on a project that requires a player's cooldown to be reset when they hit the ground. Currently I know I am doing it wrong and this glitch keeps happening because of it.




    Here is the code that it uses.

    Code:java
    1. @EventHandler
    2. public void OnPlayerRocket(PlayerInteractEvent event){
    3. Player player = event.getPlayer();
    4. if (!plugin.Jiggly.contains(player.getName())){
    5. if(player.getExp() == 1f){
    6. if((event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() ==Action.RIGHT_CLICK_BLOCK) && player.getItemInHand().getType() == Material.FIREWORK){
    7. player.setVelocity(player.getLocation().getDirection()
    8. .multiply(1.05).setY(.9));
    9. player.setExp(0.50F);
    10. plugin.RocketCooldown2.add(player.getName());
    11. }
    12. }
    13. else if(plugin.RocketCooldown2.contains(player.getName()) && player.getExp() == 0.5f){
    14. if((event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() ==Action.RIGHT_CLICK_BLOCK) && player.getItemInHand().getType() == Material.FIREWORK){
    15. player.setVelocity(player.getLocation().getDirection()
    16. .multiply(1.05).setY(.9));
    17. player.setExp(0);
    18. }
    19. }
    20. }
    21. else if (plugin.Jiggly.contains(player.getName())){
    22. if(player.getExp() == 1f){
    23. if((event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() ==Action.RIGHT_CLICK_BLOCK) && player.getItemInHand().getType() == Material.FIREWORK){
    24. player.setVelocity(player.getLocation().getDirection()
    25. .multiply(1.025).setY(.45));
    26. player.setExp(.80F);
    27. }
    28. }
    29. else if(player.getExp() == .80F){
    30. if((event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() ==Action.RIGHT_CLICK_BLOCK) && player.getItemInHand().getType() == Material.FIREWORK){
    31. player.setVelocity(player.getLocation().getDirection()
    32. .multiply(1.025).setY(.45));
    33. player.setExp(.60F);
    34. }
    35. }
    36. else if(player.getExp() == .60F){
    37. if((event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() ==Action.RIGHT_CLICK_BLOCK) && player.getItemInHand().getType() == Material.FIREWORK){
    38.  
    39. player.setVelocity(player.getLocation().getDirection()
    40. .multiply(1.025).setY(.45));
    41. player.setExp(.40F);
    42. }
    43. }
    44. else if(player.getExp() == .40F){
    45. if((event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() ==Action.RIGHT_CLICK_BLOCK) && player.getItemInHand().getType() == Material.FIREWORK){
    46. player.setVelocity(player.getLocation().getDirection()
    47. .multiply(1.025).setY(.45));
    48. player.setExp(.20F);
    49. }
    50. }
    51. else if(player.getExp() == .20F){
    52. if((event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() ==Action.RIGHT_CLICK_BLOCK) && player.getItemInHand().getType() == Material.FIREWORK){
    53. player.setVelocity(player.getLocation().getDirection()
    54. .multiply(1.025).setY(.45));
    55. player.setExp(0);
    56. }
    57. }
    58. }
    59.  
    60. }
    61.  
    62. int time;
    63. @EventHandler
    64. public void OnGround(PlayerMoveEvent e){
    65. final Player p = e.getPlayer();
    66. Bukkit.getServer().getScheduler().runTaskLater(plugin, new Runnable()
    67. {
    68. @Override
    69. public void run(){
    70. if(p.getLocation().add(0,-1,0).getBlock().getType() != Material.AIR){
    71. p.setExp(1);
    72. plugin.Carrot2.remove(p.getName());
    73.  
    74. }
    75. }
    76. }
    77. ,3L);


    If you think you can help me fix this please reply or add me as a contact on skype: twistex222

    Bump please? This is somewhat urgent.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 6, 2016
Thread Status:
Not open for further replies.

Share This Page