Git Product home page Git Product logo

Comments (2)

PXAV avatar PXAV commented on May 20, 2024

Thank you for the bug report, I'll see how I can fix it!

from kelp.

PXAV avatar PXAV commented on May 20, 2024

I have now fixed the bug. Actually, it was not a real bug, as PLAYER_AND_CONSOLE only called the onCommand(ConsoleSender, args) method and not the player method, because the command should be the same for players and consoles. But I have now changed it so that you can have both onCommand methods and depending on the executor, the corresponding method will be called.

If you want to have the same command handler method for both player and console, then you could do something like that:

@CreateCommand(name = "helloworld", executorType = ExecutorType.PLAYER_AND_CONSOLE)
public class test extends KelpCommand {

  private KelpConsoleSenderFactory senderFactory;

  @Inject
  public test(KelpConsoleSenderFactory senderFactory) {
    this.senderFactory = senderFactory;
  }

  @Override
  public void onCommandRegister() {
    allowCustomParameters(true);
  }

  @Override
  public void onCommand(KelpConsoleSender consoleSender, String[] args) {
    System.out.println("command executed by either player or console " + Arrays.toString(args));
  }

  @Override
  public void onCommand(KelpPlayer player, String[] args) {
    CommandSender sender = player.getBukkitPlayer();
    this.onCommand(senderFactory.newKelpConsoleSender(sender), args);
  }

}

The fix will be released with v0.0.4

from kelp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.