Added additional safety when cleaning up cutscene attributes

This commit is contained in:
Ceikry 2022-07-05 08:09:06 +00:00 committed by Ryan
parent 7300e746b1
commit b5213c40b4
2 changed files with 23 additions and 12 deletions

View file

@ -370,6 +370,7 @@ public class DuelArea extends MapZone {
* @param p the player. * @param p the player.
*/ */
private void leave(Player p) { private void leave(Player p) {
p.getProperties().setSafeZone(false);
if (p.getAttribute("duel:ammo", null) != null) { if (p.getAttribute("duel:ammo", null) != null) {
List<GroundItem> ammo = p.getAttribute("duel:ammo"); List<GroundItem> ammo = p.getAttribute("duel:ammo");
Container c = new Container(40); Container c = new Container(40);

View file

@ -256,7 +256,21 @@ abstract class Cutscene(val player: Player) {
8 -> player.properties.teleportLocation = exitLocation 8 -> player.properties.teleportLocation = exitLocation
9 -> fadeFromBlack() 9 -> fadeFromBlack()
16 -> { 16 -> {
try {
endActions?.invoke() endActions?.invoke()
} catch (e: Exception) {
SystemLogger.logErr("There's some bad nasty code in ${this::class.java.simpleName} end actions!")
e.printStackTrace()
}
return true
}
}
return false
}
override fun stop() {
super.stop()
player ?: return
player.removeAttribute(ATTRIBUTE_CUTSCENE) player.removeAttribute(ATTRIBUTE_CUTSCENE)
player.removeAttribute(ATTRIBUTE_CUTSCENE_STAGE) player.removeAttribute(ATTRIBUTE_CUTSCENE_STAGE)
player.properties.isSafeZone = false player.properties.isSafeZone = false
@ -266,12 +280,8 @@ abstract class Cutscene(val player: Player) {
clearNPCs() clearNPCs()
player.unhook(CUTSCENE_DEATH_HOOK) player.unhook(CUTSCENE_DEATH_HOOK)
player.logoutListeners.remove("cutscene") player.logoutListeners.remove("cutscene")
RandomEventManager.getInstance(player)!!.enabled = true RandomEventManager.getInstance(player)?.enabled = true
PacketRepository.send(MinimapState::class.java, MinimapStateContext(player, 0)) PacketRepository.send(MinimapState::class.java, MinimapStateContext(player, 0))
return true
}
}
return false
} }
}) })
} }