Documentation

This documentation just shows a small list of possabilities of ManiaControl.
A full overview of all classes/properties/methods can be found here!

Small how-to on plugins

Every server controller uses plugins to provide functions to server admins and players. This is also the case for the new ManiaControl controller for the ManiaPlanet games. In this topic you find a small how-to on creating plugins for ManiaControl.

Note beforehand
The complete ManiaControl core has PHPDoc comments. This means that if you use a IDE that supports this, coding plugins for ManiaControl will be much easier! It provides you with a clear overview, suggestions for auto completion, etc. Without this support it might be quite hard to create plugins, because of the extensive core.

Dev Mode
Please Turn on the development Mode in the ManiaControl.php file outside the core.

Usage Information
Besides the Website Documentation you can use the Method ->getUsageInformation() on most of the PHP classes

File Naming
All Plugin Class Names must equal the corresponding FileNames and each file can only content one Class, please use Proper Namespacing according to the folder structure.

Small basic plugin set-up

    <?php
    use ManiaControl\Callbacks\CallbackListener;
    use ManiaControl\Callbacks\CallbackManager;
    use ManiaControl\Callbacks\TimerListner;
    use ManiaControl\Commands\CommandListener;
    use ManiaControl\ManiaControl;
    use ManiaControl\Manialinks\ManialinkPageAnswerListener;
    use ManiaControl\Players\Player;
    use ManiaControl\Players\PlayerManager;
    use ManiaControl\Plugins\Plugin;

    /**
     * Name of the plugin ... (small description)
     *
     * @author  ...
     */

    class MyPlugin... implements CallbackListener, CommandListener, ManialinkPageAnswerListener, TimerListener, Plugin {
        /**
         * Constants
         */
        const ID                 = ...;
	    const VERSION            = 0.1;

		/**
		 * Private properties
		 */
		/** @var    ManiaControl $maniaControl */
		private $maniaControl = null;

		/**
		 * Load the plugin
		 *
		 * @param  \ManiaControl\ManiaControl $maniaControl
		 */
		public function load(ManiaControl $maniaControl) {
				$this->maniaControl = $maniaControl;
			}

		/**
		 * Unload the plugin and its resources
		 */
		public function unload() {
				$this->maniaControl = null;
			}

		/**
		 * Get plugin id
		 *
		 * @return  int
		 */
		public static function getId() {
				return self::ID;
			}

		/**
		 * Get Plugin Name
		 *
		 * @return  string
		 */
		public static function getName() {
				return '... Plugin';
			}

		/**
		 * Get Plugin Version
		 *
		 * @return  float
		 */
		public static function getVersion() {
				return self::VERSION;
			}

		/**
		 * Get Plugin Author
		 *
		 * @return  string
		 */
		public static function getAuthor() {
				return '...';
			}

		/**
		 * Get Plugin Description
		 *
		 * @return  string
		 */
		public static function getDescription() {
            return '...';
        }
}
                

You can download this template here.

Be sure to include the class that you need in your plugin by using "use":

                    use ManiaControl\Admin\AuthenticationManager;
                    use ManiaControl\Callbacks\CallbackManager;
                    use ManiaControl\Configurators\ScriptSettings;
                    use ManiaControl\Configurators\ServerSettings;
                    use ManiaControl\Manialinks\ManialinkManager;
                    use ManiaControl\Maps\MapManager;
                    use ManiaControl\Maps\MapQueue;
                    use ManiaControl\Players\PlayerManager;
                    use Maniacontrol\Server\ServerCommands;
                

Callbacks
A very usefull resource are callbacks, which are called when something happens on the server. These callbacks can be registered in the load()-method via the callback manager:

                    $this->maniaControl->getCallbackManager()->registerCallbackListener(*callback*, $this, '*method*');
                

Additionally to the Callbacks defined in the Callbacks interface, the following callbacks can be registered via this method:

The method you enter in the callback register should be in your Plugin class and can look like this (f.e. the PlayerConnect):

                <?php
                    /**
                     * Handle PlayerConnect callback
                     *
                     * @param  Player $player
                     */
                    public function handlePlayerConnect(Player $player) {
                        var_dump($player->login);
                    }
                ?>

                

Timers
With timers it is a special case, because ManiaControl has created its own timing devices, giving you the opportunity to create a listener which is called every X ms.
If you create a method called "handle1Second", which you want to call every second (1000 ms), then you can do the following:

                $this->maniaControl->getTimerManager()->registerTimerListening($this, 'handle1Second', 1000);
            

Methods
ManiaControl uses the Dedicated Server API, which gives you easy access to methods with which you can contact the server. This API is accessible with $this->maniaControl->client->, after which you put the method name you want to use (using lower Camel Case), such as forceSpectator($login, $mode);.

Check out the nice overview Xymph has on his site (methods), you can use every method listed there as long as you change the first character to lowercase. The PHP functions that provide these methods accept the same parameters as listed on the overview.

Chat Commands
TODO

Settings
TODO

Communication Manager
TODO

Asynchronous HTTP Requests
TODO

Write Simple ManiaLinks
TODO

Got stuck?
Check the plugins that are already made, to look for solutions for your current problem. You can also check out the HTML document from the PHPDoc, listing all the functions in the ManiaControl core. If that doesn't help, then you can always ask for help in our ManiaPlanet toolforum.