Creating a repeating command

Discussion in 'Plugin Development' started by JCDcrafter, Oct 1, 2017.

  1. JCDcrafter

    JCDcrafter Member

    Apr 28, 2016
    40
    10
    8
    Male
    in the onEnable i want to make it so that it will repeat the command "/say Welcome to the server" every 10 minutes. I know i have to use this.getServer().dispatchCommand(new ConsoleCommandSender, "say Welcome to the server") to get the server message but i don't know how to get it to repeat every 10 minutes.
    What would the code be?
     
  2. pkt77

    pkt77 New Member

    Aug 26, 2017
    5
    1
    3
    Male
    PHP:
            getServer().getScheduler().scheduleDelayedRepeatingTask(this, () -> {
                
    getServer().dispatchCommand(new ConsoleCommandSender(), "say Welcome to the server");
            }, 
    1200012000);
     
    JCDcrafter likes this.
  3. JCDcrafter

    JCDcrafter Member

    Apr 28, 2016
    40
    10
    8
    Male
    Thank You
     
  4. Christopher Caldwell

    Feb 11, 2016
    25
    4
    3
    Male
    Why Not just sendMessage to every player in the server
     
  5. JCDcrafter

    JCDcrafter Member

    Apr 28, 2016
    40
    10
    8
    Male
    I could do that and that would be very easy but i was just using that command as an example I'm not actually using it to send a message to everyone i just needed the code
     
    Christopher Caldwell likes this.