Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updated to PM4 #84

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 16 additions & 17 deletions SkyWars/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: SkyWars
api: 3.0.0
api: 4.0.0
version: 1.2.1
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
version: 1.2.1
version: 1.3.0-beta1

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In order to update plugin on poggit it is required to increase the version

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also you should mention yourself in authors field

main: vixikhd\skywars\SkyWars
author: VixikHD
Expand All @@ -10,19 +10,18 @@ permissions:
sw.cmd:
description: Permission to all SkyWars commands
default: op
children:
sw.cmd.help:
description: Permission for /sw help
default: op
sw.cmd.create:
description: Permission for /sw create
default: op
sw.cmd.remove:
description: Permission for /sw remove
default: op
sw.cmd.set:
description: Permission for /sw set
default: op
sw.cmd.arenas:
description: Permission for /sw arenas
default: op
sw.cmd.help:
description: Permission for /sw help
default: op
sw.cmd.create:
description: Permission for /sw create
default: op
sw.cmd.remove:
description: Permission for /sw remove
default: op
sw.cmd.set:
description: Permission for /sw set
default: op
sw.cmd.arenas:
description: Permission for /sw arenas
default: op
36 changes: 18 additions & 18 deletions SkyWars/src/vixikhd/skywars/SkyWars.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
use pocketmine\event\block\BlockBreakEvent;
use pocketmine\event\Listener;
use pocketmine\event\player\PlayerChatEvent;
use pocketmine\level\Level;
use pocketmine\world\World;
use pocketmine\plugin\PluginBase;
use vixikhd\skywars\arena\Arena;
use vixikhd\skywars\arena\MapReset;
Expand Down Expand Up @@ -53,13 +53,13 @@ class SkyWars extends PluginBase implements Listener {
/** @var int[] $setupData */
public $setupData = [];

public function onEnable() {
public function onEnable(): void {
$this->getServer()->getPluginManager()->registerEvents($this, $this);
$this->dataProvider = new YamlDataProvider($this);
$this->getServer()->getCommandMap()->register("SkyWars", $this->commands[] = new SkyWarsCommand($this));
}

public function onDisable() {
public function onDisable(): void {
$this->dataProvider->saveArenas();
}

Expand All @@ -73,7 +73,7 @@ public function onChat(PlayerChatEvent $event) {
return;
}

$event->setCancelled(\true);
$event->cancel();
$args = explode(" ", $event->getMessage());

/** @var Arena $arena */
Expand Down Expand Up @@ -103,7 +103,7 @@ public function onChat(PlayerChatEvent $event) {
$player->sendMessage("§cUsage: §7level <levelName>");
break;
}
if(!$this->getServer()->isLevelGenerated($args[1])) {
if(!$this->getServer()->getWorldManager()->isWorldGenerated($args[1])) {
$player->sendMessage("§c> Level $args[1] does not found!");
break;
}
Expand All @@ -124,33 +124,33 @@ public function onChat(PlayerChatEvent $event) {
break;
}

$arena->data["spawns"]["spawn-{$args[1]}"] = (new Vector3($player->getX(), $player->getY(), $player->getZ()))->__toString();
$player->sendMessage("§a> Spawn $args[1] set to X: " . (string)round($player->getX()) . " Y: " . (string)round($player->getY()) . " Z: " . (string)round($player->getZ()));
$arena->data["spawns"]["spawn-{$args[1]}"] = (new Vector3($player->getPosition()->getX(), $player->getPosition()->getY(), $player->getPosition()->getZ()))->__toString();
$player->sendMessage("§a> Spawn $args[1] set to X: " . (string)round($player->getPosition()->getX()) . " Y: " . (string)round($player->getPosition()->getY()) . " Z: " . (string)round($player->getPosition()->getZ()));
break;
case "joinsign":
$player->sendMessage("§a> Break block to set join sign!");
$this->setupData[$player->getName()] = 0;
break;
case "savelevel":
if(!$arena->level instanceof Level) {
if(!$arena->level instanceof World) {
$levelName = $arena->data["level"];
if(!is_string($levelName) || !$this->getServer()->isLevelGenerated($levelName)) {
if(!is_string($levelName) || !$this->getServer()->getWorldManager()->isWorldGenerated($levelName)) {
errorMessage:
$player->sendMessage("§c> Error while saving the level: world not found.");
if($arena->setup) {
$player->sendMessage("§6> Try save level after enabling the arena.");
}
return;
}
if(!$this->getServer()->isLevelLoaded($levelName)) {
$this->getServer()->loadLevel($levelName);
if(!$this->getServer()->getWorldManager()->isWorldLoaded($levelName)) {
$this->getServer()->getWorldManager()->loadWorld($levelName, true);
}

try {
if(!$arena->mapReset instanceof MapReset) {
goto errorMessage;
}
$arena->mapReset->saveMap($this->getServer()->getLevelByName($levelName));
$arena->mapReset->saveMap($this->getServer()->getWorldManager()->getWorldByName($levelName));
$player->sendMessage("§a> Level saved!");
}
catch (\Exception $exception) {
Expand All @@ -170,12 +170,12 @@ public function onChat(PlayerChatEvent $event) {
break;
}

if($this->getServer()->isLevelGenerated($arena->data["level"])) {
if(!$this->getServer()->isLevelLoaded($arena->data["level"]))
$this->getServer()->loadLevel($arena->data["level"]);
if($this->getServer()->getWorldManager()->isWorldGenerated($arena->data["level"])) {
if(!$this->getServer()->getWorldManager()->isWorldLoaded($arena->data["level"]))
$this->getServer()->getWorldManager()->loadWorld($arena->data["level"], true);
if(!$arena->mapReset instanceof MapReset)
$arena->mapReset = new MapReset($arena);
$arena->mapReset->saveMap($this->getServer()->getLevelByName($arena->data["level"]));
$arena->mapReset->saveMap($this->getServer()->getWorldManager()->getWorldByName($arena->data["level"]));
}

$arena->loadArena(false);
Expand Down Expand Up @@ -205,10 +205,10 @@ public function onBreak(BlockBreakEvent $event) {
if(isset($this->setupData[$player->getName()])) {
switch ($this->setupData[$player->getName()]) {
case 0:
$this->setters[$player->getName()]->data["joinsign"] = [(new Vector3($block->getX(), $block->getY(), $block->getZ()))->__toString(), $block->getLevel()->getFolderName()];
$this->setters[$player->getName()]->data["joinsign"] = [(new Vector3($block->getPosition()->getX(), $block->getPosition()->getY(), $block->getPosition()->getZ()))->__toString(), $block->getPosition()->getWorld()->getFolderName()];
$player->sendMessage("§a> Join sign updated!");
unset($this->setupData[$player->getName()]);
$event->setCancelled(\true);
$event->cancel();
break;
}
}
Expand Down
Loading