wth is wrong with my plugin.yml

Discussion in 'Plugin Development' started by johnny boy, Jan 10, 2017.

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

    johnny boy

    Something is very wrong.. I have tried re-writing it and it still doesn't work..

    Here is mainclass:
    Code:
    package com.enjin.stargonagames;
    
    import org.bukkit.configuration.file.FileConfiguration;
    import org.bukkit.plugin.java.JavaPlugin;
    
    import com.enjin.stargonagames.command.BuyCommand;
    
    public class MainClass extends JavaPlugin {
       
        public FileConfiguration config;
       
        public void onEnable() {
            getCommand("buy").setExecutor(new BuyCommand(this));
        }
    
    }
    
    and plugin.yml:
    Code:
    main: com.enjin.stargonagames.MainClass
    version: 1.0
    name: BuyCommand
    
    and error log:
    http://pastebin.com/mR3E9Cms
     
  2. Offline

    timtower Administrator Administrator Moderator

  3. Offline

    johnny boy

    I did that but it still just said invalid plugin.yml..
     
  4. Offline

    timtower Administrator Administrator Moderator

  5. Offline

    johnny boy

    @timtower
    Code:
    main: com.enjin.stargonagames.MainClass
    version: 1.0
    name: BuyCommand
    
    commands:
      buy:
        description: Buy command
     
  6. Offline

    timtower Administrator Administrator Moderator

  7. Offline

    johnny boy

  8. Offline

    MarinD99

    Code:
    Caused by: java.io.FileNotFoundException: Jar does not contain plugin.yml
    Where is your plugin.yml located?
     
  9. Offline

    johnny boy

    I'll show a picture:
    View attachment 28761
    As you can see it is where it should be.. I really don't know what's going on here!
     
  10. Offline

    MarinD99

    "It's where it needs to be" - No. It needs to be located within your src folder, alongside your config.yml.
     
  11. Offline

    timtower Administrator Administrator Moderator

    Wrong there.

    @MemeplexOwner Open the jar with a zip program, is there a plugin.yml?
     
  12. Offline

    johnny boy

    .. Problem fixed. It looks like I have lost quite a few braincells ;-;

    EDIT: Now it's not working... What's wrong with eclipse.
     
  13. Offline

    timtower Administrator Administrator Moderator

    @MemeplexOwner Export it, but before you hit "ok" make a screenshot.
     
  14. Offline

    johnny boy

    ok :p Wait, There is no ok do you mean finish?
     
  15. Offline

    timtower Administrator Administrator Moderator

    I probably do :p
     
  16. Offline

    johnny boy

  17. Offline

    Zombie_Striker

    Either you already hit "finish", or you have not exported it yet. We want that window that pops up.
     
  18. Offline

    johnny boy

    k here:

    View attachment 28765
    here

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jan 10, 2017
  19. @MemeplexOwner If you are getting the not containing plugin.yml it's likely you aren't restarting the server or you're running the wrong server/exporting to the wrong one

    Server log?
     
  20. Offline

    johnny boy

  21. Offline

    johnny boy

    I checked if the args.length == 0 but it is still saying NPE..
     
  22. Offline

    johnny boy

    its probably something silly
    Code:
    package com.enjin.stargonagames.command;
    
    import org.bukkit.ChatColor;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandExecutor;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    
    import com.enjin.stargonagames.MainClass;
    
    public class BuyCommand implements CommandExecutor {
       
        MainClass config;
       
        public BuyCommand(MainClass config) {
            this.config = config;
        }
       
        public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
        if (!(sender instanceof Player)) {
            sender.sendMessage("You must be a player.");
            return false;
        }
       
        Player player = (Player) sender;
        if (args.length == 0) {
        String buyMessage = config.getConfig().getString("buyMessage");
        String newBuyMessage = ChatColor.translateAlternateColorCodes('&', buyMessage);
        player.sendMessage(newBuyMessage);
        return true;
    }
        if (args.length > 2 && args[0].equalsIgnoreCase("edit") && args[1].equalsIgnoreCase("message")) {
            StringBuilder userBuyMessage = new StringBuilder();
            for (int i = 3; i < args.length; i++) {
                String userBuyMessageAdded = args[i] + " ";
                userBuyMessage.append(userBuyMessageAdded);
            }
            config.getConfig().set("buyMessage", userBuyMessage.toString());
            String buyMessageNoColour = config.getConfig().getString("buyMessage");
            String newBuyMessageColour = ChatColor.translateAlternateColorCodes('&', buyMessageNoColour);
            config.getConfig().set("buyMessage", newBuyMessageColour);
            config.saveConfig();
        }
        return false;
        }
    
    }
    
     
  23. Offline

    CrazyLukeHD

    @MarinD99 The plugin.yml file doesn't need to be in the src folder. As long as it is in the PROJECT folder it's fine. That's the way mine is and it works.
     
    ipodtouch0218 likes this.
  24. Offline

    johnny boy

    Yes, it does..
     
Thread Status:
Not open for further replies.

Share This Page