Skip to content

Developpers : First plugin

De Cramer Oliver edited this page Jul 10, 2014 · 3 revisions

Creating a Plugin

First of all we recomend any developer wto use an IDE. This will allow you to have code completation and not need relay on documentation that we didn't generate. The IDE will find the documentations we have provide it inside the code and will allow you develop faster & with less errors.

We do strongly recomend Netbeans or PHPStorm as the 2 best IDE's out there.

If you have created plugins for ManiaLive before you will see that expansion isn't much different, the main differences will be due to all the eXpansion layer that will allow your plugins to be much more interactive and easy to configure by admins.

We will consider that you will release you plugin under the "oliverde8" name, and that the plugin that we will do will be called test. This means our plugin needs to be placed under here libraries/ManiaLivePlugins/oliverde8/test. Our working namespace will be ManiaLivePlugins\oliverde8\test

Here we will create 2 files. One of them is the plugin that will contain all the functional part of what you intend to do. This file will be called Test.php. The second file is the file that will contain all the information for your plugin to be able to interact with expansion even when it isn't still loaded. This interections are about letting now the system which game modes and titles your plugin support and declaring all the configuration that you plugin needs. We will work on the details on the MetaData in another tutorial for now we will just create a MetaData that does nothing. Let's create a MetaData.php file.

namespace ManiaLivePlugins\oliverde8\test;

class MetaData extends ManiaLivePlugins\eXpansion\Core\types\MetaData{
//@todo work on easy to configure settings & configure dependencies
}

Once this is done we can create our plugin. So let's create the test.php file and put this content in it

namespace ManiaLivePlugins\oliverde8\test;

class test extends ManiaLivePlugins\eXpansion\Core\types\BasicPlugin{

public function exp_onLoad()
{
}

public function exp_onReady()
{
}

public function exp_onUnLoad()
{
}
}

We now should have a working plugin that does nothing. To test it out, restart expansion on your "dev" server and check the plugin list. You should see a a plugin named ManiaLivePlugins\oliverde8\test\test.

It is important to extend BasicPlugin of eXpansion and not the Plugin type from ManiaLive. Our plugin type extends the ManiaLive plugin types and by doing so will allow the plugin to have ingame configuration, translations and most importantly it will allow the plugin management system that loads & unloads the plugin depending on the game mode and title to work.

I would like to note that ManiaLive plugins do work with little modifications on eXPansion but they will not be supported by the plugin management system and the in game configuration.

Listening to events

The dedicated events

Manialive events

Custom events

Some more basic knowledge

The storage

the dedicated connection