mirror of
https://gitlab.com/2009scape/2009scape.git
synced 2025-12-10 10:20:41 -07:00
Fixed issue where unequip listeners did not fire on death
This commit is contained in:
parent
678d25dacd
commit
86a25dd76f
2 changed files with 34 additions and 0 deletions
|
|
@ -11,6 +11,7 @@ import core.game.container.impl.EquipmentContainer;
|
|||
import core.game.container.impl.InventoryListener;
|
||||
import core.game.dialogue.DialogueInterpreter;
|
||||
import core.game.interaction.InteractPlugin;
|
||||
import core.game.interaction.InteractionListeners;
|
||||
import core.game.node.entity.Entity;
|
||||
import core.game.node.entity.combat.BattleState;
|
||||
import core.game.node.entity.combat.CombatStyle;
|
||||
|
|
@ -54,6 +55,7 @@ import core.net.packet.context.SkillContext;
|
|||
import core.net.packet.out.BuildDynamicScene;
|
||||
import core.net.packet.out.SkillLevel;
|
||||
import core.net.packet.out.UpdateSceneGraph;
|
||||
import core.plugin.Plugin;
|
||||
import core.tools.*;
|
||||
import kotlin.Unit;
|
||||
import kotlin.jvm.functions.Function1;
|
||||
|
|
@ -654,6 +656,13 @@ public class Player extends Entity {
|
|||
GroundItemManager.create(new Item(526), getLocation(), k);
|
||||
final Container[] c = DeathTask.getContainers(this);
|
||||
|
||||
for (Item i : getEquipment().toArray()) {
|
||||
if (i == null) continue;
|
||||
InteractionListeners.run(i.getId(), this, i, false);
|
||||
Plugin equipPlugin = i.getDefinition().getConfiguration("equipment", null);
|
||||
if (equipPlugin != null) equipPlugin.fireEvent("unequip");
|
||||
}
|
||||
|
||||
boolean canCreateGrave = GraveController.allowGenerate(this);
|
||||
if (canCreateGrave) {
|
||||
Grave g = GraveController.produceGrave(GraveController.getGraveType(this));
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@ package content
|
|||
|
||||
import TestUtils
|
||||
import core.api.EquipmentSlot
|
||||
import core.api.addItem
|
||||
import core.api.impact
|
||||
import core.game.node.entity.skill.Skills
|
||||
import core.game.node.item.Item
|
||||
import org.junit.jupiter.api.Assertions
|
||||
|
|
@ -11,6 +13,7 @@ import core.game.global.action.EquipHandler
|
|||
import core.game.interaction.InteractionListener
|
||||
import core.game.interaction.IntType
|
||||
import core.game.interaction.InteractionListeners
|
||||
import core.game.node.entity.player.info.Rights
|
||||
|
||||
class EquipTests {
|
||||
companion object {
|
||||
|
|
@ -141,4 +144,26 @@ class EquipTests {
|
|||
Assertions.assertEquals(p.inventory.getSlot(Item(Items.ABYSSAL_WHIP_4151)), 25)
|
||||
Assertions.assertEquals(p.inventory.getSlot(Item(Items.RUNE_DEFENDER_8850)), 0)
|
||||
}
|
||||
|
||||
@Test fun graveDeathWithEquippedItemShouldFireUnequipHooks() {
|
||||
TestUtils.getMockPlayer("graveunequip").use {p ->
|
||||
var hookFired = false
|
||||
val tempHook = object : InteractionListener {
|
||||
override fun defineListeners() {
|
||||
onUnequip(Items.ABYSSAL_WHIP_4151) { player, node ->
|
||||
hookFired = true
|
||||
return@onUnequip true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tempHook.defineListeners()
|
||||
p.details.rights = Rights.REGULAR_PLAYER
|
||||
addItem(p, Items.ABYSSAL_WHIP_4151, 28)
|
||||
p.equipment.replace(Item(Items.ABYSSAL_WHIP_4151), EquipmentSlot.WEAPON.ordinal)
|
||||
impact(p, p.skills.lifepoints)
|
||||
TestUtils.advanceTicks(25, false)
|
||||
Assertions.assertEquals(true, hookFired)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue