Solved PlayerInteractEvent doesn't work properly!

Discussion in 'Plugin Development' started by ChristolisTV, May 2, 2016.

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

    ChristolisTV

    I am trying to create a Speed Booster for my server. But for some reason it only Disables it. If you would like to help me there is my code:

    Code:Java
    1.  
    2. @EventHandler
    3. public void interactEvent(PlayerInteractEvent event) {
    4. boolean slimeballboolean = false;
    5. Player player = event.getPlayer();
    6. if(player.getItemInHand().getType().equals(Material.SLIME_BALL)) {
    7. if(event.getAction() == Action.RIGHT_CLICK_AIR) {
    8. if(slimeballboolean) {
    9. slimeballboolean = true;
    10. player.setWalkSpeed(0.5f);
    11. sendActionBar(player, "&fSpeed booster&a Enabled&f!");
    12. }
    13. else if(!slimeballboolean) {
    14. slimeballboolean = false;
    15. player.setWalkSpeed(0.2f);
    16. sendActionBar(player, "&fSpeed booster&4 Disabled&f!");
    17. }
    18. }
    19. }
    20. }
    21.  
     
    Last edited: May 3, 2016
  2. Offline

    Kharte321

    Can U Please Put Your Whole Code Or Your OnEnable In Here
     
  3. Offline

    Zombie_Striker

    You placed this variable (which should be a field) in the wrong place. Make the variable a field and that should fix the problem.

    BTW:
    This "Speedboost" is actally slower than base minecraft's speed. The normal speed is 1.
     
  4. Offline

    ChristolisTV

Thread Status:
Not open for further replies.

Share This Page