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