Skip to content

Commit

Permalink
Fix effects staying when items replaced in inventory, closes #397
Browse files Browse the repository at this point in the history
  • Loading branch information
Aericio committed Sep 29, 2023
1 parent f2750c7 commit d2fdb06
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/DaPigGuy/PiggyCustomEnchants/EventListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -208,9 +208,9 @@ public function onJoin(PlayerJoinEvent $event): void
if ($inventory instanceof PlayerInventory || $inventory instanceof ArmorInventory) {
$holder = $inventory->getHolder();
if ($holder instanceof Player) {
if (!$oldItem->equals(($newItem = $inventory->getItem($slot)), !$inventory instanceof ArmorInventory)) {
if ($newItem->equals(VanillaItems::AIR()) || $inventory instanceof ArmorInventory) foreach ($oldItem->getEnchantments() as $oldEnchantment) ToggleableEnchantment::attemptToggle($holder, $oldItem, $oldEnchantment, $inventory, $slot, false);
if ($oldItem->equals(VanillaItems::AIR()) || $inventory instanceof ArmorInventory) foreach ($newItem->getEnchantments() as $newEnchantment) ToggleableEnchantment::attemptToggle($holder, $newItem, $newEnchantment, $inventory, $slot);
if (!$oldItem->equals(($newItem = $inventory->getItem($slot)), false)) {
foreach ($oldItem->getEnchantments() as $oldEnchantment) ToggleableEnchantment::attemptToggle($holder, $oldItem, $oldEnchantment, $inventory, $slot, false);
foreach ($newItem->getEnchantments() as $newEnchantment) ToggleableEnchantment::attemptToggle($holder, $newItem, $newEnchantment, $inventory, $slot);
}
}
}
Expand Down

0 comments on commit d2fdb06

Please sign in to comment.