Skip to content

Commit

Permalink
Finally updated to PMMP 3.x.x, fix #28
Browse files Browse the repository at this point in the history
  • Loading branch information
GamakCZ committed Aug 5, 2018
1 parent 7cd4e6e commit 17965fd
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 3 deletions.
4 changes: 3 additions & 1 deletion SkyWars/src/skywars/arena/Arena.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
namespace skywars\arena;

use pocketmine\block\Block;
use pocketmine\entity\Attribute;
use pocketmine\event\entity\EntityLevelChangeEvent;
use pocketmine\event\Listener;
use pocketmine\event\player\PlayerDeathEvent;
Expand All @@ -33,6 +34,7 @@
use pocketmine\item\Item;
use pocketmine\level\Level;
use pocketmine\level\Position;
use pocketmine\network\mcpe\protocol\AdventureSettingsPacket;
use pocketmine\Player;
use pocketmine\tile\Chest;
use pocketmine\tile\Tile;
Expand Down Expand Up @@ -463,7 +465,7 @@ public function loadArena(bool $restart = false) {



if($restart) {
else {
$this->scheduler->reloadTimer();
$this->level = $this->mapReset->loadMap($this->data["level"]);
}
Expand Down
10 changes: 10 additions & 0 deletions SkyWars/src/skywars/arena/ArenaScheduler.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@

use pocketmine\level\Level;
use pocketmine\level\Position;
use pocketmine\level\sound\AnvilUseSound;
use pocketmine\level\sound\ClickSound;
use pocketmine\scheduler\Task;
use pocketmine\tile\Sign;
use skywars\math\Time;
Expand Down Expand Up @@ -71,6 +73,14 @@ public function onRun(int $currentTick) {
$this->startTime--;
if($this->startTime == 0) {
$this->plugin->startGame();
foreach ($this->plugin->players as $player) {
$this->plugin->level->addSound(new AnvilUseSound($player->asVector3()));
}
}
else {
foreach ($this->plugin->players as $player) {
$this->plugin->level->addSound(new ClickSound($player->asVector3()));
}
}
}
else {
Expand Down
1 change: 1 addition & 0 deletions SkyWars/src/skywars/arena/MapReset.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public function saveMap(Level $level) {
if(is_file($zipPath)) {
unlink($zipPath);
}

$zip->open($zipPath, \ZipArchive::CREATE | \ZipArchive::OVERWRITE);
$files = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator(realpath($levelPath)), \RecursiveIteratorIterator::LEAVES_ONLY);

Expand Down
9 changes: 8 additions & 1 deletion SkyWars/src/skywars/commands/SkyWarsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,12 +165,19 @@ public function execute(CommandSender $sender, string $commandLabel, array $args
}
$sender->sendMessage($list);
break;
default:
if(!$sender->hasPermission("sw.cmd.help")) {
$sender->sendMessage("§cYou have not permissions to use this command!");
break;
}
$sender->sendMessage("§cUsage: §7/sw help");
break;
}

}

/**
* @return SkyWars|Plugin $skywars
* @return SkyWars|Plugin $plugin
*/
public function getPlugin(): Plugin {
return $this->plugin;
Expand Down
6 changes: 5 additions & 1 deletion SkyWars/src/skywars/provider/YamlDataProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,11 @@ public function loadArenas() {
public function saveArenas() {
foreach ($this->plugin->arenas as $fileName => $arena) {
if($arena->level instanceof Level) {
$arena->level->unload(true);
foreach ($arena->players as $player) {
$player->teleport($player->getServer()->getDefaultLevel()->getSpawnLocation());
}
// must be reseted
$arena->mapReset->loadMap($arena->level->getFolderName());
}
$config = new Config($this->getDataFolder() . "arenas" . DIRECTORY_SEPARATOR . $fileName . ".yml", Config::YAML);
$config->setAll($arena->data);
Expand Down

2 comments on commit 17965fd

@Flipax
Copy link

@Flipax Flipax commented on 17965fd Oct 18, 2018

Choose a reason for hiding this comment

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

Saving arena doesn't work, What a trash plugin.

@GamakCZ
Copy link
Owner Author

Choose a reason for hiding this comment

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

in newest versions, you must save world in setup mode using 'savelevel' command

Please sign in to comment.