From 63fb1a49d4d7b6b326addf1b350da78e7d5b37af Mon Sep 17 00:00:00 2001 From: Aaron Brock Date: Tue, 7 Jul 2015 03:26:59 -0400 Subject: [PATCH] Moo Signed-off-by: Aaron Brock --- .../Mineplex/src/mineplex/plugin/Main.php | 31 +++++++++++++++++++ .../components/spawn/SimpleSpawnComponent.php | 20 ++++++------ .../game/games/sg/SurvivalGames.php | 29 ++++++++++------- 3 files changed, 59 insertions(+), 21 deletions(-) diff --git a/Pocket/plugins/Mineplex/src/mineplex/plugin/Main.php b/Pocket/plugins/Mineplex/src/mineplex/plugin/Main.php index 5ee8d91f6..415f1150f 100644 --- a/Pocket/plugins/Mineplex/src/mineplex/plugin/Main.php +++ b/Pocket/plugins/Mineplex/src/mineplex/plugin/Main.php @@ -6,12 +6,17 @@ 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\util\UtilString; +use pocketmine\block\Block; use pocketmine\event\Listener; +use pocketmine\event\player\PlayerCommandPreprocessEvent; use pocketmine\event\player\PlayerDeathEvent; +use pocketmine\event\player\PlayerInteractEvent; use pocketmine\event\player\PlayerJoinEvent; use pocketmine\event\player\PlayerLoginEvent; use pocketmine\level\Position; use pocketmine\math\Vector3; +use pocketmine\Player; use pocketmine\plugin\PluginBase; use mineplex\plugin\gameengine\arenas\Arena; use pocketmine\Server; @@ -45,4 +50,30 @@ class Main extends PluginBase implements Listener { $this->arena->addPlayer($event->getPlayer()); } + + public function punch(PlayerInteractEvent $event) + { + if ($event->getAction() == PlayerInteractEvent::LEFT_CLICK_BLOCK || $event->getAction() == PlayerInteractEvent::RIGHT_CLICK_BLOCK) + { + $event->getPlayer()->sendMessage("Block: " . $event->getBlock()->getId() . ":" . $event->getBlock()->getDamage()); + } + } + + public function command(PlayerCommandPreprocessEvent $event) + { + if (UtilString::startsWith($event->getMessage(), "/pos")) + self::sendLoc($event->getPlayer()); + } + + public static function sendLoc(Player $player) + { + $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/spawn/SimpleSpawnComponent.php b/Pocket/plugins/Mineplex/src/mineplex/plugin/gameengine/game/components/spawn/SimpleSpawnComponent.php index 5ef9eadfb..29a0ecf59 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 @@ -13,11 +13,11 @@ use mineplex\plugin\gameengine\arenas\Arena; use mineplex\plugin\gameengine\arenas\events\ArenaEndEvent; use mineplex\plugin\gameengine\game\components\world\event\WorldLoadSuccessEvent; use mineplex\plugin\gameengine\game\components\world\WorldComponent; +use mineplex\plugin\Main; use mineplex\plugin\util\UtilArray; use pocketmine\event\HandlerList; use pocketmine\event\Listener; use pocketmine\level\Position; -use pocketmine\math\Vector3; use pocketmine\Player; use pocketmine\Server; @@ -54,14 +54,6 @@ class SimpleSpawnComponent implements SpawnComponent, Listener { print (count($this->spawns) . " spawns Loaded\n"); - //Just testing to make sure it is a location. - $pos = $this->spawns[array_rand($this->spawns)]; - - print "\nX: " . $pos->getX(); - print "\nY: " . $pos->getY(); - print "\nZ: " . $pos->getZ(); - print "\nLevel: " . $pos->getLevel()->getName(); - } /** @@ -70,20 +62,25 @@ class SimpleSpawnComponent implements SpawnComponent, Listener { */ function respawn(Player $player) { + if (count($this->spawns) < 1) { print "no spawns!"; - return; } + /* $player->getInventory()->clearAll(); $player->removeAllEffects(); $player->resetFallDistance(); $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 "\nX: " . $pos->getX(); print "\nY: " . $pos->getY(); @@ -91,6 +88,9 @@ class SimpleSpawnComponent implements SpawnComponent, Listener { print "\nLevel: " . $pos->getLevel()->getName(); $player->teleport($pos); + + $player->sendMessage("After:"); + Main::sendLoc($player); return $pos; } 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 5f84070d7..77ed45aa2 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 @@ -26,29 +26,36 @@ use mineplex\plugin\gameengine\game\components\world\WorldComponent; use mineplex\plugin\gameengine\game\Game; use mineplex\plugin\gameengine\arenas\Arena; use mineplex\plugin\gameengine\game\components\feature\Feature; +use mineplex\plugin\gameengine\time\BenchSchedule; +use mineplex\plugin\gameengine\time\BenchTask; +use mineplex\plugin\gameengine\time\BenchTaskData; use pocketmine\item\Item; class SurvivalGames implements Game { + /** @var Arena */ + private $arena; function start(Arena $arena) { + $this->arena = $arena; + $gameStateComponent = new GameStateComponent($arena); - $spectateComponent = new GameModeSpectateComponent($arena); + //$spectateComponent = new GameModeSpectateComponent($arena); //Init features - $noPickUpItem = new NoPickUpItem($arena, [Item::GRASS], true); + //$noPickUpItem = new NoPickUpItem($arena, [Item::GRASS], true); - $pack = array(new NoBlockBreak($arena, [Item::GRASS]), new NoBlockPlace($arena, [Item::WOOD], true),new NoDropItem($arena, [Item::APPLE], true)); + //$pack = array(new NoBlockBreak($arena, [Item::GRASS]), new NoBlockPlace($arena, [Item::WOOD], true),new NoDropItem($arena, [Item::APPLE], true)); /** @var Feature[][] $features */ - $features = array( - GameState::LOBBY => array($noPickUpItem, $pack) - ); + //$features = array( + // GameState::LOBBY => array($noPickUpItem, $pack) + //); - new GameStateFeatureManager($arena, $features); + //new GameStateFeatureManager($arena, $features); - new LobbyComponent($arena); + //new LobbyComponent($arena); $worldComponent = new WorldComponent($arena); @@ -58,11 +65,11 @@ class SurvivalGames implements Game { new LobbyCountdown($arena, $gameStateComponent, $worldComponent, GameState::LOBBY, GameState::PRE_GAME, 10, 1); - new GameStateCountdown($arena, $gameStateComponent, 10, GameState::PRE_GAME, GameState::GAME); + //new GameStateCountdown($arena, $gameStateComponent, 10, GameState::PRE_GAME, GameState::GAME); - new GameStateCountdown($arena, $gameStateComponent, 20, GameState::GAME, GameState::POST_GAME); + //new GameStateCountdown($arena, $gameStateComponent, 20, GameState::GAME, GameState::POST_GAME); - new GameStateCountdown($arena, $gameStateComponent, 10, GameState::POST_GAME, GameState::RESTARTING); + //new GameStateCountdown($arena, $gameStateComponent, 10, GameState::POST_GAME, GameState::RESTARTING); } } \ No newline at end of file