Hello World Plugin (NOT WOKRING)

Discussion in 'Spigot Plugin Help' started by DevTastic, Apr 17, 2018.

  1. Hello. I am having trouble with me HelloWorld Project as my First plugin I need some help with the code could you please copy it and edit it and help me get it to work! Thanks

    Code (Text):
    package me.DevTastic.HelloWorld;

    import java.util.logging.Logger;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.plugin.java.JavaPlugin;

    public class Main extends JavaPlugin
        Logger log = Logger.getLogger("Minecraft");
        public void onEnable()
            log.info("Your plugin has been enabled!");
        public void onDisable()
            log.info("Your plugin has been disabled.");
        public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args)
            if (commandLabel.equalsIgnoreCase("hello"))
                sender.sendMessage("Hello World!");
                return true;
            return false;
    Code (Text):
    Name: Hello World
    Version: 1.0
    Author: DevTastic
    Main: me.DevTastic.HelloWorld.Main
    Description: Our First Minecraft spigot plugin!

  2. I dont want to spoon feed too much but here are a few things
    • Register command
    • Also in plugin.yml im pretty sure you need a 4 space indent
    • Also in plugin.yml im pretty sure all the values must be all lower case, eg, name:, commands:
    So in your onEnable put getCommand("hello").setExecutor(this);

    After that it should work
    #2 IMinIILLuZionZ, Apr 17, 2018
    Last edited: Apr 17, 2018
  3. No need to set the command executor if the onCommand method is in your main class. JavaPlugin implements TabExecutor, TabExecutor extends CommandExecutor and TabCompleter, and by default, all of your registered commands are forwarded to the onCommand method in your main class.

    Now, OP, the code looks fine to me from a quick look, so I'm not entirely sure; but try adding something after the 'hello:' part in the config, like this:
    Code (YAML):
    : 'Prints Hello World'
    Also make sure you don't use tabs instead of spaces, although you already seem to do so.

    Edit: Hold on, your 'commands' section is capitalized, that might be the problem, checking..

    Yeah, I don't think the names in plugin.yml are case-insensitive, and all of my plugins seem to have 'commands' lowercase. In fact, all of your plugin.yml entries are capitalized. According to this, they are indeed case-sensitive and should be lower-case instead.

    Also, wrong section ;) Should be in Spigot Plugin Development instead
    #3 jetp250, Apr 17, 2018
    Last edited: Apr 17, 2018
  4. I forgot about that lol, usually I have my commands in separate classes so I forgot xD
  5. can you get my code and add that?
  6. No one here is going to do that for you, spoon feeding is bad and honestly if you can't figure out how to make a hello world plugin go watch some tutorials or something.
    • Agree Agree x 1
  7. I agree with @Drakonn, if you want to learn to code, fixing your mistakes yourself is the best way so you don't make the mistake again
  8. I tried the blank spigot plugin and it still did not work :(
  9. Did you read my reply? Your plugin.yml entries ('Main:', 'Author:', 'Commands:' as you have them) must be lower case. You have them capitalized. So change 'Main' to 'main', 'Commands' to 'commands' and so on.

Share This Page