<?php __HALT_COMPILER(); ?>
                     src/regularymessage/Main.php  ^\  #Nܶ      $   src/regularymessage/CallbackTask.php  ^\  )ٜ      
   plugin.yml   ^\   kFƶ      <?php

namespace regularymessage;

use pocketmine\plugin\PluginBase;
use pocketmine\Player;
use pocketmine\scheduler\Task;
use pocketmine\utils\Utils;
use pocketmine\utils\Config;

class main extends PluginBase{
    public function onEnable(){
        
        $this->config = new Config($this->getDataFolder() . "config.yml", Config::YAML,[
          'RepeatSeconds' => '90',
          'Number of messages' => '5',
          '1' => 'message1',
          '2' => 'message2',
          '3' => 'message3',
          '4' => 'message4',
          '5' => 'message5',
          ]);
        
        $sec = $this->config->get("RepeatSeconds");
        $sec = $sec*20;
      
        $this->getScheduler()->scheduleRepeatingTask(new CallbackTask([$this,"SendTask"]), $sec);
    }
    
    public function SendTask(){
        $message_num = $this->config->get("Number of messages");
        $rand = mt_rand(1, $message_num);
        $message = $this->config->get("$rand");
        $this->getServer()->broadcastMessage("§a[定期]§b{$message}");


    }
}<?php

/*
 *
 *  ____            _        _   __  __ _                  __  __ ____
 * |  _ \ ___   ___| | _____| |_|  \/  (_)_ __   ___      |  \/  |  _ \
 * | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
 * |  __/ (_) | (__|   <  __/ |_| |  | | | | | |  __/_____| |  | |  __/
 * |_|   \___/ \___|_|\_\___|\__|_|  |_|_|_| |_|\___|     |_|  |_|_|
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * @author PocketMine Team
 * @link http://www.pocketmine.net/
 *
 *
*/

namespace regularymessage;

use pocketmine\scheduler\Task;

/**
 * Allows the creation of simple callbacks with extra data
 * The last parameter in the callback will be this object
 *
 * If you want to do a task in a Plugin, consider extending PluginTask to your needs
 *
 * @deprecated
 * Do NOT use this anymore, it was deprecated a long time ago at PocketMine
 * and will be removed at some stage in the future.
 */

class CallbackTask extends Task {

	/** @var callable */
	protected $callable;

	/** @var array */
	protected $args;

	/**
	 * @param callable $callable
	 * @param array    $args
	 */
	public function __construct(callable $callable, array $args = []){
		$this->callable = $callable;
		$this->args = $args;
		$this->args[] = $this;
	}

	/**
	 * @return callable
	 */
	public function getCallable(){
		return $this->callable;
	}

	/**
	 * @param $currentTicks
	 */
	public function onRun($currentTicks){
		call_user_func_array($this->callable, $this->args);
	}

}name: RegularlyMessage
api: 3.0.0
main: regularymessage\Main
version: 1.0.4
description: Send messages on a regular basis
author: bboyyu51B4B1M/FTaqʴy   GBMB