PluginAPI

This commit is contained in:
Shoghi Cervantes Pueyo
2012-12-23 17:37:53 +01:00
parent 99151981db
commit e0c245d86e
6 changed files with 115 additions and 65 deletions

31
example/ExamplePlugin.php Normal file
View File

@ -0,0 +1,31 @@
<?php
/*
__PocketMine Plugin__
name=Example Plugin
version=0.0.1
author=shoghicp
class=ExamplePlugin
api=true
*/
class ExamplePlugin{
private $api;
public function __construct($api, $server = false){
$this->api = $api;
}
public function init(){
$this->api->console->register("example", "Example command", array($this, "handleCommand"));
}
public function handleCommand($cmd, $arg){
switch($cmd){
case "example":
console("EXAMPLE!!!");
break;
}
}
}

View File

@ -1,45 +0,0 @@
<?php
/*
-
/ \
/ \
/ PocketMine \
/ MP \
|\ @shoghicp /|
|. \ / .|
| .. \ / .. |
| .. | .. |
| .. | .. |
\ | /
\ | /
\ | /
\ | /
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.
*/
require_once("common/dependencies.php");
require_once("classes/PocketMinecraftClient.class.php");
file_put_contents("packets.log", "");
define("DEBUG", 2);
$client = new PocketMinecraftClient("shoghicp");
console("[INFO] Searching servers...");
$list = $client->getServerList();
foreach($list as $i => $info){
console("[Server] #".$i." ".$info["ip"]." ".$info["username"]);
}
console("[Select Server] #", false, false);
$i = (int) trim(fgets(STDIN));
if(isset($list[$i])){
$client->start($list[$i]["ip"]);
}else{
console("[Error] Unknown ID");
}