Solved Enable/Disable Fly

Discussion in 'Plugin Development' started by Mjhurtado1, Sep 4, 2014.

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

    Mjhurtado1

    What I want to happen: When you go in water with Diamond boots, then you speed up/your fly is enabled. When you come out of the water your fly is disabled.

    What happens instead: Nothing.

    There is nothing in the console, I'm a little confused.

    Code:java
    1. package us.xblaze.BoomArrows;
    2.  
    3. import org.bukkit.GameMode;
    4. import org.bukkit.Location;
    5. import org.bukkit.Material;
    6. import org.bukkit.enchantments.Enchantment;
    7. import org.bukkit.entity.Fireball;
    8. import org.bukkit.entity.Player;
    9. import org.bukkit.event.EventHandler;
    10. import org.bukkit.event.Listener;
    11. import org.bukkit.event.entity.EntityShootBowEvent;
    12. import org.bukkit.event.player.PlayerMoveEvent;
    13. import org.bukkit.plugin.java.JavaPlugin;
    14.  
    15. public class Main extends JavaPlugin implements Listener{
    16.  
    17.  
    18. public void onEnable(){
    19. getServer().getPluginManager().registerEvents(this, this);
    20. }
    21.  
    22.  
    23. @EventHandler
    24. public void inWater(PlayerMoveEvent e){
    25.  
    26. Material m = e.getPlayer().getLocation().getBlock().getType();
    27. Player p = e.getPlayer();
    28. if(m == Material.WATER || m == Material.STATIONARY_WATER){
    29. if(p.getGameMode().equals( GameMode.SURVIVAL)){
    30. if(p.getInventory().getBoots() != null){
    31. if(p.getInventory().getBoots().getType() == Material.DIAMOND_BOOTS){
    32. if(!p.hasPermission("bypass.fastswimming")){
    33. p.setAllowFlight(true);
    34. p.setFlying(true);
    35. }
    36. }else{
    37. if(!p.hasPermission("bypass.fastswimming")){
    38. p.setAllowFlight(false);
    39. p.setFlying(false);
    40. }
    41. }
    42. }
    43. }
    44. }else{
    45. if(!p.hasPermission("bypass.fastswimming")){
    46. p.setAllowFlight(false);
    47. p.setFlying(false);
    48. return;
    49. }
    50. }
    51.  
    52. }



    And yes, I also went over my YML file 10 times, its perfect, and it says the plugin is enabled in /plugins

    Having some trouble, so any help would be appreciated!
     
  2. Offline

    GameplayJDK

    Mjhurtado1 First try to add debug messages, e.g. System.out.println("I'm in if statement no. 1/2/3/..etc"); and check if the p.setFlying stuff is reached. (The player location is normally relative to the players head, so if you'd like to check if the players legs are inside the solid/stationary water block, you'd have to subtract 1 from y of the location).
     
  3. Offline

    Mjhurtado1

    It seems like the problem is where I have if(!p.hasPermission("bypass.fastswimming")){}

    Problem solved! :D Thanks!

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 10, 2016
  4. Offline

    ChipDev

    Im just wondering what you did ;)
     
  5. Offline

    Mjhurtado1

    It was reeeaaaal stupid of me, I was OP, apparently when your OP you get all the perms by default, so, I put a System.out.println("I bypassed the fastswimming perm, was this suppose to happen?") ; it happened.

    I learned a lot in this one day tho, so I guess its for the best haha

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 10, 2016
    ChipDev likes this.
  6. Offline

    Flash_Cow

    if u use essentials:
    Node:
    - essentials.fly
    --------------------------
    to use fly in game /fly
     
  7. Flash_Cow This is for people who are making their own plugins, and your answer isn't really relevant to the question. :)
     
    es359 likes this.
Thread Status:
Not open for further replies.

Share This Page