Switched to '/' to DIRECTORY_SEPARATOR
Signed-off-by: Aaron Brock <TheMineBench@gmail.com>
This commit is contained in:
parent
361d090171
commit
7c571e20d4
@ -10,6 +10,7 @@ namespace mineplex\plugin\gameengine\arenas;
|
|||||||
|
|
||||||
use mineplex\plugin\gameengine\arenas\events\ArenaEndEvent;
|
use mineplex\plugin\gameengine\arenas\events\ArenaEndEvent;
|
||||||
use mineplex\plugin\gameengine\game\factory\GameFactory;
|
use mineplex\plugin\gameengine\game\factory\GameFactory;
|
||||||
|
use mineplex\plugin\util\UtilArray;
|
||||||
use pocketmine\event\Listener;
|
use pocketmine\event\Listener;
|
||||||
use pocketmine\plugin\Plugin;
|
use pocketmine\plugin\Plugin;
|
||||||
use pocketmine\event\player\PlayerJoinEvent;
|
use pocketmine\event\player\PlayerJoinEvent;
|
||||||
@ -51,17 +52,20 @@ class MultiGameArena implements Arena, Listener
|
|||||||
|
|
||||||
public function addPlayer(Player $player)
|
public function addPlayer(Player $player)
|
||||||
{
|
{
|
||||||
$this->plugin->getServer()->getPluginManager()->callEvent(new ArenaJoinEvent($this, $player));
|
if (!UtilArray::hasKey($player->getName(), $this->players))
|
||||||
array_push($this->players, $player);
|
{
|
||||||
|
$this->plugin->getServer()->getPluginManager()->callEvent(new ArenaJoinEvent($this, $player));
|
||||||
|
$this->players[$player->getName()] = $player;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function removePlayer(Player $player)
|
public function removePlayer(Player $player)
|
||||||
{
|
{
|
||||||
if (($key = array_search($player, $this->players, true)) !== FALSE) {
|
if (UtilArray::hasKey($player->getName(), $this->players))
|
||||||
unset($this->players[$key]);
|
{
|
||||||
|
$this->plugin->getServer()->getPluginManager()->callEvent(new ArenaQuitEvent($this, $player));
|
||||||
|
unset($this->players[$player->getName()]);
|
||||||
}
|
}
|
||||||
Server::getInstance()->broadcastMessage("Calling ArenaQuitEvent");
|
|
||||||
$this->plugin->getServer()->getPluginManager()->callEvent(new ArenaQuitEvent($this, $player));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onQuit(PlayerQuitEvent $event)
|
public function onQuit(PlayerQuitEvent $event)
|
||||||
@ -75,6 +79,7 @@ class MultiGameArena implements Arena, Listener
|
|||||||
Server::getInstance()->broadcastMessage("Game Over!");
|
Server::getInstance()->broadcastMessage("Game Over!");
|
||||||
Server::getInstance()->getPluginManager()->callEvent(new ArenaEndEvent($this));
|
Server::getInstance()->getPluginManager()->callEvent(new ArenaEndEvent($this));
|
||||||
$this->startGame();
|
$this->startGame();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function startGame()
|
private function startGame()
|
||||||
|
@ -41,7 +41,7 @@ class LobbyCountdown implements Listener, BenchTask {
|
|||||||
const COUNTDOWN_ID = "count";
|
const COUNTDOWN_ID = "count";
|
||||||
|
|
||||||
|
|
||||||
public function __construct(Arena $arena, GameStateComponent $gameStateComponent, $worldComponent = null, $startGameState, $setGameState, $count, $minPlayers = 2)
|
public function __construct(Arena $arena, GameStateComponent $gameStateComponent, WorldComponent $worldComponent = null, $startGameState, $setGameState, $count, $minPlayers = 2)
|
||||||
{
|
{
|
||||||
$this->arena = $arena;
|
$this->arena = $arena;
|
||||||
$this->gameStateComponent = $gameStateComponent;
|
$this->gameStateComponent = $gameStateComponent;
|
||||||
@ -61,11 +61,11 @@ class LobbyCountdown implements Listener, BenchTask {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param bool $addOne
|
* @param int $offset
|
||||||
*/
|
*/
|
||||||
function checkCountdown($addOne = false)
|
function checkCountdown($offset = 0)
|
||||||
{
|
{
|
||||||
$playerCount = (count($this->arena->getPlayers()) + $addOne);
|
$playerCount = (count($this->arena->getPlayers()) + $offset);
|
||||||
|
|
||||||
if ($this->gameStateComponent->getGameState() == $this->startGameState && ($this->worldComponent == null || $this->worldComponent->isWorldReady()) && $playerCount >= $this->minPlayers)
|
if ($this->gameStateComponent->getGameState() == $this->startGameState && ($this->worldComponent == null || $this->worldComponent->isWorldReady()) && $playerCount >= $this->minPlayers)
|
||||||
{
|
{
|
||||||
@ -76,20 +76,18 @@ class LobbyCountdown implements Listener, BenchTask {
|
|||||||
BenchSchedule::runTaskTimerWithId($this, 1000, 1000, self::COUNTDOWN_ID);
|
BenchSchedule::runTaskTimerWithId($this, 1000, 1000, self::COUNTDOWN_ID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$this->setWaiting($playerCount);
|
$this->setWaiting($playerCount);
|
||||||
BenchSchedule::cancelTaskWithId($this, self::COUNTDOWN_ID);
|
BenchSchedule::cancelTaskWithId($this, self::COUNTDOWN_ID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function onJoin(ArenaJoinEvent $event)
|
public function onJoin(ArenaJoinEvent $event)
|
||||||
{
|
{
|
||||||
if ($event->getArena() !== $this->arena)
|
if ($event->getArena() !== $this->arena)
|
||||||
return;
|
return;
|
||||||
$this->checkCountdown(true);
|
$this->checkCountdown(1);
|
||||||
$this->popup($event->getPlayer());
|
$this->popup($event->getPlayer());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -98,14 +96,15 @@ class LobbyCountdown implements Listener, BenchTask {
|
|||||||
if ($event->getArena() !== $this->arena)
|
if ($event->getArena() !== $this->arena)
|
||||||
return;
|
return;
|
||||||
if ($this->gameStateComponent->getGameState() == $this->startGameState)
|
if ($this->gameStateComponent->getGameState() == $this->startGameState)
|
||||||
$this->checkCountdown();
|
$this->checkCountdown(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function onWorldCreation(WorldLoadSuccessEvent $event)
|
public function onWorldCreation(WorldLoadSuccessEvent $event)
|
||||||
{
|
{
|
||||||
if ($event->getArena() !== $this->arena)
|
if ($event->getArena() !== $this->arena)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
$this->checkCountdown();
|
$this->checkCountdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -155,7 +154,6 @@ class LobbyCountdown implements Listener, BenchTask {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$this->message = "§9Game starting in:§c $this->count";
|
$this->message = "§9Game starting in:§c $this->count";
|
||||||
|
|
||||||
$this->count--;
|
$this->count--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,8 +12,10 @@ use mineplex\plugin\gameengine\arenas\Arena;
|
|||||||
use mineplex\plugin\gameengine\arenas\events\ArenaEndEvent;
|
use mineplex\plugin\gameengine\arenas\events\ArenaEndEvent;
|
||||||
use mineplex\plugin\gameengine\arenas\events\ArenaJoinEvent;
|
use mineplex\plugin\gameengine\arenas\events\ArenaJoinEvent;
|
||||||
use mineplex\plugin\gameengine\game\components\feature\ListenerFeature;
|
use mineplex\plugin\gameengine\game\components\feature\ListenerFeature;
|
||||||
|
use mineplex\plugin\gameengine\game\components\feature\UtilFeature;
|
||||||
use mineplex\plugin\gameengine\game\components\gamestate\events\GameStateChangeEvent;
|
use mineplex\plugin\gameengine\game\components\gamestate\events\GameStateChangeEvent;
|
||||||
use mineplex\plugin\gameengine\game\components\gamestate\GameState;
|
use mineplex\plugin\gameengine\game\components\gamestate\GameState;
|
||||||
|
use mineplex\plugin\util\UtilTeleport;
|
||||||
use pocketmine\event\block\BlockBreakEvent;
|
use pocketmine\event\block\BlockBreakEvent;
|
||||||
use pocketmine\event\entity\EntityDamageEvent;
|
use pocketmine\event\entity\EntityDamageEvent;
|
||||||
use pocketmine\event\entity\EntityShootBowEvent;
|
use pocketmine\event\entity\EntityShootBowEvent;
|
||||||
@ -23,6 +25,7 @@ use pocketmine\event\Listener;
|
|||||||
use pocketmine\event\player\PlayerDropItemEvent;
|
use pocketmine\event\player\PlayerDropItemEvent;
|
||||||
use pocketmine\level\Level;
|
use pocketmine\level\Level;
|
||||||
use pocketmine\level\Position;
|
use pocketmine\level\Position;
|
||||||
|
use pocketmine\math\Vector3;
|
||||||
use pocketmine\Player;
|
use pocketmine\Player;
|
||||||
use pocketmine\Server;
|
use pocketmine\Server;
|
||||||
|
|
||||||
@ -33,7 +36,7 @@ class LobbyComponent implements Listener
|
|||||||
private $arena;
|
private $arena;
|
||||||
|
|
||||||
/** @var String */
|
/** @var String */
|
||||||
public $worldName;
|
public $world;
|
||||||
|
|
||||||
private $duringLobbyGameState;
|
private $duringLobbyGameState;
|
||||||
|
|
||||||
@ -48,18 +51,41 @@ class LobbyComponent implements Listener
|
|||||||
|
|
||||||
$world->setTime(6000);
|
$world->setTime(6000);
|
||||||
$world->stopTime();
|
$world->stopTime();
|
||||||
|
$world->setSpawnLocation(new Vector3(0, 103, 0));
|
||||||
|
|
||||||
$this->worldName = $world->getName();
|
$this->world = $world;
|
||||||
|
|
||||||
$this->arena = $arena;
|
$this->arena = $arena;
|
||||||
$this->duringLobbyGameState = new DuringLobbyGameState($arena, $world);
|
$this->duringLobbyGameState = new DuringLobbyGameState($this);
|
||||||
|
|
||||||
Server::getInstance()->getPluginManager()->registerEvents($this, $arena->getPlugin());
|
Server::getInstance()->getPluginManager()->registerEvents($this, $arena->getPlugin());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function sendToSpawn(Player $player)
|
||||||
|
{
|
||||||
|
$player->getInventory()->clearAll();
|
||||||
|
$player->removeAllEffects();
|
||||||
|
$player->setGamemode(Player::ADVENTURE);
|
||||||
|
|
||||||
|
$player->setHealth($player->getMaxHealth());
|
||||||
|
$player->resetFallDistance();
|
||||||
|
|
||||||
|
$pos = $this->world->getSpawnLocation()->add(rand(-4, 4), 0, rand(-4, 4));
|
||||||
|
|
||||||
|
UtilTeleport::teleport($player, new Position($pos->getX(), $pos->getY(), $pos->getZ(), $this->world));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public function onBlockBreak(BlockBreakEvent $event)
|
public function onBlockBreak(BlockBreakEvent $event)
|
||||||
{
|
{
|
||||||
if ($event->getBlock()->getLevel()->getName() != $this->worldName)
|
if ($event->getBlock()->getLevel() != $this->world)
|
||||||
|
return;
|
||||||
|
$event->setCancelled();
|
||||||
|
}
|
||||||
|
|
||||||
|
function onDamage(EntityDamageEvent $event)
|
||||||
|
{
|
||||||
|
if (!$event->getEntity()->getLevel() == $this->world)
|
||||||
return;
|
return;
|
||||||
$event->setCancelled();
|
$event->setCancelled();
|
||||||
}
|
}
|
||||||
@ -77,6 +103,11 @@ class LobbyComponent implements Listener
|
|||||||
{
|
{
|
||||||
if (!$this->duringLobbyGameState->isEnabled())
|
if (!$this->duringLobbyGameState->isEnabled())
|
||||||
{
|
{
|
||||||
|
foreach ($this->getArena()->getPlayers() as $player)
|
||||||
|
{
|
||||||
|
if ($player->getPosition()->getLevel() !== $this->world)
|
||||||
|
$this->sendToSpawn($player);
|
||||||
|
}
|
||||||
$this->duringLobbyGameState->enable();
|
$this->duringLobbyGameState->enable();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -89,26 +120,34 @@ class LobbyComponent implements Listener
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @priority HIGH
|
||||||
|
* @param ArenaEndEvent $event
|
||||||
|
*/
|
||||||
public function onGameEnd(ArenaEndEvent $event)
|
public function onGameEnd(ArenaEndEvent $event)
|
||||||
{
|
{
|
||||||
if ($event->getArena() !== $this->arena)
|
if ($event->getArena() !== $this->arena)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
HandlerList::unregisterAll($this);
|
HandlerList::unregisterAll($this);
|
||||||
|
|
||||||
if ($this->duringLobbyGameState->isEnabled())
|
if ($this->duringLobbyGameState->isEnabled())
|
||||||
$this->duringLobbyGameState->disable();
|
$this->duringLobbyGameState->disable();
|
||||||
}
|
}
|
||||||
|
function getArena()
|
||||||
|
{
|
||||||
|
return $this->arena;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class DuringLobbyGameState extends ListenerFeature
|
class DuringLobbyGameState extends ListenerFeature
|
||||||
{
|
{
|
||||||
|
private $master;
|
||||||
|
|
||||||
private $spawn;
|
public function __construct(LobbyComponent $master)
|
||||||
|
|
||||||
public function __construct(Arena $arena, Level $world)
|
|
||||||
{
|
{
|
||||||
parent::__construct($arena);
|
parent::__construct($master->getArena());
|
||||||
$this->spawn = new Position(0, 103, 0, $world);
|
$this->master = $master;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -117,9 +156,8 @@ class DuringLobbyGameState extends ListenerFeature
|
|||||||
*/
|
*/
|
||||||
function onDamage(EntityDamageEvent $event)
|
function onDamage(EntityDamageEvent $event)
|
||||||
{
|
{
|
||||||
if (!in_array($event->getEntity(), $this->getArena()->getPlayers()))
|
if (!$this->getArena()->hasPlayer($event->getEntity()))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
$event->setCancelled();
|
$event->setCancelled();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -129,9 +167,8 @@ class DuringLobbyGameState extends ListenerFeature
|
|||||||
*/
|
*/
|
||||||
function onDrop(PlayerDropItemEvent $event)
|
function onDrop(PlayerDropItemEvent $event)
|
||||||
{
|
{
|
||||||
if (!in_array($event->getPlayer(), $this->getArena()->getPlayers()))
|
if (!$this->getArena()->hasPlayer($event->getPlayer()))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
$event->setCancelled();
|
$event->setCancelled();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -141,9 +178,8 @@ class DuringLobbyGameState extends ListenerFeature
|
|||||||
*/
|
*/
|
||||||
function onPickUp(InventoryPickupItemEvent $event)
|
function onPickUp(InventoryPickupItemEvent $event)
|
||||||
{
|
{
|
||||||
if (!in_array($event->getInventory()->getHolder(), $this->getArena()->getPlayers()))
|
if (!$this->getArena()->hasPlayer($event->getInventory()->getHolder()))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
$event->setCancelled();
|
$event->setCancelled();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -153,7 +189,7 @@ class DuringLobbyGameState extends ListenerFeature
|
|||||||
*/
|
*/
|
||||||
function onBowShoot(EntityShootBowEvent $event)
|
function onBowShoot(EntityShootBowEvent $event)
|
||||||
{
|
{
|
||||||
if (!in_array($event->getEntity(), $this->getArena()->getPlayers()))
|
if (!$this->getArena()->hasPlayer($event->getEntity()))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
$event->setCancelled();
|
$event->setCancelled();
|
||||||
@ -168,29 +204,6 @@ class DuringLobbyGameState extends ListenerFeature
|
|||||||
if ($this->getArena() !== $event->getArena())
|
if ($this->getArena() !== $event->getArena())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
$this->sendToSpawn($event->getPlayer());
|
$this->master->sendToSpawn($event->getPlayer());
|
||||||
}
|
|
||||||
|
|
||||||
function sendToSpawn(Player $player)
|
|
||||||
{
|
|
||||||
$player->getInventory()->clearAll();
|
|
||||||
$player->removeAllEffects();
|
|
||||||
$player->setGamemode(Player::ADVENTURE);
|
|
||||||
|
|
||||||
$player->setHealth($player->getMaxHealth());
|
|
||||||
$player->resetFallDistance();
|
|
||||||
|
|
||||||
$pos = $this->spawn->add(rand(-4, 4), 0, rand(-4, 4));
|
|
||||||
|
|
||||||
$player->teleport($pos);
|
|
||||||
}
|
|
||||||
|
|
||||||
function enable()
|
|
||||||
{
|
|
||||||
parent::enable();
|
|
||||||
foreach ($this->getArena()->getPlayers() as $player)
|
|
||||||
{
|
|
||||||
$this->sendToSpawn($player);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -63,6 +63,7 @@ class GameModeSpectateComponent implements SpectateComponent, Listener {
|
|||||||
{
|
{
|
||||||
if (!$this->isSpectating($player))
|
if (!$this->isSpectating($player))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
$event = new DisableSpectateEvent($this->arena, $player);
|
$event = new DisableSpectateEvent($this->arena, $player);
|
||||||
|
|
||||||
Server::getInstance()->getPluginManager()->callEvent($event);
|
Server::getInstance()->getPluginManager()->callEvent($event);
|
||||||
@ -73,21 +74,22 @@ class GameModeSpectateComponent implements SpectateComponent, Listener {
|
|||||||
if (($key = array_search($player, $this->spectators, true)) !== FALSE) {
|
if (($key = array_search($player, $this->spectators, true)) !== FALSE) {
|
||||||
unset($this->spectators[$key]);
|
unset($this->spectators[$key]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Low to keep consistency, so if someone listens ArenaQuitEvent then the player will be in neither the spectator list or the player list.
|
//HIGH so you can do isSpectating on ArenaQuitEvent
|
||||||
/**
|
/**
|
||||||
* @priority LOW
|
* @priority HIGH
|
||||||
* @param ArenaQuitEvent $event
|
* @param ArenaQuitEvent $event
|
||||||
*/
|
*/
|
||||||
public function onQuit(ArenaQuitEvent $event)
|
public function onQuit(ArenaQuitEvent $event)
|
||||||
{
|
{
|
||||||
if ($this->arena !== $event->getArena())
|
if ($this->arena !== $event->getArena())
|
||||||
return;
|
return;
|
||||||
|
if ($this->isSpectating($event->getPlayer()))
|
||||||
if (($key = array_search($event->getPlayer(), $this->spectators, true)) !== FALSE) {
|
{
|
||||||
unset($this->spectators[$key]);
|
unset($this->spectators[$event->getPlayer()->getName()]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -97,7 +99,7 @@ class GameModeSpectateComponent implements SpectateComponent, Listener {
|
|||||||
*/
|
*/
|
||||||
public function isSpectating(Player $player)
|
public function isSpectating(Player $player)
|
||||||
{
|
{
|
||||||
return in_array($player, $this->getSpectators());
|
return UtilArray::hasKey($player->getName(), $this->spectators);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -106,7 +108,7 @@ class GameModeSpectateComponent implements SpectateComponent, Listener {
|
|||||||
*/
|
*/
|
||||||
public function isNotSpectating(Player $player)
|
public function isNotSpectating(Player $player)
|
||||||
{
|
{
|
||||||
return in_array($player, $this->arena->getPlayers()) && !$this->isSpectating($player);
|
return $this->arena->hasPlayer($player) && !$this->isSpectating($player);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -64,7 +64,6 @@ class LMSVictoryType implements Listener{
|
|||||||
HandlerList::unregisterAll($this);
|
HandlerList::unregisterAll($this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class DuringGame extends ListenerFeature implements BenchTask {
|
class DuringGame extends ListenerFeature implements BenchTask {
|
||||||
@ -93,9 +92,7 @@ class DuringGame extends ListenerFeature implements BenchTask {
|
|||||||
$this->endPlayersAmount = $endPlayersAmount;
|
$this->endPlayersAmount = $endPlayersAmount;
|
||||||
}
|
}
|
||||||
|
|
||||||
#On LOWEST so I can check if the player is spectating, as the player is removed from the spectating list on LOW
|
|
||||||
/**
|
/**
|
||||||
* @priority LOWEST
|
|
||||||
* @param ArenaQuitEvent $event
|
* @param ArenaQuitEvent $event
|
||||||
*/
|
*/
|
||||||
public function onLeave(ArenaQuitEvent $event)
|
public function onLeave(ArenaQuitEvent $event)
|
||||||
@ -106,7 +103,7 @@ class DuringGame extends ListenerFeature implements BenchTask {
|
|||||||
if (!$this->spectateComponent->isSpectating($event->getPlayer()))
|
if (!$this->spectateComponent->isSpectating($event->getPlayer()))
|
||||||
array_push($this->rank, $event->getPlayer());
|
array_push($this->rank, $event->getPlayer());
|
||||||
|
|
||||||
$this->checkEndGame();
|
BenchSchedule::runTaskLater($this, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -117,7 +114,6 @@ class DuringGame extends ListenerFeature implements BenchTask {
|
|||||||
|
|
||||||
array_push($this->rank, $event->getPlayer());
|
array_push($this->rank, $event->getPlayer());
|
||||||
|
|
||||||
//Meh, don't like doing things this way, but I need it to call sendWinners after the player is added to spectating from spectating.
|
|
||||||
BenchSchedule::runTaskLater($this, 0);
|
BenchSchedule::runTaskLater($this, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -158,9 +154,9 @@ class DuringGame extends ListenerFeature implements BenchTask {
|
|||||||
if ($counter >= 3)
|
if ($counter >= 3)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->arena->broadcast("");
|
$this->arena->broadcast("");
|
||||||
$this->arena->broadcast("----------");
|
$this->arena->broadcast("----------");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function run(BenchTaskData $task)
|
public function run(BenchTaskData $task)
|
||||||
|
@ -73,14 +73,14 @@ class WorldComponent implements Listener
|
|||||||
|
|
||||||
$this->arena->getPlugin()->getServer()->unloadLevel($this->world);
|
$this->arena->getPlugin()->getServer()->unloadLevel($this->world);
|
||||||
|
|
||||||
UtilFile::deleteDir('worlds/' . $this->worldNameFolder);
|
UtilFile::deleteDir('worlds' . DIRECTORY_SEPARATOR . $this->worldNameFolder);
|
||||||
|
|
||||||
print("Successfully Deleted: " . $this->worldNameFolder . "\n");
|
print("Successfully Deleted: " . $this->worldNameFolder . "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
private function loadWorld($gameName)
|
private function loadWorld($gameName)
|
||||||
{
|
{
|
||||||
$files = scandir('../update/maps/' . $gameName . '/');
|
$files = scandir('..' . DIRECTORY_SEPARATOR. '..' . DIRECTORY_SEPARATOR. 'update'. DIRECTORY_SEPARATOR .'maps' . DIRECTORY_SEPARATOR . $gameName . '/');
|
||||||
|
|
||||||
$maps = array();
|
$maps = array();
|
||||||
|
|
||||||
@ -103,10 +103,10 @@ class WorldComponent implements Listener
|
|||||||
|
|
||||||
//Unzip World
|
//Unzip World
|
||||||
$zip = new ZipArchive;
|
$zip = new ZipArchive;
|
||||||
$res = $zip->open('../update/maps/' . $gameName . '/' . $worldName . '.zip');
|
$res = $zip->open('..' . DIRECTORY_SEPARATOR. 'update' . DIRECTORY_SEPARATOR. 'maps' . DIRECTORY_SEPARATOR . $gameName . DIRECTORY_SEPARATOR . $worldName . '.zip');
|
||||||
if ($res === TRUE)
|
if ($res === TRUE)
|
||||||
{
|
{
|
||||||
$zip->extractTo('worlds/' . $this->worldNameFolder . '/');
|
$zip->extractTo('worlds' . DIRECTORY_SEPARATOR . $this->worldNameFolder . '/');
|
||||||
$zip->close();
|
$zip->close();
|
||||||
print("Successfully Extracted: " . $this->worldNameFolder . "\n");
|
print("Successfully Extracted: " . $this->worldNameFolder . "\n");
|
||||||
}
|
}
|
||||||
@ -146,7 +146,7 @@ class WorldComponent implements Listener
|
|||||||
|
|
||||||
public function loadWorldData()
|
public function loadWorldData()
|
||||||
{
|
{
|
||||||
$handle = fopen('worlds/' . $this->worldNameFolder . '/WorldConfig.dat', "r");
|
$handle = fopen('worlds' . DIRECTORY_SEPARATOR . $this->worldNameFolder . DIRECTORY_SEPARATOR. 'WorldConfig.dat', "r");
|
||||||
if ($handle)
|
if ($handle)
|
||||||
{
|
{
|
||||||
//These store the array that data should be inserted into
|
//These store the array that data should be inserted into
|
||||||
|
Loading…
Reference in New Issue
Block a user