#Command is not run and usage message is given

1 messages · Page 1 of 1 (latest)

vale sentinel
#

Both of the commands setup within my plugin are not running when run by the user, they are defined both within the plugin.yml (below) and are set in the onEnable() (below) method in the main class.

I have investigated this with both logging and through a debugger with jdwp, the onCommand method is never reached.

It seems like we reach the following line in execute in the Spigot PluginCommand class:

success = executor.onCommand(sender, this, commandLabel, args);

This sends us into getCommand in the JavaPlugin class (I assume some sort of reflection being done here in the background) where we do the following if statement:

if (command == null || command.getPlugin() != this)

I then take the next step in the debugger and we end up back in execute in PluginCommand with a success value of false

Both logical operators in this if statement result in false so we should continue to the next if statement (below) and return command as expected. Any idea why this is not happening would be massively appriciated - I am totally stumped

if (command != null && command.getPlugin() == this)
#

plugin.yml

name: conceptc-claiming
version: "1.0-SNAPSHOT"
author: Dinoosawruss
main: com.github.dinoosawruss.ConceptCClaiming
api-version: '1.20'

depend: [conceptc-core]

commands:
  claim:
    description: Commands used to control claims
    usage: /<command> <trust|untrust|info> [args]

  ignoreclaims:
    description: Admin command to ignore any claims
    usage: /ignoreclaims
    permission: conceptc.admin.ignoreclaims
#

onEnable()

@Override
public void onEnable() {
    logger = getLogger();

    dbUtils = getPlugin(ConceptCCore.class).getDbUtils();
    
    logger.log(Level.INFO, "{0}.onEnable()", this.getClass().getName());

    this.getServer().getPluginManager().registerEvents(new BlockListener(), this);
    this.getServer().getPluginManager().registerEvents(new ClaimBlockInteractListener(), this);
    this.getServer().getPluginManager().registerEvents(new ViolationEventListener(), this);

    this.getCommand("claim").setExecutor(new ClaimListener());
    this.getCommand("ignoreclaims").setExecutor(new IgnoreClaims());
}
#

getPlugin in PluginCommand seems to never even be called (checked with breakpoint and jdwp) despite command == null resulting in false

limpid crest
#

Show your ClaimListener class pls

vale sentinel
#

ClaimListener

package com.github.dinoosawruss.commands.listeners;

import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;

import com.github.dinoosawruss.commands.executors.ClaimInfo;
import com.github.dinoosawruss.commands.executors.ClaimTrust;
import com.github.dinoosawruss.commands.executors.ClaimUntrust;

public class ClaimListener implements CommandExecutor {
    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        if (sender instanceof Player) {
            Player player = (Player) sender;

            if (args.length == 0) {
                player.sendMessage("Insufficient args");
                return false;
            }

            switch(args[0]) {
            case "trust":
                new ClaimTrust(player, args);
                break;

            case "untrust":
                new ClaimUntrust(player, args);
                break;

            case "info":
                new ClaimInfo(player);
                break;

            default:
                player.sendMessage("Unknown argument");
                return false;
            }
        }
        
        return true;
    }
    
}
limpid crest
#

Let everything return true and try again

vale sentinel
#

Will try that but we never enter onCommand so

#

invalid session gimme a minute

#

We get usage from Console though which will always be returning true and my breakpoint on onCommand line 1 is never hit

> claim
[19:46:16 INFO]: /claim <trust|untrust|info> [args]
#

And also just get usage back from player running the command even with all true

limpid crest
#

Im assuming you never /reload, right?

vale sentinel
#

Nope thats with a server restart

#

Also added sender.sendMessage("You reached this line"); to the first line and the message isn't sent to sender in console or in game

limpid crest
#

Alright, send me the compiled jar from your server pls

#

Bc this sounds quite impossible

vale sentinel
#

yes thats why i'm confused...

#

ok to dm? - seems like I cant upload files here

limpid crest
#

Ok. But you should verify your acc at some point.

vale sentinel
#

Sent

limpid crest
#

Kind of on a dead end here. Update your server jar.
Did you try listening to the CommandPreprocessEvent?

vale sentinel
#

Updated server jar to no avail
As an alternative to CommandExecutor interface or?

limpid crest
#

Just to check if the event is fired.

#

Wait, try calling the command like this: /conceptc-claiming:claim

vale sentinel
#

Clever thinking that seems to run the command

limpid crest
#

Then there is another plugin registering an empty claim command i think

vale sentinel
#

yeah perhaps i've accidentally registered claim in one of the other plugins - its only my plugins on the server

#

will check now

#

Yep that'll do it - always something unexpected thank you kindly for your assistance

#

Copy and pasting moment