Dropped the use of GameTimeController for spawn protection.

This commit is contained in:
MobiusDev
2018-04-18 01:54:52 +00:00
parent 999f8d09ac
commit a05027021a
28 changed files with 150 additions and 231 deletions

View File

@@ -688,21 +688,10 @@ public final class L2PcInstance extends L2Playable
private L2ItemInstance _boltItem;
// Used for protection after teleport
private long _protectEndTime = 0;
private L2ItemInstance _lure = null;
public boolean isSpawnProtected()
{
return _protectEndTime > GameTimeController.getInstance().getGameTicks();
}
private long _spawnProtectEndTime = 0;
private long _teleportProtectEndTime = 0;
public boolean isTeleportProtected()
{
return _teleportProtectEndTime > GameTimeController.getInstance().getGameTicks();
}
private L2ItemInstance _lure = null;
// protects a char from aggro mobs when getting up from fake death
private long _recentFakeDeathEndTime = 0;
@@ -3846,32 +3835,28 @@ public final class L2PcInstance extends L2Playable
return item;
}
/**
* Set _protectEndTime according settings.
* @param protect
*/
public void setProtection(boolean protect)
public boolean isSpawnProtected()
{
if (Config.DEVELOPER && (protect || (_protectEndTime > 0)))
{
LOGGER.warning(getName() + ": Protection " + (protect ? "ON " + (GameTimeController.getInstance().getGameTicks() + (Config.PLAYER_SPAWN_PROTECTION * GameTimeController.TICKS_PER_SECOND)) : "OFF") + " (currently " + GameTimeController.getInstance().getGameTicks() + ")");
}
_protectEndTime = protect ? GameTimeController.getInstance().getGameTicks() + (Config.PLAYER_SPAWN_PROTECTION * GameTimeController.TICKS_PER_SECOND) : 0;
return _spawnProtectEndTime > System.currentTimeMillis();
}
public boolean isTeleportProtected()
{
return _teleportProtectEndTime > System.currentTimeMillis();
}
public void setSpawnProtection(boolean protect)
{
_spawnProtectEndTime = protect ? System.currentTimeMillis() + (Config.PLAYER_SPAWN_PROTECTION * 1000) : 0;
}
public void setTeleportProtection(boolean protect)
{
if (Config.DEVELOPER && (protect || (_teleportProtectEndTime > 0)))
{
LOGGER.warning(getName() + ": Tele Protection " + (protect ? "ON " + (GameTimeController.getInstance().getGameTicks() + (Config.PLAYER_TELEPORT_PROTECTION * GameTimeController.TICKS_PER_SECOND)) : "OFF") + " (currently " + GameTimeController.getInstance().getGameTicks() + ")");
}
_teleportProtectEndTime = protect ? GameTimeController.getInstance().getGameTicks() + (Config.PLAYER_TELEPORT_PROTECTION * GameTimeController.TICKS_PER_SECOND) : 0;
_teleportProtectEndTime = protect ? System.currentTimeMillis() + (Config.PLAYER_TELEPORT_PROTECTION * 1000) : 0;
}
/**
* Set protection from agro mobs when getting up from fake death, according settings.
* Set protection from aggro mobs when getting up from fake death, according settings.
* @param protect
*/
public void setRecentFakeDeath(boolean protect)
@@ -10738,7 +10723,7 @@ public final class L2PcInstance extends L2Playable
{
if (isSpawnProtected())
{
setProtection(false);
setSpawnProtection(false);
if (!isInsideZone(ZoneId.PEACE))
{
sendPacket(SystemMessageId.YOU_ARE_NO_LONGER_PROTECTED_FROM_AGGRESSIVE_MONSTERS);

View File

@@ -437,7 +437,7 @@ public class EnterWorld implements IClientIncomingPacket
if (Config.PLAYER_SPAWN_PROTECTION > 0)
{
activeChar.setProtection(true);
activeChar.setSpawnProtection(true);
}
activeChar.spawnMe(activeChar.getX(), activeChar.getY(), activeChar.getZ());