getAll() публичный Метод

public getAll ( boolean $keys = false ) : array
$keys boolean
Результат array
Пример #1
1
 public function registerPlayer(IPlayer $player, $hash)
 {
     $name = trim(strtolower($player->getName()));
     @mkdir($this->plugin->getDataFolder() . "players/" . $name[0] . "/");
     $data = new Config($this->plugin->getDataFolder() . "players/" . $name[0] . "/{$name}.yml", Config::YAML);
     $data->set("registerdate", time());
     $data->set("logindate", time());
     $data->set("lastip", null);
     $data->set("hash", $hash);
     $data->save();
     return $data->getAll();
 }
Пример #2
0
 public function checkConfig()
 {
     if ($this->version > ConfigUpdater::CONFIG_VERSION) {
         $this->tapToDo->getLogger()->warning("The config loaded is not supported. It may not function correctly. ");
     }
     while ($this->version < ConfigUpdater::CONFIG_VERSION) {
         switch ($this->version) {
             case 0:
                 $this->tapToDo->getLogger()->info("Updating config from version 0 to 1...");
                 $blocks = $this->config->getAll();
                 foreach ($blocks as $id => $block) {
                     foreach ($block["commands"] as $i => $command) {
                         if (strpos($command, "%safe") === false && strpos($command, "%op") === false) {
                             $command .= "%pow";
                         }
                         $block["commands"][$i] = str_replace("%safe", "", $command);
                     }
                     $blocks[$id] = $block;
                 }
                 unlink($this->tapToDo->getDataFolder() . "blocks.yml");
                 $this->tapToDo->saveResource("blocks.yml");
                 $this->config = new Config($this->tapToDo->getDataFolder() . "blocks.yml", Config::YAML);
                 $this->config->set("version", 1);
                 $this->config->set("blocks", $blocks);
                 $this->config->save();
                 $this->version = 1;
                 break;
         }
     }
     return $this->config;
 }
Пример #3
0
 public function onEnable()
 {
     @mkdir($this->getDataFolder());
     $this->initMessage();
     $this->config_File = new Config($this->getDataFolder() . "set-up.yml", Config::YAML, ["enable-snowing" => 1, "enable-sunlight" => 0]);
     $this->config = $this->config_File->getAll();
     $this->pk = new AddEntityPacket();
     $this->pk->type = 81;
     $this->pk->metadata = [Entity::DATA_FLAGS => [Entity::DATA_TYPE_BYTE, 0], Entity::DATA_SHOW_NAMETAG => [Entity::DATA_TYPE_BYTE, 0], Entity::DATA_AIR => [Entity::DATA_TYPE_SHORT, 10]];
     $this->getServer()->getScheduler()->scheduleRepeatingTask(new SnowHalationTask($this), 4);
     new OutEventListener($this);
     $this->getServer()->getPluginManager()->registerEvents($this, $this);
 }
Пример #4
0
 public function getAllZone()
 {
     $data = $this->zonesConfig->getAll(false);
     $zones = [];
     foreach ($data as $id => $value) {
         $level = $this->_plugin->getServer()->getLevelByName($value[2]);
         if ($level == null) {
             continue;
         }
         $pos1 = new Position($value[3][0], $value[3][1], $value[3][2], $level);
         $pos2 = new Position($value[3][3], $value[3][4], $value[3][5], $level);
         $zones[$value[0]] = new Zone($this->_plugin, $value[0], $value[1], $pos1, $pos2, $value[4]);
     }
     return $zones;
 }
Пример #5
0
 /**
  * Save a config section to the plugins' config.yml
  *
  * @param str $key - section to save
  * @param mixed $settings - settings to save
  */
 public function cfgSave($key, $settings)
 {
     $cfg = new Config($this->getDataFolder() . "config.yml", Config::YAML);
     $dat = $cfg->getAll();
     $dat[$key] = $settings;
     $cfg->setAll($dat);
     $cfg->save();
 }
Пример #6
0
 public function reloadSign(Arena $arena)
 {
     foreach ($this->signs->getAll() as $var => $c) {
         if ($c["arena"] === $arena->getName()) {
             $this->spawnSign($this->posFromString($var), $c);
             break;
         }
     }
 }
Пример #7
0
 public function tagExists($tag)
 {
     foreach ($this->shopSign->getAll() as $key => $val) {
         if ($tag == $key) {
             return $val;
         }
     }
     return false;
 }
