Solved dispatchCommand [unknown command!]

Discussion in 'Spigot Plugin Development' started by RockinChaos, Apr 14, 2017.

Thread Status:
Not open for further replies.
  1. Okay, so I have been struggling with this for a very long time now and I really need to figure out a fix for this issue.

    So this is my problem, I have my plugin setup to dispatch command as the instance of the player correct? I tried using both player.performCommand and Bukkit.dispatchCommand both didn't work.

    If I have the player dispatch a normal command such as /help or /spawn as well as 90% of all other plugins commands such as navigation menus or ultra cosmetics, etc it works great and executes just fine!
    My problem is I have currently ran into 4 plugins that I cannot get the players to execute the commands for.
    1.) ChestCommandsGUI (executing the commands for the custom menu's doesn't work).
    2.) MyCommand (executing any custom command created within this plugin doesn't work).
    3.) BuyCraft (executing the /buy command only).
    4.) MinecraftMarket (executing /buy command only).

    I debugged it and the players are properly executing the command but for some reason it returned as unknown command! It shows the player typing the correct command though so I don't really understand. If you manually type in the command via the chat window it works fine but if my plugin attempts to make the player execute one of those commands from those plugins it doesn't work.

    Any incite into this would be great and I can clarify anything if needed to.
     
  2. Code?

    You should perform it without '/' to make it work
     
  3. I already provided the code I said it was player.performCommand and Bukkit.dispatchCommand. I currently use;
    Bukkit.dispatchCommand(player, Command);

    the / has nothing to do with it as you can see any other command that doesn't have to do with those 4 plugins works fine. I also said that I have debugged them and it executes as it should and no / is included anyways but thanks for the suggestion.

    EDIT: I have found out that player.chat("/" + Command); actually works. Would this be a proper/suggested way to execute a command? If so I will mark this as resolved, I just need some feedback.
     
    #3 RockinChaos, Apr 14, 2017
    Last edited: Apr 14, 2017
  4. W
    Where is this code you've provided?
     
  5. Lol I just provided it for the 2nd time but for the 3rd time this is the code;

    Code (Text):
    Bukkit.dispatchCommand(player, Command);
    I also said that; I have found out that player.chat("/" + Command); actually works, I wanted to know if this is practical to use.
     
    #5 RockinChaos, Apr 14, 2017
    Last edited: Apr 14, 2017
  6. Mas

    Mas

    That isn't your code, it's a single line which gives us no context of what your plugin is doing.

    Whether your method is practical depends on the circumstance. If Player#performCommand isn't working for that specific command, then yes, Player#chat with the slash at the start is probably okay to use (you'll want to make a util method for it if you are going to be using that method a lot).
     
  7. That very much is my code and provides perfect context to what I am doing (obviously executing a command if you would have read the whole post).

    player is the player, command is the command such as "buy" via buycraft. Bukkit.dispatchCommand(player, Command); Bukkit dispatching the command. I was trying to explain that the way it is executed doesn't work for those certain plugins. I was keeping it simple showing you the line of code I am trying to execute that doesn't work properly, as well as my variables are common knowledge as player being exactly what it is called and the command being a string.

    For anyone else running into this issue use player.chat("/" + Command); I am now marking this as resolved.
     
    • Like Like x 1
Thread Status:
Not open for further replies.