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

public get ( $k, mixed $default = false ) : boolean | mixed
$k
$default mixed
Результат boolean | mixed
Пример #1
2
 public function onCommand(CommandSender $sender, Command $cmd, $label, array $sub)
 {
     @mkdir($this->getServer()->getDataPath() . "/plugins/! DeBePlugins/");
     $korean = new Config($this->getServer()->getDataPath() . "/plugins/! DeBePlugins/" . "! Korean.yml", Config::YAML, ["Korean" => false]);
     if ($korean->get("Korean")) {
         $korean->set("Korean", false);
         $m = "설정";
     } else {
         $korean->set("Korean", true);
         $m = "해제";
     }
     $sender->sendMessage("[Korean] 한국말 {$m}");
     $korean->save();
     return true;
 }
Пример #2
1
 public function payTax()
 {
     if (($percent = $this->config->get("tax-as-percentage")) !== "") {
         $players = $this->getServer()->getOnlinePlayers();
         foreach ($players as $player) {
             if ($player->hasPermission("economytax.tax.avoid")) {
                 continue;
             }
             $money = $this->api->myMoney($player);
             $taking = $money * ($percent / 100);
             $this->api->reduceMoney($player, min($money, $taking), true, "EconomyTax");
             $player->sendMessage("Your " . EconomyAPI::getInstance()->getMonetaryUnit() . "{$taking} has taken by tax.");
         }
     } else {
         $money = $this->config->get("tax-as-money");
         $players = $this->getServer()->getOnlinePlayers();
         foreach ($players as $player) {
             if ($player->hasPermission("economytax.tax.avoid")) {
                 continue;
             }
             $this->api->reduceMoney($player, min($this->api->myMoney($player), $money), true, "EconomyTax");
             $player->sendMessage("Your " . EconomyAPI::getInstance()->getMonetaryUnit() . "{$money} has taken by tax.");
         }
     }
 }
Пример #3
0
 private function spawnSign(Position $pos, $get = false)
 {
     if (!$get || !is_array($get)) {
         $get = $this->signs->get($this->posToString($pos));
     }
     if ($pos->level->getBlockIdAt($pos->x, $pos->y, $pos->z) !== Item::SIGN_POST && $pos->level->getBlockIdAt($pos->x, $pos->y, $pos->z) !== Item::WALL_SIGN) {
         if ($pos->level->getBlockIdAt($pos->x, $pos->y - 1, $pos->z) !== Item::AIR && $pos->level->getBlockIdAt($pos->x, $pos->y - 1, $pos->z) !== Item::WALL_SIGN) {
             $pos->level->setBlock($pos, Block::get(Item::SIGN_POST, $get["direction"]), true, true);
         } else {
             $direction = 3;
             if ($pos->level->getBlockIdAt($pos->x - 1, $pos->y, $pos->z) !== Item::AIR) {
                 $direction = 5;
             } elseif ($pos->level->getBlockIdAt($pos->x + 1, $pos->y, $pos->z) !== Item::AIR) {
                 $direction = 4;
             } elseif ($pos->level->getBlockIdAt($pos->x, $pos->y, $pos->z + 1) !== Item::AIR) {
                 $direction = 2;
             }
             $pos->level->setBlock($pos, Block::get(Item::WALL_SIGN, $direction), true, true);
         }
     }
     if (isset($this->tntRun->arenas[$get["arena"]])) {
         $arena = $this->tntRun->arenas[$get["arena"]];
         $lines = ["[TNT Run]", TextFormat::ITALIC . $get["arena"], TextFormat::DARK_GREEN . $arena->getStatusManager()->toString(), count($arena->getPlayerManager()->getAllPlayers()) . "/" . $get["n_players"]];
     } else {
         $lines = ["[TNT Run]", TextFormat::RED . "Arena", $get["arena"], TextFormat::RED . "Not loaded"];
     }
     $tile = $pos->getLevel()->getTile($pos);
     if ($tile instanceof Sign) {
         $tile->setText(...$lines);
     }
 }