Пример #8
0
 public function parseMines()
 {
     foreach ($this->mineData->getAll() as $n => $m) {
         if ($m[6] !== false) {
             $this->mines[$n] = new Mine($this, new Vector3(min($m[0], $m[1]), min($m[2], $m[3]), min($m[4], $m[5])), new Vector3(max($m[0], $m[1]), max($m[2], $m[3]), max($m[4], $m[5])), $this->getServer()->getLevelByName($m[7]), $m[6]);
         } else {
             $this->mines[$n] = new Mine($this, new Vector3(min($m[0], $m[1]), min($m[2], $m[3]), min($m[4], $m[5])), new Vector3(max($m[0], $m[1]), max($m[2], $m[3]), max($m[4], $m[5])), $this->getServer()->getLevelByName($m[7]));
         }
     }
 }
Пример #9
0
 public function onEnable()
 {
     // Initializing config files
     $this->saveResource("config.yml");
     $yml = new Config($this->getDataFolder() . "config.yml", Config::YAML);
     $this->yml = $yml->getAll();
     $this->getLogger()->debug("Config files have been saved!");
     $this->getServer()->getPluginManager()->registerEvents($this, $this);
     $this->getServer()->getLogger()->info(Color::BOLD . Color::GOLD . "M" . Color::AQUA . "TeamPvP " . Color::GREEN . "Enabled" . Color::RED . "!");
 }
Пример #10
0
 public function getWord($word)
 {
     if (file_exists($this->getDataFolder() . "denied-words/" . strtolower($word . ".yml"))) {
         $data = new Config($this->getDataFolder() . "denied-words/" . strtolower($word . ".yml"), Config::YAML);
         return $data->getAll();
     } else {
         return false;
         //Word not found
     }
 }
 public function updatePerms()
 {
     foreach ($this->getServer()->getPluginManager()->getPermissions() as $perm) {
         if (!$this->permsConfig->exists($perm->getName(), true)) {
             $this->permsConfig->set(strtolower($perm->getName()), $this->getDefaultIndex($perm->getDefault()));
         }
     }
     $all = $this->permsConfig->getAll();
     asort($all, SORT_FLAG_CASE | SORT_NATURAL);
     $this->permsConfig->setAll($all);
 }
Пример #12
0
 public function onEnable()
 {
     $this->getServer()->getPluginManager()->registerEvents($this, $this);
     if (!file_exists($this->getDataFolder())) {
         @mkdir($this->getDataFolder(), 0755, true);
     }
     $c = new Config($this->getDataFolder() . "country.yml", Config::YAML, array("en" => false, "us" => false, "fr" => false, "cn" => true, "in" => true, "sy" => true, "so" => true, "kr" => true));
     $c->save();
     $this->c = $c->getAll();
     $this->reason = ["en" => "§aYou are not allowed to get in as of your living country", "us" => "§aYou are not allowed to get in as of your living country", "fr" => "§aYou are not allowed to get in as of your living country", "cn" => "§a你因为安全高风险国家的国家,一直踢。", "in" => "§aक्योंकि सुरक्षा के उच्च जोखिम वाले देशों के अपने देश, लात कर दिया गया है", "sy" => "§aكان بلدكم بسبب الدول عالية المخاطر الأمنية، ركلة.", "so" => "§aYour dalka sababtoo ah dalalka khatarta sare ammaanka, ayaa laad", "kr" => "§a당신의 나라는 보안 위험이 높은 국가이기 때문에, kick되었습니다."];
 }
