Solved Fly Plugin

Discussion in 'Plugin Development' started by ollinator01, Aug 23, 2016.

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

    ollinator01

    Last edited: Aug 23, 2016
  2. Offline

    timtower Administrator Administrator Moderator

  3. @ollinator01
    It's a rather obvious problem if the plugin is supposed to make users fly, because right now all it does is let people fly, not make them fly.
     
  4. Offline

    ollinator01

    @timtower
    I mean that i failed as i programm the Plugin.
    @AlvinB
    It should make users fly.
     
  5. @InstanceofDeath
    While that does look nicer, yes, it is not the problem and it should work just fine with it.

    @ollinator01
    You might want to have a look at the "setFlying()" method.
     
  6. Offline

    ollinator01

  7. Offline

    InstanceofDeath

    Its a Yaml file .. formatting is required

    description point has to many spaces - wrote the exact same thing in german xD

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
  8. @InstanceofDeath
    No, if you put that original file through a yaml parser, you will see it works just fine. Here's a yaml parser to prove my point:
    http://yaml-online-parser.appspot.com/

    @ollinator01
    Oh, I forgot to mention that you both need to "setAllowFlight()" and "setFlying()". After all, you can't make someone fly if they aren't allowed to.
     
  9. Offline

    ollinator01

  10. @ollinator01
    Oh, what do you mean by "doesn't work"? Are there any errors in console?
     
  11. Offline

    ArsenArsen

    Don't blind cast, remove onEnable and onDisable, they do nothing and bukkit logs plugins enable and disable for you.
     
  12. Offline

    ollinator01

  13. Offline

    playmaker247

    Try: player.setAllowFlight(isEnabled()); it worked for me
    You also might want to check if the player is already flying
     
    ollinator01 likes this.
  14. Code:
        public boolean onCommand(CommandSender sender, Command cmd, String lable, String[] args){
      
            Player p = (Player) sender;
      
            if(cmd.getName().equalsIgnoreCase("fly")) {
          
                p.setAllowFlight(true);
                p.sendMessage("§2Du kannst du nun fliegen!");
    [INDENT]        }[/INDENT]
          
            return true;
        }
    }
    to:

    Code:
      public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
         if (cmd.getName().equalsIgnoreCase("fly")) {
           //Always check perms! We don't want everyone to be able to do /fly, Unless you do.
           if (!sender.hasPermission("permission.flt")){
             sender.sendMessage(ChatColor.RED + "You don't have permission to do this!");
             return true;
           } else {
             Player p = (Player)sender;
             //If the player is not already in /fly, We want them to be able to fly again.
             if (!p.isFlying()) {
               p.setAllowFlight(true);
               p.setFlying(true);
               p.sendMessage(ChatColor.AQUA + "Flying mode set to true!");
               return true;
             } else {
               //If the player is already in /fly, We should disable there flight.
               p.setAllowFlight(false);
               p.setFlying(false);
               p.sendMessage(ChatColor.AQUA + "Flying mode set to false!");
               return true;
               /*
                * Obviously add all checks
                * Like if the sender is a
                * Player and things like
                * that... Please don't copy
                * This code, Because I have
                * not tried it and am not
                * sure if it works. Thanks.
                */
             }
           }
         }
         return false;
       }
    
    
    Obviously I just made this on the spot, And did not test it. So I'd recommend not copy and pasting this code. It was just to give an example. Remember to add all checks also such as if the sender is a Player and things like that.

    EDIT: Could we have a server log? Also... How do you make it defined as Java code? I like the black look of it, But have never knew how to define the Language.
     
    Last edited: Aug 24, 2016
    ollinator01 likes this.
  15. Offline

    ollinator01

  16. Offline

    N00BHUN73R

    @Mindlessmink
    Offtopic:
    Code:java
    1.  
    2. This is dark? :p
    3. Using syntax=java tags.
    4.  


    Anyways, On-Topic:
    @ollinator01
    Try out what Mindless gave you, if it doesn't work, show us your server console because something's not right
     
  17. Offline

    ollinator01

    @N00BHUN73R

    Code:
    package me.fliegen;
    
    import org.bukkit.Bukkit;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandExecutor;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    
    public class Fliegen implements CommandExecutor  {
    
        @Override
        public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
    
            if(command.getName().equalsIgnoreCase("fliegen")){
                if(sender instanceof Player){
                    Player p = (Player)sender;
                    if(p.hasPermission("per.fliegen")){
                        if(args.length == 0){
                           
                            p.setAllowFlight(true);
                            p.setFlying(true);
                            p.sendMessage("§bDu kannst jetzt fliegen!");
                           
                        } else if (args.length == 1) {
                           
                            Player target = Bukkit.getPlayer(args[0]);
                            if(target != null) {
                               
                                target.setAllowFlight(true);
                                target.setFlying(true);
                                target.sendMessage("§aDer Spieler §6" +target.getName()+ "§a kann jetzt fliegen!");
                               
                            } else {
                                p.sendMessage("§cDer Spieler §4" + args[0] + "§c ist nicht auf dem Server!" );
                            }   
                        } else {
                            p.sendMessage("§cBitte benutze nur §6/fliegen <Spieler>§c!");
                        }
                    } else {
                        p.sendMessage("§4Dazu hast du keine Rechte!");
                    }
                }
            }
               
            return false;}
    }
    Code:
    package me.implement;
    
    import org.bukkit.plugin.java.JavaPlugin;
    
    import me.fliegen.Fliegen;
    
    public class IFliegen extends JavaPlugin {
       
        public void onEnable(){
           
            this.getCommand("fliegen").setExecutor(new Fliegen());
           
            System.out.println("§2Das Plugin wurde erfolgreich gestartet");
        }
    
    }
    
    Code:
    main: me.fliegen.Fliegen
    version: 1.0
    name: Fliegen
    author: Oliver
    
    commands:
      fliegen:
        description: Laesst dich fliegen!
        usage: /fliegen <command>
        aliases: [f, fl]
    The Console:
    http://pastebin.com/Yn0DkzpA
     
  18. @N00BHUN73R Oh.. Sorry I was off-topic. I was just curious :3
     
  19. Offline

    N00BHUN73R

    @ollinator01
    PHP:
    Could not load 'plugins\Fly.jar' in folder 'plugins'
    org.bukkit.plugin.InvalidDescriptionExceptionInvalid plugin.yml
    As you can see, your plugin.yml is not formatted correctly.,
    Make sure you used no tabs and only spaces, (4 spaces for a "tab")

    Scratch all of that, I just found the real error
    PHP:
    Could not load 'plugins\Fliegen.jar' in folder 'plugins'
    org.bukkit.plugin.InvalidPluginExceptionmain class `me.fliegen.Fliegen' does n
    ot extend JavaPlugin
    Fliegen does not extend JavaPlugin, which it needs to in order for it to run.

    So change,
    me.fliegen.Fliegen
    to
    me.fliegen.IFliegen
     
    Last edited: Aug 24, 2016
  20. Offline

    ollinator01

  21. @ollinator your class does not implement CommandExecutor.

    A lot of replies but no one found this :'(

    @Mindlessmink also, bukkit by default checks perms, so remove that note to prevent confusion.
     
  22. Offline

    timtower Administrator Administrator Moderator

    @TheEnderCrafter9
    Code:
    public class Fliegen implements CommandExecutor {
    It does though, and else setExecutor would have complained
     
  23. @timtower I was looking at the pastebin files. :p

    @ollinator1 could you post the files you are using again?
     
  24. Offline

    ollinator01

  25. @ollinator01
    The problem here is that you specify the path in the plugin.yml to be "me.fliegen.IFliegen" while the actual path is "me.implement.IFliegen".

    I recommend you change these paths as they are incredibly confusing, and in different packages. Also, the package name should be "me.<your username>.<your plugin name>".
     
  26. Offline

    ollinator01

    Hmm nothing happened @AlvinB , i have now me.Oliver.Fliegen
     
  27. @ollinator01
    Show us the updated main class, aswell as the plugin.yml
     
  28. Offline

    ollinator01

  29. @ollinator01
    Again, the package names don't match up. In the plugin.yml you say the Main Class is "me.Oliver.Fliegen" while the actual name is "me.implement.IFliegen". Both of these paths need to be the same, otherwise your plugin won't work.
     
  30. Offline

    ollinator01

    Ohh ok now XD Ok thank you so much!
     
Thread Status:
Not open for further replies.

Share This Page