Plugin not working and no errors

Discussion in 'Spigot Plugin Development' started by ZevoGaems, May 4, 2017.

  1. When I run my plugin it says there are no errors but it says when I run the command it says it doesn't exist? Could someone please help me?

    Code (Text):
    package pw.LoopTurn.hotbar;

    import org.bukkit.Bukkit;
    import org.bukkit.ChatColor;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    import org.bukkit.plugin.java.JavaPlugin;

    public class main extends JavaPlugin {

        public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
            if(cmd.getName().equalsIgnoreCase("moderate")) {
                if(!sender.hasPermission("minegrid.moderate")) {
                    sender.sendMessage(ChatColor.RED + "Requested Permission /n TRAINEE");
                    return true;
                } else if(!(sender instanceof Player)) {
                    sender.sendMessage(ChatColor.RED + "Error");
                    return true;
                } else if(args.length != 1) {
                    sender.sendMessage(ChatColor.RED + "Specify Player to Moderate");
                } else if(args.length == 1) {
                    String pName = args[0];
                    final Player target = Bukkit.getPlayerExact(pName);
                    if(target == null) {
                        sender.sendMessage(ChatColor.RED + "Player could not be intentified");
                        return true;
                    } else if(target != null) {
                        ((Player) sender).teleport(target.getLocation());
                        sender.sendMessage(ChatColor.RED + "Teleported to " + target.getName());
                        return true;
                    }
                }
            }
            return true;
        }

    }
     
    Config.yml

    Code (Text):
    main: pw.LoopTurn.hotbar.main
    name: MineGridModerator
    version: 1.0
    author: LoopTurn_
    description: Moderates Players

    commands:
        Moderate:
           description: moderates a player
           usage: /<command> (player) (reason)

    permissions:
        minegrid.moderate
           description: moderates a player
           default: op
    Here is how I setup the files
    [​IMG]
    if image doesn't load go here http://imgur.com/a/C91Dx
     
  2. you mean plugin.yml right?
     
  3. Well that explains alot... I was calling it config.yml
     
    • Funny Funny x 1
  4. also src folder, one out of the main package
     
  5. Yeah thats what I thought, I was learning how to setup configs recently so yeah I must have mixed them up
     
  6. I fixed it up but it still doesn't work????
     
  7. Send a image of your project
     
  8. Your plugin.yml should be in the resources directory.

    /src/main/java/main.java
    /src/main/resources/plugin.yml

    You could also use a command interpreter to do this for you, there are many on here and im sure there would be one suitable for you. Some don't even require you to put your commands in the plugin.yml

    Mine: https://www.spigotmc.org/resources/command-interpreter.37560/
     
    #9 Stuperfied, May 4, 2017
    Last edited: May 4, 2017
    • Agree Agree x 1
  9. Oh also, don't know if you noticed "Player could not be intentified".
     
  10. What? I wrote that :p
     
  11. Does the main class contain something else or just what you posted? You're neither implementing CommandExecutor nor registering your command in the onEnable method. [edit]okay, apparently not needed if it's in the main class[/edit]

    offtopic: "intentified" has nothing to do with someone being in a tent. The word you're looking for is probably identified.
     
    #12 Coww, May 4, 2017
    Last edited: May 4, 2017
  12. He extends JavaPlugin, which automagically does all that out of the box for beginners. ;)

    @ZevoGaems I think the casing of things is getting you all mixed up. You main class is in all lowercase. You have upper case characters in your package names. You are registering a command with caps (not sure if commands are case sensitive). Could you post your servers log file? I'm thinking either the casing of characters is either messing with things, or your plugin.yml is not in the proper spot in the compiled jar file. The log should tell us more.
     
    • Agree Agree x 1
  13. JavaPlugin already implements CommandExecutor and since it's in the same class, it doesn't have to be registered (I don't think)

    @OP, Check the logs at the very top when plugins load in to look for errors and one would have shown with an incorrect plugin.yml

    Edit: Sniped by Billy