Skip to content
This repository was archived by the owner on Dec 12, 2022. It is now read-only.

Commit a829912

Browse files
committed
feat: last changes
1 parent c0311e0 commit a829912

7 files changed

Lines changed: 39 additions & 52 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# WoolVolcano
22

3-
Victory effect for your Minecraft BE server, inspired by Cubecraft, for Pocketmine 4.0.0
3+
Victory effect for your Minecraft BE server, inspired by Cubecraft, for Pocketmine 3.0.0
44

55
If you encounter any bugs, have suggestions or questions, [create an issue](https://github.com/Josscoder/WoolVolcano/issues/new).
66

plugin.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
name: Main
1+
name: WoolVolcano
22
main: jossc\volcano\Main
3-
api: 4.0.0
3+
api: 3.0.0
44
version: 1.1
55
author: Josscoder

src/jossc/volcano/Main.php

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,20 @@
55
use jossc\volcano\entity\CustomFallingWoolBlock;
66
use jossc\volcano\listener\EventListener;
77
use jossc\volcano\task\VolcanoTak;
8-
use pocketmine\block\BlockFactory;
9-
use pocketmine\block\BlockLegacyIds;
10-
use pocketmine\entity\EntityDataHelper;
11-
use pocketmine\entity\EntityFactory;
12-
use pocketmine\nbt\tag\CompoundTag;
13-
use pocketmine\player\Player;
8+
use pocketmine\entity\Entity;
9+
use pocketmine\Player;
1410
use pocketmine\plugin\PluginBase;
1511
use pocketmine\utils\TextFormat;
16-
use pocketmine\world\World;
1712

1813
class Main extends PluginBase {
1914

2015
/*** @var Main */
2116
private static $main;
2217

23-
protected function onEnable(): void{
18+
public function onEnable()
19+
{
20+
parent::onEnable();
21+
2422
self::$main = $this;
2523

2624
$this->registerEntity();
@@ -33,15 +31,14 @@ protected function onEnable(): void{
3331
$this->getLogger()->info(TextFormat::GREEN . 'This plugin has been enabled!.');
3432
}
3533

34+
public function onDisable(): void {
35+
parent::onDisable();
36+
37+
$this->getLogger()->info(TextFormat::RED . 'This plugin has been disabled!.');
38+
}
39+
3640
private function registerEntity(): void {
37-
EntityFactory::getInstance()->register(CustomFallingWoolBlock::class,
38-
function(World $world, CompoundTag $nbt) : CustomFallingWoolBlock {
39-
return new CustomFallingWoolBlock(
40-
EntityDataHelper::parseLocation($nbt, $world),
41-
BlockFactory::getInstance()->get(BlockLegacyIds::WOOL, 0),
42-
$nbt
43-
);
44-
}, ['CustomFallingWoolBlock', 'minecraft:falling_wool_block_entity']);
41+
Entity::registerEntity(CustomFallingWoolBlock::class, true);
4542
}
4643

4744
/*** @return Main */
@@ -52,11 +49,7 @@ public static function getInstance(): Main {
5249
/*** @param Player $player */
5350
public function giveTo(Player $player): void {
5451
$this->getScheduler()->scheduleDelayedRepeatingTask(
55-
new VolcanoTak($player, $player->getWorld()), 1, 3
52+
new VolcanoTak($player, $player->getLevel()), 1, 3
5653
);
5754
}
58-
59-
protected function onDisable(): void {
60-
$this->getLogger()->info(TextFormat::RED . 'This plugin has been disabled!.');
61-
}
6255
}

src/jossc/volcano/entity/CustomFallingWoolBlock.php

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,23 @@
22

33
namespace jossc\volcano\entity;
44

5+
use pocketmine\block\Block;
56
use pocketmine\entity\object\FallingBlock;
6-
use pocketmine\nbt\tag\CompoundTag;
77

88
class CustomFallingWoolBlock extends FallingBlock {
99

10-
/*** @param CompoundTag $nbt */
11-
protected function initEntity(CompoundTag $nbt): void
10+
protected function initEntity(): void
1211
{
13-
parent::initEntity($nbt);
14-
12+
$this->block = Block::get(Block::WOOL, rand(0, 15));
1513
$this->setForceMovementUpdate(true);
16-
$this->setSilent(true);
1714
$this->setCanSaveWithChunk(false);
1815
}
1916

2017
/**
2118
* @param int $tickDiff
2219
* @return bool
2320
*/
24-
protected function entityBaseTick(int $tickDiff = 1): bool
21+
public function entityBaseTick(int $tickDiff = 1): bool
2522
{
2623
if ($this->isClosed()) {
2724
return false;

src/jossc/volcano/listener/EventListener.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public function __construct(Main $main) {
2020
}
2121

2222
/*** @param PlayerChatEvent $event */
23-
public function PlayerChatEvent(PlayerChatEvent $event): void {
23+
public function onChat(PlayerChatEvent $event): void {
2424
$player = $event->getPlayer();
2525

2626
if (!$player->getServer()->isOp($player->getName())) {
@@ -31,7 +31,7 @@ public function PlayerChatEvent(PlayerChatEvent $event): void {
3131
return;
3232
}
3333

34-
$event->cancel();
34+
$event->setCancelled();
3535

3636
$this->main->giveTo($player);
3737
}

src/jossc/volcano/task/VolcanoTak.php

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@
44

55
use jossc\volcano\entity\CustomFallingWoolBlock;
66
use jossc\volcano\utils\Utils;
7-
use pocketmine\player\Player;
7+
use pocketmine\level\Level;
8+
use pocketmine\Player;
89
use pocketmine\scheduler\Task;
9-
use pocketmine\world\World;
1010

1111
class VolcanoTak extends Task {
1212

1313
/*** @var Player */
1414
private $player;
1515

16-
/*** @var World */
16+
/*** @var Level */
1717
private $world;
1818

1919
/*** @var array */
@@ -25,14 +25,16 @@ class VolcanoTak extends Task {
2525
/**
2626
* VolcanoTak constructor.
2727
* @param Player $player
28-
* @param World $world
28+
* @param Level $world
2929
*/
30-
public function __construct(Player $player, World $world) {
30+
public function __construct(Player $player, Level $world) {
3131
$this->player = $player;
3232
$this->world = $world;
3333
}
3434

35-
public function onRun(): void {
35+
/*** @param int $currentTick */
36+
public function onRun(int $currentTick)
37+
{
3638
if ($this->isExecutable()) {
3739

3840
$location = $this->player->getLocation();
@@ -60,13 +62,14 @@ public function onRun(): void {
6062
}
6163
}
6264

65+
6366
/*** @return bool */
6467
private function isExecutable(): bool {
6568
$player = $this->player;
6669
$amount = $this->amount;
6770

6871
return ($amount >= 1) &&
6972
($player->isOnline()) &&
70-
($player->getWorld() === $this->world);
73+
($player->getLevel() === $this->world);
7174
}
7275
}

src/jossc/volcano/utils/Utils.php

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,11 @@
33
namespace jossc\volcano\utils;
44

55
use jossc\volcano\entity\CustomFallingWoolBlock;
6-
use pocketmine\block\BlockFactory;
7-
use pocketmine\block\BlockLegacyIds;
8-
use pocketmine\entity\EntityDataHelper;
9-
use pocketmine\entity\Location;
6+
use pocketmine\entity\Entity;
7+
use pocketmine\level\Location;
108
use pocketmine\math\Vector3;
119
use pocketmine\network\mcpe\protocol\PlaySoundPacket;
12-
use pocketmine\player\Player;
10+
use pocketmine\Player;
1311

1412
class Utils {
1513

@@ -18,13 +16,9 @@ class Utils {
1816
* @return CustomFallingWoolBlock
1917
*/
2018
public static function generateFallingWoolBlock(Location $location): CustomFallingWoolBlock {
21-
$nbt = EntityDataHelper::createBaseNBT($location->asVector3());
19+
$nbt = Entity::createBaseNBT($location->asVector3());
2220

23-
$fallingBlock = new CustomFallingWoolBlock(
24-
$location,
25-
BlockFactory::getInstance()->get(BlockLegacyIds::WOOL, rand(0, 15)),
26-
$nbt
27-
);
21+
$fallingBlock = new CustomFallingWoolBlock($location->getLevel(), $nbt);
2822

2923
$fallingBlock->setMotion(new Vector3(
3024
-sin(mt_rand(1, 360) / 60 * M_PI),
@@ -52,6 +46,6 @@ public static function playSound(string $soundName, Player $player): void {
5246
$pk->y = $location->y;
5347
$pk->z = $location->z;
5448

55-
$player->getNetworkSession()->sendDataPacket($pk);
49+
$player->sendDataPacket($pk);
5650
}
5751
}

0 commit comments

Comments
 (0)