Пример #4
0
 public function process()
 {
     $path = $this->getServer()->getPluginManager()->getPlugin("SimpleAuth")->getDataFolder() . "/players/";
     foreach (glob($path . "*/*.yml") as $file) {
         $data = new Config($file, Config::YAML);
         $pname = trim(strtolower(basename($file, ".yml")));
         $regdate = $data->get("registerdate");
         $logindate = $data->get("logindate");
         $ip = $data->get("lastip");
         $hash = $data->get("hash");
         /*$this->db->query("UPDATE simpleauth_players SET name = 
         		'" . $pname . "', hash = '" . $hash . "', registerdate = '"
         		. $regdate ."', logindate = '" . $logindate . "', lastip = '"
         		. $ip . "' WHERE ");*/
         $result = $this->db->query("INSERT INTO simpleauth_players (name, hash, registerdate, logindate, lastip)\n\t\t\t\t\t\t\t\t\t\tVALUES ('{$pname}', '{$hash}', '{$regdate}', '{$logindate}', '{$ip}')");
         if ($result) {
             $this->users++;
         } else {
             $this->getServer()->getPluginManager()->disablePlugin($this);
             $this->getLogger()->critical("Unable to sumbit user to MySQL Database: Unknown Error. Disabling Plugin...");
         }
         if ($this->users % 100 === 0) {
             $this->getLogger()->notice((string) $this->users . " processed.");
         }
     }
 }
Пример #5
0
 public function onEnable()
 {
     $this->getServer()->getLogger()->info("ParkourRunner enabled");
     $this->getServer()->getPluginManager()->registerEvents($this, $this);
     $this->saveDefaultConfig();
     $this->saveResource("arenas.yml");
     $this->saveResource("mysql.yml");
     $this->arenaconf = new Config($this->getDataFolder() . "arenas.yml");
     $arenas = (new Config($this->getDataFolder() . "arenas.yml"))->getAll();
     $mysql = new Config($this->getDataFolder() . "mysql.yml");
     self::$mysql = new \mysqli($mysql->get("host"), $mysql->get("user"), $mysql->get("password"), $mysql->get("database"), $mysql->get("port"));
     if (self::$mysql->connect_error) {
         $this->getLogger()->critical("Cannot connect to MySQL database: " . self::$mysql->connect_error);
     } else {
         $this->getLogger()->info("Connected to MySQL database.");
         self::$mysql->query("CREATE TABLE IF NOT EXISTS ParkourRunner (\n            username VARCHAR(32),\n            map VARCHAR(64),\n            highscore FLOAT\n            )");
     }
     foreach ($arenas as $name => $info) {
         $level = $this->getServer()->getLevelByName($info['level']);
         $checkpoints = array();
         if (isset($info['checkpoints'])) {
             foreach ($info['checkpoints'] as $checkpoint => $cinfo) {
                 $checkpoints[(int) $checkpoint] = array("yaw" => $cinfo['yaw'], "position" => new Position($cinfo['x'], $cinfo['y'], $cinfo['z'], $level));
             }
         }
         $this->arenas[strtolower($name)] = new Map($name, $info["map-maker"], $info["date-of-creation"], $level, $info['floor-y'], new Position($info['timer-block']['x'], $info['timer-block']['y'], $info['timer-block']['z'], $level), $info['start-position']['yaw'], new Position($info['start-position']['x'], $info['start-position']['y'], $info['start-position']['z'], $level), new Position($info['end-block']['x'], $info['end-block']['y'], $info['end-block']['z'], $level), $checkpoints);
         $this->getLogger()->info("§cMap §b'" . $name . "'§c has loaded.");
     }
 }