Пример #13
0
 private function fixOldConfig()
 {
     $tempData = $this->config->getAll();
     $version = $this->getDescription()->getVersion();
     $tempData["version"] = $version;
     if (!isset($tempData["default-factions-plugin"])) {
         $tempData["default-factions-plugin"] = null;
     }
     if (isset($tempData["enable-multiworld-support"])) {
         $tempData["enable-multiworld-chat"] = $tempData["enable-multiworld-support"];
         unset($tempData["enable-multiworld-support"]);
     }
     if (isset($tempData["custom-no-fac-message"])) {
         unset($tempData["custom-no-fac-message"]);
     }
     if (isset($tempData["groups"])) {
         foreach ($tempData["groups"] as $groupName => $tempGroupData) {
             if (isset($tempGroupData["default-chat"])) {
                 $tempGroupData["chat"] = $this->fixOldData($tempGroupData["default-chat"]);
                 unset($tempGroupData["default-chat"]);
             } else {
                 $tempGroupData["chat"] = $this->fixOldData($tempGroupData["chat"]);
             }
             if (isset($tempGroupData["default-nametag"])) {
                 $tempGroupData["nametag"] = $this->fixOldData($tempGroupData["default-nametag"]);
                 unset($tempGroupData["default-nametag"]);
             } else {
                 $tempGroupData["nametag"] = $this->fixOldData($tempGroupData["nametag"]);
             }
             if (isset($tempGroupData["worlds"])) {
                 foreach ($tempGroupData["worlds"] as $worldName => $worldData) {
                     if (isset($worldData["default-chat"])) {
                         $worldData["chat"] = $this->fixOldData($worldData["default-chat"]);
                         unset($worldData["default-chat"]);
                     } else {
                         $worldData["chat"] = $this->fixOldData($worldData["chat"]);
                     }
                     if (isset($worldData["default-nametag"])) {
                         $worldData["nametag"] = $this->fixOldData($worldData["default-nametag"]);
                         unset($worldData["default-nametag"]);
                     } else {
                         $worldData["nametag"] = $this->fixOldData($worldData["nametag"]);
                     }
                     $tempGroupData["worlds"][$worldName] = $worldData;
                 }
             }
             $tempData["groups"][$groupName] = $tempGroupData;
         }
     }
     $this->config->setAll($tempData);
     $this->config->save();
     $this->config->reload();
     $this->getLogger()->notice("Upgraded PureChat config.yml to the latest version");
 }
 public function updatePlayer(IPlayer $player, $type)
 {
     $name = strtolower($player->getName());
     if ($this->playerExists($player)) {
         @mkdir($this->plugin->getDataFolder() . "players/" . $name . ".yml");
         $data = new Config($this->plugin->getDataFolder() . "players/" . $name . ".yml");
         $data->set($type, $data->getAll()[$type] + 1);
         return $data->save();
     } else {
         $this->addPlayer($player);
     }
 }
Пример #15
0
 public function preloadPortals()
 {
     $path = $this->plugin->getDataFolder() . MapPortal::DIR_PORTAL_DATA;
     if (!file_exists($path)) {
         @mkdir($path, 0755, true);
     }
     $this->plugin->log("#loading portal " . $path);
     $handler = opendir($path);
     while (($filename = readdir($handler)) !== false) {
         $this->plugin->getLogger()->info($filename);
         if ($filename != "." && $filename != "..") {
             $data = new Config($path . $filename, Config::YAML);
             $data->getAll();
             Server::getInstance()->loadLevel($data->get("levelName"));
             $pLevel = Server::getInstance()->getLevelByName($data->get("levelName"));
             $name = str_replace(".yml", "", $filename);
             $name = $data->get("name");
             $levelName = $data->get("levelName");
             $portal = new MapPortal($this->plugin, $name);
             $portal->levelName = $levelName;
             $portal->displayName = $data->get("displayName");
             $portal->type = $data->get("type");
             if ($data->get("portalEnter1X") != null) {
                 $portal->portalEnterPos1 = new Position($data->get("portalEnter1X"), $data->get("portalEnter1Y"), $data->get("portalEnter1Z"), $pLevel);
             }
             if ($data->get("portalEnter2X") != null) {
                 $portal->portalEnterPos2 = new Position($data->get("portalEnter2X"), $data->get("portalEnter2Y"), $data->get("portalEnter2Z"), $pLevel);
             }
             if ($data->get("entranceX") != null) {
                 $portal->enterpos = new Position($data->get("entranceX"), $data->get("entranceY"), $data->get("entranceZ"));
             }
             if ($data->get("portalExit1X") != null) {
                 $portal->portalExitPos1 = new Position($data->get("portalExit1X"), $data->get("portalExit1Y"), $data->get("portalExit1Z"), $pLevel);
             }
             if ($data->get("portalExit2X") != null) {
                 $portal->portalExitPos2 = new Position($data->get("portalExit2X"), $data->get("portalExit2Y"), $data->get("portalExit2Z"), $pLevel);
             }
             if ($data->get("exitX") != null) {
                 $portal->exitpos = new Position($data->get("exitX"), $data->get("exitY"), $data->get("exitZ"));
             }
             if ($data->get("locationX") != null) {
                 $portal->location = new Position($data->get("locationX"), $data->get("locationY"), $data->get("locationZ"), $pLevel);
             }
             $portal->enterLevelName = $data->get("enterLevelName");
             $portal->exitLevelName = $data->get("exitLevelName");
             $portal->maps = $data->get("maps");
             $this->portals[$name] = $portal;
         }
     }
     closedir($handler);
 }
Пример #16
0
 public function onEnable()
 {
     if (!file_exists($this->getDataFolder())) {
         mkdir($this->getDataFolder());
     }
     $this->airport = array();
     $this->saveResource("language.properties");
     $this->saveResource("airport.yml");
     $this->lang = new Config($this->getDataFolder() . "language.properties", Config::PROPERTIES);
     $this->tag = new Config($this->getDataFolder() . "airport.yml", Config::YAML);
     $airportYml = new Config($this->getDataFolder() . "AirportData.yml", Config::YAML);
     $this->airport = $airportYml->getAll();
     $this->getServer()->getPluginManager()->registerEvents($this, $this);
 }
