本文整理汇总了PHP中pocketmine\command\CommandSender::isOp方法的典型用法代码示例。如果您正苦于以下问题:PHP CommandSender::isOp方法的具体用法?PHP CommandSender::isOp怎么用?PHP CommandSender::isOp使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pocketmine\command\CommandSender
的用法示例。
在下文中一共展示了CommandSender::isOp方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
public function execute(CommandSender $sender, $command, array $args)
{
if (count($args) > 0) {
if ($args[0] == "reload" && ($sender->isOp() || $sender->hasPermission("ballzauth.ba.reload"))) {
if (isset($args[1])) {
if ($args[1] == "users") {
User::load();
$sender->sendMessage(TextFormat::GREEN . "The users where reloaded");
return true;
} elseif ($args[1] == "config") {
Config::load();
$sender->sendMessage(TextFormat::GREEN . "The config where reloaded");
return true;
}
}
$sender->sendMessage(TextFormat::GOLD . "Usage : /ba reload [config/users]");
return true;
} elseif ($args[0] == "help" && count($args) < 2) {
$sender->sendMessage(TextFormat::GOLD . "------ Help ------");
$sender->sendMessage(TextFormat::GOLD . "/ba reload : " . TextFormat::GRAY . "Reload the users or the config");
return true;
}
}
$sender->sendMessage(TextFormat::GREEN . "------" . TextFormat::GOLD . " BallzAuth " . TextFormat::GREEN . "------");
$sender->sendMessage(TextFormat::GREEN . " Created by Vavaballz");
$sender->sendMessage(TextFormat::GREEN . "-----------------------");
$sender->sendMessage(TextFormat::GOLD . "Type /ba help for command help");
return true;
}
示例2: checkPermission
private function checkPermission(CommandSender $sender)
{
if (!($sender->isOp() or $sender->hasPermission("nt.commmand"))) {
$sender->sendMessage(TextFormat::RED . "You don't have permission to use this command.");
return false;
}
return true;
}
示例3: onCommand
public function onCommand(CommandSender $sender, Command $cmd, $label, array $args)
{
switch ($cmd->getName()) {
case "isop":
$sender->sendMessage("[Server] " . TextFormat::GREEN . "You " . ($sender->isOp() ? "are" : "are not") . " op!");
return true;
}
}
示例4: onCommand
public function onCommand(CommandSender $sender, Command $cmd, $label, array $args)
{
if ($sender->isOp() || $sender instanceof ConsoleCommandSender) {
if (strtolower($cmd->getName()) == "rwl" && !isset($args[2])) {
if (isset($args[0])) {
switch (strtolower($args[0])) {
case "add":
if (!isset($args[1])) {
$sender->sendMessage(TextFormat::RED . "/rwl add [player name]");
break;
}
if ($this->addPlayer($args[1]) === false) {
$sender->sendMessage(TextFormat::RED . "player is already whitelisted");
} else {
$this->addPlayer($args[1]);
$sender->sendMessage(TextFormat::GREEN . "added " . $args[1] . " to the whitelist");
}
break;
case "remove":
if (!isset($args[1])) {
$sender->sendMessage(TextFormat::RED . "/rwl remove [player name]");
break;
}
if ($this->removePlayer($args[1]) === false) {
$sender->sendMessage(TextFormat::RED . "player is not whitelisted");
} else {
$this->removePlayer($args[1]);
$sender->sendMessage(TextFormat::GREEN . "removed " . $args[1] . " from whitelist");
}
break;
case "on":
$this->turnWl("on");
$sender->sendMessage(TextFormat::GREEN . "Whitelist truned on");
break;
case "off":
$this->turnWl("off");
$sender->sendMessage(TextFormat::GREEN . "Whitelist truned off");
break;
}
if ($args[0] !== "add" && $args[0] !== "remove" && $args[0] !== "off" && $args[0] !== "on") {
$sender->sendMessage(TextFormat::RED . "/rwl add [player name]");
}
} else {
$sender->sendMessage(TextFormat::RED . "/rwl add [player name]");
}
}
}
}
示例5: onCommand
public function onCommand(CommandSender $sender, Command $command, $label, array $args)
{
if (!$sender->isOp()) {
return false;
}
if (!isset($args[0]) or !is_numeric($args[0])) {
$sender->sendMessage("[CustomPacket] type : /custompacket <port>");
return true;
}
$this->getConfig()->set("port", intval($args[0]));
$this->getConfig()->save();
self::$interface->shutdown();
self::$interface = new SocketInterface($this->getServer(), $this->getConfig()->get("port", 19131));
$sender->sendMessage("[CustomPacket] Settings have been applied successfully");
return true;
}
示例6: onCommand
public function onCommand(CommandSender $sender, Command $cmd, $l, array $args)
{
if (!$sender instanceof Player or $sender->isOp()) {
if (!isset($args[0])) {
return false;
}
$kicked = $this->getServer()->getPlayer($k = array_shift($args));
if ($kicked !== null and $kicked->isOnline()) {
isset($args[0]) ? $kicked->kick(implode(" ", $args), false) : $kicked->kick();
$sender->sendMessage("Kicked " . $args[0] . " with custom message");
} else {
$sender->sendMessage("Player " . $args[0] . " is not online");
}
} else {
$sender->sendMessage("You don't have permission to use this command");
}
return true;
}
示例7: onCommand
public function onCommand(CommandSender $player, Command $cmd, $label, array $args)
{
switch ($cmd->getName()) {
case "bw":
if ($player->isOp()) {
if ($this->mode == 0 and $args[0] == "addarena") {
$this->mode = 1;
$player->sendMessage(TextFormat::YELLOW . "Use /bw add [worldname] to add an arena");
} elseif ($this->mode == 1 and $args[0] == "add") {
if (file_exists($this->getServer()->getDataPath() . "/worlds/" . $args[0])) {
if (!$this->getServer()->getLevelByName($args[1]) instanceof Level) {
$this->getServer()->loadLevel($args[1]);
}
$spawn = $this->getServer()->getLevelByName($args[1])->getSafeSpawn();
$this->getServer()->getLevelByName($args[1])->loadChunk($spawn->x, $spawn->z);
if ($player instanceof Player) {
$player->teleport($spawn);
}
$this->arenaname = $args[1];
$player->sendMessage(TextFormat::GREEN . "You have successfully entered the arena! Now you have to set 4 bases");
$player->sendMessage(TextFormat::GOLD . "Touch" . TextFormat::BLUE . "Team blue" . TextFormat::GOLD . "'s bed now");
$this->mode = 2;
} else {
$player->sendMessage(TextFormat::RED . "This is not a valid name!");
}
} elseif ($this->mode == 0 and $args[0] == "regsign" and isset($args[1])) {
if (file_exists($this->getDataFolder() . "/arenas/" . $args[1])) {
$player->sendMessage(TextFormat::YELLOW . "You are about to register a sign for the arena {$args['1']}. Tap a sign to activate it!");
$this->regname = $args[1];
$this->mode = 10;
} else {
$player->sendMessage(TextFormat::RED . "This is not a valid name!");
}
} elseif ($this->mode == 0 and $args[0] == "regsign") {
$player->sendMessage(TextFormat::YELLOW . "Usage: /bw regsign [worldname]");
} elseif ($args[0] == "cancel") {
$this->mode = 0;
$player->sendMessage(TextFormat::GREEN . "Cancelled!");
}
}
return true;
}
return true;
}
示例8: onCommand
public function onCommand(CommandSender $sender, Command $cmd, $label, array $args)
{
if ($sender->isOp()) {
switch ($cmd->getName()) {
case "setpos":
$pos = $args[0];
$this->writeCoords($pos, $sender);
// When issued, saves in the config the coordinates and the spawnpoint nubmer
break;
case "s1":
$this->getConfig()->set("pos1", array((int) $sender->x, (int) $sender->y, (int) $sender->z));
break;
case 's2':
$this->getConfig()->set("pos2", array(round($sender->getX(), $sender->getY(), $sender->getZ())));
break;
default:
$sender->sendMessage(TextFormat::RED . 'You must be op to use these commands');
break;
}
}
}
示例9: onCommand
public function onCommand(CommandSender $sender, Command $command, $label, array $args)
{
$username = $sender->getName();
switch ($command->getName()) {
case "ht":
if ($sender->isOp()) {
if ($this->isEnabled !== false) {
$this->isEnabled = false;
} else {
$this->isEnabled = true;
}
foreach ($this->getServer()->getOnlinePlayers() as $player) {
$this->renderNameTag($player);
}
} else {
$sender->sendMessage(TextFormat::RED . "You don't have permission to use this command");
}
return true;
break;
}
}
示例10: execute
public function execute(CommandSender $sender, $label, array $params)
{
if (!$this->plugin->isEnabled()) {
return false;
}
if (!$sender instanceof Player) {
$sender->sendMessage("Please use the command in-game");
return true;
}
if ($sender->isOp()) {
// Get current op location
$playerLocation = $sender->getLocation();
$this->plugin->getLogger()->info("location" . $sender->getLocation());
// Add the arena
$this->arenaManager->referenceNewArena($playerLocation);
// Notify the op
$sender->sendMessage("[1vs1] A new arena has been created at your position ! There are " . $this->arenaManager->getNumberOfArenas() . " arenas.");
return true;
} else {
$sender->sendMessage(TextFormat::RED . "You must be op for use this command !");
}
}
示例11: hasCommandAccess
private function hasCommandAccess(CommandSender $sender)
{
if ($sender->getName() == "CONSOLE") {
return true;
} elseif ($sender->isOp()) {
return true;
}
return false;
}
示例12: onCommand
public function onCommand(CommandSender $sender, Command $command, $label, array $args)
{
switch (strtolower($command->getName())) {
case "onigo":
if ($sender->isOp()) {
if (!isset($args[0])) {
return false;
}
switch (strtolower($args[0])) {
case "start":
$this->setStartGame();
break;
case "stop":
$this->setStopGame();
break;
case "skip":
$this->setTime(0);
break;
}
return true;
} else {
return false;
}
break;
}
return false;
}
示例13: onCommandUser
public function onCommandUser(CommandSender $sender, array $args)
{
$MessageManager = $this->MessageManager;
$MessageManager = $this->SignShop->messageManager();
if ($this->SignShop->getProvider()->getPlayer($sender->getName())["authorized"] != "denied") {
switch (strtolower($args[0])) {
case "?":
case "h":
case "help":
if ($sender->isOp() || $this->SignShop->getProvider()->getPlayer($sender->getName())["authorized"] == "root") {
$sender->sendMessage($this->showHelp(false, true, true));
} else {
$sender->sendMessage($this->showHelp());
}
return;
case "echo":
case "say":
$get = $this->SignShop->getProvider()->getPlayer($sender->getName());
switch (strtolower(trim($args[1]))) {
case "on":
case "true":
$get["echo"] = true;
$this->SignShop->getProvider()->setPlayer($sender->getName(), $get);
$MessageManager->send($sender, "The_action_has_been_executed_successfully");
return;
case "off":
case "false":
$get["echo"] = false;
$this->SignShop->getProvider()->setPlayer($sender->getName(), $get);
$MessageManager->send($sender, "The_action_has_been_executed_successfully");
return;
}
$MessageManager->send($sender, "Invalid_arguments");
return;
case "v":
case "view":
$this->SignShop->temp[$sender->getName()] = ["action" => "view"];
$MessageManager->send($sender, "Now_touch_on_the_Sign_that_you_want_to_do_this_action");
return;
case "remove":
$this->SignShop->temp[$sender->getName()] = ["action" => "remove"];
$MessageManager->send($sender, "Now_touch_on_the_Sign_that_you_want_to_do_this_action");
return;
case "empty":
$this->SignShop->temp[$sender->getName()] = ["action" => "empty"];
$MessageManager->send($sender, "Now_touch_on_the_Sign_that_you_want_to_do_this_action");
return;
case "s":
case "set":
if (count($args) == 3) {
switch (strtolower($args[1])) {
case "amount":
if (is_numeric($args[2]) && $args[2] > 0) {
$this->SignShop->temp[$sender->getName()] = ["action" => "set", "arg" => "amount", "value" => $args[2]];
$MessageManager->send($sender, "Now_touch_on_the_Sign_that_you_want_to_do_this_action");
} else {
$MessageManager->send($sender, "Invalid_value_of_@@", $MessageManager->getMessage("cost"));
}
return;
case "available":
if (is_numeric($args[2]) && $args[2] > 0 && $args[2] < 64 * 45) {
$this->SignShop->temp[$sender->getName()] = ["action" => "set", "arg" => "available", "value" => $args[2]];
$MessageManager->send($sender, "Now_touch_on_the_Sign_that_you_want_to_do_this_action");
} else {
if (strtolower($args[2]) == "unlimited") {
if ($this->SignShop->getProvider()->getPlayer($sender->getName())["authorized"] == "root") {
$this->SignShop->temp[$sender->getName()] = ["action" => "set", "arg" => "unlimited"];
$MessageManager->send($sender, "Now_touch_on_the_Sign_that_you_want_to_do_this_action");
} else {
$MessageManager->send($sender, "You_are_not_authorized_to_run_this_command");
}
} else {
$MessageManager->send($sender, "Invalid_value_of_@@", $MessageManager->getMessage("available"));
}
}
return;
case "cost":
if (is_numeric($args[2]) && $args[2] >= 0) {
$this->SignShop->temp[$sender->getName()] = ["action" => "set", "arg" => "cost", "value" => $args[2]];
$MessageManager->send($sender, "Now_touch_on_the_Sign_that_you_want_to_do_this_action");
} else {
$MessageManager->send($sender, "Invalid_value_of_@@", $MessageManager->getMessage("cost"));
}
return;
case "maker":
if ($args[2] != " ") {
$this->SignShop->temp[$sender->getName()] = ["action" => "set", "arg" => "maker", "name" => $args[2]];
$MessageManager->send($sender, "Now_touch_on_the_Sign_that_you_want_to_do_this_action");
} else {
$MessageManager->send($sender, "Invalid_value_of_@@", $MessageManager->getMessage("maker"));
}
return;
}
}
$MessageManager->send($sender, "Invalid_arguments");
return;
}
return true;
} else {
$MessageManager->send($sender, "You_are_not_authorized_to_run_this_command");
//.........这里部分代码省略.........
示例14: opmsgCmd
public function opmsgCmd(CommandSender $sender, array $args)
{
if (count($args) == 0) {
return false;
}
$ms = TextFormat::BLUE . mc::_("OpMsg [%1%] ", $sender->getName()) . TextFormat::YELLOW . implode(" ", $args);
$this->owner->getLogger()->info($ms);
$count = 0;
foreach ($this->owner->getServer()->getOnlinePlayers() as $pl) {
if (!$pl->isOp()) {
continue;
}
$pl->sendMessage($ms);
++$count;
}
if ($sender instanceof Player && !$sender->isOp()) {
if ($count) {
$sender->sendMessage(mc::_("(ops:%1%) ", $count) . implode(" ", $args));
} else {
$sender->sendMessage(mc::_("Message sent to console only"));
if ($sender->hasPermission("gb.cmd.rpt")) {
$sender->sendMessage(mc::_("Try /rpt instead"));
}
}
}
return true;
}
示例15: onCommand
public function onCommand(CommandSender $sender, Command $command, $label, array $args)
{
if (strtolower($command) == $this->get("command")) {
// TODO <- 빈칸에 명령어
if (!isset($args[0])) {
if ($sender->isOp()) {
$this->alert($sender, $this->get("command-ophelp"));
} else {
$this->alert($sender, $this->get("command-help"));
}
return true;
}
switch (strtolower($args[0])) {
case $this->get("command-participation"):
if (!$this->war->isPlay()) {
$this->alert($sender, $this->get("not-resume-war"));
break;
}
if ($this->war->getSoldier($sender) != null) {
$this->alert($sender, $this->get("already-participate"));
break;
}
$this->war->participate($sender);
$this->message($sender, str_replace("%team%", $this->war->getSoldier($sender)->getTeam()->getTeamName(), $this->get("success-participate")));
break;
case $this->get("command-spawn"):
if (!$sender->isOp()) {
$this->alert($sender, $this->get("dont-have-permission"));
break;
}
if (!isset($args[1])) {
$this->alert($sender, $this->get("spawn-help"));
break;
}
$pos = new Position($sender->getX(), $sender->getY(), $sender->getZ(), $sender->getLevel());
switch (strtolower($args[1])) {
case $this->get("command-red"):
$this->war->redteam->setSpawnPoint($pos);
$this->message($sender, str_replace("%team%", $args[1], $this->get("success-setspawn")));
break;
case $this->get("command-blue"):
$this->war->blueteam->setSpawnPoint($pos);
$this->message($sender, str_replace("%team%", $args[1], $this->get("success-setspawn")));
break;
case $this->get("command-lobby"):
$this->war->setLobby($pos);
$this->message($sender, $this->get("success-setlobby"));
break;
default:
$this->alert($sender, $this->get("spawn-help"));
}
break;
case $this->get("command-leave"):
if ($this->war->leaveWar($sender)) {
$this->message($sender, $this->get("leave-from-war"));
} else {
$this->alert($sender, $this->get("you-dont-participate"));
}
break;
default:
if ($sender->isOp()) {
$this->alert($sender, $this->get("command-ophelp"));
} else {
$this->alert($sender, $this->get("command-help"));
}
break;
}
}
return true;
}