本文整理汇总了PHP中pocketmine\utils\Config::get方法的典型用法代码示例。如果您正苦于以下问题:PHP Config::get方法的具体用法?PHP Config::get怎么用?PHP Config::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pocketmine\utils\Config
的用法示例。
在下文中一共展示了Config::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: payTax
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.");
}
}
}
示例2: onCommand
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;
}
示例3: spawnSign
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: process
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: onEnable
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: onJoin
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: remove
public function remove($name)
{
$past = $this->config->get($name, null);
$this->config->remove($name);
$this->config->save();
return $past;
}
示例8: __construct
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: initPermissions
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']);
}
}
示例10: getOfflinePlayerData
/**
*
* @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: isPlayerBanned
/**
* @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: 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}\"";
}
示例13: getShop
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: saveBlock
/**
* @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: __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);
}
}