コード例 #1
0
ファイル: RCON.php プロジェクト: MunkySkunk/BukkitPE
 public function check()
 {
     for ($n = 0; $n < $this->threads; ++$n) {
         if ($this->workers[$n]->isTerminated() === true) {
             $this->workers[$n] = new RCONInstance($this->socket, $this->password, $this->clientsPerThread);
         } elseif ($this->workers[$n]->isWaiting()) {
             if ($this->workers[$n]->response !== "") {
                 $this->server->getLogger()->info($this->workers[$n]->response);
                 $this->workers[$n]->synchronized(function (RCONInstance $thread) {
                     $thread->notify();
                 }, $this->workers[$n]);
             } else {
                 $response = new RemoteConsoleCommandSender();
                 $command = $this->workers[$n]->cmd;
                 $this->server->getPluginManager()->callEvent($ev = new RemoteServerCommandEvent($response, $command));
                 if (!$ev->isCancelled()) {
                     $this->server->dispatchCommand($ev->getSender(), $ev->getCommand());
                 }
                 $this->workers[$n]->response = TextFormat::clean($response->getMessage());
                 $this->workers[$n]->synchronized(function (RCONInstance $thread) {
                     $thread->notify();
                 }, $this->workers[$n]);
             }
         }
     }
 }
コード例 #2
0
 public function onCompletion(Server $server)
 {
     $level = $server->getLevel($this->levelId);
     if ($level !== null) {
         /** @var FullChunk $chunk */
         $chunk = $this->chunkClass;
         $chunk = $chunk::fromFastBinary($this->chunk, $level->getProvider());
         if ($chunk === null) {
             //TODO error
             return;
         }
         $level->generateChunkCallback($chunk->getX(), $chunk->getZ(), $chunk);
     }
 }
コード例 #3
0
ファイル: Sugarcane.php プロジェクト: MunkySkunk/BukkitPE
 public function onUpdate($type)
 {
     if ($type === Level::BLOCK_UPDATE_NORMAL) {
         $down = $this->getSide(0);
         if ($down->isTransparent() === true and $down->getId() !== self::SUGARCANE_BLOCK) {
             $this->getLevel()->scheduleUpdate($this, 0);
         }
     } elseif ($type === Level::BLOCK_UPDATE_RANDOM) {
         if ($this->getSide(0)->getId() !== self::SUGARCANE_BLOCK) {
             if ($this->meta === 0xf) {
                 for ($y = 1; $y < 3; ++$y) {
                     $b = $this->getLevel()->getBlock(new Vector3($this->x, $this->y + $y, $this->z));
                     if ($b->getId() === self::AIR) {
                         Server::getInstance()->getPluginManager()->callEvent($ev = new BlockGrowEvent($b, new Sugarcane()));
                         $this->getLevel()->setBlock($b, new Sugarcane(), true);
                         break;
                     }
                 }
                 $this->meta = 0;
                 $this->getLevel()->setBlock($this, $this, true);
             } else {
                 ++$this->meta;
                 $this->getLevel()->setBlock($this, $this, true);
             }
             return Level::BLOCK_UPDATE_RANDOM;
         }
     } elseif ($type === Level::BLOCK_UPDATE_SCHEDULED) {
         $this->getLevel()->useBreakOn($this);
     }
     return false;
 }
コード例 #4
0
 /**
  * @return void
  */
 public function registerServerAliases()
 {
     $values = $this->server->getCommandAliases();
     foreach ($values as $alias => $commandStrings) {
         if (strpos($alias, ":") !== false or strpos($alias, " ") !== false) {
             $this->server->getLogger()->warning($this->server->getLanguage()->translateString("BukkitPE.command.alias.illegal", [$alias]));
             continue;
         }
         $targets = [];
         $bad = "";
         foreach ($commandStrings as $commandString) {
             $args = explode(" ", $commandString);
             $command = $this->getCommand($args[0]);
             if ($command === null) {
                 if (strlen($bad) > 0) {
                     $bad .= ", ";
                 }
                 $bad .= $commandString;
             } else {
                 $targets[] = $commandString;
             }
         }
         if (strlen($bad) > 0) {
             $this->server->getLogger()->warning($this->server->getLanguage()->translateString("BukkitPE.command.alias.notFound", [$alias, $bad]));
             continue;
         }
         //These registered commands have absolute priority
         if (count($targets) > 0) {
             $this->knownCommands[strtolower($alias)] = new FormattedCommandAlias(strtolower($alias), $targets);
         } else {
             unset($this->knownCommands[strtolower($alias)]);
         }
     }
 }
