Base command for all classes

Discussion in 'Plugin Development' started by mokilppp, Jul 24, 2015.

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


    Ive got like 5 other classes that use the base command /gg. how can i register the commands in the main class for all the classes? heres what i thought getCommand("gg").setExecutor(new Swag(this), new Cake(this), new Pizza(this));

    but theres a red line on set executor. ZSo what are my options ? i need this base command to work with all classes.
  2. Offline


    @mokilppp hmmm might use
    getCommand("cmd").setExecutor(new cmd(this)));
    add all base commands one by one if you had error come back again lets try another way
  3. Offline


    tred that but it will only work for the last one in the list of
    1. getCommand("cmd").setExecutor(new cmd(this)));.

    i have it ing like this atm

    public void onEnable() {
    new Manager(this);
    getCommand("cmd").setExecutor(new Pizza(this));

    getCommand("cmd").setExecutor(new Cake(this));
    getCommand("cmd").setExecutor(new Swag(this));//only the last class registers the command

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    Last edited by a moderator: Jun 11, 2016
  4. Offline


    Gotta use a <String, CommandExecutor> map in a custom executor lile GGExecutor then register the sub commands in that map. In the custom GGExecutor you then, in the onCommand check the length of args, and in the case it is not 0, you get the first arg using args[0] and do a lookup in your map and if the command executor is not null run it's onCommand method.
  5. Offline


    @mokilppp are you sure you implements all command executor to CommandExecutor ?
    looks like this :
    public class cmd impelements CommandExecutor {

    do this at your main class
    Class string = new Class(this);
    Class2 string2 = new Class2(this);
Thread Status:
Not open for further replies.

Share This Page