本文整理汇总了PHP中pocketmine\command\CommandSender::hasPermission方法的典型用法代码示例。如果您正苦于以下问题:PHP CommandSender::hasPermission方法的具体用法?PHP CommandSender::hasPermission怎么用?PHP CommandSender::hasPermission使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pocketmine\command\CommandSender
的用法示例。
在下文中一共展示了CommandSender::hasPermission方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onCommand
public function onCommand(CommandSender $sender, Command $cmd, $label, array $args)
{
if (strtolower($cmd->getName()) === "sneak") {
if (isset($args[0])) {
$target = $this->plugin->getServer()->getPlayer($args[0]);
if ($sender->hasPermission("sneak.command.other")) {
if ($target instanceof Player) {
$this->plugin->toggleSneak($target);
$target->sendMessage(TF::BOLD . TF::AQUA . $sender->getName() . TF::RESET . TF::GOLD . " has toggled sneaking for you!");
$sender->sendMessage(TF::GOLD . "Toggled sneaking for " . TF::BOLD . TF::AQUA . $target->getName()) . TF::RESET . TF::GOLD . "!";
return true;
} else {
$sender->sendMessage(TF::RED . $args[0] . "is not online!");
return true;
}
} else {
$sender->sendMessage(TF::RED . "You do not have permissions to use the 'sneak' command!");
return true;
}
} elseif ($sender instanceof Player) {
if ($sender->hasPermission("sneak.command.self")) {
$this->plugin->toggleSneak($sender);
$sender->sendMessage(TF::GOLD . "You have toggled sneaking!");
} else {
$sender->sendMessage(TF::RED . "You do not have permissions to use the 'sneak' command!");
}
} else {
$sender->sendMessage(TF::RED . "You must run the 'sneak' command in-game!");
}
return false;
}
}
示例2: onCommand
public function onCommand(CommandSender $sender, Command $command, $label, array $args)
{
if (strtolower($command->getName()) == "nf") {
if (!($sender->hasPermission("notify") || $sender->hasPermission("notify.command") || $sender->hasPermission("notify.command.nf"))) {
$sender->sendMessage(TextFormat::RED . "You don't have permission to use that command!");
return true;
} else {
if (!isset($args[0])) {
return false;
} else {
if ($args[0] == "on") {
if ($this->enabled[0] == "on") {
$sender->sendMessage("NotifySounds are already enabled!");
return true;
} else {
$this->enabled[0] = "on";
$sender->sendMessage("NotifySounds enabled!");
return true;
}
} elseif ($args[0] == "off") {
if ($this->enabled[0] == "off") {
$sender->sendMessage("NotifySounds are already disabled!");
return true;
} else {
$this->enabled[0] = "off";
$sender->sendMessage("NotifySounds disabled");
}
} else {
return false;
}
}
}
}
}
示例3: onCommand
public function onCommand(CommandSender $issuer, Command $cmd, $label, array $args)
{
switch ($cmd->getName()) {
case "setjail":
if ($issuer->hasPermission("jail.command") !== true && $issuer->hasPermission("jail.command.setjail") !== true) {
$issuer->sendMessage($this->plugin->colourMessage("&cYou don't have permission for this!"));
return true;
}
if (!isset($args[0])) {
return false;
}
$jail = $args[0];
if ($this->plugin->jailExists($jail) !== false) {
$issuer->sendMessage($this->plugin->colourMessage("&cJail already exists!"));
return true;
}
if (!$issuer instanceof Player) {
$issuer->sendMessage($this->plugin->colourMessage("Command only works in-game!"));
return true;
}
$this->plugin->setJail($jail, $issuer->x, $issuer->y, $issuer->z, $issuer->getLevel());
$issuer->sendMessage($this->plugin->colourMessage("&6You created jail: &c" . $jail . "&6!"));
return true;
break;
}
}
示例4: onCommand
public function onCommand(CommandSender $issuer, Command $cmd, $label, array $args)
{
switch ($cmd->getName()) {
case "unjail":
if ($issuer->hasPermission("jail.command") !== true && $issuer->hasPermission("jail.command.unjail") !== true) {
$issuer->sendMessage($this->plugin->colourMessage("&cYou don't have permission for this!"));
return true;
}
if (!isset($args[0])) {
return false;
}
$target = $this->plugin->getServer()->getPlayer($args[0]);
if ($target === null) {
$issuer->sendMessage($this->plugin->colourMessage("&cInvalid target!"));
return true;
}
if ($this->plugin->isJailed($target) !== true) {
$issuer->sendMessage($this->plugin->colourMessage("&cTarget is not jailed!"));
return true;
}
$this->plugin->unjail($target);
$issuer->sendMessage($this->plugin->colourMessage("&6You unjailed &e" . $target->getName() . " &6!"));
$target->sendMessage($this->plugin->colourMessage("&6You have been unjailed!"));
return true;
break;
}
}
示例5: onCommand
public function onCommand(CommandSender $sender, Command $cmd, $label, array $args)
{
if (strtolower($cmd->getName('cratekey'))) {
if (count($args) == 0) {
$sender->sendMessage(TextFormat::RED . "/cratekey <give/giveall>");
}
if (count($args) == 1) {
if ($args[0] == "giveall") {
if ($sender->hasPermission("mysterycrates.command.cratekey.giveall")) {
$this->plugin->giveCratekeyAll();
$sender->sendMessage(TextFormat::GOLD . "You have given a cratekey to everyone on the server!");
$sender->getServer()->broadcastMessage(TextFormat::BOLD . TextFormat::BLUE . "[MysteryCrates]" . TextFormat::GREEN . TextFormat::RESET . " Everyone has been given a cratekey by " . TextFormat::GOLD . $sender->getName() . "! ");
}
}
}
if (count($args) == 2) {
if ($args[0] == "give") {
if ($sender->hasPermission("mysterycrates.command.cratekey.give")) {
$player = $sender->getServer()->getPlayer($args[1]);
if ($player instanceof Player) {
$player->sendMessage(TextFormat::GREEN . "You have been given a cratekey by " . TextFormat::GOLD . $sender->getName());
$sender->sendMessage(TextFormat::GOLD . "Given a cratekey to " . TextFormat::GOLD . $player->getName());
$this->plugin->giveCratekey($player);
} else {
$sender->sendMessage(TextFormat::RED . "That player cannot be found");
}
}
}
}
}
}
示例6: onCommand
public function onCommand(Issuer $issuer, Cmd $cmd, $alias, array $args)
{
if (!isset($args[0])) {
if (!$issuer->hasPermission("iplogger.self.read")) {
$issuer->sendMessage("You don't have permission to view your own IP log!");
return true;
}
if (!$issuer instanceof Player) {
return false;
// request pass arg 0
}
$name = strtolower($issuer->getName());
} else {
if (!$issuer->hasPermission("iplogger.other.read")) {
$issuer->sendMessage("You don't have permission to view otheres' IP log!");
return true;
}
$name = strtolower(trim($args[0]));
}
$path = $this->getFileByString($name);
if (!is_file($path)) {
$issuer->sendMessage("{$name} has never been on this server!");
return true;
}
$issuer->sendMessage("IP log of {$name}:");
$msg = str_replace(PHP_EOL, ", ", file_get_contents($path));
if (substr($msg, -2) === ", ") {
$msg = substr($msg, 0, -2);
}
$issuer->sendMessage($msg);
return true;
}
示例7: onCommand
public function onCommand(CommandSender $issuer, Command $cmd, $label, array $args)
{
switch ($cmd->getName()) {
case "jailtp":
if ($issuer->hasPermission("jail.command") !== true && $issuer->hasPermission("jail.command.jailtp") !== true) {
$issuer->sendMessage($this->plugin->colourMessage("&cYou don't have permission for this!"));
return true;
}
if (!isset($args[0])) {
return false;
}
$jail = $args[0];
if ($this->plugin->jailExists($jail) !== true) {
$issuer->sendMessage($this->plugin->colourMessage("&cJail doesn't exist!"));
return true;
}
if (!$issuer instanceof Player) {
$issuer->sendMessage($this->plugin->colourMessage("Command only works in-game!"));
return true;
}
$this->plugin->teleportToJail($issuer, $jail);
$issuer->sendMessage($this->plugin->colourMessage("&6You have been teleported to jail &c" . $jail));
return true;
break;
}
}
示例8: onCommand
public function onCommand(CommandSender $issuer, Command $cmd, $label, array $args)
{
switch ($cmd->getName()) {
case "deljail":
if ($issuer->hasPermission("jail.command") !== true && $issuer->hasPermission("jail.command.deljail") !== true) {
$issuer->sendMessage($this->plugin->colourMessage("&cYou don't have permission for this!"));
return true;
}
if (!isset($args[0])) {
return false;
}
$jail = $args[0];
if ($this->plugin->jailExists($jail) !== true) {
$issuer->sendMessage($this->plugin->colourMessage("&cJail doesn't exist!"));
return true;
}
$t = $this->plugin->data->getAll();
$result = true;
foreach (array_keys($t) as $name) {
if (isset($t[$name]["jail"]) && $t[$name]["jail"] == $jail) {
if ($result !== false) {
$result = false;
}
}
}
if ($result !== true) {
$issuer->sendMessage($this->plugin->colourMessage("&cUnable to delete jail. Someone is still being jailed there!"));
return true;
}
$this->plugin->delJail($jail);
$issuer->sendMessage($this->plugin->colourMessage("&6You deleted jail: &c" . $jail . "&6!"));
return true;
break;
}
}
示例9: onCommand
public function onCommand(CommandSender $sender, Command $cmd, $label, array $args)
{
if (strtolower($cmd->getName()) === "stats") {
if (isset($args[0])) {
$name = $args[0];
if ($sender->hasPermission("pvp-stats.command.other")) {
if ($this->plugin->getData($name) !== null) {
if ($this->plugin->getData($name)["kills"] >= 1 and $this->plugin->getData($name)["deaths"] >= 1) {
$sender->sendMessage($this->plugin->translateColors(str_replace(array("@player", "@kills", "@deaths", "@kdratio"), array($name, $this->plugin->getData($name)["kills"], $this->plugin->getData($name)["deaths"], round($this->plugin->getData($name)["kills"] / $this->plugin->getData($name)["deaths"], 3)), (new Config($this->plugin->getDataFolder() . "Settings.yml"))->getAll()["other-command-format"])));
} else {
$sender->sendMessage($this->plugin->translateColors(str_replace(array("@player", "@kills", "@deaths", "@kdratio"), array($name, $this->plugin->getData($name)["kills"], $this->plugin->getData($name)["deaths"], "&r&cN&r&7/&r&cA&r"), (new Config($this->plugin->getDataFolder() . "Settings.yml"))->getAll()["other-command-format"])));
}
} else {
$sender->sendMessage(TextFormat::RED . "Sorry, stats for " . $name . " don't exist.");
}
} else {
$sender->sendMessage(TextFormat::RED . "You don't have permissions to use this command.");
}
} else {
if ($sender instanceof Player) {
if ($sender->hasPermission("pvp-stats.command.self")) {
if ($this->plugin->getPlayer($sender)["kills"] >= 1 and $this->plugin->getPlayer($sender)["deaths"] >= 1) {
$sender->sendMessage($this->plugin->translateColors(str_replace(array("@kills", "@deaths", "@kdratio"), array($this->plugin->getPlayer($sender)["kills"], $this->plugin->getPlayer($sender)["deaths"], round($this->plugin->getPlayer($sender)["kills"] / $this->plugin->getPlayer($sender)["deaths"], 3)), (new Config($this->plugin->getDataFolder() . "Settings.yml"))->getAll()["self-command-format"])));
} else {
$sender->sendMessage($this->plugin->translateColors(str_replace(array("@kills", "@deaths", "@kdratio"), array($this->plugin->getPlayer($sender)["kills"], $this->plugin->getPlayer($sender)["deaths"], "&r&cN&r&7/&r&cA&r"), (new Config($this->plugin->getDataFolder() . "Settings.yml"))->getAll()["self-command-format"])));
}
} else {
$sender->sendMessage(TextFormat::RED . "You don't have permissions to use this command.");
}
} else {
$sender->sendMessage(TextFormat::RED . "Please run this command in-game!");
}
}
}
}
示例10: onCommand
public function onCommand(CommandSender $sender, Command $command, $label, array $args)
{
switch ($command->getName()) {
case "consoleclients":
if (!$sender->hasPermission("pocketdockconsole.command.consoleclients")) {
$sender->sendMessage(TextFormat::RED . "[PDC] Get some permissions...");
return true;
}
$authedclients = explode(";", $this->thread->connectedips);
if (count($authedclients) < 2) {
$sender->sendMessage("[PDC] There are no connected clients");
return true;
}
$sender->sendMessage("[PDC] Connected client(s) are: " . implode("; ", $authedclients));
return true;
case "killclient":
if (!$sender->hasPermission("pocketdockconsole.command.killclient")) {
$sender->sendMessage(TextFormat::RED . "[PDC] Get some permissions...");
return true;
}
if (!isset($args[0])) {
$sender->sendMessage($command->getUsage());
return true;
}
$sender->sendMessage("[PDC] Killing client: " . $args[0]);
$this->thread->clienttokill = $args[0];
return true;
default:
return false;
}
}
示例11: onCommand
public function onCommand(CommandSender $sender, Command $command, $label, array $args)
{
if (strtolower($command->getName()) == "bam") {
if ($sender instanceof Player) {
if (!($sender->hasPermission("bambam") || $sender->hasPermission("bambam.command") || $sender->hasPermission("bambam.command.bam"))) {
return false;
}
$chambers = $this->getConfig()->get("chambers");
if ($chambers < 2) {
$sender->sendMessage(TextFormat::RED . "You don't have enough chambers!");
return true;
}
if (mt_rand(1, $chambers) == 1) {
$sender->setHealth(0);
$sender->sendMessage(TextFormat::RED . "Unlucky.");
} else {
$sender->sendMessage(TextFormat::GREEN . "You survived.");
foreach ($this->getConfig()->get("commands") as $command) {
$this->getServer()->dispatchCommand(new ConsoleCommandSender(), str_replace("{player}", $sender->getName(), $command));
}
}
} else {
$sender->sendMessage(TextFormat::RED . "You can only play in-game!");
}
return true;
}
}
示例12: onCommand
public function onCommand(CommandSender $sender, Command $cmd, $label, array $args)
{
$fcmd = strtolower($cmd->getName());
switch ($fcmd) {
case "broadcaster":
if (isset($args[0])) {
$args[0] = strtolower($args[0]);
if ($args[0] == "reload") {
if ($sender->hasPermission("broadcaster.reload")) {
$this->plugin->reloadConfig();
$this->cfg = $this->plugin->getConfig()->getAll();
$time = intval($this->cfg["time"]) * 20;
$this->plugin->task->remove();
$this->plugin->ptask->remove();
$this->plugin->task = $this->plugin->getServer()->getScheduler()->scheduleRepeatingTask(new Task($this->plugin), $time);
$this->plugin->ptask = $this->plugin->getServer()->getScheduler()->scheduleRepeatingTask(new PopupTask($this->plugin), $time);
$sender->sendMessage($this->plugin->translateColors("&", Main::PREFIX . "&aConfiguration Reloaded."));
return true;
} else {
$sender->sendMessage($this->plugin->translateColors("&", "&cYou don't have permissions to use this command"));
return true;
}
} elseif ($args[0] == "info") {
if ($sender->hasPermission("broadcaster.info")) {
$sender->sendMessage($this->plugin->translateColors("&", Main::PREFIX . "&2BroadCaster &9v" . Main::VERSION . " &2developed by&9 " . Main::PRODUCER));
$sender->sendMessage($this->plugin->translateColors("&", Main::PREFIX . "&2Website &9" . Main::MAIN_WEBSITE));
return true;
} else {
$sender->sendMessage($this->plugin->translateColors("&", "&cYou don't have permissions to use this command"));
return true;
}
} else {
if ($sender->hasPermission("broadcaster")) {
$sender->sendMessage($this->plugin->translateColors("&", Main::PREFIX . "&cSubcommand &9" . $args[0] . "&c not found. Use &9/bc &cto show available commands"));
break;
} else {
$sender->sendMessage($this->plugin->translateColors("&", "&cYou don't have permissions to use this command"));
break;
}
return true;
}
} else {
if ($sender->hasPermission("broadcaster")) {
$sender->sendMessage($this->plugin->translateColors("&", "&2- &9Available Commands &2-"));
$sender->sendMessage($this->plugin->translateColors("&", "&9/bc info &2- &9Show info about this plugin"));
$sender->sendMessage($this->plugin->translateColors("&", "&9/bc reload &2- &9Reload the config"));
$sender->sendMessage($this->plugin->translateColors("&", "&9/sendmessage &2- &9Send message to the specified player (* for all players)"));
$sender->sendMessage($this->plugin->translateColors("&", "&9/sendpopup &2- &9Send popup to the specified player (* for all players)"));
break;
} else {
$sender->sendMessage($this->plugin->translateColors("&", "&cYou don't have permissions to use this command"));
break;
}
return true;
}
}
return true;
}
示例13: onCommand
public function onCommand(CommandSender $sender, Command $command, $label, array $args)
{
$subcmd = array_shift($args);
switch (strtolower($subcmd)) {
case null:
if ($sender->hasPermission("notice.broadcast")) {
$this->broadcast();
} else {
$sender->sendMesage(new TranslationContainer("%commands.generic.permission"));
}
return true;
case "message":
if ($sender->hasPermission("notice.message")) {
$message = "------- メッセージ -------\n";
foreach ($this->getMessages() as $number => $text) {
$message .= $number . ": " . $text . "\n";
}
} else {
$message = new TranslationContainer("%commands.generic.permission");
}
$sender->sendMessage($message);
return true;
case "reload":
if ($sender->hasPermission("notice.reload")) {
$this->reload();
$sender->sendMessage("configファイルを再読み込みしました");
} else {
$sender->sendMesage(new TranslationContainer("%commands.generic.permission"));
}
return true;
case "help":
default:
if ($this->messageExists($subcmd)) {
if ($sender->hasPermission("notice.broadcast")) {
$this->broadcast($subcmd);
} else {
$sender->sendMesage(new TranslationContainer("%commands.generic.permission"));
}
} else {
if ($sender->hasPermission("notice.help")) {
$message = "--- コマンド一覧 ---\n";
$message .= "/notice [キー] >> メッセージをブロードキャストします\n";
$message .= "/notice message >> メッセージ一覧を取得します\n";
$message .= "/notice reload >> configファイルを再読み込みしました\n";
$message .= "/notice help >> コマンドを確認します";
$sender->sendMessage($message);
} else {
$sender->sendMesage(new TranslationContainer("%commands.generic.permission"));
}
}
return true;
}
}
示例14: onCommand
public function onCommand(CommandSender $sender, Command $cmd, $label, array $args)
{
$fcmd = strtolower($cmd->getName());
switch ($fcmd) {
case "chestlocker":
if (isset($args[0])) {
$args[0] = strtolower($args[0]);
if ($args[0] == "help") {
if ($sender->hasPermission("chestlocker.commands.help")) {
$sender->sendMessage($this->plugin->translateColors("&", "&c|| &8Available Commands &c||"));
$sender->sendMessage($this->plugin->translateColors("&", "&c/chlock info &8> Show info about this plugin"));
$sender->sendMessage($this->plugin->translateColors("&", "&c/chlock reload &8> Reload the config"));
$sender->sendMessage($this->plugin->translateColors("&", "&c/lockchest &8> Lock a " . Main::ITEM_NAME_2));
$sender->sendMessage($this->plugin->translateColors("&", "&c/unlockchest &8> Unlock a " . Main::ITEM_NAME_2));
break;
} else {
$sender->sendMessage($this->plugin->translateColors("&", "&cYou don't have permissions to use this command"));
break;
}
} elseif ($args[0] == "reload") {
if ($sender->hasPermission("chestlocker.commands.reload")) {
$this->plugin->reloadConfig();
$sender->sendMessage($this->plugin->translateColors("&", Main::PREFIX . "&aConfiguration Reloaded."));
break;
} else {
$sender->sendMessage($this->plugin->translateColors("&", "&cYou don't have permissions to use this command"));
break;
}
} elseif ($args[0] == "info") {
if ($sender->hasPermission("chestlocker.commands.info")) {
$sender->sendMessage($this->plugin->translateColors("&", Main::PREFIX . "&8ChestLocker &cv" . Main::VERSION . " &8developed by&c " . Main::PRODUCER));
$sender->sendMessage($this->plugin->translateColors("&", Main::PREFIX . "&8Website &c" . Main::MAIN_WEBSITE));
break;
} else {
$sender->sendMessage($this->plugin->translateColors("&", "&cYou don't have permissions to use this command"));
break;
}
}
} else {
if ($sender->hasPermission("chestlocker.commands.help")) {
$sender->sendMessage($this->plugin->translateColors("&", "&c|| &8Available Commands &c||"));
$sender->sendMessage($this->plugin->translateColors("&", "&c/chlock info &8> Show info about this plugin"));
$sender->sendMessage($this->plugin->translateColors("&", "&c/chlock reload &8> Reload the config"));
$sender->sendMessage($this->plugin->translateColors("&", "&c/lockchest &8> Lock a " . Main::ITEM_NAME_2));
$sender->sendMessage($this->plugin->translateColors("&", "&c/unlockchest &8> Unlock a " . Main::ITEM_NAME_2));
break;
} else {
$sender->sendMessage($this->plugin->translateColors("&", "&cYou don't have permissions to use this command"));
break;
}
}
}
}
示例15: onCommand
public function onCommand(CommandSender $issuer, Command $cmd, $label, array $args)
{
switch ($cmd->getName()) {
case "jails":
if ($issuer->hasPermission("jail.command") !== true && $issuer->hasPermission("jail.command.jails") !== true) {
$issuer->sendMessage($this->plugin->colourMessage("&cYou don't have permission for this!"));
return true;
}
$issuer->sendMessage($this->plugin->colourMessage("&6Jails: &f" . implode(", ", $this->plugin->getJails())));
return true;
break;
}
}