本文整理汇总了PHP中aliuly\common\mc类的典型用法代码示例。如果您正苦于以下问题:PHP mc类的具体用法?PHP mc怎么用?PHP mc使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了mc类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:DWWf,项目名称:pocketmine-plugins,代码行数:26,代码来源:CmdAFK.php
示例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;
}
开发者ID:DWWf,项目名称:pocketmine-plugins,代码行数:33,代码来源:SubCommandMap.php
示例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;
}
开发者ID:0-DevMatthew-0,项目名称:pocketmine-plugins,代码行数:31,代码来源:CmdBlowUp.php
示例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;
}
开发者ID:edwinyoo44,项目名称:pocketmine-plugins,代码行数:32,代码来源:CmdNear.php
示例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);
}
开发者ID:jigibbs123,项目名称:pocketmine-plugins,代码行数:32,代码来源:Main.php
示例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;
}
开发者ID:jigibbs123,项目名称:pocketmine-plugins,代码行数:27,代码来源:DumpMsgs.php
示例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;
}
开发者ID:0-DevMatthew-0,项目名称:pocketmine-plugins,代码行数:29,代码来源:CmdTpTop.php
示例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;
}
开发者ID:0-DevMatthew-0,项目名称:pocketmine-plugins,代码行数:25,代码来源:CmdItemInfo.php
示例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;
}
开发者ID:DWWf,项目名称:pocketmine-plugins,代码行数:28,代码来源:CmdTpBack.php
示例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;
}
开发者ID:DWWf,项目名称:pocketmine-plugins,代码行数:31,代码来源:CmdWall.php
示例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;
}
开发者ID:DWWf,项目名称:pocketmine-plugins,代码行数:33,代码来源:CmdGmx.php
示例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);
}
开发者ID:DWWf,项目名称:pocketmine-plugins,代码行数:35,代码来源:CmdShowInv.php
示例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"]);
}
开发者ID:DWWf,项目名称:pocketmine-plugins,代码行数:7,代码来源:CmdTpTop.php
示例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;
}
开发者ID:DWWf,项目名称:pocketmine-plugins,代码行数:34,代码来源:CmdItemInfo.php
示例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");
}
开发者ID:DWWf,项目名称:pocketmine-plugins,代码行数:37,代码来源:FastTransfer.php
示例16: onCommand
public function onCommand(CommandSender $sender, Command $cmd, $label, array $args)
{
if ($cmd->getName() != "heal") {
return false;
}
if (count($args) == 0) {
if (!MPMU::inGame($sender)) {
return true;
}
$sender->setHealth($sender->getMaxHealth());
$sender->sendMessage(mc::_("You have been healed"));
return true;
}
if (($patient = MPMU::getPlayer($sender, $args[0])) === null) {
return true;
}
if (isset($args[1]) && is_numeric($args[1])) {
$health = $patient->getHealth() + intval($args[1]);
if ($health > $patient->getMaxHealth()) {
$health = $patient->getMaxHealth();
}
} else {
$health = $patient->getMaxHealth();
}
$patient->setHealth($health);
$sender->sendMessage(mc::_("%1% was healed.", $args[0]));
return true;
}
开发者ID:DWWf,项目名称:pocketmine-plugins,代码行数:28,代码来源:CmdHeal.php
示例17: onCommand
public function onCommand(CommandSender $sender, Command $cmd, $label, array $args)
{
if ($cmd->getName() != "as") {
return false;
}
if (count($args) < 2) {
$sender->sendMessage(mc::_("Must specified a player and a command"));
return false;
}
$player = $this->owner->getServer()->getPlayer($n = array_shift($args));
if (!$player) {
$sender->sendMessage(mc::_("Player %1% not found", $n));
return true;
}
if ($args[0] == 'chat' || $args[0] == 'say') {
array_shift($args);
$chat = implode(" ", $args);
$this->owner->getServer()->getPluginManager()->callEvent($ev = new PlayerChatEvent($player, $chat));
if (!$ev->isCancelled()) {
if (MPMU::apiVersion("1.12.0")) {
$s = $this->owner->getServer();
$s->broadcastMessage($s->getLanguage()->translateString($ev->getFormat(), [$ev->getPlayer()->getDisplayName(), $ev->getMessage()]), $ev->getRecipients());
} else {
$this->owner->getServer()->broadcastMessage(sprintf($ev->getFormat(), $ev->getPlayer()->getDisplayName(), $ev->getMessage()), $ev->getRecipients());
}
}
} else {
$cmdline = implode(' ', $args);
$sender->sendMessage(mc::_("Running command as %1%", $n));
$this->owner->getServer()->dispatchCommand($player, $cmdline);
}
return true;
}
开发者ID:0-DevMatthew-0,项目名称:pocketmine-plugins,代码行数:33,代码来源:CmdAs.php
示例18: processCmd
public function processCmd($msg, $sender)
{
if (preg_match('/^\\s*!!/', $msg)) {
$msg = trim(preg_replace('/^\\s*!!\\s*/', '', $msg));
// Match !
$last = $this->owner->getState("RepeatMgr", $sender, false);
if ($last === false) {
$sender->sendMessage(mc::_("You do not have any recorded previous command"));
return false;
}
// Just the previous command...
if ($msg == "") {
return $last;
}
if (is_numeric($msg)) {
// We need to replace the last word with $msg....
$words = preg_split('/\\s+/', $last);
if (count($words) == 1) {
// Only a single world, we append the number...
$newmsg = $last . " " . $msg;
} else {
if (is_numeric($words[count($words) - 1])) {
// Exchange the last word (page count)
$words[count($words) - 1] = $msg;
$newmsg = implode(" ", $words);
} else {
// Last word wasn't a number... append one
$newmsg = $last . " " . $msg;
}
}
} elseif ($msg == "/" && substr($last, 0, 1) != "/") {
// Forgotten "/"
$newmsg = "/" . $last;
} elseif (substr($msg, 0, 1) == "^") {
// Do we need space?
if (preg_match('/^\\s+/', $msg)) {
$newmsg = trim(substr($msg, 1)) . " " . $last;
} else {
$newmsg = trim(substr($msg, 1)) . $last;
}
} else {
$words = preg_split('/\\s+/', $msg, 2);
if (count($words) > 1 && stristr($last, $words[0]) !== false) {
// Replace string
$newmsg = str_ireplace($words[0], $words[1], $last);
} else {
// Add string...
$newmsg = $last . ' ' . $msg;
}
}
if (!$sender instanceof Player) {
$sender->sendMessage(">> {$newmsg}");
}
$last = $this->owner->setState("RepeatMgr", $sender, $newmsg);
return $newmsg;
}
$last = $this->owner->setState("RepeatMgr", $sender, $msg);
return false;
}
开发者ID:DWWf,项目名称:pocketmine-plugins,代码行数:59,代码来源:RepeatMgr.php
示例19: __construct
public function __construct($owner)
{
parent::__construct($owner);
PermUtils::add($this->owner, "gb.cmd.echo", "echo command", "true");
PermUtils::add($this->owner, "gb.cmd.rem", "remark command", "true");
$this->enableCmd("echo", ["description" => mc::_("display text"), "usage" => mc::_("/echo [text]"), "permission" => "gb.cmd.echo"]);
$this->enableCmd("rem", ["description" => mc::_("don't display text"), "usage" => mc::_("/rem [text]"), "permission" => "gb.cmd.rem"]);
}
开发者ID:edwinyoo44,项目名称:pocketmine-plugins,代码行数:8,代码来源:CmdEcho.php
示例20: onSCommand
public function onSCommand(CommandSender $c, Command $cc, $scmd, $data, array $args)
{
if (count($args) != 0) {
return false;
}
$c->sendMessage(mc::_("Version: %1%", MPMU::version()));
return true;
}
开发者ID:jigibbs123,项目名称:pocketmine-plugins,代码行数:8,代码来源:Version.php
注:本文中的aliuly\common\mc类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论