Improvements for player notify death in instance.

This commit is contained in:
MobiusDev
2018-04-30 04:43:20 +00:00
parent dca612dbb5
commit d4ac772ecb
9 changed files with 26 additions and 48 deletions

View File

@ -883,12 +883,12 @@ public final class Instance implements IIdentifiable, INamable
// Listeners // Listeners
// --------------------------------------------- // ---------------------------------------------
/** /**
* This method is called when player dead inside instance. * This method is called when player dies inside instance.
* @param player * @param player
*/ */
public void onDeath(L2PcInstance player) public void onDeath(L2PcInstance player)
{ {
if (!player.isOnCustomEvent()) if (!player.isOnCustomEvent() && (_template.getEjectTime() > 0))
{ {
// Send message // Send message
final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.IF_YOU_ARE_NOT_RESURRECTED_WITHIN_S1_MINUTE_S_YOU_WILL_BE_EXPELLED_FROM_THE_INSTANT_ZONE); final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.IF_YOU_ARE_NOT_RESURRECTED_WITHIN_S1_MINUTE_S_YOU_WILL_BE_EXPELLED_FROM_THE_INSTANT_ZONE);

View File

@ -883,12 +883,12 @@ public final class Instance implements IIdentifiable, INamable
// Listeners // Listeners
// --------------------------------------------- // ---------------------------------------------
/** /**
* This method is called when player dead inside instance. * This method is called when player dies inside instance.
* @param player * @param player
*/ */
public void onDeath(L2PcInstance player) public void onDeath(L2PcInstance player)
{ {
if (!player.isOnCustomEvent()) if (!player.isOnCustomEvent() && (_template.getEjectTime() > 0))
{ {
// Send message // Send message
final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.IF_YOU_ARE_NOT_RESURRECTED_WITHIN_S1_MINUTE_S_YOU_WILL_BE_EXPELLED_FROM_THE_INSTANT_ZONE); final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.IF_YOU_ARE_NOT_RESURRECTED_WITHIN_S1_MINUTE_S_YOU_WILL_BE_EXPELLED_FROM_THE_INSTANT_ZONE);

View File

@ -883,12 +883,12 @@ public final class Instance implements IIdentifiable, INamable
// Listeners // Listeners
// --------------------------------------------- // ---------------------------------------------
/** /**
* This method is called when player dead inside instance. * This method is called when player dies inside instance.
* @param player * @param player
*/ */
public void onDeath(L2PcInstance player) public void onDeath(L2PcInstance player)
{ {
if (!player.isOnCustomEvent()) if (!player.isOnCustomEvent() && (_template.getEjectTime() > 0))
{ {
// Send message // Send message
final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.IF_YOU_ARE_NOT_RESURRECTED_WITHIN_S1_MINUTE_S_YOU_WILL_BE_EXPELLED_FROM_THE_INSTANT_ZONE); final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.IF_YOU_ARE_NOT_RESURRECTED_WITHIN_S1_MINUTE_S_YOU_WILL_BE_EXPELLED_FROM_THE_INSTANT_ZONE);

View File

@ -883,12 +883,12 @@ public final class Instance implements IIdentifiable, INamable
// Listeners // Listeners
// --------------------------------------------- // ---------------------------------------------
/** /**
* This method is called when player dead inside instance. * This method is called when player dies inside instance.
* @param player * @param player
*/ */
public void onDeath(L2PcInstance player) public void onDeath(L2PcInstance player)
{ {
if (!player.isOnCustomEvent()) if (!player.isOnCustomEvent() && (_template.getEjectTime() > 0))
{ {
// Send message // Send message
final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.IF_YOU_ARE_NOT_RESURRECTED_WITHIN_S1_MINUTE_S_YOU_WILL_BE_EXPELLED_FROM_THE_INSTANT_ZONE); final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.IF_YOU_ARE_NOT_RESURRECTED_WITHIN_S1_MINUTE_S_YOU_WILL_BE_EXPELLED_FROM_THE_INSTANT_ZONE);

View File

@ -169,12 +169,12 @@ public abstract class L2Playable extends L2Character
} }
} }
// Notify instance // Notify instance
if (getInstanceId() > 0) if ((getInstanceId() > 0) && isPlayer())
{ {
final Instance instance = InstanceManager.getInstance().getInstance(getInstanceId()); final Instance instance = InstanceManager.getInstance().getInstance(getInstanceId());
if (instance != null) if (instance != null)
{ {
instance.notifyDeath(killer, this); instance.notifyDeath(actingPlayer);
} }
} }

View File

@ -49,7 +49,6 @@ import com.l2jmobius.gameserver.model.Location;
import com.l2jmobius.gameserver.model.StatsSet; import com.l2jmobius.gameserver.model.StatsSet;
import com.l2jmobius.gameserver.model.TeleportWhereType; import com.l2jmobius.gameserver.model.TeleportWhereType;
import com.l2jmobius.gameserver.model.actor.L2Attackable; import com.l2jmobius.gameserver.model.actor.L2Attackable;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.actor.L2Npc; import com.l2jmobius.gameserver.model.actor.L2Npc;
import com.l2jmobius.gameserver.model.actor.instance.L2DoorInstance; import com.l2jmobius.gameserver.model.actor.instance.L2DoorInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance; import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
@ -872,10 +871,20 @@ public final class Instance
} }
} }
public void addEjectDeadTask(L2PcInstance player) /**
* This method is called when player dies inside instance.
* @param player
*/
public void notifyDeath(L2PcInstance player)
{ {
if (player != null) if (!player.isOnEvent() && (_ejectTime > 0))
{ {
// Send message
final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.IF_YOU_ARE_NOT_RESURRECTED_WITHIN_S1_MINUTES_YOU_WILL_BE_EXPELLED_FROM_THE_INSTANT_ZONE);
sm.addInt(_ejectTime / 60 / 1000);
player.sendPacket(sm);
// Start eject task
_ejectDeadTasks.put(player.getObjectId(), ThreadPool.schedule(() -> _ejectDeadTasks.put(player.getObjectId(), ThreadPool.schedule(() ->
{ {
if (player.isDead() && (player.getInstanceId() == getId())) if (player.isDead() && (player.getInstanceId() == getId()))
@ -894,19 +903,6 @@ public final class Instance
} }
} }
/**
* @param killer the character that killed the {@code victim}
* @param victim the character that was killed by the {@code killer}
*/
public final void notifyDeath(L2Character killer, L2Character victim)
{
final InstanceWorld instance = InstanceManager.getInstance().getPlayerWorld(victim.getActingPlayer());
if (instance != null)
{
instance.onDeath(killer, victim);
}
}
public class CheckTimeUp implements Runnable public class CheckTimeUp implements Runnable
{ {
private final int _remaining; private final int _remaining;

View File

@ -25,8 +25,6 @@ import com.l2jmobius.gameserver.model.StatsSet;
import com.l2jmobius.gameserver.model.actor.L2Character; import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.actor.L2Npc; import com.l2jmobius.gameserver.model.actor.L2Npc;
import com.l2jmobius.gameserver.model.actor.instance.L2DoorInstance; import com.l2jmobius.gameserver.model.actor.instance.L2DoorInstance;
import com.l2jmobius.gameserver.network.SystemMessageId;
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
/** /**
* Basic instance zone data transfer object. * Basic instance zone data transfer object.
@ -150,22 +148,6 @@ public class InstanceWorld
return status; return status;
} }
/**
* @param killer
* @param victim
*/
public void onDeath(L2Character killer, L2Character victim)
{
if ((victim == null) || !victim.isPlayer() || (_instance == null))
{
return;
}
final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.IF_YOU_ARE_NOT_RESURRECTED_WITHIN_S1_MINUTES_YOU_WILL_BE_EXPELLED_FROM_THE_INSTANT_ZONE);
sm.addInt(_instance.getEjectTime() / 60 / 1000);
victim.getActingPlayer().sendPacket(sm);
_instance.addEjectDeadTask(victim.getActingPlayer());
}
/** /**
* Get spawned NPCs from instance. * Get spawned NPCs from instance.
* @return set of NPCs from instance * @return set of NPCs from instance

View File

@ -883,12 +883,12 @@ public final class Instance implements IIdentifiable, INamable
// Listeners // Listeners
// --------------------------------------------- // ---------------------------------------------
/** /**
* This method is called when player dead inside instance. * This method is called when player dies inside instance.
* @param player * @param player
*/ */
public void onDeath(L2PcInstance player) public void onDeath(L2PcInstance player)
{ {
if (!player.isOnCustomEvent()) if (!player.isOnCustomEvent() && (_template.getEjectTime() > 0))
{ {
// Send message // Send message
final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.IF_YOU_ARE_NOT_RESURRECTED_WITHIN_S1_MINUTE_S_YOU_WILL_BE_EXPELLED_FROM_THE_INSTANT_ZONE); final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.IF_YOU_ARE_NOT_RESURRECTED_WITHIN_S1_MINUTE_S_YOU_WILL_BE_EXPELLED_FROM_THE_INSTANT_ZONE);

View File

@ -883,12 +883,12 @@ public final class Instance implements IIdentifiable, INamable
// Listeners // Listeners
// --------------------------------------------- // ---------------------------------------------
/** /**
* This method is called when player dead inside instance. * This method is called when player dies inside instance.
* @param player * @param player
*/ */
public void onDeath(L2PcInstance player) public void onDeath(L2PcInstance player)
{ {
if (!player.isOnCustomEvent()) if (!player.isOnCustomEvent() && (_template.getEjectTime() > 0))
{ {
// Send message // Send message
final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.IF_YOU_ARE_NOT_RESURRECTED_WITHIN_S1_MINUTE_S_YOU_WILL_BE_EXPELLED_FROM_THE_INSTANT_ZONE); final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.IF_YOU_ARE_NOT_RESURRECTED_WITHIN_S1_MINUTE_S_YOU_WILL_BE_EXPELLED_FROM_THE_INSTANT_ZONE);