本文整理汇总了PHP中pocketmine\event\block\SignChangeEvent::setCancelled方法的典型用法代码示例。如果您正苦于以下问题:PHP SignChangeEvent::setCancelled方法的具体用法?PHP SignChangeEvent::setCancelled怎么用?PHP SignChangeEvent::setCancelled使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pocketmine\event\block\SignChangeEvent
的用法示例。
在下文中一共展示了SignChangeEvent::setCancelled方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: signPlace
public function signPlace(SignChangeEvent $event)
{
if ($event->getPlayer()->isOp()) {
return;
}
$message = "";
foreach ($event->getLines() as $line) {
$message .= $line;
}
$find = $this->checkSwearWord($message);
if ($find != null) {
$event->getPlayer()->sendMessage(TextFormat::RED . $this->get("some-badwords-found") . ": " . $message . " ( " . $find . " ) ");
$event->getPlayer()->sendMessage(TextFormat::RED . $this->get("you-need-to-change-your-name"));
$event->setCancelled();
$this->cautionNotice($event->getPlayer(), $message . " ( " . $find . " ) ");
return;
}
if (isset($this->oldSign[$event->getPlayer()->getName()])) {
$find = $this->checkSwearWord($this->oldSign[$event->getPlayer()->getName()] . $message);
if ($find != null) {
$event->getPlayer()->sendMessage(TextFormat::RED . $this->get("some-badwords-found") . ": " . $find);
$event->getPlayer()->sendMessage(TextFormat::RED . $this->get("you-need-to-change-your-name"));
$event->setCancelled();
$this->cautionNotice($event->getPlayer(), $find);
return;
}
}
$this->oldSign[$event->getPlayer()->getName()] = $message;
}
示例2: onSign
public function onSign(SignChangeEvent $event)
{
if ($event->getLine(0) == "[워프]" or $event->getLine(0) == "워프") {
$player = $event->getPlayer();
if (!$player->hasPermission("nyduscanal.commands.addwarp")) {
$player->sendMessage(TextFormat::DARK_AQUA . "포탈생성권한이 없습니다.");
$event->setCancelled();
return false;
}
if (!isset(explode("[", $event->getLine(1))[1])) {
if (!isset($this->NydusCanal_List["warp"][$event->getLine(1)])) {
$player->sendMessage(TextFormat::DARK_AQUA . "해당하는 워프포인트가 없습니다.");
$event->setCancelled();
return false;
}
}
$event->setLine(0, "[워프]");
if (isset($this->NydusCanal_List["warp"][$event->getLine(1)]["price"])) {
if (isset(explode("+", $this->NydusCanal_List["warp"][$event->getLine(1)]["price"])[1])) {
$event->setLine(2, "보상:" . explode("+", $this->NydusCanal_List["warp"][$event->getLine(1)]["price"])[1] . "\$");
} else {
$event->setLine(2, "비용:" . $this->NydusCanal_List["warp"][$event->getLine(1)]["price"] . "\$");
}
}
$player->sendMessage("포탈생성이 완료되었습니다.");
$block = $event->getBlock();
$this->NydusCanal_List["signs"][$player->getLevel()->getFolderName()][$block->x . ":" . $block->y . ":" . $block->z] = $event->getLine(1);
if ($event->getLine(2) == "x") {
$this->NydusCanal_List["touch-signs"][$player->getLevel()->getFolderName()][$block->x . ":" . $block->y . ":" . $block->z] = 1;
$event->setLine(2, "");
}
}
}
示例3: onSignChange
/**
* @param SignChangeEvent $event
* @priority HIGHEST
* @ignoreCancelled true
*/
public function onSignChange(SignChangeEvent $event)
{
if (!$this->plugin->getStorage()->getShield($event->getBlock()->getLevel())->isAllowed(Shield::EDITING)) {
$event->setCancelled(true);
$event->getPlayer()->sendTip($this->plugin->getConfig()->get("signChangeNotAllowed"));
}
}
示例4: onSignChange
public function onSignChange(SignChangeEvent $event)
{
if (strtolower(TextFormat::clean($event->getLine(0))) === "[advancedkits]" and !$event->getPlayer()->hasPermission("advancedkits.admin")) {
$event->getPlayer()->sendMessage($this->ak->langManager->getTranslation("no-perm-sign"));
$event->setCancelled();
}
}
示例5: onSignChange
public function onSignChange(SignChangeEvent $event)
{
if ($event->getLine(0) === $this->getPlugin()->getConfig()->get('sign-trigger')) {
if ($event->getPlayer()->hasPermission("battlekits.sign.create")) {
if (!empty($event->getLine(1))) {
$event->getPlayer()->sendMessage("You have successfully created kit sign.");
} else {
$event->getPlayer()->sendMessage("You must set a kit.");
$event->setCancelled();
}
} else {
$event->getPlayer()->sendMessage("You don't have permission to make kit signs.");
$event->setCancelled();
}
}
}
示例6: onSignChange
/**
* Sign change
*
* @param SignChangeEvent $event
*/
public function onSignChange(SignChangeEvent $event)
{
if (strtolower($event->getPlayer()->getLevel()->getName()) === strtolower($this->plugin->hubLevelName)) {
$player = $event->getPlayer();
$block = $event->getBlock();
$line1 = $event->getLine(0);
$line2 = $event->getLine(1);
$line3 = $event->getLine(2);
$line4 = $event->getLine(3);
if (!$event->getPlayer()->isOp()) {
$event->getPlayer()->sendMessage("[HG] You are not authorized to use this command.");
$event->setCancelled(true);
} else {
if ($line1 != null && $line1 === "hungergame") {
if ($line2 != null && $line2 === "arena") {
if ($line3 != null && $line3 === "join") {
$arenaName = $line4;
$this->plugin->arenaManager->handleSetSignJoin($player, $arenaName, $block);
}
}
}
if ($line1 != null && $line1 === "hungergame") {
if ($line2 != null && $line2 === "arena") {
if ($line3 != null && $line3 === "vote") {
$arenaName = $line4;
$this->plugin->arenaManager->handleSetSignVote($player, $arenaName, $block);
}
}
}
if ($line1 != null && $line1 === "hungergame") {
if ($line2 != null && $line2 === "arena") {
if ($line3 != null && $line3 === "exit") {
$arenaName = $line4;
$this->plugin->arenaManager->handleSetSignExit($player, $arenaName, $block);
}
}
}
if ($line1 != null && $line1 === "hungergame") {
if ($line2 != null && $line2 === "arena") {
if ($line3 != null && $line3 === "stat") {
$arenaName = $line4;
$this->plugin->arenaManager->handleSetSignStat($player, $arenaName, $block);
}
}
}
}
}
}
示例7: onSignChange
public function onSignChange(SignChangeEvent $event)
{
$player = $event->getPlayer();
if ($player->hasPermission("worldstats.place")) {
if (TextFormat::clean(strtolower(trim($event->getLine(0)))) === strtolower(trim($this->sign->get("sign_trigger"))) || TextFormat::clean(strtolower(trim($event->getLine(0)))) === strtolower(trim($this->sign->get("sign_final_change")))) {
$world = $event->getLine(1);
$level = $this->getServer()->getLevelByName($world);
if ($level instanceof Level) {
$players = count($level->getPlayers());
$event->setLine(0, TextFormat::GREEN . $this->sign->get("sign_final_change"));
$event->setLine(2, TextFormat::YELLOW . $players . TextFormat::RED . " players");
} else {
$event->setLine(0, TextFormat::DARK_RED . "()()()()()()");
$event->setLine(1, TextFormat::DARK_RED . "*****");
$event->setLine(2, TextFormat::RED . "World Name Error");
$event->setLine(3, TextFormat::DARK_RED . "******");
}
}
} else {
$player->sendMessage(TextFormat::RED . "You do not have permission to create a World Status sign.");
$event->setCancelled(true);
}
}
示例8: handleDataPacket
//.........这里部分代码省略.........
$this->level->setBlock($block, new Air());
break;
}
$this->lastBreak = microtime(true);
break;
case PlayerActionPacket::ACTION_ABORT_BREAK:
$this->lastBreak = PHP_INT_MAX;
break;
case PlayerActionPacket::ACTION_RELEASE_ITEM:
if ($this->startAction > -1 and $this->getDataFlag(self::DATA_FLAGS, self::DATA_FLAG_ACTION)) {
if ($this->inventory->getItemInHand()->getId() === Item::BOW) {
$bow = $this->inventory->getItemInHand();
if ($this->isSurvival() and !$this->inventory->contains(Item::get(Item::ARROW, null))) {
$this->inventory->sendContents($this);
break;
}
$arrow = false;
foreach ($this->inventory->getContents() as $item) {
if ($item->getId() == Item::ARROW) {
$arrow = $item;
}
}
if ($arrow === false and $this->isCreative()) {
$arrow = Item::get(Item::ARROW, 0, 1);
} elseif ($arrow === false) {
break;
}
$nbt = new CompoundTag("", ["Pos" => new ListTag("Pos", [new DoubleTag("", $this->x), new DoubleTag("", $this->y + $this->getEyeHeight()), new DoubleTag("", $this->z)]), "Motion" => new ListTag("Motion", [new DoubleTag("", -sin($this->yaw / 180 * M_PI) * cos($this->pitch / 180 * M_PI)), new DoubleTag("", -sin($this->pitch / 180 * M_PI)), new DoubleTag("", cos($this->yaw / 180 * M_PI) * cos($this->pitch / 180 * M_PI))]), "Rotation" => new ListTag("Rotation", [new FloatTag("", $this->yaw), new FloatTag("", $this->pitch)]), "Fire" => new ShortTag("Fire", $this->isOnFire() ? 45 * 60 : 0), "Potion" => new ShortTag("Potion", $arrow->getDamage())]);
$diff = $this->server->getTick() - $this->startAction;
$p = $diff / 20;
$f = min(($p ** 2 + $p * 2) / 3, 1) * 2;
$ev = new EntityShootBowEvent($this, $bow, Entity::createEntity("Arrow", $this->chunk, $nbt, $this, $f == 2 ? true : false), $f);
if ($f < 0.1 or $diff < 5) {
$ev->setCancelled();
}
$this->server->getPluginManager()->callEvent($ev);
if ($ev->isCancelled()) {
$ev->getProjectile()->kill();
$this->inventory->sendContents($this);
} else {
$ev->getProjectile()->setMotion($ev->getProjectile()->getMotion()->multiply($ev->getForce()));
if ($this->isSurvival()) {
$this->inventory->removeItem(Item::get(Item::ARROW, $arrow->getDamage(), 1));
$bow->setDamage($bow->getDamage() + 1);
if ($bow->getDamage() >= 385) {
$this->inventory->setItemInHand(Item::get(Item::AIR, 0, 0));
} else {
$this->inventory->setItemInHand($bow);
}
}
if ($ev->getProjectile() instanceof Projectile) {
$this->server->getPluginManager()->callEvent($projectileEv = new ProjectileLaunchEvent($ev->getProjectile()));
if ($projectileEv->isCancelled()) {
$ev->getProjectile()->kill();
} else {
$ev->getProjectile()->spawnToAll();
$this->level->addSound(new LaunchSound($this), $this->getViewers());
}
} else {
$ev->getProjectile()->spawnToAll();
}
}
}
} elseif ($this->inventory->getItemInHand()->getId() === Item::BUCKET and $this->inventory->getItemInHand()->getDamage() === 1) {
//Milk!
$this->server->getPluginManager()->callEvent($ev = new PlayerItemConsumeEvent($this, $this->inventory->getItemInHand()));
示例9: handleDataPacket
//.........这里部分代码省略.........
$this->craftingType = 0;
$packet->eid = $this->id;
$pos = new Vector3($packet->x, $packet->y, $packet->z);
switch ($packet->action) {
case 0:
//Start break
if ($pos->distanceSquared($this) > 10000) {
break;
}
$target = $this->level->getBlock($pos);
$ev = new PlayerInteractEvent($this, $this->inventory->getItemInHand(), $target, $packet->face, $target->getId() === 0 ? PlayerInteractEvent::LEFT_CLICK_AIR : PlayerInteractEvent::LEFT_CLICK_BLOCK);
$this->getServer()->getPluginManager()->callEvent($ev);
if ($ev->isCancelled()) {
$this->inventory->sendHeldItem($this);
break;
}
$this->lastBreak = microtime(true);
break;
case 5:
//Shot arrow
if ($this->startAction > -1 and $this->getDataFlag(self::DATA_FLAGS, self::DATA_FLAG_ACTION)) {
if ($this->inventory->getItemInHand()->getId() === Item::BOW) {
$bow = $this->inventory->getItemInHand();
if ($this->isSurvival() and !$this->inventory->contains(Item::get(Item::ARROW, 0, 1))) {
$this->inventory->sendContents($this);
break;
}
$nbt = new Compound("", ["Pos" => new Enum("Pos", [new Double("", $this->x), new Double("", $this->y + $this->getEyeHeight()), new Double("", $this->z)]), "Motion" => new Enum("Motion", [new Double("", -sin($this->yaw / 180 * M_PI) * cos($this->pitch / 180 * M_PI)), new Double("", -sin($this->pitch / 180 * M_PI)), new Double("", cos($this->yaw / 180 * M_PI) * cos($this->pitch / 180 * M_PI))]), "Rotation" => new Enum("Rotation", [new Float("", $this->yaw), new Float("", $this->pitch)])]);
$diff = $this->server->getTick() - $this->startAction;
$p = $diff / 20;
$f = min(($p ** 2 + $p * 2) / 3, 1) * 2;
$ev = new EntityShootBowEvent($this, $bow, Entity::createEntity("Arrow", $this->chunk, $nbt, $this, $f == 2 ? true : false), $f);
if ($f < 0.1 or $diff < 5) {
$ev->setCancelled();
}
$this->server->getPluginManager()->callEvent($ev);
if ($ev->isCancelled()) {
$ev->getProjectile()->kill();
$this->inventory->sendContents($this);
} else {
$ev->getProjectile()->setMotion($ev->getProjectile()->getMotion()->multiply($ev->getForce()));
if ($this->isSurvival()) {
$this->inventory->removeItem(Item::get(Item::ARROW, 0, 1));
$bow->setDamage($bow->getDamage() + 1);
if ($bow->getDamage() >= 385) {
$this->inventory->setItemInHand(Item::get(Item::AIR, 0, 0));
} else {
$this->inventory->setItemInHand($bow);
}
}
if ($ev->getProjectile() instanceof Projectile) {
$this->server->getPluginManager()->callEvent($projectileEv = new ProjectileLaunchEvent($ev->getProjectile()));
if ($projectileEv->isCancelled()) {
$ev->getProjectile()->kill();
} else {
$ev->getProjectile()->spawnToAll();
$this->level->addSound(new LaunchSound($this), $this->getViewers());
}
} else {
$ev->getProjectile()->spawnToAll();
}
}
}
} elseif ($this->inventory->getItemInHand()->getId() === Item::BUCKET and $this->inventory->getItemInHand()->getDamage() === 1) {
//Milk!
$this->server->getPluginManager()->callEvent($ev = new PlayerItemConsumeEvent($this, $this->inventory->getItemInHand()));
示例10: onSignChange
/**
* @param SignChangeEvent $event
*/
public function onSignChange(SignChangeEvent $event)
{
// Special Signs
// Free sign
if (strtolower(TextFormat::clean($event->getLine(0), true)) === "[free]" && $event->getPlayer()->hasPermission("essentials.sign.create.free")) {
if (trim($event->getLine(1)) !== "" || $event->getLine(1) !== null) {
$item_name = $event->getLine(1);
if (trim($event->getLine(2)) !== "" || $event->getLine(2) !== null) {
$damage = $event->getLine(2);
} else {
$damage = 0;
}
$item = $this->getAPI()->getItem($item_name . ":" . $damage);
if ($item->getID() === 0 || $item->getName() === "Air") {
$event->getPlayer()->sendMessage(TextFormat::RED . "[Error] Invalid item name/ID");
$event->setCancelled(true);
} else {
$event->getPlayer()->sendMessage(TextFormat::GREEN . "Free sign successfully created!");
$event->setLine(0, TextFormat::AQUA . "[Free]");
$event->setLine(1, $item->getName() === "Unknown" ? $item->getID() : $item->getName());
$event->setLine(2, $damage);
}
} else {
$event->getPlayer()->sendMessage(TextFormat::RED . "[Error] You should provide an item name/ID");
$event->setCancelled(true);
}
} elseif (strtolower(TextFormat::clean($event->getLine(0), true)) === "[gamemode]" && $event->getPlayer()->hasPermission("essentials.sign.create.gamemode")) {
switch (strtolower($event->getLine(1))) {
case "survival":
case "0":
$event->setLine(1, "Survival");
break;
case "creative":
case "1":
$event->setLine(1, "Creative");
break;
case "adventure":
case "2":
$event->setLine(1, "Adventure");
break;
case "spectator":
case "view":
case "3":
$event->setLine(1, "Spectator");
break;
default:
$event->getPlayer()->sendMessage(TextFormat::RED . "[Error] Unknown Gamemode, you should use \"Survival\", \"Creative\", \"Adventure\" or \"Spectator\"");
$event->setCancelled(true);
return;
break;
}
$event->getPlayer()->sendMessage(TextFormat::GREEN . "Gamemode sign successfully created!");
$event->setLine(0, TextFormat::AQUA . "[Gamemode]");
} elseif (strtolower(TextFormat::clean($event->getLine(0), true)) === "[heal]" && $event->getPlayer()->hasPermission("essentials.sign.create.heal")) {
$event->getPlayer()->sendMessage(TextFormat::GREEN . "Heal sign successfully created!");
$event->setLine(0, TextFormat::AQUA . "[Heal]");
} elseif (strtolower(TextFormat::clean($event->getLine(0), true)) === "[kit]" && $event->getPlayer()->hasPermission("essentials.sign.create.kit")) {
if (!$this->getAPI()->kitExists($event->getLine(1))) {
$event->getPlayer()->sendMessage(TextFormat::RED . "[Error] Kit doesn't exist");
return;
}
$event->getPlayer()->sendMessage(TextFormat::GREEN . "Kit sign successfully created!");
$event->setLine(0, TextFormat::AQUA . "[Kit]");
} elseif (strtolower(TextFormat::clean($event->getLine(0), true)) === "[repair]" && $event->getPlayer()->hasPermission("essentials.sign.create.repair")) {
switch (strtolower($event->getLine(1))) {
case "hand":
$event->setLine(1, "Hand");
break;
case "all":
$event->setLine(1, "All");
break;
default:
$event->getPlayer()->sendMessage(TextFormat::RED . "[Error] Invalid argument, you should use \"Hand\" or \"All\"");
$event->setCancelled(true);
return;
break;
}
$event->getPlayer()->sendMessage(TextFormat::GREEN . "Repair sign successfully created!");
$event->setLine(0, TextFormat::AQUA . "[Repair]");
} elseif (strtolower(TextFormat::clean($event->getLine(0), true)) === "[time]" && $event->getPlayer()->hasPermission("essentials.sign.create.time")) {
switch (strtolower($event->getLine(1))) {
case "day":
$event->setLine(1, "Day");
break;
case "night":
$event->setLine(1, "Night");
break;
default:
$event->getPlayer()->sendMessage(TextFormat::RED . "[Error] Invalid time, you should use \"Day\" or \"Night\"");
$event->setCancelled(true);
return;
break;
}
$event->getPlayer()->sendMessage(TextFormat::GREEN . "Time sign successfully created!");
$event->setLine(0, TextFormat::AQUA . "[Time]");
} elseif (strtolower(TextFormat::clean($event->getLine(0), true)) === "[teleport]" && $event->getPlayer()->hasPermission("essentials.sign.create.teleport")) {
if (!is_numeric($event->getLine(1))) {
//.........这里部分代码省略.........
示例11: handleDataPacket
//.........这里部分代码省略.........
$target = $this->level->getEntity($packet->target);
$cancelled = false;
if ($target instanceof Player and $this->server->getConfigBoolean("pvp", true) === false) {
$cancelled = true;
}
if ($target instanceof Entity and $this->getGamemode() !== Player::VIEW and $this->dead !== true and $target->dead !== true) {
if ($target instanceof DroppedItem or $target instanceof Arrow) {
$this->kick("Attempting to attack an invalid entity");
$this->server->getLogger()->warning("Player " . $this->getName() . " tried to attack an invalid entity");
return;
}
$item = $this->inventory->getItemInHand();
$damageTable = [Item::WOODEN_SWORD => 4, Item::GOLD_SWORD => 4, Item::STONE_SWORD => 5, Item::IRON_SWORD => 6, Item::DIAMOND_SWORD => 7, Item::WOODEN_AXE => 3, Item::GOLD_AXE => 3, Item::STONE_AXE => 3, Item::IRON_AXE => 5, Item::DIAMOND_AXE => 6, Item::WOODEN_PICKAXE => 2, Item::GOLD_PICKAXE => 2, Item::STONE_PICKAXE => 3, Item::IRON_PICKAXE => 4, Item::DIAMOND_PICKAXE => 5, Item::WOODEN_SHOVEL => 1, Item::GOLD_SHOVEL => 1, Item::STONE_SHOVEL => 2, Item::IRON_SHOVEL => 3, Item::DIAMOND_SHOVEL => 4];
$damage = [EntityDamageEvent::MODIFIER_BASE => isset($damageTable[$item->getId()]) ? $damageTable[$item->getId()] : 1];
if ($this->distance($target) > 8) {
$cancelled = true;
} elseif ($target instanceof Player) {
if (($target->getGamemode() & 0x1) > 0) {
break;
} elseif ($this->server->getConfigBoolean("pvp") !== true or $this->server->getDifficulty() === 0) {
$cancelled = true;
}
$armorValues = [Item::LEATHER_CAP => 1, Item::LEATHER_TUNIC => 3, Item::LEATHER_PANTS => 2, Item::LEATHER_BOOTS => 1, Item::CHAIN_HELMET => 1, Item::CHAIN_CHESTPLATE => 5, Item::CHAIN_LEGGINGS => 4, Item::CHAIN_BOOTS => 1, Item::GOLD_HELMET => 1, Item::GOLD_CHESTPLATE => 5, Item::GOLD_LEGGINGS => 3, Item::GOLD_BOOTS => 1, Item::IRON_HELMET => 2, Item::IRON_CHESTPLATE => 6, Item::IRON_LEGGINGS => 5, Item::IRON_BOOTS => 2, Item::DIAMOND_HELMET => 3, Item::DIAMOND_CHESTPLATE => 8, Item::DIAMOND_LEGGINGS => 6, Item::DIAMOND_BOOTS => 3];
$points = 0;
foreach ($target->getInventory()->getArmorContents() as $index => $i) {
if (isset($armorValues[$i->getId()])) {
$points += $armorValues[$i->getId()];
}
}
$damage[EntityDamageEvent::MODIFIER_ARMOR] = -floor($damage[EntityDamageEvent::MODIFIER_BASE] * $points * 0.04);
}
$ev = new EntityDamageByEntityEvent($this, $target, EntityDamageEvent::CAUSE_ENTITY_ATTACK, $damage);
if ($cancelled) {
$ev->setCancelled();
}
$target->attack($ev->getFinalDamage(), $ev);
if ($ev->isCancelled()) {
if ($item->isTool() and $this->isSurvival()) {
$this->inventory->sendContents($this);
}
break;
}
if ($item->isTool() and $this->isSurvival()) {
if ($item->useOn($target) and $item->getDamage() >= $item->getMaxDurability()) {
$this->inventory->setItemInHand(Item::get(Item::AIR, 0, 1), $this);
} else {
$this->inventory->setItemInHand($item, $this);
}
}
}
break;
case ProtocolInfo::ANIMATE_PACKET:
if ($this->spawned === false or $this->dead === true) {
break;
}
$this->server->getPluginManager()->callEvent($ev = new PlayerAnimationEvent($this, $packet->action));
if ($ev->isCancelled()) {
break;
}
$pk = new AnimatePacket();
$pk->eid = $this->getId();
$pk->action = $ev->getAnimationType();
Server::broadcastPacket($this->getViewers(), $pk);
break;
case ProtocolInfo::RESPAWN_PACKET:
if ($this->spawned === false or $this->dead === false) {
示例12: onSignChangeEvent
/**
* 표지판으로 태그블럭을 설치가능하게 이벤트처리
*
* @param SignChangeEvent $event
*/
public function onSignChangeEvent(SignChangeEvent $event)
{
if (!$event->getPlayer()->hasPermission("tagblock.add")) {
return;
}
if (strtolower($event->getLine(0)) != $this->db->get("TAGBlock-line0")) {
return;
}
if ($event->getLine(1) != null) {
$message = $event->getLine(1);
}
if ($event->getLine(2) != null) {
$message .= "\n" . $event->getLine(2);
}
if ($event->getLine(3) != null) {
$message .= "\n" . $event->getLine(3);
}
$block = $event->getBlock()->getSide(0);
$blockPos = "{$block->x}.{$block->y}.{$block->z}";
$this->db->db["TAGBlock"][$block->getLevel()->getFolderName()][$blockPos] = $message;
$this->db->message($event->getPlayer(), $this->db->get("TAGBlock-added"));
$event->setCancelled();
$event->getBlock()->getLevel()->setBlock($event->getBlock(), Block::get(Block::AIR));
}
示例13: handleDataPacket
//.........这里部分代码省略.........
$this->lastBreak = microtime(true);
} else {
$this->inventory->sendHeldItem($this);
}
break;
case PlayerActionPacket::ACTION_ABORT_BREAK:
$this->lastBreak = PHP_INT_MAX;
break;
case PlayerActionPacket::ACTION_RELEASE_ITEM:
if ($this->startAction > -1 and $this->getDataFlag(self::DATA_FLAGS, self::DATA_FLAG_ACTION)) {
if ($this->inventory->getItemInHand()->getId() === Item::BOW) {
$bow = $this->inventory->getItemInHand();
if ($this->isSurvival() and !$this->inventory->contains(Item::get(Item::ARROW, null))) {
$this->inventory->sendContents($this);
break;
}
$arrow = false;
foreach ($this->inventory->getContents() as $item) {
if ($item->getId() == Item::ARROW) {
$arrow = $item;
}
}
if ($arrow === false and $this->isCreative()) {
$arrow = Item::get(Item::ARROW, 0, 1);
} elseif ($arrow === false) {
break;
}
$nbt = new CompoundTag("", ["Pos" => new ListTag("Pos", [new DoubleTag("", $this->x), new DoubleTag("", $this->y + $this->getEyeHeight()), new DoubleTag("", $this->z)]), "Motion" => new ListTag("Motion", [new DoubleTag("", -sin($this->yaw / 180 * M_PI) * cos($this->pitch / 180 * M_PI)), new DoubleTag("", -sin($this->pitch / 180 * M_PI)), new DoubleTag("", cos($this->yaw / 180 * M_PI) * cos($this->pitch / 180 * M_PI))]), "Rotation" => new ListTag("Rotation", [new FloatTag("", $this->yaw), new FloatTag("", $this->pitch)]), "Fire" => new ShortTag("Fire", $this->isOnFire() ? 45 * 60 : 0), "Potion" => new ShortTag("Potion", $arrow->getDamage())]);
$diff = $this->server->getTick() - $this->startAction;
$p = $diff / 20;
$f = min(($p ** 2 + $p * 2) / 3, 1) * 2;
$ev = new EntityShootBowEvent($this, $bow, Entity::createEntity("Arrow", $this->chunk, $nbt, $this, $f == 2 ? true : false), $f);
if ($f < 0.1 or $diff < 5) {
$ev->setCancelled();
}
$this->server->getPluginManager()->callEvent($ev);
if ($ev->isCancelled()) {
$ev->getProjectile()->kill();
$this->inventory->sendContents($this);
} else {
$ev->getProjectile()->setMotion($ev->getProjectile()->getMotion()->multiply($ev->getForce()));
if ($this->isSurvival()) {
$this->inventory->removeItem(Item::get(Item::ARROW, $arrow->getDamage(), 1));
$bow->setDamage($bow->getDamage() + 1);
if ($bow->getDamage() >= 385) {
$this->inventory->setItemInHand(Item::get(Item::AIR, 0, 0));
} else {
$this->inventory->setItemInHand($bow);
}
}
if ($ev->getProjectile() instanceof Projectile) {
$this->server->getPluginManager()->callEvent($projectileEv = new ProjectileLaunchEvent($ev->getProjectile()));
if ($projectileEv->isCancelled()) {
$ev->getProjectile()->kill();
} else {
$ev->getProjectile()->spawnToAll();
$this->level->addSound(new LaunchSound($this), $this->getViewers());
}
} else {
$ev->getProjectile()->spawnToAll();
}
}
}
} elseif ($this->inventory->getItemInHand()->getId() === Item::BUCKET and $this->inventory->getItemInHand()->getDamage() === 1) {
//Milk!
$this->server->getPluginManager()->callEvent($ev = new PlayerItemConsumeEvent($this, $this->inventory->getItemInHand()));
示例14: signPlace
public function signPlace(SignChangeEvent $event)
{
if ($event->getPlayer()->isOp()) {
return;
}
$message = "";
foreach ($event->getLines() as $line) {
$message .= $line . "\n";
}
if (!isset($this->signCheck[$event->getPlayer()->getName() . ">" . $message])) {
$this->signCheck[$event->getPlayer()->getName() . ">" . $message] = false;
$blockPos = "{$event->getBlock()->x}:{$event->getBlock()->y}:{$event->getBlock()->z}";
$this->getServer()->getScheduler()->scheduleAsyncTask(new GentlemanAsyncTask($event->getPlayer()->getName(), [$event->getBlock()->getId(), $event->getBlock()->getDamage(), $blockPos], $message, $this->badQueue, $this->dictionary, "sign", true));
$event->setCancelled();
return;
} else {
if (!$this->signCheck[$event->getPlayer()->getName() . ">" . $message]) {
$event->setCancelled();
return;
} else {
unset($this->signCheck[$event->getPlayer()->getName() . ">" . $message]);
}
}
}
示例15: handleDataPacket
//.........这里部分代码省略.........
$this->lastBreak = microtime(true);
} else {
$this->inventory->sendHeldItem($this);
}
break;
case PlayerActionPacket::ACTION_ABORT_BREAK:
$this->lastBreak = PHP_INT_MAX;
break;
case PlayerActionPacket::ACTION_RELEASE_ITEM:
if ($this->startAction > -1 and $this->getDataFlag(self::DATA_FLAGS, self::DATA_FLAG_ACTION)) {
if ($this->inventory->getItemInHand()->getId() === Item::BOW) {
$bow = $this->inventory->getItemInHand();
if ($this->isSurvival() and !$this->inventory->contains(Item::get(Item::ARROW, null))) {
$this->inventory->sendContents($this);
break;
}
$arrow = false;
foreach ($this->inventory->getContents() as $item) {
if ($item->getId() == Item::ARROW) {
$arrow = $item;
}
}
if ($arrow === false and $this->isCreative()) {
$arrow = Item::get(Item::ARROW, 0, 1);
} elseif ($arrow === false) {
break;
}
$nbt = new CompoundTag("", ["Pos" => new ListTag("Pos", [new DoubleTag("", $this->x), new DoubleTag("", $this->y + $this->getEyeHeight()), new DoubleTag("", $this->z)]), "Motion" => new ListTag("Motion", [new DoubleTag("", -sin($this->yaw / 180 * M_PI) * cos($this->pitch / 180 * M_PI)), new DoubleTag("", -sin($this->pitch / 180 * M_PI)), new DoubleTag("", cos($this->yaw / 180 * M_PI) * cos($this->pitch / 180 * M_PI))]), "Rotation" => new ListTag("Rotation", [new FloatTag("", $this->yaw), new FloatTag("", $this->pitch)]), "Fire" => new ShortTag("Fire", $this->isOnFire() ? 45 * 60 : 0), "Potion" => new ShortTag("Potion", $arrow->getDamage())]);
$diff = $this->server->getTick() - $this->startAction;
$p = $diff / 20;
$f = min(($p ** 2 + $p * 2) / 3, 1) * 2;
$ev = new EntityShootBowEvent($this, $bow, Entity::createEntity("Arrow", $this->chunk, $nbt, $this, $f == 2 ? true : false), $f);
if ($f < 0.1 or $diff < 5) {
$ev->setCancelled();
}
$this->server->getPluginManager()->callEvent($ev);
if ($ev->isCancelled()) {
$ev->getProjectile()->kill();
$this->inventory->sendContents($this);
} else {
$ev->getProjectile()->setMotion($ev->getProjectile()->getMotion()->multiply($ev->getForce()));
if ($this->isSurvival()) {
$this->inventory->removeItem(Item::get(Item::ARROW, $arrow->getDamage(), 1));
$bow->setDamage($bow->getDamage() + 1);
if ($bow->getDamage() >= 385) {
$this->inventory->setItemInHand(Item::get(Item::AIR, 0, 0));
} else {
$this->inventory->setItemInHand($bow);
}
}
if ($ev->getProjectile() instanceof Projectile) {
$this->server->getPluginManager()->callEvent($projectileEv = new ProjectileLaunchEvent($ev->getProjectile()));
if ($projectileEv->isCancelled()) {
$ev->getProjectile()->kill();
} else {
$ev->getProjectile()->spawnToAll();
$this->level->addSound(new LaunchSound($this), $this->getViewers());
}
} else {
$ev->getProjectile()->spawnToAll();
}
}
}
} elseif ($this->inventory->getItemInHand()->getId() === Item::BUCKET and $this->inventory->getItemInHand()->getDamage() === 1) {
//Milk!
$this->server->getPluginManager()->callEvent($ev = new PlayerItemConsumeEvent($this, $this->inventory->getItemInHand()));