Signed-off-by: Aaron Brock <TheMineBench@gmail.com>
This commit is contained in:
Aaron Brock 2015-07-07 03:26:59 -04:00
parent b65d75ab0d
commit 63fb1a49d4
3 changed files with 59 additions and 21 deletions

View File

@ -6,12 +6,17 @@ use mineplex\plugin\gameengine\arenas\MultiGameArena;
use mineplex\plugin\gameengine\game\components\world\WorldComponent; use mineplex\plugin\gameengine\game\components\world\WorldComponent;
use mineplex\plugin\gameengine\game\factory\TestGameFactory; use mineplex\plugin\gameengine\game\factory\TestGameFactory;
use mineplex\plugin\core\updater\Updater; use mineplex\plugin\core\updater\Updater;
use mineplex\plugin\util\UtilString;
use pocketmine\block\Block;
use pocketmine\event\Listener; use pocketmine\event\Listener;
use pocketmine\event\player\PlayerCommandPreprocessEvent;
use pocketmine\event\player\PlayerDeathEvent; use pocketmine\event\player\PlayerDeathEvent;
use pocketmine\event\player\PlayerInteractEvent;
use pocketmine\event\player\PlayerJoinEvent; use pocketmine\event\player\PlayerJoinEvent;
use pocketmine\event\player\PlayerLoginEvent; use pocketmine\event\player\PlayerLoginEvent;
use pocketmine\level\Position; use pocketmine\level\Position;
use pocketmine\math\Vector3; use pocketmine\math\Vector3;
use pocketmine\Player;
use pocketmine\plugin\PluginBase; use pocketmine\plugin\PluginBase;
use mineplex\plugin\gameengine\arenas\Arena; use mineplex\plugin\gameengine\arenas\Arena;
use pocketmine\Server; use pocketmine\Server;
@ -45,4 +50,30 @@ class Main extends PluginBase implements Listener
{ {
$this->arena->addPlayer($event->getPlayer()); $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());
}
} }

View File

@ -13,11 +13,11 @@ use mineplex\plugin\gameengine\arenas\Arena;
use mineplex\plugin\gameengine\arenas\events\ArenaEndEvent; use mineplex\plugin\gameengine\arenas\events\ArenaEndEvent;
use mineplex\plugin\gameengine\game\components\world\event\WorldLoadSuccessEvent; use mineplex\plugin\gameengine\game\components\world\event\WorldLoadSuccessEvent;
use mineplex\plugin\gameengine\game\components\world\WorldComponent; use mineplex\plugin\gameengine\game\components\world\WorldComponent;
use mineplex\plugin\Main;
use mineplex\plugin\util\UtilArray; use mineplex\plugin\util\UtilArray;
use pocketmine\event\HandlerList; use pocketmine\event\HandlerList;
use pocketmine\event\Listener; use pocketmine\event\Listener;
use pocketmine\level\Position; use pocketmine\level\Position;
use pocketmine\math\Vector3;
use pocketmine\Player; use pocketmine\Player;
use pocketmine\Server; use pocketmine\Server;
@ -54,14 +54,6 @@ class SimpleSpawnComponent implements SpawnComponent, Listener {
print (count($this->spawns) . " spawns Loaded\n"); 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) function respawn(Player $player)
{ {
if (count($this->spawns) < 1) if (count($this->spawns) < 1)
{ {
print "no spawns!"; print "no spawns!";
return; return;
} }
/*
$player->getInventory()->clearAll(); $player->getInventory()->clearAll();
$player->removeAllEffects(); $player->removeAllEffects();
$player->resetFallDistance(); $player->resetFallDistance();
$player->setGamemode($this->gameMode); $player->setGamemode($this->gameMode);
$player->setHealth($player->getMaxHealth()); $player->setHealth($player->getMaxHealth());
*/
$player->sendMessage("Before:");
Main::sendLoc($player);
$pos = $this->spawns[array_rand($this->spawns)]; $pos = $this->spawns[array_rand($this->spawns)];
$pos = $pos->getLevel()->getSpawnLocation();
print "\nX: " . $pos->getX(); print "\nX: " . $pos->getX();
print "\nY: " . $pos->getY(); print "\nY: " . $pos->getY();
@ -91,6 +88,9 @@ class SimpleSpawnComponent implements SpawnComponent, Listener {
print "\nLevel: " . $pos->getLevel()->getName(); print "\nLevel: " . $pos->getLevel()->getName();
$player->teleport($pos); $player->teleport($pos);
$player->sendMessage("After:");
Main::sendLoc($player);
return $pos; return $pos;
} }

View File

@ -26,29 +26,36 @@ use mineplex\plugin\gameengine\game\components\world\WorldComponent;
use mineplex\plugin\gameengine\game\Game; use mineplex\plugin\gameengine\game\Game;
use mineplex\plugin\gameengine\arenas\Arena; use mineplex\plugin\gameengine\arenas\Arena;
use mineplex\plugin\gameengine\game\components\feature\Feature; 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; use pocketmine\item\Item;
class SurvivalGames implements Game { class SurvivalGames implements Game {
/** @var Arena */
private $arena;
function start(Arena $arena) function start(Arena $arena)
{ {
$this->arena = $arena;
$gameStateComponent = new GameStateComponent($arena); $gameStateComponent = new GameStateComponent($arena);
$spectateComponent = new GameModeSpectateComponent($arena); //$spectateComponent = new GameModeSpectateComponent($arena);
//Init features //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 */ /** @var Feature[][] $features */
$features = array( //$features = array(
GameState::LOBBY => array($noPickUpItem, $pack) // GameState::LOBBY => array($noPickUpItem, $pack)
); //);
new GameStateFeatureManager($arena, $features); //new GameStateFeatureManager($arena, $features);
new LobbyComponent($arena); //new LobbyComponent($arena);
$worldComponent = new WorldComponent($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 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);
} }
} }