Merge branch 'master' of ssh://184.154.0.242:7999/min/mineplex
This commit is contained in:
commit
2bec753a34
@ -42,11 +42,11 @@ public class NotificationManager extends MiniPlugin
|
||||
if (!_enabled)
|
||||
return;
|
||||
|
||||
if (event.getType() == UpdateType.MIN_08)
|
||||
hugeSale();
|
||||
// if (event.getType() == UpdateType.MIN_08)
|
||||
// hugeSale();
|
||||
|
||||
// if (event.getType() == UpdateType.MIN_16)
|
||||
// sale();
|
||||
if (event.getType() == UpdateType.MIN_16)
|
||||
sale();
|
||||
}
|
||||
|
||||
private void sale()
|
||||
|
@ -2,15 +2,18 @@
|
||||
|
||||
namespace mineplex\plugin;
|
||||
|
||||
use mineplex\plugin\bench\arenas\MultiGameArena;
|
||||
use mineplex\plugin\bench\game\components\world\WorldComponent;
|
||||
use mineplex\plugin\bench\game\factory\TestGameFactory;
|
||||
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 pocketmine\event\Listener;
|
||||
use pocketmine\event\player\PlayerDeathEvent;
|
||||
use pocketmine\event\player\PlayerJoinEvent;
|
||||
use pocketmine\event\player\PlayerLoginEvent;
|
||||
use pocketmine\level\Position;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\plugin\PluginBase;
|
||||
use mineplex\plugin\bench\arenas\Arena;
|
||||
use mineplex\plugin\gameengine\arenas\Arena;
|
||||
use pocketmine\Server;
|
||||
|
||||
class Main extends PluginBase implements Listener
|
||||
@ -24,9 +27,7 @@ class Main extends PluginBase implements Listener
|
||||
$this->arena = new MultiGameArena($this, new TestGameFactory());
|
||||
Server::getInstance()->getPluginManager()->registerEvents($this, $this);
|
||||
|
||||
$this->test = new WorldComponent($this->arena);
|
||||
|
||||
//$this->getServer()->getPluginManager()->registerEvents($this, $this);
|
||||
//$this->test = new WorldComponent($this->arena);
|
||||
|
||||
new Updater($this);
|
||||
}
|
||||
|
@ -1,82 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: TheMineBench
|
||||
* Date: 7/1/2015
|
||||
* Time: 10:20 PM
|
||||
*/
|
||||
|
||||
namespace mineplex\plugin\bench\game\components\feature\features;
|
||||
|
||||
use mineplex\plugin\bench\arenas\Arena;
|
||||
use mineplex\plugin\bench\game\components\feature\Feature;
|
||||
use pocketmine\event\block\BlockBreakEvent;
|
||||
use pocketmine\event\HandlerList;
|
||||
use pocketmine\event\Listener;
|
||||
use pocketmine\Server;
|
||||
|
||||
class NoBlockBreak implements Feature, Listener {
|
||||
|
||||
/** @var Arena */
|
||||
private $arena;
|
||||
|
||||
/** @var int[] */
|
||||
private $ids = [];
|
||||
|
||||
/** @var bool */
|
||||
private $black;
|
||||
|
||||
/** @var bool */
|
||||
private $enabled = false;
|
||||
|
||||
/**
|
||||
* @param Arena $arena
|
||||
* @param int[] $ids
|
||||
* @param bool $black
|
||||
*/
|
||||
public function __construct(Arena $arena, array $ids = null, $black = false)
|
||||
{
|
||||
if ($ids != null) {
|
||||
$this->ids = array_flip($ids);
|
||||
foreach ($this->ids as $key => $value)
|
||||
{
|
||||
print "Key:" . $key;
|
||||
}
|
||||
}
|
||||
print "\n" . "Black: " . (($black) ? 'true' : 'false') . "\n";
|
||||
|
||||
$this->black = $black;
|
||||
|
||||
print "\n" . "SetBlackList: " . (($this->black) ? 'true' : 'false') . "\n";
|
||||
|
||||
$this->arena = $arena;
|
||||
}
|
||||
|
||||
public function onBlockBreak(BlockBreakEvent $event)
|
||||
{
|
||||
if (!in_array($event->getPlayer(), $this->arena->getPlayers()))
|
||||
return;
|
||||
|
||||
if ($this->black == (isset($this->ids[$event->getBlock()->getId()]) || array_key_exists($event->getBlock()->getId(), $this->ids)))
|
||||
$event->setCancelled();
|
||||
}
|
||||
|
||||
public function enable()
|
||||
{
|
||||
Server::getInstance()->broadcastMessage("Enabled!");
|
||||
$this->enabled = true;
|
||||
Server::getInstance()->getPluginManager()->registerEvents($this, $this->arena->getPlugin());
|
||||
}
|
||||
|
||||
public function disable()
|
||||
{
|
||||
Server::getInstance()->broadcastMessage("Disabled!");
|
||||
$this->enabled = false;
|
||||
HandlerList::unregisterAll($this);
|
||||
}
|
||||
|
||||
public function isEnabled()
|
||||
{
|
||||
return $this->enabled;
|
||||
}
|
||||
}
|
@ -1,63 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: TheMineBench
|
||||
* Date: 7/1/2015
|
||||
* Time: 10:20 PM
|
||||
*/
|
||||
|
||||
namespace mineplex\plugin\bench\game\components\feature\features;
|
||||
|
||||
use mineplex\plugin\bench\arenas\Arena;
|
||||
use mineplex\plugin\bench\game\components\feature\Feature;
|
||||
use pocketmine\entity\Effect;
|
||||
use pocketmine\event\block\BlockBreakEvent;
|
||||
use pocketmine\event\HandlerList;
|
||||
use pocketmine\event\Listener;
|
||||
use pocketmine\Player;
|
||||
use pocketmine\Server;
|
||||
|
||||
class NoMovement implements Feature, Listener {
|
||||
|
||||
private $arena;
|
||||
private $enabled = false;
|
||||
|
||||
|
||||
public function __construct(Arena $arena)
|
||||
{
|
||||
$this->arena = $arena;
|
||||
}
|
||||
|
||||
public function onBlockBreak(BlockBreakEvent $event)
|
||||
{
|
||||
if (!in_array($event->getPlayer(), $this->arena->getPlayers()))
|
||||
return;
|
||||
|
||||
|
||||
|
||||
$event->setCancelled(true);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function enable()
|
||||
{
|
||||
$this->enabled = true;
|
||||
Server::getInstance()->getPluginManager()->registerEvents($this, $this->arena->getPlugin());
|
||||
}
|
||||
|
||||
public function disable()
|
||||
{
|
||||
Server::getInstance()->broadcastMessage("Disabled!");
|
||||
$this->enabled = false;
|
||||
HandlerList::unregisterAll($this);
|
||||
}
|
||||
|
||||
public function isEnabled()
|
||||
{
|
||||
return $this->enabled;
|
||||
}
|
||||
}
|
@ -1,51 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: Exerosis
|
||||
* Date: 7/4/2015
|
||||
* Time: 3:09 PM
|
||||
*/
|
||||
|
||||
namespace mineplex\plugin\bench\game\games\sg;
|
||||
|
||||
use mineplex\plugin\bench\game\components\countdown\GameStateCountdown;
|
||||
use mineplex\plugin\bench\game\components\feature\features\NoBlockBreak;
|
||||
use mineplex\plugin\bench\game\components\feature\GameStateFeatureManager;
|
||||
use mineplex\plugin\bench\game\components\gamestate\GameState;
|
||||
use mineplex\plugin\bench\game\components\gamestate\GameStateComponent;
|
||||
use mineplex\plugin\bench\game\components\lobby\LobbyComponent;
|
||||
use mineplex\plugin\bench\game\Game;
|
||||
use mineplex\plugin\bench\arenas\Arena;
|
||||
use mineplex\plugin\bench\game\components\feature\Feature;
|
||||
use pocketmine\item\Item;
|
||||
|
||||
class SurvivalGames implements Game {
|
||||
|
||||
function start(Arena $arena)
|
||||
{
|
||||
$gameStateComponent = new GameStateComponent($arena);
|
||||
|
||||
$noBlockBreak = new NoBlockBreak($arena);
|
||||
$someBlockBreak = new NoBlockBreak($arena, array(Item::GRASS));
|
||||
|
||||
/** @var Feature[][] $features */
|
||||
$features = array(
|
||||
GameState::LOBBY => array($noBlockBreak),
|
||||
GameState::PRE_GAME => array($noBlockBreak),
|
||||
GameState::GAME => array($someBlockBreak),
|
||||
GameState::POST_GAME => array($noBlockBreak)
|
||||
);
|
||||
|
||||
new LobbyComponent($arena);
|
||||
|
||||
//new GameStateFeatureManager($arena, $features);
|
||||
|
||||
new GameStateCountdown($arena, $gameStateComponent, 20, GameState::LOBBY, GameState::PRE_GAME);
|
||||
|
||||
new GameStateCountdown($arena, $gameStateComponent, 10, GameState::PRE_GAME, GameState::GAME);
|
||||
|
||||
new GameStateCountdown($arena, $gameStateComponent, 30, GameState::GAME, GameState::POST_GAME);
|
||||
|
||||
new GameStateCountdown($arena, $gameStateComponent, 10, GameState::POST_GAME, GameState::RESTARTING);
|
||||
}
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: Exerosis
|
||||
* Date: 7/6/2015
|
||||
* Time: 6:12 PM
|
||||
*/
|
||||
|
||||
namespace mineplex\plugin\core\commen;
|
||||
|
||||
use mineplex\plugin\util\UtilArray;
|
||||
|
||||
class ItemContainer {
|
||||
|
||||
/** @var int[] */
|
||||
private $ids = [];
|
||||
|
||||
/** @var bool */
|
||||
private $black;
|
||||
|
||||
/**
|
||||
* @param int[] $ids
|
||||
* @param bool $black
|
||||
*/
|
||||
public function __construct(array $ids = null, $black = false)
|
||||
{
|
||||
if ($ids != null)
|
||||
{
|
||||
$this->ids = array_flip($ids);
|
||||
}
|
||||
$this->black = $black;
|
||||
}
|
||||
|
||||
public function hasItem($id)
|
||||
{
|
||||
return ($this->black == UtilArray::hasKey($id, $this->ids));
|
||||
}
|
||||
}
|
@ -15,6 +15,7 @@ use pocketmine\scheduler\PluginTask;
|
||||
class Updater extends PluginTask
|
||||
{
|
||||
private $plugin;
|
||||
/** @var UpdateType[] */
|
||||
private $updateTypes;
|
||||
|
||||
public function __construct(PluginBase $host)
|
||||
@ -51,7 +52,7 @@ class Updater extends PluginTask
|
||||
{
|
||||
if ($updateType->canTrigger())
|
||||
{
|
||||
$updateTypes[$updateType] = 1;
|
||||
$updateTypes[$updateType->time] = 1;
|
||||
}
|
||||
}
|
||||
//Call Event
|
||||
|
@ -5,7 +5,7 @@
|
||||
* Date: 6/30/2015
|
||||
* Time: 1:35 PM
|
||||
*/
|
||||
namespace mineplex\plugin\bench\arenas;
|
||||
namespace mineplex\plugin\gameengine\arenas;
|
||||
|
||||
use pocketmine\plugin\Plugin;
|
||||
use pocketmine\Player;
|
||||
@ -25,6 +25,12 @@ interface Arena
|
||||
*/
|
||||
public function getPlayers();
|
||||
|
||||
/**
|
||||
* @param mixed $player
|
||||
* @return bool
|
||||
*/
|
||||
public function hasPlayer($player);
|
||||
|
||||
/**
|
||||
* @return Plugin
|
||||
*/
|
@ -5,7 +5,7 @@
|
||||
* Date: 6/30/2015
|
||||
* Time: 9:06 PM
|
||||
*/
|
||||
namespace mineplex\plugin\bench\arenas;
|
||||
namespace mineplex\plugin\gameengine\arenas;
|
||||
|
||||
use pocketmine\event\Event;
|
||||
|
@ -6,26 +6,25 @@
|
||||
* Time: 12:14 PM
|
||||
*/
|
||||
|
||||
namespace mineplex\plugin\bench\arenas;
|
||||
namespace mineplex\plugin\gameengine\arenas;
|
||||
|
||||
use mineplex\plugin\bench\arenas\events\ArenaEndEvent;
|
||||
use mineplex\plugin\bench\game\factory\GameFactory;
|
||||
use mineplex\plugin\gameengine\arenas\events\ArenaEndEvent;
|
||||
use mineplex\plugin\gameengine\game\factory\GameFactory;
|
||||
use pocketmine\event\Listener;
|
||||
use pocketmine\plugin\Plugin;
|
||||
use pocketmine\event\player\PlayerJoinEvent;
|
||||
use pocketmine\event\player\PlayerQuitEvent;
|
||||
use pocketmine\Player;
|
||||
use pocketmine\Server;
|
||||
use mineplex\plugin\bench\game\Game;
|
||||
use mineplex\plugin\bench\arenas\events\ArenaCanJoinEvent;
|
||||
use mineplex\plugin\bench\arenas\events\ArenaJoinEvent;
|
||||
use mineplex\plugin\bench\arenas\events\ArenaQuitEvent;
|
||||
use mineplex\plugin\bench\arenas\events\ArenaStartEvent;
|
||||
use mineplex\plugin\gameengine\game\Game;
|
||||
use mineplex\plugin\gameengine\arenas\events\ArenaCanJoinEvent;
|
||||
use mineplex\plugin\gameengine\arenas\events\ArenaJoinEvent;
|
||||
use mineplex\plugin\gameengine\arenas\events\ArenaQuitEvent;
|
||||
use mineplex\plugin\gameengine\arenas\events\ArenaStartEvent;
|
||||
|
||||
|
||||
class MultiGameArena implements Arena, Listener
|
||||
{
|
||||
|
||||
/** @var Player[] */
|
||||
private $players = array();
|
||||
|
||||
@ -90,6 +89,17 @@ class MultiGameArena implements Arena, Listener
|
||||
return $this->players;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $player
|
||||
* @return bool
|
||||
*/
|
||||
public function hasPlayer($player)
|
||||
{
|
||||
if (!($player instanceof Player))
|
||||
return false;
|
||||
return in_array($player, $this->getPlayers());
|
||||
}
|
||||
|
||||
public function getCurrentGame()
|
||||
{
|
||||
return $this->game;
|
@ -5,20 +5,20 @@
|
||||
* Date: 6/30/2015
|
||||
* Time: 1:37 PM
|
||||
*/
|
||||
namespace mineplex\plugin\bench\arenas;
|
||||
namespace mineplex\plugin\gameengine\arenas;
|
||||
|
||||
use mineplex\plugin\bench\arenas\events\ArenaEndEvent;
|
||||
use mineplex\plugin\gameengine\arenas\events\ArenaEndEvent;
|
||||
use pocketmine\event\Listener;
|
||||
use pocketmine\plugin\Plugin;
|
||||
use pocketmine\event\player\PlayerJoinEvent;
|
||||
use pocketmine\event\player\PlayerQuitEvent;
|
||||
use pocketmine\Player;
|
||||
use pocketmine\Server;
|
||||
use mineplex\plugin\bench\game\Game;
|
||||
use mineplex\plugin\bench\arenas\events\ArenaCanJoinEvent;
|
||||
use mineplex\plugin\bench\arenas\events\ArenaJoinEvent;
|
||||
use mineplex\plugin\bench\arenas\events\ArenaQuitEvent;
|
||||
use mineplex\plugin\bench\arenas\events\ArenaStartEvent;
|
||||
use mineplex\plugin\gameengine\game\Game;
|
||||
use mineplex\plugin\gameengine\arenas\events\ArenaCanJoinEvent;
|
||||
use mineplex\plugin\gameengine\arenas\events\ArenaJoinEvent;
|
||||
use mineplex\plugin\gameengine\arenas\events\ArenaQuitEvent;
|
||||
use mineplex\plugin\gameengine\arenas\events\ArenaStartEvent;
|
||||
|
||||
class SingleGameArena implements Arena, Listener {
|
||||
//I really have no idea if there is a better way to store players... but this is what I'm using for now.
|
@ -5,12 +5,12 @@
|
||||
* Date: 6/30/2015
|
||||
* Time: 9:22 PM
|
||||
*/
|
||||
namespace mineplex\plugin\bench\arenas\events;
|
||||
namespace mineplex\plugin\gameengine\arenas\events;
|
||||
|
||||
use pocketmine\event\Cancellable;
|
||||
use pocketmine\Player;
|
||||
use mineplex\plugin\bench\arenas\ArenaEvent;
|
||||
use mineplex\plugin\bench\arenas\Arena;
|
||||
use mineplex\plugin\gameengine\arenas\ArenaEvent;
|
||||
use mineplex\plugin\gameengine\arenas\Arena;
|
||||
|
||||
class ArenaCanJoinEvent extends ArenaEvent implements Cancellable {
|
||||
public static $handlerList = null;
|
@ -5,10 +5,10 @@
|
||||
* Date: 6/30/2015
|
||||
* Time: 10:12 PM
|
||||
*/
|
||||
namespace mineplex\plugin\bench\arenas\events;
|
||||
namespace mineplex\plugin\gameengine\arenas\events;
|
||||
|
||||
use mineplex\plugin\bench\arenas\ArenaEvent;
|
||||
use mineplex\plugin\bench\arenas\Arena;
|
||||
use mineplex\plugin\gameengine\arenas\ArenaEvent;
|
||||
use mineplex\plugin\gameengine\arenas\Arena;
|
||||
|
||||
|
||||
class ArenaEndEvent extends ArenaEvent{
|
@ -5,13 +5,13 @@
|
||||
* Date: 6/30/2015
|
||||
* Time: 9:22 PM
|
||||
*/
|
||||
namespace mineplex\plugin\bench\arenas\events;
|
||||
namespace mineplex\plugin\gameengine\arenas\events;
|
||||
|
||||
use pocketmine\Player;
|
||||
|
||||
use mineplex\plugin\bench\arenas\ArenaEvent;
|
||||
use mineplex\plugin\gameengine\arenas\ArenaEvent;
|
||||
|
||||
use mineplex\plugin\bench\arenas\Arena;
|
||||
use mineplex\plugin\gameengine\arenas\Arena;
|
||||
|
||||
class ArenaJoinEvent extends ArenaEvent {
|
||||
public static $handlerList = null;
|
@ -6,11 +6,11 @@
|
||||
* Time: 9:22 PM
|
||||
*/
|
||||
|
||||
namespace mineplex\plugin\bench\arenas\events;
|
||||
namespace mineplex\plugin\gameengine\arenas\events;
|
||||
|
||||
use pocketmine\Player;
|
||||
use mineplex\plugin\bench\arenas\ArenaEvent;
|
||||
use mineplex\plugin\bench\arenas\Arena;
|
||||
use mineplex\plugin\gameengine\arenas\ArenaEvent;
|
||||
use mineplex\plugin\gameengine\arenas\Arena;
|
||||
|
||||
class ArenaQuitEvent extends ArenaEvent {
|
||||
public static $handlerList = null;
|
@ -5,10 +5,10 @@
|
||||
* Date: 6/30/2015
|
||||
* Time: 10:12 PM
|
||||
*/
|
||||
namespace mineplex\plugin\bench\arenas\events;
|
||||
namespace mineplex\plugin\gameengine\arenas\events;
|
||||
|
||||
use mineplex\plugin\bench\arenas\ArenaEvent;
|
||||
use mineplex\plugin\bench\arenas\Arena;
|
||||
use mineplex\plugin\gameengine\arenas\ArenaEvent;
|
||||
use mineplex\plugin\gameengine\arenas\Arena;
|
||||
|
||||
class ArenaStartEvent extends ArenaEvent{
|
||||
public static $handlerList = null;
|
@ -5,9 +5,9 @@
|
||||
* Date: 6/30/2015
|
||||
* Time: 9:04 PM
|
||||
*/
|
||||
namespace mineplex\plugin\bench\game;
|
||||
namespace mineplex\plugin\gameengine\game;
|
||||
|
||||
use mineplex\plugin\bench\arenas\Arena;
|
||||
use mineplex\plugin\gameengine\arenas\Arena;
|
||||
|
||||
interface Game {
|
||||
public function start(Arena $arena);
|
@ -6,18 +6,18 @@
|
||||
* Time: 5:52 PM
|
||||
*/
|
||||
|
||||
namespace mineplex\plugin\bench\game\components\countdown;
|
||||
namespace mineplex\plugin\gameengine\game\components\countdown;
|
||||
|
||||
use mineplex\plugin\bench\arenas\Arena;
|
||||
use mineplex\plugin\bench\arenas\events\ArenaEndEvent;
|
||||
use mineplex\plugin\bench\game\components\gamestate\GameStateComponent;
|
||||
use mineplex\plugin\bench\time\BenchSchedule;
|
||||
use mineplex\plugin\bench\time\BenchTask;
|
||||
use mineplex\plugin\bench\time\BenchTaskData;
|
||||
use mineplex\plugin\gameengine\arenas\Arena;
|
||||
use mineplex\plugin\gameengine\arenas\events\ArenaEndEvent;
|
||||
use mineplex\plugin\gameengine\game\components\gamestate\GameStateComponent;
|
||||
use mineplex\plugin\gameengine\time\BenchSchedule;
|
||||
use mineplex\plugin\gameengine\time\BenchTask;
|
||||
use mineplex\plugin\gameengine\time\BenchTaskData;
|
||||
use pocketmine\event\HandlerList;
|
||||
use pocketmine\event\Listener;
|
||||
use pocketmine\Server;
|
||||
use mineplex\plugin\bench\game\components\gamestate\events\GameStateChangeEvent;
|
||||
use mineplex\plugin\gameengine\game\components\gamestate\events\GameStateChangeEvent;
|
||||
|
||||
class GameStateCountdown implements Listener, BenchTask {
|
||||
|
@ -0,0 +1,197 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: Exerosis
|
||||
* Date: 7/5/2015
|
||||
* Time: 7:41 PM
|
||||
*/
|
||||
|
||||
namespace mineplex\plugin\gameengine\game\components\countdown;
|
||||
|
||||
use mineplex\plugin\gameengine\arenas\Arena;
|
||||
use mineplex\plugin\gameengine\arenas\events\ArenaEndEvent;
|
||||
use mineplex\plugin\gameengine\arenas\events\ArenaJoinEvent;
|
||||
use mineplex\plugin\gameengine\arenas\events\ArenaQuitEvent;
|
||||
use mineplex\plugin\gameengine\game\components\gamestate\GameStateComponent;
|
||||
use mineplex\plugin\gameengine\game\components\world\event\WorldLoadSuccessEvent;
|
||||
use mineplex\plugin\gameengine\game\components\world\WorldComponent;
|
||||
use mineplex\plugin\gameengine\time\BenchSchedule;
|
||||
use mineplex\plugin\gameengine\time\BenchTask;
|
||||
use mineplex\plugin\gameengine\time\BenchTaskData;
|
||||
use pocketmine\entity\Effect;
|
||||
use pocketmine\event\HandlerList;
|
||||
use pocketmine\event\Listener;
|
||||
use pocketmine\event\player\PlayerDeathEvent;
|
||||
use pocketmine\network\protocol\AnimatePacket;
|
||||
use pocketmine\network\protocol\ContainerSetDataPacket;
|
||||
use pocketmine\network\protocol\DropItemPacket;
|
||||
use pocketmine\Player;
|
||||
use pocketmine\Server;
|
||||
use mineplex\plugin\gameengine\game\components\gamestate\events\GameStateChangeEvent;
|
||||
|
||||
class LobbyCountdown implements Listener, BenchTask {
|
||||
|
||||
private $startCount;
|
||||
private $count;
|
||||
private $gameStateComponent;
|
||||
private $worldComponent;
|
||||
private $arena;
|
||||
private $startGameState;
|
||||
private $setGameState;
|
||||
private $minPlayers;
|
||||
|
||||
private $message;
|
||||
|
||||
const WAITING_FOR_PLAYERS = "Waiting for players!";
|
||||
|
||||
const POPUP_ID = "popup";
|
||||
const COUNTDOWN_ID = "count";
|
||||
|
||||
|
||||
public function __construct(Arena $arena, GameStateComponent $gameStateComponent, WorldComponent $worldComponent, $startGameState, $setGameState, $count, $minPlayers = 2)
|
||||
{
|
||||
$this->arena = $arena;
|
||||
$this->gameStateComponent = $gameStateComponent;
|
||||
$this->worldComponent = $worldComponent;
|
||||
$this->minPlayers = $minPlayers;
|
||||
|
||||
$this->startCount = $count;
|
||||
$this->count = $count;
|
||||
|
||||
$this->startGameState = $startGameState;
|
||||
$this->setGameState = $setGameState;
|
||||
|
||||
$this->message = self::WAITING_FOR_PLAYERS;
|
||||
|
||||
Server::getInstance()->getPluginManager()->registerEvents($this, $arena->getPlugin());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param bool $addOne
|
||||
*/
|
||||
function checkCountdown($addOne = false)
|
||||
{
|
||||
$playerCount = (count($this->arena->getPlayers()) + $addOne);
|
||||
|
||||
if ($this->gameStateComponent->getGameState() == $this->startGameState && $this->worldComponent->isWorldReady() && $playerCount >= $this->minPlayers)
|
||||
{
|
||||
if (!BenchSchedule::isRunningWithId($this, self::COUNTDOWN_ID))
|
||||
{
|
||||
$this->count = $this->startCount;
|
||||
$this->setCount();
|
||||
BenchSchedule::runTaskTimerWithId($this, 1000, 1000, self::COUNTDOWN_ID);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->setWaiting($playerCount);
|
||||
BenchSchedule::cancelTaskWithId($this, self::COUNTDOWN_ID);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function onJoin(ArenaJoinEvent $event)
|
||||
{
|
||||
if ($event->getArena() !== $this->arena)
|
||||
return;
|
||||
$this->checkCountdown(true);
|
||||
$this->popup($event->getPlayer());
|
||||
}
|
||||
|
||||
public function onQuit(ArenaQuitEvent $event)
|
||||
{
|
||||
if ($event->getArena() !== $this->arena)
|
||||
return;
|
||||
$this->checkCountdown();
|
||||
}
|
||||
|
||||
public function onWorldCreation(WorldLoadSuccessEvent $event)
|
||||
{
|
||||
if ($event->getArena() !== $this->arena)
|
||||
return;
|
||||
|
||||
$this->checkCountdown();
|
||||
}
|
||||
|
||||
public function onGameStateChange(GameStateChangeEvent $event)
|
||||
{
|
||||
if ($event->getArena() !== $this->arena)
|
||||
return;
|
||||
|
||||
if ($event->getToGameState() == $this->startGameState)
|
||||
{
|
||||
$this->checkCountdown();
|
||||
BenchSchedule::runTaskTimerWithId($this, 500, 500, self::POPUP_ID);
|
||||
|
||||
}
|
||||
elseif ($event->getFromGameState() == $this->startGameState)
|
||||
{
|
||||
//Cancels both tasks
|
||||
BenchSchedule::cancelTask($this);
|
||||
|
||||
$this->count = $this->startCount;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function onEnd(ArenaEndEvent $event)
|
||||
{
|
||||
if ($event->getArena() !== $this->arena)
|
||||
return;
|
||||
HandlerList::unregisterAll($this);
|
||||
}
|
||||
|
||||
public function run(BenchTaskData $data)
|
||||
{
|
||||
if ($data->getId() == self::POPUP_ID)
|
||||
{
|
||||
$this->popupAll();
|
||||
}
|
||||
else //if ($data->getId() == self::COUNTDOWN_ID)
|
||||
{
|
||||
if ($this->count <= 0)
|
||||
{
|
||||
$this->gameStateComponent->setGameState($this->setGameState);
|
||||
$data->end();
|
||||
return;
|
||||
}
|
||||
|
||||
$this->message = "§9Game starting in:§c $this->count";
|
||||
|
||||
$this->count--;
|
||||
}
|
||||
}
|
||||
|
||||
private function setWaiting($playerCount = null)
|
||||
{
|
||||
if ($playerCount == null)
|
||||
$playerCount = count($this->arena->getPlayers());
|
||||
$this->message = "§2Waiting for players! §a($playerCount/$this->minPlayers)";
|
||||
$this->popupAll();
|
||||
}
|
||||
|
||||
private function setCount($count = null)
|
||||
{
|
||||
if ($count == null)
|
||||
$count = $this->count;
|
||||
$this->message = "§9Game starting in:§c $count";
|
||||
$this->popupAll();
|
||||
}
|
||||
|
||||
private function popupAll()
|
||||
{
|
||||
foreach ($this->arena->getPlayers() as $player)
|
||||
{
|
||||
$this->popup($player);
|
||||
}
|
||||
}
|
||||
|
||||
private function popup(Player $player)
|
||||
{
|
||||
$player->sendTip($this->message);
|
||||
}
|
||||
}
|
@ -6,15 +6,17 @@
|
||||
* Time: 10:18 PM
|
||||
*/
|
||||
|
||||
namespace mineplex\plugin\bench\game\components\feature;
|
||||
namespace mineplex\plugin\gameengine\game\components\feature;
|
||||
|
||||
|
||||
interface Feature {
|
||||
|
||||
public function enable();
|
||||
|
||||
public function disable();
|
||||
/**
|
||||
* @return boolean
|
||||
*/
|
||||
public function isEnabled();
|
||||
|
||||
}
|
@ -0,0 +1,57 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: Exerosis
|
||||
* Date: 7/6/2015
|
||||
* Time: 1:03 PM
|
||||
*/
|
||||
|
||||
namespace mineplex\plugin\gameengine\game\components\feature;
|
||||
|
||||
|
||||
use mineplex\plugin\gameengine\arenas\Arena;
|
||||
use pocketmine\event\HandlerList;
|
||||
use pocketmine\event\Listener;
|
||||
use pocketmine\plugin\Plugin;
|
||||
use pocketmine\Server;
|
||||
|
||||
class ListenerFeature implements Feature, Listener {
|
||||
|
||||
/** @var bool */
|
||||
private $enabled = false;
|
||||
private $arena;
|
||||
|
||||
function __construct(Arena $arena)
|
||||
{
|
||||
$this->arena = $arena;
|
||||
}
|
||||
|
||||
public function enable()
|
||||
{
|
||||
$this->enabled = true;
|
||||
Server::getInstance()->getPluginManager()->registerEvents($this, $this->getArena()->getPlugin());
|
||||
}
|
||||
|
||||
public function disable()
|
||||
{
|
||||
$this->enabled = false;
|
||||
HandlerList::unregisterAll($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return boolean
|
||||
*/
|
||||
public function isEnabled()
|
||||
{
|
||||
$this->enabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Arena
|
||||
*/
|
||||
public function getArena()
|
||||
{
|
||||
return $this->arena;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: Exerosis
|
||||
* Date: 7/6/2015
|
||||
* Time: 12:55 PM
|
||||
*/
|
||||
|
||||
namespace mineplex\plugin\gameengine\game\components\feature;
|
||||
|
||||
|
||||
class UtilFeature {
|
||||
public static function enable(Feature $feature)
|
||||
{
|
||||
if (!$feature->isEnabled())
|
||||
$feature->enable();
|
||||
}
|
||||
|
||||
public static function disable(Feature $feature)
|
||||
{
|
||||
if ($feature->isEnabled())
|
||||
$feature->disable();
|
||||
}
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: Exerosis
|
||||
* Date: 7/6/2015
|
||||
* Time: 2:38 AM
|
||||
*/
|
||||
|
||||
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\event\player\PlayerDeathEvent;
|
||||
|
||||
class DeathSpectate extends ListenerFeature {
|
||||
|
||||
private $spectateComponent;
|
||||
|
||||
function __construct(Arena $arena, SpectateComponent $spectateComponent)
|
||||
{
|
||||
parent::__construct($arena);
|
||||
$this->spectateComponent = $spectateComponent;
|
||||
}
|
||||
|
||||
/**
|
||||
* @ignoreCancelled true
|
||||
* @param PlayerDeathEvent $event
|
||||
*/
|
||||
function onDeath(PlayerDeathEvent $event)
|
||||
{
|
||||
if (!$this->getArena()->hasPlayer($event->getEntity()))
|
||||
return;
|
||||
|
||||
if ($this->spectateComponent->enableSpectate($event->getEntity()))
|
||||
{
|
||||
//Do death stuff
|
||||
$event->getEntity()->sendTip('§4§lYOU DIED!');
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: TheMineBench
|
||||
* Date: 7/1/2015
|
||||
* Time: 10:20 PM
|
||||
*/
|
||||
|
||||
namespace mineplex\plugin\gameengine\game\components\feature\features;
|
||||
|
||||
use mineplex\plugin\core\commen\ItemContainer;
|
||||
use mineplex\plugin\gameengine\arenas\Arena;
|
||||
use mineplex\plugin\gameengine\game\components\feature\ListenerFeature;
|
||||
use pocketmine\event\block\BlockBreakEvent;
|
||||
|
||||
class NoBlockBreak extends ListenerFeature {
|
||||
|
||||
private $itemContainer;
|
||||
|
||||
/**
|
||||
* @param Arena $arena
|
||||
* @param int[] $ids
|
||||
* @param bool $black
|
||||
*/
|
||||
public function __construct(Arena $arena, array $ids = null, $black = false)
|
||||
{
|
||||
parent::__construct($arena, $ids, $black);
|
||||
$this->itemContainer = new ItemContainer($ids, $black);
|
||||
}
|
||||
|
||||
/**
|
||||
* @ignoreCancelled true
|
||||
* @param BlockBreakEvent $event
|
||||
*/
|
||||
public function onBlockBreak(BlockBreakEvent $event)
|
||||
{
|
||||
if (!$this->getArena()->hasPlayer($event->getPlayer()))
|
||||
return;
|
||||
|
||||
if ($this->itemContainer->hasItem($event->getBlock()->getId()))
|
||||
$event->setCancelled();
|
||||
}
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: TheMineBench
|
||||
* Date: 7/1/2015
|
||||
* Time: 10:20 PM
|
||||
*/
|
||||
|
||||
namespace mineplex\plugin\gameengine\game\components\feature\features;
|
||||
|
||||
use mineplex\plugin\core\commen\ItemContainer;
|
||||
use mineplex\plugin\gameengine\arenas\Arena;
|
||||
use mineplex\plugin\gameengine\game\components\feature\ListenerFeature;
|
||||
use pocketmine\event\block\BlockPlaceEvent;
|
||||
|
||||
class NoBlockPlace extends ListenerFeature {
|
||||
|
||||
private $itemContainer;
|
||||
|
||||
/**
|
||||
* @param Arena $arena
|
||||
* @param int[] $ids
|
||||
* @param bool $black
|
||||
*/
|
||||
public function __construct(Arena $arena, array $ids = null, $black = false)
|
||||
{
|
||||
parent::__construct($arena, $ids, $black);
|
||||
$this->itemContainer = new ItemContainer($ids, $black);
|
||||
}
|
||||
|
||||
/**
|
||||
* @ignoreCancelled true
|
||||
* @param BlockPlaceEvent $event
|
||||
*/
|
||||
public function onPlace(BlockPlaceEvent $event)
|
||||
{
|
||||
if (!$this->getArena()->hasPlayer($event->getPlayer()))
|
||||
return;
|
||||
|
||||
if ($this->itemContainer->hasItem($event->getBlock()->getId()))
|
||||
$event->setCancelled();
|
||||
}
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: TheMineBench
|
||||
* Date: 7/1/2015
|
||||
* Time: 10:20 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\core\commen\ItemContainer;use pocketmine\event\player\PlayerDropItemEvent;
|
||||
|
||||
class NoDropItem extends ListenerFeature {
|
||||
|
||||
private $itemContainer;
|
||||
|
||||
/**
|
||||
* @param Arena $arena
|
||||
* @param int[] $ids
|
||||
* @param bool $black
|
||||
*/
|
||||
public function __construct(Arena $arena, array $ids = null, $black = false)
|
||||
{
|
||||
parent::__construct($arena, $ids, $black);
|
||||
$this->itemContainer = new ItemContainer($ids, $black);
|
||||
}
|
||||
|
||||
/**
|
||||
* @ignoreCancelled true
|
||||
* @param PlayerDropItemEvent $event
|
||||
*/
|
||||
public function onDrop(PlayerDropItemEvent $event)
|
||||
{
|
||||
if (!$this->getArena()->hasPlayer($event->getPlayer()))
|
||||
return;
|
||||
|
||||
if ($this->itemContainer->hasItem($event->getItem()->getId()))
|
||||
$event->setCancelled();
|
||||
}
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: TheMineBench
|
||||
* Date: 7/1/2015
|
||||
* Time: 10:20 PM
|
||||
*/
|
||||
|
||||
namespace mineplex\plugin\gameengine\game\components\feature\features;
|
||||
|
||||
use mineplex\plugin\gameengine\arenas\Arena;
|
||||
use mineplex\plugin\gameengine\game\components\feature\ListenerFeature;
|
||||
use pocketmine\event\player\PlayerMoveEvent;
|
||||
|
||||
class NoMovement extends ListenerFeature {
|
||||
|
||||
public function __construct(Arena $arena)
|
||||
{
|
||||
parent::__construct($arena);
|
||||
}
|
||||
|
||||
/**
|
||||
* @ignoreCancelled true
|
||||
* @param PlayerMoveEvent $event
|
||||
*/
|
||||
public function onMove(PlayerMoveEvent $event)
|
||||
{
|
||||
if (!$this->getArena()->hasPlayer($event->getPlayer()))
|
||||
return;
|
||||
if (($event->getFrom()->getX() == $event->getTo()->getX()) && ($event->getFrom()->getY() == $event->getTo()->getY()) && ($event->getFrom()->getZ() == $event->getTo()->getZ()))
|
||||
return;
|
||||
$event->setCancelled();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,56 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: TheMineBench
|
||||
* Date: 7/1/2015
|
||||
* Time: 10:20 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\core\commen\ItemContainer;
|
||||
use pocketmine\event\inventory\InventoryPickupItemEvent;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\Server;
|
||||
|
||||
class NoPickUpItem extends ListenerFeature {
|
||||
|
||||
private $itemContainer;
|
||||
|
||||
/**
|
||||
* @param Arena $arena
|
||||
* @param int[] $ids
|
||||
* @param bool $black
|
||||
*/
|
||||
public function __construct(Arena $arena, array $ids = null, $black = false)
|
||||
{
|
||||
parent::__construct($arena, $ids, $black);
|
||||
$this->itemContainer = new ItemContainer($ids, $black);
|
||||
}
|
||||
/**
|
||||
* @ignoreCancelled true
|
||||
* @param InventoryPickupItemEvent $event
|
||||
*/
|
||||
public function onPickUp(InventoryPickupItemEvent $event)
|
||||
{
|
||||
if (!$this->getArena()->hasPlayer($event->getInventory()->getHolder())) {
|
||||
Server::getInstance()->broadcastMessage("You're not in the arena!");
|
||||
return;
|
||||
}
|
||||
|
||||
Server::getInstance()->broadcastMessage("Grass: " . Item::GRASS);
|
||||
Server::getInstance()->broadcastMessage("Item: " . $event->getItem()->getItem()->getId());
|
||||
|
||||
if ($this->itemContainer->hasItem($event->getItem()->getItem()->getId())) {
|
||||
$event->setCancelled();
|
||||
Server::getInstance()->broadcastMessage("Stopped!");
|
||||
} else
|
||||
Server::getInstance()->broadcastMessage("Not Stopped!");
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -6,29 +6,31 @@
|
||||
* Time: 12:44 AM
|
||||
*/
|
||||
|
||||
namespace mineplex\plugin\bench\game\components\feature;
|
||||
namespace mineplex\plugin\gameengine\game\components\feature\managers;
|
||||
|
||||
|
||||
use mineplex\plugin\bench\arenas\Arena;
|
||||
use mineplex\plugin\bench\arenas\events\ArenaEndEvent;
|
||||
use mineplex\plugin\bench\game\components\gamestate\events\GameStateChangeEvent;
|
||||
use mineplex\plugin\bench\game\components\gamestate\GameState;
|
||||
use mineplex\plugin\gameengine\arenas\Arena;
|
||||
use mineplex\plugin\gameengine\arenas\events\ArenaEndEvent;
|
||||
use mineplex\plugin\gameengine\game\components\gamestate\events\GameStateChangeEvent;
|
||||
use mineplex\plugin\gameengine\game\components\gamestate\GameState;
|
||||
use mineplex\plugin\util\UtilArray;
|
||||
use pocketmine\event\HandlerList;
|
||||
use pocketmine\event\Listener;
|
||||
use pocketmine\Server;
|
||||
use RecursiveArrayIterator;
|
||||
use RecursiveIteratorIterator;
|
||||
use mineplex\plugin\gameengine\game\components\feature\Feature;
|
||||
|
||||
class GameStateFeatureManager implements Listener {
|
||||
|
||||
private $arena;
|
||||
|
||||
/** @var feature[][] */
|
||||
/** @var Feature[][] */
|
||||
private $features;
|
||||
|
||||
/**
|
||||
* @param Arena $arena
|
||||
* @param feature[][] $features
|
||||
* @param Feature[][] $features
|
||||
*/
|
||||
public function __construct(Arena $arena, array $features)
|
||||
{
|
||||
@ -62,10 +64,10 @@ class GameStateFeatureManager implements Listener {
|
||||
$theseFeatures = [];
|
||||
|
||||
/** @var Feature[] $toEnable */
|
||||
$toEnable = array_udiff($theseFeatures, $lastFeatures, array($this, 'comp'));
|
||||
$toEnable = UtilArray::arrayDiff($theseFeatures, $lastFeatures);
|
||||
|
||||
/** @var Feature[] $toDisable */
|
||||
$toDisable = array_udiff($lastFeatures, $theseFeatures, array($this, 'comp'));
|
||||
$toDisable = UtilArray::arrayDiff($lastFeatures, $theseFeatures);
|
||||
|
||||
foreach ($toDisable as $feature) {
|
||||
if ($feature->isEnabled())
|
||||
@ -82,7 +84,6 @@ class GameStateFeatureManager implements Listener {
|
||||
if ($event->getArena() !== $this->arena)
|
||||
return;
|
||||
|
||||
|
||||
$iterator = new RecursiveIteratorIterator(new RecursiveArrayIterator($this->features));
|
||||
|
||||
foreach ($iterator as $feature) {
|
||||
@ -93,47 +94,6 @@ class GameStateFeatureManager implements Listener {
|
||||
HandlerList::unregisterAll($this);
|
||||
}
|
||||
|
||||
function comp($a,$b)
|
||||
{
|
||||
if ($a===$b)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
return ($a>$b)?1:-1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
* Time: 10:33 AM
|
||||
*/
|
||||
|
||||
namespace mineplex\plugin\bench\game\components\gamestate;
|
||||
namespace mineplex\plugin\gameengine\game\components\gamestate;
|
||||
|
||||
|
||||
//Yes yes I know this is a horrible way of doing things, I'm just trying to get done fast.
|
@ -6,12 +6,12 @@
|
||||
* Time: 10:26 AM
|
||||
*/
|
||||
|
||||
namespace mineplex\plugin\bench\game\components\gamestate;
|
||||
namespace mineplex\plugin\gameengine\game\components\gamestate;
|
||||
|
||||
use mineplex\plugin\bench\arenas\events\ArenaEndEvent;
|
||||
use mineplex\plugin\bench\arenas\events\ArenaStartEvent;
|
||||
use mineplex\plugin\bench\game\components\gamestate\events\GameStateChangeEvent;
|
||||
use mineplex\plugin\bench\arenas\Arena;
|
||||
use mineplex\plugin\gameengine\arenas\events\ArenaEndEvent;
|
||||
use mineplex\plugin\gameengine\arenas\events\ArenaStartEvent;
|
||||
use mineplex\plugin\gameengine\game\components\gamestate\events\GameStateChangeEvent;
|
||||
use mineplex\plugin\gameengine\arenas\Arena;
|
||||
use pocketmine\event\HandlerList;
|
||||
use pocketmine\event\Listener;
|
||||
use pocketmine\Server;
|
||||
@ -75,12 +75,14 @@ class GameStateComponent implements Listener {
|
||||
|
||||
private function localSetState($gameState)
|
||||
{
|
||||
$oldGameState = $this->getGameState();
|
||||
|
||||
$event = new GameStateChangeEvent($this->arena, $this->gameState, $gameState);
|
||||
$this->gameState = $gameState;
|
||||
|
||||
$event = new GameStateChangeEvent($this->arena, $oldGameState, $gameState);
|
||||
|
||||
//Not sure if I should call the event before of after...
|
||||
Server::getInstance()->getPluginManager()->callEvent($event);
|
||||
$this->gameState = $gameState;
|
||||
}
|
||||
|
||||
public function getGameState()
|
@ -6,10 +6,10 @@
|
||||
* Time: 10:49 AM
|
||||
*/
|
||||
|
||||
namespace mineplex\plugin\bench\game\components\gamestate\events;
|
||||
namespace mineplex\plugin\gameengine\game\components\gamestate\events;
|
||||
|
||||
use mineplex\plugin\bench\arenas\ArenaEvent;
|
||||
use mineplex\plugin\bench\arenas\Arena;
|
||||
use mineplex\plugin\gameengine\arenas\ArenaEvent;
|
||||
use mineplex\plugin\gameengine\arenas\Arena;
|
||||
|
||||
class GameStateChangeEvent extends ArenaEvent {
|
||||
|
@ -6,14 +6,14 @@
|
||||
* Time: 11:10 PM
|
||||
*/
|
||||
|
||||
namespace mineplex\plugin\bench\game\components\lobby;
|
||||
namespace mineplex\plugin\gameengine\game\components\lobby;
|
||||
|
||||
|
||||
use mineplex\plugin\bench\arenas\Arena;
|
||||
use mineplex\plugin\bench\arenas\events\ArenaEndEvent;
|
||||
use mineplex\plugin\bench\game\components\feature\Feature;
|
||||
use mineplex\plugin\bench\game\components\gamestate\events\GameStateChangeEvent;
|
||||
use mineplex\plugin\bench\game\components\gamestate\GameState;
|
||||
use mineplex\plugin\gameengine\arenas\Arena;
|
||||
use mineplex\plugin\gameengine\arenas\events\ArenaEndEvent;
|
||||
use mineplex\plugin\gameengine\arenas\events\ArenaJoinEvent;
|
||||
use mineplex\plugin\gameengine\game\components\feature\ListenerFeature;
|
||||
use mineplex\plugin\gameengine\game\components\gamestate\events\GameStateChangeEvent;
|
||||
use mineplex\plugin\gameengine\game\components\gamestate\GameState;
|
||||
use pocketmine\event\block\BlockBreakEvent;
|
||||
use pocketmine\event\entity\EntityDamageEvent;
|
||||
use pocketmine\event\entity\EntityShootBowEvent;
|
||||
@ -21,17 +21,19 @@ use pocketmine\event\HandlerList;
|
||||
use pocketmine\event\inventory\InventoryPickupItemEvent;
|
||||
use pocketmine\event\Listener;
|
||||
use pocketmine\event\player\PlayerDropItemEvent;
|
||||
use pocketmine\Server;
|
||||
use pocketmine\level\Level;
|
||||
use pocketmine\level\Position;
|
||||
use pocketmine\Player;
|
||||
use pocketmine\Server;
|
||||
|
||||
class LobbyComponent implements Listener {
|
||||
|
||||
class LobbyComponent implements Listener
|
||||
{
|
||||
|
||||
/** @var Arena */
|
||||
private $arena;
|
||||
|
||||
/** @var String */
|
||||
private $worldName;
|
||||
public $worldName;
|
||||
|
||||
private $duringLobbyGameState;
|
||||
|
||||
@ -41,7 +43,6 @@ class LobbyComponent implements Listener {
|
||||
*/
|
||||
public function __construct(Arena $arena, $world = null)
|
||||
{
|
||||
|
||||
if ($world == null)
|
||||
$world = Server::getInstance()->getDefaultLevel();
|
||||
|
||||
@ -51,7 +52,7 @@ class LobbyComponent implements Listener {
|
||||
$this->worldName = $world->getName();
|
||||
|
||||
$this->arena = $arena;
|
||||
$this->duringLobbyGameState = new DuringLobbyGameState($arena);
|
||||
$this->duringLobbyGameState = new DuringLobbyGameState($arena, $world);
|
||||
|
||||
Server::getInstance()->getPluginManager()->registerEvents($this, $arena->getPlugin());
|
||||
}
|
||||
@ -63,13 +64,17 @@ class LobbyComponent implements Listener {
|
||||
$event->setCancelled();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @priority LOW
|
||||
* @param GameStateChangeEvent $event
|
||||
*/
|
||||
public function gameStateChange(GameStateChangeEvent $event)
|
||||
{
|
||||
if ($event->getArena() !== $this->arena)
|
||||
return;
|
||||
|
||||
if ($event->getToGameState() == GameState::LOBBY) {
|
||||
if ($event->getToGameState() == GameState::LOBBY)
|
||||
{
|
||||
if (!$this->duringLobbyGameState->isEnabled())
|
||||
{
|
||||
$this->duringLobbyGameState->enable();
|
||||
@ -82,7 +87,6 @@ class LobbyComponent implements Listener {
|
||||
$this->duringLobbyGameState->disable();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function onGameEnd(ArenaEndEvent $event)
|
||||
@ -96,66 +100,97 @@ class LobbyComponent implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
class DuringLobbyGameState implements Feature, Listener {
|
||||
class DuringLobbyGameState extends ListenerFeature
|
||||
{
|
||||
|
||||
private $arena;
|
||||
private $spawn;
|
||||
|
||||
/** @var bool */
|
||||
private $enabled = false;
|
||||
|
||||
public function __construct(Arena $arena)
|
||||
public function __construct(Arena $arena, Level $world)
|
||||
{
|
||||
$this->arena = $arena;
|
||||
parent::__construct($arena);
|
||||
$this->spawn = new Position(0, 103, 0, $world);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @ignoreCancelled true
|
||||
* @param EntityDamageEvent $event
|
||||
*/
|
||||
function onDamage(EntityDamageEvent $event)
|
||||
{
|
||||
if (!in_array($event->getEntity(), $this->arena->getPlayers()))
|
||||
if (!in_array($event->getEntity(), $this->getArena()->getPlayers()))
|
||||
return;
|
||||
|
||||
$event->setCancelled();
|
||||
}
|
||||
|
||||
/**
|
||||
* @ignoreCancelled true
|
||||
* @param PlayerDropItemEvent $event
|
||||
*/
|
||||
function onDrop(PlayerDropItemEvent $event)
|
||||
{
|
||||
if (!in_array($event->getPlayer(), $this->arena->getPlayers()))
|
||||
if (!in_array($event->getPlayer(), $this->getArena()->getPlayers()))
|
||||
return;
|
||||
|
||||
$event->setCancelled();
|
||||
}
|
||||
|
||||
/**
|
||||
* @ignoreCancelled true
|
||||
* @param InventoryPickupItemEvent $event
|
||||
*/
|
||||
function onPickUp(InventoryPickupItemEvent $event)
|
||||
{
|
||||
if (!in_array($event->getInventory()->getHolder(), $this->arena->getPlayers()))
|
||||
if (!in_array($event->getInventory()->getHolder(), $this->getArena()->getPlayers()))
|
||||
return;
|
||||
|
||||
$event->setCancelled();
|
||||
}
|
||||
|
||||
/**
|
||||
* @ignoreCancelled true
|
||||
* @param EntityShootBowEvent $event
|
||||
*/
|
||||
function onBowShoot(EntityShootBowEvent $event)
|
||||
{
|
||||
if (!in_array($event->getEntity(), $this->arena->getPlayers()))
|
||||
if (!in_array($event->getEntity(), $this->getArena()->getPlayers()))
|
||||
return;
|
||||
|
||||
$event->setCancelled();
|
||||
}
|
||||
|
||||
function isEnabled()
|
||||
/**
|
||||
* @ignoreCancelled true
|
||||
* @param ArenaJoinEvent $event
|
||||
*/
|
||||
function onJoin(ArenaJoinEvent $event)
|
||||
{
|
||||
return $this->enabled;
|
||||
if ($this->getArena() !== $event->getArena())
|
||||
return;
|
||||
|
||||
$this->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()
|
||||
{
|
||||
Server::getInstance()->broadcastMessage("Enabled!");
|
||||
$this->enabled = true;
|
||||
Server::getInstance()->getPluginManager()->registerEvents($this, $this->arena->getPlugin());
|
||||
}
|
||||
|
||||
function disable()
|
||||
{
|
||||
Server::getInstance()->broadcastMessage("Disabled!");
|
||||
$this->enabled = false;
|
||||
HandlerList::unregisterAll($this);
|
||||
parent::enable();
|
||||
foreach ($this->getArena()->getPlayers() as $player)
|
||||
{
|
||||
$this->sendToSpawn($player);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: Exerosis
|
||||
* Date: 7/6/2015
|
||||
* Time: 2:06 PM
|
||||
*/
|
||||
|
||||
namespace mineplex\plugin\gameengine\game\components\spawn;
|
||||
|
||||
use pocketmine\level\Position;
|
||||
use pocketmine\Player;
|
||||
|
||||
interface SpawnComponent {
|
||||
|
||||
/**
|
||||
* @param Player $player
|
||||
* @return Position
|
||||
*/
|
||||
function respawn(Player $player);
|
||||
|
||||
}
|
@ -0,0 +1,127 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: Exerosis
|
||||
* Date: 7/6/2015
|
||||
* Time: 12:53 AM
|
||||
*/
|
||||
|
||||
namespace mineplex\plugin\gameengine\game\components\spectate;
|
||||
|
||||
use mineplex\plugin\gameengine\arenas\Arena;
|
||||
use mineplex\plugin\gameengine\arenas\events\ArenaQuitEvent;
|
||||
use mineplex\plugin\gameengine\game\components\spectate\events\DisableSpectateEvent;
|
||||
use mineplex\plugin\gameengine\game\components\spectate\events\EnableSpectateEvent;
|
||||
use mineplex\plugin\util\UtilArray;
|
||||
use pocketmine\event\Listener;
|
||||
use pocketmine\Player;
|
||||
use pocketmine\Server;
|
||||
|
||||
class GameModeSpectateComponent implements SpectateComponent, Listener {
|
||||
|
||||
/** @var Player[] */
|
||||
private $spectators = [];
|
||||
|
||||
private $arena;
|
||||
|
||||
public function __construct(Arena $arena)
|
||||
{
|
||||
$this->arena = $arena;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Player $player
|
||||
* @return bool
|
||||
*/
|
||||
public function enableSpectate(Player $player)
|
||||
{
|
||||
if ($this->isSpectating($player))
|
||||
return false;
|
||||
$event = new EnableSpectateEvent($this->arena, $player);
|
||||
|
||||
Server::getInstance()->getPluginManager()->callEvent($event);
|
||||
|
||||
if ($event->isCancelled())
|
||||
return false;
|
||||
|
||||
$player->getInventory()->clearAll();
|
||||
$player->removeAllEffects();
|
||||
|
||||
$player->setHealth($player->getMaxHealth());
|
||||
$player->resetFallDistance();
|
||||
|
||||
$player->setGamemode(Player::SPECTATOR);
|
||||
array_push($this->spectators, $player);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Player $player
|
||||
* @return bool
|
||||
*/
|
||||
public function disableSpectate(Player $player)
|
||||
{
|
||||
if (!$this->isSpectating($player))
|
||||
return false;
|
||||
$event = new DisableSpectateEvent($this->arena, $player);
|
||||
|
||||
Server::getInstance()->getPluginManager()->callEvent($event);
|
||||
|
||||
if ($event->isCancelled())
|
||||
return false;
|
||||
|
||||
if (($key = array_search($player, $this->spectators, true)) !== FALSE) {
|
||||
unset($this->spectators[$key]);
|
||||
}
|
||||
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.
|
||||
/**
|
||||
* @priority LOW
|
||||
* @param ArenaQuitEvent $event
|
||||
*/
|
||||
public function onQuit(ArenaQuitEvent $event)
|
||||
{
|
||||
if ($this->arena !== $event->getArena())
|
||||
return;
|
||||
|
||||
if (($key = array_search($event->getPlayer(), $this->spectators, true)) !== FALSE) {
|
||||
unset($this->spectators[$key]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Player $player
|
||||
* @return bool
|
||||
*/
|
||||
public function isSpectating(Player $player)
|
||||
{
|
||||
return in_array($player, $this->getSpectators());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Player $player
|
||||
* @return bool
|
||||
*/
|
||||
public function isNotSpectating(Player $player)
|
||||
{
|
||||
return in_array($player, $this->arena->getPlayers()) && !$this->isSpectating($player);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Player[]
|
||||
*/
|
||||
public function getSpectators()
|
||||
{
|
||||
return $this->spectators;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Player[]
|
||||
*/
|
||||
public function getNonSpectators()
|
||||
{
|
||||
return UtilArray::arrayDiff($this->arena->getPlayers(), $this->getSpectators());
|
||||
}
|
||||
}
|
@ -0,0 +1,49 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: Exerosis
|
||||
* Date: 7/5/2015
|
||||
* Time: 11:52 PM
|
||||
*/
|
||||
|
||||
namespace mineplex\plugin\gameengine\game\components\spectate;
|
||||
|
||||
|
||||
use pocketmine\Player;
|
||||
|
||||
interface SpectateComponent {
|
||||
/**
|
||||
* @param Player $player
|
||||
* @return bool
|
||||
*/
|
||||
public function enableSpectate(Player $player);
|
||||
|
||||
/**
|
||||
* @param Player $player
|
||||
* @return bool
|
||||
*/
|
||||
public function disableSpectate(Player $player);
|
||||
|
||||
/**
|
||||
* @param Player $player
|
||||
* @return bool
|
||||
*/
|
||||
public function isSpectating(Player $player);
|
||||
|
||||
/**
|
||||
* @param Player $player
|
||||
* @return bool
|
||||
*/
|
||||
public function isNotSpectating(Player $player);
|
||||
|
||||
/**
|
||||
* @return Player[]
|
||||
*/
|
||||
public function getSpectators();
|
||||
|
||||
/**
|
||||
* @return Player[]
|
||||
*/
|
||||
public function getNonSpectators();
|
||||
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: Exerosis
|
||||
* Date: 7/6/2015
|
||||
* Time: 1:27 AM
|
||||
*/
|
||||
|
||||
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 DisableSpectateEvent extends ArenaEvent implements Cancellable {
|
||||
public static $handlerList = null;
|
||||
|
||||
private $player;
|
||||
|
||||
public function __construct(Arena $arena, Player $player)
|
||||
{
|
||||
parent::__construct($arena);
|
||||
$this->player = $player;
|
||||
}
|
||||
|
||||
public function getPlayer()
|
||||
{
|
||||
return $this->player;
|
||||
}
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: Exerosis
|
||||
* Date: 7/6/2015
|
||||
* Time: 1:27 AM
|
||||
*/
|
||||
|
||||
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;
|
||||
|
||||
public function __construct(Arena $arena, Player $player)
|
||||
{
|
||||
parent::__construct($arena);
|
||||
$this->player = $player;
|
||||
}
|
||||
|
||||
public function getPlayer()
|
||||
{
|
||||
return $this->player;
|
||||
}
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: C
|
||||
* Date: 5/07/2015
|
||||
* Time: 4:00 PM
|
||||
*/
|
||||
|
||||
namespace mineplex\plugin\gameengine\game\components\world;
|
||||
|
||||
|
||||
use pocketmine\scheduler\AsyncTask;
|
||||
|
||||
class AsyncWorldLoader extends AsyncTask
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function onRun()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
@ -6,20 +6,16 @@
|
||||
* Time: 12:27 PM
|
||||
*/
|
||||
|
||||
namespace mineplex\plugin\bench\game\components\world;
|
||||
namespace mineplex\plugin\gameengine\game\components\world;
|
||||
|
||||
use mineplex\plugin\bench\arenas\Arena;
|
||||
use mineplex\plugin\bench\game\components\world\event\WorldLoadFailEvent;
|
||||
use mineplex\plugin\bench\game\components\world\event\WorldLoadSuccessEvent;
|
||||
use mineplex\plugin\gameengine\arenas\Arena;
|
||||
use mineplex\plugin\gameengine\game\components\world\event\WorldLoadFailEvent;
|
||||
use mineplex\plugin\gameengine\game\components\world\event\WorldLoadSuccessEvent;
|
||||
use mineplex\plugin\util\UtilString;
|
||||
use mineplex\plugin\core\updater\UpdateEvent;
|
||||
use mineplex\plugin\core\updater\UpdateType;
|
||||
use pocketmine\event\level\LevelUnloadEvent;
|
||||
use pocketmine\event\player\PlayerJoinEvent;
|
||||
use pocketmine\event\Listener;
|
||||
use pocketmine\level\Position;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\Server;
|
||||
use pocketmine\Player;
|
||||
|
||||
use ZipArchive;
|
||||
use Exception;
|
||||
@ -40,8 +36,7 @@ class WorldComponent implements Listener
|
||||
private $mapData = array();
|
||||
private $mapSettings = array();
|
||||
|
||||
private $posTest = null;
|
||||
private $player = null;
|
||||
private $ready = false;
|
||||
|
||||
public function __construct(Arena $arena)
|
||||
{
|
||||
@ -54,7 +49,7 @@ class WorldComponent implements Listener
|
||||
$this->loadWorld("Super Smash Mobs");
|
||||
}
|
||||
|
||||
//This is just some wierd testiong. Ignore it :P
|
||||
// This is just some wierd testiong. Ignore it :P
|
||||
// public function onJoin(PlayerJoinEvent $event)
|
||||
// {
|
||||
// $this->player = $event->getPlayer();
|
||||
@ -110,6 +105,10 @@ class WorldComponent implements Listener
|
||||
else
|
||||
{
|
||||
print("Error Extracting: " . $this->gameFolder . "\n");
|
||||
|
||||
Server::getInstance()->getPluginManager()->callEvent(new WorldLoadFailEvent($this->arena));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
//Load World
|
||||
@ -117,17 +116,23 @@ class WorldComponent implements Listener
|
||||
{
|
||||
$this->world = $this->arena->getPlugin()->getServer()->getLevelByName($this->gameFolder);
|
||||
|
||||
$this->world->setSpawnLocation(new Vector3(0,200,0));
|
||||
|
||||
$this->loadWorldData();
|
||||
|
||||
$this->ready = true;
|
||||
|
||||
print("Successfully Loaded World: " . $this->gameFolder . "\n");
|
||||
|
||||
Server::getInstance()->getPluginManager()->callEvent(new WorldLoadSuccessEvent($this->arena));
|
||||
Server::getInstance()->getPluginManager()->callEvent(new WorldLoadSuccessEvent($this->arena, $this->world));
|
||||
}
|
||||
else
|
||||
{
|
||||
print("Error Loading World: " . $this->gameFolder . "\n");
|
||||
|
||||
Server::getInstance()->getPluginManager()->callEvent(new WorldLoadFailEvent($this->arena));
|
||||
|
||||
$this->arena->endGame();
|
||||
}
|
||||
}
|
||||
|
||||
@ -271,5 +276,10 @@ class WorldComponent implements Listener
|
||||
{
|
||||
return rand(0, 999999); //Make this acutally unique
|
||||
}
|
||||
|
||||
public function isWorldReady()
|
||||
{
|
||||
return $this->ready;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace mineplex\plugin\gameengine\game\components\world\event;
|
||||
|
||||
use mineplex\plugin\gameengine\arenas\ArenaEvent;
|
||||
use mineplex\plugin\gameengine\arenas\Arena;
|
||||
|
||||
class WorldLoadFailEvent extends ArenaEvent
|
||||
{
|
||||
public static $handlerList = null;
|
||||
|
||||
public function __construct(Arena $arena)
|
||||
{
|
||||
parent::__construct($arena);
|
||||
}
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace mineplex\plugin\gameengine\game\components\world\event;
|
||||
|
||||
use mineplex\plugin\gameengine\arenas\ArenaEvent;
|
||||
use mineplex\plugin\gameengine\arenas\Arena;
|
||||
use pocketmine\level\Level;
|
||||
|
||||
class WorldLoadSuccessEvent extends ArenaEvent
|
||||
{
|
||||
public static $handlerList = null;
|
||||
|
||||
private $level;
|
||||
|
||||
public function __construct(Arena $arena, Level $level)
|
||||
{
|
||||
parent::__construct($arena);
|
||||
$this->level = $level;
|
||||
}
|
||||
|
||||
function getLevel()
|
||||
{
|
||||
return $this->level;
|
||||
}
|
||||
|
||||
}
|
@ -6,9 +6,9 @@
|
||||
* Time: 1:12 PM
|
||||
*/
|
||||
|
||||
namespace mineplex\plugin\bench\game\factory;
|
||||
namespace mineplex\plugin\gameengine\game\factory;
|
||||
|
||||
use mineplex\plugin\bench\game\Game;
|
||||
use mineplex\plugin\gameengine\game\Game;
|
||||
|
||||
interface GameFactory {
|
||||
/**
|
@ -6,10 +6,10 @@
|
||||
* Time: 3:03 PM
|
||||
*/
|
||||
|
||||
namespace mineplex\plugin\bench\game\factory;
|
||||
namespace mineplex\plugin\gameengine\game\factory;
|
||||
|
||||
|
||||
use mineplex\plugin\bench\game\games\sg\SurvivalGames;
|
||||
use mineplex\plugin\gameengine\game\games\sg\SurvivalGames;
|
||||
|
||||
class TestGameFactory implements GameFactory {
|
||||
|
@ -5,17 +5,17 @@
|
||||
* Date: 6/30/2015
|
||||
* Time: 9:18 PM
|
||||
*/
|
||||
namespace mineplex\plugin\bench\game\games\pvp;
|
||||
namespace mineplex\plugin\gameengine\game\games\pvp;
|
||||
|
||||
use mineplex\plugin\bench\game\components\countdown\GameStateCountdown;
|
||||
use mineplex\plugin\bench\game\components\feature\features\NoBlockBreak;
|
||||
use mineplex\plugin\bench\game\components\feature\GameStateFeatureManager;
|
||||
use mineplex\plugin\bench\game\components\gamestate\GameState;
|
||||
use mineplex\plugin\bench\game\components\gamestate\GameStateComponent;
|
||||
use mineplex\plugin\gameengine\game\components\countdown\GameStateCountdown;
|
||||
use mineplex\plugin\gameengine\game\components\feature\features\NoBlockBreak;
|
||||
use mineplex\plugin\gameengine\game\components\feature\GameStateFeatureManager;
|
||||
use mineplex\plugin\gameengine\game\components\gamestate\GameState;
|
||||
use mineplex\plugin\gameengine\game\components\gamestate\GameStateComponent;
|
||||
use pocketmine\event\Listener;
|
||||
use mineplex\plugin\bench\game\Game;
|
||||
use mineplex\plugin\bench\arenas\Arena;
|
||||
use mineplex\plugin\bench\game\components\feature\Feature;
|
||||
use mineplex\plugin\gameengine\game\Game;
|
||||
use mineplex\plugin\gameengine\arenas\Arena;
|
||||
use mineplex\plugin\gameengine\game\components\feature\Feature;
|
||||
use pocketmine\item\Item;
|
||||
|
||||
class Pvp implements Game, Listener {
|
@ -6,16 +6,16 @@
|
||||
* Time: 10:15 PM
|
||||
*/
|
||||
|
||||
namespace mineplex\plugin\bench\game\games\pvp;
|
||||
namespace mineplex\plugin\gameengine\game\games\pvp;
|
||||
|
||||
use pocketmine\event\Listener;
|
||||
use pocketmine\Server;
|
||||
use pocketmine\event\HandlerList;
|
||||
use pocketmine\event\player\PlayerDeathEvent;
|
||||
use mineplex\plugin\bench\arenas\events\ArenaQuitEvent;
|
||||
use mineplex\plugin\bench\arenas\events\ArenaJoinEvent;
|
||||
use mineplex\plugin\bench\arenas\events\ArenaEndEvent;
|
||||
use mineplex\plugin\bench\arenas\Arena;
|
||||
use mineplex\plugin\gameengine\arenas\events\ArenaQuitEvent;
|
||||
use mineplex\plugin\gameengine\arenas\events\ArenaJoinEvent;
|
||||
use mineplex\plugin\gameengine\arenas\events\ArenaEndEvent;
|
||||
use mineplex\plugin\gameengine\arenas\Arena;
|
||||
|
||||
|
||||
|
@ -0,0 +1,69 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: Exerosis
|
||||
* Date: 7/4/2015
|
||||
* Time: 3:09 PM
|
||||
*/
|
||||
|
||||
namespace mineplex\plugin\gameengine\game\games\sg;
|
||||
|
||||
use mineplex\plugin\gameengine\game\components\countdown\GameStateCountdown;
|
||||
use mineplex\plugin\gameengine\game\components\countdown\LobbyCountdown;
|
||||
use mineplex\plugin\gameengine\game\components\feature\features\DeathSpectate;
|
||||
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\NoDropItem;
|
||||
use mineplex\plugin\gameengine\game\components\feature\features\NoPickUpItem;
|
||||
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;
|
||||
use mineplex\plugin\gameengine\game\components\lobby\LobbyComponent;
|
||||
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\arenas\Arena;
|
||||
use mineplex\plugin\gameengine\game\components\feature\Feature;
|
||||
use pocketmine\item\Item;
|
||||
|
||||
class SurvivalGames implements Game {
|
||||
|
||||
function start(Arena $arena)
|
||||
{
|
||||
$gameStateComponent = new GameStateComponent($arena);
|
||||
|
||||
$spectateComponent = new GameModeSpectateComponent($arena);
|
||||
|
||||
//Init features
|
||||
|
||||
$noBlockBreak = new NoBlockBreak($arena, [Item::GRASS]);
|
||||
|
||||
$noBlockPlace = new NoBlockPlace($arena, [Item::WOOD], true);
|
||||
|
||||
$noDropItem = new NoDropItem($arena, [Item::APPLE], true);
|
||||
|
||||
$noPickUpItem = new NoPickUpItem($arena, [Item::GRASS], true);
|
||||
|
||||
/** @var Feature[][] $features */
|
||||
$features = array(
|
||||
GameState::LOBBY => array($noBlockBreak, $noBlockPlace, $noDropItem, $noPickUpItem)
|
||||
);
|
||||
|
||||
|
||||
new GameStateFeatureManager($arena, $features);
|
||||
|
||||
//new LobbyComponent($arena);
|
||||
|
||||
/*
|
||||
$worldComponent = new WorldComponent($arena);
|
||||
|
||||
new LobbyCountdown($arena, $gameStateComponent, $worldComponent, GameState::LOBBY, GameState::PRE_GAME, 50, 1);
|
||||
|
||||
new GameStateCountdown($arena, $gameStateComponent, 10, GameState::PRE_GAME, GameState::GAME);
|
||||
|
||||
new GameStateCountdown($arena, $gameStateComponent, 60, GameState::GAME, GameState::POST_GAME);
|
||||
|
||||
new GameStateCountdown($arena, $gameStateComponent, 10, GameState::POST_GAME, GameState::RESTARTING);
|
||||
*/
|
||||
}
|
||||
}
|
@ -6,7 +6,7 @@
|
||||
* Time: 1:53 PM
|
||||
*/
|
||||
|
||||
namespace mineplex\plugin\bench\time;
|
||||
namespace mineplex\plugin\gameengine\time;
|
||||
|
||||
use pocketmine\scheduler\Task;
|
||||
use pocketmine\Server;
|
||||
@ -62,31 +62,72 @@ class BenchSchedule extends Task
|
||||
|
||||
/**
|
||||
* @param BenchTask $taskToCancel
|
||||
* @return bool
|
||||
*/
|
||||
public static function cancelTask(BenchTask $taskToCancel)
|
||||
{
|
||||
$deleted = false;
|
||||
foreach (self::getInstance()->tasks as $key => $task)
|
||||
{
|
||||
if ($task->getTaskData()->getTask() === $taskToCancel)
|
||||
{
|
||||
unset (self::getInstance()->tasks[$key]);
|
||||
$deleted = true;
|
||||
}
|
||||
}
|
||||
return $deleted;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param BenchTask $taskToCancel
|
||||
* @param $id
|
||||
* @return bool
|
||||
*/
|
||||
public static function cancelTaskWithId(BenchTask $taskToCancel, $id)
|
||||
{
|
||||
$deleted = false;
|
||||
foreach (self::getInstance()->tasks as $key => $task)
|
||||
{
|
||||
if ($task->getTaskData()->getTask() === $taskToCancel && $task->getTaskData()->getId() === $id)
|
||||
{
|
||||
unset (self::getInstance()->tasks[$key]);
|
||||
$deleted = true;
|
||||
}
|
||||
}
|
||||
return $deleted;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param BenchTask $taskToCancel
|
||||
* @return bool
|
||||
*/
|
||||
public static function isRunning(BenchTask $taskToCancel)
|
||||
{
|
||||
foreach (self::getInstance()->tasks as $key => $task)
|
||||
{
|
||||
if ($task->getTaskData()->getTask() === $taskToCancel)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param BenchTask $taskToCancel
|
||||
* @param $id
|
||||
* @return bool
|
||||
*/
|
||||
public static function isRunningWithId(BenchTask $taskToCancel, $id)
|
||||
{
|
||||
foreach (self::getInstance()->tasks as $key => $task)
|
||||
{
|
||||
if ($task->getTaskData()->getTask() === $taskToCancel && $task->getTaskData()->getId() === $id)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
@ -6,7 +6,7 @@
|
||||
* Time: 2:01 PM
|
||||
*/
|
||||
|
||||
namespace mineplex\plugin\bench\time;
|
||||
namespace mineplex\plugin\gameengine\time;
|
||||
|
||||
use SplObjectStorage;
|
||||
|
@ -6,7 +6,7 @@
|
||||
* Time: 2:03 PM
|
||||
*/
|
||||
|
||||
namespace mineplex\plugin\bench\time;
|
||||
namespace mineplex\plugin\gameengine\time;
|
||||
|
||||
|
||||
|
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: Exerosis
|
||||
* Date: 7/6/2015
|
||||
* Time: 1:07 AM
|
||||
*/
|
||||
|
||||
namespace mineplex\plugin\util;
|
||||
|
||||
|
||||
class UtilArray {
|
||||
|
||||
public static function hasKey($key, array $array)
|
||||
{
|
||||
return (isset($array[$key]) || array_key_exists($key, $array));
|
||||
}
|
||||
|
||||
public static function arrayDiff(array $array, array $subtract)
|
||||
{
|
||||
return array_udiff($array, $subtract, ['mineplex\plugin\util\UtilArray', 'comp']);
|
||||
}
|
||||
|
||||
|
||||
static function comp($a,$b)
|
||||
{
|
||||
if ($a===$b)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
return ($a>$b)?1:-1;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user