plugin.yml issues

Discussion in 'Plugin Development' started by killeBr, Jan 5, 2020.

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

    killeBr

    I dont know whats wrong, it just gives me error in my console, here is my plugin.yml. Im very new to this sorry.
    =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    Code:
    name: HelloWorld
    version: 1.0
    author: Carsob
    main: me.CarsobWorld.HelloWorld.Main
    description: Speed Command.
    
    commands:
        speed:
          aliases: [speed]
          description: Activated Speed!
          usage: /speed
    -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
     
    Last edited by a moderator: Jan 5, 2020
  2. Online

    timtower Administrator Administrator Moderator

  3. Offline

    killeBr

    ok its posted. Same username

    is there anything wrong with it? because I looked over and it seemed to me the formatting was correctly done. the package name was the same as well

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jan 6, 2020
  4. Online

    timtower Administrator Administrator Moderator

    @killeBr Yeah, you need to link it. Otherwise I won't be able to find it.
     
  5. Offline

    killeBr

    https://pastebin.com/Zfu0CL6M oop sorry haha Im stupid. Its giving me a yaml error where I cannot use tabbing but nowhere in there is there tab usage I even double checked.
     
  6. Online

    timtower Administrator Administrator Moderator

    There is one on the usage though, did you update the plugin?
     
  7. But it looks like before the "speed:" there are 4 spaces where only 2 should be
     
  8. Offline

    killeBr

    Under usage that is 4 spaces, not a tab, but I also updated it, and speed is not 2 spaces and usage + description is 4 and it still doesnt work
     
  9. Offline

    Strahan

    The crash said you have a tab character in the file. Go through and delete any indentation then indent back out with your spacebar. Don't use tab.
     
  10. Offline

    killeBr

    like I said, I did the whole thing over again because I saw the error saying do not use indents, so I redid the entire thing and made sure to put spacings. the error its telling me is incorrect and I dont know how to fix it

    actually I fixed the plugin yml but now its apparently not up to date...

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.

    I keep getting console error telling asking me if the plugin is up to date.

    Heres my yml.

    Code:
    name: HelloWorld
    version: 1.1
    author: Carsob
    main: me.CarsobWorld.HelloWorld.Main
    Description: Speed Command enabled.
    
    commands:
      speed:
        usage: /speed
        description: speed enabled!
    heres my Main.

    Code:
    package me.CarsobWorld.HelloWorld;
    
    import org.bukkit.plugin.java.JavaPlugin;
    
    import me.CarsobWorld.HelloWorld.commands.speedCommand;
    
    public class Main extends JavaPlugin {
      
        @Override
        public void onEnable() {
            new speedCommand(this);
          
        }
      
    
    }
    heres the commands page:

    Code:
    package me.CarsobWorld.HelloWorld.commands;
    
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandExecutor;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    import org.bukkit.potion.PotionEffect;
    import org.bukkit.potion.PotionEffectType;
    
    import me.CarsobWorld.HelloWorld.Main;
    
    public class speedCommand implements CommandExecutor {
      
        private Main plugin;
      
        public speedCommand(Main plguin) {
            this.plugin = plugin;
            plugin.getCommand("speed").setExecutor(this);
          
          
        }
      
        @Override
        public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
            if (!(sender instanceof Player)){
                sender.sendMessage("Only Staff can execute this command!");
                return true;
            }
          
            Player p = (Player) sender;
            if (p.hasPermission("speed.use")) {
                p.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 600, 2));
              
                return true;
            }else {
                p.sendMessage("You do not have permission to run this command!");
              
            }
            return false;
        }
      
    }
    and here is the console message:
    Error occurred while enabling HelloWorld v1.1 (Is it up to date?)
    java.lang.NullPointerException: null
    at me.CarsobWorld.HelloWorld.commands.speedCommand.<init>(speedCommand.java:18) ~[?:?]
    at me.CarsobWorld.HelloWorld.Main.onEnable(Main.java:11) ~[?:?]
     
    Last edited by a moderator: Jan 6, 2020
  11. Online

    timtower Administrator Administrator Moderator

    Merged threads as the issue is pretty much the same.
    @killeBr This error occurs when you try to get and use a command that does not exist in the plugin.yml
    If you print the value of this:
    plugin.getCommand("speed")
    then it will probably print "null"
    Please check the plugin.yml in the jar to see if it is the same as the one you are exporting.
     
  12. Offline

    killeBr

    Im confused. they look to be the same.
     
  13. Offline

    Strahan

    Did you try what he said, checking if getCommand("speed") is null?

    Also, just as an aside, your speedCommand class name violates Java's naming convention. It should be PascalCase, not camelCase. Not that it has anything to do with your problem. Also your message for if the sender is not a Player is amusing; the only way that gets displayed is if someone calls it from console. If someone other than staff has console, you have big problems lol. Plus if you want to saved unnecessary indentation do a negative check and return instead:
    Code:
    Player p = (Player) sender;
    if (!p.hasPermission("speed.use")) {
      p.sendMessage("You do not have permission to run this command!");
      return true;
    }
    p.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 600, 2));
    
     
  14. Offline

    killeBr

    it says in this section right here:
    public speedCommand(Main plguin) {
    this plugin=plugin;
    plugin.getCommand("speed").setExecutor(this);

    that ( this plugin=plugin; ) has no affect so I would assume thats null. Thats the only error in my entire code

    Also, like you said, "Also your message for if the sender is not a Player is amusing; the only way that gets displayed is if someone calls it from console." how do I fix that? like I said, im fairly new to coding and just trying to learn to make a few basic things.
     
    Last edited: Jan 7, 2020
  15. Online

    timtower Administrator Administrator Moderator

    @killeBr Check the variable names in the constructor.
    You have a typo there.
     
    Strahan likes this.
  16. Offline

    Strahan

    Well, it's not really a "fix" it's just the wording isn't exactly apt. I'd make it say "Only for use in-game" or something.

    Good eye, I totally missed that lol
     
  17. Online

    timtower Administrator Administrator Moderator

    Found it by the message "has no effect"

    @killeBr Fix code issues first before testing plugins. Your editor is your best friend.
     
  18. Offline

    killeBr

    Thanks for all the help. the all in all error was the typo and an unused section of script. Thanks to you all.
     
  19. Offline

    killeBr

    I have one last question. As I am trying to have the command run speed II, I want it to also bring up a message in the color aqua: Speed enabled. But there are no errors in my code and when I do the command it say: Color:[rgb0x0ffff]Speed enabled! How can I get the [rgb0x0ffff] to instead make the color aqua.
     
  20. Online

    timtower Administrator Administrator Moderator

  21. Offline

    killeBr

    Player p = (Player) sender;
    if (p.hasPermission("speed.use")) {
    p.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 600, 2));
    p.sendMessage(Color.AQUA + "Speed Enabled!");
     
  22. Online

    timtower Administrator Administrator Moderator

  23. Offline

    killeBr

    how do I make it bold?
     
  24. Online

    timtower Administrator Administrator Moderator

  25. Offline

    killeBr

    lets say I wanted to dd both of them into the same code. How would I do that? do I hvae to use question mark to separate, or plus sign, or I have no clue what haha.
     
  26. Online

    timtower Administrator Administrator Moderator

    @killeBr Have you tried any of them?
     
  27. Offline

    killeBr

    I have tried to add both of them separating them in the same line of code using both comma and plus sign, which both tell me: The method sendMessage(String) in the type CommandSender is not applicable for the arguments (ChatColor, String). Sorry for asking you so many questions
     
  28. Online

    timtower Administrator Administrator Moderator

    @killeBr You won't get that if you are using just the plus sign.
    p.sendMessage(ChatColor.BOLD + Color.AQUA + "Speed Enabled!");
    Did you try this?
     
  29. Offline

    killeBr

    yes, now it says: (The method sendMessage(String) in the type CommandSender is not applicable for the arguments (ChatColor, String))
     
  30. Online

    timtower Administrator Administrator Moderator

    @killeBr How do you have 2 arguments for that?
     
Thread Status:
Not open for further replies.

Share This Page