作者:0-DevMatthew-
项目:RandomCommandsPlugi
public function onCommand(CommandSender $sender, Command $command, $label, array $args)
{
if ($sender instanceof Player) {
if (count($args) == 0) {
$sender->sendMessage(TextFormat::RED . "Not enough arguments.");
return;
}
if (count($args) == 1) {
if ($this->getServer()->getPlayer($args[0])) {
$location = $this->getServer()->getPlayer($args[0])->getLocation();
$sender->teleport($location);
$sender->sendMessage(TextFormat::BLUE . "[Server] You have teleported to {$args['0']}");
return;
} else {
$sender->sendMessage(TextFormat::RED . "[Server] That player isn't online!");
return;
}
}
if (count($args) == 2) {
if ($this->getServer()->getPlayer($args[0]) & getLocation() && $this->getServer()->getPlayer($args[1])) {
$location2 = $this->getServer()->getPlayer($args[1])->getLocation();
$player1 = $this->getServer()->getPlayer($args[0]);
$player2 = $this->getServer()->getPlayer($args[1]);
$player1->teleport($location2);
$player1->sendMessage(TextFormat::BLUE . "[Server] You have teleported to {$args['1']}");
return;
}
}
}
}
作者:Gabriel86
项目:pocketmine-plugin
public function onSCommand(CommandSender $c, Command $cc, $scmd, $world, array $args)
{
if ($scmd != "gm") {
return false;
}
if (count($args) == 0) {
$gm = $this->owner->getCfg($world, "gamemode", null);
if ($gm === null) {
$c->sendMessage(mc::_("[WP] No gamemode for %1%", $world));
} else {
$c->sendMessage(mc::_("[WP] %1% Gamemode: %2%", $world, MPMU::gamemodeStr($gm)));
}
return true;
}
if (count($args) != 1) {
return false;
}
$newmode = $this->owner->getServer()->getGamemodeFromString($args[0]);
if ($newmode === -1) {
$this->owner->unsetCfg($world, "gamemode");
$this->owner->getServer()->broadcastMessage(mc::_("[WP] %1% gamemode removed", $world));
} else {
$this->owner->setCfg($world, "gamemode", $newmode);
$this->owner->getServer()->broadcastMessage(mc::_("[WP] %1% gamemode set to %2%", $world, MPMU::gamemodeStr($newmode)));
}
return true;
}
作者:RedstoneAlmeid
项目:SkyBlockP
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;
}
作者:wrewol
项目:ImagicalMin
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;
}
作者:Skull3
项目:MineBloc
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;
}
作者:0-DevMatthew-
项目:pocketmine-plugin
public function onCommand(CommandSender $sender, Command $cmd, $label, array $args)
{
if ($cmd->getName() != "blowup") {
return false;
}
if (count($args) == 0) {
return false;
}
$pl = $this->owner->getServer()->getPlayer($args[0]);
if (!$pl) {
$sender->sendMessage(mc::_("%1% not found.", $args[0]));
return true;
}
array_shift($args);
$yield = 5;
$magic = false;
foreach ($args as $i) {
if (is_numeric($i)) {
$yield = intval($i);
if ($yield < 1) {
$yield = 1;
}
} elseif (strtolower($i) == "magic") {
$magic = true;
} elseif (strtolower($i) == "normal") {
$magic = false;
}
}
$this->blowPlayer($pl, $yield, $magic);
return true;
}
作者:Tolo
项目:Economy
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;
}
作者:Gumbra
项目:Pocketmine-Plugin
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;
}
作者:WonderlandP
项目:WorldEditAr
public function execute(CommandSender $sender, $alias, array $args)
{
if (!$sender instanceof Player) {
$sender->sendMessage("Please run this command in-game or through a CCS (run \"ccs\" for help).");
return true;
}
$session = $this->main->getSessionCollection()->getSession($sender);
if ($session === null or !$session->isValid()) {
$sender->sendMessage("Your account is still being loaded. Please wait...");
return true;
}
if ($alias[0] !== "/") {
return false;
// how come this could even happen!
}
if ($alias === "/") {
$this->displayHelp($sender);
return true;
} else {
$cmdName = substr($alias, 1);
var_dump($cmdName);
$cmd = $this->findCommand($cmdName);
if ($cmd === null) {
return false;
}
$ret = $cmd->run($session, $args);
if (is_string($ret)) {
$session->sendMessage($ret);
} elseif (is_int($ret)) {
// TODO
}
return true;
}
}
作者:EmreTr
项目:TNTRu
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;
}
作者:ChalkP
项目:ExamplePlugi
/**
* @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;
}
作者:DWW
项目:pocketmine-plugin
public function onSCommand(CommandSender $c, Command $cc, $scmd, $data, array $args)
{
if (count($args) == 0) {
return false;
}
$wname = implode(" ", $args);
$old = $this->owner->getServer()->getConfigString("level-name");
if ($old == $wname) {
$c->sendMessage(TextFormat::RED . mc::_("No change"));
return true;
}
if (!$this->owner->autoLoad($c, $wname)) {
$c->sendMessage(TextFormat::RED . mc::_("[MW] Unable to load %1%", $wname));
$c->sendMessage(TextFormat::RED . mc::_("Change failed!"));
return true;
}
$level = $this->owner->getServer()->getLevelByName($wname);
if ($level === null) {
$c->sendMessage(TextFormat::RED . mc::_("Error GetLevelByName %1%"));
return true;
}
$this->owner->getServer()->setConfigString("level-name", $wname);
$this->owner->getServer()->setDefaultLevel($level);
$c->sendMessage(TextFormat::BLUE . mc::_("Default world changed to %1%", $wname));
return true;
}
作者:DWW
项目:pocketmine-plugin
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;
}
作者:100henrik10
项目:TNTRu
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;
}
作者:nesgohoo
项目:PMMP-Plugin
/**
* @param CommandSender $sender
* @param string[] $args
* @return bool
*/
public function exec(CommandSender $sender, array $args)
{
if (count($args) < 2 or !is_string($args[0]) or !is_string($args[1])) {
return false;
}
$clanName = Clannish::validateName($args[0], true);
$managerName = Clannish::validateName($sender->getName());
$memberName = Clannish::validateName($args[1]);
$clan = Clannish::getInstance()->getClan($clanName);
if ($clan === null) {
$this->sendMessage($sender, "clan-not-found", ["name" => $clanName]);
return true;
}
if (!($clan->getMember($managerName)->isManager() or $sender->hasPermission("clannish.operation"))) {
$this->sendMessage($sender, "clan-manager-only");
return true;
}
if (!$clan->isMember($memberName)) {
$this->sendMessage($sender, "clan-member-not-found", ["name" => $memberName]);
return true;
}
$clan->getManager()->setGrade(ClanMember::GRADE_STAFF);
$clan->getMember($memberName)->setGrade(ClanMember::GRADE_MANAGER);
$this->sendMessage($sender, "clan-manager-delegated", ["name" => $clanName, "member" => $memberName]);
return true;
}
作者:Skull3
项目:MineBloc
public function onCommand(CommandSender $sender, Command $cmd, $label, array $sub)
{
if (!isset($sub[3])) {
return false;
}
$mm = "[Move] ";
$ik = $this->isKorean();
if (is_numeric($x = $sub[0]) && is_numeric($y = $sub[1]) && is_numeric($z = $sub[2]) && (!isset($sub[3]) or $sub[3] === "") && $sender instanceof Player) {
$player = $sender;
} elseif (!($player = $this->getServer()->getPlayer(strtolower($sub[0])))) {
$r = $sub[0] . ($ik ? "는 잘못된 플레이어명입니다." : "is invalid player");
} elseif (!(is_numeric($x = $sub[1]) && is_numeric($y = $sub[2]) && is_numeric($z = $sub[3]))) {
$r = "<X> or <Y> or <Z> " . ($ik ? "중 하나가 숫자가 아닙니다." : "is not number");
}
if (isset($r)) {
$sender->sendMessage($mm . $r);
} elseif (!($x || $y || $z)) {
return ture;
} elseif (isset($sub[4]) && $sub[4] == "%") {
$d = isset($sub[5]) && is_numeric($sub[5]) && $sub[5] >= 0 ? $sub[5] : (max($x, $y, $z) > 0 ? max($x, $y, $z) : -min($x, $y, $z));
$this->move($player, (new Vector3($x * 0.4, $y * 0.4 + 0.1, $z * 0.4))->multiply(1.11 / $d), $d, isset($sub[6]) && is_numeric($sub[6]) ? $sub[6] : 0.15);
} else {
$player->setMotion((new Vector3($x, $y, $z))->multiply(0.4));
}
return true;
}
作者:TBNRFrags246
项目:Econom
/**
* @param CommandSender $sender
* @param string $commandLabel
* @param string[] $args
*
* @return mixed
*/
public function execute(CommandSender $sender, $commandLabel, array $args)
{
if ($sender->hasPermission(SimpleWarpPermissions::LIST_WARPS_COMMAND)) {
$ret = $this->api->executeTranslationItem("listwarps-list-title");
/** @var Warp[] $iterator */
$iterator = $this->api->getWarpManager()->getIterator();
foreach ($iterator as $w) {
if ($w->canUse($sender)) {
$ret .= " * " . $w->getName() . " ";
if ($sender->hasPermission(SimpleWarpPermissions::LIST_WARPS_COMMAND_XYZ)) {
$dest = $w->getDestination();
$ret .= $dest->toString();
}
$ret .= "\n";
}
}
/**
* EASTER EGG!
*/
if ($sender instanceof Player && $sender->hasPermission(SimpleWarpPermissions::LIST_WARPS_COMMAND_VISUAL) && isset($args[0]) && $args[0] === "v") {
foreach ($iterator as $warp) {
if ($warp->getDestination()->isInternal() && $warp->getDestination()->getPosition()->getLevel() === $sender->getLevel()) {
$particle = new FloatingTextParticle($warp->getDestination()->getPosition(), "(X: {$warp->getDestination()->getPosition()->getFloorX()}}, Y: {$warp->getDestination()->getPosition()->getFloorY()}, Z: {$warp->getDestination()->getPosition()->getFloorZ()}, LEVEL: {$warp->getDestination()->getPosition()->getLevel()->getName()})", "WARP: " . TextFormat::AQUA . $warp->getName() . TextFormat::RESET);
$sender->getLevel()->addParticle($particle, [$sender]);
}
}
}
$sender->sendMessage($ret !== $this->api->executeTranslationItem("listwarps-list-title") ? $ret : $this->api->executeTranslationItem("listwarps-no-warps"));
} else {
$sender->sendMessage($this->api->executeTranslationItem("listwarps-noperm"));
}
}
作者:craftyoy
项目:BanHamme
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;
}
}
作者:Skull3
项目:MineBloc
public function onCommand(CommandSender $sender, Command $cmd, $label, array $sub)
{
$rm = TextFormat::RED . "Usage: /DropCount ";
$mm = "[DropCount] ";
$ik = $this->isKorean();
$set = $this->set;
if (!isset($sub[0])) {
$r = $rm . ($ik ? "<횟수1> <횟수2>" : "<Num1> <Num2>");
} else {
if ($sub[0] < 0 || !is_numeric($sub[0])) {
$sub[0] = 0;
}
$sub[0] = round($sub[0]);
if (isset($sub[1]) && $sub[1] > $sub[0] && is_numeric($sub[1]) !== false) {
$sub[0] = $sub[0] . "~" . round($sub[1]);
}
$set["Count"] = $sub[0];
$r = $mm . ($ik ? "드롭 횟수가 {$sub['0']} 로 설정되었습니다." : "Drop count is set {$sub['0']}");
}
if (isset($r)) {
$sender->sendMessage($r);
}
if ($this->set !== $set) {
$this->set = $set;
$this->saveYml();
}
return true;
}
作者:HotFireyDeat
项目:PM-Plugin
public function onCommand(CommandSender $sender, Command $command, $label, array $args)
{
if (strtolower($command->getName()) === "tz") {
$sender->sendMessage($this->colorlist[strtolower($this->getConfig()->get("color"))] . $this->getTime());
return true;
}
}