コード例 #5
0
 public function log($level, $message)
 {
     Server::getInstance()->getLogger()->log($level, $this->pluginName . $message);
     foreach ($this->attachments as $attachment) {
         $attachment->log($level, $message);
     }
 }
コード例 #6
0
 public function execute(CommandSender $sender, $commandLabel, array $args)
 {
     $commands = [];
     $result = false;
     foreach ($this->formatStrings as $formatString) {
         try {
             $commands[] = $this->buildCommand($formatString, $args);
         } catch (\Exception $e) {
             if ($e instanceof \InvalidArgumentException) {
                 $sender->sendMessage(TextFormat::RED . $e->getMessage());
             } else {
                 $sender->sendMessage(new TranslationContainer(TextFormat::RED . "%commands.generic.exception"));
                 $logger = $sender->getServer()->getLogger();
                 if ($logger instanceof MainLogger) {
                     $logger->logException($e);
                 }
             }
             return false;
         }
     }
     foreach ($commands as $command) {
         $result |= Server::getInstance()->dispatchCommand($sender, $command);
     }
     return (bool) $result;
 }
コード例 #7
0
 public function execute(CommandSender $sender, $currentAlias, array $args)
 {
     if (!$this->testPermission($sender)) {
         return true;
     }
     if (count($args) !== 1) {
         $sender->sendMessage(new TranslationContainer("commands.generic.usage", [$this->usageMessage]));
         return false;
     }
     $difficulty = Server::getDifficultyFromString($args[0]);
     if ($sender->getServer()->isHardcore()) {
         $difficulty = 3;
     }
     if ($difficulty !== -1) {
         $sender->getServer()->setConfigInt("difficulty", $difficulty);
         $pk = new SetDifficultyPacket();
         $pk->difficulty = $sender->getServer()->getDifficulty();
         Server::broadcastPacket($sender->getServer()->getOnlinePlayers(), $pk);
         Command::broadcastCommandMessage($sender, new TranslationContainer("commands.difficulty.success", [$difficulty]));
     } else {
         $sender->sendMessage(new TranslationContainer("commands.generic.usage", [$this->usageMessage]));
         return false;
     }
     return true;
 }
コード例 #8
0
ファイル: Crops.php プロジェクト: MunkySkunk/BukkitPE
 public function onUpdate($type)
 {
     if ($type === Level::BLOCK_UPDATE_NORMAL) {
         if ($this->getSide(0)->isTransparent() === true) {
             $this->getLevel()->useBreakOn($this);
             return Level::BLOCK_UPDATE_NORMAL;
         }
     } elseif ($type === Level::BLOCK_UPDATE_RANDOM) {
         if (mt_rand(0, 2) == 1) {
             if ($this->meta < 0x7) {
                 $block = clone $this;
                 ++$block->meta;
                 Server::getInstance()->getPluginManager()->callEvent($ev = new BlockGrowEvent($this, $block));
                 if (!$ev->isCancelled()) {
                     $this->getLevel()->setBlock($this, $ev->getNewState(), true, true);
                 } else {
                     return Level::BLOCK_UPDATE_RANDOM;
                 }
             }
         } else {
             return Level::BLOCK_UPDATE_RANDOM;
         }
     }
     return false;
 }
コード例 #9
0
 /**
  * @param Plugin $plugin
  */
 public function disablePlugin(Plugin $plugin)
 {
     if ($plugin instanceof PluginBase and $plugin->isEnabled()) {
         $this->server->getLogger()->info($this->server->getLanguage()->translateString("BukkitPE.plugin.disable", [$plugin->getDescription()->getFullName()]));
         $this->server->getPluginManager()->callEvent(new PluginDisableEvent($plugin));
         $plugin->setEnabled(false);
     }
 }
