diff --git a/README.md b/README.md index c4feb88..cb1ea09 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ * Summary: Manage Multiple Worlds * Dependency Plugins: n/a -* PocketMine-MP version: 1.4 (API:1.10.0) +* PocketMine-MP version: 1.6+php7 (API:2.0.0) * OptionalPlugins: n/a * Categories: Admin Tools, Teleportation * Plugin Access: Commands, Manages Worlds @@ -182,6 +182,7 @@ for sample files. # Changes +* 2.1.0: Updating to new API * 2.0.3: Bugfix update * Fixes bug reported by @thebigsmileXD * 2.0.2: Bug fix diff --git a/plugin.yml b/plugin.yml index ac85287..a39b751 100644 --- a/plugin.yml +++ b/plugin.yml @@ -1,10 +1,10 @@ main: aliuly\manyworlds\Main -api: 1.10.0 +api: 2.0.0 load: POSTWORLD name: ManyWorlds description: Manage Multiple Worlds -version: 2.0.3 +version: 2.1.0 author: aliuly commands: diff --git a/src/aliuly/manyworlds/MwGenLst.php b/src/aliuly/manyworlds/MwGenLst.php index edaf62c..00cedc4 100644 --- a/src/aliuly/manyworlds/MwGenLst.php +++ b/src/aliuly/manyworlds/MwGenLst.php @@ -32,7 +32,7 @@ public function __construct($owner) { public function onSCommand(CommandSender $c,Command $cc,$scmd,$data,array $args) { if (count($args) != 0) return false; - if (MPMU::apiVersion("1.12.0")) { + if (MPMU::apiVersion("1.12.0")||MPMU::apiVersion("2.0.0")) { $c->sendMessage(implode(", ",Generator::getGeneratorList())); } else { $c->sendMessage("normal, flat"); diff --git a/src/aliuly/manyworlds/MwLvDat.php b/src/aliuly/manyworlds/MwLvDat.php index 62d95bd..ba04f5c 100644 --- a/src/aliuly/manyworlds/MwLvDat.php +++ b/src/aliuly/manyworlds/MwLvDat.php @@ -33,10 +33,10 @@ use pocketmine\level\generator\Generator; use pocketmine\nbt\NBT; -use pocketmine\nbt\tag\Int; -use pocketmine\nbt\tag\String; -use pocketmine\nbt\tag\Long; -use pocketmine\nbt\tag\Compound; +//use pocketmine\nbt\tag\IntTag; +use pocketmine\nbt\tag\StringTag; +//use pocketmine\nbt\tag\LongTag; +//use pocketmine\nbt\tag\CompoundTag; use pocketmine\math\Vector3; class MwLvDat extends BasicCli { @@ -110,7 +110,7 @@ public function onSCommand(CommandSender $c,Command $cc,$scmd,$data,array $args) continue; } $changed = true; $unload = true; - $provider->getLevelData()->LevelName = new String("LevelName",$v); + $provider->getLevelData()->LevelName = new StringTag("LevelName",$v); break; case "generator": // generatorName(String) if ($provider->getLevelData()->generatorName == $v) { @@ -118,15 +118,15 @@ public function onSCommand(CommandSender $c,Command $cc,$scmd,$data,array $args) continue; } $changed=true; $unload=true; - $provider->getLevelData()->generatorName=new String("generatorName",$v); + $provider->getLevelData()->generatorName=new StringTag("generatorName",$v); break; - case "preset": // String("generatorOptions"); + case "preset": // StringTag("generatorOptions"); if ($provider->getLevelData()->generatorOptions == $v) { $c->sendMessage(mc::_("Preset unchanged")); continue; } $changed=true; $unload=true; - $provider->getLevelData()->generatorOptions =new String("generatorOptions",$v); + $provider->getLevelData()->generatorOptions =new StringTag("generatorOptions",$v); break; default: $c->sendMessage(mc::_("Unknown key %1%, ignored",$k)); diff --git a/src/aliuly/manyworlds/common/MPMU.php b/src/aliuly/manyworlds/common/MPMU.php index 06e63b8..97126cb 100644 --- a/src/aliuly/manyworlds/common/MPMU.php +++ b/src/aliuly/manyworlds/common/MPMU.php @@ -18,7 +18,7 @@ abstract class MPMU { /** @var str[] $items Nice names for items */ static protected $items = []; /** @const str VERSION plugin version string */ - const VERSION = "1.91.0dev1"; + const VERSION = "1.92.0"; /** * libcommon library version. If a version is provided it will check @@ -137,7 +137,7 @@ static public function inGame(CommandSender $sender,$msg = true) { * @return str */ static public function iName($player) { - if ($player instanceof Player) { + if ($player instanceof CommandSender) { $player = strtolower($player->getName()); } return $player; @@ -182,7 +182,7 @@ static public function callPlugin($server,$plug,$method,$args,$default = null) { $v = null; if (is_array($plug)) list($plug,$v) = $plug; if (($plugin = $server->getPluginManager()->getPlugin($plug)) === null - || $plugin->isEnabled()) return $default; + || !$plugin->isEnabled()) return $default; if ($v !== null && !self::apiCheck($plugin->getDescription()->getVersion(),$v)) return $default; if (property_exists($plugin,"api")) { diff --git a/src/aliuly/manyworlds/common/Session.php b/src/aliuly/manyworlds/common/Session.php index 81dfefc..d190fb2 100644 --- a/src/aliuly/manyworlds/common/Session.php +++ b/src/aliuly/manyworlds/common/Session.php @@ -6,7 +6,8 @@ use pocketmine\event\Listener; use pocketmine\event\player\PlayerQuitEvent; use pocketmine\plugin\PluginBase; -use pocketmine\command\CommandSender; + +use aliuly\manyworlds\common\MPMU; /** * Basic Session Manager functionality @@ -29,7 +30,7 @@ public function __construct(PluginBase $owner) { * @param PlayerQuitEvent $ev - Quit event */ public function onPlayerQuit(PlayerQuitEvent $ev) { - $n = strtolower($ev->getPlayer()->getName()); + $n = MPMU::iName($ev->getPlayer()); if (isset($this->state[$n])) unset($this->state[$n]); } /** @@ -41,8 +42,7 @@ public function onPlayerQuit(PlayerQuitEvent $ev) { * @return mixed */ public function getState($label,$player,$default) { - if ($player instanceof CommandSender) $player = $player->getName(); - $player = strtolower($player); + $player = MPMU::iName($player); if (!isset($this->state[$player])) return $default; if (!isset($this->state[$player][$label])) return $default; return $this->state[$player][$label]; @@ -56,8 +56,7 @@ public function getState($label,$player,$default) { * @return mixed */ public function setState($label,$player,$val) { - if ($player instanceof CommandSender) $player = $player->getName(); - $player = strtolower($player); + $player = MPMU::iName($player); if (!isset($this->state[$player])) $this->state[$player] = []; $this->state[$player][$label] = $val; return $val; @@ -69,8 +68,7 @@ public function setState($label,$player,$val) { * @param Player|str $player - intance of Player or their name */ public function unsetState($label,$player) { - if ($player instanceof CommandSender) $player = $player->getName(); - $player = strtolower($player); + $player = MPMU::iName($player); if (!isset($this->state[$player])) return; if (!isset($this->state[$player][$label])) return; unset($this->state[$player][$label]);