diff --git a/Pocket/plugins/Mineplex/src/mineplex/plugin/Main.php b/Pocket/plugins/Mineplex/src/mineplex/plugin/Main.php index fb64e78ad..5daeab757 100644 --- a/Pocket/plugins/Mineplex/src/mineplex/plugin/Main.php +++ b/Pocket/plugins/Mineplex/src/mineplex/plugin/Main.php @@ -6,6 +6,9 @@ use mineplex\plugin\gameengine\arenas\MultiGameArena; use mineplex\plugin\gameengine\game\components\world\WorldComponent; use mineplex\plugin\gameengine\game\factory\TestGameFactory; use mineplex\plugin\core\updater\Updater; +use mineplex\plugin\gameengine\time\BenchSchedule; +use mineplex\plugin\gameengine\time\BenchTask; +use mineplex\plugin\gameengine\time\BenchTaskData; use mineplex\plugin\util\UtilFile; use mineplex\plugin\util\UtilString; use pocketmine\block\Block; @@ -23,19 +26,16 @@ use pocketmine\plugin\PluginBase; use mineplex\plugin\gameengine\arenas\Arena; use pocketmine\Server; -class Main extends PluginBase implements Listener +class Main extends PluginBase implements Listener, BenchTask { /** @var Arena */ private $arena; - private $test; public function onEnable() { $this->arena = new MultiGameArena($this, new TestGameFactory()); Server::getInstance()->getPluginManager()->registerEvents($this, $this); - //$this->test = new WorldComponent($this->arena); - new Updater($this); $this->arena->getPlugin()->getServer()->getLevelByName("world")->setSpawnLocation(new Vector3(0, 200, 0)); @@ -44,8 +44,6 @@ class Main extends PluginBase implements Listener public function onLogin(PlayerLoginEvent $event) { - //UtilFile::deleteDir('players/' . $event->getPlayer()->getName() . '.dat'); - if ($this->arena->canJoin($event->getPlayer())) return; @@ -53,34 +51,42 @@ class Main extends PluginBase implements Listener $event->setCancelled(); } + //This is a hack to allow people to teleport a player when the join... I know it's scurry D: public function onJoin(PlayerJoinEvent $event) { - $this->arena->addPlayer($event->getPlayer()); + BenchSchedule::runTaskLaterWithId($this, 0, $event->getPlayer()); } - public function punch(PlayerInteractEvent $event) + function run(BenchTaskData $task) { - if ($event->getAction() == PlayerInteractEvent::LEFT_CLICK_BLOCK || $event->getAction() == PlayerInteractEvent::RIGHT_CLICK_BLOCK) - { - $event->getPlayer()->sendMessage("Block: " . $event->getBlock()->getId() . ":" . $event->getBlock()->getDamage()); - } + if (!($task->getId() instanceof Player)) + return; + + /** @var Player $player */ + $player = $task->getId(); + + if (!$player->isConnected()) + return; + + $this->arena->addPlayer($player); } + public function command(PlayerCommandPreprocessEvent $event) { if (UtilString::startsWith($event->getMessage(), "/pos")) self::sendLoc($event->getPlayer()); } - public static function sendLoc(Player $player) + public static function sendLoc(Player $player, Position $pos = null) { - $pos = $player->getLocation(); + if ($pos == null) + $pos = $player->getLocation(); $player->sendMessage("X: " . $pos->getX()); $player->sendMessage("Y: " . $pos->getY()); $player->sendMessage("Z: " . $pos->getZ()); $player->sendMessage("Level: " . $pos->getLevel()->getName()); - } } \ No newline at end of file diff --git a/Pocket/plugins/Mineplex/src/mineplex/plugin/gameengine/game/components/countdown/GameStateCountdown.php b/Pocket/plugins/Mineplex/src/mineplex/plugin/gameengine/game/components/countdown/GameStateCountdown.php index 4c51f99f8..894d18447 100644 --- a/Pocket/plugins/Mineplex/src/mineplex/plugin/gameengine/game/components/countdown/GameStateCountdown.php +++ b/Pocket/plugins/Mineplex/src/mineplex/plugin/gameengine/game/components/countdown/GameStateCountdown.php @@ -90,7 +90,7 @@ class GameStateCountdown implements Listener, BenchTask { { foreach ($this->arena->getPlayers() as $player) { - $player->sendPopup("Countdown: $this->count"); + $player->sendTip("Countdown: $this->count"); } } diff --git a/Pocket/plugins/Mineplex/src/mineplex/plugin/gameengine/game/components/countdown/LobbyCountdown.php b/Pocket/plugins/Mineplex/src/mineplex/plugin/gameengine/game/components/countdown/LobbyCountdown.php index 8681e666a..dc475a3d5 100644 --- a/Pocket/plugins/Mineplex/src/mineplex/plugin/gameengine/game/components/countdown/LobbyCountdown.php +++ b/Pocket/plugins/Mineplex/src/mineplex/plugin/gameengine/game/components/countdown/LobbyCountdown.php @@ -29,6 +29,7 @@ class LobbyCountdown implements Listener, BenchTask { private $startCount; private $count; private $gameStateComponent; + /** @var WorldComponent */ private $worldComponent; private $arena; private $startGameState; @@ -41,7 +42,7 @@ class LobbyCountdown implements Listener, BenchTask { const COUNTDOWN_ID = "count"; - public function __construct(Arena $arena, GameStateComponent $gameStateComponent, WorldComponent $worldComponent = null, $startGameState, $setGameState, $count, $minPlayers = 2) + public function __construct(Arena $arena, GameStateComponent $gameStateComponent, $worldComponent = null, $startGameState, $setGameState, $count, $minPlayers = 2) { $this->arena = $arena; $this->gameStateComponent = $gameStateComponent; @@ -184,6 +185,6 @@ class LobbyCountdown implements Listener, BenchTask { private function popup(Player $player) { - $player->sendPopup($this->message); + $player->sendTip($this->message); } } \ No newline at end of file diff --git a/Pocket/plugins/Mineplex/src/mineplex/plugin/gameengine/game/components/feature/features/FreezePlayers.php b/Pocket/plugins/Mineplex/src/mineplex/plugin/gameengine/game/components/feature/features/FreezePlayers.php index d27893472..4115d3cb7 100644 --- a/Pocket/plugins/Mineplex/src/mineplex/plugin/gameengine/game/components/feature/features/FreezePlayers.php +++ b/Pocket/plugins/Mineplex/src/mineplex/plugin/gameengine/game/components/feature/features/FreezePlayers.php @@ -28,7 +28,6 @@ class FreezePlayers extends ListenerFeature { function onMove(PlayerMoveEvent $event) { - if (!$this->hasPlayer($event->getPlayer())) return; @@ -41,13 +40,17 @@ class FreezePlayers extends ListenerFeature { parent::enable(); $effect = new Effect(Effect::SLOWNESS, "Waiting till game start...", 0, 0, 0, true); - $effect->setVisible(false)->setAmplifier(9)->setDuration(PHP_INT_MAX); + //TODO fix the 429496729 + $effect->setVisible(false)->setAmplifier(9)->setDuration(429496729); + print "Player Count: " . count($this->getPlayers()) . "\n"; + foreach ($this->getPlayers() as $player) { - print "Adding effect! \n"; + print "Adding effect!\n"; $player->addEffect($effect); } + } public function disable() @@ -56,7 +59,7 @@ class FreezePlayers extends ListenerFeature { print "Player Count: " . count($this->getPlayers()) . "\n"; foreach ($this->getPlayers() as $player) { - print "Adding effect! \n"; + print "Remove effect! \n"; $player->removeEffect(Effect::SLOWNESS); } } diff --git a/Pocket/plugins/Mineplex/src/mineplex/plugin/gameengine/game/components/feature/features/JoinSpectate.php b/Pocket/plugins/Mineplex/src/mineplex/plugin/gameengine/game/components/feature/features/JoinSpectate.php index 07988a691..f537d5acd 100644 --- a/Pocket/plugins/Mineplex/src/mineplex/plugin/gameengine/game/components/feature/features/JoinSpectate.php +++ b/Pocket/plugins/Mineplex/src/mineplex/plugin/gameengine/game/components/feature/features/JoinSpectate.php @@ -19,13 +19,10 @@ class JoinSpectate extends ListenerFeature { private $spectateComponent; - private $id; - function __construct(Arena $arena, SpectateComponent $spectateComponent) { parent::__construct($arena); $this->spectateComponent = $spectateComponent; - $this->id = rand(0, 99999); } function onJoin(ArenaJoinEvent $event) @@ -36,14 +33,11 @@ class JoinSpectate extends ListenerFeature { } public function enable() { - Server::getInstance()->broadcastMessage("JoinSpectate enable! : $this->id"); parent::enable(); - print "JoinSpectate enable? " . ($this->isEnabled() ? 'true' : 'false') . "\n"; } public function disable() { - Server::getInstance()->broadcastMessage("JoinSpectate disable!"); parent::disable(); } diff --git a/Pocket/plugins/Mineplex/src/mineplex/plugin/gameengine/game/components/feature/features/NoDamage.php b/Pocket/plugins/Mineplex/src/mineplex/plugin/gameengine/game/components/feature/features/NoDamage.php index d43b2cefa..45b920515 100644 --- a/Pocket/plugins/Mineplex/src/mineplex/plugin/gameengine/game/components/feature/features/NoDamage.php +++ b/Pocket/plugins/Mineplex/src/mineplex/plugin/gameengine/game/components/feature/features/NoDamage.php @@ -25,6 +25,7 @@ class NoDamage extends ListenerFeature { { if (!$this->getArena()->hasPlayer($event->getEntity())) return; + //Server::getInstance()->broadcastMessage("Stopped!"); $event->setCancelled(); } diff --git a/Pocket/plugins/Mineplex/src/mineplex/plugin/gameengine/game/components/feature/features/SpectateInGameWorld.php b/Pocket/plugins/Mineplex/src/mineplex/plugin/gameengine/game/components/feature/features/SpectateInGameWorld.php new file mode 100644 index 000000000..10f79ae6b --- /dev/null +++ b/Pocket/plugins/Mineplex/src/mineplex/plugin/gameengine/game/components/feature/features/SpectateInGameWorld.php @@ -0,0 +1,56 @@ +worldComponent = $worldComponent; + + } + + function onJoin(EnableSpectateEvent $event) + { + if ($this->getArena() !== $event->getArena() || !$this->worldComponent->isWorldReady()) + return; + + if ($event->getPlayer()->getPosition()->getLevel() == $this->worldComponent->getWorld()) + return; + + UtilTeleport::teleport($event->getPlayer(), $this->worldComponent->getWorld()->getSpawnLocation()); + } + public function enable() + { + parent::enable(); + } + + public function disable() + { + parent::disable(); + } + +} \ No newline at end of file diff --git a/Pocket/plugins/Mineplex/src/mineplex/plugin/gameengine/game/components/lobby/LobbyComponent.php b/Pocket/plugins/Mineplex/src/mineplex/plugin/gameengine/game/components/lobby/LobbyComponent.php index d6a8eb2d1..5b86acbfc 100644 --- a/Pocket/plugins/Mineplex/src/mineplex/plugin/gameengine/game/components/lobby/LobbyComponent.php +++ b/Pocket/plugins/Mineplex/src/mineplex/plugin/gameengine/game/components/lobby/LobbyComponent.php @@ -15,6 +15,8 @@ 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\GameState; +use mineplex\plugin\gameengine\time\BenchTaskData; +use mineplex\plugin\Main; use mineplex\plugin\util\UtilTeleport; use pocketmine\event\block\BlockBreakEvent; use pocketmine\event\entity\EntityDamageEvent; @@ -40,6 +42,7 @@ class LobbyComponent implements Listener private $duringLobbyGameState; + private $spawn; /** * @param Arena $arena * @param Level $world @@ -51,16 +54,18 @@ class LobbyComponent implements Listener $world->setTime(6000); $world->stopTime(); - $world->setSpawnLocation(new Vector3(0, 103, 0)); $this->world = $world; + $this->spawn = new Position(0, 103, 0, $world); + $this->arena = $arena; $this->duringLobbyGameState = new DuringLobbyGameState($this); Server::getInstance()->getPluginManager()->registerEvents($this, $arena->getPlugin()); } + function sendToSpawn(Player $player) { $player->getInventory()->clearAll(); @@ -70,9 +75,12 @@ class LobbyComponent implements Listener $player->setHealth($player->getMaxHealth()); $player->resetFallDistance(); - $pos = $this->world->getSpawnLocation()->add(rand(-4, 4), 0, rand(-4, 4)); + //Main::sendLoc($player, $this->world->getSpawnLocation()); + + $pos = $this->spawn->add(rand(-4, 4), 0, rand(-4, 4)); UtilTeleport::teleport($player, new Position($pos->getX(), $pos->getY(), $pos->getZ(), $this->world)); + //Main::sendLoc($player); } @@ -85,7 +93,7 @@ class LobbyComponent implements Listener function onDamage(EntityDamageEvent $event) { - if (!$event->getEntity()->getLevel() == $this->world) + if ($event->getEntity()->getLevel() !== $this->world) return; $event->setCancelled(); } diff --git a/Pocket/plugins/Mineplex/src/mineplex/plugin/gameengine/game/components/spawn/SimpleSpawnComponent.php b/Pocket/plugins/Mineplex/src/mineplex/plugin/gameengine/game/components/spawn/SimpleSpawnComponent.php index 30bd97943..036dbd9dc 100644 --- a/Pocket/plugins/Mineplex/src/mineplex/plugin/gameengine/game/components/spawn/SimpleSpawnComponent.php +++ b/Pocket/plugins/Mineplex/src/mineplex/plugin/gameengine/game/components/spawn/SimpleSpawnComponent.php @@ -11,6 +11,7 @@ namespace mineplex\plugin\gameengine\game\components\spawn; use mineplex\plugin\gameengine\arenas\Arena; use mineplex\plugin\gameengine\arenas\events\ArenaEndEvent; +use mineplex\plugin\gameengine\game\components\spectate\SpectateComponent; use mineplex\plugin\gameengine\game\components\world\event\WorldLoadSuccessEvent; use mineplex\plugin\gameengine\game\components\world\WorldComponent; use mineplex\plugin\Main; @@ -27,15 +28,17 @@ class SimpleSpawnComponent implements SpawnComponent, Listener { private $arena; private $worldComponent; private $gameMode; - + private $spectateComponent; /** @var Position[] */ private $spawns = []; - function __construct(Arena $arena, WorldComponent $worldComponent, $gameMode = Player::SURVIVAL) + function __construct(Arena $arena, WorldComponent $worldComponent, SpectateComponent $spectateComponent = null, $gameMode = Player::SURVIVAL) { + $this->arena = $arena; $this->worldComponent = $worldComponent; $this->gameMode = $gameMode; + $this->spectateComponent = $spectateComponent; Server::getInstance()->getPluginManager()->registerEvents($this, $arena->getPlugin()); } @@ -67,12 +70,6 @@ class SimpleSpawnComponent implements SpawnComponent, Listener { function respawn(Player $player) { - if (count($this->spawns) < 1) - { - print "no spawns!"; - return; - } - /* $player->getInventory()->clearAll(); $player->removeAllEffects(); @@ -80,21 +77,53 @@ class SimpleSpawnComponent implements SpawnComponent, Listener { $player->setGamemode($this->gameMode); $player->setHealth($player->getMaxHealth()); */ - $player->sendMessage("Before:"); - Main::sendLoc($player); - $pos = $this->spawns[array_rand($this->spawns)]; - //$pos = $pos->getLevel()->getSpawnLocation(); - - print_r($pos); + $pos = $this->getSpawn(); UtilTeleport::teleport($player, $pos); - //$player->teleport($pos); - $player->sendMessage("After:"); - Main::sendLoc($player); return $pos; } + /** + * @return null|Position + */ + function getSpawn() + { + if (count($this->spawns) < 1) + { + print "no spawns!"; + return null; + } + /** @var Position $best */ + $best = null; + $bestDist = 0; + + foreach ($this->spawns as $spawn) + { + + $closestPlayer = -1; + + foreach ($this->getPlayers() as $player) + { + if ($player->getPosition()->getLevel() != $spawn->getLevel()) + continue; + //distanceSquared is a cheaper method, and as long as its consistent it will be fine + $playerDist = $spawn->distanceSquared($player->getPosition()); + if ($playerDist < $closestPlayer || $closestPlayer < 0) + { + $closestPlayer = $playerDist; + } + } + if ($best == null || $closestPlayer > $bestDist) + { + $best = $spawn; + $bestDist = $closestPlayer; + } + + } + return $best; + } + function respawnAll() { foreach ($this->arena->getPlayers() as $player) { @@ -108,4 +137,13 @@ class SimpleSpawnComponent implements SpawnComponent, Listener { return; HandlerList::unregisterAll($this); } + + function getPlayers() + { + if ($this->spectateComponent != null) + return $this->spectateComponent->getNonSpectators(); + else + return $this->arena->getPlayers(); + } + } \ No newline at end of file diff --git a/Pocket/plugins/Mineplex/src/mineplex/plugin/gameengine/game/components/spectate/events/EnableSpectateEvent.php b/Pocket/plugins/Mineplex/src/mineplex/plugin/gameengine/game/components/spectate/events/EnableSpectateEvent.php index 9c26c8136..f18825110 100644 --- a/Pocket/plugins/Mineplex/src/mineplex/plugin/gameengine/game/components/spectate/events/EnableSpectateEvent.php +++ b/Pocket/plugins/Mineplex/src/mineplex/plugin/gameengine/game/components/spectate/events/EnableSpectateEvent.php @@ -8,13 +8,13 @@ namespace mineplex\plugin\gameengine\game\components\spectate\events; - use mineplex\plugin\gameengine\arenas\ArenaEvent; use mineplex\plugin\gameengine\arenas\Arena; use pocketmine\event\Cancellable; use pocketmine\Player; class EnableSpectateEvent extends ArenaEvent implements Cancellable { + public static $handlerList = null; private $player; diff --git a/Pocket/plugins/Mineplex/src/mineplex/plugin/gameengine/game/components/team/SimpleTeam.php b/Pocket/plugins/Mineplex/src/mineplex/plugin/gameengine/game/components/team/SimpleTeam.php new file mode 100644 index 000000000..2074b2597 --- /dev/null +++ b/Pocket/plugins/Mineplex/src/mineplex/plugin/gameengine/game/components/team/SimpleTeam.php @@ -0,0 +1,78 @@ +name = $name; + $this->color = $color; + } + + function addPlayer_forUseByManagerOnly(Player $player) + { + $this->players[$player->getName()] = $player; + $player->sendMessage("$this->color You are now on the team $this->name!"); + } + + function removePlayer_forUseByManagerOnly(Player $player) + { + if ($this->hasPlayer($player)) + unset ($this->players[$player->getName()]); + } + + /** + * @return Player[] + */ + function getPlayers() + { + return $this->players; + } + + /** + * @param Player $player + * @return bool + */ + function hasPlayer(Player $player) + { + return UtilArray::hasKey($player->getName(), $this->players); + } + + /** + * @return string + */ + function getName() + { + $this->name; + } + + /** + * @return string + */ + function getColor() + { + $this->color; + } + +} \ No newline at end of file diff --git a/Pocket/plugins/Mineplex/src/mineplex/plugin/gameengine/game/components/team/SimpleTeamManager.php b/Pocket/plugins/Mineplex/src/mineplex/plugin/gameengine/game/components/team/SimpleTeamManager.php new file mode 100644 index 000000000..f0b2cc655 --- /dev/null +++ b/Pocket/plugins/Mineplex/src/mineplex/plugin/gameengine/game/components/team/SimpleTeamManager.php @@ -0,0 +1,95 @@ +arena = $arena; + foreach ($teams as $team) + { + $this->addTeam($team); + } + } + + function addTeam(Team $team) + { + $this->teams[$team->getName()] = $team; + } + + /** + * @param String $name + * @return Team|null + */ + function getTeam($name) + { + if (UtilArray::hasKey($name, $this->teams)) + { + return $this->teams[$name]; + } + return null; + } + + /** + * @return Team[] + */ + function getTeams() + { + return $this->teams; + } + + /** + * @param Player $player + * @return Team|null + */ + function getPlayersTeam(Player $player) + { + foreach ($this->getTeams() as $team) + { + if ($team->hasPlayer($player)) + return $team; + } + return null; + } + + function setPlayersTeam(Player $player, Team $team) + { + $oldTeam = $this->getPlayersTeam($player); + if ($oldTeam != null) + { + $oldTeam->removePlayer_forUseByManagerOnly($player); + } + + //Meh, why not? + if (!in_array($team, $this->teams)) + { + throw new InvalidArgumentException('The team giving is not known by this manager!'); + } + + $team->addPlayer_forUseByManagerOnly($player); + + } + +} \ No newline at end of file diff --git a/Pocket/plugins/Mineplex/src/mineplex/plugin/gameengine/game/components/team/Team.php b/Pocket/plugins/Mineplex/src/mineplex/plugin/gameengine/game/components/team/Team.php new file mode 100644 index 000000000..68d0721c6 --- /dev/null +++ b/Pocket/plugins/Mineplex/src/mineplex/plugin/gameengine/game/components/team/Team.php @@ -0,0 +1,41 @@ +arena = $arena; + $this->teamManager = $teamManager; + Server::getInstance()->getPluginManager()->registerEvents($this, $arena->getPlugin()); + } + + public function gameState(GameStateChangeEvent $event) + { + if ($event->getArena() != $this->arena) + return; + + if ($event->getToGameState() == GameState::PRE_GAME) + $this->deal(); + + } + + function deal() + { + $teams = array_values($this->teamManager->getTeams()); + $counter = 0; + foreach ($this->arena->getPlayers() as $player) + { + Server::getInstance()->broadcastMessage($counter % count($teams)); + $this->teamManager->setPlayersTeam($player, $teams[$counter % count($teams)]); + $counter++; + } + } + + function gameEnd(ArenaEndEvent $event) + { + if ($event->getArena() != $this->arena) + return; + HandlerList::unregisterAll($this); + } +} \ No newline at end of file diff --git a/Pocket/plugins/Mineplex/src/mineplex/plugin/gameengine/game/components/team/TeamManager.php b/Pocket/plugins/Mineplex/src/mineplex/plugin/gameengine/game/components/team/TeamManager.php new file mode 100644 index 000000000..859cebec9 --- /dev/null +++ b/Pocket/plugins/Mineplex/src/mineplex/plugin/gameengine/game/components/team/TeamManager.php @@ -0,0 +1,35 @@ +arena = $arena; + $this->worldComponent = $worldComponent; + $this->time = $time; + } + + public function onWorld(WorldLoadSuccessEvent $event) + { + if ($event->getArena() !== $this->arena) + return; + $event->getLevel()->setTime($this->time); + $event->getLevel()->stopTime(); + } + +} \ No newline at end of file diff --git a/Pocket/plugins/Mineplex/src/mineplex/plugin/gameengine/game/components/world/WorldComponent.php b/Pocket/plugins/Mineplex/src/mineplex/plugin/gameengine/game/components/world/WorldComponent.php index ded7e9ae6..f0e613b8a 100644 --- a/Pocket/plugins/Mineplex/src/mineplex/plugin/gameengine/game/components/world/WorldComponent.php +++ b/Pocket/plugins/Mineplex/src/mineplex/plugin/gameengine/game/components/world/WorldComponent.php @@ -13,6 +13,9 @@ use mineplex\plugin\gameengine\arenas\events\ArenaEndEvent; use mineplex\plugin\gameengine\arenas\events\ArenaStartEvent; use mineplex\plugin\gameengine\game\components\world\event\WorldLoadFailEvent; use mineplex\plugin\gameengine\game\components\world\event\WorldLoadSuccessEvent; +use mineplex\plugin\gameengine\time\BenchSchedule; +use mineplex\plugin\gameengine\time\BenchTask; +use mineplex\plugin\gameengine\time\BenchTaskData; use mineplex\plugin\util\UtilArray; use mineplex\plugin\util\UtilString; use mineplex\plugin\util\UtilFile; @@ -26,7 +29,7 @@ use pocketmine\Server; use ZipArchive; use Exception; -class WorldComponent implements Listener +class WorldComponent implements Listener, BenchTask { private $arena; @@ -34,7 +37,7 @@ class WorldComponent implements Listener private $worldNameFolder; /** @var \pocketmine\level\Level */ - private $world; + private $world = null; private $mapName; private $mapAuthor; @@ -58,7 +61,7 @@ class WorldComponent implements Listener { if ($this->arena !== $event->getArena()) return; - $this->loadWorld("Super Smash Mobs"); + $this->loadWorld("Survival Games"); } private function unloadWorld() @@ -305,6 +308,17 @@ class WorldComponent implements Listener if ($this->arena !== $event->getArena()) return; HandlerList::unregisterAll($this); + BenchSchedule::runTaskLater($this, (1000 * 10)); + } + + public function run(BenchTaskData $bench) + { + $this->unloadWorld(); + } + + public function getWorld() + { + return $this->world; } } diff --git a/Pocket/plugins/Mineplex/src/mineplex/plugin/gameengine/game/games/sg/SurvivalGames.php b/Pocket/plugins/Mineplex/src/mineplex/plugin/gameengine/game/games/sg/SurvivalGames.php index b1bdbd1a6..395b2a394 100644 --- a/Pocket/plugins/Mineplex/src/mineplex/plugin/gameengine/game/games/sg/SurvivalGames.php +++ b/Pocket/plugins/Mineplex/src/mineplex/plugin/gameengine/game/games/sg/SurvivalGames.php @@ -18,6 +18,7 @@ use mineplex\plugin\gameengine\game\components\feature\features\NoBlockPlace; use mineplex\plugin\gameengine\game\components\feature\features\NoDamage; use mineplex\plugin\gameengine\game\components\feature\features\NoDropItem; use mineplex\plugin\gameengine\game\components\feature\features\NoPickUpItem; +use mineplex\plugin\gameengine\game\components\feature\features\SpectateInGameWorld; use mineplex\plugin\gameengine\game\components\feature\managers\GameStateFeatureManager; use mineplex\plugin\gameengine\game\components\gamestate\GameState; use mineplex\plugin\gameengine\game\components\gamestate\GameStateComponent; @@ -25,11 +26,16 @@ use mineplex\plugin\gameengine\game\components\lobby\LobbyComponent; use mineplex\plugin\gameengine\game\components\spawn\SimpleSpawnComponent; use mineplex\plugin\gameengine\game\components\spawn\SpawnAt; use mineplex\plugin\gameengine\game\components\spectate\GameModeSpectateComponent; +use mineplex\plugin\gameengine\game\components\team\SimpleTeam; +use mineplex\plugin\gameengine\game\components\team\SimpleTeamManager; +use mineplex\plugin\gameengine\game\components\team\TeamDealer; +use mineplex\plugin\gameengine\game\components\world\TimeComponent; use mineplex\plugin\gameengine\game\components\world\WorldComponent; use mineplex\plugin\gameengine\game\Game; use mineplex\plugin\gameengine\game\components\countdown\LobbyCountdown; use mineplex\plugin\gameengine\game\components\feature\Feature; use mineplex\plugin\gameengine\game\components\victorytype\LMSVictoryType; + class SurvivalGames implements Game { function start(Arena $arena) @@ -40,11 +46,21 @@ class SurvivalGames implements Game { $worldComponent = new WorldComponent($arena); + + + $teamManager = new SimpleTeamManager($arena, [new SimpleTeam('Bench', '§6'), new SimpleTeam('Not Bench', '§b')]); + new TeamDealer($arena, $teamManager); + + + new LobbyComponent($arena); + new TimeComponent($arena, $worldComponent); + //Features start---- $noDamage = new NoDamage($arena); - $joinSpectate = new JoinSpectate($arena, $spectateComponent); + + $joinSpectate = [new JoinSpectate($arena, $spectateComponent), new SpectateInGameWorld($arena, $worldComponent, $spectateComponent)]; $stopEveryThing = array(new NoBlockBreak($arena), new NoBlockPlace($arena),new NoDropItem($arena), new NoPickUpItem($arena)); @@ -68,11 +84,11 @@ class SurvivalGames implements Game { new LobbyCountdown( $arena, $gameStateComponent, $worldComponent, GameState::LOBBY, GameState::PRE_GAME, 10, 2); - //new GameStateCountdown($arena, $gameStateComponent, 5, GameState::LOBBY, GameState::PRE_GAME); + new GameStateCountdown($arena, $gameStateComponent, 20, GameState::PRE_GAME, GameState::GAME); - //new GameStateCountdown($arena, $gameStateComponent, 5, GameState::GAME, GameState::POST_GAME); + new LMSVictoryType( $arena, $spectateComponent, $gameStateComponent); new GameStateCountdown($arena, $gameStateComponent, 5, GameState::POST_GAME, GameState::RESTARTING); diff --git a/Pocket/plugins/Mineplex/src/mineplex/plugin/util/UtilTeleport.php b/Pocket/plugins/Mineplex/src/mineplex/plugin/util/UtilTeleport.php index bc414ac2e..150e7587e 100644 --- a/Pocket/plugins/Mineplex/src/mineplex/plugin/util/UtilTeleport.php +++ b/Pocket/plugins/Mineplex/src/mineplex/plugin/util/UtilTeleport.php @@ -20,28 +20,34 @@ use pocketmine\network\protocol\UpdateBlockPacket; class UtilTeleport { - public static function teleport(Player $player, Position $position) { + /** + * @param Player $player + * @param Vector3|Position $pos + */ + public static function teleport(Player $player, Vector3 $pos) + { + if ($pos instanceof Position) + { + $current = $player->getPosition(); + // + // This CRAZY HACK is to remove Tile entities that seem to linger + // whenever you teleport! + // - $current = $player->getPosition(); - - // - // This CRAZY HACK is to remove Tile entities that seem to linger - // whenever you teleport! - // - - if ($current->getLevel() != $position->getLevel()) { - $player->noDamageTicks = 20; - foreach ($current->getLevel()->getTiles() as $tile) { - $pk = new UpdateBlockPacket(); - $pk->x = $tile->x; - $pk->y = $tile->y; - $pk->z = $tile->z; - $pk->block = 0; - $pk->meta = 0; - $player->dataPacket($pk); + if ($current->getLevel() != $pos->getLevel()) { + $player->noDamageTicks = 20; + foreach ($current->getLevel()->getTiles() as $tile) { + $pk = new UpdateBlockPacket(); + $pk->x = $tile->x; + $pk->y = $tile->y; + $pk->z = $tile->z; + $pk->block = 0; + $pk->meta = 0; + $player->dataPacket($pk); + } } } - $player->teleport($position); // Start the teleport - return true; + + $player->teleport($pos); } } \ No newline at end of file diff --git a/Pocket/server.properties b/Pocket/server.properties index 20fc94da3..aec7f0629 100644 --- a/Pocket/server.properties +++ b/Pocket/server.properties @@ -1,6 +1,6 @@ #Properties Config file -#Sat Jul 11 00:36:33 ACT 2015 -motd=Minecraft: PE Server +#Mon Jul 13 05:54:15 ACT 2015 +motd=Box server-port=19132 memory-limit=-1 white-list=off @@ -13,7 +13,7 @@ spawn-mobs=off gamemode=0 force-gamemode=off hardcore=off -pvp=off +pvp=on difficulty=1 generator-settings= level-name=world