コード例 #10
0
ファイル: NetherPortal.php プロジェクト: MunkySkunk/BukkitPE
 public function onEntityCollide(Entity $entity)
 {
     Server::getInstance()->getPluginManager()->callEvent($ev = new EntityEnterPortalEvent($entity, $this));
     if (!$ev->isCancelled()) {
         return true;
     }
     return false;
 }
コード例 #11
0
 /**
  * @param Permission $perm
  * @param Permission $parent
  *
  * @return Permission
  */
 public static function registerPermission(Permission $perm, Permission $parent = null)
 {
     if ($parent instanceof Permission) {
         $parent->getChildren()[$perm->getName()] = true;
         return self::registerPermission($perm);
     }
     Server::getInstance()->getPluginManager()->addPermission($perm);
     return Server::getInstance()->getPluginManager()->getPermission($perm->getName());
 }
コード例 #12
0
 public static function reload()
 {
     if (Server::getInstance()->getPluginManager()->useTimings()) {
         foreach (self::$HANDLERS as $timings) {
             $timings->reset();
         }
         TimingsCommand::$timingStart = microtime(true);
     }
 }
コード例 #13
0
ファイル: Fire.php プロジェクト: MunkySkunk/BukkitPE
 public function onEntityCollide(Entity $entity)
 {
     if (!$entity->hasEffect(Effect::FIRE_RESISTANCE)) {
         $ev = new EntityDamageByBlockEvent($this, $entity, EntityDamageEvent::CAUSE_FIRE, 1);
         $entity->attack($ev->getFinalDamage(), $ev);
     }
     $ev = new EntityCombustByBlockEvent($this, $entity, 8);
     Server::getInstance()->getPluginManager()->callEvent($ev);
     if (!$ev->isCancelled()) {
         $entity->setOnFire($ev->getDuration());
     }
 }
コード例 #14
0
ファイル: Squid.php プロジェクト: MunkySkunk/BukkitPE
 public function attack($damage, EntityDamageEvent $source)
 {
     parent::attack($damage, $source);
     if ($source->isCancelled()) {
         return;
     }
     if ($source instanceof EntityDamageByEntityEvent) {
         $this->swimSpeed = mt_rand(150, 350) / 2000;
         $e = $source->getDamager();
         $this->swimDirection = (new Vector3($this->x - $e->x, $this->y - $e->y, $this->z - $e->z))->normalize();
         $pk = new EntityEventPacket();
         $pk->eid = $this->getId();
         $pk->event = EntityEventPacket::SQUID_INK_CLOUD;
         Server::broadcastPacket($this->hasSpawned, $pk);
     }
 }
コード例 #15
0
 public function __construct(Player $player, $message, $format = "chat.type.text", array $recipients = null)
 {
     $this->player = $player;
     $this->message = $message;
     //TODO: @deprecated (backwards-compativility)
     $i = 0;
     while (($pos = strpos($format, "%s")) !== false) {
         $format = substr($format, 0, $pos) . "{%{$i}}" . substr($format, $pos + 2);
         ++$i;
     }
     $this->format = $format;
     if ($recipients === null) {
         $this->recipients = Server::getInstance()->getPluginManager()->getPermissionSubscriptions(Server::BROADCAST_CHANNEL_USERS);
     } else {
         $this->recipients = $recipients;
     }
 }
