Merge changes from master

This commit is contained in:
Dylan K. Taylor
2017-08-22 14:13:31 +01:00
131 changed files with 690 additions and 505 deletions

View File

@@ -31,7 +31,7 @@ use pocketmine\Player;
class BanCommand extends VanillaCommand{
public function __construct($name){
public function __construct(string $name){
parent::__construct(
$name,
"%pocketmine.command.ban.player.description",

View File

@@ -31,7 +31,7 @@ use pocketmine\Player;
class BanIpCommand extends VanillaCommand{
public function __construct($name){
public function __construct(string $name){
parent::__construct(
$name,
"%pocketmine.command.ban.ip.description",
@@ -71,7 +71,7 @@ class BanIpCommand extends VanillaCommand{
return true;
}
private function processIPBan($ip, CommandSender $sender, $reason){
private function processIPBan(string $ip, CommandSender $sender, string $reason){
$sender->getServer()->getIPBans()->addBan($ip, $reason, null, $sender->getName());
foreach($sender->getServer()->getOnlinePlayers() as $player){

View File

@@ -30,7 +30,7 @@ use pocketmine\permission\BanEntry;
class BanListCommand extends VanillaCommand{
public function __construct($name){
public function __construct(string $name){
parent::__construct(
$name,
"%pocketmine.command.banlist.description",

View File

@@ -30,7 +30,7 @@ use pocketmine\Server;
class DefaultGamemodeCommand extends VanillaCommand{
public function __construct($name){
public function __construct(string $name){
parent::__construct(
$name,
"%pocketmine.command.defaultgamemode.description",

View File

@@ -32,7 +32,7 @@ use pocketmine\utils\TextFormat;
class DeopCommand extends VanillaCommand{
public function __construct($name){
public function __construct(string $name){
parent::__construct(
$name,
"%pocketmine.command.deop.description",

View File

@@ -32,7 +32,7 @@ use pocketmine\Server;
class DifficultyCommand extends VanillaCommand{
public function __construct($name){
public function __construct(string $name){
parent::__construct(
$name,
"%pocketmine.command.difficulty.description",

View File

@@ -29,7 +29,7 @@ class DumpMemoryCommand extends VanillaCommand{
private static $executions = 0;
public function __construct($name){
public function __construct(string $name){
parent::__construct(
$name,
"Dumps the memory",

View File

@@ -31,7 +31,7 @@ use pocketmine\utils\TextFormat;
class EffectCommand extends VanillaCommand{
public function __construct($name){
public function __construct(string $name){
parent::__construct(
$name,
"%pocketmine.command.effect.description",

View File

@@ -31,7 +31,7 @@ use pocketmine\utils\TextFormat;
class EnchantCommand extends VanillaCommand{
public function __construct($name){
public function __construct(string $name){
parent::__construct(
$name,
"%pocketmine.command.enchant.description",

View File

@@ -33,7 +33,7 @@ use pocketmine\utils\TextFormat;
class GamemodeCommand extends VanillaCommand{
public function __construct($name){
public function __construct(string $name){
parent::__construct(
$name,
"%pocketmine.command.gamemode.description",

View File

@@ -28,7 +28,7 @@ use pocketmine\utils\TextFormat;
class GarbageCollectorCommand extends VanillaCommand{
public function __construct($name){
public function __construct(string $name){
parent::__construct(
$name,
"%pocketmine.command.gc.description",

View File

@@ -27,7 +27,7 @@ use pocketmine\command\Command;
use pocketmine\command\CommandSender;
use pocketmine\command\utils\InvalidCommandSyntaxException;
use pocketmine\event\TranslationContainer;
use pocketmine\item\Item;
use pocketmine\item\ItemFactory;
use pocketmine\nbt\JsonNBTParser;
use pocketmine\nbt\tag\CompoundTag;
use pocketmine\Player;
@@ -35,7 +35,7 @@ use pocketmine\utils\TextFormat;
class GiveCommand extends VanillaCommand{
public function __construct($name){
public function __construct(string $name){
parent::__construct(
$name,
"%pocketmine.command.give.description",
@@ -54,7 +54,7 @@ class GiveCommand extends VanillaCommand{
}
$player = $sender->getServer()->getPlayer($args[0]);
$item = Item::fromString($args[1]);
$item = ItemFactory::fromString($args[1]);
if(!isset($args[2])){
$item->setCount($item->getMaxStackSize());

View File

@@ -30,7 +30,7 @@ use pocketmine\utils\TextFormat;
class HelpCommand extends VanillaCommand{
public function __construct($name){
public function __construct(string $name){
parent::__construct(
$name,
"%pocketmine.command.help.description",

View File

@@ -32,7 +32,7 @@ use pocketmine\utils\TextFormat;
class KickCommand extends VanillaCommand{
public function __construct($name){
public function __construct(string $name){
parent::__construct(
$name,
"%pocketmine.command.kick.description",

View File

@@ -33,7 +33,7 @@ use pocketmine\utils\TextFormat;
class KillCommand extends VanillaCommand{
public function __construct($name){
public function __construct(string $name){
parent::__construct(
$name,
"%pocketmine.command.kill.description",

View File

@@ -29,7 +29,7 @@ use pocketmine\Player;
class ListCommand extends VanillaCommand{
public function __construct($name){
public function __construct(string $name){
parent::__construct(
$name,
"%pocketmine.command.list.description",

View File

@@ -31,7 +31,7 @@ use pocketmine\utils\TextFormat;
class MeCommand extends VanillaCommand{
public function __construct($name){
public function __construct(string $name){
parent::__construct(
$name,
"%pocketmine.command.me.description",

View File

@@ -32,7 +32,7 @@ use pocketmine\utils\TextFormat;
class OpCommand extends VanillaCommand{
public function __construct($name){
public function __construct(string $name){
parent::__construct(
$name,
"%pocketmine.command.op.description",

View File

@@ -30,7 +30,7 @@ use pocketmine\event\TranslationContainer;
class PardonCommand extends VanillaCommand{
public function __construct($name){
public function __construct(string $name){
parent::__construct(
$name,
"%pocketmine.command.unban.player.description",

View File

@@ -30,7 +30,7 @@ use pocketmine\event\TranslationContainer;
class PardonIpCommand extends VanillaCommand{
public function __construct($name){
public function __construct(string $name){
parent::__construct(
$name,
"%pocketmine.command.unban.ip.description",

View File

@@ -28,6 +28,7 @@ use pocketmine\command\CommandSender;
use pocketmine\command\utils\InvalidCommandSyntaxException;
use pocketmine\event\TranslationContainer;
use pocketmine\item\Item;
use pocketmine\item\ItemFactory;
use pocketmine\level\particle\AngryVillagerParticle;
use pocketmine\level\particle\BlockForceFieldParticle;
use pocketmine\level\particle\BubbleParticle;
@@ -63,7 +64,7 @@ use pocketmine\utils\TextFormat;
class ParticleCommand extends VanillaCommand{
public function __construct($name){
public function __construct(string $name){
parent::__construct(
$name,
"%pocketmine.command.particle.description",
@@ -125,7 +126,6 @@ class ParticleCommand extends VanillaCommand{
/**
* @param string $name
*
* @param Vector3 $pos
* @param float $xd
* @param float $yd
@@ -134,7 +134,7 @@ class ParticleCommand extends VanillaCommand{
*
* @return Particle|null
*/
private function getParticle($name, Vector3 $pos, $xd, $yd, $zd, $data){
private function getParticle(string $name, Vector3 $pos, float $xd, float $yd, float $zd, int $data = null){
switch($name){
case "explode":
return new ExplodeParticle($pos);
@@ -173,12 +173,12 @@ class ParticleCommand extends VanillaCommand{
case "reddust":
return new RedstoneParticle($pos, $data ?? 1);
case "snowballpoof":
return new ItemBreakParticle($pos, Item::get(Item::SNOWBALL));
return new ItemBreakParticle($pos, ItemFactory::get(Item::SNOWBALL));
case "slime":
return new ItemBreakParticle($pos, Item::get(Item::SLIMEBALL));
return new ItemBreakParticle($pos, ItemFactory::get(Item::SLIMEBALL));
case "itembreak":
if($data !== null and $data !== 0){
return new ItemBreakParticle($pos, Item::get($data));
return new ItemBreakParticle($pos, ItemFactory::get($data));
}
break;
case "terrain":
@@ -206,7 +206,7 @@ class ParticleCommand extends VanillaCommand{
if(strpos($name, "iconcrack_") === 0){
$d = explode("_", $name);
if(count($d) === 3){
return new ItemBreakParticle($pos, Item::get((int) $d[1], (int) $d[2]));
return new ItemBreakParticle($pos, ItemFactory::get((int) $d[1], (int) $d[2]));
}
}elseif(strpos($name, "blockcrack_") === 0){
$d = explode("_", $name);

View File

@@ -29,7 +29,7 @@ use pocketmine\utils\TextFormat;
class PluginsCommand extends VanillaCommand{
public function __construct($name){
public function __construct(string $name){
parent::__construct(
$name,
"%pocketmine.command.plugins.description",

View File

@@ -30,7 +30,7 @@ use pocketmine\utils\TextFormat;
class ReloadCommand extends VanillaCommand{
public function __construct($name){
public function __construct(string $name){
parent::__construct(
$name,
"%pocketmine.command.reload.description",

View File

@@ -29,7 +29,7 @@ use pocketmine\event\TranslationContainer;
class SaveCommand extends VanillaCommand{
public function __construct($name){
public function __construct(string $name){
parent::__construct(
$name,
"%pocketmine.command.save.description",

View File

@@ -29,7 +29,7 @@ use pocketmine\event\TranslationContainer;
class SaveOffCommand extends VanillaCommand{
public function __construct($name){
public function __construct(string $name){
parent::__construct(
$name,
"%pocketmine.command.saveoff.description",

View File

@@ -29,7 +29,7 @@ use pocketmine\event\TranslationContainer;
class SaveOnCommand extends VanillaCommand{
public function __construct($name){
public function __construct(string $name){
parent::__construct(
$name,
"%pocketmine.command.saveon.description",

View File

@@ -32,7 +32,7 @@ use pocketmine\utils\TextFormat;
class SayCommand extends VanillaCommand{
public function __construct($name){
public function __construct(string $name){
parent::__construct(
$name,
"%pocketmine.command.say.description",

View File

@@ -29,7 +29,7 @@ use pocketmine\Player;
class SeedCommand extends VanillaCommand{
public function __construct($name){
public function __construct(string $name){
parent::__construct(
$name,
"%pocketmine.command.seed.description",

View File

@@ -33,7 +33,7 @@ use pocketmine\utils\TextFormat;
class SetWorldSpawnCommand extends VanillaCommand{
public function __construct($name){
public function __construct(string $name){
parent::__construct(
$name,
"%pocketmine.command.setworldspawn.description",

View File

@@ -34,7 +34,7 @@ use pocketmine\utils\TextFormat;
class SpawnpointCommand extends VanillaCommand{
public function __construct($name){
public function __construct(string $name){
parent::__construct(
$name,
"%pocketmine.command.spawnpoint.description",

View File

@@ -29,7 +29,7 @@ use pocketmine\utils\Utils;
class StatusCommand extends VanillaCommand{
public function __construct($name){
public function __construct(string $name){
parent::__construct(
$name,
"%pocketmine.command.status.description",

View File

@@ -29,7 +29,7 @@ use pocketmine\event\TranslationContainer;
class StopCommand extends VanillaCommand{
public function __construct($name){
public function __construct(string $name){
parent::__construct(
$name,
"%pocketmine.command.stop.description",

View File

@@ -33,7 +33,7 @@ use pocketmine\utils\TextFormat;
class TeleportCommand extends VanillaCommand{
public function __construct($name){
public function __construct(string $name){
parent::__construct(
$name,
"%pocketmine.command.tp.description",

View File

@@ -31,7 +31,7 @@ use pocketmine\utils\TextFormat;
class TellCommand extends VanillaCommand{
public function __construct($name){
public function __construct(string $name){
parent::__construct(
$name,
"%pocketmine.command.tell.description",

View File

@@ -33,7 +33,7 @@ use pocketmine\utils\TextFormat;
class TimeCommand extends VanillaCommand{
public function __construct($name){
public function __construct(string $name){
parent::__construct(
$name,
"%pocketmine.command.time.description",

View File

@@ -35,7 +35,7 @@ class TimingsCommand extends VanillaCommand{
public static $timingStart = 0;
public function __construct($name){
public function __construct(string $name){
parent::__construct(
$name,
"%pocketmine.command.timings.description",

View File

@@ -29,7 +29,7 @@ use pocketmine\event\TranslationContainer;
class TitleCommand extends VanillaCommand{
public function __construct($name){
public function __construct(string $name){
parent::__construct(
$name,
"%pocketmine.command.title.description",

View File

@@ -31,7 +31,7 @@ use pocketmine\Player;
class TransferServerCommand extends VanillaCommand{
public function __construct($name){
public function __construct(string $name){
parent::__construct(
$name,
"%pocketmine.command.transferserver.description",

View File

@@ -30,11 +30,15 @@ abstract class VanillaCommand extends Command{
const MAX_COORD = 30000000;
const MIN_COORD = -30000000;
public function __construct($name, $description = "", $usageMessage = null, array $aliases = []){
parent::__construct($name, $description, $usageMessage, $aliases);
}
protected function getInteger(CommandSender $sender, $value, $min = self::MIN_COORD, $max = self::MAX_COORD){
/**
* @param CommandSender $sender
* @param mixed $value
* @param int $min
* @param int $max
*
* @return int
*/
protected function getInteger(CommandSender $sender, $value, int $min = self::MIN_COORD, int $max = self::MAX_COORD) : int{
$i = (int) $value;
if($i < $min){
@@ -46,7 +50,16 @@ abstract class VanillaCommand extends Command{
return $i;
}
protected function getRelativeDouble($original, CommandSender $sender, $input, $min = self::MIN_COORD, $max = self::MAX_COORD){
/**
* @param float $original
* @param CommandSender $sender
* @param string $input
* @param float $min
* @param float $max
*
* @return float
*/
protected function getRelativeDouble(float $original, CommandSender $sender, string $input, float $min = self::MIN_COORD, float $max = self::MAX_COORD) : float{
if($input{0} === "~"){
$value = $this->getDouble($sender, substr($input, 1));
@@ -56,7 +69,15 @@ abstract class VanillaCommand extends Command{
return $this->getDouble($sender, $input, $min, $max);
}
protected function getDouble(CommandSender $sender, $value, $min = self::MIN_COORD, $max = self::MAX_COORD){
/**
* @param CommandSender $sender
* @param mixed $value
* @param float $min
* @param float $max
*
* @return float
*/
protected function getDouble(CommandSender $sender, $value, float $min = self::MIN_COORD, float $max = self::MAX_COORD) : float{
$i = (double) $value;
if($i < $min){

View File

@@ -31,7 +31,7 @@ use pocketmine\utils\TextFormat;
class VersionCommand extends VanillaCommand{
public function __construct($name){
public function __construct(string $name){
parent::__construct(
$name,
"%pocketmine.command.version.description",

View File

@@ -31,7 +31,7 @@ use pocketmine\utils\TextFormat;
class WhitelistCommand extends VanillaCommand{
public function __construct($name){
public function __construct(string $name){
parent::__construct(
$name,
"%pocketmine.command.whitelist.description",
@@ -108,7 +108,7 @@ class WhitelistCommand extends VanillaCommand{
return true;
}
private function badPerm(CommandSender $sender, $perm){
private function badPerm(CommandSender $sender, string $perm) : bool{
if(!$sender->hasPermission("pocketmine.command.whitelist.$perm")){
$sender->sendMessage(new TranslationContainer(TextFormat::RED . "%commands.generic.permission"));