コード例 #1
0
ファイル: Flags.php プロジェクト: markehme/factionsphp
 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;
 }
コード例 #2
0
ファイル: Players.php プロジェクト: markehme/factionsphp
 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;
 }
コード例 #3
0
ファイル: Flag.php プロジェクト: markehme/factionsphp
 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;
     }
 }
コード例 #4
0
ファイル: Faction.php プロジェクト: markehme/factionsphp
 private function getPathToJSON()
 {
     return Factions::getMStorePath() . DIRECTORY_SEPARATOR . "factions_faction" . DIRECTORY_SEPARATOR . $this->id . ".json";
 }