Пример #6
0
 public function onJoin(PlayerJoinEvent $event)
 {
     if ($this->plugin->status === "enabled") {
         $event->getPlayer()->sendMessage("[xAuth] This server is protected by xAuth.");
     }
     if ($this->plugin->status === "enabled" and $this->plugin->provider === "yml") {
         $myuser = new Config($this->plugin->getDataFolder() . "users/" . strtolower($event->getPlayer()->getName() . ".yml"), Config::YAML);
         if (!$this->plugin->registered->exists(strtolower($event->getPlayer()->getName()))) {
             $this->plugin->proccessmanager[$event->getPlayer()->getId()] = 0;
             $this->plugin->loginmanager[$event->getPlayer()->getId()] = 0;
             $event->getPlayer()->sendMessage("[xAuth] You are not registered.");
             $event->getPlayer()->sendMessage("[xAuth] Type your wanted password in chat.");
             return;
         } else {
             if ($this->plugin->getConfig("ip-auth") === true && $myuser->get("myip") !== $event->getPlayer()->getAddress()) {
                 $this->plugin->proccessmanager[$event->getPlayer()->getId()] = 2;
                 $event->getPlayer()->sendMessage("[xAuth] Your IP does not match.");
                 $event->getPlayer()->sendMessage("[xAuth] Please type your password in chat.");
                 return;
             }
             if ($this->plugin->getConfig("ip-auth") === true && $myuser->get("myip") === $event->getPlayer()->getAddress()) {
                 $event->getPlayer()->sendMessage("[xAuth] You are now logged-in.");
                 return;
             }
             if ($this->plugin->getConfig("ip-auth") !== true) {
                 $event->getPlayer()->sendMessage("[xAuth] Please type your password in chat to log-in.");
                 return;
             } else {
                 $this->chatmanager[$event->getPlayer()->getId()] = 1;
                 $event->getPlayer()->sendMessage("[xAuth] You are now logged-in.");
             }
         }
     }
 }
Пример #7
0
 public function remove($name)
 {
     $past = $this->config->get($name, null);
     $this->config->remove($name);
     $this->config->save();
     return $past;
 }
Пример #8
0
 public function __construct(Main $tntRun)
 {
     $this->tntRun = $tntRun;
     $this->tntRun->saveResource("messages.yml");
     $this->messages = new Config($this->tntRun->getDataFolder() . "messages.yml", Config::YAML);
     $this->tag = $this->messages->get("prefix");
 }