コード例 #16
0
 public function putPacket(Player $player, DataPacket $packet, $needACK = false, $immediate = false)
 {
     if (isset($this->identifiers[$h = spl_object_hash($player)])) {
         $identifier = $this->identifiers[$h];
         $pk = null;
         if (!$packet->isEncoded) {
             $packet->encode();
         } elseif (!$needACK) {
             if (!isset($packet->__encapsulatedPacket)) {
                 $packet->__encapsulatedPacket = new CachedEncapsulatedPacket();
                 $packet->__encapsulatedPacket->identifierACK = null;
                 $packet->__encapsulatedPacket->buffer = $packet->buffer;
                 if ($packet->getChannel() !== 0) {
                     $packet->__encapsulatedPacket->reliability = 3;
                     $packet->__encapsulatedPacket->orderChannel = $packet->getChannel();
                     $packet->__encapsulatedPacket->orderIndex = 0;
                 } else {
                     $packet->__encapsulatedPacket->reliability = 2;
                 }
             }
             $pk = $packet->__encapsulatedPacket;
         }
         if (!$immediate and !$needACK and $packet::NETWORK_ID !== ProtocolInfo::BATCH_PACKET and Network::$BATCH_THRESHOLD >= 0 and strlen($packet->buffer) >= Network::$BATCH_THRESHOLD) {
             $this->server->batchPackets([$player], [$packet], true, $packet->getChannel());
             return null;
         }
         if ($pk === null) {
             $pk = new EncapsulatedPacket();
             $pk->buffer = $packet->buffer;
             if ($packet->getChannel() !== 0) {
                 $packet->reliability = 3;
                 $packet->orderChannel = $packet->getChannel();
                 $packet->orderIndex = 0;
             } else {
                 $packet->reliability = 2;
             }
             if ($needACK === true) {
                 $pk->identifierACK = $this->identifiersACK[$identifier]++;
             }
         }
         $this->interface->sendEncapsulated($identifier, $pk, ($needACK === true ? RakLib::FLAG_NEED_ACK : 0) | ($immediate === true ? RakLib::PRIORITY_IMMEDIATE : RakLib::PRIORITY_NORMAL));
         return $pk->identifierACK;
     }
     return null;
 }
コード例 #17
0
 public function execute(CommandSender $sender, $currentAlias, array $args)
 {
     if (!$this->testPermission($sender)) {
         return true;
     }
     if (count($args) === 0) {
         $sender->sendMessage(new TranslationContainer("commands.generic.usage", [$this->usageMessage]));
         return false;
     }
     $gameMode = Server::getGamemodeFromString($args[0]);
     if ($gameMode !== -1) {
         $sender->getServer()->setConfigInt("gamemode", $gameMode);
         $sender->sendMessage(new TranslationContainer("commands.defaultgamemode.success", [Server::getGamemodeString($gameMode)]));
     } else {
         $sender->sendMessage("Unknown game mode");
     }
     return true;
 }
コード例 #18
0
ファイル: AsyncPool.php プロジェクト: gitter-badger/BukkitPE
 public function collectTasks()
 {
     Timings::$schedulerAsyncTimer->startTiming();
     foreach ($this->tasks as $task) {
         if ($task->isGarbage() and !$task->isRunning()) {
             if (!$task->hasCancelledRun()) {
                 $task->onCompletion($this->server);
             }
             $this->removeTask($task);
         } elseif ($task->isTerminated()) {
             $info = $task->getTerminationInfo();
             $this->removeTask($task, true);
             $this->server->getLogger()->critical("Could not execute asynchronous task " . (new \ReflectionClass($task))->getShortName() . ": " . (isset($info["message"]) ? $info["message"] : "Unknown"));
             $this->server->getLogger()->critical("On " . $info["scope"] . ", line " . $info["line"] . ", " . $info["function"] . "()");
         }
     }
     Timings::$schedulerAsyncTimer->stopTiming();
 }
コード例 #19
0
ファイル: Mycelium.php プロジェクト: MunkySkunk/BukkitPE
 public function onUpdate($type)
 {
     if ($type === Level::BLOCK_UPDATE_RANDOM) {
         //TODO: light levels
         $x = mt_rand($this->x - 1, $this->x + 1);
         $y = mt_rand($this->y - 2, $this->y + 2);
         $z = mt_rand($this->z - 1, $this->z + 1);
         $block = $this->getLevel()->getBlock(new Vector3($x, $y, $z));
         if ($block->getId() === Block::DIRT) {
             if ($block->getSide(1) instanceof Transparent) {
                 Server::getInstance()->getPluginManager()->callEvent($ev = new BlockSpreadEvent($block, $this, new Mycelium()));
                 if (!$ev->isCancelled()) {
                     $this->getLevel()->setBlock($block, $ev->getNewState());
                 }
             }
         }
     }
 }
