Skip to content
This repository has been archived by the owner on Mar 12, 2021. It is now read-only.

Commit

Permalink
Fix #25 and fix #28
Browse files Browse the repository at this point in the history
  • Loading branch information
Xenophilicy committed Oct 1, 2020
1 parent ce6b4b3 commit 352c579
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 22 deletions.
2 changes: 1 addition & 1 deletion 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
Expand Down
12 changes: 9 additions & 3 deletions 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
Expand All @@ -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"

Expand Down
22 changes: 10 additions & 12 deletions src/Xenophilicy/TableSpoon/TableSpoon.php
Expand Up @@ -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;
Expand Down Expand Up @@ -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(){
Expand All @@ -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();
}
Expand Down
Expand Up @@ -9,6 +9,7 @@
use pocketmine\level\Level;
use pocketmine\Player;
use Xenophilicy\TableSpoon\player\PlayerSessionManager;
use Xenophilicy\TableSpoon\TableSpoon;

/**
* Class PortalMultiBlock
Expand All @@ -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();
}
}
4 changes: 2 additions & 2 deletions src/Xenophilicy/TableSpoon/item/FishingRod.php
Expand Up @@ -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){
Expand Down
12 changes: 8 additions & 4 deletions src/Xenophilicy/TableSpoon/level/LevelManager.php
Expand Up @@ -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"]);
}
Expand Down

0 comments on commit 352c579

Please sign in to comment.