本文整理汇总了PHP中pocketmine\command\CommandSender::getName方法的典型用法代码示例。如果您正苦于以下问题:PHP CommandSender::getName方法的具体用法?PHP CommandSender::getName怎么用?PHP CommandSender::getName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pocketmine\command\CommandSender
的用法示例。
在下文中一共展示了CommandSender::getName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例2: onCommand
public function onCommand(CommandSender $sender, Command $cmd, $label, array $args)
{
// TODO: Change command structure
// TODO: - /action: Please write your command into chat, other players won't be able to see it!
// TODO: - Use %player% to replace with the player name
// TODO: - /actionDelAll: Remove all actions assigned to the block
switch (strtolower($cmd->getName())) {
case "action":
if (!$sender instanceof Player) {
$sender->sendMessage("This command should not be run on console.");
return true;
}
$sender->sendMessage("Please tap a block to assign your command.");
$this->normalSessions[$sender->getName()] = 'action';
break;
case "actiondelall":
if (!$sender instanceof Player) {
$sender->sendMessage("This command should not be run on console.");
return true;
}
$sender->sendMessage("Select the target block to continue.");
$this->normalSessions[$sender->getName()] = 'actionDelAll';
break;
default:
break;
}
return true;
}
示例3: 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;
}
示例4: 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");
}
}
}
}
}
}
示例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 (count($args) === 0) {
$biomes = TextFormat::WHITE . implode(", ", array_keys($this->biomes));
$sender->sendMessage($this->translateString("biome.possible", [$biomes]));
return true;
} elseif (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 . $this->translateString("notinplot"));
return true;
}
if ($plot->owner !== $sender->getName()) {
$sender->sendMessage(TextFormat::RED . $this->translateString("notowner"));
return true;
}
if (!isset($this->biomes[$biome])) {
$sender->sendMessage(TextFormat::RED . $this->translateString("biome.invalid"));
$biomes = implode(", ", array_keys($this->biomes));
$sender->sendMessage(TextFormat::RED . $this->translateString("biome.possible", [$biomes]));
return true;
}
$biome = Biome::getBiome($this->biomes[$biome]);
if ($this->getPlugin()->setPlotBiome($plot, $biome)) {
$sender->sendMessage($this->translateString("biome.success", [$biome->getName()]));
} else {
$sender->sendMessage(TextFormat::RED . $this->translateString("error"));
}
return true;
}
示例7: exec
public function exec(CommandSender $sender, array $args)
{
$username = $sender->getName();
$result = $this->getPlugin()->myMoney($username);
$sender->sendMessage($this->getPlugin()->getMessage("mymoney-mymoney", $sender->getName(), array($result, "%2", "%3", "%4")));
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: onCommand
public function onCommand(CommandSender $sender, Command $command, $label, array $args)
{
if ($command->getName() === "tc") {
if (!isset($args[0])) {
$sender->sendMessage("/tc add <command> : Add command to a block.");
$sender->sendMessage("/tc delete : Deletes commands from block.");
return true;
} elseif ($args[0] === "add") {
if (!isset($args[1])) {
$sender->sendMessage("/tc add <command>");
return true;
} else {
$moved_args = array();
foreach ($args as $argss) {
array_push($moved_args, $argss);
}
unset($moved_args[array_search("add", $moved_args)]);
$command = implode(" ", $moved_args);
array_push($this->tapwait, array("plyr" => $sender->getName(), "command" => $command));
$sender->sendMessage("Tap on the block to add the command to..");
return true;
}
} elseif ($args[0] == "delete") {
if (!isset($args[1])) {
$sender->sendMessage("/tc delete");
return true;
} else {
array_push($this->tapwait, array("plyrv" => $sender->getName(), "dell" => "yes"));
$sender->sendMessage("Tap on the block to delete commands from..");
return true;
}
}
}
}
示例10: execute
public function execute(CommandSender $sender, array $args)
{
if (empty($args)) {
$plotNumber = 1;
} elseif (count($args) === 1 and is_numeric($args[0])) {
$plotNumber = (int) $args[0];
} else {
return false;
}
$plots = $this->getPlugin()->getProvider()->getPlotsByOwner($sender->getName());
if (empty($plots)) {
$sender->sendMessage(TextFormat::RED . "You don't have any plots");
return true;
}
if (!isset($plots[$plotNumber - 1])) {
$sender->sendMessage(TextFormat::RED . "You don't have a plot with home number {$plotNumber}");
return true;
}
$player = $this->getPlugin()->getServer()->getPlayer($sender->getName());
$plot = $plots[$plotNumber - 1];
if ($this->getPlugin()->teleportPlayerToPlot($player, $plot)) {
$sender->sendMessage(TextFormat::GREEN . "Teleported to " . TextFormat::WHITE . $plot);
} else {
$sender->sendMessage(TextFormat::GREEN . "Could not teleport because plot world " . $plot->levelName . " is not loaded");
}
return true;
}
示例11: 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;
}
示例12: 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;
}
示例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: onCommand
public function onCommand(CommandSender $sender, Command $command, $label, array $params)
{
$username = strtolower($sender->getName());
$player = $this->getServer()->getPlayer($username);
if (!$player instanceof Player) {
$sender->sendMessage("Use this command in-game!");
return true;
}
switch ($command->getName()) {
case "pvppon":
$this->getConfig()->set(strtolower($sender->getName()), true);
$this->getConfig()->save();
$sender->sendMessage("PvP enabled for you.\nUse '/pvppoff' for disable.");
break;
case "pvppoff":
$this->getConfig()->set(strtolower($sender->getName()), false);
$this->getConfig()->save();
$sender->sendMessage("PvP disabled for you.\nUse '/pvppon' for enable.");
break;
case "pvpp":
if ($this->getConfig()->get(strtolower($sender->getName()))) {
$sender->sendMessage("How PvP enabled for you.\nUse '/pvppoff' for disable.");
} else {
$sender->sendMessage("How PvP disabled for you.\nUse '/pvppon' for enable.");
}
break;
}
return true;
}
示例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 . "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;
}