Ejemplo n.º 1
0
 public function onLoadChunk(ChunkLoadEvent $event)
 {
     if ($event->getLevel()->getName() !== "world_pvp") {
         return;
     }
     $chunk = $event->getChunk();
     $hash = Level::chunkHash($chunk->getX(), $chunk->getZ());
     if (isset($this->modelLocs[$hash])) {
         foreach ($this->modelLocs[$hash] as $id => $loc) {
             $model = new PvpKitModel($this->game, $id, $loc);
             $model->spawnToAll();
             $this->models[$id] = $model;
         }
     }
     if (isset($this->shopLocs[$hash])) {
         foreach ($this->shopLocs[$hash] as $col => $loc) {
             $shop = new PvpUpgradeDummyShop($this->game, $loc, $col);
             $shop->spawnToAll();
             $this->shops[$col] = $shop;
         }
     }
     if ($hash === $this->bowHash) {
         $this->bow = new PvpBowHolder(Settings::kitpvp_getBowLocation($this->game->getMain()->getServer()), $this->game);
     }
 }
Ejemplo n.º 2
0
 /**
  * @param Location $loc
  * @param PvpGame $game
  */
 public function __construct($loc, $game)
 {
     if (!$loc instanceof Location or !$game instanceof PvpGame) {
         $this->badConstruct($loc);
         return;
     }
     $this->game = $game;
     $this->setDataFlag(self::DATA_FLAGS, self::DATA_FLAG_ACTION, true);
     parent::__construct($game->getMain(), $loc, " Upgrade\nYour bow");
     $this->getInventory()->setItem(0, new Bow());
     $this->getInventory()->setHeldItemSlot(0);
 }
Ejemplo n.º 3
0
 /**
  * @param Player $player
  * @param PvpSessionData|null $data
  */
 public function spawnTo(Player $player, $data = null)
 {
     if ($data === null) {
         $data = $this->game->getPlayerData($player, true);
         // most likely newly joined
         if (!$data instanceof PvpSessionData) {
             return;
             // don't spawn to players who aren't programmatically in KitPvP
         }
     }
     $kit = $data->getKitById($this->kid, true, $isNew);
     $this->getInventory()->sendContents($player);
     $this->setNameTag($kit->name === "" ? "Kit {$this->kid}" : $kit->name);
     if ($data->getKitIdInUse() === $this->kid) {
         $this->nameTag = self::IN_USE_TAG . $this->nameTag;
     }
     parent::spawnTo($player);
     $kit->equip($this->getInventory(), $data, false);
     // TODO hardcode
     $this->getInventory()->sendArmorContents([$player]);
     $this->getInventory()->sendHeldItem($player);
     if ($data->getEditingKitId() === $this->kid) {
         $this->fireTo($player);
     }
 }
Ejemplo n.º 4
0
 public function nextType()
 {
     /** @var \legionpe\config\KitUpgradeInfo[] $items */
     $items = Settings::$KITPVP_KITS[$this->column];
     switch ($this->column) {
         case Settings::KIT_HELMET:
             $this->getInventory()->setHelmet($items[$this->curPos++]->getItem());
             $players = $this->game->getMain()->getServer()->getLevelByName("world_pvp")->getPlayers();
             $this->getInventory()->sendArmorContents($players);
             break;
         case Settings::KIT_CHESTPLATE:
             $this->getInventory()->setChestplate($items[$this->curPos++]->getItem());
             $players = $this->game->getMain()->getServer()->getLevelByName("world_pvp")->getPlayers();
             $this->getInventory()->sendArmorContents($players);
             break;
         case Settings::KIT_LEGGINGS:
             $this->getInventory()->setLeggings($items[$this->curPos++]->getItem());
             $players = $this->game->getMain()->getServer()->getLevelByName("world_pvp")->getPlayers();
             $this->getInventory()->sendArmorContents($players);
             break;
         case Settings::KIT_BOOTS:
             $this->getInventory()->setBoots($items[$this->curPos++]->getItem());
             $players = $this->game->getMain()->getServer()->getLevelByName("world_pvp")->getPlayers();
             $this->getInventory()->sendArmorContents($players);
             break;
         default:
             $item = $items[$this->curPos++]->getItem();
             $this->getInventory()->setItemInHand($item);
             $this->getInventory()->sendHeldItem($this->getInventory()->getViewers());
             break;
     }
     if (!isset($items[$this->curPos])) {
         $this->curPos = 0;
     }
 }
Ejemplo n.º 5
0
 public function update($force = false)
 {
     if ($this->needSave or $force) {
         // stats
         if ($this->isUpdate) {
             $this->game->getMain()->getMySQLi()->query("UPDATE kitpvp SET kills=%d,deaths=%d,kit=%d,bow=%d,maxstreak=%d WHERE uid=%d;", MysqlConnection::RAW, $this->getKills(), $this->getDeaths(), $this->getKitIdInUse(), $this->data["bow"], $this->data["maxstreak"], $this->getUID());
         } else {
             $this->game->getMain()->getMySQLi()->query("INSERT INTO kitpvp(uid,kills,deaths,kit,bow,maxstreak)VALUES(%d,%d,%d,%d,%d,%d)", MysqlConnection::RAW, $this->getUID(), $this->getKills(), $this->getDeaths(), $this->getKitIdInUse(), $this->data["bow"], $this->data["maxstreak"]);
         }
         $this->isUpdate = true;
     }
     // kits
     foreach ($this->kits as $kit) {
         if ($kit->updated or $force) {
             $kit->updateToMysql($this->game->getMain()->getMySQLi());
         }
     }
     $this->needSave = false;
 }