コード例 #20
0
ファイル: QueryHandler.php プロジェクト: MunkySkunk/BukkitPE
 public function __construct()
 {
     $this->server = Server::getInstance();
     $this->server->getLogger()->info($this->server->getLanguage()->translateString("BukkitPE.server.query.start"));
     $addr = ($ip = $this->server->getIp()) != "" ? $ip : "0.0.0.0";
     $port = $this->server->getPort();
     $this->server->getLogger()->info($this->server->getLanguage()->translateString("BukkitPE.server.query.info", [$port]));
     /*
     The Query protocol is built on top of the existing Minecraft PE UDP network stack.
     Because the 0xFE packet does not exist in the MCPE protocol,
     we can identify	Query packets and remove them from the packet queue.
     
     Then, the Query class handles itself sending the packets in raw form, because
     packets can conflict with the MCPE ones.
     */
     $this->regenerateToken();
     $this->lastToken = $this->token;
     $this->regenerateInfo();
     $this->server->getLogger()->info($this->server->getLanguage()->translateString("BukkitPE.server.query.running", [$addr, $port]));
 }
コード例 #21
0
ファイル: Cactus.php プロジェクト: MunkySkunk/BukkitPE
 public function onUpdate($type)
 {
     if ($type === Level::BLOCK_UPDATE_NORMAL) {
         $down = $this->getSide(0);
         $up = $this->getSide(1);
         if ($down->getId() !== self::SAND and $down->getId() !== self::CACTUS) {
             $this->getLevel()->scheduleUpdate($this, 0);
         } else {
             for ($side = 2; $side <= 5; ++$side) {
                 $b = $this->getSide($side);
                 if (!$b->canBeFlowedInto() && $b->getId() !== Block::SNOW_LAYER) {
                     // Snow can be stacked to a full block beside a cactus without destroying the cactus.
                     $this->getLevel()->useBreakOn($this);
                 }
             }
         }
     } elseif ($type === Level::BLOCK_UPDATE_RANDOM) {
         if ($this->getSide(0)->getId() !== self::CACTUS) {
             if ($this->meta == 0xf) {
                 for ($y = 1; $y < 3; ++$y) {
                     $b = $this->getLevel()->getBlock(new Vector3($this->x, $this->y + $y, $this->z));
                     if ($b->getId() === self::AIR) {
                         Server::getInstance()->getPluginManager()->callEvent($ev = new BlockGrowEvent($b, new Cactus()));
                         if (!$ev->isCancelled()) {
                             $this->getLevel()->setBlock($b, $ev->getNewState(), true);
                         }
                     }
                 }
                 $this->meta = 0;
                 $this->getLevel()->setBlock($this, $this);
             } else {
                 ++$this->meta;
                 $this->getLevel()->setBlock($this, $this);
             }
         }
     } elseif ($type === Level::BLOCK_UPDATE_SCHEDULED) {
         $this->getLevel()->useBreakOn($this);
     }
     return false;
 }
コード例 #22
0
ファイル: MelonStem.php プロジェクト: MunkySkunk/BukkitPE
 public function onUpdate($type)
 {
     if ($type === Level::BLOCK_UPDATE_NORMAL) {
         if ($this->getSide(0)->isTransparent() === true) {
             $this->getLevel()->useBreakOn($this);
             return Level::BLOCK_UPDATE_NORMAL;
         }
     } elseif ($type === Level::BLOCK_UPDATE_RANDOM) {
         if (mt_rand(0, 2) == 1) {
             if ($this->meta < 0x7) {
                 $block = clone $this;
                 ++$block->meta;
                 Server::getInstance()->getPluginManager()->callEvent($ev = new BlockGrowEvent($this, $block));
                 if (!$ev->isCancelled()) {
                     $this->getLevel()->setBlock($this, $ev->getNewState(), true);
                 }
                 return Level::BLOCK_UPDATE_RANDOM;
             } else {
                 for ($side = 2; $side <= 5; ++$side) {
                     $b = $this->getSide($side);
                     if ($b->getId() === self::MELON_BLOCK) {
                         return Level::BLOCK_UPDATE_RANDOM;
                     }
                 }
                 $side = $this->getSide(mt_rand(2, 5));
                 $d = $side->getSide(0);
                 if ($side->getId() === self::AIR and ($d->getId() === self::FARMLAND or $d->getId() === self::GRASS or $d->getId() === self::DIRT)) {
                     Server::getInstance()->getPluginManager()->callEvent($ev = new BlockGrowEvent($side, new Melon()));
                     if (!$ev->isCancelled()) {
                         $this->getLevel()->setBlock($side, $ev->getNewState(), true);
                     }
                 }
             }
         }
         return Level::BLOCK_UPDATE_RANDOM;
     }
     return false;
 }