Пример #9
0
 public function initPermissions()
 {
     foreach ($this->config->get('groups') as $name => $groupData) {
         $perms = [];
         foreach ($groupData['perms'] as $str) {
             $str = $this->getServer()->getPluginManager()->getPermission($str);
             if ($str instanceof Permission) {
                 $perms[] = $str;
             }
         }
         $this->groups[$name] = new Group($this, $name, $perms, $groupData['entrance'], $groupData['exit'], $groupData['members']);
     }
 }
 /**
  *
  * @param string $name        	
  *
  * @return CompoundTag
  */
 public function getOfflinePlayerData($name)
 {
     $name = strtolower($name);
     $path = $this->datapath . "players/";
     if (file_exists($path . "{$name}.dat")) {
         try {
             $nbt = new NBT(NBT::BIG_ENDIAN);
             $nbt->readCompressed(file_get_contents($path . "{$name}.dat"));
             return $nbt->getData();
         } catch (\Throwable $e) {
             // zlib decode error / corrupt data
             rename($path . "{$name}.dat", $path . "{$name}.dat.bak");
         }
     }
     $spawn = explode(':', $this->spawn);
     $nbt = new CompoundTag("", [new LongTag("firstPlayed", floor(microtime(true) * 1000)), new LongTag("lastPlayed", floor(microtime(true) * 1000)), new ListTag("Pos", [new DoubleTag(0, $spawn[0]), new DoubleTag(1, $spawn[1]), new DoubleTag(2, $spawn[2])]), new StringTag("Level", $spawn[3]), new ListTag("Inventory", []), new CompoundTag("Achievements", []), new IntTag("playerGameType", $this->gamemode), new ListTag("Motion", [new DoubleTag(0, 0.0), new DoubleTag(1, 0.0), new DoubleTag(2, 0.0)]), new ListTag("Rotation", [new FloatTag(0, 0.0), new FloatTag(1, 0.0)]), new FloatTag("FallDistance", 0.0), new ShortTag("Fire", 0), new ShortTag("Air", 300), new ByteTag("OnGround", 1), new ByteTag("Invulnerable", 0), new StringTag("NameTag", $name)]);
     $nbt->Pos->setTagType(NBT::TAG_Double);
     $nbt->Inventory->setTagType(NBT::TAG_Compound);
     $nbt->Motion->setTagType(NBT::TAG_Double);
     $nbt->Rotation->setTagType(NBT::TAG_Float);
     if (file_exists($path . "{$name}.yml")) {
         // Importing old PocketMine-MP files
         $data = new Config($path . "{$name}.yml", Config::YAML, []);
         $nbt["playerGameType"] = (int) $data->get("gamemode");
         $nbt["Level"] = $data->get("position")["level"];
         $nbt["Pos"][0] = $data->get("position")["x"];
         $nbt["Pos"][1] = $data->get("position")["y"];
         $nbt["Pos"][2] = $data->get("position")["z"];
         $nbt["SpawnLevel"] = $data->get("spawn")["level"];
         $nbt["SpawnX"] = (int) $data->get("spawn")["x"];
         $nbt["SpawnY"] = (int) $data->get("spawn")["y"];
         $nbt["SpawnZ"] = (int) $data->get("spawn")["z"];
         foreach ($data->get("inventory") as $slot => $item) {
             if (count($item) === 3) {
                 $nbt->Inventory[$slot + 9] = new CompoundTag("", [new ShortTag("id", $item[0]), new ShortTag("Damage", $item[1]), new ByteTag("Count", $item[2]), new ByteTag("Slot", $slot + 9), new ByteTag("TrueSlot", $slot + 9)]);
             }
         }
         foreach ($data->get("hotbar") as $slot => $itemSlot) {
             if (isset($nbt->Inventory[$itemSlot + 9])) {
                 $item = $nbt->Inventory[$itemSlot + 9];
                 $nbt->Inventory[$slot] = new CompoundTag("", [new ShortTag("id", $item["id"]), new ShortTag("Damage", $item["Damage"]), new ByteTag("Count", $item["Count"]), new ByteTag("Slot", $slot), new ByteTag("TrueSlot", $item["TrueSlot"])]);
             }
         }
         foreach ($data->get("armor") as $slot => $item) {
             if (count($item) === 2) {
                 $nbt->Inventory[$slot + 100] = new CompoundTag("", [new ShortTag("id", $item[0]), new ShortTag("Damage", $item[1]), new ByteTag("Count", 1), new ByteTag("Slot", $slot + 100)]);
             }
         }
         foreach ($data->get("achievements") as $achievement => $status) {
             $nbt->Achievements[$achievement] = new ByteTag($achievement, $status == true ? 1 : 0);
         }
         unlink($path . "{$name}.yml");
     }
     return $nbt;
 }
Пример #11
0
 /**
  * @param Player $player
  * @return bool
  */
 public function isPlayerBanned(Player $player)
 {
     if ($this->isEnabled()) {
         return in_array(strtolower($player->getName()), $this->config->get("bannedPlayers"));
     }
     return false;
 }
Пример #12
0
 public function getMessage($key, $val = array("%1", "%2", "%3"))
 {
     if ($this->lang->exists($key)) {
         return str_replace(array("%MONETARY_UNIT%", "%1", "%2", "%3"), array(EconomyAPI::getInstance()->getMonetaryUnit(), $val[0], $val[1], $val[2]), $this->lang->get($key));
     }
     return "There are no message which has key \"{$key}\"";
 }
