Bug fixing sequence initiated.
This commit is contained in:
parent
a0a5cfb5ec
commit
42dc29ed27
8 changed files with 109 additions and 66 deletions
9
README.md
Normal file
9
README.md
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
# HideAndSeek
|
||||||
|
The original minigame, free, and better than ever !
|
||||||
|
|
||||||
|
Do you know the hide and seek? It's a game where some people (the hiders) hide themselfs and then the other people (the seekers) go seek them and have to find them in a limited time.
|
||||||
|
This is a recreation of this game for pocketmine !
|
||||||
|
Please note that this is still under development.
|
||||||
|
|
||||||
|
Commands:
|
||||||
|
- /hideandseek <sub command> [parameters]
|
|
@ -13,9 +13,12 @@
|
||||||
name: HideAndSeek
|
name: HideAndSeek
|
||||||
author: Ad5001
|
author: Ad5001
|
||||||
version: 1.0
|
version: 1.0
|
||||||
api: [3.0.0, 3.0.0-ALPHA1]
|
api: [3.0.0, 3.0.0-ALPHA3]
|
||||||
main: Ad5001\HideAndSeek\Main
|
main: Ad5001\HideAndSeek\Main
|
||||||
load: POSTWORLD
|
load: POSTWORLD
|
||||||
commands: []
|
commands:
|
||||||
|
hideandseek:
|
||||||
|
description: Main HideAndSeek management command
|
||||||
|
usage: /hideandseek <sub command> [parameters]
|
||||||
permissions: []
|
permissions: []
|
||||||
...
|
...
|
|
@ -19,5 +19,15 @@
|
||||||
Max players: 16
|
Max players: 16
|
||||||
|
|
||||||
# Seconds to wait between the time 75% of the maximum players have joined and the games starts.
|
# Seconds to wait between the time 75% of the maximum players have joined and the games starts.
|
||||||
Waiting time: 16
|
Waiting time: 60
|
||||||
|
|
||||||
|
# Minutes seekers will have to find to find all the hiders before they win.
|
||||||
|
Seeking time: 3
|
||||||
|
|
||||||
|
# Percentage of the players that will be seekers.
|
||||||
|
Seekers percentage: 10
|
||||||
|
|
||||||
|
# Parameters below are set for every game and are not changable by commands
|
||||||
|
# The world players should be tped to when the game ends.
|
||||||
|
Lobby world: world
|
||||||
...
|
...
|
|
@ -31,8 +31,7 @@ class DataBase extends SQLite3 {
|
||||||
$table = $data["table"];
|
$table = $data["table"];
|
||||||
unset($data["table"]);
|
unset($data["table"]);
|
||||||
$str = $this->buildQueryArgs($data);
|
$str = $this->buildQueryArgs($data);
|
||||||
$result = $this->query("SELECT $dataToGet FROM $table WHERE $str");
|
$result = $this->query("SELECT $dataToGet FROM $table$str");
|
||||||
if($result !== false) $result = $result->fetchArray();
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,7 +46,7 @@ class DataBase extends SQLite3 {
|
||||||
$table = $data["table"];
|
$table = $data["table"];
|
||||||
unset($data["table"]);
|
unset($data["table"]);
|
||||||
$str = $this->buildQueryArgs($data);
|
$str = $this->buildQueryArgs($data);
|
||||||
return $this->query("UPDATE $table SET $key = '$value' WHERE $str");
|
return $this->query("UPDATE $table SET $key = '$value'$str");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -68,7 +67,7 @@ class DataBase extends SQLite3 {
|
||||||
*/
|
*/
|
||||||
public function delete(string $table, array $data) {
|
public function delete(string $table, array $data) {
|
||||||
$str = $this->buildQueryArgs($data);
|
$str = $this->buildQueryArgs($data);
|
||||||
return $this->query("DELETE FROM $table WHERE $str");
|
return $this->query("DELETE FROM $table$str");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -77,9 +76,9 @@ class DataBase extends SQLite3 {
|
||||||
@return string
|
@return string
|
||||||
*/
|
*/
|
||||||
public function buildQueryArgs(array $data) : string {
|
public function buildQueryArgs(array $data) : string {
|
||||||
$str = "";
|
$str = " WHERE ";
|
||||||
foreach($data as $k => $d) $str .= "$k = '$d' AND ";
|
foreach($data as $k => $d) $str .= "$k = '$d' AND ";
|
||||||
return substr($str, 0, strlen($str) - 5);
|
return strlen($str) !== 7 ? substr($str, 0, strlen($str) - 5) : "";
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -88,6 +87,7 @@ class DataBase extends SQLite3 {
|
||||||
@return SQLite3Result|bool
|
@return SQLite3Result|bool
|
||||||
*/
|
*/
|
||||||
public function query($qry) {
|
public function query($qry) {
|
||||||
|
echo $qry . ";;";
|
||||||
$res = parent::query($qry);
|
$res = parent::query($qry);
|
||||||
if($res instanceof \SQLite3Result) self::setNumRows($res);
|
if($res instanceof \SQLite3Result) self::setNumRows($res);
|
||||||
return $res;
|
return $res;
|
||||||
|
|
|
@ -58,10 +58,10 @@ class Game extends PluginTask /* Allows easy game running */ implements Listener
|
||||||
*/
|
*/
|
||||||
public function __construct(Level $level) {
|
public function __construct(Level $level) {
|
||||||
// Initialisation
|
// Initialisation
|
||||||
|
$this->level = $level;
|
||||||
$this->initDB();
|
$this->initDB();
|
||||||
$level->game = $this;
|
$level->game = $this;
|
||||||
$this->setLevel($level);
|
$this->getMain()->getServer()->getPluginManager()->registerEvents($this,$this->getMain());
|
||||||
$this->registerEvents();
|
|
||||||
|
|
||||||
// Registering players
|
// Registering players
|
||||||
foreach($this->getLevel()->getPlayers() as $p) {
|
foreach($this->getLevel()->getPlayers() as $p) {
|
||||||
|
@ -70,7 +70,7 @@ class Game extends PluginTask /* Allows easy game running */ implements Listener
|
||||||
|
|
||||||
// Loading timer.
|
// Loading timer.
|
||||||
parent::__construct($this->getMain());
|
parent::__construct($this->getMain());
|
||||||
$this->getMain()->getServer()->getScheduler()->scheduleRepeatingTask($this, 1);
|
// $this->getMain()->getServer()->getScheduler()->scheduleRepeatingTask($this, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -158,16 +158,17 @@ class Game extends PluginTask /* Allows easy game running */ implements Listener
|
||||||
/*
|
/*
|
||||||
Inits the database for the game.
|
Inits the database for the game.
|
||||||
*/
|
*/
|
||||||
public function initDB() {
|
protected function initDB() {
|
||||||
$qry = $this->getMain()->getDatabase()->get("*", ["table" => "Games", "name" => $this->getName()]);
|
$qry = $this->getMain()->getDatabase()->get("*", ["table" => "Games", "name" => $this->getName()]);
|
||||||
if(is_array($qry)) {
|
if($qry instanceof \SQLite3Result) {
|
||||||
if(count($qry) == 0) { // Game not initiated in the db.
|
if($qry->num_rows == 0) { // Game not initiated in the db.
|
||||||
|
$id = $this->getMain()->getDatabase()->get("*", ["table" => "Games"]);
|
||||||
$v3 = $this->getLevel()->getSafeSpawn();
|
$v3 = $this->getLevel()->getSafeSpawn();
|
||||||
$v3Ser = $v3->x . "," . $v3->y . "," . $v3->z; // V32String
|
$v3Ser = $v3->x . "," . $v3->y . "," . $v3->z; // V32String
|
||||||
$this->getMain()->getDatabase()->insert("Games", [$this->getName(), $v3Ser, $v3Ser, $this->getMain()->getMaxPlayers(), $this->getMain()->getWaitTime(), $this->getMain()->getSeekTime(), $this->getMain()->getSeekersPercentage()]); // Inserting the db with new queries
|
$this->getMain()->getDatabase()->insert("Games", [$this->getName(), $v3Ser, $v3Ser, $this->getMain()->getMaxPlayers(), $this->getMain()->getWaitTime(), $this->getMain()->getSeekTime(), $this->getMain()->getSeekersPercentage(), $id->num_rows]); // Inserting the db with new queries
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new Exception("Could not contact database.");
|
throw new \Exception("Could not contact database.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -346,7 +347,7 @@ class Game extends PluginTask /* Allows easy game running */ implements Listener
|
||||||
*/
|
*/
|
||||||
public function setLevel(Level $level) {
|
public function setLevel(Level $level) {
|
||||||
$this->level = $level;
|
$this->level = $level;
|
||||||
return $this->getMain()->getDatabase()->set("level", $level->getName(), ["table" => "Games", "name" => $this->getName()]);
|
return $this->getMain()->getDatabase()->set("name", $level->getName(), ["table" => "Games", "name" => $this->getName()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -391,8 +392,9 @@ class Game extends PluginTask /* Allows easy game running */ implements Listener
|
||||||
$this->getMain()->getServer()->getPluginManager()->getPlugin("SpectatorPlus")->isSpectator($player))) { // Support for spectator Plus
|
$this->getMain()->getServer()->getPluginManager()->getPlugin("SpectatorPlus")->isSpectator($player))) { // Support for spectator Plus
|
||||||
$this->spectators[$player->getName()] = $player;
|
$this->spectators[$player->getName()] = $player;
|
||||||
$player->HideAndSeekRole = self::ROLE_SPECTATE;
|
$player->HideAndSeekRole = self::ROLE_SPECTATE;
|
||||||
} elseif($this->step == self::STEP_WAIT) {
|
} elseif($this->step == self::STEP_WAIT || $this->step == self::STEP_START) {
|
||||||
// API inside player's class (easilier to get data)
|
// API inside player's class (easilier to get data)
|
||||||
|
$this->sendMessage("§a" . $player->getName() . " joined (" . count($this->players) . "/" . $this->getMaxPlayers() . "). " . (count($this->players) - round($this->getMaxPlayers() * 0.75)) . "players left before starting");
|
||||||
$player->hideAndSeekGame = $this;
|
$player->hideAndSeekGame = $this;
|
||||||
$player->HideAndSeekRole = self::ROLE_WAIT;
|
$player->HideAndSeekRole = self::ROLE_WAIT;
|
||||||
$player->playsHideAndSeek = true;
|
$player->playsHideAndSeek = true;
|
||||||
|
@ -470,9 +472,13 @@ class Game extends PluginTask /* Allows easy game running */ implements Listener
|
||||||
@param $event \pocketmine\event\entity\EntityLevelChangeEvent
|
@param $event \pocketmine\event\entity\EntityLevelChangeEvent
|
||||||
*/
|
*/
|
||||||
public function onEntityLevelChange(\pocketmine\event\entity\EntityLevelChangeEvent $event) {
|
public function onEntityLevelChange(\pocketmine\event\entity\EntityLevelChangeEvent $event) {
|
||||||
if($event->getTarget()->getName() == $this->getName() && $event->getEntity instanceof Player) {
|
if($event->getTarget()->getName() == $this->getName() && $event->getEntity() instanceof Player) {
|
||||||
|
if(count($this->players) >= $this->getMaxPlayers()) {
|
||||||
|
$event->setCancelled();
|
||||||
|
$event->getEntity()->sendMessage(Main::PREFIX . "§cThe maximum number of players in this game has been reached.");
|
||||||
|
}
|
||||||
$this->registerPlayer($event->getEntity());
|
$this->registerPlayer($event->getEntity());
|
||||||
} elseif($event->getOrigin()->getName() == $this->getName() && $event->getEntity instanceof Player) {
|
} elseif($event->getOrigin()->getName() == $this->getName() && $event->getEntity() instanceof Player) {
|
||||||
$this->unregisterPlayer($event->getEntity());
|
$this->unregisterPlayer($event->getEntity());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -482,7 +488,7 @@ class Game extends PluginTask /* Allows easy game running */ implements Listener
|
||||||
@param $event \pocketmine\event\block\BlockBreakEvent
|
@param $event \pocketmine\event\block\BlockBreakEvent
|
||||||
*/
|
*/
|
||||||
public function onBlockBreak(\pocketmine\event\block\BlockBreakEvent $event) {
|
public function onBlockBreak(\pocketmine\event\block\BlockBreakEvent $event) {
|
||||||
if($event->getPlayer()->getLevel() == $this->getName()) {
|
if($event->getLevel()->getLevel() == $this->getName()) {
|
||||||
$event->setCancelled();
|
$event->setCancelled();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -492,7 +498,7 @@ class Game extends PluginTask /* Allows easy game running */ implements Listener
|
||||||
@param $event \pocketmine\event\block\BlockPlaceEvent
|
@param $event \pocketmine\event\block\BlockPlaceEvent
|
||||||
*/
|
*/
|
||||||
public function onBlockPlace(\pocketmine\event\block\BlockPlaceEvent $event) {
|
public function onBlockPlace(\pocketmine\event\block\BlockPlaceEvent $event) {
|
||||||
if($event->getPlayer()->getLevel() == $this->getName()) {
|
if($event->getLevel()->getLevel() == $this->getName()) {
|
||||||
$event->setCancelled();
|
$event->setCancelled();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -516,6 +522,19 @@ class Game extends PluginTask /* Allows easy game running */ implements Listener
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
Checks when a player dies to prevent it.
|
||||||
|
@param $event \pocketmine\event\player\PlayerDeathEvent
|
||||||
|
*/
|
||||||
|
public function onPlayerDeath(\pocketmine\event\player\PlayerDeathEvent $event) {
|
||||||
|
if($event->getPlayer()->getLevel() == $this->getName()) {
|
||||||
|
$event->setCancelled();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Checks when a player joins in the world to make him rejoin automaticly
|
Checks when a player joins in the world to make him rejoin automaticly
|
||||||
@param $event \pocketmine\event\player\PlayerJoinEvent
|
@param $event \pocketmine\event\player\PlayerJoinEvent
|
||||||
|
|
|
@ -141,9 +141,10 @@ class GameManager {
|
||||||
$result = $db->get("*", ["table" => "Games"]);
|
$result = $db->get("*", ["table" => "Games"]);
|
||||||
if($result !== false) {
|
if($result !== false) {
|
||||||
while($row = $result->fetchArray()) {
|
while($row = $result->fetchArray()) {
|
||||||
|
if(is_null($row["name"])) return;
|
||||||
if(is_null($this->gamesName[$row["name"]]) && ($lvl = $this->getMain()->getServer()->getLevelByName($row["name"])) !== null) { // Game doesn't exists && level is loaded
|
if(is_null($this->gamesName[$row["name"]]) && ($lvl = $this->getMain()->getServer()->getLevelByName($row["name"])) !== null) { // Game doesn't exists && level is loaded
|
||||||
$this->games[$row["id"]] = new Game($lvl);
|
$this->games[$row["Id"]] = new Game($lvl);
|
||||||
$this->gamesNames[$row["name"]] = $row["id"];
|
$this->gamesNames[$row["name"]] = $row["Id"];
|
||||||
$this->getMain()->getLogger()->notice("Succefully registered game level {$row['name']}.");
|
$this->getMain()->getLogger()->notice("Succefully registered game level {$row['name']}.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,7 @@ class Main extends PluginBase implements Listener {
|
||||||
//Database setup
|
//Database setup
|
||||||
$this->db = new DataBase($this->getDatafolder() . "base.db");
|
$this->db = new DataBase($this->getDatafolder() . "base.db");
|
||||||
if($this->db->query("PRAGMA table_info(Games);")->num_rows == 0) {
|
if($this->db->query("PRAGMA table_info(Games);")->num_rows == 0) {
|
||||||
$this->db->query(<<<A
|
$this->db->exec(<<<A
|
||||||
CREATE TABLE Games (
|
CREATE TABLE Games (
|
||||||
name VARCHAR( 128 ) NOT NULL,
|
name VARCHAR( 128 ) NOT NULL,
|
||||||
spawnpoint VARCHAR( 128 ) NOT NULL,
|
spawnpoint VARCHAR( 128 ) NOT NULL,
|
||||||
|
@ -44,7 +44,8 @@ CREATE TABLE Games (
|
||||||
max_players INT NOT NULL,
|
max_players INT NOT NULL,
|
||||||
waiting_time INT NOT NULL,
|
waiting_time INT NOT NULL,
|
||||||
seek_time INT NOT NULL,
|
seek_time INT NOT NULL,
|
||||||
seekers_percentage INT NOT NULL
|
seekers_percentage INT NOT NULL,
|
||||||
|
Id INT PRIMARY KEY
|
||||||
)
|
)
|
||||||
A
|
A
|
||||||
);
|
);
|
||||||
|
@ -70,14 +71,14 @@ A
|
||||||
case "creategame":
|
case "creategame":
|
||||||
case "addgame":
|
case "addgame":
|
||||||
if($sender->getLevel()->getName() == $this->getLobbyWorld()->getName()) {
|
if($sender->getLevel()->getName() == $this->getLobbyWorld()->getName()) {
|
||||||
$sender->sendMessage(self::PREFIX . "§4Could not create game ! You're in the lobby level.");
|
$sender->sendMessage(self::PREFIX . "§cCould not create game ! You're in the lobby level.");
|
||||||
return true;
|
return true;
|
||||||
} elseif(!is_null($this->getGameManager()->getGameByLevel($sender->getLevel()))) {
|
} elseif(!is_null($this->getGameManager()->getGameByLevel($sender->getLevel()))) {
|
||||||
$sender->sendMessage(self::PREFIX . "§4This level is already an hide and seek game.");
|
$sender->sendMessage(self::PREFIX . "§cThis level is already an hide and seek game.");
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
$this->getGameManager()[] = new Game($sender->getLevel());
|
$this->getGameManager()->hey = new Game($sender->getLevel()); // Doesn't care 'bout the name set. It customùly sets it.
|
||||||
$sender->sendMessage(self::PREFIX . "§4Succefully created hide and seek game in level {$sender->getLevel()->getName()}.");
|
$sender->sendMessage(self::PREFIX . "§cSuccefully created hide and seek game in level {$sender->getLevel()->getName()}.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -85,11 +86,11 @@ A
|
||||||
case "delgame":
|
case "delgame":
|
||||||
$game = $this->getGameManager()->getGameByLevel($sender->getLevel());
|
$game = $this->getGameManager()->getGameByLevel($sender->getLevel());
|
||||||
if(!is_null($game)) {
|
if(!is_null($game)) {
|
||||||
unset($this->getGameManager()[$sender->getLevel()->getName()]);
|
unset($this->getGameManager()->{$sender->getLevel()->getName()});
|
||||||
$sender->sendMessage(self::PREFIX . "§4Succefully deleted hide and seek game in level {$sender->getLevel()->getName()}.");
|
$sender->sendMessage(self::PREFIX . "§cSuccefully deleted hide and seek game in level {$sender->getLevel()->getName()}.");
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
$sender->sendMessage(self::PREFIX . "§4You're not in an hide and seek game world.");
|
$sender->sendMessage(self::PREFIX . "§cYou're not in an hide and seek game world.");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "setmaxplayers":
|
case "setmaxplayers":
|
||||||
|
@ -98,13 +99,13 @@ A
|
||||||
if(!is_null($game)) {
|
if(!is_null($game)) {
|
||||||
if(isset($args[1]) && is_int($args[1]) && $args[1] > 1) {
|
if(isset($args[1]) && is_int($args[1]) && $args[1] > 1) {
|
||||||
$game->setMaxPlayers($args[1]);
|
$game->setMaxPlayers($args[1]);
|
||||||
$sender->sendMessage(self::PREFIX . "§4Succefully set maximum amount of players of hide and seek game in level {$sender->getLevel()->getName()} to {$args[1]}.");
|
$sender->sendMessage(self::PREFIX . "§cSuccefully set maximum amount of players of hide and seek game in level {$sender->getLevel()->getName()} to {$args[1]}.");
|
||||||
} else {
|
} else {
|
||||||
$sender->sendMessage("§4Usage: /hideandseek setmaxplayers <max amount>");
|
$sender->sendMessage("§cUsage: /hideandseek setmaxplayers <max amount>");
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
$sender->sendMessage(self::PREFIX . "§4You're not in an hide and seek game world.");
|
$sender->sendMessage(self::PREFIX . "§cYou're not in an hide and seek game world.");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "setseekerspercentage":
|
case "setseekerspercentage":
|
||||||
|
@ -113,13 +114,13 @@ A
|
||||||
if(!is_null($game)) {
|
if(!is_null($game)) {
|
||||||
if(isset($args[1]) && is_int($args[1]) && $args[1] > 0 && $args[1] < 100) {
|
if(isset($args[1]) && is_int($args[1]) && $args[1] > 0 && $args[1] < 100) {
|
||||||
$game->setSeekersPercentage($args[1]);
|
$game->setSeekersPercentage($args[1]);
|
||||||
$sender->sendMessage(self::PREFIX . "§4Succefully set seekers percentage of hide and seek game in level {$sender->getLevel()->getName()} to {$args[1]}.");
|
$sender->sendMessage(self::PREFIX . "§cSuccefully set seekers percentage of hide and seek game in level {$sender->getLevel()->getName()} to {$args[1]}.");
|
||||||
} else {
|
} else {
|
||||||
$sender->sendMessage("§4Usage: /hideandseek setseekerspercentage <percentage>");
|
$sender->sendMessage("§cUsage: /hideandseek setseekerspercentage <percentage>");
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
$sender->sendMessage(self::PREFIX . "§4You're not in an hide and seek game world.");
|
$sender->sendMessage(self::PREFIX . "§cYou're not in an hide and seek game world.");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "setwaitingtime":
|
case "setwaitingtime":
|
||||||
|
@ -129,13 +130,13 @@ A
|
||||||
if(!is_null($game)) {
|
if(!is_null($game)) {
|
||||||
if(isset($args[1]) && is_int($args[1]) && $args[1] > 0) {
|
if(isset($args[1]) && is_int($args[1]) && $args[1] > 0) {
|
||||||
$game->setWaitTime($args[1]);
|
$game->setWaitTime($args[1]);
|
||||||
$sender->sendMessage(self::PREFIX . "§4Succefully set waiting time of hide and seek game in level {$sender->getLevel()->getName()} to {$args[1]}.");
|
$sender->sendMessage(self::PREFIX . "§cSuccefully set waiting time of hide and seek game in level {$sender->getLevel()->getName()} to {$args[1]}.");
|
||||||
} else {
|
} else {
|
||||||
$sender->sendMessage("§4Usage: /hideandseek setwaittime <seconds to wait>");
|
$sender->sendMessage("§cUsage: /hideandseek setwaittime <seconds to wait>");
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
$sender->sendMessage(self::PREFIX . "§4You're not in an hide and seek game world.");
|
$sender->sendMessage(self::PREFIX . "§cYou're not in an hide and seek game world.");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "setseektime":
|
case "setseektime":
|
||||||
|
@ -144,13 +145,13 @@ A
|
||||||
if(!is_null($game)) {
|
if(!is_null($game)) {
|
||||||
if(isset($args[1]) && is_int($args[1]) && $args[1] > 0) {
|
if(isset($args[1]) && is_int($args[1]) && $args[1] > 0) {
|
||||||
$game->setSeekTime($args[1]);
|
$game->setSeekTime($args[1]);
|
||||||
$sender->sendMessage(self::PREFIX . "§4Succefully set seeking time of hide and seek game in level {$sender->getLevel()->getName()} to {$args[1]}.");
|
$sender->sendMessage(self::PREFIX . "§cSuccefully set seeking time of hide and seek game in level {$sender->getLevel()->getName()} to {$args[1]}.");
|
||||||
} else {
|
} else {
|
||||||
$sender->sendMessage("§4Usage: /hideandseek setseektime <minutes of seeking>");
|
$sender->sendMessage("§cUsage: /hideandseek setseektime <minutes of seeking>");
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
$sender->sendMessage(self::PREFIX . "§4You're not in an hide and seek game world.");
|
$sender->sendMessage(self::PREFIX . "§cYou're not in an hide and seek game world.");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "setspawn":
|
case "setspawn":
|
||||||
|
@ -158,23 +159,11 @@ A
|
||||||
$pos = new \pocketmine\math\Vector3($sender->x, $sender->y, $sender->z);
|
$pos = new \pocketmine\math\Vector3($sender->x, $sender->y, $sender->z);
|
||||||
$game = $this->getGameManager()->getGameByLevel($sender->getLevel());
|
$game = $this->getGameManager()->getGameByLevel($sender->getLevel());
|
||||||
if(!is_null($game)) {
|
if(!is_null($game)) {
|
||||||
$game->setSpawn($args[1]);
|
$game->setSpawn($pos);
|
||||||
$sender->sendMessage(self::PREFIX . "§4Succefully set spawn of hide and seek game in level {$sender->getLevel()->getName()} to x: $pos->x, y: $pos->y, z: $pos->z.");
|
$sender->sendMessage(self::PREFIX . "§cSuccefully set spawn of hide and seek game in level {$sender->getLevel()->getName()} to x: $pos->x, y: $pos->y, z: $pos->z.");
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
$sender->sendMessage(self::PREFIX . "§4You're not in an hide and seek game world.");
|
$sender->sendMessage(self::PREFIX . "§cYou're not in an hide and seek game world.");
|
||||||
}
|
|
||||||
break;
|
|
||||||
case "setspawn":
|
|
||||||
case "ss":
|
|
||||||
$pos = new \pocketmine\math\Vector3($sender->x, $sender->y, $sender->z);
|
|
||||||
$game = $this->getGameManager()->getGameByLevel($sender->getLevel());
|
|
||||||
if(!is_null($game)) {
|
|
||||||
$game->setSpawn($args[1]);
|
|
||||||
$sender->sendMessage(self::PREFIX . "§4Succefully set spawn of hide and seek game in level {$sender->getLevel()->getName()} to x: $pos->x, y: $pos->y, z: $pos->z.");
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
$sender->sendMessage(self::PREFIX . "§4You're not in an hide and seek game world.");
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "setseekersspawn":
|
case "setseekersspawn":
|
||||||
|
@ -182,13 +171,25 @@ A
|
||||||
$pos = new \pocketmine\math\Vector3($sender->x, $sender->y, $sender->z);
|
$pos = new \pocketmine\math\Vector3($sender->x, $sender->y, $sender->z);
|
||||||
$game = $this->getGameManager()->getGameByLevel($sender->getLevel());
|
$game = $this->getGameManager()->getGameByLevel($sender->getLevel());
|
||||||
if(!is_null($game)) {
|
if(!is_null($game)) {
|
||||||
$game->setSeekersSpawn($args[1]);
|
$game->setSeekersSpawn($pos);
|
||||||
$sender->sendMessage(self::PREFIX . "§4Succefully set seekers spawn of hide and seek game in level {$sender->getLevel()->getName()} to x: $pos->x, y: $pos->y, z: $pos->z.");
|
$sender->sendMessage(self::PREFIX . "§cSuccefully set seekers spawn of hide and seek game in level {$sender->getLevel()->getName()} to x: $pos->x, y: $pos->y, z: $pos->z.");
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
$sender->sendMessage(self::PREFIX . "§4You're not in an hide and seek game world.");
|
$sender->sendMessage(self::PREFIX . "§cYou're not in an hide and seek game world.");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
$sender->sendMessage(str_ireplace(PHP_EOL, PHP_EOL . self::PREFIX,self::PREFIX. "§cSub-command {$args[0]} not found !
|
||||||
|
Possible subcommands:
|
||||||
|
- creategame (or addgame): Creates a hide and seek
|
||||||
|
- deletegame (or delgame): Deletes the hide and seek
|
||||||
|
- setmaxplayers <number of players>(or smp): Sets the maximum number of players
|
||||||
|
- setseekerspercentage <percentage>(or ssp): Sets the percentage of players that will be seekers
|
||||||
|
- setwaittime <seconds to wait>(or swt): Sets the waiting time of players when 75 percents of the maximum players joined and the game starts
|
||||||
|
- setseektime <minutes to seek>(or sst): Sets the time seekers have to find all hiders before hiders wins
|
||||||
|
- setspawn(or ss): Sets the spawn of the place players will wait, hide, and seek
|
||||||
|
- setseekersspawn(or sss): Sets the place where players will be tped to while hiders are hiding
|
||||||
|
Please note that all those subcommands are relative to the world where you execute the command in."));
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
|
@ -279,6 +280,6 @@ A
|
||||||
@param $event \pocketmine\event\level\LevelLoadEvent
|
@param $event \pocketmine\event\level\LevelLoadEvent
|
||||||
*/
|
*/
|
||||||
public function onLevelLoad(\pocketmine\event\level\LevelLoadEvent $event) {
|
public function onLevelLoad(\pocketmine\event\level\LevelLoadEvent $event) {
|
||||||
$this->getGameManager()->refreshRegisterGames();
|
$this->getGameManager()->refreshRegisterGames($this->getDatabase());
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -14,7 +14,7 @@
|
||||||
namespace Ad5001\HideAndSeek\tasks;
|
namespace Ad5001\HideAndSeek\tasks;
|
||||||
|
|
||||||
use pocketmine\Server;
|
use pocketmine\Server;
|
||||||
use pocketmine\schedulerPluginTask;
|
use pocketmine\scheduler\PluginTask;
|
||||||
use pocketmine\Player;
|
use pocketmine\Player;
|
||||||
|
|
||||||
use Ad5001\HideAndSeek\Main;
|
use Ad5001\HideAndSeek\Main;
|
||||||
|
|
Loading…
Reference in a new issue