Пример #17
0
 public function load()
 {
     foreach ($this->config->getAll() as $chestData) {
         $level = $this->main->getServer()->getLevelByName($chestData["levelName"]);
         if ($level instanceof Level) {
             $chest = new Chest(new Position($chestData["x"], $chestData["y"], $chestData["z"], $level));
             $chestTile = $chest->getChest();
             if ($chestTile instanceof \pocketmine\tile\Chest) {
                 $pattern = $this->main->getPatternStore()->makePattern($chestData["patternName"], $chestData["patternArgs"]);
                 if ($pattern instanceof ChestPattern) {
                     $chest->setPattern($pattern);
                     $this->chests[] = $chest;
                 } else {
                     $this->main->getLogger()->warning("Failed to load a chest: Pattern data invalid.");
                 }
             } else {
                 $this->main->getLogger()->warning("Failed to load a chest: No chest at position.");
             }
         } else {
             $this->main->getLogger()->warning("Failed to load a chest: Level is not loaded.");
         }
     }
 }
Пример #18
0
 /**
  * @param bool $inArray
  * @return array|string
  */
 public function kitList($inArray = false)
 {
     $kits = ["Normal kits" => [], "Donator kits" => []];
     foreach ($this->kits->getAll() as $key => $values) {
         if ($values["Donator"]) {
             $kits["Donator kits"][] = $key;
         } else {
             $kits["Normal kits"][] = $key;
         }
     }
     if (!$inArray) {
         $k = "[KitPro] Available kits:\n - Normal kits:";
         $d = "\n - Donator kits:";
         foreach ($kits as $type => $list) {
             if ($type === "Normal kits") {
                 $k .= implode("\n  * ", $list);
             } else {
                 $d .= implode("\n  * ", $list);
             }
         }
         $kits = $k . $d;
     }
     return $kits;
 }
Пример #19
0
 private function infoJob($username, $job)
 {
     foreach ($this->joblist->getAll(true) as $aJob) {
         if ($aJob === $job) {
             $info = $this->joblist->get($job);
             foreach ($info as $type => $detail) {
                 foreach ($detail as $value) {
                     $id = $value['ID'];
                     $meta = $value['meta'];
                     $amount = $value['amount'];
                     $this->getServer()->getPlayer($username)->sendMessage("{$type} {$id}:{$meta} {$amount}");
                 }
             }
         }
     }
 }
Пример #20
0
 public function __construct()
 {
     // load recipes from src/pocketmine/recipes.json
     $recipes = new Config(Server::getInstance()->getFilePath() . "src/pocketmine/resources/recipes.json", Config::JSON, []);
     MainLogger::getLogger()->info("Loading recipes...");
     foreach ($recipes->getAll() as $recipe) {
         switch ($recipe["Type"]) {
             case 0:
                 // TODO: handle multiple result items
                 if (count($recipe["Result"]) == 1) {
                     $first = $recipe["Result"][0];
                     $result = new ShapelessRecipe(Item::get($first["ID"], $first["Damage"], $first["Count"]));
                     foreach ($recipe["Ingredients"] as $ingredient) {
                         $result->addIngredient(Item::get($ingredient["ID"], $ingredient["Damage"], $ingredient["Count"]));
                     }
                     $this->registerRecipe($result);
                 }
                 break;
             case 1:
                 // TODO: handle multiple result items
                 if (count($recipe["Result"]) == 1) {
                     $first = $recipe["Result"][0];
                     $result = new ShapedRecipe(Item::get($first["ID"], $first["Damage"], $first["Count"]), $recipe["Height"], $recipe["Width"]);
                     $shape = array_chunk($recipe["Ingredients"], $recipe["Width"]);
                     foreach ($shape as $y => $row) {
                         foreach ($row as $x => $ingredient) {
                             $result->addIngredient($x, $y, Item::get($ingredient["ID"], $ingredient["Damage"] < 0 ? null : $ingredient["Damage"], $ingredient["Count"]));
                         }
                     }
                     $this->registerRecipe($result);
                 }
                 break;
             case 2:
                 $result = $recipe["Result"];
                 $resultItem = Item::get($result["ID"], $result["Damage"], $result["Count"]);
                 $this->registerRecipe(new FurnaceRecipe($resultItem, Item::get($recipe["Ingredients"], 0, 1)));
                 break;
             case 3:
                 $result = $recipe["Result"];
                 $resultItem = Item::get($result["ID"], $result["Damage"], $result["Count"]);
                 $this->registerRecipe(new FurnaceRecipe($resultItem, Item::get($recipe["Ingredients"]["ID"], $recipe["Ingredients"]["Damage"], 1)));
                 break;
             default:
                 break;
         }
     }
 }