Пример #13
0
 public function getShop($x, $y = 0, $z = 0, $level = null)
 {
     if ($x instanceof Position) {
         $y = $x->getFloorY();
         $z = $x->getFloorZ();
         $level = $x->getLevel();
         $x = $x->getFloorX();
     }
     if ($level instanceof Level) {
         $level = $level->getFolderName();
     }
     if (!$this->config->exists($x . ":" . $y . ":" . $z . ":" . $level)) {
         return false;
     }
     return $this->config->get($x . ":" . $y . ":" . $z . ":" . $level);
 }
Пример #14
0
 /**
  * @param Block $block
  */
 public function saveBlock(Block $block)
 {
     $this->blocks[$block->getPosition()->getX() . ":" . $block->getPosition()->getY() . ":" . $block->getPosition()->getZ() . ":" . $block->getPosition()->getLevel()->getName()] = $block;
     $blocks = $this->config->get("blocks");
     $blocks[$block->id] = $block->toArray();
     $this->config->set("blocks", $blocks);
     $this->config->save();
 }
Пример #15
0
 /**
  * @param Loader $plugin
  * @param string $originalFile
  */
 public function __construct(Loader $plugin, $originalFile)
 {
     $oF = fopen($originalFile, "rb");
     $originalInfo = fread($oF, filesize($originalFile));
     fclose($oF);
     $oFS = fopen($originalFileSave = $plugin->getDataFolder() . "MessagesOriginal.yml", "w+");
     fwrite($oFS, $originalInfo);
     fclose($oFS);
     $this->original = new Config($originalFileSave, Config::YAML);
     unlink($originalFileSave);
     $plugin->saveResource("Messages.yml");
     $this->config = new Config($file = $plugin->getDataFolder() . "Messages.yml", Config::YAML);
     if (!$this->config->exists("version") || $this->config->get("version") !== self::VERSION) {
         $plugin->getLogger()->debug(TextFormat::RED . "An invalid language file was found, generating a new one...");
         unlink($file);
         $plugin->saveResource("Messages.yml", true);
         $this->config = new Config($file, Config::YAML);
     }
 }
Пример #16
0
 /**
  * Add a new arena
  * @param $id
  * @param $capacity
  */
 public function addArena($id, $capacity)
 {
     $newArena = new Arena($id, $capacity, array(), $this);
     array_push($this->arenas, $newArena);
     $arenaArray = array('id' => $id, 'capacity' => $capacity, 'spawnpoints' => array());
     $arenas = $this->config->get('arenas');
     $arenas[count($arenas)] = $arenaArray;
     $this->config->set('arenas', $arenas);
     $this->config->save();
 }
 public function __construct(SignShop $SignShop, $dataResources)
 {
     $this->SignShop = $SignShop;
     $file_message = new Config($dataResources . "messages.yml", Config::YAML, $this->message);
     $this->dataResources = $dataResources;
     if ($file_message->get("version_mex") != "oneone") {
         $SignShop->getServer()->getLogger()->info(TextFormat::RED . "Please update the file messages.yml");
     }
     foreach ($this->message as $var => $c) {
         if ($file_message->exists($var) && isset($file_message->get($var)["message"]) && !empty($file_message->get($var)["message"])) {
             $c = $file_message->get($var)["message"];
         } else {
             $c = str_replace("_", " ", $var);
         }
         $this->message[$var]["message"] = $c;
     }
     $this->message["version_mex"] = "oneone";
     $file_message->setAll($this->message);
     $file_message->save();
 }
Пример #18
0
 /**
  * @param PlayerLoginEvent $event
  */
 public function onLoginEvent(PlayerLoginEvent $event)
 {
     $username = strtolower($event->getPlayer()->getName());
     if (!isset($this->money["money"][$username])) {
         $this->getServer()->getPluginManager()->callEvent($ev = new CreateAccountEvent($this, $username, $this->config->get("default-money"), $this->config->get("default-debt"), null, "EconomyAPI"));
         $this->money["money"][$username] = round($ev->getDefaultMoney(), 2);
     }
     if (!isset($this->playerLang[$username])) {
         $this->setLang($this->config->get("default-lang"), $username);
     }
 }
