本文整理汇总了PHP中pocketmine\utils\Config::exists方法的典型用法代码示例。如果您正苦于以下问题:PHP Config::exists方法的具体用法?PHP Config::exists怎么用?PHP Config::exists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pocketmine\utils\Config
的用法示例。
在下文中一共展示了Config::exists方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: touchIP
public function touchIP($ip)
{
if (!$this->ipList->exists($ip)) {
$this->ipList->set($ip);
return false;
}
return true;
}
示例2: getConfigurationValue
/**
* @param string $key
* @param mixed $default
*
* @return mixed
*/
public function getConfigurationValue($key, $default = false)
{
if ($this->config->exists($key)) {
return $this->config->get($key);
}
return $default;
}
示例3: getMessage
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}\"";
}
示例4: onPlayerJoin
public function onPlayerJoin(PlayerJoinEvent $event)
{
$name = $event->getPlayer()->getName();
if (!$this->users->exists($name)) {
$this->users->set($name, array('slot1' => null, 'slot2' => null));
$this->users->save();
}
}
示例5: __construct
/**
* @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);
}
}
示例6: updatePerms
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);
}
示例7: removeShop
public function removeShop($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)) {
$this->config->remove($x . ":" . $y . ":" . $z . ":" . $level);
return true;
}
return false;
}
示例8: __construct
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();
}
示例9: parseData
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;
}
}
}
示例10: isOp
/**
* @param string $name
*
* @return bool
*/
public function isOp($name)
{
return $this->operators->exists($name, true);
}
示例11: onCommand
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;
}
示例12: isBackupPlayer
/**
* @param string $player
* @return bool
*/
public function isBackupPlayer($player)
{
return $this->backups->exists(strtolower($player), true);
}
示例13: isExempted
/**
* @param Player $player
* @return bool
*/
public function isExempted(Player $player)
{
return $this->exempts->exists($player->getName(), true);
}
示例14: getDeaths
public function getDeaths($player)
{
$data = new Config($this->getDataFolder() . "data/killanddeeath/" . strtolower($player) . ".yml", Config::YAML);
if ($data->exists("kills") && $data->exists("deaths")) {
return $data->get("deaths");
} else {
$data->setAll(array("kills" => 0, "deaths" => 0));
$data->save();
}
}
示例15: removeDonator
/**
* @param string $name
*/
public function removeDonator($name)
{
if ($this->donators->exists($name, true)) {
$this->donators->remove(strtolower($name));
}
}