コード例 #23
0
 public function execute(CommandSender $sender, $currentAlias, array $args)
 {
     if (!$this->testPermission($sender)) {
         return true;
     }
     if (count($args) === 0) {
         $sender->sendMessage(new TranslationContainer("commands.generic.usage", [$this->usageMessage]));
         return false;
     }
     $gameMode = Server::getGamemodeFromString($args[0]);
     if ($gameMode === -1) {
         $sender->sendMessage("Unknown game mode");
         return true;
     }
     $target = $sender;
     if (isset($args[1])) {
         $target = $sender->getServer()->getPlayer($args[1]);
         if ($target === null) {
             $sender->sendMessage(new TranslationContainer(TextFormat::RED . "%commands.generic.player.notFound"));
             return true;
         }
     } elseif (!$sender instanceof Player) {
         $sender->sendMessage(new TranslationContainer("commands.generic.usage", [$this->usageMessage]));
         return true;
     }
     $target->setGamemode($gameMode);
     if ($gameMode !== $target->getGamemode()) {
         $sender->sendMessage("Game mode change for " . $target->getName() . " failed!");
     } else {
         if ($target === $sender) {
             Command::broadcastCommandMessage($sender, new TranslationContainer("commands.gamemode.success.self", [Server::getGamemodeString($gameMode)]));
         } else {
             $target->sendMessage(new TranslationContainer("gameMode.changed"));
             Command::broadcastCommandMessage($sender, new TranslationContainer("commands.gamemode.success.other", [$target->getName(), Server::getGamemodeString($gameMode)]));
         }
     }
     return true;
 }
コード例 #24
0
 /**
  * Registers all the events in the given Listener class
  *
  * @param Listener $listener
  * @param Plugin   $plugin
  *
  * @throws PluginException
  */
 public function registerEvents(Listener $listener, Plugin $plugin)
 {
     if (!$plugin->isEnabled()) {
         throw new PluginException("Plugin attempted to register " . get_class($listener) . " while not enabled");
     }
     $reflection = new \ReflectionClass(get_class($listener));
     foreach ($reflection->getMethods(\ReflectionMethod::IS_PUBLIC) as $method) {
         if (!$method->isStatic()) {
             $priority = EventPriority::NORMAL;
             $ignoreCancelled = false;
             if (preg_match("/^[\t ]*\\* @priority[\t ]{1,}([a-zA-Z]{1,})/m", (string) $method->getDocComment(), $matches) > 0) {
                 $matches[1] = strtoupper($matches[1]);
                 if (defined(EventPriority::class . "::" . $matches[1])) {
                     $priority = constant(EventPriority::class . "::" . $matches[1]);
                 }
             }
             if (preg_match("/^[\t ]*\\* @ignoreCancelled[\t ]{1,}([a-zA-Z]{1,})/m", (string) $method->getDocComment(), $matches) > 0) {
                 $matches[1] = strtolower($matches[1]);
                 if ($matches[1] === "false") {
                     $ignoreCancelled = false;
                 } elseif ($matches[1] === "true") {
                     $ignoreCancelled = true;
                 }
             }
             $parameters = $method->getParameters();
             if (count($parameters) === 1 and $parameters[0]->getClass() instanceof \ReflectionClass and is_subclass_of($parameters[0]->getClass()->getName(), Event::class)) {
                 $class = $parameters[0]->getClass()->getName();
                 $reflection = new \ReflectionClass($class);
                 if (strpos((string) $reflection->getDocComment(), "@deprecated") !== false and $this->server->getProperty("settings.deprecated-verbose", true)) {
                     $this->server->getLogger()->warning($this->server->getLanguage()->translateString("BukkitPE.plugin.deprecatedEvent", [$plugin->getName(), $class, get_class($listener) . "->" . $method->getName() . "()"]));
                 }
                 $this->registerEvent($class, $listener, $priority, new MethodEventExecutor($method->getName()), $plugin, $ignoreCancelled);
             }
         }
     }
 }