Пример #19
0
 private function sendSpiderToFolder()
 {
     //Sends spiders to clean up stuff.
     $indexing = fgets(fopen($this->plugin->getDataFolder() . "index.txt", 'r'));
     $myuser = new Config($this->plugin->getDataFolder() . "players/" . strtolower($indexing . ".yml"), Config::YAML);
     $date = $myuser->get("date");
     # Check if registered.
     if ($this->getServer()->getPlayer($indexing) !== null) {
         return false;
     } elseif ($myuser->get("registered") !== true) {
         unlink(new Config($this->plugin->getDataFolder() . "players/" . strtolower($indexing . ".yml"), Config::YAML));
         return true;
     } elseif ($date > 0) {
         unlink(new Config($this->plugin->getDataFolder() . "players/" . strtolower($indexing->getName() . ".yml"), Config::YAML));
         $file = $this->plugin->getDataFolder() . "index.txt";
         $file->remove($indexing);
         $file->save();
         array_push($this->plugin->mainlogger, "xAuthSpider> Deleted {$indexing} from players folder.");
         return true;
     }
     return false;
 }
Пример #20
0
 private function parseData($moneyFile)
 {
     $moneyCfg = new Config($moneyFile, Config::YAML);
     $this->moneyFile = $moneyCfg;
     if ($moneyCfg->exists("version")) {
         $this->version = $moneyCfg->get("version");
     } else {
         $this->version = self::VERSION_1;
     }
     if ($this->version === self::VERSION_1) {
         $this->moneyData = $moneyCfg->get("money");
     } else {
         switch ($this->version) {
             case self::VERSION_2:
                 $money = [];
                 foreach ($moneyCfg->get("money") as $player => $m) {
                     $money[strtolower($player)] = $m;
                 }
                 $this->moneyData = $money;
                 break;
         }
     }
 }
Пример #21
0
 public static function listsArenas(Player $sender, $path)
 {
     $xpath = $path . MapArena::ARENA_DIRECTORY;
     if (!file_exists($xpath)) {
         @mkdir($xpath, 0755, true);
         return null;
     }
     $output = "List of Arenas:\n";
     $handler = opendir($xpath);
     $i = 1;
     while (($filename = readdir($handler)) !== false) {
         if ($filename != "." && $filename != "..") {
             $data = new Config($xpath . $filename, Config::YAML);
             $name = str_replace(".yml", "", $filename);
             $id = $data->get("id");
             $levelname = $data->get("levelName");
             $pos = new Position($data->get("positionX"), $data->get("positionY"), $data->get("positionZ"));
             $output .= $i . ". " . $name . " " . $pos->x . " " . $pos->y . " " . $pos->z . "\n";
             $i++;
         }
     }
     closedir($handler);
     return $output;
 }
Пример #22
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}");
                 }
             }
         }
     }
 }
Пример #23
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;
     }
 }
Пример #24
0
 public function onLevelLoad(LevelLoadEvent $event)
 {
     if ($event->getLevel()->getProvider()->getGenerator() === "myplot") {
         $settings = $event->getLevel()->getProvider()->getGeneratorOptions();
         if (isset($settings["preset"]) === false or $settings["preset"] === "") {
             return;
         }
         $settings = json_decode($settings["preset"], true);
         if ($settings === false) {
             return;
         }
         $levelName = $event->getLevel()->getName();
         $filePath = $this->plugin->getDataFolder() . "worlds/" . $levelName . ".yml";
         $config = $this->plugin->getConfig();
         $default = ["RestrictEntityMovement" => $config->getNested("DefaultWorld.RestrictEntityMovement"), "ClaimPrice" => $config->getNested("DefaultWorld.ClaimPrice"), "ClearPrice" => $config->getNested("DefaultWorld.ClearPrice"), "DisposePrice" => $config->getNested("DefaultWorld.DisposePrice"), "ResetPrice" => $config->getNested("DefaultWorld.ResetPrice")];
         $config = new Config($filePath, Config::YAML, $default);
         foreach (array_keys($default) as $key) {
             $settings[$key] = $config->get($key);
         }
         $this->plugin->addLevelSettings($levelName, new PlotLevelSettings($levelName, $settings));
     }
 }
