Changed Command inheritance

This commit is contained in:
Shoghi Cervantes 2014-03-26 18:10:49 +01:00
parent 2112de42ad
commit 76438e78d2
4 changed files with 71 additions and 4 deletions

View File

@ -84,7 +84,7 @@ abstract class Command{
* @param string $usageMessage
* @param string[] $aliases
*/
protected function __construct($name, $description = "", $usageMessage = null, array $aliases = array()){
public function __construct($name, $description = "", $usageMessage = null, array $aliases = array()){
$this->name = $name;
$this->nextLabel = $name;
$this->label = $name;

View File

@ -0,0 +1,68 @@
<?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 PocketMine\Command\Defaults;
use PocketMine\Command\CommandSender;
use PocketMine\Utils\TextFormat;
use PocketMine\Player;
use PocketMine\Level\Level;
use PocketMine;
class SeedCommand extends VanillaCommand{
public function __construct($name){
parent::__construct(
$name,
"Shows the world seed",
"/seed"
);
$this->setPermission("pocketmine.command.seed");
}
public function execute(CommandSender $sender, $currentAlias, array $args){
if(!$this->testPermission($sender)){
return true;
}
if($sender instanceof Player){
$seed = $sender->getLevel()->getSeed();
}else{
$seed = Level::getDefault()->getSeed();
}
$sender->sendMessage("Seed: " . $seed);
return true;
}
private function getPluginList(){
$list = "";
foreach(($plugins = PocketMine\Server::getInstance()->getPluginManager()->getPlugins()) as $plugin){
if(strlen($list) > 0){
$list .= TextFormat::WHITE . ", ";
}
$list .= $plugin->isEnabled() ? TextFormat::GREEN : TextFormat::RED;
$list .= $plugin->getDescription()->getName();
}
return "(" . count($plugins) . "): $list";
}
}

View File

@ -30,7 +30,7 @@ abstract class VanillaCommand extends Command{
const MAX_COORD = 524288;
const MIN_COORD = -524288;
protected function __construct($name, $description = "", $usageMessage = null, array $aliases = array()){
public function __construct($name, $description = "", $usageMessage = null, array $aliases = array()){
parent::__construct($name, $description, $usageMessage, $aliases);
}

View File

@ -26,7 +26,6 @@ namespace PocketMine\Network;
use PocketMine\Network\Query\QueryPacket;
use PocketMine\Network\RakNet\Info;
use PocketMine\Network\RakNet\Packet;
use PocketMine\Network\RakNet\Packet as RakNetPacket;
use PocketMine;
@ -143,7 +142,7 @@ class ThreadedHandler extends \Thread{
}
private function putPacket(){
if(($packet = $this->queue->synchronized(function (){
if(($packet = $this->queue->synchronized(function(){
return $this->queue->shift();
})) instanceof Packet
){