Пример #21
0
 public function onEnable()
 {
     // Initializing config files
     $this->saveResource("config.yml");
     $yml = new Config($this->getDataFolder() . "config.yml", Config::YAML);
     $this->yml = $yml->getAll();
     $this->getLogger()->debug("Config files have been saved!");
     $level = $this->yml["sign_world"];
     if (!$this->getServer()->isLevelGenerated($level)) {
         $this->getLogger()->error("The level you used on the config ( " . $level . " ) doesn't exist! stopping plugin...");
         $this->getServer()->getPluginManager()->disablePlugin($this->getServer()->getPluginManager()->getPlugin("MTeamPvP"));
     }
     if (!$this->getServer()->isLevelLoaded($level)) {
         $this->getServer()->loadLevel($level);
     }
     $this->getServer()->getScheduler()->scheduleRepeatingTask(new Tasks\SignUpdaterTask($this), 15);
     $this->getServer()->getPluginManager()->registerEvents($this, $this);
     $this->getServer()->getLogger()->info(Color::BOLD . Color::GOLD . "M" . Color::AQUA . "TeamPvP " . Color::GREEN . "Enabled" . Color::RED . "!");
 }
Пример #22
0
 public function onCommand(CommandSender $sender, Command $command, $label, array $args)
 {
     switch ($command->getName()) {
         case "alias":
             if (!isset($args[0])) {
                 $sender->sendMessage(TextFormat::RED . "Usage: " . $command->getUsage() . "");
                 return true;
             }
             $name = strtolower($args[0]);
             $player = $this->getServer()->getPlayer($name);
             if ($player instanceof Player) {
                 $ip = $player->getPlayer()->getAddress();
                 $file = new Config($this->getDataFolder() . "players/ip/" . $ip[0] . "/" . $ip . ".txt");
                 $names = $file->getAll(true);
                 $names = implode(', ', $names);
                 $sender->sendMessage(TextFormat::GREEN . "[Alias] Showing alias of " . $name . "...");
                 $sender->sendMessage(TextFormat::BLUE . "[Alias] " . $names . "");
                 return true;
             } else {
                 if (!is_file($this->getDataFolder() . "players/lastip/" . $name[0] . "/" . $name . ".yml")) {
                     $sender->sendMessage(TextFormat::YELLOW . "[Alias] Error: Player does not exist!");
                     return true;
                 } else {
                     $lastip = new Config($this->getDataFolder() . "players/lastip/" . $name[0] . "/" . $name . ".yml");
                     $ip = $lastip->get("lastip");
                     $file = new Config($this->getDataFolder() . "players/ip/" . $ip[0] . "/" . $ip . ".txt");
                     $names = $file->getAll(true);
                     if ($names == null) {
                         $sender->sendMessage(TextFormat::YELLOW . "[Alias] Error: Player does not exist!");
                         break;
                     } else {
                         $names = implode(', ', $names);
                         $sender->sendMessage(TextFormat::GREEN . "[Alias] Showing alias of " . $name . "...");
                         $sender->sendMessage(TextFormat::BLUE . "[Alias] " . $names . "");
                         return true;
                     }
                 }
             }
             return true;
     }
 }
Пример #23
0
 public function registerResidences()
 {
     $path = $this->getDataFolder() . "worlds/";
     foreach (array_diff(scandir($path), [".", ".."]) as $dir) {
         if (is_dir($path . $dir)) {
             $level = $dir;
             foreach (glob($path . $dir . "*.yml") as $file) {
                 $cfg = new Config($file);
                 $data = $cfg->getAll();
                 if (count($data) < 8) {
                     continue;
                 }
                 if (!(isset($data["Name"]) && isset($data["Owner"]) && isset($data["PlayerFlags"]) && isset($data["AreaFlags"]) && isset($data["EnterMessage"]) && isset($data["LeaveMessage"]))) {
                     continue;
                 }
                 if (!(isset($data["Pos1"]["X"]) && is_numeric($data["Pos1"]["X"]) && isset($data["Pos1"]["Y"]) && is_numeric($data["Pos1"]["Z"]) && isset($data["Pos2"]["X"]) && is_numeric($data["Pos2"]["X"]) && isset($data["Pos2"]["Y"]) && is_numeric($data["Pos2"]["Y"]) && isset($data["Pos2"]["Z"]) && is_numeric($data["Pos1"]["X"]))) {
                     continue;
                 }
                 $this->areas[$data["Name"]] = new Area($data, $level);
             }
         }
     }
 }
