Custom command not working!

Discussion in 'Plugin Development' started by DenverXDXDXD, Nov 22, 2017.

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


    Hey guys!

    I made a simple plugin were when you enter a certain command it prints a simple message
    (I am using eclipse and minecraft 1.12.2)



    print "Test successful!"

    Here is the code:

    Main class:
    package com.Denver.plugin;
    import org.bukkit.command.*;
    import org.bukkit.entity.Player;
    public class main extends JavaPlugin{
        public void onEnable() {
            getLogger().info("Plugin DenverXDXDXD has been enabled!");
        public void onDisable() {
        public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
            if (cmd.getName().equalsIgnoreCase("DXD.test") && sender instanceof Player) {
                Player player = (Player) sender;
                player.sendMessage("Test successfull!");
            return false;
    Yml file:
    name: DenverXDXDXD
    main: com.Denver.plugin.main
    version: 1.0
          description: This is a test command.
          usage: /<command>

    It prints out "Test successful" but it also prints out the command you entered.

    I only want it to print "Test successful" and nothing else.
  2. @DenverXDXDXD
    The reason it is printing out the command usage is because you are returning false. That value determines if the command was issued correctly. If the command worked the way it should, return true.

    BTW: If the onDisable does nothing, delete it. Also, since bukkit already logs your plugins when they are enabled, you do not need to log that your plugin has been enabled.
  3. Drop a return true; after the send message method. Because of ^
  4. Offline


    The command prints out the command you entered too because the "Usage in plugin.yml, the usage tells you the usage everytime even if used correctly
  5. Offline


    Thank you guys!

    I will try returning false
  6. Offline


    no lol, change the return false to a return true, its on the bottom of your code
Thread Status:
Not open for further replies.

Share This Page