本文整理汇总了PHP中pocketmine\entity\Effect类的典型用法代码示例。如果您正苦于以下问题:PHP Effect类的具体用法?PHP Effect怎么用?PHP Effect使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Effect类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onPlayerMove
public function onPlayerMove(PlayerMoveEvent $event)
{
$player = $event->getPlayer();
$world = $player->getLevel();
$block = $world->getBlock($player->floor()->subtract(0, 1));
if ($world->getName() == $this->getHotBlock()->getConfig()->get("world")) {
switch ($block->getId()) {
case Block::PLANKS:
$player->sendTip("§aYou're safe!");
break;
case Block::END_STONE:
$player->sendTip("§eGo!");
break;
case Block::NETHERRACK:
$player->sendTip("§cYou'll poisoned!");
$effect = Effect::getEffect(Effect::POISON);
$effect->setVisible(true);
$effect->setDuration(50);
$player->addEffect($effect);
break;
case Block::QUARTZ_BLOCK:
if (count($world->getPlayers()) < $this->getHotBlock()->getConfig()->get("players")) {
$player->sendTip("§cThere must be " . $this->getHotBlock()->getConfig()->get("players") . "players online");
} else {
$player->sendTip("§eYou're standing on the §l§cHot§6Block§r§e! §bMove!");
$this->getHotBlock()->getEconomy()->addMoney($player, 1, false, "HotBlock");
$player->sendPopup("§eYou have §a" . $this->getHotBlock()->getEconomy()->myMoney($player) . " §bCoins");
}
break;
}
}
}
示例2: onPlayerRespawned
public function onPlayerRespawned(PlayerRespawnEvent $event)
{
$p = $event->getPlayer();
$level = $p->getLevel();
$light = new AddEntityPacket();
$light->type = 93;
$light->eid = Entity::$entityCount++;
$light->metadata = array();
$light->speedX = 9;
$light->speedY = 0;
$light->speedZ = -9;
$light->yaw = $p->getYaw();
$light->pitch = $p->getPitch();
$light->x = $p->x;
$light->y = $p->y;
$light->z = $p->z;
foreach ($level->getPlayers() as $pl) {
$pl->dataPacket($light);
$pl->addEffect(Effect::getEffect(Effect::SPEED)->setAmplifier(3)->setDuration(30000));
$pl->setGamemode(2);
$pl->getInventory()->addItem(new Item(Item::COOKIE, 0, 64));
$pl->getInventory()->addItem(new Item(Item::SLIMEBALL, 0, 1));
$pl->getInventory()->addItem(new Item(Item::COAL, 0, 1));
$pl->getInventory()->addItem(new Item(Item::GUNPOWDER, 0, 1));
}
}
示例3: execute
public function execute(CommandSender $sender, $alias, array $args)
{
if ($this->testPermission($sender)) {
return false;
}
if (!$sender instanceof Player || count($args) < 1) {
$this->sendUsage($sender, $alias);
return false;
}
if (!is_numeric($args[0])) {
$sender->sendMessage(TextFormat::RED . "[Error] Please provide a valid value");
return false;
}
$player = $sender;
if (isset($args[1]) && !($player = $this->getAPI()->getPlayer($args[1]))) {
$sender->sendMessage(TextFormat::RED . "[Error] Player not found");
return false;
}
if ((int) $args[0] === 0) {
$player->removeEffect(Effect::SPEED);
} else {
$effect = Effect::getEffect(Effect::SPEED);
$effect->setAmplifier($args[0]);
$effect->setDuration(PHP_INT_MAX);
$player->addEffect($effect);
}
$sender->sendMessage(TextFormat::YELLOW . "Speed amplified by " . TextFormat::WHITE . $args[0]);
return true;
}
示例4: onPlayerDeathEvent
public function onPlayerDeathEvent(PlayerDeathEvent $event)
{
$cfg = $this->getConfig();
$duration = $cfg->get("Duration");
$particles = $cfg->get("Particles");
$amplifier = $cfg->get("Amplifier");
$give = $cfg->get("Add-Money");
$lose = $cfg->get("Lost-Money");
$id = $cfg->get("Effect-ID");
$effect = Effect::getEffect($id);
$effect->setVisible($particles);
$effect->setAmplifier($amplifier);
$effect->setDuration($duration);
$player = $event->getEntity();
$name = strtolower($player->getName());
if ($player instanceof Player) {
$cause = $player->getLastDamageCause();
if ($cause instanceof EntityDamageByEntityEvent) {
$damager = $cause->getDamager();
if ($damager instanceof Player) {
$damager->sendMessage("You killed " . $player . ".\nYou earn \$" . $give . " for getting a kill and an effect!");
$damager->addEffect($effect);
$this->money->addMoney($damager, $give);
$player->sendMessage("You were killed by " . $damager);
$this->money->reduceMoney($player, $lose);
}
}
}
}
示例5: parseEffectLine
private function parseEffectLine($txt)
{
$txt = preg_split('/\\s*:\\s*/', $txt);
if (count($txt) == 0 || count($txt) > 3) {
return null;
}
if (!isset($txt[1]) || empty($txt[1])) {
$txt[1] = 60;
}
if (!isset($txt[2]) || empty($txt[2])) {
$txt[2] = 1;
}
if (is_numeric($txt[0])) {
$effect = Effect::getEffect($txt[0]);
} else {
$effect = Effect::getEffectByName($txt[0]);
}
if ($effect === null) {
return null;
}
$effect->setDuration($txt[1] * 20);
$effect->setAmplifier($txt[2]);
$effect->setVisible(true);
return $effect;
}
示例6: onHurt
public function onHurt(EntityDamageEvent $event)
{
if ($event instanceof EntityDamageByEntityEvent) {
if ($event->getDamager()->getInventory()->getItemInHand()->getId() === 276) {
$event->getEntity()->addEffect(Effect::getEffect($this->getConfig()->get("DiamondSwordEffect"))->setAmplifier($this->getConfig()->get("DiamondSwordAmp"))->setDuration($this->getConfig()->get("DiamondSwordTime"))->setVisible(false));
}
}
}
示例7: eat
public function eat(PlayerItemConsumeEvent $ev)
{
$p = $ev->getPlayer();
if ($ev->getItem()->getId() === 322) {
$p->addEffect(Effect::getEffect(10)->setAmplifier(4)->setDuration(100)->setVisible(true));
$p->addEffect(Effect::getEffect(21)->setAmplifier(2)->setDuration(20 * 120)->setVisible(true));
}
}
示例8: execute
public function execute(CommandSender $sender, $currentAlias, array $args)
{
if (!$this->testPermission($sender)) {
return \true;
}
if (\count($args) < 2) {
return \true;
}
$player = $sender->getServer()->getPlayer($args[0]);
if ($player === \null) {
return \true;
}
if (\strtolower($args[1]) === "clear") {
foreach ($player->getEffects() as $effect) {
$player->removeEffect($effect->getId());
}
return \true;
}
$effect = Effect::getEffectByName($args[1]);
if ($effect === \null) {
$effect = Effect::getEffect((int) $args[1]);
}
if ($effect === \null) {
return \true;
}
$duration = 300;
$amplification = 0;
if (\count($args) >= 3) {
$duration = (int) $args[2];
if (!$effect instanceof InstantEffect) {
$duration *= 20;
}
} elseif ($effect instanceof InstantEffect) {
$duration = 1;
}
if (\count($args) >= 4) {
$amplification = (int) $args[3];
}
if (\count($args) >= 5) {
$v = \strtolower($args[4]);
if ($v === "on" or $v === "true" or $v === "t" or $v === "1") {
$effect->setVisible(\false);
}
}
if ($duration === 0) {
if (!$player->hasEffect($effect->getId())) {
if (\count($player->getEffects()) === 0) {
} else {
}
return \true;
}
$player->removeEffect($effect->getId());
} else {
$effect->setDuration($duration)->setAmplifier($amplification);
$player->addEffect($effect);
}
return \true;
}
示例9: getAdditionalEffects
public function getAdditionalEffects() : array
{
$chance = mt_rand(0, 100);
if ($chance >= 20) {
return [Effect::getEffect(Effect::HUNGER)->setDuration(30 * 20)];
} else {
return [];
}
}
示例10: startGame
public function startGame()
{
$this->currentStatus = self::STATUS_PREPARING;
$this->roundTick = 0;
foreach ($this->player as $playerData) {
$playerData["player"]->getInventory()->addItem(Item::get(self::SHOVEL));
$playerData["player"]->addEffect(Effect::getEffect(Effect::JUMP)->setAmplifier(3)->setDuration(36000));
$playerData["player"]->addEffect(Effect::getEffect(Effect::SPEED)->setAmplifier(3)->setDuration(36000));
}
}
示例11: onItemHeld
public function onItemHeld(PlayerItemHeldEvent $ev)
{
$player = $ev->getPlayer();
if ($ev->getPlayer()->getInventory()->getItemInHand()->getId() === 369) {
$ev->getPlayer()->sendTip(TextFormat::RED . "Ezero Enabled!");
$player->addEffect(Effect::getEffect(11)->setAmplifier(0)->setDuration(999999)->setVisible(false));
} else {
$player->removeEffect(11);
}
}
示例12: onInteract
/**
* @param PlayerInteractEvent $ev
*/
public function onInteract(PlayerInteractEvent $ev)
{
if ($ev->getItem()->getId() == 296) {
$player = $ev->getPlayer();
$effect = Effect::getEffect(5);
$effect->setDuration(20 * 1000);
$effect->setAmplifier(1);
$player->getEffect($effect);
$effect1 = Effect::getEffect(4);
$effect1->setDuration(20 * 1000);
$effect1->setAmplifier(1);
$player->getEffect($effect1);
}
}
示例13: onMove
public function onMove(PlayerMoveEvent $event)
{
$bubble = new BubbleParticle(new Vector3($event->getPlayer()->getX(), $event->getPlayer()->getY() + 0.5, $event->getPlayer()->getZ()));
$critical = new CriticalParticle(new Vector3($event->getPlayer()->getX(), $event->getPlayer()->getY() + 0.5, $event->getPlayer()->getZ()));
$enchant = new EnchantParticle(new Vector3($event->getPlayer()->getX(), $event->getPlayer()->getY() + 0.5, $event->getPlayer()->getZ()));
$flame = new FlameParticle(new Vector3($event->getPlayer()->getX(), $event->getPlayer()->getY() + 0.5, $event->getPlayer()->getZ()));
$heart = new HeartParticle(new Vector3($event->getPlayer()->getX(), $event->getPlayer()->getY() + 0.5, $event->getPlayer()->getZ()));
$ink = new InkParticle(new Vector3($event->getPlayer()->getX(), $event->getPlayer()->getY() + 0.5, $event->getPlayer()->getZ()));
$lava = new LavaDripParticle(new Vector3($event->getPlayer()->getX(), $event->getPlayer()->getY() + 0.5, $event->getPlayer()->getZ()));
$portal = new PortalParticle(new Vector3($event->getPlayer()->getX(), $event->getPlayer()->getY() + 0.5, $event->getPlayer()->getZ()));
$smoke = new SmokeParticle(new Vector3($event->getPlayer()->getX(), $event->getPlayer()->getY() + 0.5, $event->getPlayer()->getZ()));
$water = new WaterDripParticle(new Vector3($event->getPlayer()->getX(), $event->getPlayer()->getY() + 0.5, $event->getPlayer()->getZ()));
$player = $event->getPlayer();
$cfg = $this->getConfig();
$block = $event->getPlayer()->getLevel()->getBlock($event->getPlayer()->floor()->subtract(0, 1));
if ($block instanceof Block) {
$id = $block->getId();
$meta = $block->getDamage();
if ($cfg->exists($id . ":" . $meta)) {
$effects = $cfg->get($id . ":" . $meta);
foreach ($effects as $effect) {
$player->addEffect(Effect::getEffect((int) $effect["effect"])->setAmplifier((int) $effect["amplifier"])->setDuration((int) $effect["duration"] * 20)->setVisible((int) $effect["visible"]));
if ($effect["particle"] === "none") {
//
} elseif ($effect["particle"] === "bubble") {
$player->getLevel()->addParticle($bubble);
} elseif ($effect["particle"] === "critical") {
$player->getLevel()->addParticle($critical);
} elseif ($effect["particle"] === "enchant") {
$player->getLevel()->addParticle($enchant);
} elseif ($effect["particle"] === "flame") {
$player->getLevel()->addParticle($flame);
} elseif ($effect["particle"] === "heart") {
$player->getLevel()->addParticle($heart);
} elseif ($effect["particle"] === "ink") {
$player->getLevel()->addParticle($ink);
} elseif ($effect["particle"] === "lava") {
$player->getLevel()->addParticle($lava);
} elseif ($effect["particle"] === "portal") {
$player->getLevel()->addParticle($portal);
} elseif ($effect["particle"] === "smoke") {
$player->getLevel()->addParticle($smoke);
} elseif ($effect["particle"] === "water") {
$player->getLevel()->addParticle($water);
}
}
}
}
}
示例14: onHurt
public function onHurt(EntityDamageEvent $event)
{
if ($event instanceof EntityDamageByEntityEvent) {
$damager = $event->getDamager();
$player = $event->getEntity();
if ($damager instanceof Player) {
if ($damager->getInventory()->getItemInHand()->getId() === 280) {
$event->setKnockBack($this->getConfig()->get("KnockBack-Power"));
$player->addEffect(Effect::getEffect(20)->setAmplifier(1)->setDuration(50)->setVisible(true));
$level = $damager->getLevel();
$level->addSound(new AnvilFallSound($damager->getLocation()));
}
}
}
}
示例15: onRun
public function onRun($tick)
{
$this->plugin->gameduration -= 1;
foreach ($this->plugin->getServer()->getOnlinePlayers() as $p) {
if ($this->plugin->gameduration == 612) {
$players = $this->plugin->getServer()->getOnlinePlayers();
$effect = Effect::getEffect(1);
$effect->setDuration(99999999);
$effect->setAmplifier(0);
$effect->setVisible(false);
$ran1 = $this->plugin->getServer()->getPlayer($this->plugin->getConfig()->get("it1"));
$ran2 = $this->plugin->getServer()->getPlayer($this->plugin->getConfig()->get("it2"));
$ran3 = $this->plugin->getServer()->getPlayer($this->plugin->getConfig()->get("it3"));
$ran1->addEffect($effect);
$ran2->addEffect($effect);
$ran3->addEffect($effect);
$ran1->setNameTag(TextFormat::RED . "[RUN AWAY FROM ME]");
$ran2->setNameTag(TextFormat::RED . "[RUN AWAY FROM ME]");
$ran3->setNameTag(TextFormat::RED . "[RUN AWAY FROM ME]");
$p->getInventory()->addItem(Item::get(280, 0, 1));
$ran1->getInventory()->addItem(Item::get(276, 0, 1));
$ran2->getInventory()->addItem(Item::get(276, 0, 1));
$ran3->getInventory()->addItem(Item::get(276, 0, 1));
$ran1->getInventory()->removeItem(Item::get(280, 0, 1));
$ran2->getInventory()->removeItem(Item::get(280, 0, 1));
$ran3->getInventory()->removeItem(Item::get(280, 0, 1));
$ran3->sendMessage("Seems like your it! Tag Players with the sword.");
$ran2->sendMessage("Seems like your it! Tag Players with the sword.");
$ran1->sendMessage("Seems like your it! Tag Players with the sword.");
$ran1->teleport(new Vector3(159, 4, 170));
$ran2->teleport(new Vector3(159, 4, 170));
$ran3->teleport(new Vector3(159, 4, 170));
$this->plugin->getServer()->dispatchCommand(new ConsoleCommandSender(), "whitelist on");
} elseif ($this->plugin->gameduration == 599) {
$this->plugin->getServer()->getPlayer(strtolower($this->plugin->getConfig()->get("it1")))->teleport(new Vector3(153, 4, 128));
$this->plugin->getServer()->getPlayer(strtolower($this->plugin->getConfig()->get("it2")))->teleport(new Vector3(153, 4, 128));
$this->plugin->getServer()->getPlayer(strtolower($this->plugin->getConfig()->get("it3")))->teleport(new Vector3(153, 4, 128));
}
}
if ($this->plugin->gameduration == 0) {
$p->kick("Game Over");
}
}