Пример #24
0
 public function onEnable()
 {
     @mkdir($this->getDataFolder());
     $this->dispensers = (new Config($this->getDataFolder() . "dispensers.yml", Config::YAML))->getAll();
     $this->useOld = (new \ReflectionClass(Item::class))->hasMethod("isPlaceable");
     if (!file_exists($this->getDataFolder() . "translation_en.yml")) {
         (new Config($this->getDataFolder() . "translation_en.yml", Config::YAML, yaml_parse(stream_get_contents($resource = $this->getResource("translation_en.yml")))))->save();
         @fclose($resource);
         $this->getLogger()->info(TextFormat::YELLOW . "Extracted translation_en.yml!");
     }
     if (!file_exists($this->getDataFolder() . "translation_ko.yml")) {
         (new Config($this->getDataFolder() . "translation_ko.yml", Config::YAML, yaml_parse(stream_get_contents($resource = $this->getResource("translation_ko.yml")))))->save();
         @fclose($resource);
         $this->getLogger()->info(TextFormat::YELLOW . "Extracted translation_ko.yml!");
     }
     if (!file_exists($this->getDataFolder() . "config.yml")) {
         $prefs = new Config($this->getDataFolder() . "config.yml", Config::YAML, yaml_parse(stream_get_contents($resource = $this->getResource("config.yml"))));
         $prefs->save();
         $config = $prefs->getAll();
         @fclose($resource);
         $this->getLogger()->info(TextFormat::YELLOW . "Extracted config.yml!");
     } else {
         $config = (new Config($this->getDataFolder() . "config.yml", Config::YAML))->getAll();
     }
     $language = "en";
     if (isset($config["language"])) {
         $language = $config["language"];
     }
     $this->translations = (new Config($this->getDataFolder() . "translation_{$language}.yml", Config::YAML))->getAll();
     $autoSaveTerm = EconomyAPI::getInstance()->getConfigurationValue("auto-save-interval");
     if ($autoSaveTerm !== false) {
         $this->getServer()->getScheduler()->scheduleRepeatingTask(new TaskAutoSave($this), 20 * 60 * $autoSaveTerm);
     }
     $this->getServer()->getPluginManager()->registerEvents($this, $this);
     $this->doubleTap = array();
     $this->itemPlaceList = array();
 }
Пример #25
0
 public function onEnable()
 {
     @mkdir($this->getDataFolder());
     if (self::$instance == null) {
         self::$instance = $this;
     }
     $this->initMessage();
     $this->messagesUpdate();
     $this->config = new Config($this->getDataFolder() . "settings.yml", Config::YAML, ["default-home-size" => 20, "maximum-home-limit" => 1, "show-prevent-message" => true, "show-opland-message" => true, "economy-enable" => true, "economy-home-price" => 5000, "economy-home-reward-price" => 2500, "hour-tax-price" => 4, "default-prefix" => $this->get("default-prefix"), "welcome-prefix" => $this->get("welcome-prefix"), "default-wall-type" => 139, "enable-setarea" => true]);
     $this->config_Data = $this->config->getAll();
     $signTemplate = new Config($this->getDataFolder() . "signTemplate.yml", Config::YAML, ["signTemplate" => ["0" => "----------", "1" => "X", "2" => "ECONOMY LAND", "3" => "----------"]]);
     $this->signTemplate = $signTemplate->getAll();
     foreach ($this->getServer()->getLevels() as $level) {
         $this->db[$level->getFolderName()] = new SimpleArea_Database($this->getServer()->getDataPath() . "worlds/" . $level->getFolderName() . "/", $level, $this->config_Data["default-wall-type"]);
     }
     $this->getServer()->getScheduler()->scheduleRepeatingTask(new AutoSaveTask($this), 2400);
     $this->getServer()->getScheduler()->scheduleRepeatingTask(new HourTaxCheckTask($this), 7200);
     $this->registerCommand($this->get("commands-area"), "simplearea.commands.area", $this->get("commands-area-desc"));
     $this->registerCommand($this->get("commands-setarea"), "simplearea.commands.setarea", $this->get("commands-setarea-desc"));
     $this->registerCommand($this->get("commands-sellarea"), "simplearea.commands.sellarea", $this->get("commands-sellarea-desc"));
     $this->registerCommand($this->get("commands-givearea"), "simplearea.commands.givearea", $this->get("commands-givearea-desc"));
     $this->registerCommand($this->get("commands-buyarea"), "simplearea.commands.buyarea", $this->get("commands-buyarea-desc"));
     $this->registerCommand($this->get("commands-arealist"), "simplearea.commands.arealist", $this->get("commands-arealist-desc"));
     $this->registerCommand($this->get("commands-rent"), "simplearea.commands.rent", $this->get("commands-rent-desc"));
     $this->registerCommand($this->get("commands-invite"), "simplearea.commands.invite", $this->get("commands-invite-desc"));
     $this->registerCommand($this->get("commands-inviteout"), "simplearea.commands.inviteout", $this->get("commands-inviteout-desc"));
     $this->registerCommand($this->get("commands-inviteclear"), "simplearea.commands.inviteclear", $this->get("commands-inviteclear-desc"));
     $this->registerCommand($this->get("commands-invitelist"), "simplearea.commands.invitelist", $this->get("commands-invitelist-desc"));
     $this->registerCommand($this->get("commands-welcome"), "simplearea.commands.welcome", $this->get("commands-welcome-desc"));
     $this->registerCommand($this->get("commands-simplearea"), "simplearea.commands.simplearea", $this->get("commands-simplearea-desc"));
     $this->registerCommand($this->get("commands-sa-yap"), "simplearea.commands.yap", $this->get("commands-yap-desc"));
     if ($this->checkEconomyAPI()) {
         $this->economyAPI = \onebone\economyapi\EconomyAPI::getInstance();
     }
     $this->getServer()->getPluginManager()->registerEvents($this, $this);
 }
