summaryrefslogtreecommitdiffstats
path: root/MCServer/Plugins/APIDump/Writing-a-MCServer-plugin.html
diff options
context:
space:
mode:
authorTycho <work.tycho+git@gmail.com>2014-02-01 00:31:05 +0100
committerTycho <work.tycho+git@gmail.com>2014-02-01 00:31:05 +0100
commitfec17409d2f566af18bad269fe2c5c372a474ecb (patch)
tree93baa2311e38fddb86a68e550955c261ac96cf3b /MCServer/Plugins/APIDump/Writing-a-MCServer-plugin.html
parentChanged signitures of Several BLockHandler Methods (diff)
parentContributors now match real life, and are alpha-sorted. (diff)
downloadcuberite-fec17409d2f566af18bad269fe2c5c372a474ecb.tar
cuberite-fec17409d2f566af18bad269fe2c5c372a474ecb.tar.gz
cuberite-fec17409d2f566af18bad269fe2c5c372a474ecb.tar.bz2
cuberite-fec17409d2f566af18bad269fe2c5c372a474ecb.tar.lz
cuberite-fec17409d2f566af18bad269fe2c5c372a474ecb.tar.xz
cuberite-fec17409d2f566af18bad269fe2c5c372a474ecb.tar.zst
cuberite-fec17409d2f566af18bad269fe2c5c372a474ecb.zip
Diffstat (limited to 'MCServer/Plugins/APIDump/Writing-a-MCServer-plugin.html')
-rw-r--r--MCServer/Plugins/APIDump/Writing-a-MCServer-plugin.html25
1 files changed, 8 insertions, 17 deletions
diff --git a/MCServer/Plugins/APIDump/Writing-a-MCServer-plugin.html b/MCServer/Plugins/APIDump/Writing-a-MCServer-plugin.html
index 0e07cebdf..1eec4842a 100644
--- a/MCServer/Plugins/APIDump/Writing-a-MCServer-plugin.html
+++ b/MCServer/Plugins/APIDump/Writing-a-MCServer-plugin.html
@@ -25,7 +25,7 @@
</p>
<p>
Next, we must obtain a copy of CoreMessaging.lua. This can be found
- <a href="https://raw.github.com/mc-server/MCServer/master/MCServer/Plugins/MagicCarpet/coremessaging.lua">here.</a>
+ <a href="https://gist.github.com/bearbin/8715888">here.</a>
This is used to provide messaging support that is compliant with MCServer standards.
</p>
<h2>Creating the basic template</h2>
@@ -35,19 +35,14 @@
Format it like so:
</p>
<pre class="prettyprint lang-lua">
-local PLUGIN
+PLUGIN = nil
function Initialize(Plugin)
- Plugin:SetName("DerpyPlugin")
+ Plugin:SetName("NewPlugin")
Plugin:SetVersion(1)
PLUGIN = Plugin
- -- Hooks
-
- local PluginManager = cPluginManager:Get()
- -- Command bindings
-
LOG("Initialised " .. Plugin:GetName() .. " v." .. Plugin:GetVersion())
return true
end
@@ -84,7 +79,7 @@ end
To register a hook, insert the following code template into the "-- Hooks" area in the previous code example.
</p>
<pre class="prettyprint lang-lua">
-cPluginManager:AddHook(cPluginManager.HOOK_NAME_HERE, FunctionNameToBeCalled)
+cPluginManager.AddHook(cPluginManager.HOOK_NAME_HERE, FunctionNameToBeCalled)
</pre>
<p>
What does this code do?
@@ -102,10 +97,7 @@ function Initialize(Plugin)
Plugin:SetName("DerpyPlugin")
Plugin:SetVersion(1)
- cPluginManager:AddHook(cPluginManager.HOOK_PLAYER_MOVING, OnPlayerMoving)
-
- local PluginManager = cPluginManager:Get()
- -- Command bindings
+ cPluginManager.AddHook(cPluginManager.HOOK_PLAYER_MOVING, OnPlayerMoving)
LOG("Initialised " .. Plugin:GetName() .. " v." .. Plugin:GetVersion())
return true
@@ -127,10 +119,10 @@ end
</p>
<pre class="prettyprint lang-lua">
-- ADD THIS IF COMMAND DOES NOT REQUIRE A PARAMETER (/explode)
-PluginManager:BindCommand("/commandname", "permissionnode", FunctionToCall, " - Description of command")
+cPluginManager.BindCommand("/commandname", "permissionnode", FunctionToCall, " - Description of command")
-- ADD THIS IF COMMAND DOES REQUIRE A PARAMETER (/explode Notch)
-PluginManager:BindCommand("/commandname", "permissionnode", FunctionToCall, " ~ Description of command and parameter(s)")
+cPluginManager.BindCommand("/commandname", "permissionnode", FunctionToCall, " ~ Description of command and parameter(s)")
</pre>
<p>
What does it do, and why are there two?
@@ -197,8 +189,7 @@ function Initialize(Plugin)
Plugin:SetName("DerpyPluginThatBlowsPeopleUp")
Plugin:SetVersion(9001)
- local PluginManager = cPluginManager:Get()
- PluginManager:BindCommand("/explode", "derpyplugin.explode", Explode, " ~ Explode a player");
+ cPluginManager.BindCommand("/explode", "derpyplugin.explode", Explode, " ~ Explode a player");
cPluginManager:AddHook(cPluginManager.HOOK_COLLECTING_PICKUP, OnCollectingPickup)