Skip to content

Commit

Permalink
Update to PocketMine-MP 3.0.0-ALPHA7
Browse files Browse the repository at this point in the history
  • Loading branch information
dresnite committed Aug 10, 2017
1 parent f301c8f commit bfdd2e3
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 19 deletions.
4 changes: 2 additions & 2 deletions plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ name: SkyBlock
author: GiantQuartz
website: http://twitter.com/GiantQuartz
main: SkyBlock\Main
version: "0.1.7"
api: [2.0.0]
version: "0.1.8"
api: [3.0.0-ALPHA7]
2 changes: 1 addition & 1 deletion src/SkyBlock/EventListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ public function onHurt(EntityDamageEvent $event) {
*/
public function onUnloadLevel(LevelUnloadEvent $event) {
foreach($event->getLevel()->getPlayers() as $player) {
$player->teleportImmediate($this->plugin->getServer()->getDefaultLevel()->getSafeSpawn());
$player->teleport($this->plugin->getServer()->getDefaultLevel()->getSafeSpawn());
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/SkyBlock/Main.php
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ public function setResetHandler() {
* Register ChatHandler instance
*/
public function setChatHandler() {
$this->chatHandler = new ChatHandler($this);
$this->chatHandler = new ChatHandler();
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/SkyBlock/PluginHearbeat.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public function __construct(Main $owner) {
parent::__construct($owner);
}

public function onRun($currentTick) {
public function onRun(int $currentTick) {
$this->nextUpdate++;
/** @var Main $owner */
$owner = $this->getOwner();
Expand Down
8 changes: 4 additions & 4 deletions src/SkyBlock/command/SkyBlockCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function sendMessage(Player $sender, $message) {
$sender->sendMessage(TextFormat::GREEN . "- " . TextFormat::WHITE . $message);
}

public function execute(CommandSender $sender, $commandLabel, array $args) {
public function execute(CommandSender $sender, string $commandLabel, array $args) {
if($sender instanceof Player) {
if(isset($args[0])) {
switch($args[0]) {
Expand Down Expand Up @@ -238,7 +238,7 @@ public function execute(CommandSender $sender, $commandLabel, array $args) {
if($player instanceof Player and $player->isOnline()) {
$invitation = $this->plugin->getInvitationHandler()->getInvitation($player);
if($invitation instanceof Invitation) {
if($invitation->getSender() == $player) {
if($invitation->getSender() === $player) {
$invitation->accept();
}
else {
Expand Down Expand Up @@ -270,7 +270,7 @@ public function execute(CommandSender $sender, $commandLabel, array $args) {
if($player instanceof Player and $player->isOnline()) {
$invitation = $this->plugin->getInvitationHandler()->getInvitation($player);
if($invitation instanceof Invitation) {
if($invitation->getSender() == $player) {
if($invitation->getSender() === $player) {
$invitation->deny();
}
else {
Expand Down Expand Up @@ -354,7 +354,7 @@ public function execute(CommandSender $sender, $commandLabel, array $args) {
if($player instanceof Player and $player->isOnline()) {
$playerConfig = $this->plugin->getSkyBlockManager()->getPlayerConfig($player);
$playerIsland = $this->plugin->getIslandManager()->getOnlineIsland($playerConfig->get("island"));
if($island == $playerIsland) {
if($island === $playerIsland) {
$island->setOwnerName($player);
$island->addPlayer($player);
$this->sendMessage($sender, "You sent the ownership to {$player->getName()}");
Expand Down
15 changes: 8 additions & 7 deletions src/SkyBlock/generator/generators/BasicIsland.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,15 @@ public function init(ChunkManager $level, Random $random) {
*
* @return string
*/
public function getName() {
public function getName() : string {
return $this->name;
}

public function getSettings() {
public function getSettings() : array {
return $this->settings;
}

public function generateChunk($chunkX, $chunkZ) {
public function generateChunk(int $chunkX, int $chunkZ) {
$chunk = $this->level->getChunk($chunkX, $chunkZ);
$chunk->setGenerated();
if ($chunkX % 20 == 0 && $chunkZ % 20 == 0) {
Expand All @@ -79,20 +79,21 @@ public function generateChunk($chunkX, $chunkZ) {
}
}

public function populateChunk($chunkX, $chunkZ) {
for ($x = 0; $x < 16; $x++) {
public function populateChunk(int $chunkX, int $chunkZ) {
// this disappeared in API 3.0.0-ALPHA1 due to client changes (client doesn't support custom biome colours anymore)
/*for ($x = 0; $x < 16; $x++) {
for ($z = 0; $z < 16; $z++) {
$this->level->getChunk($chunkX, $chunkZ)->setBiomeColor($x, $z, 133, 188, 86);
}
}
}*/
}

/**
* Return BasicIsland spawn
*
* @return Vector3
*/
public function getSpawn() {
public function getSpawn() : Vector3 {
return new Vector3(8, 7, 10);
}

Expand Down
9 changes: 6 additions & 3 deletions src/SkyBlock/skyblock/SkyBlockManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use pocketmine\item\Item;
use pocketmine\level\generator\Generator;
use pocketmine\math\Vector3;
use pocketmine\nbt\NBT;
use pocketmine\nbt\tag\CompoundTag;
use pocketmine\nbt\tag\IntTag;
use pocketmine\nbt\tag\ListTag;
Expand Down Expand Up @@ -43,15 +44,17 @@ public function spawnDefaultChest($islandName) {
$level = $this->plugin->getServer()->getLevelByName($islandName);
$level->setBlock(new Vector3(10, 6, 4), new Block(0, 0));
$level->loadChunk(10, 4, true);
$level->setBlock(new Vector3(10, 6, 4), new Block(54, 0));
/** @var Chest $chest */
$chest = Tile::createTile("Chest",$level->getChunk(10 >> 4, 4 >> 4), new CompoundTag(" ", [
$nbt = new CompoundTag(" ", [
new ListTag("Items", []),
new StringTag("id", Tile::CHEST),
new IntTag("x", 10),
new IntTag("y", 6),
new IntTag("z", 4)
]));
$level->setBlock(new Vector3(10, 6, 4), new Block(54, 0));
]);
$nbt->Items->setTagType(NBT::TAG_Compound);
$chest = Tile::createTile("Chest", $level, $nbt);
$level->addTile($chest);
$inventory = $chest->getInventory();
$inventory->addItem(Item::get(Item::WATER, 0, 2));
Expand Down

0 comments on commit bfdd2e3

Please sign in to comment.