diff --git a/plugin.yml b/plugin.yml index 261cfdc..cd5a352 100644 --- a/plugin.yml +++ b/plugin.yml @@ -1,6 +1,6 @@ name: TableSpoon main: Xenophilicy\TableSpoon\TableSpoon -version: 0.0.6-ALPHA +version: 0.0.7-ALPHA api: 3.13.0 authors: [ CortexPE, Xenophilicy, HyperFlareMC ] description: Adds cool features to PocketMine diff --git a/resources/config.yml b/resources/config.yml index 465594b..6bed138 100644 --- a/resources/config.yml +++ b/resources/config.yml @@ -1,4 +1,4 @@ -VERSION: "1.0.2" # Internal use only +VERSION: "1.1.0" # Internal use only entities: # Enable lightning and fire damage @@ -23,14 +23,20 @@ enchantments: dimensions: # Nether dimension configuration nether: - # Enable or disable the Nether dimension + # Enable or disable teleporting to the Nether dimension (using portal) enabled: true + # Enable or disable the Nether level generation + # If you have your own Nether world, you can disable this to use it + generate: true # Set the name of the nether level name: "nether" # End dimension configuration end: - # Enable or disable the End dimension + # Enable or disable teleporting to the End dimension (using portal) enabled: false + # Enable or disable the End level generation + # If you have your own End world, you can disable this to use it + generate: true # Set the name of the end level name: "end" diff --git a/src/Xenophilicy/TableSpoon/TableSpoon.php b/src/Xenophilicy/TableSpoon/TableSpoon.php index bbfdc91..c858da3 100644 --- a/src/Xenophilicy/TableSpoon/TableSpoon.php +++ b/src/Xenophilicy/TableSpoon/TableSpoon.php @@ -29,7 +29,7 @@ */ class TableSpoon extends PluginBase { - public const CONFIG_VERSION = "1.0.2"; + public const CONFIG_VERSION = "1.1.0"; /** @var Config */ public static $cacheFile; @@ -63,8 +63,16 @@ public function onLoad(){ } public function onEnable(){ - $this->initManagers(); $this->checkConfigVersion(); + $this->initManagers(); + } + + private function checkConfigVersion(){ + if(version_compare(self::CONFIG_VERSION, $this->getConfig()->get("VERSION"), "gt")){ + $this->getLogger()->warning("You've updated TableSpoon but have an outdated config! Please delete your old config for new features to be enabled and to prevent unwanted errors!"); + $this->getServer()->getPluginManager()->disablePlugin($this); + return; + } } private function initManagers(){ @@ -91,16 +99,6 @@ private function initManagers(){ } } - private function checkConfigVersion(){ - $configVersion = $this->getConfig()->get("VERSION"); - $pluginVersion = $this->getDescription()->getVersion(); - if(version_compare(self::CONFIG_VERSION, $configVersion, "gt")){ - $this->getLogger()->warning("You have updated TableSpoon to v" . $pluginVersion . " but have a config from v$configVersion! Please delete your old config for new features to be enabled and to prevent unwanted errors!"); - $this->getServer()->getPluginManager()->disablePlugin($this); - return; - } - } - public function onDisable(){ self::$cacheFile->save(); } diff --git a/src/Xenophilicy/TableSpoon/block/multiblock/PortalMultiBlock.php b/src/Xenophilicy/TableSpoon/block/multiblock/PortalMultiBlock.php index bd924fa..209bf36 100644 --- a/src/Xenophilicy/TableSpoon/block/multiblock/PortalMultiBlock.php +++ b/src/Xenophilicy/TableSpoon/block/multiblock/PortalMultiBlock.php @@ -9,6 +9,7 @@ use pocketmine\level\Level; use pocketmine\Player; use Xenophilicy\TableSpoon\player\PlayerSessionManager; +use Xenophilicy\TableSpoon\TableSpoon; /** * Class PortalMultiBlock @@ -29,10 +30,12 @@ final public function getTeleportationDuration(Player $player): int{ abstract public function getTargetWorldInstance(): Level; public function onPlayerMoveInside(Player $player, Block $block): void{ + if(!TableSpoon::$settings["dimensions"]["nether"]["enabled"]) return; PlayerSessionManager::get($player)->onEnterPortal($this); } public function onPlayerMoveOutside(Player $player, Block $block): void{ + if(!TableSpoon::$settings["dimensions"]["nether"]["enabled"]) return; PlayerSessionManager::get($player)->onLeavePortal(); } } \ No newline at end of file diff --git a/src/Xenophilicy/TableSpoon/item/FishingRod.php b/src/Xenophilicy/TableSpoon/item/FishingRod.php index 69fd26f..3195fe3 100644 --- a/src/Xenophilicy/TableSpoon/item/FishingRod.php +++ b/src/Xenophilicy/TableSpoon/item/FishingRod.php @@ -37,11 +37,11 @@ public function getMaxStackSize(): int{ } public function getMaxDurability(): int{ - return 355; // TODO: Know why it breaks early at 65 + return 355; } public function onClickAir(Player $player, Vector3 $directionVector): bool{ - if(TableSpoon::$settings["fishing"]["enabled"]){ + if(TableSpoon::$settings["player"]["fishing"]["enabled"]){ $session = TableSpoon::getInstance()->getSessionById($player->getId()); if($session instanceof PlayerSession){ if(!$session->fishing){ diff --git a/src/Xenophilicy/TableSpoon/level/LevelManager.php b/src/Xenophilicy/TableSpoon/level/LevelManager.php index 96b2243..3e1815d 100644 --- a/src/Xenophilicy/TableSpoon/level/LevelManager.php +++ b/src/Xenophilicy/TableSpoon/level/LevelManager.php @@ -32,14 +32,18 @@ private static function registerGenerators(){ private static function loadAndGenerateLevels(){ TableSpoon::$overworldLevel = TableSpoon::getInstance()->getServer()->getDefaultLevel(); if(TableSpoon::$settings["dimensions"]["nether"]["enabled"]){ - if(!Server::getInstance()->loadLevel(TableSpoon::$settings["dimensions"]["nether"]["name"])){ - Server::getInstance()->generateLevel(TableSpoon::$settings["dimensions"]["nether"]["name"], (time()), GeneratorManager::getGenerator("nether")); + if(TableSpoon::$settings["dimensions"]["nether"]["generate"]){ + if(!Server::getInstance()->loadLevel(TableSpoon::$settings["dimensions"]["nether"]["name"])){ + Server::getInstance()->generateLevel(TableSpoon::$settings["dimensions"]["nether"]["name"], (time()), GeneratorManager::getGenerator("nether")); + } } TableSpoon::$netherLevel = Server::getInstance()->getLevelByName(TableSpoon::$settings["dimensions"]["nether"]["name"]); } if(TableSpoon::$settings["dimensions"]["end"]["enabled"]){ - if(!Server::getInstance()->loadLevel(TableSpoon::$settings["dimensions"]["end"]["name"])){ - Server::getInstance()->generateLevel(TableSpoon::$settings["dimensions"]["end"]["name"], time(), GeneratorManager::getGenerator("ender")); + if(TableSpoon::$settings["dimensions"]["end"]["generate"]){ + if(!Server::getInstance()->loadLevel(TableSpoon::$settings["dimensions"]["end"]["name"])){ + Server::getInstance()->generateLevel(TableSpoon::$settings["dimensions"]["end"]["name"], time(), GeneratorManager::getGenerator("ender")); + } } TableSpoon::$endLevel = Server::getInstance()->getLevelByName(TableSpoon::$settings["dimensions"]["end"]["name"]); }