Пример #25
0
 private function loadFactionsPlugin()
 {
     $factionsPluginName = $this->config->get("default-factions-plugin");
     if ($factionsPluginName === null) {
         $this->getLogger()->notice("No valid factions plugin in default-factions-plugin node was found. Disabling factions plugin support.");
     } else {
         switch (strtolower($factionsPluginName)) {
             case "factionspro":
                 $factionsPro = $this->getServer()->getPluginManager()->getPlugin("FactionsPro");
                 if ($factionsPro !== null) {
                     if (version_compare($factionsPro->getDescription()->getVersion(), "1.5b1") === -1) {
                         $this->factionsAPI = new FactionsProOld();
                         $this->getLogger()->notice("FactionsPro-OLD support enabled.");
                         break;
                     } else {
                         $this->factionsAPI = new FactionsProNew();
                         $this->getLogger()->notice("FactionsPro-NEW support enabled.");
                         break;
                     }
                 }
                 $this->getLogger()->notice("No valid factions plugin in default-factions-plugin node was found. Disabling factions plugin support.");
                 break;
             case "xeviouspe-factions":
                 if ($this->getServer()->getPluginManager()->getPlugin("XeviousPE-Factions") !== null) {
                     $this->factionsAPI = new XeviousPE_Factions();
                     $this->getLogger()->notice("XeviousPE-Factions support enabled.");
                     break;
                 }
                 $this->getLogger()->notice("No valid factions plugin in default-factions-plugin node was found. Disabling factions plugin support.");
                 break;
             default:
                 $this->getLogger()->notice("No valid factions plugin in default-factions-plugin node was found. Disabling factions plugin support.");
                 break;
         }
     }
 }
Пример #26
0
 /**
  * @param string  $variable
  * @param boolean $defaultValue
  *
  * @return boolean
  */
 public function getConfigBoolean($variable, $defaultValue = false)
 {
     $v = getopt("", ["{$variable}::"]);
     if (isset($v[$variable])) {
         $value = $v[$variable];
     } else {
         $value = $this->properties->exists($variable) ? $this->properties->get($variable) : $defaultValue;
     }
     if (is_bool($value)) {
         return $value;
     }
     switch (strtolower($value)) {
         case "on":
         case "true":
         case "1":
         case "yes":
             return true;
     }
     return false;
 }
Пример #27
0
 public function onCommand(CommandSender $sender, Command $command, $label, array $params)
 {
     switch (array_shift($params)) {
         case "join":
             if (!$sender instanceof Player) {
                 $sender->sendMessage("Please run this command in-game.");
             }
             if ($this->player->exists($sender->getName())) {
                 $sender->sendMessage("You already have joined job.");
             } else {
                 $job = array_shift($params);
                 if (trim($job) === "") {
                     $sender->sendMessage("Usage: /job join <name>");
                     break;
                 }
                 if ($this->jobs->exists($job)) {
                     $this->player->set($sender->getName(), $job);
                     $sender->sendMessage("You have joined to the job \"{$job}\"");
                 } else {
                     $sender->sendMessage("There's no job named \"{$job}\"");
                 }
             }
             break;
         case "retire":
             if (!$sender instanceof Player) {
                 $sender->sendMessage("Please run this command in-game.");
             }
             if ($this->player->exists($sender->getName())) {
                 $job = $this->player->get($sender->getName());
                 $this->player->remove($sender->getName());
                 $sender->sendMessage("You have retired from the job \"{$job}\"");
             } else {
                 $sender->sendMessage("You don't have job that you've joined");
             }
             break;
         case "list":
             $max = 0;
             foreach ($this->jobs->getAll() as $d) {
                 $max += count($d);
             }
             $max = ceil($max / 5);
             $page = array_shift($params);
             $page = max(1, $page);
             $page = min($max, $page);
             $page = (int) $page;
             $current = 1;
             $n = 1;
             $output = "Showing job list page {$page} of {$max} : \n";
             foreach ($this->jobs->getAll() as $name => $job) {
                 $info = "";
                 foreach ($job as $id => $money) {
                     $cur = (int) ceil($n / 5);
                     if ($cur === $page) {
                         $info .= $name . " : " . $id . " | " . EconomyAPI::getInstance()->getMonetaryUnit() . "" . $money . "\n";
                     } elseif ($cur > $page) {
                         break;
                     }
                     ++$n;
                 }
                 $output .= $info;
             }
             $sender->sendMessage($output);
             break;
         case "me":
             if (!$sender instanceof Player) {
                 $sender->sendMessage("Please run this command in-game.");
             }
             if ($this->player->exists($sender->getName())) {
                 $sender->sendMessage("Your job : " . $this->player->get($sender->getName()));
             } else {
                 $sender->sendMessage("You don't have any jobs you've joined.");
             }
             break;
         default:
             $sender->sendMessage($command->getUsage());
     }
     return true;
 }