Пример #26
0
 public function onEnable()
 {
     //Initializing config files
     $this->saveResource("config.yml");
     //To-Do $this->saveResource("Items.yml");
     //To-Do $this->saveResource("rewards.yml");
     //To-Do $items = new Config($this->getDataFolder() . "Items.yml", Config::YAML);
     //To-Do $this->items = $items->getAll();
     //To-Do $rewards = new Config($this->getDataFolder() . "rewards.yml", Config::YAML);
     //To-Do $this->rewards = $rewards->getAll();
     $yml = new Config($this->getDataFolder() . "config.yml", Config::YAML);
     $this->yml = $yml->getAll();
     $this->getLogger()->debug("Config files have been saved!");
     $this->getServer()->getPluginManager()->registerEvents($this, $this);
     $level = $this->yml["spleef-world"];
     if (!$this->getServer()->isLevelGenerated($level)) {
         $this->getLogger()->error("The level you used on the config ( " . $level . " ) doesn't exist! stopping plugin...");
         $this->getServer()->getPluginManager()->disablePlugin($this->getServer()->getPluginManager()->getPlugin("MSpleef"));
     }
     if (!$this->getServer()->isLevelLoaded($level)) {
         $this->getServer()->loadLevel($level);
     }
     $this->getServer()->getLogger()->info(Color::BOLD . Color::GOLD . "M" . Color::AQUA . "Spleef " . Color::GREEN . "Enabled" . Color::RED . "!");
 }
 /**
  * Load Languages
  */
 public function loadLanguageMessages()
 {
     if (!file_exists($this->getPlugin()->getDataFolder())) {
         @mkdir($this->getDataFolder(), 0777, true);
         file_put_contents($this->getDataFolder() . "config.yml", $this->getResource("config.yml"));
     }
     $this->getPlugin()->saveDefaultConfig();
     // retrieve language setting
     $configlang = $this->getSetup()->getMessageLanguage();
     $messageFile = $this->getPlugin()->getDataFolder() . "messages_" . $configlang . ".yml";
     $this->getPlugin()->getLogger()->info("CTF Message Language = " . $messageFile);
     if (!file_exists($messageFile)) {
         $this->getPlugin()->getLogger()->info("Game Messages Default to EN");
         file_put_contents($this->getPlugin()->getDataFolder() . "messages_EN.yml", $this->getPlugin()->getResource("messages_EN.yml"));
         $msgConfig = new Config($this->getPlugin()->getDataFolder() . "messages_EN.yml");
         $messages = $msgConfig->getAll();
         $this->messages = $this->parseMessages($messages);
         // $this->getPlugin ()->getLogger ()->info ( "Warning!, specify configuration language not found!, fall back to use English" );
     } else {
         $this->getPlugin()->getLogger()->info("use existing");
         $messages = (new Config($messageFile))->getAll();
         $this->messages = $this->parseMessages($messages);
     }
 }
