Temporary Flying

Discussion in 'Plugin Development' started by 22vortex22, Oct 23, 2013.

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

    22vortex22

    Ok for some reason my bukkit runnables aren't working....


    Code:java
    1. @EventHandler
    2. public void onClickItem1(PlayerInteractEvent event){
    3. final Player player = event.getPlayer();
    4. if(event.getAction().equals(Action.RIGHT_CLICK_AIR) || event.getAction().equals(Action.RIGHT_CLICK_BLOCK)) {
    5. if(event.hasItem() && event.getPlayer().getItemInHand().getType().equals(Material.RED_ROSE)) {
    6.  
    7. if (player.hasPermission("CustomKits.Butterfly")){
    8. if (!plugin.FlyCooldown.contains(player.getName())){
    9. player.setAllowFlight(true);
    10. player.setFlying(true);
    11. player.sendMessage(ChatColor.GOLD + "You are now flying!");
    12. plugin.FlyCooldown.add(player.getName());
    13. Bukkit.getServer().getPluginManager().getPlugin("CustomKits").getServer().getScheduler().scheduleSyncDelayedTask(Bukkit.getServer().getPluginManager().getPlugin("CustomKits"), new Runnable() {
    14. @Override
    15. public void run() {
    16. player.setFlying(false);
    17. player.setAllowFlight(false);
    18. }
    19.  
    20. },15*20);
    21. Bukkit.getServer().getPluginManager().getPlugin("CustomKits").getServer().getScheduler().scheduleSyncDelayedTask(Bukkit.getServer().getPluginManager().getPlugin("CustomKits"), new Runnable() {
    22.  
    23. @Override
    24. public void run() {
    25. plugin.FlyCooldown.remove(player.getName());
    26. player.sendMessage(ChatColor.GOLD + "You may now fly again!");
    27. }
    28.  
    29. },30*20);
    30. }
    31. else player.sendMessage(ChatColor.RED + "You must wait to fly again!");
    32. }
    33. }
    34. }
    35. }
    36. }


    Whats wrong with it
     
  2. Offline

    felixfritz

    If you have saved the plugin as an instance, why are you getting the plugin through the getPlugin method in line 13 and 21 then?

    Is it just not reacting to anything? Do you get any error messages / stack traces?
     
  3. Offline

    22vortex22


    It activates... It gives me fly and then it doesn't every activate the runnables. So I never stop flying. There are no errors at all.
     
Thread Status:
Not open for further replies.

Share This Page