Пример #28
0
 /**
  * @param Player $player
  * @return string
  */
 public function getSavedNameTag(Player $player)
 {
     return $this->nametags->get(strtolower($player->getName()));
 }
Пример #29
0
 public function unlockChest($level, $x, $y, $z, $player)
 {
     if (file_exists($this->data . Main::_DIRECTORY . strtolower($level . "/") . strtolower($x . Main::_FILE . $y . Main::_FILE . $z . ".yml"))) {
         $chest = new Config($this->data . Main::_DIRECTORY . strtolower($level . "/") . strtolower($x . Main::_FILE . $y . Main::_FILE . $z . ".yml"), Config::YAML);
         $tmp = $chest->get("player");
         if (strtolower($player) == strtolower($tmp)) {
             unlink($this->data . Main::_DIRECTORY . strtolower($level . "/") . strtolower($x . Main::_FILE . $y . Main::_FILE . $z . ".yml"));
             return 2;
             //Success!
         } else {
             return 1;
             //Failed: Player is not owner of chest
         }
     } else {
         return 0;
         //Failed: Chest not registered
     }
 }
Пример #30
-1
 public function onEnable()
 {
     @mkdir($this->getDataFolder());
     $this->saveDefaultConfig();
     $this->reloadConfig();
     $this->saveResource("config.yml", false);
     $this->config = new Config($this->getDataFolder() . "config.yml");
     $this->getServer()->getPluginManager()->registerEvents($this, $this);
     $config = $this->config->get("mysql_settings");
     if (!isset($config["host"]) or !isset($config["user"]) or !isset($config["password"]) or !isset($config["database"])) {
         $this->getLogger()->critical("MISSED MYSQL SETTINGS!");
         $this->getLogger()->critical("PLEASE, CHANGE IT IN config.yml");
         $this->getLogger()->critical("PLUGIN: PlayerStats");
         return;
     }
     $this->db = new \mysqli($config["host"], $config["user"], $config["password"], $config["database"], isset($config["port"]) ? $config["port"] : 3306);
     if ($this->db->connect_error) {
         $this->getLogger()->critical("Couldn't connect to MySQL: " . $this->db->connect_error);
         $this->getLogger()->critical("Disabled PlayerStats plugin !");
         $this->getServer()->getPluginManager()->disablePlugin($this->getServer()->getPluginManager()->getPlugin("PlayerStats"));
         return;
     }
     $this->getLogger()->info("Creating query to database...");
     $resource = $this->getResource("mysql.sql");
     $this->db->query(stream_get_contents($resource));
     @fclose($resource);
     $this->getLogger()->info("Done!");
     $this->getLogger()->info("Successfully connected to MySQL server!");
 }