Пример #28
0
 public function onEnable()
 {
     @mkdir($this->getDataFolder());
     $this->createConfig();
     $this->scanResources();
     file_put_contents($this->getDataFolder() . "ReadMe.txt", $this->readResource("ReadMe.txt"));
     if (!is_file($this->getDataFolder() . "PlayerLang.dat")) {
         file_put_contents($this->getDataFolder() . "PlayerLang.dat", serialize([]));
     }
     $this->playerLang = unserialize(file_get_contents($this->getDataFolder() . "PlayerLang.dat"));
     if (!isset($this->playerLang["console"])) {
         $this->getLangFile();
     }
     $commands = ["setmoney" => "onebone\\economyapi\\commands\\SetMoneyCommand", "seemoney" => "onebone\\economyapi\\commands\\SeeMoneyCommand", "mymoney" => "onebone\\economyapi\\commands\\MyMoneyCommand", "pay" => "onebone\\economyapi\\commands\\PayCommand", "givemoney" => "onebone\\economyapi\\commands\\GiveMoneyCommand", "topmoney" => "onebone\\economyapi\\commands\\TopMoneyCommand", "setlang" => "onebone\\economyapi\\commands\\SetLangCommand", "takemoney" => "onebone\\economyapi\\commands\\TakeMoneyCommand", "mystatus" => "onebone\\economyapi\\commands\\MyStatusCommand"];
     $commandMap = $this->getServer()->getCommandMap();
     foreach ($commands as $key => $command) {
         foreach ($this->command->get($key) as $cmd) {
             $commandMap->register("economyapi", new $command($this, $cmd));
         }
     }
     $this->getServer()->getPluginManager()->registerEvents($this, $this);
     $this->convertData();
     $moneyConfig = new Config($this->getDataFolder() . "Money.yml", Config::YAML, ["version" => 2, "money" => []]);
     if ($moneyConfig->get("version") < self::CURRENT_DATABASE_VERSION) {
         $converter = new DataConverter($this->getDataFolder() . "Money.yml");
         $result = $converter->convertData(self::CURRENT_DATABASE_VERSION);
         if ($result !== false) {
             $this->getLogger()->info("Converted data into new database. Database version : " . self::CURRENT_DATABASE_VERSION);
         }
         $moneyConfig = new Config($this->getDataFolder() . "Money.yml", Config::YAML);
     }
     $this->money = $moneyConfig->getAll();
     $this->monetaryUnit = $this->config->get("monetary-unit");
     $time = $this->config->get("auto-save-interval");
     if (is_numeric($time)) {
         $interval = $time * 1200;
         $this->getServer()->getScheduler()->scheduleDelayedRepeatingTask(new SaveTask($this), $interval, $interval);
         $this->getLogger()->notice("Auto save has been set to interval : " . $time . " min(s)");
     }
     $update_check = new Config($this->getDataFolder() . "update-check.yml", Config::YAML, yaml_parse($this->readResource("update-check.yml")));
     if ($update_check->get("check-update")) {
         try {
             $this->getLogger()->info("Checking for updates... It may be take some while.");
             $host = $update_check->get("update-host");
             $url = "http://" . $host . "/?package_version=" . self::PACKAGE_VERSION . "&version=" . $this->getDescription()->getVersion() . "&lang=" . $this->getServer()->getLanguage()->getName();
             $desc = json_decode(Utils::getUrl($url), true);
             if ($desc["update-available"]) {
                 $this->getLogger()->notice("New version of EconomyS v" . $desc["new-version"] . " was released. You can download file from " . $desc["download-address"]);
             }
             if ($desc["notice"] !== "") {
                 $this->getLogger()->notice($desc["notice"]);
             }
         } catch (\Exception $e) {
             $this->getLogger()->warning("An exception during check-update has been detected.");
         }
     }
 }
Пример #29
0
 public function getAll()
 {
     return $this->config->getAll();
 }
Пример #30
-1
 public function loadInventory(Player $player, Inventory $inv)
 {
     $n = trim(strtolower($player->getName()));
     if ($n === "") {
         return false;
     }
     $d = substr($n, 0, 1);
     $path = $this->getDataFolder() . $d . "/" . $n . ".yml";
     if (!is_file($path)) {
         return false;
     }
     $cfg = new Config($path, Config::YAML);
     $yaml = $cfg->getAll();
     if ($this->isGlobal) {
         $ln = "*";
     } else {
         $ln = trim(strtolower($player->getLevel()->getName()));
     }
     if (!isset($yaml[$ln])) {
         return false;
     }
     $inv->clearAll();
     foreach ($yaml[$ln] as $slot => $t) {
         list($id, $dam, $cnt) = explode(":", $t);
         $item = Item::get($id, $dam, $cnt);
         $inv->setItem($slot, $item);
     }
     return true;
 }