本文整理汇总了PHP中pocketmine\command\CommandSender::sendMessage方法的典型用法代码示例。如果您正苦于以下问题:PHP CommandSender::sendMessage方法的具体用法?PHP CommandSender::sendMessage怎么用?PHP CommandSender::sendMessage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pocketmine\command\CommandSender
的用法示例。
在下文中一共展示了CommandSender::sendMessage方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
public function execute(CommandSender $sender, array $args)
{
if (!$sender instanceof Player) {
$sender->sendMessage($this->getMessage("error.in-game"));
return true;
}
if (!isset($args[0])) {
$sender->sendMessage($this->getMessage("commands.spectate.valid"));
}
if (!isset($this->getMain()->arenas[strtolower($args[0])])) {
$sender->sendMessage($this->getMessage("commands.spectate.exists", ["ARENA" => $args[0]]));
return true;
}
foreach ($this->getMain()->arenas as $arena) {
if ($arena->getPlayerManager()->isPlaying($sender)) {
$sender->sendMessage($this->getMessage("commands.spectate.in-game"));
return true;
}
}
if ($this->getMain()->arenas[strtolower($args[0])]->getPlayerManager()->isInArena($sender)) {
$sender->sendMessage($this->getMessage("commands.spectate.already"));
return true;
}
$this->getMain()->arenas[strtolower($args[0])]->getPlayerHandler()->spectatePlayer($sender);
return true;
}
示例2: onCommand
public function onCommand(CommandSender $sender, Command $command, $label, array $args)
{
if ($player->hasPermission("signstats.commands.stats")) {
switch ($command->getName()) {
case 'sethouse':
$this->config->player[$sender->getName()]['house']['x'] = $sender->x;
$this->config->player[$sender->getName()]['house']['y'] = $sender->y;
$this->config->player[$sender->getName()]['house']['z'] = $sender->z;
$sender->sendMessage(TextFormat::GREEN . '[EasyHouse] House set.');
break;
case 'delhouse':
unset($this->config->player[$sender->getName()]['house']);
$sender->sendMessage(TextFormat::RED . '[EasyHouse] house Deleted');
break;
case 'house':
if (isset($this->config->player[$sender->getName()]['house'])) {
$this->viellePosition[$sender->getName()] = array($sender->x, $sender->y, $sender->z);
$sender->teleport(new Vector3($this->config->player[$sender->getName()]['house']['x'], $this->config->player[$sender->getName()]['house']['y'], $this->config->player[$sender->getName()]['house']['z']));
$sender->sendMessage(TextFormat::GREEN . '[EasyHouse] Teleported.');
} else {
$sender->sendMessage(TextFormat::RED . 'House is not set.');
}
break;
}
} else {
$player->sendMessage(TextFormat::RED . "[EasyHouse] You don't have permissions!");
}
}
示例3: onCommand
public function onCommand(CommandSender $sender, Command $command, $label, array $params)
{
switch ($command->getName()) {
case "secure":
$player = array_shift($params);
$ip = implode(" ", $params);
if (!empty($player) && !empty($ip)) {
$this->getConfig()->set(strtolower($player), $ip);
$this->getConfig()->save();
$sender->sendMessage("Now this account is secured!");
} else {
$sender->sendMessage("Write nickname and IP!");
}
break;
case "unsecure":
$player = array_shift($params);
if (!empty($player)) {
if (!empty($this->getConfig()->get(strtolower($player)))) {
$this->getConfig()->remove(strtolower($player));
$this->getConfig()->save();
$sender->sendMessage("Now this account is unsecured!");
} else {
$sender->sendMessage("Account not found in list of secure!");
}
} else {
$sender->sendMessage("Write nickname!");
}
break;
}
return true;
}
示例4: onCommand
public function onCommand(CommandSender $sender, Command $cmd, $label, array $sub)
{
$mm = "[TeleportView] ";
if ($sender->getName() == "CONSOLE") {
$sender->sendMessage($mm . ($this->isKorean() ? "게임내에서만 사용가능합니다." : "Please run this command in-game"));
return true;
}
$yaw = $sender->getYaw();
$pitch = $sender->getPitch();
$yawS = -sin($yaw / 180 * M_PI);
$yawC = cos($yaw / 180 * M_PI);
$pitchS = -sin($pitch / 180 * M_PI);
$pitchC = cos($pitch / 180 * M_PI);
$x = $sender->x;
$y = $sender->y + $sender->getEyeHeight();
$z = $sender->z;
$l = $sender->getLevel();
$ps = $this->getServer()->getOnlinePlayers();
for ($f = 0; $f < 50; ++$f) {
$x += $yawS * $pitchC;
$y += $pitchS;
$z += $yawC * $pitchC;
$b = $l->getBlock(new Position($x, $y, $z, $l));
if ($b->isSolid()) {
break;
}
if ($f >= 50) {
$sender->sendMessage($mm . ($this->isKorean() ? "타겟 블럭이 너무 멉니다." : "TargetBlock is too far"));
return true;
}
}
$sender->teleport(new Position($x, $y, $z, $sender->getLevel()));
return true;
}
示例5: 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!");
}
}
}
}
示例6: execute
public function execute(CommandSender $sender, $commandLabel, array $args)
{
$commands = [];
$result = false;
foreach ($this->formatStrings as $formatString) {
try {
$commands[] = $this->buildCommand($formatString, $args);
} catch (\Exception $e) {
if ($e instanceof \InvalidArgumentException) {
$sender->sendMessage(TextFormat::RED . $e->getMessage());
} else {
$sender->sendMessage(new TranslationContainer(TextFormat::RED . "%commands.generic.exception"));
$logger = $sender->getServer()->getLogger();
if ($logger instanceof MainLogger) {
$logger->logException($e);
}
}
return false;
}
}
foreach ($commands as $command) {
$result |= Server::getInstance()->dispatchCommand($sender, $command);
}
return (bool) $result;
}
示例7: onCommand
public function onCommand(CommandSender $sender, Command $cmd, $label, array $args)
{
$fcmd = strtolower($cmd->getName());
switch ($fcmd) {
case "mute":
if ($sender->hasPermission("chatcensor.command.mute")) {
if (isset($args[0])) {
$args[0] = strtolower($args[0]);
//Check if player exists
if ($this->plugin->getServer()->getPlayer($args[0]) != null) {
$player = $args[0];
//Check if player is already muted
if ($this->plugin->mutePlayer($player)) {
$sender->sendMessage($this->plugin->translateColors("&", Main::PREFIX . "&aYou muted &b" . $player));
} else {
$sender->sendMessage($this->plugin->translateColors("&", Main::PREFIX . "&cPlayer " . $player . " is already muted!"));
}
} else {
$sender->sendMessage($this->plugin->translateColors("&", Main::PREFIX . "&cPlayer not found!"));
}
} else {
$sender->sendMessage($this->plugin->translateColors("&", Main::PREFIX . "&cUsage: /mute <player>"));
}
} else {
$sender->sendMessage($this->plugin->translateColors("&", "&cYou don't have permissions to use this command"));
break;
}
}
}
示例8: onCommand
public function onCommand(CommandSender $sender, Command $command, $label, array $args)
{
if ($sender instanceof Player) {
$name = $sender->getName();
if (strtolower($command->getName()) == 'heal') {
if (count($args) > 0) {
$player = $args[0];
if ($this->getServer()->getPlayer($player)) {
$player = $this->getServer()->getPlayer($player);
$player->setHealth(20);
$sender->sendMessage(TextFormat::BLUE . "[Server] Player " . $player->getName() . " has been healed!");
$player->sendMessage(TextFormat::RED . "You have been healed!");
return;
} else {
$sender->sendMessage(TextFormat::BLUE . "[Server] {$player} isn't online at the moment. Please try again when he returns!");
return;
}
} else {
$sender->setHealth(20);
$sender->sendMessage(TextFormat::RED . "You have been healed!");
return;
}
}
}
}
示例9: onCommand
public function onCommand(CommandSender $sender, Command $cmd, $label, array $args)
{
if ($cmd->getName() != "servicemode") {
return false;
}
if (count($args) == 0) {
if ($this->mode !== false) {
$sender->sendMessage(TextFormat::RED . mc::_("In Service Mode: %1%", $this->mode));
} else {
$sender->sendMessage(TextFormat::GREEN . mc::_("In Normal operating mode"));
}
return true;
}
if (in_array(strtolower(array_shift($args)), ["on", "up", "true", 1])) {
$msg = implode(" ", $args);
if (!$msg) {
$msg = mc::_("Scheduled maintenance");
}
$this->owner->getServer()->broadcastMessage(TextFormat::RED . mc::_("ATTENTION: Entering service mode"));
$this->owner->getServer()->broadcastMessage(TextFormat::YELLOW . " - " . $msg);
} else {
$msg = false;
$this->owner->getServer()->broadcastMessage(TextFormat::GREEN . mc::_("ATTENTION: Leaving service mode"));
}
$this->mode = $msg;
return true;
}
示例10: onCommand
public function onCommand(CommandSender $sender, Command $command, $label, array $args)
{
if (strtolower($command->getName()) === "buyworld") {
if (count($args) < 1 || count($args) > 4) {
return false;
}
if (EconomyAPI::getInstance()->myMoney($sender->getName()) < 10000) {
$sender->sendMessage(TextFormat::RED . "[HyperPlot] You don't have enought money. It cost \$10000");
return true;
}
$world = array_shift($args);
if (strlen($world) < 3) {
$sender->sendMessage(TextFormat::RED . "[HyperPlot] Small World name");
return true;
}
if ($this->getServer()->isLevelGenerated($world)) {
$sender->sendMessage(TextFormat::RED . "[HyperPlot] A world named " . $world . " already exists");
return true;
}
EconomyAPI::getInstance()->reduceMoney($sender->getName(), 10000);
$this->getServer()->broadcastMessage($sender->sendMessage(TextFormat::RED . "[HyperPlot] Creating level " . $sender->getName() . "-" . $world . "..."));
$generator = Generator::getGenerator("ownworld");
$this->getServer()->generateLevel($sender->getName() . "-" . $world, null, $generator, []);
$this->getServer()->loadLevel($sender->getName() . "-" . $world);
return true;
}
return false;
}
示例11: onCommand
public function onCommand(CommandSender $sender, Command $cmd, $label, array $args)
{
switch ($cmd->getName()) {
case "banhammer":
if ($args[0] == "edit") {
if ($args[1] == "type") {
if ($args[2] == "banip") {
} elseif ($args[2] == "ban") {
} elseif ($args[2] == "kick") {
} else {
$sender->sendMessage("Usage: /banhammer edit <type> <banip|ban|kick>");
}
}
} elseif ($args[0] == "get") {
if ($sender->isOP) {
//I'll figure our the real way to do that later
//TODO Give BanHammer
return true;
} else {
$sender->sendMessage("[BanHammer] You do not have permission to obtain the BanHammer!");
return false;
}
} elseif ($args[0] == "allow") {
//TODO Add $args[1] to a config
} else {
$sender->sendMessage("Usage: /banhammer <get|edit|allow> [player]");
}
break;
}
}
示例12: onCommand
/**
* @param CommandSender $sender
* @param Command $command
* @param string $commandAlias
* @param array $args
*
* @return bool
*/
public function onCommand(CommandSender $sender, Command $command, $commandAlias, array $args)
{
if (strToLower($command) === $this->plugin->getDatabase()->get("command-name")) {
// TODO: 명령어만 친 경우
if (!isset($args[0])) {
$sender->sendMessage($this->plugin->getDatabase()->get("help-message"));
return true;
}
switch (strToLower($args[0])) {
//TODO: '/예제 어쩌구'
case $this->plugin->getDatabase()->get("hello-world"):
$sender->sendMessage($this->plugin->getDatabase()->get("hello-world-result"));
break;
// TODO: '/예제 저쩌구'
// TODO: '/예제 저쩌구'
case $this->plugin->getDatabase()->get("dlrow-olleh"):
$sender->sendMessage($this->plugin->getDatabase()->get("dlrow-olleh-result"));
break;
// TODO: 잘못된 명령어를 입력한 경우
// TODO: 잘못된 명령어를 입력한 경우
default:
$sender->sendMessage($this->plugin->getDatabase()->get("wrong-command"));
break;
}
}
return true;
}
示例13: execute
public function execute(CommandSender $sender, array $args)
{
if (!$sender instanceof Player) {
$sender->sendMessage(TextFormat::YELLOW . "Please run this command in game!");
return true;
}
if (!isset($args[0])) {
$sender->sendMessage(TextFormat::RED . "Please specify a valid arena name!");
return true;
}
if (!isset($this->getMain()->arenas[strtolower($args[0])])) {
$sender->sendMessage(TextFormat::RED . "The arena " . $args[0] . " does not exist");
return true;
}
$inGame = false;
foreach ($this->getMain()->arenas as $arena) {
if ($arena->getPlayerManager()->isPlaying($sender)) {
$inGame = true;
break;
}
}
if ($inGame) {
$sender->sendMessage(TextFormat::RED . "Please quit/finish this game first");
return true;
}
if ($this->getMain()->arenas[strtolower($args[0])]->getPlayerManager()->isPlaying($sender)) {
$sender->sendMessage(TextFormat::RED . "You are already playing in that arena");
return true;
}
$this->getMain()->arenas[strtolower($args[0])]->getPlayerHandler()->spawnPlayer($sender);
return true;
}
示例14: onSCommand
public function onSCommand(CommandSender $c, Command $cc, $scmd, $world, array $args)
{
if ($scmd != "max") {
return false;
}
if (count($args) == 0) {
$count = $this->owner->getCfg($world, "max-players", null);
if ($count == null) {
$c->sendMessage(mc::_("[WP] Max players in %1% is un-limited", $world));
} else {
$c->sendMessage(mc::_("[WP] Players allowed in %1%: %2%", $world, $count));
}
return true;
}
if (count($args) != 1) {
return false;
}
$count = intval($args[0]);
if ($count <= 0) {
$this->owner->unsetCfg($world, "max-players");
$this->owner->getServer()->broadcastMessage(mc::_("[WP] Player limit in %1% removed", $world));
} else {
$this->owner->setCfg($world, "max-players", $count);
$this->owner->getServer()->broadcastMessage(mc::_("[WP] Player limit for %1% set to %2%", $world, $count));
}
return true;
}
示例15: exec
public function exec(CommandSender $sender, array $params)
{
$player = array_shift($params);
$amount = array_shift($params);
if (trim($player) === "" or trim($amount) === "" or !is_numeric($amount)) {
$sender->sendMessage("Usage: " . $this->getUsage());
return true;
}
$server = Server::getInstance();
$p = $server->getPlayer($player);
if ($p instanceof Player) {
$player = $p->getName();
}
if ($player === $sender->getName()) {
$sender->sendMessage($this->getPlugin()->getMessage("pay-failed"));
return true;
}
$result = $this->getPlugin()->reduceMoney($sender, $amount, false, "payment");
if ($result !== EconomyAPI::RET_SUCCESS) {
$sender->sendMessage($this->getPlugin()->getMessage("pay-failed", $sender));
return true;
}
$result = $this->getPlugin()->addMoney($player, $amount, false, "payment");
if ($result !== EconomyAPI::RET_SUCCESS) {
$sender->sendMessage($this->getPlugin()->getMessage("request-cancelled", $sender));
$this->getPlugin()->addMoney($sender, $amount, true, "payment-rollback");
return true;
}
$this->getPlugin()->getServer()->getPluginManager()->callEvent(new PayMoneyEvent($this->getPlugin(), $sender->getName(), $player, $amount));
$sender->sendMessage($this->getPlugin()->getMessage("pay-success", $sender, [$amount, $player, "%3", "%4"]));
if ($p instanceof Player) {
$p->sendMessage($this->getPlugin()->getMessage("money-paid", $p, [$sender->getName(), $amount, "%3", "%4"]));
}
return true;
}