Last active
May 17, 2023 23:30
-
-
Save TheNewHEROBRINEX/161575fa78077d3b1043cb529fb92bad to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
public function onItemPickup(InventoryPickupItemEvent $event) : void{ | |
$inventory = $event->getInventory(); | |
if($inventory instanceof PlayerInventory){ | |
$player = $inventory->getHolder(); | |
if($player instanceof Player){ | |
$murderPlayer = $this->plugin->findMurderPlayer($player); | |
$itemEntity = $event->getItem(); | |
$itemItem = $itemEntity->getItem(); | |
if($murderPlayer instanceof MurderPlayer){ | |
$event->setCancelled(); | |
if($murderPlayer->isAlive()){ | |
$murderRole = $murderPlayer->getRoleNonNull(); | |
if(match($itemItem->getId()){ | |
ItemIds::EMERALD => $murderRole->onEmeraldPickup(), | |
ItemIds::WOODEN_SWORD, ItemIds::STONE_SWORD, ItemIds::IRON_SWORD, ItemIds::GOLDEN_SWORD, ItemIds::DIAMOND_SWORD => $murderRole->onSwordPickup($itemItem), | |
default => false | |
}){ | |
$pk = new TakeItemActorPacket(); //play sound and despawn as normal | |
$pk->eid = $player->getId(); | |
$pk->target = $itemEntity->getId(); | |
$this->getPlugin()->getServer()->broadcastPacket($player->getViewers(), $pk); | |
$itemEntity->flagForDespawn(); | |
} | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment