public function translateColors($message) { foreach ($this->tntRun->colors as $code => $c) { $message = str_replace($this->tntRun->getConfig()->get("code") . $code, $c, $message); } return $message; }
public function leaveSpectator(Player $player) { $this->arena->getPlayerManager()->removeSpectator($player); if ($player->isOnline()) { $player->sendMessage("You are no longer spectating the arena " . $this->arena->getName()); $this->tntRun->getPlayerData()->restorePlayer($player); } }
public function __construct(Main $tntRun) { $this->tntRun = $tntRun; if (file_exists($tntRun->getDataFolder() . "stats.db")) { $this->db = new \SQLite3($tntRun->getDataFolder() . "stats.db", SQLITE3_OPEN_READWRITE); } else { $this->db = new \SQLite3($tntRun->getDataFolder() . "stats.db", SQLITE3_OPEN_CREATE | SQLITE3_OPEN_READWRITE); } $this->db->exec("CREATE TABLE IF NOT EXISTS tntstats (name TEXT PRIMARY KEY, matches INTEGER, wins INTEGER)"); }
public function translateAndFormat($key, ...$args) { $message = $this->messages->getNested($key, false); if (!$message) { $this->tntRun->getServer()->getLogger()->warning("TntRun translation for " . $key . " not found in messages.yml"); return ""; } foreach ($args as $k => $str) { $message = str_replace("%" . $k, $str, $message); } return $this->translateColors($this->tag . $message); }
public function __construct(Main $tntRun) { $this->tntRun = $tntRun; $settings = $this->tntRun->getConfig()->get("mysql-settings"); $this->db = new \mysqli($settings["host"], $settings["username"], $settings["password"], $settings["database"], isset($settings["port"]) ? $settings["port"] : 3306); if ($this->db->connect_error) { $tntRun->getLogger()->critical("Couldn't connect to MySQL: " . $this->db->connect_error); $tntRun->getServer()->shutdown(); return; } $this->db->query("CREATE TABLE IF NOT EXISTS tntstats (name VARCHAR(16) PRIMARY KEY, matches INT, wins INT)"); $tntRun->getServer()->getScheduler()->scheduleRepeatingTask(new TaskPingMySQL($tntRun), 600); }
public function signCreate(SignChangeEvent $event) { $line = $event->getLines(); $error = []; if (str_replace([" ", "[", "]", "/"], "", strtolower(trim($line[0]))) !== "tntrun") { return; } if (!$event->getPlayer()->hasPermission("tntrun.create")) { $event->setCancelled(); return; } if (!is_numeric($line[2])) { $error[] = "<Number_of_players> is not numeric"; } else { if ($line[2] <= 0) { $error[] = "<Number_of_players> must be greater than 0"; } } if (!is_numeric($line[3])) { $error[] = "<Time> is not numeric"; } else { if ($line[3] <= 0) { $error[] = "<Time> must be greater than 0"; } } if (count($error)) { $this->tntRun->getSign()->newSign($event->getBlock(), ["arena" => trim($line[1]), "direction" => $event->getBlock()->getDamage(), "n_players" => $line[2], "time" => $line[3]]); $event->getPlayer()->sendMessage("[TNTRun] " . TextFormat::DARK_GREEN . "The Sign was created successfully!"); } else { foreach ($error as $e) { $event->getPlayer()->sendMessage("[TNTRun] " . TextFormat::DARK_RED . $e); } $event->setCancelled(); } }
public function startArenaRegen() { $this->arena->getStatusManager()->setRegenerating(); $level = $this->tntRun->getServer()->getLevelByName($this->arena->getStructureManager()->getLevelName()); foreach ($this->arena->getStructureManager()->getFloors() as $floorY) { $this->tntRun->getServer()->getScheduler()->scheduleDelayedTask(new AddfloorTask($this->tntRun, $this->arena->getStructureManager()->getPos1(), $this->arena->getStructureManager()->getPos2(), $floorY, $level), 10); } $this->arena->getStatusManager()->setRegenerating(false); }
public function getSpawn() { return new Position($this->spawn["x"], $this->spawn["y"], $this->spawn["z"], $this->tntRun->getServer()->getLevelByName($this->levelName)); }
public function onRun($currentTick) { $this->tntRun->getStats()->ping(); }
public function __construct(Main $tntRun) { if ($tntRun->getServer()->getPluginManager()->getPlugin("PocketMoney") instanceof Plugin) { $version = explode(".", $tntRun->getServer()->getPluginManager()->getPlugin("PocketMoney")->getDescription()->getVersion()); if ($version[0] < 4) { $tntRun->getLogger()->critical("The version of PocketMoney is too old! Please update PocketMoney to version 4.0.1"); $tntRun->getServer()->shutdown(); } $this->PocketMoney = $tntRun->getServer()->getPluginManager()->getPlugin("PocketMoney"); } elseif ($tntRun->getServer()->getPluginManager()->getPlugin("EconomyAPI") instanceof Plugin) { $version = explode(".", $tntRun->getServer()->getPluginManager()->getPlugin("EconomyAPI")->getDescription()->getVersion()); if ($version[0] < 2) { $tntRun->getLogger()->critical("The version of EconomyAPI is too old! Please update EconomyAPI to version 2.0.8"); $tntRun->getServer()->shutdown(); } $this->EconomyS = $tntRun->getServer()->getPluginManager()->getPlugin("EconomyAPI"); } elseif ($tntRun->getServer()->getPluginManager()->getPlugin("MassiveEconomy") instanceof Plugin) { $this->MassiveEconomy = $tntRun->getServer()->getPluginManager()->getPlugin("MassiveEconomy"); } else { $tntRun->getLogger()->critical("This plugin to work needs the plugin PocketMoney or EconomyS or MassiveEconomy."); $tntRun->getServer()->shutdown(); } }
private function posFromString($pos) { $e = explode(":", $pos); return new Position($e[0], $e[1], $e[2], $this->tntRun->getServer()->getLevelByName(str_replace("%", " ", $e[3]))); }