本文整理汇总了PHP中aliuly\common\mc类的典型用法代码示例。如果您正苦于以下问题:PHP mc类的具体用法?PHP mc怎么用?PHP mc使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了mc类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onCommand
public function onCommand(CommandSender $sender, Command $cmd, $label, array $args)
{
echo __METHOD__ . "," . __LINE__ . "\n";
//##DEBUG
if (strtolower($cmd->getName()) != "afk") {
return false;
}
if (!MPMU::inGame($sender)) {
return true;
}
$api = $this->owner->api;
if ($api->isShielded($sender) && $api->isFrozen($sender) && $api->getMute($sender)) {
// Current AFK'ed
$msg = count($args) == 0 ? mc::_("%1% is back at keyboard", $sender->getName()) : implode(" ", $args);
$api->freeze($sender, false);
$api->setMute($sender, false);
$api->setShield($sender, false);
} else {
$msg = count($args) == 0 ? mc::_("%1% is away from keyboard", $sender->getName()) : implode(" ", $args);
$api->freeze($sender, true);
$api->setMute($sender, true);
$api->setShield($sender, true);
}
$this->owner->getServer()->broadcastMessage($msg);
return true;
}
示例2: dispatchSCmd
/**
* Dispatch commands using sub command table
*/
public function dispatchSCmd(CommandSender $sender, Command $cmd, array $args, $data = null)
{
if (count($args) == 0) {
$sender->sendMessage(mc::_("No sub-command specified"));
return false;
}
$scmd = strtolower(array_shift($args));
if (isset($this->aliases[$scmd])) {
$scmd = $this->aliases[$scmd];
}
if (!isset($this->executors[$scmd])) {
$sender->sendMessage(mc::_("Unknown sub-command %2% (try /%1% help)", $cmd->getName(), $scmd));
return false;
}
if (isset($this->permission[$scmd])) {
if (!$sender->hasPermission($this->permission[$scmd])) {
$sender->sendMessage(mc::_("You are not allowed to do this"));
return true;
}
}
$callback = $this->executors[$scmd];
if ($callback($sender, $cmd, $scmd, $data, $args)) {
return true;
}
if (isset($this->executors["help"])) {
$callback = $this->executors["help"];
return $callback($sender, $cmd, $scmd, $data, ["usage"]);
}
return false;
}
示例3: onCommand
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;
}
示例4: onCommand
public function onCommand(CommandSender $sender, Command $cmd, $label, array $args)
{
if ($cmd->getName() != "near") {
return false;
}
if (!MPMU::inGame($sender)) {
return true;
}
switch (count($args)) {
case 0:
$radius = 64 * 64;
break;
case 1:
$radius = (int) $args[0] * (int) $args[0];
break;
default:
return false;
}
$players = [];
foreach ($sender->getLevel()->getPlayers() as $pl) {
$dist = $pl->distanceSquared($players);
if ($dist < $radius) {
$players[] = $pl->getDisplayName();
}
}
if (count($players) == 0) {
$sender->sendMessage(mc::_("No near by players found!"));
} else {
$sender->sendMessage(mc::_("Neighbors(%1%): %2%", count($players), implode(", ", $players)));
}
return true;
}
示例5: onEnable
public function onEnable()
{
if (\pocketmine\DEBUG <= 1) {
return;
}
echo __METHOD__ . "," . __LINE__ . "\n";
//##DEBUG
// Create example folders
if (!is_dir($this->getDataFolder())) {
mkdir($this->getDataFolder());
}
$mft = explode("\n", trim($this->getResourceContents("manifest.txt")));
foreach ($mft as $f) {
if (file_exists($this->getDataFolder() . $f)) {
continue;
}
$txt = $this->getResourceContents("examples/" . $f);
file_put_contents($this->getDataFolder() . $f, $txt);
}
echo __METHOD__ . "," . __LINE__ . "\n";
//##DEBUG
mc::plugin_init($this, $this->getFile());
MPMU::addCommand($this, $this, "libcommon", ["description" => "LibCommon Command Line interface", "usage" => "/libcommon <subcommand> [options]", "aliases" => ["lc"], "permission" => "libcommon.debug.command"]);
$this->modules = [];
foreach (["Version", "DumpMsgs"] as $mod) {
echo __METHOD__ . "," . __LINE__ . " - {$mod}\n";
//##DEBUG
$mod = __NAMESPACE__ . "\\" . $mod;
$this->modules[] = new $mod($this);
}
$this->modules[] = new BasicHelp($this);
}
示例6: onSCommand
public function onSCommand(CommandSender $c, Command $cc, $scmd, $data, array $args)
{
if (count($args) != 1) {
return false;
}
$pname = $args[0];
$mgr = $this->owner->getServer()->getPluginManager();
$plugin = $mgr->getPlugin($pname);
if ($plugin === null) {
$c->sendMessage(mc::_("%1%: plugin not found", $pname));
return true;
}
$getini = [$plugin, "getMessagesIni"];
if (!is_callable($getini)) {
$c->sendMessage(mc::_("%1%: does not support dumping messages.ini", $pname));
return true;
}
if (!is_dir($plugin->getDataFolder())) {
mkdir($plugin->getDataFolder());
}
if (file_put_contents($plugin->getDataFolder() . "messages.ini", $getini())) {
$c->sendMessage(mc::_("%1%: messages.ini created", $pname));
} else {
$c->sendMessage(mc::_("%1%: error dumping messages.ini", $pname));
}
return true;
}
示例7: onCommand
public function onCommand(CommandSender $sender, Command $cmd, $label, array $args)
{
if ($cmd->getName() != "top") {
return false;
}
switch (count($args)) {
case 0:
if (!MPMU::inGame($sender)) {
return true;
}
$pl = $sender;
break;
case 1:
if (!MPMU::access($sender, "gb.cmd.top.others")) {
return true;
}
$pl = $this->owner->getServer()->getPlayer($args[0]);
if (!$pl) {
$sender->sendMessage(mc::_("%1% not found", $args[0]));
return true;
}
break;
default:
return false;
}
$y = $pl->getLevel()->getHighestBlockAt($pl->getX(), $pl->getZ()) + 1;
$pl->teleport(new Vector3($pl->getX(), $y, $pl->getZ()));
return true;
}
示例8: onCommand
public function onCommand(CommandSender $sender, Command $cmd, $label, array $args)
{
switch (count($args)) {
case 0:
if (!MPMU::inGame($sender)) {
return true;
}
$target = $sender;
break;
case 1:
if (($target = $this->owner->getServer()->getPlayer($args[0])) == null) {
$sender->sendMessage(mc::_("%1% not found", $args[0]));
return true;
}
break;
default:
return false;
}
$item = clone $target->getInventory()->getItemInHand();
$sender->sendMesage(TextFormat::BLUE . mc::_("Item: ") . TextFormat::WHITE . ItemName::str($item));
$sender->sendMesage(TextFormat::BLUE . mc::_("ItemId: ") . TextFormat::WHITE . $item->getId());
$sender->sendMesage(TextFormat::BLUE . mc::_("Count: ") . TextFormat::WHITE . $item->getCount());
$sender->sendMesage(TextFormat::BLUE . mc::_("Damage: ") . TextFormat::WHITE . $item->getDamage());
return true;
}
示例9: onCommand
public function onCommand(CommandSender $sender, Command $cmd, $label, array $args)
{
if (count($args) !== 0) {
return false;
}
if ($cmd->getName() != "back") {
return false;
}
if (!MPMU::inGame($sender)) {
return true;
}
$pos = $this->getState($sender, null);
if ($pos == null) {
$sender->sendMessage(mc::_("No recorded death position to return to"));
return true;
}
list($x, $y, $z, $world) = $pos;
$level = TPUtils::getLevelByName($this->owner->getServer(), $world);
if ($level === null) {
$sender->sendMessage(mc::_("Can not return to your death location"));
$this->unsetState($sender);
return true;
}
$sender->sendMessage(mc::_("Teleporting to the place of your demise"));
TPUtils::tpNearBy($sender, new Position($x, $y, $z, $level));
$this->unsetState($sender);
return true;
}
示例10: onCommand
public function onCommand(CommandSender $sender, Command $cmd, $label, array $args)
{
if (strtolower($cmd->getName()) != "wall") {
return false;
}
if (count($args) == 0) {
return false;
}
if ($sender instanceof RemoteConsoleCommandSender && ($who = MPMU::startsWith($args[1], "--rpc=")) !== null) {
array_shift($args);
$msg = implode(" ", $args);
if ($msg != "") {
$this->owner->getServer()->broadcastMesage(mc::_("WALL:%1% %2%", $who, $msg));
}
return true;
}
$msg = implode(" ", $args);
$who = $sender->getName();
$this->owner->getServer()->broadcastMessage(mc::_("WALL:%1% %2%", $who, $msg));
$lst = $this->owner->getModule("ServerList");
foreach ($lst->getIds() as $id) {
if ($lst->getServerAttr($id, "rcon-pw") === null) {
continue;
}
$host = $lst->getServerAttr($id, "rcon-host");
$port = $lst->getServerAttr($id, "rcon-port");
$auth = $lst->getServerAttr($id, "rcon-pw");
$this->owner->getServer()->getScheduler()->scheduleAsyncTask(new RconTask($this->owner, "rconDone", [$host, $port, $auth], "wall --rpc=" . $who . " " . $msg, [null]));
}
return true;
}
示例11: onCommand
public function onCommand(CommandSender $sender, Command $cmd, $label, array $args)
{
if (!MPMU::inGame($sender)) {
return true;
}
switch ($cmd->getName()) {
case "gmc":
$mode = 1;
break;
case "gms":
$mode = 0;
break;
case "gma":
$mode = 2;
break;
case "gmspc":
$mode = 3;
break;
default:
return false;
}
if ($mode !== $sender->getGamemode()) {
$sender->setGamemode($mode);
if ($mode !== $sender->getGamemode()) {
$sender->sendMessage(TextFormat::RED . mc::_("Unable to change gamemode"));
} else {
$this->owner->getServer()->broadcastMessage(mc::_("%1% changed gamemode to %2% mode", $sender->getName(), MPMU::gamemodeStr($mode)));
}
} else {
$sender->sendMessage(mc::_("You are already in %1% mode", MPMU::gamemodeStr($mode)));
}
return true;
}
示例12: onCommand
public function onCommand(CommandSender $sender, Command $cmd, $label, array $args)
{
$pageNumber = $this->getPageNumber($args);
if (count($args) != 1) {
$sender->sendMessage(mc::_("You must specify a player's name"));
return false;
}
if (($target = MPMU::getPlayer($sender, $args[0])) === null) {
return true;
}
if ($cmd->getName() == "seeinv") {
$tab = [[$args[0], mc::_("Count"), mc::_("Damage")]];
$max = $target->getInventory()->getSize();
foreach ($target->getInventory()->getContents() as $slot => &$item) {
if ($slot >= $max) {
continue;
}
$tab[] = [ItemName::str($item) . " (" . $item->getId() . ")", $item->getCount(), $item->getDamage()];
}
if (count($tab) == 1) {
$sender->sendMessage(mc::_("The inventory for %1% is EMPTY", $args[0]));
return true;
}
} elseif ($cmd->getName() == "seearmor") {
$tab = [[mc::_("Armor for"), TextFormat::RED . $args[0]]];
foreach ([0 => "head", 1 => "body", 2 => "legs", 3 => "boots"] as $slot => $attr) {
$item = $target->getInventory()->getArmorItem($slot);
if ($item->getID() == 0) {
continue;
}
$tab[] = [$attr . TextFormat::BLUE, ItemName::str($item) . " (" . $item->getId() . ":" . $item->getDamage() . ")"];
}
}
return $this->paginateTable($sender, $pageNumber, $tab);
}
示例13: __construct
public function __construct($owner)
{
parent::__construct($owner);
PermUtils::add($this->owner, "gb.cmd.top", "top commnad", "op");
PermUtils::add($this->owner, "gb.cmd.top.others", "top others commnad", "op");
$this->enableCmd("top", ["description" => mc::_("Teleport player to top most block"), "usage" => mc::_("/top [player]"), "permission" => "gb.cmd.top"]);
}
示例14: onCommand
public function onCommand(CommandSender $sender, Command $cmd, $label, array $args)
{
switch (count($args)) {
case 0:
if (!MPMU::inGame($sender)) {
return true;
}
$target = $sender;
$other = false;
break;
case 1:
if (($target = MPMU::getPlayer($sender, $args[0])) === null) {
return true;
}
$other = true;
break;
default:
return false;
}
$item = clone $target->getInventory()->getItemInHand();
if ($item->getId() == Item::AIR) {
if ($other) {
$sender->sendMessage(mc::_("%1% is holding nothing!", $target->getDisplayName()));
} else {
$sender->sendMessage(mc::_("You are holding nothing!"));
}
return true;
}
$sender->sendMessage(TextFormat::BLUE . mc::_("Item: ") . TextFormat::WHITE . ItemName::str($item));
$sender->sendMessage(TextFormat::BLUE . mc::_("ItemId: ") . TextFormat::WHITE . $item->getId());
$sender->sendMessage(TextFormat::BLUE . mc::_("Count: ") . TextFormat::WHITE . $item->getCount());
$sender->sendMessage(TextFormat::BLUE . mc::_("Damage: ") . TextFormat::WHITE . $item->getDamage());
return true;
}
示例15: transferPlayer
/**
* This will transfer a player and also add the workaround for players
* lingering connections...
* @param Player $player
* @param str $address
* @param int $port
* @param str $message
* @return bool
*/
public static function transferPlayer(Player $player, $address, $port, $message = null)
{
$ft = $player->getServer()->getPluginManager()->getPlugin("FastTransfer");
if ($ft === null) {
return false;
}
if ($message === null) {
$message = mc::_("You are being transferred");
}
$res = $ft->transferPlayer($player, $address, $port, $message);
// find out the RakLib interface, which is the network interface that MCPE players connect with
foreach ($player->getServer()->getNetwork()->getInterfaces() as $interface) {
if ($interface instanceof RakLibInterface) {
$raklib = $interface;
break;
}
}
if (!isset($rakLib)) {
return $res;
}
// calculate the identifier for the player used by RakLib
$identifier = $player->getAddress() . ":" . $player->getPort();
// this method call is the most important one -
// it sends some signal to RakLib that makes it think that the client
// has clicked the "Quit to Title" button (or timed out). Some RakLib
// internal stuff will then tell PocketMine that the player has quitted.
$rakLib->closeSession($identifier, "transfer");
}