本文整理匯總了PHP中pocketmine\event\player\PlayerGameModeChangeEvent::getPlayer方法的典型用法代碼示例。如果您正苦於以下問題:PHP PlayerGameModeChangeEvent::getPlayer方法的具體用法?PHP PlayerGameModeChangeEvent::getPlayer怎麽用?PHP PlayerGameModeChangeEvent::getPlayer使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pocketmine\event\player\PlayerGameModeChangeEvent
的用法示例。
在下文中一共展示了PlayerGameModeChangeEvent::getPlayer方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: onPlayerGameModeChange
public function onPlayerGameModeChange(PlayerGameModeChangeEvent $event)
{
if ($event->isCancelled()) {
return;
}
$p = $event->getPlayer();
if (!$p->hasPermission("debe.worldinventory.change")) {
return;
}
$n = strtolower($p->getName());
$g = $event->getNewGamemode();
$wn = strtolower($p->getLevel()->getFolderName());
$this->createInv($p, $wn);
$wiw = $this->wi[$n]["Worlds"][$wn];
$g = $event->getNewGamemode();
if ($g == 1) {
$inv = $p->getInventory();
foreach ($inv->getContents() as $i) {
if ($i->getID() !== 0 and $i->getCount() > 0) {
$wiw[] = $i->getID() . ":" . $i->getDamage() . ":" . $i->getCount();
}
}
$inv->clearAll();
} else {
$this->gmc[$n] = $wiw;
$wiw = [];
}
$this->wi[$n]["Worlds"][$wn] = $wiw;
$this->saveYml();
$p->sendMessage("[WorldInventory] " . ($this->isKorean() ? "인벤토리가 교체되었습니다." : "Inventory is change ") . " : GameModeChange");
}
示例2: onGameModeChange
/**
* @param PlayerGameModeChangeEvent $event
*/
public function onGameModeChange(PlayerGameModeChangeEvent $event)
{
$player = $event->getPlayer();
$newGamemode = $event->getNewGamemode();
switch ($newGamemode) {
case 0:
$this->plugin->getServer()->getScheduler()->scheduleDelayedTask(new GISPluginTask($this->plugin, "loadArmorContents", array($player)), 15);
$this->plugin->getServer()->getScheduler()->scheduleDelayedTask(new GISPluginTask($this->plugin, "loadContents", array($player)), 15);
break;
case 1:
$this->plugin->saveArmorContents($player);
$this->plugin->saveContents($player);
break;
default:
break;
}
}
示例3: onGmChange
public function onGmChange(PlayerGameModeChangeEvent $ev)
{
$player = $ev->getPlayer();
$newgm = $ev->getNewGamemode();
$oldgm = $player->getGamemode();
if (($newgm == 1 || $newgm == 3) && ($oldgm == 0 || $oldgm == 2)) {
// We need to save inventory
$this->saveInv($player);
}
if (($newgm == 0 || $newgm == 2) && ($oldgm == 1 || $oldgm == 3)) {
// Need to restore inventory (but later!)
$inv = $this->getState($player, null);
if ($inv == null) {
return;
}
// No inventory on file!
$this->owner->getServer()->getScheduler()->scheduleDelayedTask(new PluginCallbackTask($this->owner, [$this, "loadInv"], [$player]), self::TICKS);
}
}
示例4: onPlayerGameModeChange
/**
*
* @param PlayerGameModeChangeEvent $event
*/
public function onPlayerGameModeChange(PlayerGameModeChangeEvent $event)
{
$this->showGameMode($event->getPlayer());
}
示例5: onPlayerGameModeChange
/**
* @param PlayerGameModeChangeEvent $event
* @priority HIGHEST
* @ignoreCancelled true
*/
public function onPlayerGameModeChange(PlayerGameModeChangeEvent $event)
{
if (!$this->plugin->getStorage()->getShield($event->getPlayer()->getLevel())->isAllowed(Shield::GAMEMODE_CHANGING)) {
$event->setCancelled(true);
$event->getPlayer()->sendTip($this->plugin->getConfig()->get("gamemodeChangeNotAllowed"));
}
}
示例6: PlayerGameModeChangeEvent
public function PlayerGameModeChangeEvent(PlayerGameModeChangeEvent $event)
{
$event->getPlayer()->getInventory()->addItem(Item::get(1, 0, 1));
$event->getPlayer()->getInventory()->clearAll();
}
示例7: onGameModeChange
public function onGameModeChange(PlayerGameModeChangeEvent $event)
{
$playerName = $event->getPlayer()->getName();
//$chunkX=131;
//$chunkZ=132;
foreach ($this->joinedplayers as $key => $value) {
if ($key == $playerName) {
$event->getPlayer()->sendMessage("What are you going to do?=_=Be good buys!");
$event->setCancelled();
//$rere=new SimpleChunk($chunkX,$chunkZ);
}
}
}
示例8: onPlayerGameModeChange
public function onPlayerGameModeChange(PlayerGameModeChangeEvent $event)
{
$Player = $event->getPlayer();
$Level = $Player->getLevel();
if (!$this->plugin->game || $this->plugin->game->level_name != $Level->getFolderName()) {
return;
}
$event->setCancelled(!in_array($event->getNewGamemode(), [0, 3]));
}