コード例 #25
0
 public function execute()
 {
     if ($this->hasExecuted() or !$this->canExecute()) {
         return false;
     }
     Server::getInstance()->getPluginManager()->callEvent($ev = new InventoryTransactionEvent($this));
     if ($ev->isCancelled()) {
         foreach ($this->inventories as $inventory) {
             if ($inventory instanceof PlayerInventory) {
                 $inventory->sendArmorContents($this->getSource());
             }
             $inventory->sendContents($this->getSource());
         }
         return false;
     }
     foreach ($this->transactions as $transaction) {
         $transaction->getInventory()->setItem($transaction->getSlot(), $transaction->getTargetItem());
     }
     $this->hasExecuted = true;
     return true;
 }
コード例 #26
0
 public function onCompletion(Server $server)
 {
     $level = $server->getLevel($this->levelId);
     if ($level !== null) {
         if ($this->state === false) {
             $level->registerGenerator();
             return;
         }
         /** @var FullChunk $chunkC */
         $chunkC = $this->chunkClass;
         $chunk = $chunkC::fromFastBinary($this->chunk, $level->getProvider());
         if ($chunk === null) {
             //TODO error
             return;
         }
         for ($i = 0; $i < 9; ++$i) {
             if ($i === 4) {
                 continue;
             }
             $c = $this->{"chunk{$i}"};
             if ($c !== null) {
                 $c = $chunkC::fromFastBinary($c, $level->getProvider());
                 $level->generateChunkCallback($c->getX(), $c->getZ(), $c);
             }
         }
         $level->generateChunkCallback($chunk->getX(), $chunk->getZ(), $chunk);
     }
 }
コード例 #27
0
ファイル: Level.php プロジェクト: MunkySkunk/BukkitPE
 public function removeMetadata($metadataKey, Plugin $plugin)
 {
     $this->server->getLevelMetadata()->removeMetadata($this, $metadataKey, $plugin);
 }
コード例 #28
0
 /**
  * @param bool[]               $children
  * @param bool                 $invert
  * @param PermissionAttachment $attachment
  */
 private function calculateChildPermissions(array $children, $invert, $attachment)
 {
     foreach ($children as $name => $v) {
         $perm = Server::getInstance()->getPluginManager()->getPermission($name);
         $value = ($v xor $invert);
         $this->permissions[$name] = new PermissionAttachmentInfo($this->parent !== null ? $this->parent : $this, $name, $attachment, $value);
         Server::getInstance()->getPluginManager()->subscribeToPermission($name, $this->parent !== null ? $this->parent : $this);
         if ($perm instanceof Permission) {
             $this->calculateChildPermissions($perm->getChildren(), !$value, $attachment);
         }
     }
 }
コード例 #29
0
ファイル: BaseInventory.php プロジェクト: MunkySkunk/BukkitPE
 public function clear($index)
 {
     if (isset($this->slots[$index])) {
         $item = Item::get(Item::AIR, null, 0);
         $old = $this->slots[$index];
         $holder = $this->getHolder();
         if ($holder instanceof Entity) {
             Server::getInstance()->getPluginManager()->callEvent($ev = new EntityInventoryChangeEvent($holder, $old, $item, $index));
             if ($ev->isCancelled()) {
                 $this->sendSlot($index, $this->getViewers());
                 return false;
             }
             $item = $ev->getNewItem();
         }
         if ($item->getId() !== Item::AIR) {
             $this->slots[$index] = clone $item;
         } else {
             unset($this->slots[$index]);
         }
         $this->onSlotChange($index, $old);
     }
     return true;
 }
コード例 #30
0
 public function onCompletion(Server $server)
 {
     $server->broadcastPacketsCallback($this->final, $this->targets, $this->channel);
 }