本文整理汇总了PHP中pocketmine\command\CommandSender::getServer方法的典型用法代码示例。如果您正苦于以下问题:PHP CommandSender::getServer方法的具体用法?PHP CommandSender::getServer怎么用?PHP CommandSender::getServer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pocketmine\command\CommandSender
的用法示例。
在下文中一共展示了CommandSender::getServer方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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");
}
}
}
}
}
}
示例2: processIPBan
private function processIPBan($ip, CommandSender $sender, $reason)
{
$sender->getServer()->getIPBans()->addBan($ip, $reason, null, $sender->getName());
foreach ($sender->getServer()->getOnlinePlayers() as $player) {
if ($player->getAddress() === $ip) {
$player->kick("You have been IP banned.");
}
}
Command::broadcastCommandMessage($sender, "Banned IP Address " . $ip);
}
示例3: processIPBan
private function processIPBan($ip, CommandSender $sender, $reason)
{
$sender->getServer()->getIPBans()->addBan($ip, $reason, \null, $sender->getName());
foreach ($sender->getServer()->getOnlinePlayers() as $player) {
if ($player->getAddress() === $ip) {
$player->kick($reason !== "" ? $reason : "IP banned.");
}
}
$sender->getServer()->getNetwork()->blockAddress($ip, -1);
}
示例4: execute
public function execute(CommandSender $sender, $commandLabel, array $args)
{
$dist = 0;
if (count($args) === 0) {
$sender->sendMessage("Usage: /dtp [from] <to>[-<distance behind <to>>]");
return;
} elseif (count($args) === 1) {
if (!($from = $sender) instanceof Player) {
$sender->sendMessage("Please run this command in-game.");
return;
}
$toName = $args[0];
$pos = strpos($toName, "-");
if ($pos !== false) {
$dist = (int) substr($toName, $pos + 1);
$toName = substr($toName, 0, $pos);
}
$to = $sender->getServer()->getPlayer($toName);
if (!$to instanceof Player) {
$sender->sendMessage("{$toName} isn't online!");
return;
}
} else {
$from = $sender->getServer()->getPlayer($args[0]);
if (!$from instanceof Player) {
$sender->sendMessage("{$args['0']} isn't online!");
return;
}
$toName = $args[1];
$pos = strpos($toName, "-");
if ($pos !== false) {
$dist = (int) substr($toName, $pos + 1);
$toName = substr($toName, 0, $pos);
}
$to = $sender->getServer()->getPlayer($toName);
if (!$to instanceof Player) {
$sender->sendMessage("{$toName} isn't online!");
return;
}
}
$l = $to->getLevel();
$v3 = $to->subtract($to->getDirectionVector()->multiply($dist))->floor();
for ($i = $v3->y; $i < 128; $v3->y = ++$i) {
$b = $l->getBlock($v3);
$id = $b->getId();
if ($id === 0 or 8 <= $id and $id <= 11) {
break;
}
}
$from->teleport(Position::fromObject($v3, $l));
$from->sendMessage("Teleported to {$to->getName()}");
}
示例5: execute
public function execute(CommandSender $sender, array $args)
{
if (!empty($args)) {
return false;
}
$player = $sender->getServer()->getPlayer($sender->getName());
$plot = $this->getPlugin()->getPlotByPosition($player->getPosition());
if ($plot === null) {
$sender->sendMessage(TextFormat::RED . $this->translateString("notinplot"));
return true;
}
if ($plot->owner !== $sender->getName() and !$sender->hasPermission("myplot.admin.reset")) {
$sender->sendMessage(TextFormat::RED . $this->translateString("notowner"));
return true;
}
$economy = $this->getPlugin()->getEconomyProvider();
$price = $this->getPlugin()->getLevelSettings($plot->levelName)->resetPrice;
if ($economy !== null and !$economy->reduceMoney($player, $price)) {
$sender->sendMessage(TextFormat::RED . $this->translateString("reset.nomoney"));
return true;
}
if ($this->getPlugin()->resetPlot($plot)) {
$sender->sendMessage($this->translateString("reset.success"));
} else {
$sender->sendMessage(TextFormat::RED . $this->translateString("error"));
}
return true;
}
示例6: execute
public function execute(CommandSender $sender, array $args)
{
if (!empty($args)) {
return false;
}
$player = $sender->getServer()->getPlayer($sender->getName());
$plot = $this->getPlugin()->getPlotByPosition($player->getPosition());
if ($plot === null) {
$sender->sendMessage(TextFormat::RED . "You are not standing on an island");
return true;
}
if ($plot->owner !== $sender->getName() and !$sender->hasPermission("skyblock.admin.clear")) {
$sender->sendMessage(TextFormat::RED . "You are not the owner of this island");
return true;
}
$economy = $this->getPlugin()->getEconomyProvider();
$price = $this->getPlugin()->getLevelSettings($plot->levelName)->clearPrice;
if ($economy !== null and !$economy->reduceMoney($player, $price)) {
$sender->sendMessage(TextFormat::RED . "You don't have enough money to clear this island");
return true;
}
if ($this->getPlugin()->clearPlot($plot, $player)) {
$sender->sendMessage("Island is being cleared...");
} else {
$sender->sendMessage(TextFormat::RED . "Could not clear this island");
}
return true;
}
示例7: execute
public function execute(CommandSender $sender, array $args)
{
if (!empty($args)) {
return false;
}
$player = $sender->getServer()->getPlayer($sender->getName());
$levelName = $player->getLevel()->getName();
$plots = $this->getPlugin()->getProvider()->getPlotsByOwner($sender->getName());
if (empty($plots)) {
$sender->sendMessage(TextFormat::RED . $this->translateString("homes.noplots"));
return true;
}
$sender->sendMessage(TextFormat::DARK_GREEN . $this->translateString("homes.header"));
usort($plots, function ($plot1, $plot2) {
/** @var $plot1 Plot */
/** @var $plot2 Plot */
if ($plot1->levelName == $plot2->levelName) {
return 0;
}
return $plot1->levelName < $plot2->levelName ? -1 : 1;
});
for ($i = 0; $i < count($plots); $i++) {
$plot = $plots[$i];
$message = TextFormat::DARK_GREEN . ($i + 1) . ") ";
$message .= TextFormat::WHITE . $levelName . " " . $plot;
if ($plot->name !== "") {
$message .= " = " . $plot->name;
}
$sender->sendMessage($message);
}
return true;
}
示例8: execute
public function execute(CommandSender $sender, array $args)
{
if (count($args) !== 1) {
return false;
}
$player = $sender->getServer()->getPlayer($sender->getName());
$biome = strtoupper($args[0]);
$plot = $this->getPlugin()->getPlotByPosition($player->getPosition());
if ($plot === null) {
$sender->sendMessage(TextFormat::RED . "You are not standing on an island");
return true;
}
if ($plot->owner !== $sender->getName()) {
$sender->sendMessage(TextFormat::RED . "You are not the owner of this island");
return true;
}
if (!isset($this->biomes[$biome])) {
$sender->sendMessage(TextFormat::RED . "That biome doesn't exist");
$biomes = implode(", ", array_keys($this->biomes));
$sender->sendMessage(TextFormat::RED . "The possible biomes are: {$biomes}");
return true;
}
$biome = Biome::getBiome($this->biomes[$biome]);
if ($this->getPlugin()->setPlotBiome($plot, $biome)) {
$sender->sendMessage(TextFormat::GREEN . "Changed the island biome");
} else {
$sender->sendMessage(TextFormat::RED . "Could not change the island biome");
}
return true;
}
示例9: execute
public function execute(CommandSender $sender, array $args)
{
if (count($args) != 1) {
return false;
}
$player = $sender->getServer()->getPlayer($sender->getName());
$levelName = $player->getLevel()->getName();
if (!$this->getPlugin()->isLevelLoaded($levelName)) {
$sender->sendMessage(TextFormat::RED . $this->translateString("warp.notinplotworld"));
return true;
}
$plotIdArray = explode(";", $args[0]);
if (count($plotIdArray) != 2 or !is_numeric($plotIdArray[0]) or !is_numeric($plotIdArray[1])) {
$sender->sendMessage(TextFormat::RED . $this->translateString("warp.wrongid"));
return true;
}
$plot = $this->getPlugin()->getProvider()->getPlot($levelName, $plotIdArray[0], $plotIdArray[1]);
if ($plot->owner == "" and !$sender->hasPermission("myplot.admin.warp")) {
$sender->sendMessage(TextFormat::RED . $this->translateString("warp.unclaimed"));
return true;
}
$this->getPlugin()->teleportPlayerToPlot($player, $plot);
$plot = TextFormat::GREEN . $plot . TextFormat::WHITE;
$sender->sendMessage($this->translateString("warp.success", [$plot]));
return true;
}
示例10: execute
public function execute(CommandSender $sender, array $args)
{
if (count($args) !== 1) {
return false;
}
$helper = $args[0];
$player = $sender->getServer()->getPlayer($sender->getName());
$plot = $this->getPlugin()->getPlotByPosition($player->getPosition());
if ($plot === null) {
$sender->sendMessage(TextFormat::RED . "You are not standing inside a plot");
return true;
}
if ($plot->owner !== $sender->getName() and !$sender->hasPermission("myplot.admin.addhelper")) {
$sender->sendMessage(TextFormat::RED . "You are not the owner of this plot");
return true;
}
if (!$plot->addHelper($helper)) {
$sender->sendMessage($helper . " was already a helper of this plot");
return true;
}
if ($this->getPlugin()->getProvider()->savePlot($plot)) {
$sender->sendMessage(TextFormat::GREEN . $helper . " is now a helper of this plot");
} else {
$sender->sendMessage(TextFormat::RED . "Helper could not be added");
}
return true;
}
示例11: execute
public function execute(CommandSender $sender, array $args)
{
if (!empty($args)) {
return false;
}
$player = $sender->getServer()->getPlayer($sender->getName());
$levelName = $player->getLevel()->getName();
if (!$this->getPlugin()->isLevelLoaded($levelName)) {
$sender->sendMessage(TextFormat::RED . "You are not inside a plot world");
return true;
}
$sender->sendMessage(TextFormat::RED . "Finding a free plot for you");
if ($this->getPlugin()->getProvider() instanceof \MyPlot\provider\MYSQLDataProvider) {
$plot = $this->getPlugin()->getPlotByPosition($sender->getPosition());
$plot = $this->getPlugin()->getProvider()->getNextFreePlot($levelName, 20, $plot->X, $plot->Z);
} else {
$plot = $this->getPlugin()->getProvider()->getNextFreePlot($levelName);
}
if ($plot !== null) {
$this->getPlugin()->teleportPlayerToPlot($player, $plot);
$sender->sendMessage(TextFormat::GREEN . "Teleported to " . TextFormat::WHITE . $plot);
$sender->sendMessage(TextFormat::GREEN . "If you dont like this plot use the /p auto command again to find another.");
} else {
$sender->sendMessage(TextFormat::RED . "No free plots found in this world");
}
return true;
}
示例12: execute
public function execute(CommandSender $sender, array $args)
{
$confirm = (count($args) == 1 and $args[0] == $this->translateString("confirm"));
if (count($args) != 0 and !$confirm) {
return false;
}
$player = $sender->getServer()->getPlayer($sender->getName());
$plot = $this->getPlugin()->getPlotByPosition($player->getPosition());
if ($plot === null) {
$sender->sendMessage(TextFormat::RED . $this->translateString("notinplot"));
return true;
}
if ($plot->owner !== $sender->getName() and !$sender->hasPermission("myplot.admin.reset")) {
$sender->sendMessage(TextFormat::RED . $this->translateString("notowner"));
return true;
}
if ($confirm) {
$economy = $this->getPlugin()->getEconomyProvider();
$price = $this->getPlugin()->getLevelSettings($plot->levelName)->resetPrice;
if ($economy !== null and !$economy->reduceMoney($player, $price)) {
$sender->sendMessage(TextFormat::RED . $this->translateString("reset.nomoney"));
return true;
}
$maxBlocksPerTick = $this->getPlugin()->getConfig()->get("ClearBlocksPerTick", 256);
if ($this->getPlugin()->resetPlot($plot, $maxBlocksPerTick)) {
$sender->sendMessage($this->translateString("reset.success"));
} else {
$sender->sendMessage(TextFormat::RED . $this->translateString("error"));
}
} else {
$plotId = TextFormat::GREEN . $plot . TextFormat::WHITE;
$sender->sendMessage($this->translateString("reset.confirm", [$plotId]));
}
return true;
}
示例13: execute
public function execute(CommandSender $sender, array $args)
{
if (count($args) !== 1) {
return false;
}
$helper = $args[0];
$player = $sender->getServer()->getPlayer($sender->getName());
$plot = $this->getPlugin()->getPlotByPosition($player->getPosition());
if ($plot === null) {
$sender->sendMessage(TextFormat::RED . "You are not standing inside a plot");
return true;
}
if ($plot->owner !== $sender->getName()) {
$sender->sendMessage(TextFormat::RED . "You are not the owner of this plot");
return true;
}
if (!$plot->removeHelper($helper)) {
$sender->sendMessage($helper . " was never a helper of this plot.");
return true;
}
if ($this->getPlugin()->getProvider()->savePlot($plot)) {
$sender->sendMessage(TextFormat::GREEN . $helper . " has been removed.");
} else {
$sender->sendMessage(TextFormat::RED . "Could not remove that player.");
}
return true;
}
示例14: 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;
}
示例15: execute
public function execute(CommandSender $sender, array $args)
{
if (count($args) !== 1) {
return false;
}
$helper = $args[0];
$player = $sender->getServer()->getPlayer($sender->getName());
$plot = $this->getPlugin()->getPlotByPosition($player->getPosition());
if ($plot === null) {
$sender->sendMessage(TextFormat::RED . $this->translateString("notinplot"));
return true;
}
if ($plot->owner !== $sender->getName() and !$sender->hasPermission("myplot.admin.removehelper")) {
$sender->sendMessage(TextFormat::RED . $this->translateString("notowner"));
return true;
}
if (!$plot->removeHelper($helper)) {
$sender->sendMessage(TextFormat::RED . $this->translateString("removehelper.notone", [$helper]));
return true;
}
if ($this->getPlugin()->getProvider()->savePlot($plot)) {
$sender->sendMessage($this->translateString("removehelper.success", [$helper]));
} else {
$sender->sendMessage(TextFormat::RED . $this->translateString("error"));
}
return true;
}