diff --git a/src/MyPlot/EventListener.php b/src/MyPlot/EventListener.php index 7e2e485d..9602ff74 100644 --- a/src/MyPlot/EventListener.php +++ b/src/MyPlot/EventListener.php @@ -7,6 +7,8 @@ use MyPlot\events\MyPlotPlayerEnterPlotEvent; use MyPlot\events\MyPlotPlayerLeavePlotEvent; use MyPlot\events\MyPlotPvpEvent; +use MyPlot\plot\BasePlot; +use MyPlot\plot\SinglePlot; use pocketmine\block\Liquid; use pocketmine\block\Sapling; use pocketmine\block\utils\TreeType; @@ -38,25 +40,25 @@ public function __construct(private MyPlot $plugin, private InternalAPI $interna * @param WorldLoadEvent $event */ public function onLevelLoad(WorldLoadEvent $event) : void{ - if(file_exists($this->plugin->getDataFolder()."worlds".DIRECTORY_SEPARATOR.$event->getWorld()->getFolderName().".yml")) { + if(file_exists($this->plugin->getDataFolder() . "worlds" . DIRECTORY_SEPARATOR . $event->getWorld()->getFolderName() . ".yml")){ $this->plugin->getLogger()->debug("MyPlot level " . $event->getWorld()->getFolderName() . " loaded!"); $settings = $event->getWorld()->getProvider()->getWorldData()->getGeneratorOptions(); $settings = json_decode($settings, true); - if($settings === false) { + if($settings === false){ return; } $levelName = $event->getWorld()->getFolderName(); - $default = array_filter((array) $this->plugin->getConfig()->get("DefaultWorld", []), function($key) : bool { + $default = array_filter((array) $this->plugin->getConfig()->get("DefaultWorld", []), function($key) : bool{ return !in_array($key, ["PlotSize", "GroundHeight", "RoadWidth", "RoadBlock", "WallBlock", "PlotFloorBlock", "PlotFillBlock", "BottomBlock"], true); }, ARRAY_FILTER_USE_KEY); - $config = new Config($this->plugin->getDataFolder()."worlds".DIRECTORY_SEPARATOR.$levelName.".yml", Config::YAML, $default); - foreach(array_keys($default) as $key) { - $settings[$key] = $config->get((string)$key); + $config = new Config($this->plugin->getDataFolder() . "worlds" . DIRECTORY_SEPARATOR . $levelName . ".yml", Config::YAML, $default); + foreach(array_keys($default) as $key){ + $settings[$key] = $config->get((string) $key); } $this->internalAPI->addLevelSettings($levelName, new PlotLevelSettings($levelName, $settings)); - if($this->plugin->getConfig()->get('AllowFireTicking', false) === false) { - $ref = new \ReflectionClass($event->getWorld()); + if($this->plugin->getConfig()->get('AllowFireTicking', false) === false){ + $ref = new \ReflectionClass(World::class); $prop = $ref->getProperty('randomTickBlocks'); $prop->setAccessible(true); $randomTickBlocks = $prop->getValue($event->getWorld()); @@ -71,7 +73,7 @@ public function onLevelLoad(WorldLoadEvent $event) : void{ * * @param WorldUnloadEvent $event */ - public function onLevelUnload(WorldUnloadEvent $event) : void { + public function onLevelUnload(WorldUnloadEvent $event) : void{ $levelName = $event->getWorld()->getFolderName(); if($this->internalAPI->unloadLevelSettings($levelName)){ $this->plugin->getLogger()->debug("Level " . $event->getWorld()->getFolderName() . " unloaded!"); @@ -84,7 +86,7 @@ public function onLevelUnload(WorldUnloadEvent $event) : void { * * @param BlockPlaceEvent $event */ - public function onBlockPlace(BlockPlaceEvent $event) : void { + public function onBlockPlace(BlockPlaceEvent $event) : void{ $this->onEventOnBlock($event); } @@ -94,7 +96,7 @@ public function onBlockPlace(BlockPlaceEvent $event) : void { * * @param BlockBreakEvent $event */ - public function onBlockBreak(BlockBreakEvent $event) : void { + public function onBlockBreak(BlockBreakEvent $event) : void{ $this->onEventOnBlock($event); } @@ -104,7 +106,7 @@ public function onBlockBreak(BlockBreakEvent $event) : void { * * @param PlayerInteractEvent $event */ - public function onPlayerInteract(PlayerInteractEvent $event) : void { + public function onPlayerInteract(PlayerInteractEvent $event) : void{ $this->onEventOnBlock($event); } @@ -114,7 +116,7 @@ public function onPlayerInteract(PlayerInteractEvent $event) : void { * * @param SignChangeEvent $event */ - public function onSignChange(SignChangeEvent $event) : void { + public function onSignChange(SignChangeEvent $event) : void{ $this->onEventOnBlock($event); } @@ -136,8 +138,8 @@ private function onEventOnBlock(BlockPlaceEvent|SignChangeEvent|PlayerInteractEv $ev->call(); $ev->isCancelled() ? $event->cancel() : $event->uncancel(); - $plot = $this->internalAPI->getPlotFromCache($plot); - if($plot === null){ + $plot = $this->internalAPI->getPlotFromCache($plot, true); + if(!$plot instanceof SinglePlot){ $event->cancel(); $this->plugin->getLogger()->debug("Cancelled block change event at $x,$pos->y,$z in [$levelName]"); return; @@ -167,8 +169,8 @@ private function onEventOnBlock(BlockPlaceEvent|SignChangeEvent|PlayerInteractEv elseif($plotLevel->editBorderBlocks){ $plot = $this->internalAPI->getPlotBorderingPosition($event->getBlock()->getPosition()); if($plot !== null){ - $plot = $this->internalAPI->getPlotFromCache($plot); - if($plot === null){ + $plot = $this->internalAPI->getPlotFromCache($plot, true); + if(!$plot instanceof SinglePlot){ $event->cancel(); $this->plugin->getLogger()->debug("Cancelled block change event at $x,$pos->y,$z in [$levelName]"); return; @@ -188,7 +190,7 @@ private function onEventOnBlock(BlockPlaceEvent|SignChangeEvent|PlayerInteractEv } } $event->cancel(); - $this->plugin->getLogger()->debug("Block placement/break/interaction of {$event->getBlock()->getName()} was cancelled at ".$event->getBlock()->getPosition()->__toString()); + $this->plugin->getLogger()->debug("Block placement/break/interaction of {$event->getBlock()->getName()} was cancelled at " . $event->getBlock()->getPosition()->__toString()); } /** @@ -230,7 +232,7 @@ public function onExplosion(EntityExplodeEvent $event) : void{ * * @param EntityMotionEvent $event */ - public function onEntityMotion(EntityMotionEvent $event) : void { + public function onEntityMotion(EntityMotionEvent $event) : void{ $level = $event->getEntity()->getWorld(); if(!$level instanceof World) return; @@ -238,7 +240,7 @@ public function onEntityMotion(EntityMotionEvent $event) : void { if($this->internalAPI->getLevelSettings($levelName) === null) return; $settings = $this->internalAPI->getLevelSettings($levelName); - if($settings->restrictEntityMovement and !($event->getEntity() instanceof Player)) { + if($settings->restrictEntityMovement and !($event->getEntity() instanceof Player)){ $event->cancel(); $this->plugin->getLogger()->debug("Cancelled entity motion on " . $levelName); } @@ -282,7 +284,7 @@ public function onBlockSpread(BlockSpreadEvent $event) : void{ * * @param PlayerMoveEvent $event */ - public function onPlayerMove(PlayerMoveEvent $event) : void { + public function onPlayerMove(PlayerMoveEvent $event) : void{ $this->onEventOnMove($event->getPlayer(), $event); } @@ -292,9 +294,9 @@ public function onPlayerMove(PlayerMoveEvent $event) : void { * * @param EntityTeleportEvent $event */ - public function onPlayerTeleport(EntityTeleportEvent $event) : void { + public function onPlayerTeleport(EntityTeleportEvent $event) : void{ $entity = $event->getEntity(); - if ($entity instanceof Player) { + if($entity instanceof Player){ $this->onEventOnMove($entity, $event); } } @@ -325,24 +327,18 @@ private function onEventOnMove(Player $player, EntityTeleportEvent|PlayerMoveEve $ev->isCancelled() ? $event->cancel() : $event->uncancel(); } - if($plot !== null){ + if($plot !== null) $plot = $this->internalAPI->getPlotFromCache($plot, true); - if($plot === null){ - $event->cancel(); // This causes a stutter step where the player will be denied for a tick or longer while the cache populates - $this->plugin->getLogger()->debug("Cancelled player move on [$levelName] due to plot not cached"); - return; - } - } - if($plot !== null and ($plotFrom === null or !$plot->isSame($plotFrom))){ + if($plot instanceof BasePlot and ($plotFrom === null or !$plot->isSame($plotFrom))){ if(str_contains((string) $plot, "-0")) return; + $plot = SinglePlot::fromBase($plot); $ev = new MyPlotPlayerEnterPlotEvent($plot, $player); $event->isCancelled() ? $ev->cancel() : $ev->uncancel(); $username = $ev->getPlayer()->getName(); - $plot = $this->internalAPI->getPlotFromCache($plot, true); if($plot->owner !== $username and ($plot->isDenied($username) or $plot->isDenied("*")) and !$ev->getPlayer()->hasPermission("myplot.admin.denyplayer.bypass") @@ -384,7 +380,7 @@ private function onEventOnMove(Player $player, EntityTeleportEvent|PlayerMoveEve * * @param EntityDamageByEntityEvent $event */ - public function onEntityDamage(EntityDamageByEntityEvent $event) : void { + public function onEntityDamage(EntityDamageByEntityEvent $event) : void{ $damaged = $event->getEntity(); $damager = $event->getDamager(); if($damaged instanceof Player and $damager instanceof Player){ @@ -399,7 +395,7 @@ public function onEntityDamage(EntityDamageByEntityEvent $event) : void { $plot = $this->internalAPI->getPlotFast($x, $z, $plotLevel); if($plot !== null){ $plot = $this->internalAPI->getPlotFromCache($plot); - if($plot === null){ + if(!$plot instanceof SinglePlot){ if($plotLevel->restrictPVP and !$damager->hasPermission("myplot.admin.pvp.bypass")) $event->cancel(); $this->plugin->getLogger()->debug("Cancelled player damage on [$levelName] due to plot not cached"); diff --git a/src/MyPlot/events/MyPlotBlockEvent.php b/src/MyPlot/events/MyPlotBlockEvent.php index 3f77ea55..2c69cc41 100644 --- a/src/MyPlot/events/MyPlotBlockEvent.php +++ b/src/MyPlot/events/MyPlotBlockEvent.php @@ -2,7 +2,7 @@ declare(strict_types=1); namespace MyPlot\events; -use MyPlot\Plot; +use MyPlot\plot\BasePlot; use pocketmine\block\Block; use pocketmine\event\block\BlockBreakEvent; use pocketmine\event\block\BlockPlaceEvent; @@ -13,7 +13,7 @@ use pocketmine\event\player\PlayerInteractEvent; use pocketmine\player\Player; -class MyPlotBlockEvent extends MyPlotPlotEvent implements Cancellable { +class MyPlotBlockEvent extends MyPlotPlotEvent implements Cancellable{ use CancellableTrait; private Block $block; @@ -24,30 +24,30 @@ class MyPlotBlockEvent extends MyPlotPlotEvent implements Cancellable { /** * MyPlotBlockEvent constructor. * - * @param Plot $plot - * @param Block $block - * @param Player $player + * @param BasePlot $plot + * @param Block $block + * @param Player $player * @param BlockPlaceEvent|BlockBreakEvent|PlayerInteractEvent|SignChangeEvent $event */ - public function __construct(Plot $plot, Block $block, Player $player, Event $event) { + public function __construct(BasePlot $plot, Block $block, Player $player, Event $event){ $this->block = $block; $this->player = $player; $this->event = $event; parent::__construct($plot); } - public function getBlock() : Block { + public function getBlock() : Block{ return $this->block; } /** * @return BlockPlaceEvent|BlockBreakEvent|PlayerInteractEvent|SignChangeEvent */ - public function getEvent() : Event { + public function getEvent() : Event{ return $this->event; } - public function getPlayer() : Player { + public function getPlayer() : Player{ return $this->player; } } \ No newline at end of file diff --git a/src/MyPlot/events/MyPlotBorderChangeEvent.php b/src/MyPlot/events/MyPlotBorderChangeEvent.php index cf387f78..b3c9cdff 100644 --- a/src/MyPlot/events/MyPlotBorderChangeEvent.php +++ b/src/MyPlot/events/MyPlotBorderChangeEvent.php @@ -4,6 +4,6 @@ namespace MyPlot\events; -class MyPlotBorderChangeEvent extends MyPlotBlockEvent { +class MyPlotBorderChangeEvent extends MyPlotBlockEvent{ } \ No newline at end of file diff --git a/src/MyPlot/events/MyPlotClearEvent.php b/src/MyPlot/events/MyPlotClearEvent.php index 8ea187a4..8c1fe6e9 100644 --- a/src/MyPlot/events/MyPlotClearEvent.php +++ b/src/MyPlot/events/MyPlotClearEvent.php @@ -2,11 +2,11 @@ declare(strict_types=1); namespace MyPlot\events; -use MyPlot\Plot; +use MyPlot\plot\BasePlot; use pocketmine\event\Cancellable; use pocketmine\event\CancellableTrait; -class MyPlotClearEvent extends MyPlotPlotEvent implements Cancellable { +class MyPlotClearEvent extends MyPlotPlotEvent implements Cancellable{ use CancellableTrait; private int $maxBlocksPerTick; @@ -14,19 +14,19 @@ class MyPlotClearEvent extends MyPlotPlotEvent implements Cancellable { /** * MyPlotClearEvent constructor. * - * @param Plot $plot - * @param int $maxBlocksPerTick + * @param BasePlot $plot + * @param int $maxBlocksPerTick */ - public function __construct(Plot $plot, int $maxBlocksPerTick = 256) { + public function __construct(BasePlot $plot, int $maxBlocksPerTick = 256){ $this->maxBlocksPerTick = $maxBlocksPerTick; parent::__construct($plot); } - public function getMaxBlocksPerTick() : int { + public function getMaxBlocksPerTick() : int{ return $this->maxBlocksPerTick; } - public function setMaxBlocksPerTick(int $maxBlocksPerTick) : self { + public function setMaxBlocksPerTick(int $maxBlocksPerTick) : self{ $this->maxBlocksPerTick = $maxBlocksPerTick; return $this; } diff --git a/src/MyPlot/events/MyPlotCloneEvent.php b/src/MyPlot/events/MyPlotCloneEvent.php index 91eb0e0c..01c724e6 100644 --- a/src/MyPlot/events/MyPlotCloneEvent.php +++ b/src/MyPlot/events/MyPlotCloneEvent.php @@ -2,31 +2,25 @@ declare(strict_types=1); namespace MyPlot\events; -use MyPlot\Plot; +use MyPlot\plot\BasePlot; use pocketmine\event\Cancellable; use pocketmine\event\CancellableTrait; -class MyPlotCloneEvent extends MyPlotPlotEvent implements Cancellable { +class MyPlotCloneEvent extends MyPlotPlotEvent implements Cancellable{ use CancellableTrait; - protected Plot $clonePlot; + protected BasePlot $clonePlot; - /** - * MyPlotCloneEvent constructor. - * - * @param Plot $originPlot - * @param Plot $clonePlot - */ - public function __construct(Plot $originPlot, Plot $clonePlot) { + public function __construct(BasePlot $originPlot, BasePlot $clonePlot){ $this->clonePlot = $clonePlot; parent::__construct($originPlot); } - public function setClonePlot(Plot $clonePlot) : void { + public function setClonePlot(BasePlot $clonePlot) : void{ $this->clonePlot = $clonePlot; } - public function getClonePlot() : Plot { + public function getClonePlot() : BasePlot{ return $this->clonePlot; } } \ No newline at end of file diff --git a/src/MyPlot/events/MyPlotDenyEvent.php b/src/MyPlot/events/MyPlotDenyEvent.php deleted file mode 100644 index 6a88361d..00000000 --- a/src/MyPlot/events/MyPlotDenyEvent.php +++ /dev/null @@ -1,57 +0,0 @@ -type = $type; - $this->player = $player; - parent::__construct($plot); - } - - public function getType() : int { - return $this->type; - } - - public function setType(int $type) : self { - $this->type = $type; - return $this; - } - - public function getDenied() : string { - return $this->player; - } - - /** - * @param IPlayer|string $player - * - * @return self - */ - public function setDenied(IPlayer|string $player) : self { - if($player instanceof IPlayer) { - $this->player = $player->getName(); - }else { - $this->player = $player; - } - return $this; - } -} \ No newline at end of file diff --git a/src/MyPlot/events/MyPlotDisposeEvent.php b/src/MyPlot/events/MyPlotDisposeEvent.php index 04a5d56d..5c86cfcf 100644 --- a/src/MyPlot/events/MyPlotDisposeEvent.php +++ b/src/MyPlot/events/MyPlotDisposeEvent.php @@ -2,19 +2,9 @@ declare(strict_types=1); namespace MyPlot\events; -use MyPlot\Plot; use pocketmine\event\Cancellable; use pocketmine\event\CancellableTrait; -class MyPlotDisposeEvent extends MyPlotPlotEvent implements Cancellable { +class MyPlotDisposeEvent extends MyPlotPlotEvent implements Cancellable{ use CancellableTrait; - - /** - * MyPlotClearEvent constructor. - * - * @param Plot $plot - */ - public function __construct(Plot $plot) { - parent::__construct($plot); - } } \ No newline at end of file diff --git a/src/MyPlot/events/MyPlotFillEvent.php b/src/MyPlot/events/MyPlotFillEvent.php index fdeb9fb7..ce7f27f9 100644 --- a/src/MyPlot/events/MyPlotFillEvent.php +++ b/src/MyPlot/events/MyPlotFillEvent.php @@ -2,11 +2,11 @@ declare(strict_types=1); namespace MyPlot\events; -use MyPlot\Plot; +use MyPlot\plot\BasePlot; use pocketmine\event\Cancellable; use pocketmine\event\CancellableTrait; -class MyPlotFillEvent extends MyPlotPlotEvent implements Cancellable { +class MyPlotFillEvent extends MyPlotPlotEvent implements Cancellable{ use CancellableTrait; /** @var int $maxBlocksPerTick */ @@ -15,10 +15,10 @@ class MyPlotFillEvent extends MyPlotPlotEvent implements Cancellable { /** * MyPlotFillEvent constructor. * - * @param Plot $plot - * @param int $maxBlocksPerTick + * @param BasePlot $plot + * @param int $maxBlocksPerTick */ - public function __construct(Plot $plot, int $maxBlocksPerTick = 256) { + public function __construct(BasePlot $plot, int $maxBlocksPerTick = 256){ $this->maxBlocksPerTick = $maxBlocksPerTick; parent::__construct($plot); } @@ -26,7 +26,7 @@ public function __construct(Plot $plot, int $maxBlocksPerTick = 256) { /** * @return int */ - public function getMaxBlocksPerTick() : int { + public function getMaxBlocksPerTick() : int{ return $this->maxBlocksPerTick; } @@ -35,7 +35,7 @@ public function getMaxBlocksPerTick() : int { * * @return self */ - public function setMaxBlocksPerTick(int $maxBlocksPerTick) : self { + public function setMaxBlocksPerTick(int $maxBlocksPerTick) : self{ $this->maxBlocksPerTick = $maxBlocksPerTick; return $this; } diff --git a/src/MyPlot/events/MyPlotGenerationEvent.php b/src/MyPlot/events/MyPlotGenerationEvent.php index 958d12bc..627b3527 100644 --- a/src/MyPlot/events/MyPlotGenerationEvent.php +++ b/src/MyPlot/events/MyPlotGenerationEvent.php @@ -6,7 +6,7 @@ use pocketmine\event\CancellableTrait; use pocketmine\event\Event; -class MyPlotGenerationEvent extends Event implements Cancellable { +class MyPlotGenerationEvent extends Event implements Cancellable{ use CancellableTrait; private string $levelName; @@ -17,30 +17,30 @@ class MyPlotGenerationEvent extends Event implements Cancellable { /** * MyPlotGenerationEvent constructor. * - * @param string $levelName - * @param string $generator + * @param string $levelName + * @param string $generator * @param string[] $settings */ - public function __construct(string $levelName, string $generator = "myplot", array $settings = []) { + public function __construct(string $levelName, string $generator = "myplot", array $settings = []){ $this->levelName = $levelName; $this->generator = $generator; $this->settings = $settings; } - public function getLevelName() : string { + public function getLevelName() : string{ return $this->levelName; } - public function setLevelName(string $levelName) : self { + public function setLevelName(string $levelName) : self{ $this->levelName = $levelName; return $this; } - public function getGenerator() : string { + public function getGenerator() : string{ return $this->generator; } - public function setGenerator(string $generator) : self { + public function setGenerator(string $generator) : self{ $this->generator = $generator; return $this; } @@ -48,7 +48,7 @@ public function setGenerator(string $generator) : self { /** * @return string[] */ - public function getSettings() : array { + public function getSettings() : array{ return $this->settings; } @@ -58,7 +58,7 @@ public function getSettings() : array { * @return self * @throws \JsonException */ - public function setSettings(array $settings) : self { + public function setSettings(array $settings) : self{ $this->settings = $settings; $this->settings["preset"] = json_encode($settings, JSON_THROW_ON_ERROR); return $this; diff --git a/src/MyPlot/events/MyPlotMergeEvent.php b/src/MyPlot/events/MyPlotMergeEvent.php index 7411ff9e..4cd821db 100644 --- a/src/MyPlot/events/MyPlotMergeEvent.php +++ b/src/MyPlot/events/MyPlotMergeEvent.php @@ -2,33 +2,38 @@ declare(strict_types=1); namespace MyPlot\events; -use MyPlot\Plot; +use MyPlot\plot\BasePlot; +use MyPlot\plot\MergedPlot; use pocketmine\event\Cancellable; use pocketmine\event\CancellableTrait; -class MyPlotMergeEvent extends MyPlotPlotEvent implements Cancellable { +class MyPlotMergeEvent extends MyPlotPlotEvent implements Cancellable{ use CancellableTrait; - /** @var Plot[][] $toMerge */ - private array $toMerge; + /** @var BasePlot[] $toMerge */ + private array $toMerge; + private int $direction; - /** - * MyPlotMergeEvent constructor. - * @param Plot $plot - * @param Plot[][] $toMerge - */ - public function __construct(Plot $plot, array $toMerge) { - $this->toMerge = $toMerge; + /** + * MyPlotMergeEvent constructor. + * + * @param MergedPlot $plot + * @param int $direction + * @param BasePlot[] $toMerge + */ + public function __construct(MergedPlot $plot, int $direction, array $toMerge){ parent::__construct($plot); + $this->direction = $direction; + $this->toMerge = $toMerge; } - /** - * @return Plot[][] - */ - public function getToMergePairs() : array { - return $this->toMerge; - } + /** + * @return BasePlot[] + */ + public function getToMergePairs() : array{ + return $this->toMerge; + } } \ No newline at end of file diff --git a/src/MyPlot/events/MyPlotPlayerEnterPlotEvent.php b/src/MyPlot/events/MyPlotPlayerEnterPlotEvent.php index a1ae4af4..9a17d66d 100644 --- a/src/MyPlot/events/MyPlotPlayerEnterPlotEvent.php +++ b/src/MyPlot/events/MyPlotPlayerEnterPlotEvent.php @@ -2,12 +2,12 @@ declare(strict_types=1); namespace MyPlot\events; -use MyPlot\Plot; +use MyPlot\plot\BasePlot; use pocketmine\event\Cancellable; use pocketmine\event\CancellableTrait; use pocketmine\player\Player; -class MyPlotPlayerEnterPlotEvent extends MyPlotPlotEvent implements Cancellable { +class MyPlotPlayerEnterPlotEvent extends MyPlotPlotEvent implements Cancellable{ use CancellableTrait; private Player $player; @@ -15,19 +15,19 @@ class MyPlotPlayerEnterPlotEvent extends MyPlotPlotEvent implements Cancellable /** * MyPlotPlayerEnterPlotEvent constructor. * - * @param Plot $plot - * @param Player $player + * @param BasePlot $plot + * @param Player $player */ - public function __construct(Plot $plot, Player $player) { + public function __construct(BasePlot $plot, Player $player){ $this->player = $player; parent::__construct($plot); } - public function getPlayer() : Player { + public function getPlayer() : Player{ return $this->player; } - public function setPlayer(Player $player) : self { + public function setPlayer(Player $player) : self{ $this->player = $player; return $this; } diff --git a/src/MyPlot/events/MyPlotPlayerLeavePlotEvent.php b/src/MyPlot/events/MyPlotPlayerLeavePlotEvent.php index b2afdeb7..eb5b5125 100644 --- a/src/MyPlot/events/MyPlotPlayerLeavePlotEvent.php +++ b/src/MyPlot/events/MyPlotPlayerLeavePlotEvent.php @@ -2,12 +2,12 @@ declare(strict_types=1); namespace MyPlot\events; -use MyPlot\Plot; +use MyPlot\plot\BasePlot; use pocketmine\event\Cancellable; use pocketmine\event\CancellableTrait; use pocketmine\player\Player; -class MyPlotPlayerLeavePlotEvent extends MyPlotPlotEvent implements Cancellable { +class MyPlotPlayerLeavePlotEvent extends MyPlotPlotEvent implements Cancellable{ use CancellableTrait; private Player $player; @@ -15,15 +15,15 @@ class MyPlotPlayerLeavePlotEvent extends MyPlotPlotEvent implements Cancellable /** * MyPlotPlayerLeavePlotEvent constructor. * - * @param Plot $plot - * @param Player $player + * @param BasePlot $plot + * @param Player $player */ - public function __construct(Plot $plot, Player $player) { + public function __construct(BasePlot $plot, Player $player){ $this->player = $player; parent::__construct($plot); } - public function getPlayer() : Player { + public function getPlayer() : Player{ return $this->player; } } \ No newline at end of file diff --git a/src/MyPlot/events/MyPlotPlotEvent.php b/src/MyPlot/events/MyPlotPlotEvent.php index abb7a585..4b766845 100644 --- a/src/MyPlot/events/MyPlotPlotEvent.php +++ b/src/MyPlot/events/MyPlotPlotEvent.php @@ -2,21 +2,21 @@ declare(strict_types=1); namespace MyPlot\events; -use MyPlot\Plot; +use MyPlot\plot\BasePlot; use pocketmine\event\Event; -class MyPlotPlotEvent extends Event { - protected Plot $plot; +class MyPlotPlotEvent extends Event{ + protected BasePlot $plot; - public function __construct(Plot $plot) { + public function __construct(BasePlot $plot){ $this->plot = $plot; } - public function getPlot() : Plot { + public function getPlot() : BasePlot{ return $this->plot; } - public function setPlot(Plot $plot) : self { + public function setPlot(BasePlot $plot) : self{ $this->plot = $plot; return $this; } diff --git a/src/MyPlot/events/MyPlotPvpEvent.php b/src/MyPlot/events/MyPlotPvpEvent.php index 01c70373..85dfc755 100644 --- a/src/MyPlot/events/MyPlotPvpEvent.php +++ b/src/MyPlot/events/MyPlotPvpEvent.php @@ -2,35 +2,35 @@ declare(strict_types=1); namespace MyPlot\events; -use MyPlot\Plot; +use MyPlot\plot\BasePlot; use pocketmine\event\Cancellable; use pocketmine\event\CancellableTrait; use pocketmine\event\entity\EntityDamageByEntityEvent; use pocketmine\player\Player; -class MyPlotPvpEvent extends MyPlotPlotEvent implements Cancellable { +class MyPlotPvpEvent extends MyPlotPlotEvent implements Cancellable{ use CancellableTrait; private Player $attacker; private Player $damaged; private ?EntityDamageByEntityEvent $event; - public function __construct(Plot $plot, Player $attacker, Player $damaged, ?EntityDamageByEntityEvent $event = null) { + public function __construct(BasePlot $plot, Player $attacker, Player $damaged, ?EntityDamageByEntityEvent $event = null){ $this->attacker = $attacker; $this->damaged = $damaged; $this->event = $event; parent::__construct($plot); } - public function getAttacker() : Player { + public function getAttacker() : Player{ return $this->attacker; } - public function getDamaged() : Player { + public function getDamaged() : Player{ return $this->damaged; } - public function getEvent() : ?EntityDamageByEntityEvent { + public function getEvent() : ?EntityDamageByEntityEvent{ return $this->event; } } \ No newline at end of file diff --git a/src/MyPlot/events/MyPlotResetEvent.php b/src/MyPlot/events/MyPlotResetEvent.php index 86ab7cef..90139456 100644 --- a/src/MyPlot/events/MyPlotResetEvent.php +++ b/src/MyPlot/events/MyPlotResetEvent.php @@ -2,19 +2,22 @@ declare(strict_types=1); namespace MyPlot\events; -use MyPlot\Plot; +use MyPlot\plot\BasePlot; +use MyPlot\plot\SinglePlot; use pocketmine\event\Cancellable; use pocketmine\event\CancellableTrait; -class MyPlotResetEvent extends MyPlotPlotEvent implements Cancellable { +class MyPlotResetEvent extends MyPlotPlotEvent implements Cancellable{ use CancellableTrait; + public function __construct(SinglePlot $plot){ + parent::__construct($plot); + } + /** - * MyPlotClearEvent constructor. - * - * @param Plot $plot + * @return SinglePlot */ - public function __construct(Plot $plot) { - parent::__construct($plot); + public function getPlot() : BasePlot{ + return parent::getPlot(); } } \ No newline at end of file diff --git a/src/MyPlot/events/MyPlotSaveEvent.php b/src/MyPlot/events/MyPlotSaveEvent.php index d4a0e9e8..46a82fb9 100644 --- a/src/MyPlot/events/MyPlotSaveEvent.php +++ b/src/MyPlot/events/MyPlotSaveEvent.php @@ -2,26 +2,18 @@ declare(strict_types=1); namespace MyPlot\events; -use MyPlot\Plot; -use pocketmine\event\Cancellable; -use pocketmine\event\CancellableTrait; +use MyPlot\plot\BasePlot; +use MyPlot\plot\SinglePlot; -class MyPlotSaveEvent extends MyPlotPlotEvent implements Cancellable { - use CancellableTrait; - - public const SQLITE3 = 0; - public const MySQL = 1; - public const JSON = 2; - public const YAML = 3; - public const OTHER = -1; - private int $type; - - public function __construct(int $type, Plot $plot) { - $this->type = $type; +class MyPlotSaveEvent extends MyPlotPlotEvent{ + public function __construct(SinglePlot $plot){ parent::__construct($plot); } - public function getSaveType() : int { - return $this->type; + /** + * @return SinglePlot + */ + public function getPlot() : BasePlot{ + return parent::getPlot(); } } \ No newline at end of file diff --git a/src/MyPlot/events/MyPlotSettingEvent.php b/src/MyPlot/events/MyPlotSettingEvent.php index b2116784..55f937c4 100644 --- a/src/MyPlot/events/MyPlotSettingEvent.php +++ b/src/MyPlot/events/MyPlotSettingEvent.php @@ -2,26 +2,29 @@ declare(strict_types=1); namespace MyPlot\events; -use MyPlot\Plot; +use MyPlot\plot\BasePlot; +use MyPlot\plot\SinglePlot; use pocketmine\event\Cancellable; use pocketmine\event\CancellableTrait; -class MyPlotSettingEvent extends MyPlotPlotEvent implements Cancellable { +class MyPlotSettingEvent extends MyPlotPlotEvent implements Cancellable{ use CancellableTrait; - private Plot $oldPlot; + private SinglePlot $oldPlot; - public function __construct(Plot $oldPlot, Plot $newPlot) { + public function __construct(SinglePlot $oldPlot, SinglePlot $newPlot){ $this->oldPlot = $oldPlot; parent::__construct($newPlot); } - public function getOldPlot() : Plot { + public function getOldPlot() : SinglePlot{ return $this->oldPlot; } - public function setOldPlot(Plot $oldPlot) : self { - $this->oldPlot = $oldPlot; - return $this; + /** + * @return SinglePlot + */ + public function getPlot() : BasePlot{ + return parent::getPlot(); } } \ No newline at end of file diff --git a/src/MyPlot/events/MyPlotTeleportEvent.php b/src/MyPlot/events/MyPlotTeleportEvent.php index ed4b548c..c5c17bfa 100644 --- a/src/MyPlot/events/MyPlotTeleportEvent.php +++ b/src/MyPlot/events/MyPlotTeleportEvent.php @@ -2,22 +2,22 @@ declare(strict_types=1); namespace MyPlot\events; -use MyPlot\Plot; +use MyPlot\plot\BasePlot; use pocketmine\player\Player; -class MyPlotTeleportEvent extends MyPlotPlayerEnterPlotEvent { +class MyPlotTeleportEvent extends MyPlotPlayerEnterPlotEvent{ private bool $center; - public function __construct(Plot $plot, Player $player, bool $center = false) { + public function __construct(BasePlot $plot, Player $player, bool $center = false){ $this->center = $center; parent::__construct($plot, $player); } - public function toCenter() : bool { + public function toCenter() : bool{ return $this->center; } - public function setToCenter(bool $center) : self { + public function setToCenter(bool $center) : self{ $this->center = $center; return $this; }