public static function getDefaults() { if (self::$default_flags == null) { $flags = array(); foreach (scandir(Factions::getMStorePath() . DIRECTORY_SEPARATOR . "factions_mflag") as $key => $flagRaw) { if (!in_array($flagRaw, array(".", ".."))) { $path = Factions::getMStorePath() . DIRECTORY_SEPARATOR . "factions_mflag" . DIRECTORY_SEPARATOR . $flagRaw; if (is_file($path)) { $flagName = basename($flagRaw, ".json"); $flag = new Flag($flagName); $flags[$flagName] = $flag; } } } self::$default_flags = $flags; } return self::$default_flags; }
public static function getAll() { if (self::$player_cache == null) { $players = array(); if (!Factions::checkMStore(true)) { return $players; } foreach (scandir(Factions::getMStorePath() . DIRECTORY_SEPARATOR . "factions_mplayer") as $key => $playerRaw) { if (!in_array($playerRaw, array(".", ".."))) { $path = Factions::getMStorePath() . DIRECTORY_SEPARATOR . "factions_mplayer" . DIRECTORY_SEPARATOR . $playerRaw; if (is_file($path)) { $playerId = basename($path, ".json"); $player = new Player($playerId); $players[$playerId] = $player; } } } self::$player_cache = $players; } return self::$player_cache; }
function __construct($name, $state = null) { $this->name = $name; if ($state != null) { $this->state = $state; } else { $path = Factions::getMStorePath() . DIRECTORY_SEPARATOR . "factions_mflag" . DIRECTORY_SEPARATOR . $name . ".json"; $rawJSON = json_decode(file_get_contents($path)); if ($rawJSON->standard == "true" || $rawJSON->standard == true || $rawJSON->standard == 1 || $rawJSON->standard == "1") { $this->state == true; } else { $this->state == false; } $this->name = $rawJSON->name; } // Ensure the state value is nice and tidy if ($this->state == 1 || $this->state == true) { $this->state = true; } else { $this->state = false; } }
private function getPathToJSON() { return Factions::getMStorePath() . DIRECTORY_SEPARATOR . "factions_faction" . DIRECTORY_SEPARATOR . $this->id . ".json"; }