Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to PM5 #67

Merged
merged 3 commits into from
Oct 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: PHPStan

on: [push, pull_request]

jobs:
phpstan:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
ref: ${{ github.ref }}
- uses: shivammathur/setup-php@v2
with:
php-version: '8.0'
- name: Create Vendor Directory
run: |
echo Making directory...
mkdir vendor
echo Directory made.
- name: wget InvMenu
uses: wei/wget@v1
with:
args: -O vendor/InvMenu.phar https://poggit.pmmp.io/r/219916/InvMenu_dev-196.phar
- name: Run PHPStan
uses: paroxity/pmmp-phpstan-action@5.3.0
with:
phpstan-config: phpstan.neon.dist
14 changes: 14 additions & 0 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
parameters:
paths:
- /source/src
level: 6
bootstrapFiles:
- phar:///pocketmine/PocketMine-MP.phar/vendor/autoload.php
scanDirectories:
- /source/src
- phar:///source/vendor/InvMenu.phar/src/
excludePaths:
analyse:
- source/vendor
reportUnmatchedIgnoredErrors: false
checkMissingIterableValueType: false
4 changes: 2 additions & 2 deletions plugin.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Minion
version: 2.0.0
api: 4.0.0
version: 2.1.0
api: 5.0.0
main: CLADevs\Minion\Loader
author: CLADevs
depend:
Expand Down
3 changes: 2 additions & 1 deletion resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ blocks:
normal: true
#Blocks that cannot be broken
#ids of block that cannot be broken
cannot: [7, 20]
# Must be vanilla names
cannot: ["obsidian"]

level:
#if they reach level 2 or higher they will have auto smelt unlocked put "n" to turn it off
Expand Down
2 changes: 0 additions & 2 deletions src/CLADevs/Minion/Loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ class Loader extends PluginBase{

private array $removeTap = [];

private array $minions = [];

public function onLoad(): void{
self::setInstance($this);
foreach(array_keys($this->getResources()) as $path){
Expand Down
17 changes: 8 additions & 9 deletions src/CLADevs/Minion/entities/MinionEntity.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,12 @@
use muqsit\invmenu\transaction\InvMenuTransactionResult;
use pocketmine\block\Block;
use pocketmine\block\tile\Chest;
use pocketmine\block\utils\MobHeadType;
use pocketmine\block\VanillaBlocks;
use pocketmine\entity\Human;
use pocketmine\event\entity\EntityDamageByEntityEvent;
use pocketmine\event\entity\EntityDamageEvent;
use pocketmine\inventory\Inventory;
use pocketmine\item\ItemFactory;
use pocketmine\item\ItemIds;
use pocketmine\item\ItemTypeIds;
use pocketmine\item\VanillaItems;
use pocketmine\math\Vector3;
use pocketmine\nbt\tag\CompoundTag;
Expand Down Expand Up @@ -113,7 +112,7 @@ public function entityBaseTick(int $tickDiff = 1): bool{
}

public function sendSpawnItems(): void{
$this->getArmorInventory()->setHelmet(VanillaItems::PLAYER_HEAD());
$this->getArmorInventory()->setHelmet(VanillaBlocks::MOB_HEAD()->setMobHeadType(MobHeadType::PLAYER())->asItem());
$this->getArmorInventory()->setChestplate(VanillaItems::LEATHER_TUNIC());
$this->getArmorInventory()->setLeggings(VanillaItems::LEATHER_PANTS());
$this->getArmorInventory()->setBoots(VanillaItems::LEATHER_BOOTS());
Expand All @@ -136,8 +135,8 @@ public function breakBlock(Block $block): bool{
}
$success = true;
}
if(!in_array($block->getId(), Configuration::getUnbreakableBlocks()) && !$success){
$inv->addItem(ItemFactory::getInstance()->get($block->getId(), $block->getMeta()));
if(!in_array($block->getName(), Configuration::getUnbreakableBlocks()) && !$success){
$inv->addItem($block->asItem());
$success = true;
}
}
Expand Down Expand Up @@ -196,16 +195,16 @@ public function getMainInventory(?callable $callable = null): InvMenu{
$player = $tr->getPlayer();
$item = $tr->getItemClicked();

switch($item->getId()){
case ItemIds::REDSTONE_DUST:
switch($item->getTypeId()){
case ItemTypeIds::REDSTONE_DUST:
if($this->isFlaggedForDespawn()){
return $tr->discard();
}
MinionListener::getInstance()->removeLinkable($player);
$this->flagForDespawn();
$player->getInventory()->addItem(Loader::getInstance()->asMinionItem(static::getMinionType(), $player, $this->getLevel()));
break;
case ItemIds::CHEST:
case VanillaBlocks::CHEST()->asItem()->getTypeId():
if($this->getLookingBehind() instanceof \pocketmine\block\Chest){
$player->sendMessage(TextFormat::RED . "Please remove the chest behind the miner, to set new linkable chest.");
return $tr->discard();
Expand Down
6 changes: 3 additions & 3 deletions src/CLADevs/Minion/entities/types/FarmerMinion.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use muqsit\invmenu\transaction\InvMenuTransaction;
use muqsit\invmenu\transaction\InvMenuTransactionResult;
use pocketmine\block\Block;
use pocketmine\block\BlockLegacyIds;
use pocketmine\block\BlockTypeIds;
use pocketmine\block\Chest;
use pocketmine\block\Crops;
use pocketmine\item\VanillaItems;
Expand Down Expand Up @@ -50,7 +50,7 @@ public function entityBaseTick(int $tickDiff = 1): bool{
$xz = clone $this->getPosition()->add($x, 0, $z);
$pos = clone $xz->subtract(0, 1, 0);

if($this->getWorld()->getBlock($pos)->getId() === BlockLegacyIds::FARMLAND && $i !== 4){ //4 is middle block
if($this->getWorld()->getBlock($pos)->getTypeId() === BlockTypeIds::FARMLAND && $i !== 4){ //4 is middle block
$b = $this->getWorld()->getBlock($xz);

if($b instanceof Crops && $b->getAge() >= 7){
Expand Down Expand Up @@ -80,7 +80,7 @@ public function breakBlock(Block $block): bool{
$inv = $tile->getInventory();

foreach($inv->getContents() as $slot => $item){
if($item->getBlock()->getId() === $block->getId()){
if($item->getBlock()->getTypeId() === $block->getTypeId()){
$this->getInventory()->setItemInHand($item);
$this->getWorld()->setBlock($block->getPosition(), $item->getBlock(), true);
$this->sendSpawnItems();
Expand Down
4 changes: 2 additions & 2 deletions src/CLADevs/Minion/entities/types/MinerMinion.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
use onebone\economyapi\EconomyAPI;
use pocketmine\block\Air;
use pocketmine\block\Chest;
use pocketmine\item\ItemIds;
use pocketmine\item\ItemTypeIds;
use pocketmine\item\VanillaItems;
use pocketmine\player\Player;
use pocketmine\Server;
Expand Down Expand Up @@ -75,7 +75,7 @@ protected function handleInventory(Player $attacker): void{
$player = $tr->getPlayer();
$item = $tr->getItemClicked();

if($item->getId() === ItemIds::EMERALD){
if($item->getTypeId() === ItemTypeIds::EMERALD){
if(($lvl = $this->getLevel()) >= Configuration::getMaxLevel()){
$player->sendMessage(TextFormat::RED . "You have maxed the level!");
return $tr->discard();
Expand Down
Loading