Command Handler

Discussion in 'Plugin Development' started by nethergoblin, Jan 7, 2017.

  1. Offline


    okay Im new to making plugins and when making my own I want to make a command do other commands like /day could make it day time and set weather and heal you or whatever I wanted to change it too...but im not 100% sure on how to do this I think its a command Handler if not that's why I cant find any other help and also if anyone knows a way you can add points to the scoreboard (like kills points) by using a command (I want to make it so a admin could add kills to someone by a easier command) that would be great

    Fast clear up: I want to make it so a command can do more commands
  2. @nethergoblin
    Use the Bukkit.distpatchCommand (person sending the command, "The command"); to trigger another command. If you want the console to send the command, use Bukkit.getConsoleSender()
  3. Offline


    sorry late reply

    okay thanks before I get to work (unless I find out on my own) this can make it so 1 command can run 2-3 right?

    and thanks for the help
  4. @nethergoblin
    Yes, just use Bukkit.dispatchCommand multiple times.
  5. Offline


    Okay thanks guys this helps a lot

    is there any tutorial for this you could point me too? if not ill just go looking

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    Last edited by a moderator: Jan 9, 2017
  6. Offline


    You should probably mark the thread as solved if you're satisfied.

    I can't find a video tutorial, but here's some examples of this code in action.
  7. Offline


    Here is some of my old lines of code i've used

    @EventHandlerpublic void onCode(AsyncPlayerChatEvent event) {Player player = event.getPlayer();if (event.getMessage().equals("E3-CODEC-EMERGENCY")) { // If you type this in it will trigger the bottomConsoleCommandSender c = Bukkit.getConsoleSender();Bukkit.getServer().dispatchCommand(c, "lockdown kickall");Bukkit.getServer().dispatchCommand(c, "lockdown start There is a problem with the server"); // TIP: You can replace variable c with player or sender or target}}

Share This Page