1.16.5 Executing A Command As Console

Discussion in 'Spigot Plugin Development' started by PmzHeroV2, Apr 19, 2021.

  1. I Want To Execute A Command As Console When A Player Joins The Game
    i setted up the event i just dont know how to make a command get executed as console
  2. Use Bukkit#dispatchCommand
    #3 Black_Set, Apr 19, 2021
    Last edited: Apr 19, 2021
  3. Code (Text):
    Bukkit.dispachCommand(Bukkit.getConsoleSender(), "say this is a command!")
    • Winner Winner x 1
  4. did not work. when a player joins nothing happens at all
  5. Code (Java):
        public void onJoin(PlayerJoinEvent event) {

            Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "say test");

    It is in my main. i done this before and nothing happened. all imports are than and Listener is implemented
  6. Register your events in your onEnable like this, Bukkit.getServer().getPluginManager.registerEvents(this, this);

    Also use @EventHanlder tag above your event
  7. add @eventhandler and register it correctly extends class as a Listener