Meh
Signed-off-by: Aaron Brock <TheMineBench@gmail.com>
This commit is contained in:
parent
4b800340d8
commit
31d6cbd7ce
@ -11,13 +11,15 @@ namespace mineplex\plugin\gameengine\game\components\countdown;
|
|||||||
use mineplex\plugin\gameengine\arenas\Arena;
|
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\gamestate\GameStateComponent;
|
use mineplex\plugin\gameengine\game\components\gamestate\GameStateComponent;
|
||||||
|
use mineplex\plugin\gameengine\game\components\gamestate\events\GameStateChangeEvent;
|
||||||
use mineplex\plugin\gameengine\time\BenchSchedule;
|
use mineplex\plugin\gameengine\time\BenchSchedule;
|
||||||
use mineplex\plugin\gameengine\time\BenchTask;
|
use mineplex\plugin\gameengine\time\BenchTask;
|
||||||
use mineplex\plugin\gameengine\time\BenchTaskData;
|
use mineplex\plugin\gameengine\time\BenchTaskData;
|
||||||
|
|
||||||
use pocketmine\event\HandlerList;
|
use pocketmine\event\HandlerList;
|
||||||
use pocketmine\event\Listener;
|
use pocketmine\event\Listener;
|
||||||
use pocketmine\Server;
|
use pocketmine\Server;
|
||||||
use mineplex\plugin\gameengine\game\components\gamestate\events\GameStateChangeEvent;
|
|
||||||
|
|
||||||
class GameStateCountdown implements Listener, BenchTask {
|
class GameStateCountdown implements Listener, BenchTask {
|
||||||
|
|
||||||
@ -69,17 +71,17 @@ class GameStateCountdown implements Listener, BenchTask {
|
|||||||
|
|
||||||
public function run(BenchTaskData $data)
|
public function run(BenchTaskData $data)
|
||||||
{
|
{
|
||||||
print "§$this->startGameState---"."\n";
|
//print "§$this->startGameState---"."\n";
|
||||||
|
$this->popup();
|
||||||
if ($this->count <= 0)
|
if ($this->count <= 0)
|
||||||
{
|
{
|
||||||
$this->gameStateComponent->setGameState($this->setGameState);
|
$this->gameStateComponent->setGameState($this->setGameState);
|
||||||
$data->end();
|
$data->end();
|
||||||
}
|
}
|
||||||
|
else
|
||||||
$this->popup();
|
{
|
||||||
|
$this->count--;
|
||||||
$this->count--;
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,87 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Created by PhpStorm.
|
||||||
|
* User: Exerosis
|
||||||
|
* Date: 7/9/2015
|
||||||
|
* Time: 10:07 PM
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace mineplex\plugin\gameengine\game\components\feature\features;
|
||||||
|
|
||||||
|
|
||||||
|
use mineplex\plugin\gameengine\arenas\Arena;
|
||||||
|
use mineplex\plugin\gameengine\game\components\feature\ListenerFeature;
|
||||||
|
use mineplex\plugin\gameengine\game\components\spectate\SpectateComponent;
|
||||||
|
use pocketmine\entity\Effect;
|
||||||
|
use pocketmine\event\player\PlayerMoveEvent;
|
||||||
|
use pocketmine\Player;
|
||||||
|
|
||||||
|
class FreezePlayers extends ListenerFeature {
|
||||||
|
|
||||||
|
private $spectateComponent;
|
||||||
|
|
||||||
|
function __construct(Arena $arena, SpectateComponent $spectateComponent = null)
|
||||||
|
{
|
||||||
|
parent::__construct($arena);
|
||||||
|
$this->spectateComponent = $spectateComponent;
|
||||||
|
}
|
||||||
|
|
||||||
|
function onMove(PlayerMoveEvent $event)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (!$this->hasPlayer($event->getPlayer()))
|
||||||
|
return;
|
||||||
|
|
||||||
|
if ($event->getFrom()->getFloorX() != $event->getTo()->getFloorX() || $event->getFrom()->getFloorZ() != $event->getTo()->getFloorZ())
|
||||||
|
$event->setCancelled();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function enable()
|
||||||
|
{
|
||||||
|
parent::enable();
|
||||||
|
|
||||||
|
$effect = new Effect(Effect::SLOWNESS, "Waiting till game start...", 0, 0, 0, true);
|
||||||
|
$effect->setVisible(false)->setAmplifier(9)->setDuration(PHP_INT_MAX);
|
||||||
|
print "Player Count: " . count($this->getPlayers()) . "\n";
|
||||||
|
foreach ($this->getPlayers() as $player)
|
||||||
|
{
|
||||||
|
print "Adding effect! \n";
|
||||||
|
$player->addEffect($effect);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function disable()
|
||||||
|
{
|
||||||
|
parent::disable();
|
||||||
|
print "Player Count: " . count($this->getPlayers()) . "\n";
|
||||||
|
foreach ($this->getPlayers() as $player)
|
||||||
|
{
|
||||||
|
print "Adding effect! \n";
|
||||||
|
$player->removeEffect(Effect::SLOWNESS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Player[]
|
||||||
|
*/
|
||||||
|
private function getPlayers()
|
||||||
|
{
|
||||||
|
if ($this->spectateComponent !== null)
|
||||||
|
return $this->spectateComponent->getNonSpectators();
|
||||||
|
else
|
||||||
|
return $this->getArena()->getPlayers();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Player $player
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
private function hasPlayer(Player $player)
|
||||||
|
{
|
||||||
|
if ($this->spectateComponent !== null)
|
||||||
|
return $this->spectateComponent->isNotSpectating($player);
|
||||||
|
else
|
||||||
|
return $this->getArena()->hasPlayer($player);
|
||||||
|
}
|
||||||
|
}
|
@ -25,7 +25,7 @@ class NoDamage extends ListenerFeature {
|
|||||||
{
|
{
|
||||||
if (!$this->getArena()->hasPlayer($event->getEntity()))
|
if (!$this->getArena()->hasPlayer($event->getEntity()))
|
||||||
return;
|
return;
|
||||||
Server::getInstance()->broadcastMessage("Stopped!");
|
//Server::getInstance()->broadcastMessage("Stopped!");
|
||||||
$event->setCancelled();
|
$event->setCancelled();
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -11,6 +11,7 @@ namespace mineplex\plugin\gameengine\game\games\sg;
|
|||||||
use mineplex\plugin\gameengine\arenas\Arena;
|
use mineplex\plugin\gameengine\arenas\Arena;
|
||||||
use mineplex\plugin\gameengine\game\components\countdown\GameStateCountdown;
|
use mineplex\plugin\gameengine\game\components\countdown\GameStateCountdown;
|
||||||
use mineplex\plugin\gameengine\game\components\feature\features\DeathSpectate;
|
use mineplex\plugin\gameengine\game\components\feature\features\DeathSpectate;
|
||||||
|
use mineplex\plugin\gameengine\game\components\feature\features\FreezePlayers;
|
||||||
use mineplex\plugin\gameengine\game\components\feature\features\JoinSpectate;
|
use mineplex\plugin\gameengine\game\components\feature\features\JoinSpectate;
|
||||||
use mineplex\plugin\gameengine\game\components\feature\features\NoBlockBreak;
|
use mineplex\plugin\gameengine\game\components\feature\features\NoBlockBreak;
|
||||||
use mineplex\plugin\gameengine\game\components\feature\features\NoBlockPlace;
|
use mineplex\plugin\gameengine\game\components\feature\features\NoBlockPlace;
|
||||||
@ -21,7 +22,10 @@ use mineplex\plugin\gameengine\game\components\feature\managers\GameStateFeature
|
|||||||
use mineplex\plugin\gameengine\game\components\gamestate\GameState;
|
use mineplex\plugin\gameengine\game\components\gamestate\GameState;
|
||||||
use mineplex\plugin\gameengine\game\components\gamestate\GameStateComponent;
|
use mineplex\plugin\gameengine\game\components\gamestate\GameStateComponent;
|
||||||
use mineplex\plugin\gameengine\game\components\lobby\LobbyComponent;
|
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\spectate\GameModeSpectateComponent;
|
||||||
|
use mineplex\plugin\gameengine\game\components\world\WorldComponent;
|
||||||
use mineplex\plugin\gameengine\game\Game;
|
use mineplex\plugin\gameengine\game\Game;
|
||||||
use mineplex\plugin\gameengine\game\components\countdown\LobbyCountdown;
|
use mineplex\plugin\gameengine\game\components\countdown\LobbyCountdown;
|
||||||
use mineplex\plugin\gameengine\game\components\feature\Feature;
|
use mineplex\plugin\gameengine\game\components\feature\Feature;
|
||||||
@ -34,7 +38,11 @@ class SurvivalGames implements Game {
|
|||||||
|
|
||||||
$spectateComponent = new GameModeSpectateComponent($arena);
|
$spectateComponent = new GameModeSpectateComponent($arena);
|
||||||
|
|
||||||
//Init features
|
$worldComponent = new WorldComponent($arena);
|
||||||
|
|
||||||
|
new LobbyComponent($arena);
|
||||||
|
|
||||||
|
//Features start----
|
||||||
$noDamage = new NoDamage($arena);
|
$noDamage = new NoDamage($arena);
|
||||||
$joinSpectate = new JoinSpectate($arena, $spectateComponent);
|
$joinSpectate = new JoinSpectate($arena, $spectateComponent);
|
||||||
|
|
||||||
@ -43,10 +51,7 @@ class SurvivalGames implements Game {
|
|||||||
/** @var Feature[][] $features */
|
/** @var Feature[][] $features */
|
||||||
$features = array(
|
$features = array(
|
||||||
|
|
||||||
//Just here cause I'm not using LobbyComponent atm
|
GameState::PRE_GAME => array( $stopEveryThing, $noDamage, $joinSpectate, new FreezePlayers($arena, $spectateComponent)),
|
||||||
//GameState::LOBBY => array( $stopEveryThing, $noDamage, ),
|
|
||||||
|
|
||||||
GameState::PRE_GAME => array( $stopEveryThing, $noDamage, $joinSpectate),
|
|
||||||
|
|
||||||
GameState::GAME => array( $stopEveryThing, $joinSpectate , new DeathSpectate($arena, $spectateComponent)),
|
GameState::GAME => array( $stopEveryThing, $joinSpectate , new DeathSpectate($arena, $spectateComponent)),
|
||||||
|
|
||||||
@ -54,15 +59,18 @@ class SurvivalGames implements Game {
|
|||||||
|
|
||||||
);
|
);
|
||||||
|
|
||||||
new LobbyComponent($arena);
|
|
||||||
|
|
||||||
new GameStateFeatureManager($arena, $features);
|
new GameStateFeatureManager($arena, $features);
|
||||||
|
//Features end---
|
||||||
|
|
||||||
new LobbyCountdown( $arena, $gameStateComponent, null, GameState::LOBBY, GameState::PRE_GAME, 10, 2);
|
|
||||||
|
|
||||||
|
new SpawnAt($arena, new SimpleSpawnComponent($arena, $worldComponent), [GameState::PRE_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, 5, GameState::LOBBY, GameState::PRE_GAME);
|
||||||
|
|
||||||
new GameStateCountdown($arena, $gameStateComponent, 5, GameState::PRE_GAME, GameState::GAME);
|
new GameStateCountdown($arena, $gameStateComponent, 20, GameState::PRE_GAME, GameState::GAME);
|
||||||
|
|
||||||
//new GameStateCountdown($arena, $gameStateComponent, 5, GameState::GAME, GameState::POST_GAME);
|
//new GameStateCountdown($arena, $gameStateComponent, 5, GameState::GAME, GameState::POST_GAME);
|
||||||
new LMSVictoryType( $arena, $spectateComponent, $gameStateComponent);
|
new LMSVictoryType( $arena, $spectateComponent, $gameStateComponent);
|
||||||
|
@ -20,65 +20,28 @@ use pocketmine\network\protocol\UpdateBlockPacket;
|
|||||||
|
|
||||||
class UtilTeleport {
|
class UtilTeleport {
|
||||||
|
|
||||||
public static function teleport(Player $player, Position $pos)
|
public static function teleport(Player $player, Position $position) {
|
||||||
{
|
|
||||||
|
|
||||||
$player->noDamageTicks = 20;
|
$current = $player->getPosition();
|
||||||
|
|
||||||
//$player->teleport($pos);
|
//
|
||||||
|
// This CRAZY HACK is to remove Tile entities that seem to linger
|
||||||
|
// whenever you teleport!
|
||||||
|
//
|
||||||
|
|
||||||
$current = $player->getLevel();
|
if ($current->getLevel() != $position->getLevel()) {
|
||||||
|
$player->noDamageTicks = 20;
|
||||||
if ($current->getName() != $pos->getLevel()) {
|
foreach ($current->getLevel()->getTiles() as $tile) {
|
||||||
|
|
||||||
foreach ($pos->getLevel()->getTiles() as $tile)
|
|
||||||
{
|
|
||||||
$pk = new UpdateBlockPacket();
|
$pk = new UpdateBlockPacket();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$pk->x = $tile->x;
|
$pk->x = $tile->x;
|
||||||
$pk->y = $tile->y;
|
$pk->y = $tile->y;
|
||||||
$pk->z = $tile->z;
|
$pk->z = $tile->z;
|
||||||
|
$pk->block = 0;
|
||||||
|
$pk->meta = 0;
|
||||||
$pk->block = $tile->getBlock();
|
|
||||||
$pk->meta = $tile->metadata;
|
|
||||||
|
|
||||||
Packet
|
|
||||||
|
|
||||||
$player->dataPacket($pk);
|
$player->dataPacket($pk);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
foreach ($current->getTiles() as $tile) {
|
|
||||||
|
|
||||||
$pk = new UpdateBlockPacket();
|
|
||||||
|
|
||||||
$thereTile = $pos->getLevel()->getTile(new Vector3($tile->x, $tile->y, $tile->z));
|
|
||||||
|
|
||||||
$pk->x = $tile->x;
|
|
||||||
$pk->y = $tile->y;
|
|
||||||
$pk->z = $tile->z;
|
|
||||||
if ($thereTile !== null)
|
|
||||||
{
|
|
||||||
print "There tile is not null!";
|
|
||||||
$pk->block = $thereTile->getBlock();
|
|
||||||
$pk->meta = $thereTile->metadata;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
print "null!";
|
|
||||||
$pk->block = 0;
|
|
||||||
$pk->meta = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
$player->dataPacket($pk);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
//$player->sendChunk()
|
$player->teleport($position); // Start the teleport
|
||||||
$player->teleport($pos);
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user