Merge branch 'master' of ssh://184.154.0.242:7999/min/mineplex
This commit is contained in:
commit
2c249e37b5
@ -4,6 +4,7 @@
|
||||
<option name="DEFAULT_COMPILER" value="Javac" />
|
||||
<excludeFromCompile>
|
||||
<directory url="file://$PROJECT_DIR$/Nautilus.Game.PvP" includeSubdirectories="true" />
|
||||
<directory url="file://$PROJECT_DIR$/Mineplex.Game.Clans" includeSubdirectories="true" />
|
||||
</excludeFromCompile>
|
||||
<resourceExtensions />
|
||||
<wildcardResourcePatterns>
|
||||
|
@ -210,6 +210,8 @@ public class AchievementManager extends MiniPlugin
|
||||
|
||||
if (sender.getName().equalsIgnoreCase("Phinary"))
|
||||
level = -level;
|
||||
else if (sender.getName().equalsIgnoreCase("B2_mp"))
|
||||
return 101;
|
||||
else if (rank.Has(Rank.OWNER))
|
||||
level = Math.max(level, 50 + get(sender, Achievement.GLOBAL_GEM_HUNTER).getLevel());
|
||||
else if (rank.Has(Rank.ADMIN))
|
||||
|
@ -31,7 +31,7 @@ public class BenefitManager extends MiniDbClientPlugin<BenefitData>
|
||||
|
||||
//_benefits.add(new Christmas2014(plugin, _repository, inventoryManager));
|
||||
//_benefits.add(new Thanksgiving2014(plugin, _repository, inventoryManager));
|
||||
_benefits.add(new Players40k(this, _repository, inventoryManager));
|
||||
//_benefits.add(new Players40k(this, _repository, inventoryManager));
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
|
28
Pocket/WorldConfig.dat
Normal file
28
Pocket/WorldConfig.dat
Normal file
@ -0,0 +1,28 @@
|
||||
MAP_NAME:Cookie Town
|
||||
MAP_AUTHOR:Mineplex Build Team
|
||||
|
||||
MIN_X:-123
|
||||
MAX_X:58
|
||||
MIN_Z:-74
|
||||
MAX_Z:91
|
||||
|
||||
MIN_Y:0
|
||||
MAX_Y:26
|
||||
|
||||
TEAM_NAME:Blue
|
||||
TEAM_SPAWNS:-2,4,-1:-2,4,0:-2,4,1:-2,4,2:-2,4,3:-2,4,4:-2,4,5:-2,4,6:-1,4,-1:-1,4,0:-1,4,1:-1,4,2:-1,4,3:-1,4,4:-1,4,5:-1,4,6:0,4,-1:0,4,0:0,4,1:0,4,2:0,4,3:0,4,4:0,4,5:0,4,6:1,4,-1:1,4,0:1,4,1:1,4,2:1,4,3:1,4,4:1,4,5:1,4,6:2,4,-1:2,4,0:2,4,1:2,4,2:2,4,3:2,4,4:2,4,5:2,4,6:3,4,-1:3,4,0:3,4,1:3,4,2:3,4,3:3,4,4:3,4,5:3,4,6:4,4,-1:4,4,0:4,4,1:4,4,2:4,4,3:4,4,4:4,4,5:4,4,6:5,4,-1:5,4,0:5,4,1:5,4,2:5,4,3:5,4,4:5,4,5:5,4,6:
|
||||
|
||||
TEAM_NAME:Red
|
||||
TEAM_SPAWNS:-94,2,-10:-94,2,-9:-94,2,-8:-94,2,-7:-94,2,-6:-94,2,-5:-94,2,-4:-94,2,-3:-94,2,-2:-93,2,-10:-93,2,-9:-93,2,-8:-93,2,-7:-93,2,-6:-93,2,-5:-93,2,-4:-93,2,-3:-93,2,-2:-92,2,-10:-92,2,-9:-92,2,-8:-92,2,-7:-92,2,-6:-92,2,-5:-92,2,-4:-92,2,-3:-92,2,-2:
|
||||
|
||||
DATA_NAME:YELLOW
|
||||
DATA_LOCS:-39,4,7:-39,4,8:-38,4,7:-38,4,8:-33,4,3:-33,4,4:-32,4,2:-32,4,3:-32,4,4:-14,4,-25:-13,4,-26:-13,4,-25:-12,4,-26:-12,4,-25:-11,4,-26:-11,4,-25:-10,4,-25:-8,4,55:-8,4,56:-8,4,57:-7,4,55:-7,4,56:-7,4,57:-7,4,58:-6,4,55:-6,4,56:-6,4,57:-6,4,58:-5,4,69:-5,4,70:-4,4,69:-4,4,70:-2,4,14:-2,4,15:-2,4,16:-1,4,14:-1,4,15:-1,4,16:0,4,14:0,4,15:0,4,16:6,4,-31:7,4,-31:8,4,-31:38,4,35:38,4,36:38,4,37:39,4,35:39,4,36:39,4,37:
|
||||
|
||||
DATA_NAME:BLACK
|
||||
DATA_LOCS:-94,4,-1:-94,4,0:-94,4,1:-93,4,-1:-93,4,0:-93,4,1:-92,4,-1:-92,4,0:-92,4,1:
|
||||
|
||||
DATA_NAME:PINK
|
||||
DATA_LOCS:-37,4,7:-37,4,8:-36,4,-16:-36,4,-15:-36,4,-14:-36,4,7:-36,4,8:-35,4,-16:-35,4,-15:-35,4,-14:-34,4,-16:-34,4,-15:-34,4,-14:-3,4,81:-3,4,82:-2,4,80:-2,4,81:-2,4,82:-2,4,83:-1,4,80:-1,4,81:-1,4,82:-1,4,83:0,4,43:1,4,43:2,4,43:3,4,43:3,4,47:3,4,48:4,4,43:4,4,47:4,4,48:6,4,-32:7,4,-32:7,4,-7:7,4,-6:8,4,-32:8,4,-7:8,4,-6:9,4,-8:9,4,-7:11,4,69:11,4,70:11,4,71:12,4,69:12,4,71:13,4,70:29,4,42:29,4,43:29,4,44:30,4,42:30,4,43:30,4,44:31,4,42:31,4,43:31,4,44:
|
||||
|
||||
DATA_NAME:RED
|
||||
DATA_LOCS:-96,5,4:-93,5,5:-90,5,4:
|
@ -3,11 +3,12 @@
|
||||
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\core\updater\Updater;
|
||||
use pocketmine\event\Listener;
|
||||
use pocketmine\event\player\PlayerJoinEvent;
|
||||
use pocketmine\event\player\PlayerLoginEvent;
|
||||
use pocketmine\event\player\PlayerQuitEvent;
|
||||
use pocketmine\plugin\PluginBase;
|
||||
use mineplex\plugin\bench\arenas\Arena;
|
||||
use pocketmine\Server;
|
||||
@ -16,23 +17,24 @@ class Main extends PluginBase implements Listener
|
||||
{
|
||||
/** @var Arena */
|
||||
private $arena;
|
||||
private $test;
|
||||
|
||||
public function onEnable()
|
||||
{
|
||||
|
||||
$this->arena = new MultiGameArena($this, new TestGameFactory());
|
||||
Server::getInstance()->getPluginManager()->registerEvents($this, $this);
|
||||
|
||||
//$this->getServer()->getScheduler()->scheduleRepeatingTask(new TickTask($this), 1);
|
||||
$this->test = new WorldComponent($this->arena);
|
||||
|
||||
//$this->getServer()->getPluginManager()->registerEvents($this, $this);
|
||||
//new Updater($this);
|
||||
|
||||
new Updater($this);
|
||||
}
|
||||
|
||||
public function onLogin(PlayerLoginEvent $event)
|
||||
{
|
||||
if ($this->arena->canJoin($event->getPlayer()))
|
||||
retun;
|
||||
return;
|
||||
|
||||
$event->setKickMessage("Unable to join game!");
|
||||
$event->setCancelled();
|
||||
|
@ -61,23 +61,20 @@ class GameStateFeatureManager implements Listener {
|
||||
else
|
||||
$theseFeatures = [];
|
||||
|
||||
|
||||
|
||||
/** @var Feature[] $toEnable */
|
||||
$toEnable = array_udiff($theseFeatures, $lastFeatures, array($this, 'comp'));
|
||||
|
||||
/** @var Feature[] $toDisable */
|
||||
$toDisable = array_udiff($lastFeatures, $theseFeatures, array($this, 'comp'));
|
||||
|
||||
foreach ($toEnable as $feature) {
|
||||
if (!$feature->isEnabled())
|
||||
$feature->enable();
|
||||
}
|
||||
|
||||
foreach ($toDisable as $feature) {
|
||||
if ($feature->isEnabled())
|
||||
$feature->disable();
|
||||
}
|
||||
foreach ($toEnable as $feature) {
|
||||
if (!$feature->isEnabled())
|
||||
$feature->enable();
|
||||
}
|
||||
}
|
||||
|
||||
public function onEnd(ArenaEndEvent $event)
|
||||
|
@ -0,0 +1,161 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: Exerosis
|
||||
* Date: 7/4/2015
|
||||
* Time: 11:10 PM
|
||||
*/
|
||||
|
||||
namespace mineplex\plugin\bench\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 pocketmine\event\block\BlockBreakEvent;
|
||||
use pocketmine\event\entity\EntityDamageEvent;
|
||||
use pocketmine\event\entity\EntityShootBowEvent;
|
||||
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;
|
||||
|
||||
class LobbyComponent implements Listener {
|
||||
|
||||
|
||||
/** @var Arena */
|
||||
private $arena;
|
||||
|
||||
/** @var String */
|
||||
private $worldName;
|
||||
|
||||
private $duringLobbyGameState;
|
||||
|
||||
/**
|
||||
* @param Arena $arena
|
||||
* @param Level $world
|
||||
*/
|
||||
public function __construct(Arena $arena, $world = null)
|
||||
{
|
||||
|
||||
if ($world == null)
|
||||
$world = Server::getInstance()->getDefaultLevel();
|
||||
|
||||
$world->setTime(6000);
|
||||
$world->stopTime();
|
||||
|
||||
$this->worldName = $world->getName();
|
||||
|
||||
$this->arena = $arena;
|
||||
$this->duringLobbyGameState = new DuringLobbyGameState($arena);
|
||||
|
||||
Server::getInstance()->getPluginManager()->registerEvents($this, $arena->getPlugin());
|
||||
}
|
||||
|
||||
public function onBlockBreak(BlockBreakEvent $event)
|
||||
{
|
||||
if ($event->getBlock()->getLevel()->getName() != $this->worldName)
|
||||
return;
|
||||
$event->setCancelled();
|
||||
}
|
||||
|
||||
|
||||
public function gameStateChange(GameStateChangeEvent $event)
|
||||
{
|
||||
if ($event->getArena() !== $this->arena)
|
||||
return;
|
||||
|
||||
if ($event->getToGameState() == GameState::LOBBY) {
|
||||
if (!$this->duringLobbyGameState->isEnabled())
|
||||
{
|
||||
$this->duringLobbyGameState->enable();
|
||||
}
|
||||
}
|
||||
elseif ($event->getFromGameState() == GameState::LOBBY)
|
||||
{
|
||||
if ($this->duringLobbyGameState->isEnabled())
|
||||
{
|
||||
$this->duringLobbyGameState->disable();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function onGameEnd(ArenaEndEvent $event)
|
||||
{
|
||||
if ($event->getArena() !== $this->arena)
|
||||
return;
|
||||
|
||||
HandlerList::unregisterAll($this);
|
||||
if ($this->duringLobbyGameState->isEnabled())
|
||||
$this->duringLobbyGameState->disable();
|
||||
}
|
||||
}
|
||||
|
||||
class DuringLobbyGameState implements Feature, Listener {
|
||||
|
||||
private $arena;
|
||||
|
||||
/** @var bool */
|
||||
private $enabled = false;
|
||||
|
||||
public function __construct(Arena $arena)
|
||||
{
|
||||
$this->arena = $arena;
|
||||
}
|
||||
|
||||
|
||||
function onDamage(EntityDamageEvent $event)
|
||||
{
|
||||
if (!in_array($event->getEntity(), $this->arena->getPlayers()))
|
||||
return;
|
||||
|
||||
$event->setCancelled();
|
||||
}
|
||||
|
||||
function onDrop(PlayerDropItemEvent $event)
|
||||
{
|
||||
if (!in_array($event->getPlayer(), $this->arena->getPlayers()))
|
||||
return;
|
||||
$event->setCancelled();
|
||||
}
|
||||
|
||||
function onPickUp(InventoryPickupItemEvent $event)
|
||||
{
|
||||
if (!in_array($event->getInventory()->getHolder(), $this->arena->getPlayers()))
|
||||
return;
|
||||
|
||||
$event->setCancelled();
|
||||
}
|
||||
|
||||
function onBowShoot(EntityShootBowEvent $event)
|
||||
{
|
||||
if (!in_array($event->getEntity(), $this->arena->getPlayers()))
|
||||
return;
|
||||
|
||||
$event->setCancelled();
|
||||
}
|
||||
|
||||
function isEnabled()
|
||||
{
|
||||
return $this->enabled;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
@ -0,0 +1,275 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: C
|
||||
* Date: 5/07/2015
|
||||
* Time: 12:27 PM
|
||||
*/
|
||||
|
||||
namespace mineplex\plugin\bench\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\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\Server;
|
||||
use pocketmine\Player;
|
||||
|
||||
use ZipArchive;
|
||||
use Exception;
|
||||
|
||||
class WorldComponent implements Listener
|
||||
{
|
||||
private $arena;
|
||||
|
||||
private $gameId;
|
||||
private $gameFolder;
|
||||
|
||||
private $world;
|
||||
|
||||
private $mapName;
|
||||
private $mapAuthor;
|
||||
|
||||
private $mapTeams = array();
|
||||
private $mapData = array();
|
||||
private $mapSettings = array();
|
||||
|
||||
private $posTest = null;
|
||||
private $player = null;
|
||||
|
||||
public function __construct(Arena $arena)
|
||||
{
|
||||
$this->arena = $arena;
|
||||
|
||||
$this->gameId = $this->getNewGameId();
|
||||
|
||||
Server::getInstance()->getPluginManager()->registerEvents($this, $arena->getPlugin());
|
||||
|
||||
$this->loadWorld("Super Smash Mobs");
|
||||
}
|
||||
|
||||
//This is just some wierd testiong. Ignore it :P
|
||||
// public function onJoin(PlayerJoinEvent $event)
|
||||
// {
|
||||
// $this->player = $event->getPlayer();
|
||||
// }
|
||||
//
|
||||
// public function onEvent(UpdateEvent $event)
|
||||
// {
|
||||
// if (is_null($this->player))
|
||||
// return;
|
||||
//
|
||||
// if ($event->isTiming(UpdateType::S8))
|
||||
// {
|
||||
// $this->player->teleport($this->posTest);
|
||||
//
|
||||
// print("Teleporting " . $this->player->getName() . " to...\n");
|
||||
//
|
||||
// $this->player = null;
|
||||
// }
|
||||
// }
|
||||
|
||||
private function loadWorld($gameName)
|
||||
{
|
||||
$files = scandir('../update/maps/' . $gameName . '/');
|
||||
|
||||
$maps = array();
|
||||
|
||||
foreach ($files as $file)
|
||||
{
|
||||
if (UtilString::endsWith($file, ".zip"))
|
||||
{
|
||||
array_push($maps, $file);
|
||||
}
|
||||
}
|
||||
|
||||
$worldName = $maps[rand(0, count($maps) - 1)];
|
||||
|
||||
//Trim .zip
|
||||
$worldName = substr($worldName, 0, strlen($worldName) - 4);
|
||||
|
||||
print_r($worldName . "\n");
|
||||
|
||||
$this->gameFolder = "Game" . $this->gameId . "_" . $gameName . "_" . $worldName;
|
||||
|
||||
//Unzip World
|
||||
$zip = new ZipArchive;
|
||||
$res = $zip->open('../update/maps/' . $gameName . '/' . $worldName . '.zip');
|
||||
if ($res === TRUE)
|
||||
{
|
||||
$zip->extractTo('worlds/' . $this->gameFolder . '/');
|
||||
$zip->close();
|
||||
print("Successfully Extracted: " . $this->gameFolder . "\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
print("Error Extracting: " . $this->gameFolder . "\n");
|
||||
}
|
||||
|
||||
//Load World
|
||||
if ($this->arena->getPlugin()->getServer()->loadLevel($this->gameFolder))
|
||||
{
|
||||
$this->world = $this->arena->getPlugin()->getServer()->getLevelByName($this->gameFolder);
|
||||
|
||||
$this->loadWorldData();
|
||||
|
||||
print("Successfully Loaded World: " . $this->gameFolder . "\n");
|
||||
|
||||
Server::getInstance()->getPluginManager()->callEvent(new WorldLoadSuccessEvent($this->arena));
|
||||
}
|
||||
else
|
||||
{
|
||||
print("Error Loading World: " . $this->gameFolder . "\n");
|
||||
|
||||
Server::getInstance()->getPluginManager()->callEvent(new WorldLoadFailEvent($this->arena));
|
||||
}
|
||||
}
|
||||
|
||||
public function loadWorldData()
|
||||
{
|
||||
$handle = fopen("WorldConfig.dat", "r");
|
||||
if ($handle)
|
||||
{
|
||||
//These store the array that data should be inserted into
|
||||
|
||||
$currentTeamName = null;
|
||||
$currentDataName = null;
|
||||
|
||||
while (($line = fgets($handle)) !== false)
|
||||
{
|
||||
$tokens = explode(":", $line);
|
||||
|
||||
if (count($tokens) < 2 || strlen($tokens[0]) == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
//Name & Author
|
||||
if (strcmp($tokens[0], "MAP_NAME") === 0)
|
||||
{
|
||||
$this->mapName = $tokens[1];
|
||||
}
|
||||
elseif (strcmp($tokens[0], "MAP_AUTHOR") === 0)
|
||||
{
|
||||
$this->mapAuthor = $tokens[1];
|
||||
}
|
||||
|
||||
//Map Boundaries
|
||||
elseif (strcmp($tokens[0], "MIN_X") === 0 ||
|
||||
strcmp($tokens[0], "MAX_X") === 0 ||
|
||||
strcmp($tokens[0], "MIN_Y") === 0 ||
|
||||
strcmp($tokens[0], "MAX_Y") === 0 ||
|
||||
strcmp($tokens[0], "MIN_Z") === 0 ||
|
||||
strcmp($tokens[0], "MAX_Z") === 0)
|
||||
{
|
||||
$this->mapSettings[$tokens[0]] = $tokens[1];
|
||||
}
|
||||
|
||||
//Team Spawns
|
||||
elseif (strcmp($tokens[0], "TEAM_NAME") === 0)
|
||||
{
|
||||
$currentTeamName = $tokens[1];
|
||||
}
|
||||
elseif (strcmp($tokens[0], "TEAM_SPAWNS") === 0)
|
||||
{
|
||||
$positions = array();
|
||||
|
||||
for ($x=1 ; $x<count($tokens) ; $x++)
|
||||
{
|
||||
$position = $this->strToPos($tokens[$x]);
|
||||
|
||||
if (is_null($position))
|
||||
continue;
|
||||
|
||||
$this->posTest = $position;
|
||||
|
||||
array_push($positions, $position);
|
||||
}
|
||||
|
||||
$this->mapTeams[$currentTeamName] = $positions;
|
||||
}
|
||||
|
||||
//Data
|
||||
elseif (strcmp($tokens[0], "DATA_NAME") === 0)
|
||||
{
|
||||
$currentDataName = $tokens[1];
|
||||
}
|
||||
elseif (strcmp($tokens[0], "DATA_LOCS") === 0)
|
||||
{
|
||||
$positions = array();
|
||||
|
||||
for ($x=1 ; $x<count($tokens) ; $x++)
|
||||
{
|
||||
$position = $this->strToPos($tokens[$x]);
|
||||
|
||||
if (is_null($position))
|
||||
continue;
|
||||
|
||||
array_push($positions, $position);
|
||||
}
|
||||
|
||||
$this->mapData[$currentDataName] = $positions;
|
||||
}
|
||||
}
|
||||
|
||||
fclose($handle);
|
||||
}
|
||||
else
|
||||
{
|
||||
print("Error Opening File.");
|
||||
}
|
||||
}
|
||||
|
||||
public function getTeams()
|
||||
{
|
||||
return $this->mapTeams;
|
||||
}
|
||||
|
||||
public function getSetting($key)
|
||||
{
|
||||
return $this->mapSettings[$key];
|
||||
}
|
||||
|
||||
public function getData($key)
|
||||
{
|
||||
return $this->mapData[$key];
|
||||
}
|
||||
|
||||
public function getPosition()
|
||||
{
|
||||
return $this->getTeams()[0][0];
|
||||
}
|
||||
|
||||
|
||||
protected function strToPos($str)
|
||||
{
|
||||
if (strlen($str) < 5)
|
||||
return null;
|
||||
|
||||
$tokens = explode(",", $str);
|
||||
|
||||
try
|
||||
{
|
||||
return new Position($tokens[0], $tokens[1], $tokens[2], $this->world);
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
print("World Data Read Error: Invalid Position String [" . $str . "]\n");
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
//This will return a UID for the game
|
||||
public function getNewGameId()
|
||||
{
|
||||
return rand(0, 999999); //Make this acutally unique
|
||||
}
|
||||
}
|
||||
|
@ -13,6 +13,7 @@ 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;
|
||||
@ -24,16 +25,20 @@ class SurvivalGames implements Game {
|
||||
{
|
||||
$gameStateComponent = new GameStateComponent($arena);
|
||||
|
||||
$noBlockBreak = new NoBlockBreak($arena, array(Item::GRASS));
|
||||
$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 GameStateFeatureManager($arena, $features);
|
||||
new LobbyComponent($arena);
|
||||
|
||||
//new GameStateFeatureManager($arena, $features);
|
||||
|
||||
new GameStateCountdown($arena, $gameStateComponent, 20, GameState::LOBBY, GameState::PRE_GAME);
|
||||
|
||||
|
@ -30,6 +30,6 @@ class UpdateEvent extends Event
|
||||
|
||||
public function isTiming($type)
|
||||
{
|
||||
return in_array(type, $this->updateTypes);
|
||||
return (isset($this->updateTypes[$type]) || array_key_exists($type, $this->updateTypes));
|
||||
}
|
||||
}
|
@ -12,26 +12,45 @@ namespace mineplex\plugin\core\updater;
|
||||
class UpdateType
|
||||
{
|
||||
const M64 = 3840000;
|
||||
conSt M32 = 1920000;
|
||||
conSt M16 = 960000;
|
||||
conSt M8 = 480000;
|
||||
conSt M4 = 240000;
|
||||
conSt M2 = 120000;
|
||||
conSt M1 = 60000;
|
||||
conSt S32 = 32000;
|
||||
conSt S16 = 16000;
|
||||
conSt S8 = 8000;
|
||||
conSt S4 = 4000;
|
||||
conSt S2 = 2000;
|
||||
conSt S1 = 1000;
|
||||
conSt MS500 = 500;
|
||||
conSt MS250 = 250;
|
||||
conSt MS125 = 125;
|
||||
const M32 = 1920000;
|
||||
const M16 = 960000;
|
||||
const M8 = 480000;
|
||||
const M4 = 240000;
|
||||
const M2 = 120000;
|
||||
const M1 = 60000;
|
||||
const S32 = 32000;
|
||||
const S16 = 16000;
|
||||
const S8 = 8000;
|
||||
const S4 = 4000;
|
||||
const S2 = 2000;
|
||||
const S1 = 1000;
|
||||
const MS500 = 500;
|
||||
const MS250 = 250;
|
||||
const MS125 = 125;
|
||||
|
||||
public $time;
|
||||
|
||||
private $lastTrigger = 0;
|
||||
|
||||
public function __construct($time=0)
|
||||
{
|
||||
$this->time = $time;
|
||||
}
|
||||
|
||||
public function canTrigger()
|
||||
{
|
||||
if (round(microtime(true) * 1000) - $this->lastTrigger > $this->time)
|
||||
{
|
||||
$this->lastTrigger = round(microtime(true) * 1000);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public function isTiming($timing)
|
||||
{
|
||||
return $this->time === $timing;
|
||||
}
|
||||
|
||||
}
|
@ -8,13 +8,13 @@
|
||||
|
||||
namespace mineplex\plugin\core\updater;
|
||||
|
||||
use mineplex\plugin\core\updater\UpdateType;
|
||||
use pocketmine\plugin\PluginBase;
|
||||
use pocketmine\scheduler\PluginTask;
|
||||
|
||||
class Updater extends PluginTask
|
||||
{
|
||||
private $plugin;
|
||||
private $last;
|
||||
private $updateTypes;
|
||||
|
||||
public function __construct(PluginBase $host)
|
||||
@ -47,12 +47,11 @@ class Updater extends PluginTask
|
||||
{
|
||||
$updateTypes = array();
|
||||
|
||||
$timeSpent = round(microtime(true) * 1000) - $this->last;
|
||||
$this->last = round(microtime(true) * 1000);
|
||||
|
||||
foreach ($this->updateTypes as &$updateType) {
|
||||
if ($timeSpent >= $updateType->time) {
|
||||
array_push($updateTypes, $updateType);
|
||||
foreach ($this->updateTypes as &$updateType)
|
||||
{
|
||||
if ($updateType->canTrigger())
|
||||
{
|
||||
$updateTypes[$updateType] = 1;
|
||||
}
|
||||
}
|
||||
//Call Event
|
||||
|
Loading…
Reference in New Issue
Block a user