mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-20 16:00:20 +00:00
Merge branch 'php-5.6'
This commit is contained in:
commit
812ae09a06
@ -20,9 +20,9 @@
|
||||
*/
|
||||
|
||||
namespace {
|
||||
function safe_var_dump(){
|
||||
function safe_var_dump(...$params){
|
||||
static $cnt = 0;
|
||||
foreach(func_get_args() as $var){
|
||||
foreach($params as $var){
|
||||
switch(true){
|
||||
case is_array($var):
|
||||
echo str_repeat(" ", $cnt) . "array(" . count($var) . ") {" . PHP_EOL;
|
||||
@ -263,8 +263,8 @@ namespace pocketmine {
|
||||
|
||||
$errors = 0;
|
||||
|
||||
if(version_compare("5.5.0", PHP_VERSION) > 0){
|
||||
$logger->critical("Use PHP >= 5.5.0");
|
||||
if(version_compare("5.6.0", PHP_VERSION) > 0){
|
||||
$logger->critical("You must use PHP >= 5.6");
|
||||
++$errors;
|
||||
}
|
||||
|
||||
|
@ -1489,7 +1489,7 @@ class Server{
|
||||
|
||||
Level::$COMPRESSION_LEVEL = $this->getProperty("chunk-sending.compression-level", 7);
|
||||
|
||||
if(defined("pocketmine\\DEBUG") and \pocketmine\DEBUG >= 0 and function_exists("cli_set_process_title")){
|
||||
if(defined("pocketmine\\DEBUG") and \pocketmine\DEBUG >= 0){
|
||||
@cli_set_process_title($this->getName() . " " . $this->getPocketMineVersion());
|
||||
}
|
||||
|
||||
|
@ -225,9 +225,8 @@ abstract class BaseInventory implements Inventory{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function addItem(){
|
||||
public function addItem(...$slots){
|
||||
/** @var Item[] $slots */
|
||||
$slots = func_get_args();
|
||||
foreach($slots as $i => $slot){
|
||||
$slots[$i] = clone $slot;
|
||||
}
|
||||
@ -264,9 +263,8 @@ abstract class BaseInventory implements Inventory{
|
||||
return $slots;
|
||||
}
|
||||
|
||||
public function removeItem(){
|
||||
public function removeItem(...$slots){
|
||||
/** @var Item[] $slots */
|
||||
$slots = func_get_args();
|
||||
for($i = 0; $i < $this->getSize(); ++$i){
|
||||
$item = $this->getItem($i);
|
||||
if($item->getID() === Item::AIR){
|
||||
|
@ -73,7 +73,7 @@ interface Inventory{
|
||||
*
|
||||
* @return Item[]
|
||||
*/
|
||||
public function addItem();
|
||||
public function addItem(...$slots);
|
||||
|
||||
/**
|
||||
* Checks if a given Item can be added to the inventory
|
||||
@ -92,7 +92,7 @@ interface Inventory{
|
||||
*
|
||||
* @return Item[]
|
||||
*/
|
||||
public function removeItem();
|
||||
public function removeItem(...$slots);
|
||||
|
||||
/**
|
||||
* @return Item[]
|
||||
|
@ -393,63 +393,63 @@ class Item{
|
||||
public static function init(){
|
||||
if(count(self::$list) === 0){
|
||||
self::$list = array(
|
||||
self::SUGARCANE => new Sugarcane(),
|
||||
self::WHEAT_SEEDS => new WheatSeeds(),
|
||||
self::PUMPKIN_SEEDS => new PumpkinSeeds(),
|
||||
self::MELON_SEEDS => new MelonSeeds(),
|
||||
self::MUSHROOM_STEW => new MushroomStew(),
|
||||
self::BEETROOT_SOUP => new BeetrootSoup(),
|
||||
self::CARROT => new Carrot(),
|
||||
self::POTATO => new Potato(),
|
||||
self::BEETROOT_SEEDS => new BeetrootSeeds(),
|
||||
self::SIGN => new Sign(),
|
||||
self::WOODEN_DOOR => new WoodenDoor(),
|
||||
self::BUCKET => new Bucket(),
|
||||
self::IRON_DOOR => new IronDoor(),
|
||||
self::CAKE => new Cake(),
|
||||
self::BED => new Bed(),
|
||||
self::PAINTING => new Painting(),
|
||||
self::COAL => new Coal(),
|
||||
self::APPLE => new Apple(),
|
||||
self::SPAWN_EGG => new SpawnEgg(),
|
||||
self::DIAMOND => new Diamond(),
|
||||
self::STICK => new Stick(),
|
||||
self::BOWL => new Bowl(),
|
||||
self::FEATHER => new Feather(),
|
||||
self::BRICK => new Brick(),
|
||||
self::IRON_SWORD => new IronSword(),
|
||||
self::IRON_INGOT => new IronIngot(),
|
||||
self::GOLD_INGOT => new GoldIngot(),
|
||||
self::IRON_SHOVEL => new IronShovel(),
|
||||
self::IRON_PICKAXE => new IronPickaxe(),
|
||||
self::IRON_AXE => new IronAxe(),
|
||||
self::IRON_HOE => new IronHoe(),
|
||||
self::DIAMOND_SWORD => new DiamondSword(),
|
||||
self::DIAMOND_SHOVEL => new DiamondShovel(),
|
||||
self::DIAMOND_PICKAXE => new DiamondPickaxe(),
|
||||
self::DIAMOND_AXE => new DiamondAxe(),
|
||||
self::DIAMOND_HOE => new DiamondHoe(),
|
||||
self::GOLD_SWORD => new GoldSword(),
|
||||
self::GOLD_SHOVEL => new GoldShovel(),
|
||||
self::GOLD_PICKAXE => new GoldPickaxe(),
|
||||
self::GOLD_AXE => new GoldAxe(),
|
||||
self::GOLD_HOE => new GoldHoe(),
|
||||
self::STONE_SWORD => new StoneSword(),
|
||||
self::STONE_SHOVEL => new StoneShovel(),
|
||||
self::STONE_PICKAXE => new StonePickaxe(),
|
||||
self::STONE_AXE => new StoneAxe(),
|
||||
self::STONE_HOE => new StoneHoe(),
|
||||
self::WOODEN_SWORD => new WoodenSword(),
|
||||
self::WOODEN_SHOVEL => new WoodenShovel(),
|
||||
self::WOODEN_PICKAXE => new WoodenPickaxe(),
|
||||
self::WOODEN_AXE => new WoodenAxe(),
|
||||
self::WOODEN_HOE => new WoodenHoe(),
|
||||
self::FLINT_STEEL => new FlintSteel(),
|
||||
self::SHEARS => new Shears(),
|
||||
self::BOW => new Bow(),
|
||||
self::SUGARCANE => Sugarcane::class,
|
||||
self::WHEAT_SEEDS => WheatSeeds::class,
|
||||
self::PUMPKIN_SEEDS => PumpkinSeeds::class,
|
||||
self::MELON_SEEDS => MelonSeeds::class,
|
||||
self::MUSHROOM_STEW => MushroomStew::class,
|
||||
self::BEETROOT_SOUP => BeetrootSoup::class,
|
||||
self::CARROT => Carrot::class,
|
||||
self::POTATO => Potato::class,
|
||||
self::BEETROOT_SEEDS => BeetrootSeeds::class,
|
||||
self::SIGN => Sign::class,
|
||||
self::WOODEN_DOOR => WoodenDoor::class,
|
||||
self::BUCKET => Bucket::class,
|
||||
self::IRON_DOOR => IronDoor::class,
|
||||
self::CAKE => Cake::class,
|
||||
self::BED => Bed::class,
|
||||
self::PAINTING => Painting::class,
|
||||
self::COAL => Coal::class,
|
||||
self::APPLE => Apple::class,
|
||||
self::SPAWN_EGG => SpawnEgg::class,
|
||||
self::DIAMOND => Diamond::class,
|
||||
self::STICK => Stick::class,
|
||||
self::BOWL => Bowl::class,
|
||||
self::FEATHER => Feather::class,
|
||||
self::BRICK => Brick::class,
|
||||
self::IRON_SWORD => IronSword::class,
|
||||
self::IRON_INGOT => IronIngot::class,
|
||||
self::GOLD_INGOT => GoldIngot::class,
|
||||
self::IRON_SHOVEL => IronShovel::class,
|
||||
self::IRON_PICKAXE => IronPickaxe::class,
|
||||
self::IRON_AXE => IronAxe::class,
|
||||
self::IRON_HOE => IronHoe::class,
|
||||
self::DIAMOND_SWORD => DiamondSword::class,
|
||||
self::DIAMOND_SHOVEL => DiamondShovel::class,
|
||||
self::DIAMOND_PICKAXE => DiamondPickaxe::class,
|
||||
self::DIAMOND_AXE => DiamondAxe::class,
|
||||
self::DIAMOND_HOE => DiamondHoe::class,
|
||||
self::GOLD_SWORD => GoldSword::class,
|
||||
self::GOLD_SHOVEL => GoldShovel::class,
|
||||
self::GOLD_PICKAXE => GoldPickaxe::class,
|
||||
self::GOLD_AXE => GoldAxe::class,
|
||||
self::GOLD_HOE => GoldHoe::class,
|
||||
self::STONE_SWORD => StoneSword::class,
|
||||
self::STONE_SHOVEL => StoneShovel::class,
|
||||
self::STONE_PICKAXE => StonePickaxe::class,
|
||||
self::STONE_AXE => StoneAxe::class,
|
||||
self::STONE_HOE => StoneHoe::class,
|
||||
self::WOODEN_SWORD => WoodenSword::class,
|
||||
self::WOODEN_SHOVEL => WoodenShovel::class,
|
||||
self::WOODEN_PICKAXE => WoodenPickaxe::class,
|
||||
self::WOODEN_AXE => WoodenAxe::class,
|
||||
self::WOODEN_HOE => WoodenHoe::class,
|
||||
self::FLINT_STEEL => FlintSteel::class,
|
||||
self::SHEARS => Shears::class,
|
||||
self::BOW => Bow::class,
|
||||
);
|
||||
foreach(Block::$list as $id => $class){
|
||||
self::$list[$id] = new ItemBlock(new $class);
|
||||
self::$list[$id] = $class;
|
||||
}
|
||||
|
||||
}
|
||||
@ -457,9 +457,12 @@ class Item{
|
||||
|
||||
public static function get($id, $meta = 0, $count = 1){
|
||||
if(isset(self::$list[$id])){
|
||||
$item = clone self::$list[$id];
|
||||
$item->setDamage($meta);
|
||||
$item->setCount($count);
|
||||
$class = self::$list[$id];
|
||||
if($id < 256){
|
||||
$item = new ItemBlock(new $class($meta), $meta, $count);
|
||||
}else{
|
||||
$item = new $class($meta, $count);
|
||||
}
|
||||
}else{
|
||||
$item = new Item($id, $meta, $count);
|
||||
}
|
||||
|
@ -100,9 +100,7 @@ class ChunkRequestTask extends AsyncTask{
|
||||
}
|
||||
}
|
||||
|
||||
$biomeColors = $this->biomeColors;
|
||||
array_unshift($biomeColors, "N*");
|
||||
$biomeColors = call_user_func_array("pack", $biomeColors);
|
||||
$biomeColors = pack("N*", ...$this->biomeColors);
|
||||
|
||||
$ordered = zlib_encode(Binary::writeLInt($this->chunkX) . Binary::writeLInt($this->chunkZ) . $orderedIds . $orderedData . $orderedSkyLight . $orderedLight . $this->biomeIds . $biomeColors . $this->tiles, ZLIB_ENCODING_DEFLATE, $this->compressionLevel);
|
||||
|
||||
|
@ -122,9 +122,7 @@ class McRegion extends BaseLevelProvider{
|
||||
}
|
||||
}
|
||||
|
||||
$biomeColors = $chunk->getBiomeColorArray();
|
||||
array_unshift($biomeColors, "N*");
|
||||
$biomeColors = call_user_func_array("pack", $biomeColors);
|
||||
$biomeColors = pack("N*", ...$chunk->getBiomeColorArray());
|
||||
|
||||
$ordered = zlib_encode(
|
||||
Binary::writeLInt($x) . Binary::writeLInt($z) .
|
||||
|
@ -37,8 +37,6 @@ class IntArray extends NamedTag{
|
||||
|
||||
public function write(NBT $nbt){
|
||||
$nbt->putInt(count($this->value));
|
||||
$ints = $this->value;
|
||||
array_unshift($ints, $nbt->endianness === NBT::LITTLE_ENDIAN ? "V*" : "N*");
|
||||
$nbt->put(call_user_func_array("pack", $ints));
|
||||
$nbt->put(pack($nbt->endianness === NBT::LITTLE_ENDIAN ? "V*" : "N*", ...$this->value));
|
||||
}
|
||||
}
|
@ -33,7 +33,7 @@ class MethodEventExecutor implements EventExecutor{
|
||||
}
|
||||
|
||||
public function execute(Listener $listener, Event $event){
|
||||
call_user_func(array($listener, $this->method), $event);
|
||||
$listener->{$this->getMethod()}($event);
|
||||
}
|
||||
|
||||
public function getMethod(){
|
||||
|
Loading…
x
Reference in New Issue
Block a user