Addition of CreatureSeeTaskManager.

This commit is contained in:
MobiusDevelopment 2021-06-23 22:27:40 +00:00
parent 71dd707e53
commit 1d6efc99e4
110 changed files with 1672 additions and 418 deletions

View File

@ -254,7 +254,6 @@ public abstract class AbstractAI implements Ctrl
{
case EVT_THINK:
{
_actor.updateSeenCreatures();
onEvtThink();
break;
}

View File

@ -37,8 +37,6 @@ import org.l2jmobius.gameserver.model.actor.Npc;
import org.l2jmobius.gameserver.model.actor.Summon;
import org.l2jmobius.gameserver.model.actor.instance.PetInstance;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.events.EventDispatcher;
import org.l2jmobius.gameserver.model.events.impl.creature.OnCreatureSee;
import org.l2jmobius.gameserver.network.Disconnection;
import org.l2jmobius.gameserver.network.serverpackets.DeleteObject;
@ -357,13 +355,6 @@ public class World
}
}
}
// Notify OnCreatureSee for creatures that do not trigger EVT_THINK.
if (!wo.isAttackable() && wo.isCreature() && object.isCreature())
{
EventDispatcher.getInstance().notifyEventAsync(new OnCreatureSee((Creature) wo, (Creature) object), (Creature) wo);
EventDispatcher.getInstance().notifyEventAsync(new OnCreatureSee((Creature) object, (Creature) wo), (Creature) object);
}
});
}
@ -577,13 +568,6 @@ public class World
}
}
}
// Notify OnCreatureSee for creatures that do not trigger EVT_THINK.
if (!wo.isAttackable() && wo.isCreature() && object.isCreature())
{
EventDispatcher.getInstance().notifyEventAsync(new OnCreatureSee((Creature) wo, (Creature) object), (Creature) wo);
EventDispatcher.getInstance().notifyEventAsync(new OnCreatureSee((Creature) object, (Creature) wo), (Creature) object);
}
}
}
}

View File

@ -157,6 +157,7 @@ import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
import org.l2jmobius.gameserver.network.serverpackets.TeleportToLocation;
import org.l2jmobius.gameserver.network.serverpackets.UserInfo;
import org.l2jmobius.gameserver.taskmanager.AttackStanceTaskManager;
import org.l2jmobius.gameserver.taskmanager.CreatureSeeTaskManager;
import org.l2jmobius.gameserver.taskmanager.GameTimeTaskManager;
import org.l2jmobius.gameserver.util.Util;
@ -1751,6 +1752,7 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
// Forget all seen creatures.
if (_seenCreatures != null)
{
CreatureSeeTaskManager.getInstance().remove(this);
_seenCreatures.clear();
}
@ -5446,6 +5448,8 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
}
}
}
CreatureSeeTaskManager.getInstance().add(this);
}
public void updateSeenCreatures()

View File

@ -1075,8 +1075,7 @@ public class Npc extends Creature
setClanId(getCastle().getOwnerId());
}
if (isAttackable() // OnCreatureSee for non attackables is triggered at World.
&& CREATURE_SEE_IDS.contains(getId()))
if (CREATURE_SEE_IDS.contains(getId()))
{
initSeenCreatures();
}

View File

@ -0,0 +1,71 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.l2jmobius.gameserver.taskmanager;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import org.l2jmobius.commons.concurrent.ThreadPool;
import org.l2jmobius.gameserver.model.actor.Creature;
/**
* @author Mobius
*/
public class CreatureSeeTaskManager
{
private static final Set<Creature> CREATURES = ConcurrentHashMap.newKeySet();
private static boolean _working = false;
public CreatureSeeTaskManager()
{
ThreadPool.scheduleAtFixedRate(() ->
{
if (_working)
{
return;
}
_working = true;
for (Creature creature : CREATURES)
{
creature.updateSeenCreatures();
}
_working = false;
}, 1000, 1000);
}
public void add(Creature creature)
{
CREATURES.add(creature);
}
public void remove(Creature creature)
{
CREATURES.remove(creature);
}
public static CreatureSeeTaskManager getInstance()
{
return SingletonHolder.INSTANCE;
}
private static class SingletonHolder
{
protected static final CreatureSeeTaskManager INSTANCE = new CreatureSeeTaskManager();
}
}

View File

@ -254,7 +254,6 @@ public abstract class AbstractAI implements Ctrl
{
case EVT_THINK:
{
_actor.updateSeenCreatures();
onEvtThink();
break;
}

View File

@ -37,8 +37,6 @@ import org.l2jmobius.gameserver.model.actor.Npc;
import org.l2jmobius.gameserver.model.actor.Summon;
import org.l2jmobius.gameserver.model.actor.instance.PetInstance;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.events.EventDispatcher;
import org.l2jmobius.gameserver.model.events.impl.creature.OnCreatureSee;
import org.l2jmobius.gameserver.network.Disconnection;
import org.l2jmobius.gameserver.network.serverpackets.DeleteObject;
@ -357,13 +355,6 @@ public class World
}
}
}
// Notify OnCreatureSee for creatures that do not trigger EVT_THINK.
if (!wo.isAttackable() && wo.isCreature() && object.isCreature())
{
EventDispatcher.getInstance().notifyEventAsync(new OnCreatureSee((Creature) wo, (Creature) object), (Creature) wo);
EventDispatcher.getInstance().notifyEventAsync(new OnCreatureSee((Creature) object, (Creature) wo), (Creature) object);
}
});
}
@ -577,13 +568,6 @@ public class World
}
}
}
// Notify OnCreatureSee for creatures that do not trigger EVT_THINK.
if (!wo.isAttackable() && wo.isCreature() && object.isCreature())
{
EventDispatcher.getInstance().notifyEventAsync(new OnCreatureSee((Creature) wo, (Creature) object), (Creature) wo);
EventDispatcher.getInstance().notifyEventAsync(new OnCreatureSee((Creature) object, (Creature) wo), (Creature) object);
}
}
}
}

View File

@ -157,6 +157,7 @@ import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
import org.l2jmobius.gameserver.network.serverpackets.TeleportToLocation;
import org.l2jmobius.gameserver.network.serverpackets.UserInfo;
import org.l2jmobius.gameserver.taskmanager.AttackStanceTaskManager;
import org.l2jmobius.gameserver.taskmanager.CreatureSeeTaskManager;
import org.l2jmobius.gameserver.taskmanager.GameTimeTaskManager;
import org.l2jmobius.gameserver.util.Util;
@ -1751,6 +1752,7 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
// Forget all seen creatures.
if (_seenCreatures != null)
{
CreatureSeeTaskManager.getInstance().remove(this);
_seenCreatures.clear();
}
@ -5446,6 +5448,8 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
}
}
}
CreatureSeeTaskManager.getInstance().add(this);
}
public void updateSeenCreatures()

View File

@ -1075,8 +1075,7 @@ public class Npc extends Creature
setClanId(getCastle().getOwnerId());
}
if (isAttackable() // OnCreatureSee for non attackables is triggered at World.
&& CREATURE_SEE_IDS.contains(getId()))
if (CREATURE_SEE_IDS.contains(getId()))
{
initSeenCreatures();
}

View File

@ -0,0 +1,71 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.l2jmobius.gameserver.taskmanager;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import org.l2jmobius.commons.concurrent.ThreadPool;
import org.l2jmobius.gameserver.model.actor.Creature;
/**
* @author Mobius
*/
public class CreatureSeeTaskManager
{
private static final Set<Creature> CREATURES = ConcurrentHashMap.newKeySet();
private static boolean _working = false;
public CreatureSeeTaskManager()
{
ThreadPool.scheduleAtFixedRate(() ->
{
if (_working)
{
return;
}
_working = true;
for (Creature creature : CREATURES)
{
creature.updateSeenCreatures();
}
_working = false;
}, 1000, 1000);
}
public void add(Creature creature)
{
CREATURES.add(creature);
}
public void remove(Creature creature)
{
CREATURES.remove(creature);
}
public static CreatureSeeTaskManager getInstance()
{
return SingletonHolder.INSTANCE;
}
private static class SingletonHolder
{
protected static final CreatureSeeTaskManager INSTANCE = new CreatureSeeTaskManager();
}
}

View File

@ -254,7 +254,6 @@ public abstract class AbstractAI implements Ctrl
{
case EVT_THINK:
{
_actor.updateSeenCreatures();
onEvtThink();
break;
}

View File

@ -37,8 +37,6 @@ import org.l2jmobius.gameserver.model.actor.Npc;
import org.l2jmobius.gameserver.model.actor.Summon;
import org.l2jmobius.gameserver.model.actor.instance.PetInstance;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.events.EventDispatcher;
import org.l2jmobius.gameserver.model.events.impl.creature.OnCreatureSee;
import org.l2jmobius.gameserver.network.Disconnection;
import org.l2jmobius.gameserver.network.serverpackets.DeleteObject;
@ -357,13 +355,6 @@ public class World
}
}
}
// Notify OnCreatureSee for creatures that do not trigger EVT_THINK.
if (!wo.isAttackable() && wo.isCreature() && object.isCreature())
{
EventDispatcher.getInstance().notifyEventAsync(new OnCreatureSee((Creature) wo, (Creature) object), (Creature) wo);
EventDispatcher.getInstance().notifyEventAsync(new OnCreatureSee((Creature) object, (Creature) wo), (Creature) object);
}
});
}
@ -577,13 +568,6 @@ public class World
}
}
}
// Notify OnCreatureSee for creatures that do not trigger EVT_THINK.
if (!wo.isAttackable() && wo.isCreature() && object.isCreature())
{
EventDispatcher.getInstance().notifyEventAsync(new OnCreatureSee((Creature) wo, (Creature) object), (Creature) wo);
EventDispatcher.getInstance().notifyEventAsync(new OnCreatureSee((Creature) object, (Creature) wo), (Creature) object);
}
}
}
}

View File

@ -157,6 +157,7 @@ import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
import org.l2jmobius.gameserver.network.serverpackets.TeleportToLocation;
import org.l2jmobius.gameserver.network.serverpackets.UserInfo;
import org.l2jmobius.gameserver.taskmanager.AttackStanceTaskManager;
import org.l2jmobius.gameserver.taskmanager.CreatureSeeTaskManager;
import org.l2jmobius.gameserver.taskmanager.GameTimeTaskManager;
import org.l2jmobius.gameserver.util.Util;
@ -1751,6 +1752,7 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
// Forget all seen creatures.
if (_seenCreatures != null)
{
CreatureSeeTaskManager.getInstance().remove(this);
_seenCreatures.clear();
}
@ -5446,6 +5448,8 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
}
}
}
CreatureSeeTaskManager.getInstance().add(this);
}
public void updateSeenCreatures()

View File

@ -1075,8 +1075,7 @@ public class Npc extends Creature
setClanId(getCastle().getOwnerId());
}
if (isAttackable() // OnCreatureSee for non attackables is triggered at World.
&& CREATURE_SEE_IDS.contains(getId()))
if (CREATURE_SEE_IDS.contains(getId()))
{
initSeenCreatures();
}

View File

@ -0,0 +1,71 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.l2jmobius.gameserver.taskmanager;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import org.l2jmobius.commons.concurrent.ThreadPool;
import org.l2jmobius.gameserver.model.actor.Creature;
/**
* @author Mobius
*/
public class CreatureSeeTaskManager
{
private static final Set<Creature> CREATURES = ConcurrentHashMap.newKeySet();
private static boolean _working = false;
public CreatureSeeTaskManager()
{
ThreadPool.scheduleAtFixedRate(() ->
{
if (_working)
{
return;
}
_working = true;
for (Creature creature : CREATURES)
{
creature.updateSeenCreatures();
}
_working = false;
}, 1000, 1000);
}
public void add(Creature creature)
{
CREATURES.add(creature);
}
public void remove(Creature creature)
{
CREATURES.remove(creature);
}
public static CreatureSeeTaskManager getInstance()
{
return SingletonHolder.INSTANCE;
}
private static class SingletonHolder
{
protected static final CreatureSeeTaskManager INSTANCE = new CreatureSeeTaskManager();
}
}

View File

@ -254,7 +254,6 @@ public abstract class AbstractAI implements Ctrl
{
case EVT_THINK:
{
_actor.updateSeenCreatures();
onEvtThink();
break;
}

View File

@ -37,8 +37,6 @@ import org.l2jmobius.gameserver.model.actor.Npc;
import org.l2jmobius.gameserver.model.actor.Summon;
import org.l2jmobius.gameserver.model.actor.instance.PetInstance;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.events.EventDispatcher;
import org.l2jmobius.gameserver.model.events.impl.creature.OnCreatureSee;
import org.l2jmobius.gameserver.network.Disconnection;
import org.l2jmobius.gameserver.network.serverpackets.DeleteObject;
@ -357,13 +355,6 @@ public class World
}
}
}
// Notify OnCreatureSee for creatures that do not trigger EVT_THINK.
if (!wo.isAttackable() && wo.isCreature() && object.isCreature())
{
EventDispatcher.getInstance().notifyEventAsync(new OnCreatureSee((Creature) wo, (Creature) object), (Creature) wo);
EventDispatcher.getInstance().notifyEventAsync(new OnCreatureSee((Creature) object, (Creature) wo), (Creature) object);
}
});
}
@ -577,13 +568,6 @@ public class World
}
}
}
// Notify OnCreatureSee for creatures that do not trigger EVT_THINK.
if (!wo.isAttackable() && wo.isCreature() && object.isCreature())
{
EventDispatcher.getInstance().notifyEventAsync(new OnCreatureSee((Creature) wo, (Creature) object), (Creature) wo);
EventDispatcher.getInstance().notifyEventAsync(new OnCreatureSee((Creature) object, (Creature) wo), (Creature) object);
}
}
}
}

View File

@ -157,6 +157,7 @@ import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
import org.l2jmobius.gameserver.network.serverpackets.TeleportToLocation;
import org.l2jmobius.gameserver.network.serverpackets.UserInfo;
import org.l2jmobius.gameserver.taskmanager.AttackStanceTaskManager;
import org.l2jmobius.gameserver.taskmanager.CreatureSeeTaskManager;
import org.l2jmobius.gameserver.taskmanager.GameTimeTaskManager;
import org.l2jmobius.gameserver.util.Util;
@ -1751,6 +1752,7 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
// Forget all seen creatures.
if (_seenCreatures != null)
{
CreatureSeeTaskManager.getInstance().remove(this);
_seenCreatures.clear();
}
@ -5446,6 +5448,8 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
}
}
}
CreatureSeeTaskManager.getInstance().add(this);
}
public void updateSeenCreatures()

View File

@ -1075,8 +1075,7 @@ public class Npc extends Creature
setClanId(getCastle().getOwnerId());
}
if (isAttackable() // OnCreatureSee for non attackables is triggered at World.
&& CREATURE_SEE_IDS.contains(getId()))
if (CREATURE_SEE_IDS.contains(getId()))
{
initSeenCreatures();
}

View File

@ -0,0 +1,71 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.l2jmobius.gameserver.taskmanager;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import org.l2jmobius.commons.concurrent.ThreadPool;
import org.l2jmobius.gameserver.model.actor.Creature;
/**
* @author Mobius
*/
public class CreatureSeeTaskManager
{
private static final Set<Creature> CREATURES = ConcurrentHashMap.newKeySet();
private static boolean _working = false;
public CreatureSeeTaskManager()
{
ThreadPool.scheduleAtFixedRate(() ->
{
if (_working)
{
return;
}
_working = true;
for (Creature creature : CREATURES)
{
creature.updateSeenCreatures();
}
_working = false;
}, 1000, 1000);
}
public void add(Creature creature)
{
CREATURES.add(creature);
}
public void remove(Creature creature)
{
CREATURES.remove(creature);
}
public static CreatureSeeTaskManager getInstance()
{
return SingletonHolder.INSTANCE;
}
private static class SingletonHolder
{
protected static final CreatureSeeTaskManager INSTANCE = new CreatureSeeTaskManager();
}
}

View File

@ -254,7 +254,6 @@ public abstract class AbstractAI implements Ctrl
{
case EVT_THINK:
{
_actor.updateSeenCreatures();
onEvtThink();
break;
}

View File

@ -37,8 +37,6 @@ import org.l2jmobius.gameserver.model.actor.Npc;
import org.l2jmobius.gameserver.model.actor.Summon;
import org.l2jmobius.gameserver.model.actor.instance.PetInstance;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.events.EventDispatcher;
import org.l2jmobius.gameserver.model.events.impl.creature.OnCreatureSee;
import org.l2jmobius.gameserver.network.Disconnection;
import org.l2jmobius.gameserver.network.serverpackets.DeleteObject;
@ -357,13 +355,6 @@ public class World
}
}
}
// Notify OnCreatureSee for creatures that do not trigger EVT_THINK.
if (!wo.isAttackable() && wo.isCreature() && object.isCreature())
{
EventDispatcher.getInstance().notifyEventAsync(new OnCreatureSee((Creature) wo, (Creature) object), (Creature) wo);
EventDispatcher.getInstance().notifyEventAsync(new OnCreatureSee((Creature) object, (Creature) wo), (Creature) object);
}
});
}
@ -577,13 +568,6 @@ public class World
}
}
}
// Notify OnCreatureSee for creatures that do not trigger EVT_THINK.
if (!wo.isAttackable() && wo.isCreature() && object.isCreature())
{
EventDispatcher.getInstance().notifyEventAsync(new OnCreatureSee((Creature) wo, (Creature) object), (Creature) wo);
EventDispatcher.getInstance().notifyEventAsync(new OnCreatureSee((Creature) object, (Creature) wo), (Creature) object);
}
}
}
}

View File

@ -157,6 +157,7 @@ import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
import org.l2jmobius.gameserver.network.serverpackets.TeleportToLocation;
import org.l2jmobius.gameserver.network.serverpackets.UserInfo;
import org.l2jmobius.gameserver.taskmanager.AttackStanceTaskManager;
import org.l2jmobius.gameserver.taskmanager.CreatureSeeTaskManager;
import org.l2jmobius.gameserver.taskmanager.GameTimeTaskManager;
import org.l2jmobius.gameserver.util.Util;
@ -1751,6 +1752,7 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
// Forget all seen creatures.
if (_seenCreatures != null)
{
CreatureSeeTaskManager.getInstance().remove(this);
_seenCreatures.clear();
}
@ -5455,6 +5457,8 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
}
}
}
CreatureSeeTaskManager.getInstance().add(this);
}
public void updateSeenCreatures()

View File

@ -1075,8 +1075,7 @@ public class Npc extends Creature
setClanId(getCastle().getOwnerId());
}
if (isAttackable() // OnCreatureSee for non attackables is triggered at World.
&& CREATURE_SEE_IDS.contains(getId()))
if (CREATURE_SEE_IDS.contains(getId()))
{
initSeenCreatures();
}

View File

@ -0,0 +1,71 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.l2jmobius.gameserver.taskmanager;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import org.l2jmobius.commons.concurrent.ThreadPool;
import org.l2jmobius.gameserver.model.actor.Creature;
/**
* @author Mobius
*/
public class CreatureSeeTaskManager
{
private static final Set<Creature> CREATURES = ConcurrentHashMap.newKeySet();
private static boolean _working = false;
public CreatureSeeTaskManager()
{
ThreadPool.scheduleAtFixedRate(() ->
{
if (_working)
{
return;
}
_working = true;
for (Creature creature : CREATURES)
{
creature.updateSeenCreatures();
}
_working = false;
}, 1000, 1000);
}
public void add(Creature creature)
{
CREATURES.add(creature);
}
public void remove(Creature creature)
{
CREATURES.remove(creature);
}
public static CreatureSeeTaskManager getInstance()
{
return SingletonHolder.INSTANCE;
}
private static class SingletonHolder
{
protected static final CreatureSeeTaskManager INSTANCE = new CreatureSeeTaskManager();
}
}

View File

@ -254,7 +254,6 @@ public abstract class AbstractAI implements Ctrl
{
case EVT_THINK:
{
_actor.updateSeenCreatures();
onEvtThink();
break;
}

View File

@ -37,8 +37,6 @@ import org.l2jmobius.gameserver.model.actor.Npc;
import org.l2jmobius.gameserver.model.actor.Summon;
import org.l2jmobius.gameserver.model.actor.instance.PetInstance;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.events.EventDispatcher;
import org.l2jmobius.gameserver.model.events.impl.creature.OnCreatureSee;
import org.l2jmobius.gameserver.network.Disconnection;
import org.l2jmobius.gameserver.network.serverpackets.DeleteObject;
@ -357,13 +355,6 @@ public class World
}
}
}
// Notify OnCreatureSee for creatures that do not trigger EVT_THINK.
if (!wo.isAttackable() && wo.isCreature() && object.isCreature())
{
EventDispatcher.getInstance().notifyEventAsync(new OnCreatureSee((Creature) wo, (Creature) object), (Creature) wo);
EventDispatcher.getInstance().notifyEventAsync(new OnCreatureSee((Creature) object, (Creature) wo), (Creature) object);
}
});
}
@ -577,13 +568,6 @@ public class World
}
}
}
// Notify OnCreatureSee for creatures that do not trigger EVT_THINK.
if (!wo.isAttackable() && wo.isCreature() && object.isCreature())
{
EventDispatcher.getInstance().notifyEventAsync(new OnCreatureSee((Creature) wo, (Creature) object), (Creature) wo);
EventDispatcher.getInstance().notifyEventAsync(new OnCreatureSee((Creature) object, (Creature) wo), (Creature) object);
}
}
}
}

View File

@ -157,6 +157,7 @@ import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
import org.l2jmobius.gameserver.network.serverpackets.TeleportToLocation;
import org.l2jmobius.gameserver.network.serverpackets.UserInfo;
import org.l2jmobius.gameserver.taskmanager.AttackStanceTaskManager;
import org.l2jmobius.gameserver.taskmanager.CreatureSeeTaskManager;
import org.l2jmobius.gameserver.taskmanager.GameTimeTaskManager;
import org.l2jmobius.gameserver.util.Util;
@ -1751,6 +1752,7 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
// Forget all seen creatures.
if (_seenCreatures != null)
{
CreatureSeeTaskManager.getInstance().remove(this);
_seenCreatures.clear();
}
@ -5455,6 +5457,8 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
}
}
}
CreatureSeeTaskManager.getInstance().add(this);
}
public void updateSeenCreatures()

View File

@ -1075,8 +1075,7 @@ public class Npc extends Creature
setClanId(getCastle().getOwnerId());
}
if (isAttackable() // OnCreatureSee for non attackables is triggered at World.
&& CREATURE_SEE_IDS.contains(getId()))
if (CREATURE_SEE_IDS.contains(getId()))
{
initSeenCreatures();
}

View File

@ -0,0 +1,71 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.l2jmobius.gameserver.taskmanager;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import org.l2jmobius.commons.concurrent.ThreadPool;
import org.l2jmobius.gameserver.model.actor.Creature;
/**
* @author Mobius
*/
public class CreatureSeeTaskManager
{
private static final Set<Creature> CREATURES = ConcurrentHashMap.newKeySet();
private static boolean _working = false;
public CreatureSeeTaskManager()
{
ThreadPool.scheduleAtFixedRate(() ->
{
if (_working)
{
return;
}
_working = true;
for (Creature creature : CREATURES)
{
creature.updateSeenCreatures();
}
_working = false;
}, 1000, 1000);
}
public void add(Creature creature)
{
CREATURES.add(creature);
}
public void remove(Creature creature)
{
CREATURES.remove(creature);
}
public static CreatureSeeTaskManager getInstance()
{
return SingletonHolder.INSTANCE;
}
private static class SingletonHolder
{
protected static final CreatureSeeTaskManager INSTANCE = new CreatureSeeTaskManager();
}
}

View File

@ -254,7 +254,6 @@ public abstract class AbstractAI implements Ctrl
{
case EVT_THINK:
{
_actor.updateSeenCreatures();
onEvtThink();
break;
}

View File

@ -37,8 +37,6 @@ import org.l2jmobius.gameserver.model.actor.Npc;
import org.l2jmobius.gameserver.model.actor.Summon;
import org.l2jmobius.gameserver.model.actor.instance.PetInstance;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.events.EventDispatcher;
import org.l2jmobius.gameserver.model.events.impl.creature.OnCreatureSee;
import org.l2jmobius.gameserver.network.Disconnection;
import org.l2jmobius.gameserver.network.serverpackets.DeleteObject;
@ -357,13 +355,6 @@ public class World
}
}
}
// Notify OnCreatureSee for creatures that do not trigger EVT_THINK.
if (!wo.isAttackable() && wo.isCreature() && object.isCreature())
{
EventDispatcher.getInstance().notifyEventAsync(new OnCreatureSee((Creature) wo, (Creature) object), (Creature) wo);
EventDispatcher.getInstance().notifyEventAsync(new OnCreatureSee((Creature) object, (Creature) wo), (Creature) object);
}
});
}
@ -577,13 +568,6 @@ public class World
}
}
}
// Notify OnCreatureSee for creatures that do not trigger EVT_THINK.
if (!wo.isAttackable() && wo.isCreature() && object.isCreature())
{
EventDispatcher.getInstance().notifyEventAsync(new OnCreatureSee((Creature) wo, (Creature) object), (Creature) wo);
EventDispatcher.getInstance().notifyEventAsync(new OnCreatureSee((Creature) object, (Creature) wo), (Creature) object);
}
}
}
}

View File

@ -157,6 +157,7 @@ import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
import org.l2jmobius.gameserver.network.serverpackets.TeleportToLocation;
import org.l2jmobius.gameserver.network.serverpackets.UserInfo;
import org.l2jmobius.gameserver.taskmanager.AttackStanceTaskManager;
import org.l2jmobius.gameserver.taskmanager.CreatureSeeTaskManager;
import org.l2jmobius.gameserver.taskmanager.GameTimeTaskManager;
import org.l2jmobius.gameserver.util.Util;
@ -1751,6 +1752,7 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
// Forget all seen creatures.
if (_seenCreatures != null)
{
CreatureSeeTaskManager.getInstance().remove(this);
_seenCreatures.clear();
}
@ -5455,6 +5457,8 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
}
}
}
CreatureSeeTaskManager.getInstance().add(this);
}
public void updateSeenCreatures()

View File

@ -1075,8 +1075,7 @@ public class Npc extends Creature
setClanId(getCastle().getOwnerId());
}
if (isAttackable() // OnCreatureSee for non attackables is triggered at World.
&& CREATURE_SEE_IDS.contains(getId()))
if (CREATURE_SEE_IDS.contains(getId()))
{
initSeenCreatures();
}

View File

@ -0,0 +1,71 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.l2jmobius.gameserver.taskmanager;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import org.l2jmobius.commons.concurrent.ThreadPool;
import org.l2jmobius.gameserver.model.actor.Creature;
/**
* @author Mobius
*/
public class CreatureSeeTaskManager
{
private static final Set<Creature> CREATURES = ConcurrentHashMap.newKeySet();
private static boolean _working = false;
public CreatureSeeTaskManager()
{
ThreadPool.scheduleAtFixedRate(() ->
{
if (_working)
{
return;
}
_working = true;
for (Creature creature : CREATURES)
{
creature.updateSeenCreatures();
}
_working = false;
}, 1000, 1000);
}
public void add(Creature creature)
{
CREATURES.add(creature);
}
public void remove(Creature creature)
{
CREATURES.remove(creature);
}
public static CreatureSeeTaskManager getInstance()
{
return SingletonHolder.INSTANCE;
}
private static class SingletonHolder
{
protected static final CreatureSeeTaskManager INSTANCE = new CreatureSeeTaskManager();
}
}

View File

@ -254,7 +254,6 @@ public abstract class AbstractAI implements Ctrl
{
case EVT_THINK:
{
_actor.updateSeenCreatures();
onEvtThink();
break;
}

View File

@ -37,8 +37,6 @@ import org.l2jmobius.gameserver.model.actor.Npc;
import org.l2jmobius.gameserver.model.actor.Summon;
import org.l2jmobius.gameserver.model.actor.instance.PetInstance;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.events.EventDispatcher;
import org.l2jmobius.gameserver.model.events.impl.creature.OnCreatureSee;
import org.l2jmobius.gameserver.network.Disconnection;
import org.l2jmobius.gameserver.network.serverpackets.DeleteObject;
@ -357,13 +355,6 @@ public class World
}
}
}
// Notify OnCreatureSee for creatures that do not trigger EVT_THINK.
if (!wo.isAttackable() && wo.isCreature() && object.isCreature())
{
EventDispatcher.getInstance().notifyEventAsync(new OnCreatureSee((Creature) wo, (Creature) object), (Creature) wo);
EventDispatcher.getInstance().notifyEventAsync(new OnCreatureSee((Creature) object, (Creature) wo), (Creature) object);
}
});
}
@ -577,13 +568,6 @@ public class World
}
}
}
// Notify OnCreatureSee for creatures that do not trigger EVT_THINK.
if (!wo.isAttackable() && wo.isCreature() && object.isCreature())
{
EventDispatcher.getInstance().notifyEventAsync(new OnCreatureSee((Creature) wo, (Creature) object), (Creature) wo);
EventDispatcher.getInstance().notifyEventAsync(new OnCreatureSee((Creature) object, (Creature) wo), (Creature) object);
}
}
}
}

View File

@ -157,6 +157,7 @@ import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
import org.l2jmobius.gameserver.network.serverpackets.TeleportToLocation;
import org.l2jmobius.gameserver.network.serverpackets.UserInfo;
import org.l2jmobius.gameserver.taskmanager.AttackStanceTaskManager;
import org.l2jmobius.gameserver.taskmanager.CreatureSeeTaskManager;
import org.l2jmobius.gameserver.taskmanager.GameTimeTaskManager;
import org.l2jmobius.gameserver.util.Util;
@ -1751,6 +1752,7 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
// Forget all seen creatures.
if (_seenCreatures != null)
{
CreatureSeeTaskManager.getInstance().remove(this);
_seenCreatures.clear();
}
@ -5454,6 +5456,8 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
}
}
}
CreatureSeeTaskManager.getInstance().add(this);
}
public void updateSeenCreatures()

View File

@ -1075,8 +1075,7 @@ public class Npc extends Creature
setClanId(getCastle().getOwnerId());
}
if (isAttackable() // OnCreatureSee for non attackables is triggered at World.
&& CREATURE_SEE_IDS.contains(getId()))
if (CREATURE_SEE_IDS.contains(getId()))
{
initSeenCreatures();
}

View File

@ -0,0 +1,71 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.l2jmobius.gameserver.taskmanager;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import org.l2jmobius.commons.concurrent.ThreadPool;
import org.l2jmobius.gameserver.model.actor.Creature;
/**
* @author Mobius
*/
public class CreatureSeeTaskManager
{
private static final Set<Creature> CREATURES = ConcurrentHashMap.newKeySet();
private static boolean _working = false;
public CreatureSeeTaskManager()
{
ThreadPool.scheduleAtFixedRate(() ->
{
if (_working)
{
return;
}
_working = true;
for (Creature creature : CREATURES)
{
creature.updateSeenCreatures();
}
_working = false;
}, 1000, 1000);
}
public void add(Creature creature)
{
CREATURES.add(creature);
}
public void remove(Creature creature)
{
CREATURES.remove(creature);
}
public static CreatureSeeTaskManager getInstance()
{
return SingletonHolder.INSTANCE;
}
private static class SingletonHolder
{
protected static final CreatureSeeTaskManager INSTANCE = new CreatureSeeTaskManager();
}
}

View File

@ -254,7 +254,6 @@ public abstract class AbstractAI implements Ctrl
{
case EVT_THINK:
{
_actor.updateSeenCreatures();
onEvtThink();
break;
}

View File

@ -39,8 +39,6 @@ import org.l2jmobius.gameserver.model.actor.Npc;
import org.l2jmobius.gameserver.model.actor.Summon;
import org.l2jmobius.gameserver.model.actor.instance.PetInstance;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.events.EventDispatcher;
import org.l2jmobius.gameserver.model.events.impl.creature.OnCreatureSee;
import org.l2jmobius.gameserver.network.Disconnection;
import org.l2jmobius.gameserver.network.serverpackets.DeleteObject;
@ -362,13 +360,6 @@ public class World
}
}
}
// Notify OnCreatureSee for creatures that do not trigger EVT_THINK.
if (!wo.isAttackable() && wo.isCreature() && object.isCreature())
{
EventDispatcher.getInstance().notifyEventAsync(new OnCreatureSee((Creature) wo, (Creature) object), (Creature) wo);
EventDispatcher.getInstance().notifyEventAsync(new OnCreatureSee((Creature) object, (Creature) wo), (Creature) object);
}
});
}
@ -582,13 +573,6 @@ public class World
}
}
}
// Notify OnCreatureSee for creatures that do not trigger EVT_THINK.
if (!wo.isAttackable() && wo.isCreature() && object.isCreature())
{
EventDispatcher.getInstance().notifyEventAsync(new OnCreatureSee((Creature) wo, (Creature) object), (Creature) wo);
EventDispatcher.getInstance().notifyEventAsync(new OnCreatureSee((Creature) object, (Creature) wo), (Creature) object);
}
}
}
}

View File

@ -157,6 +157,7 @@ import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
import org.l2jmobius.gameserver.network.serverpackets.TeleportToLocation;
import org.l2jmobius.gameserver.network.serverpackets.UserInfo;
import org.l2jmobius.gameserver.taskmanager.AttackStanceTaskManager;
import org.l2jmobius.gameserver.taskmanager.CreatureSeeTaskManager;
import org.l2jmobius.gameserver.taskmanager.GameTimeTaskManager;
import org.l2jmobius.gameserver.util.Util;
@ -1751,6 +1752,7 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
// Forget all seen creatures.
if (_seenCreatures != null)
{
CreatureSeeTaskManager.getInstance().remove(this);
_seenCreatures.clear();
}
@ -5454,6 +5456,8 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
}
}
}
CreatureSeeTaskManager.getInstance().add(this);
}
public void updateSeenCreatures()

View File

@ -1076,8 +1076,7 @@ public class Npc extends Creature
setClanId(getCastle().getOwnerId());
}
if (isAttackable() // OnCreatureSee for non attackables is triggered at World.
&& CREATURE_SEE_IDS.contains(getId()))
if (CREATURE_SEE_IDS.contains(getId()))
{
initSeenCreatures();
}

View File

@ -0,0 +1,71 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.l2jmobius.gameserver.taskmanager;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import org.l2jmobius.commons.concurrent.ThreadPool;
import org.l2jmobius.gameserver.model.actor.Creature;
/**
* @author Mobius
*/
public class CreatureSeeTaskManager
{
private static final Set<Creature> CREATURES = ConcurrentHashMap.newKeySet();
private static boolean _working = false;
public CreatureSeeTaskManager()
{
ThreadPool.scheduleAtFixedRate(() ->
{
if (_working)
{
return;
}
_working = true;
for (Creature creature : CREATURES)
{
creature.updateSeenCreatures();
}
_working = false;
}, 1000, 1000);
}
public void add(Creature creature)
{
CREATURES.add(creature);
}
public void remove(Creature creature)
{
CREATURES.remove(creature);
}
public static CreatureSeeTaskManager getInstance()
{
return SingletonHolder.INSTANCE;
}
private static class SingletonHolder
{
protected static final CreatureSeeTaskManager INSTANCE = new CreatureSeeTaskManager();
}
}

View File

@ -254,7 +254,6 @@ public abstract class AbstractAI implements Ctrl
{
case EVT_THINK:
{
_actor.updateSeenCreatures();
onEvtThink();
break;
}

View File

@ -39,8 +39,6 @@ import org.l2jmobius.gameserver.model.actor.Npc;
import org.l2jmobius.gameserver.model.actor.Summon;
import org.l2jmobius.gameserver.model.actor.instance.PetInstance;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.events.EventDispatcher;
import org.l2jmobius.gameserver.model.events.impl.creature.OnCreatureSee;
import org.l2jmobius.gameserver.network.Disconnection;
import org.l2jmobius.gameserver.network.serverpackets.DeleteObject;
@ -362,13 +360,6 @@ public class World
}
}
}
// Notify OnCreatureSee for creatures that do not trigger EVT_THINK.
if (!wo.isAttackable() && wo.isCreature() && object.isCreature())
{
EventDispatcher.getInstance().notifyEventAsync(new OnCreatureSee((Creature) wo, (Creature) object), (Creature) wo);
EventDispatcher.getInstance().notifyEventAsync(new OnCreatureSee((Creature) object, (Creature) wo), (Creature) object);
}
});
}
@ -582,13 +573,6 @@ public class World
}
}
}
// Notify OnCreatureSee for creatures that do not trigger EVT_THINK.
if (!wo.isAttackable() && wo.isCreature() && object.isCreature())
{
EventDispatcher.getInstance().notifyEventAsync(new OnCreatureSee((Creature) wo, (Creature) object), (Creature) wo);
EventDispatcher.getInstance().notifyEventAsync(new OnCreatureSee((Creature) object, (Creature) wo), (Creature) object);
}
}
}
}

View File

@ -157,6 +157,7 @@ import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
import org.l2jmobius.gameserver.network.serverpackets.TeleportToLocation;
import org.l2jmobius.gameserver.network.serverpackets.UserInfo;
import org.l2jmobius.gameserver.taskmanager.AttackStanceTaskManager;
import org.l2jmobius.gameserver.taskmanager.CreatureSeeTaskManager;
import org.l2jmobius.gameserver.taskmanager.GameTimeTaskManager;
import org.l2jmobius.gameserver.util.Util;
@ -1751,6 +1752,7 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
// Forget all seen creatures.
if (_seenCreatures != null)
{
CreatureSeeTaskManager.getInstance().remove(this);
_seenCreatures.clear();
}
@ -5454,6 +5456,8 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
}
}
}
CreatureSeeTaskManager.getInstance().add(this);
}
public void updateSeenCreatures()

View File

@ -1076,8 +1076,7 @@ public class Npc extends Creature
setClanId(getCastle().getOwnerId());
}
if (isAttackable() // OnCreatureSee for non attackables is triggered at World.
&& CREATURE_SEE_IDS.contains(getId()))
if (CREATURE_SEE_IDS.contains(getId()))
{
initSeenCreatures();
}

View File

@ -0,0 +1,71 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.l2jmobius.gameserver.taskmanager;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import org.l2jmobius.commons.concurrent.ThreadPool;
import org.l2jmobius.gameserver.model.actor.Creature;
/**
* @author Mobius
*/
public class CreatureSeeTaskManager
{
private static final Set<Creature> CREATURES = ConcurrentHashMap.newKeySet();
private static boolean _working = false;
public CreatureSeeTaskManager()
{
ThreadPool.scheduleAtFixedRate(() ->
{
if (_working)
{
return;
}
_working = true;
for (Creature creature : CREATURES)
{
creature.updateSeenCreatures();
}
_working = false;
}, 1000, 1000);
}
public void add(Creature creature)
{
CREATURES.add(creature);
}
public void remove(Creature creature)
{
CREATURES.remove(creature);
}
public static CreatureSeeTaskManager getInstance()
{
return SingletonHolder.INSTANCE;
}
private static class SingletonHolder
{
protected static final CreatureSeeTaskManager INSTANCE = new CreatureSeeTaskManager();
}
}

View File

@ -298,7 +298,6 @@ public abstract class AbstractAI implements Ctrl
{
case EVT_THINK:
{
_actor.updateSeenCreatures();
onEvtThink();
break;
}

View File

@ -36,8 +36,6 @@ import org.l2jmobius.gameserver.model.actor.Npc;
import org.l2jmobius.gameserver.model.actor.Summon;
import org.l2jmobius.gameserver.model.actor.instance.PetInstance;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.events.EventDispatcher;
import org.l2jmobius.gameserver.model.events.impl.creature.OnCreatureSee;
import org.l2jmobius.gameserver.network.Disconnection;
import org.l2jmobius.gameserver.network.serverpackets.DeleteObject;
@ -353,13 +351,6 @@ public class World
}
}
}
// Notify OnCreatureSee for creatures that do not trigger EVT_THINK.
if (!wo.isAttackable() && wo.isCreature() && object.isCreature())
{
EventDispatcher.getInstance().notifyEventAsync(new OnCreatureSee((Creature) wo, (Creature) object), (Creature) wo);
EventDispatcher.getInstance().notifyEventAsync(new OnCreatureSee((Creature) object, (Creature) wo), (Creature) object);
}
});
}
@ -573,13 +564,6 @@ public class World
}
}
}
// Notify OnCreatureSee for creatures that do not trigger EVT_THINK.
if (!wo.isAttackable() && wo.isCreature() && object.isCreature())
{
EventDispatcher.getInstance().notifyEventAsync(new OnCreatureSee((Creature) wo, (Creature) object), (Creature) wo);
EventDispatcher.getInstance().notifyEventAsync(new OnCreatureSee((Creature) object, (Creature) wo), (Creature) object);
}
}
}
}

View File

@ -157,6 +157,7 @@ import org.l2jmobius.gameserver.network.serverpackets.StopMove;
import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
import org.l2jmobius.gameserver.network.serverpackets.TeleportToLocation;
import org.l2jmobius.gameserver.taskmanager.AttackStanceTaskManager;
import org.l2jmobius.gameserver.taskmanager.CreatureSeeTaskManager;
import org.l2jmobius.gameserver.taskmanager.GameTimeTaskManager;
import org.l2jmobius.gameserver.util.Util;
@ -2473,6 +2474,7 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
// Forget all seen creatures.
if (_seenCreatures != null)
{
CreatureSeeTaskManager.getInstance().remove(this);
_seenCreatures.clear();
}
@ -6779,6 +6781,8 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
}
}
}
CreatureSeeTaskManager.getInstance().add(this);
}
public void updateSeenCreatures()

View File

@ -1290,8 +1290,7 @@ public class Npc extends Creature
WalkingManager.getInstance().onSpawn(this);
}
if (isAttackable() // OnCreatureSee for non attackables is triggered at World.
&& CREATURE_SEE_IDS.contains(getId()))
if (CREATURE_SEE_IDS.contains(getId()))
{
initSeenCreatures();
}

View File

@ -0,0 +1,71 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.l2jmobius.gameserver.taskmanager;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import org.l2jmobius.commons.concurrent.ThreadPool;
import org.l2jmobius.gameserver.model.actor.Creature;
/**
* @author Mobius
*/
public class CreatureSeeTaskManager
{
private static final Set<Creature> CREATURES = ConcurrentHashMap.newKeySet();
private static boolean _working = false;
public CreatureSeeTaskManager()
{
ThreadPool.scheduleAtFixedRate(() ->
{
if (_working)
{
return;
}
_working = true;
for (Creature creature : CREATURES)
{
creature.updateSeenCreatures();
}
_working = false;
}, 1000, 1000);
}
public void add(Creature creature)
{
CREATURES.add(creature);
}
public void remove(Creature creature)
{
CREATURES.remove(creature);
}
public static CreatureSeeTaskManager getInstance()
{
return SingletonHolder.INSTANCE;
}
private static class SingletonHolder
{
protected static final CreatureSeeTaskManager INSTANCE = new CreatureSeeTaskManager();
}
}

View File

@ -298,7 +298,6 @@ public abstract class AbstractAI implements Ctrl
{
case EVT_THINK:
{
_actor.updateSeenCreatures();
onEvtThink();
break;
}

View File

@ -36,8 +36,6 @@ import org.l2jmobius.gameserver.model.actor.Npc;
import org.l2jmobius.gameserver.model.actor.Summon;
import org.l2jmobius.gameserver.model.actor.instance.PetInstance;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.events.EventDispatcher;
import org.l2jmobius.gameserver.model.events.impl.creature.OnCreatureSee;
import org.l2jmobius.gameserver.network.Disconnection;
import org.l2jmobius.gameserver.network.serverpackets.DeleteObject;
@ -353,13 +351,6 @@ public class World
}
}
}
// Notify OnCreatureSee for creatures that do not trigger EVT_THINK.
if (!wo.isAttackable() && wo.isCreature() && object.isCreature())
{
EventDispatcher.getInstance().notifyEventAsync(new OnCreatureSee((Creature) wo, (Creature) object), (Creature) wo);
EventDispatcher.getInstance().notifyEventAsync(new OnCreatureSee((Creature) object, (Creature) wo), (Creature) object);
}
});
}
@ -573,13 +564,6 @@ public class World
}
}
}
// Notify OnCreatureSee for creatures that do not trigger EVT_THINK.
if (!wo.isAttackable() && wo.isCreature() && object.isCreature())
{
EventDispatcher.getInstance().notifyEventAsync(new OnCreatureSee((Creature) wo, (Creature) object), (Creature) wo);
EventDispatcher.getInstance().notifyEventAsync(new OnCreatureSee((Creature) object, (Creature) wo), (Creature) object);
}
}
}
}

View File

@ -158,6 +158,7 @@ import org.l2jmobius.gameserver.network.serverpackets.StopMove;
import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
import org.l2jmobius.gameserver.network.serverpackets.TeleportToLocation;
import org.l2jmobius.gameserver.taskmanager.AttackStanceTaskManager;
import org.l2jmobius.gameserver.taskmanager.CreatureSeeTaskManager;
import org.l2jmobius.gameserver.taskmanager.GameTimeTaskManager;
import org.l2jmobius.gameserver.util.Util;
@ -2475,6 +2476,7 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
// Forget all seen creatures.
if (_seenCreatures != null)
{
CreatureSeeTaskManager.getInstance().remove(this);
_seenCreatures.clear();
}
@ -6781,6 +6783,8 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
}
}
}
CreatureSeeTaskManager.getInstance().add(this);
}
public void updateSeenCreatures()

View File

@ -1290,8 +1290,7 @@ public class Npc extends Creature
WalkingManager.getInstance().onSpawn(this);
}
if (isAttackable() // OnCreatureSee for non attackables is triggered at World.
&& CREATURE_SEE_IDS.contains(getId()))
if (CREATURE_SEE_IDS.contains(getId()))
{
initSeenCreatures();
}

View File

@ -0,0 +1,71 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.l2jmobius.gameserver.taskmanager;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import org.l2jmobius.commons.concurrent.ThreadPool;
import org.l2jmobius.gameserver.model.actor.Creature;
/**
* @author Mobius
*/
public class CreatureSeeTaskManager
{
private static final Set<Creature> CREATURES = ConcurrentHashMap.newKeySet();
private static boolean _working = false;
public CreatureSeeTaskManager()
{
ThreadPool.scheduleAtFixedRate(() ->
{
if (_working)
{
return;
}
_working = true;
for (Creature creature : CREATURES)
{
creature.updateSeenCreatures();
}
_working = false;
}, 1000, 1000);
}
public void add(Creature creature)
{
CREATURES.add(creature);
}
public void remove(Creature creature)
{
CREATURES.remove(creature);
}
public static CreatureSeeTaskManager getInstance()
{
return SingletonHolder.INSTANCE;
}
private static class SingletonHolder
{
protected static final CreatureSeeTaskManager INSTANCE = new CreatureSeeTaskManager();
}
}

View File

@ -254,7 +254,6 @@ public abstract class AbstractAI implements Ctrl
{
case EVT_THINK:
{
_actor.updateSeenCreatures();
onEvtThink();
break;
}

View File

@ -37,8 +37,6 @@ import org.l2jmobius.gameserver.model.actor.Npc;
import org.l2jmobius.gameserver.model.actor.Summon;
import org.l2jmobius.gameserver.model.actor.instance.PetInstance;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.events.EventDispatcher;
import org.l2jmobius.gameserver.model.events.impl.creature.OnCreatureSee;
import org.l2jmobius.gameserver.network.Disconnection;
import org.l2jmobius.gameserver.network.serverpackets.DeleteObject;
@ -357,13 +355,6 @@ public class World
}
}
}
// Notify OnCreatureSee for creatures that do not trigger EVT_THINK.
if (!wo.isAttackable() && wo.isCreature() && object.isCreature())
{
EventDispatcher.getInstance().notifyEventAsync(new OnCreatureSee((Creature) wo, (Creature) object), (Creature) wo);
EventDispatcher.getInstance().notifyEventAsync(new OnCreatureSee((Creature) object, (Creature) wo), (Creature) object);
}
});
}
@ -577,13 +568,6 @@ public class World
}
}
}
// Notify OnCreatureSee for creatures that do not trigger EVT_THINK.
if (!wo.isAttackable() && wo.isCreature() && object.isCreature())
{
EventDispatcher.getInstance().notifyEventAsync(new OnCreatureSee((Creature) wo, (Creature) object), (Creature) wo);
EventDispatcher.getInstance().notifyEventAsync(new OnCreatureSee((Creature) object, (Creature) wo), (Creature) object);
}
}
}
}

View File

@ -157,6 +157,7 @@ import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
import org.l2jmobius.gameserver.network.serverpackets.TeleportToLocation;
import org.l2jmobius.gameserver.network.serverpackets.UserInfo;
import org.l2jmobius.gameserver.taskmanager.AttackStanceTaskManager;
import org.l2jmobius.gameserver.taskmanager.CreatureSeeTaskManager;
import org.l2jmobius.gameserver.taskmanager.GameTimeTaskManager;
import org.l2jmobius.gameserver.util.Util;
@ -1751,6 +1752,7 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
// Forget all seen creatures.
if (_seenCreatures != null)
{
CreatureSeeTaskManager.getInstance().remove(this);
_seenCreatures.clear();
}
@ -5445,6 +5447,8 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
}
}
}
CreatureSeeTaskManager.getInstance().add(this);
}
public void updateSeenCreatures()

View File

@ -1075,8 +1075,7 @@ public class Npc extends Creature
setClanId(getCastle().getOwnerId());
}
if (isAttackable() // OnCreatureSee for non attackables is triggered at World.
&& CREATURE_SEE_IDS.contains(getId()))
if (CREATURE_SEE_IDS.contains(getId()))
{
initSeenCreatures();
}

View File

@ -0,0 +1,71 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.l2jmobius.gameserver.taskmanager;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import org.l2jmobius.commons.concurrent.ThreadPool;
import org.l2jmobius.gameserver.model.actor.Creature;
/**
* @author Mobius
*/
public class CreatureSeeTaskManager
{
private static final Set<Creature> CREATURES = ConcurrentHashMap.newKeySet();
private static boolean _working = false;
public CreatureSeeTaskManager()
{
ThreadPool.scheduleAtFixedRate(() ->
{
if (_working)
{
return;
}
_working = true;
for (Creature creature : CREATURES)
{
creature.updateSeenCreatures();
}
_working = false;
}, 1000, 1000);
}
public void add(Creature creature)
{
CREATURES.add(creature);
}
public void remove(Creature creature)
{
CREATURES.remove(creature);
}
public static CreatureSeeTaskManager getInstance()
{
return SingletonHolder.INSTANCE;
}
private static class SingletonHolder
{
protected static final CreatureSeeTaskManager INSTANCE = new CreatureSeeTaskManager();
}
}

View File

@ -254,7 +254,6 @@ public abstract class AbstractAI implements Ctrl
{
case EVT_THINK:
{
_actor.updateSeenCreatures();
onEvtThink();
break;
}

View File

@ -37,8 +37,6 @@ import org.l2jmobius.gameserver.model.actor.Npc;
import org.l2jmobius.gameserver.model.actor.Summon;
import org.l2jmobius.gameserver.model.actor.instance.PetInstance;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.events.EventDispatcher;
import org.l2jmobius.gameserver.model.events.impl.creature.OnCreatureSee;
import org.l2jmobius.gameserver.network.Disconnection;
import org.l2jmobius.gameserver.network.serverpackets.DeleteObject;
@ -357,13 +355,6 @@ public class World
}
}
}
// Notify OnCreatureSee for creatures that do not trigger EVT_THINK.
if (!wo.isAttackable() && wo.isCreature() && object.isCreature())
{
EventDispatcher.getInstance().notifyEventAsync(new OnCreatureSee((Creature) wo, (Creature) object), (Creature) wo);
EventDispatcher.getInstance().notifyEventAsync(new OnCreatureSee((Creature) object, (Creature) wo), (Creature) object);
}
});
}
@ -577,13 +568,6 @@ public class World
}
}
}
// Notify OnCreatureSee for creatures that do not trigger EVT_THINK.
if (!wo.isAttackable() && wo.isCreature() && object.isCreature())
{
EventDispatcher.getInstance().notifyEventAsync(new OnCreatureSee((Creature) wo, (Creature) object), (Creature) wo);
EventDispatcher.getInstance().notifyEventAsync(new OnCreatureSee((Creature) object, (Creature) wo), (Creature) object);
}
}
}
}

View File

@ -157,6 +157,7 @@ import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
import org.l2jmobius.gameserver.network.serverpackets.TeleportToLocation;
import org.l2jmobius.gameserver.network.serverpackets.UserInfo;
import org.l2jmobius.gameserver.taskmanager.AttackStanceTaskManager;
import org.l2jmobius.gameserver.taskmanager.CreatureSeeTaskManager;
import org.l2jmobius.gameserver.taskmanager.GameTimeTaskManager;
import org.l2jmobius.gameserver.util.Util;
@ -1751,6 +1752,7 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
// Forget all seen creatures.
if (_seenCreatures != null)
{
CreatureSeeTaskManager.getInstance().remove(this);
_seenCreatures.clear();
}
@ -5445,6 +5447,8 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
}
}
}
CreatureSeeTaskManager.getInstance().add(this);
}
public void updateSeenCreatures()

View File

@ -1075,8 +1075,7 @@ public class Npc extends Creature
setClanId(getCastle().getOwnerId());
}
if (isAttackable() // OnCreatureSee for non attackables is triggered at World.
&& CREATURE_SEE_IDS.contains(getId()))
if (CREATURE_SEE_IDS.contains(getId()))
{
initSeenCreatures();
}

View File

@ -0,0 +1,71 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.l2jmobius.gameserver.taskmanager;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import org.l2jmobius.commons.concurrent.ThreadPool;
import org.l2jmobius.gameserver.model.actor.Creature;
/**
* @author Mobius
*/
public class CreatureSeeTaskManager
{
private static final Set<Creature> CREATURES = ConcurrentHashMap.newKeySet();
private static boolean _working = false;
public CreatureSeeTaskManager()
{
ThreadPool.scheduleAtFixedRate(() ->
{
if (_working)
{
return;
}
_working = true;
for (Creature creature : CREATURES)
{
creature.updateSeenCreatures();
}
_working = false;
}, 1000, 1000);
}
public void add(Creature creature)
{
CREATURES.add(creature);
}
public void remove(Creature creature)
{
CREATURES.remove(creature);
}
public static CreatureSeeTaskManager getInstance()
{
return SingletonHolder.INSTANCE;
}
private static class SingletonHolder
{
protected static final CreatureSeeTaskManager INSTANCE = new CreatureSeeTaskManager();
}
}

View File

@ -254,7 +254,6 @@ public abstract class AbstractAI implements Ctrl
{
case EVT_THINK:
{
_actor.updateSeenCreatures();
onEvtThink();
break;
}

View File

@ -37,8 +37,6 @@ import org.l2jmobius.gameserver.model.actor.Npc;
import org.l2jmobius.gameserver.model.actor.Summon;
import org.l2jmobius.gameserver.model.actor.instance.PetInstance;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.events.EventDispatcher;
import org.l2jmobius.gameserver.model.events.impl.creature.OnCreatureSee;
import org.l2jmobius.gameserver.network.Disconnection;
import org.l2jmobius.gameserver.network.serverpackets.DeleteObject;
@ -357,13 +355,6 @@ public class World
}
}
}
// Notify OnCreatureSee for creatures that do not trigger EVT_THINK.
if (!wo.isAttackable() && wo.isCreature() && object.isCreature())
{
EventDispatcher.getInstance().notifyEventAsync(new OnCreatureSee((Creature) wo, (Creature) object), (Creature) wo);
EventDispatcher.getInstance().notifyEventAsync(new OnCreatureSee((Creature) object, (Creature) wo), (Creature) object);
}
});
}
@ -577,13 +568,6 @@ public class World
}
}
}
// Notify OnCreatureSee for creatures that do not trigger EVT_THINK.
if (!wo.isAttackable() && wo.isCreature() && object.isCreature())
{
EventDispatcher.getInstance().notifyEventAsync(new OnCreatureSee((Creature) wo, (Creature) object), (Creature) wo);
EventDispatcher.getInstance().notifyEventAsync(new OnCreatureSee((Creature) object, (Creature) wo), (Creature) object);
}
}
}
}

View File

@ -157,6 +157,7 @@ import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
import org.l2jmobius.gameserver.network.serverpackets.TeleportToLocation;
import org.l2jmobius.gameserver.network.serverpackets.UserInfo;
import org.l2jmobius.gameserver.taskmanager.AttackStanceTaskManager;
import org.l2jmobius.gameserver.taskmanager.CreatureSeeTaskManager;
import org.l2jmobius.gameserver.taskmanager.GameTimeTaskManager;
import org.l2jmobius.gameserver.util.Util;
@ -1751,6 +1752,7 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
// Forget all seen creatures.
if (_seenCreatures != null)
{
CreatureSeeTaskManager.getInstance().remove(this);
_seenCreatures.clear();
}
@ -5454,6 +5456,8 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
}
}
}
CreatureSeeTaskManager.getInstance().add(this);
}
public void updateSeenCreatures()

View File

@ -1075,8 +1075,7 @@ public class Npc extends Creature
setClanId(getCastle().getOwnerId());
}
if (isAttackable() // OnCreatureSee for non attackables is triggered at World.
&& CREATURE_SEE_IDS.contains(getId()))
if (CREATURE_SEE_IDS.contains(getId()))
{
initSeenCreatures();
}

View File

@ -0,0 +1,71 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.l2jmobius.gameserver.taskmanager;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import org.l2jmobius.commons.concurrent.ThreadPool;
import org.l2jmobius.gameserver.model.actor.Creature;
/**
* @author Mobius
*/
public class CreatureSeeTaskManager
{
private static final Set<Creature> CREATURES = ConcurrentHashMap.newKeySet();
private static boolean _working = false;
public CreatureSeeTaskManager()
{
ThreadPool.scheduleAtFixedRate(() ->
{
if (_working)
{
return;
}
_working = true;
for (Creature creature : CREATURES)
{
creature.updateSeenCreatures();
}
_working = false;
}, 1000, 1000);
}
public void add(Creature creature)
{
CREATURES.add(creature);
}
public void remove(Creature creature)
{
CREATURES.remove(creature);
}
public static CreatureSeeTaskManager getInstance()
{
return SingletonHolder.INSTANCE;
}
private static class SingletonHolder
{
protected static final CreatureSeeTaskManager INSTANCE = new CreatureSeeTaskManager();
}
}

View File

@ -254,7 +254,6 @@ public abstract class AbstractAI implements Ctrl
{
case EVT_THINK:
{
_actor.updateSeenCreatures();
onEvtThink();
break;
}

View File

@ -37,8 +37,6 @@ import org.l2jmobius.gameserver.model.actor.Npc;
import org.l2jmobius.gameserver.model.actor.Summon;
import org.l2jmobius.gameserver.model.actor.instance.PetInstance;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.events.EventDispatcher;
import org.l2jmobius.gameserver.model.events.impl.creature.OnCreatureSee;
import org.l2jmobius.gameserver.network.Disconnection;
import org.l2jmobius.gameserver.network.serverpackets.DeleteObject;
@ -357,13 +355,6 @@ public class World
}
}
}
// Notify OnCreatureSee for creatures that do not trigger EVT_THINK.
if (!wo.isAttackable() && wo.isCreature() && object.isCreature())
{
EventDispatcher.getInstance().notifyEventAsync(new OnCreatureSee((Creature) wo, (Creature) object), (Creature) wo);
EventDispatcher.getInstance().notifyEventAsync(new OnCreatureSee((Creature) object, (Creature) wo), (Creature) object);
}
});
}
@ -577,13 +568,6 @@ public class World
}
}
}
// Notify OnCreatureSee for creatures that do not trigger EVT_THINK.
if (!wo.isAttackable() && wo.isCreature() && object.isCreature())
{
EventDispatcher.getInstance().notifyEventAsync(new OnCreatureSee((Creature) wo, (Creature) object), (Creature) wo);
EventDispatcher.getInstance().notifyEventAsync(new OnCreatureSee((Creature) object, (Creature) wo), (Creature) object);
}
}
}
}

View File

@ -158,6 +158,7 @@ import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
import org.l2jmobius.gameserver.network.serverpackets.TeleportToLocation;
import org.l2jmobius.gameserver.network.serverpackets.UserInfo;
import org.l2jmobius.gameserver.taskmanager.AttackStanceTaskManager;
import org.l2jmobius.gameserver.taskmanager.CreatureSeeTaskManager;
import org.l2jmobius.gameserver.taskmanager.GameTimeTaskManager;
import org.l2jmobius.gameserver.util.Util;
@ -1752,6 +1753,7 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
// Forget all seen creatures.
if (_seenCreatures != null)
{
CreatureSeeTaskManager.getInstance().remove(this);
_seenCreatures.clear();
}
@ -5479,6 +5481,8 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
}
}
}
CreatureSeeTaskManager.getInstance().add(this);
}
public void updateSeenCreatures()

View File

@ -1087,8 +1087,7 @@ public class Npc extends Creature
setClanId(getCastle().getOwnerId());
}
if (isAttackable() // OnCreatureSee for non attackables is triggered at World.
&& CREATURE_SEE_IDS.contains(getId()))
if (CREATURE_SEE_IDS.contains(getId()))
{
initSeenCreatures();
}

View File

@ -0,0 +1,71 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.l2jmobius.gameserver.taskmanager;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import org.l2jmobius.commons.concurrent.ThreadPool;
import org.l2jmobius.gameserver.model.actor.Creature;
/**
* @author Mobius
*/
public class CreatureSeeTaskManager
{
private static final Set<Creature> CREATURES = ConcurrentHashMap.newKeySet();
private static boolean _working = false;
public CreatureSeeTaskManager()
{
ThreadPool.scheduleAtFixedRate(() ->
{
if (_working)
{
return;
}
_working = true;
for (Creature creature : CREATURES)
{
creature.updateSeenCreatures();
}
_working = false;
}, 1000, 1000);
}
public void add(Creature creature)
{
CREATURES.add(creature);
}
public void remove(Creature creature)
{
CREATURES.remove(creature);
}
public static CreatureSeeTaskManager getInstance()
{
return SingletonHolder.INSTANCE;
}
private static class SingletonHolder
{
protected static final CreatureSeeTaskManager INSTANCE = new CreatureSeeTaskManager();
}
}

View File

@ -254,7 +254,6 @@ public abstract class AbstractAI implements Ctrl
{
case EVT_THINK:
{
_actor.updateSeenCreatures();
onEvtThink();
break;
}

View File

@ -37,8 +37,6 @@ import org.l2jmobius.gameserver.model.actor.Npc;
import org.l2jmobius.gameserver.model.actor.Summon;
import org.l2jmobius.gameserver.model.actor.instance.PetInstance;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.events.EventDispatcher;
import org.l2jmobius.gameserver.model.events.impl.creature.OnCreatureSee;
import org.l2jmobius.gameserver.network.Disconnection;
import org.l2jmobius.gameserver.network.serverpackets.DeleteObject;
@ -357,13 +355,6 @@ public class World
}
}
}
// Notify OnCreatureSee for creatures that do not trigger EVT_THINK.
if (!wo.isAttackable() && wo.isCreature() && object.isCreature())
{
EventDispatcher.getInstance().notifyEventAsync(new OnCreatureSee((Creature) wo, (Creature) object), (Creature) wo);
EventDispatcher.getInstance().notifyEventAsync(new OnCreatureSee((Creature) object, (Creature) wo), (Creature) object);
}
});
}
@ -577,13 +568,6 @@ public class World
}
}
}
// Notify OnCreatureSee for creatures that do not trigger EVT_THINK.
if (!wo.isAttackable() && wo.isCreature() && object.isCreature())
{
EventDispatcher.getInstance().notifyEventAsync(new OnCreatureSee((Creature) wo, (Creature) object), (Creature) wo);
EventDispatcher.getInstance().notifyEventAsync(new OnCreatureSee((Creature) object, (Creature) wo), (Creature) object);
}
}
}
}

View File

@ -158,6 +158,7 @@ import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
import org.l2jmobius.gameserver.network.serverpackets.TeleportToLocation;
import org.l2jmobius.gameserver.network.serverpackets.UserInfo;
import org.l2jmobius.gameserver.taskmanager.AttackStanceTaskManager;
import org.l2jmobius.gameserver.taskmanager.CreatureSeeTaskManager;
import org.l2jmobius.gameserver.taskmanager.GameTimeTaskManager;
import org.l2jmobius.gameserver.util.Util;
@ -1752,6 +1753,7 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
// Forget all seen creatures.
if (_seenCreatures != null)
{
CreatureSeeTaskManager.getInstance().remove(this);
_seenCreatures.clear();
}
@ -5479,6 +5481,8 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
}
}
}
CreatureSeeTaskManager.getInstance().add(this);
}
public void updateSeenCreatures()

View File

@ -1087,8 +1087,7 @@ public class Npc extends Creature
setClanId(getCastle().getOwnerId());
}
if (isAttackable() // OnCreatureSee for non attackables is triggered at World.
&& CREATURE_SEE_IDS.contains(getId()))
if (CREATURE_SEE_IDS.contains(getId()))
{
initSeenCreatures();
}

View File

@ -0,0 +1,71 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.l2jmobius.gameserver.taskmanager;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import org.l2jmobius.commons.concurrent.ThreadPool;
import org.l2jmobius.gameserver.model.actor.Creature;
/**
* @author Mobius
*/
public class CreatureSeeTaskManager
{
private static final Set<Creature> CREATURES = ConcurrentHashMap.newKeySet();
private static boolean _working = false;
public CreatureSeeTaskManager()
{
ThreadPool.scheduleAtFixedRate(() ->
{
if (_working)
{
return;
}
_working = true;
for (Creature creature : CREATURES)
{
creature.updateSeenCreatures();
}
_working = false;
}, 1000, 1000);
}
public void add(Creature creature)
{
CREATURES.add(creature);
}
public void remove(Creature creature)
{
CREATURES.remove(creature);
}
public static CreatureSeeTaskManager getInstance()
{
return SingletonHolder.INSTANCE;
}
private static class SingletonHolder
{
protected static final CreatureSeeTaskManager INSTANCE = new CreatureSeeTaskManager();
}
}

View File

@ -254,7 +254,6 @@ public abstract class AbstractAI implements Ctrl
{
case EVT_THINK:
{
_actor.updateSeenCreatures();
onEvtThink();
break;
}

View File

@ -37,8 +37,6 @@ import org.l2jmobius.gameserver.model.actor.Npc;
import org.l2jmobius.gameserver.model.actor.Summon;
import org.l2jmobius.gameserver.model.actor.instance.PetInstance;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.events.EventDispatcher;
import org.l2jmobius.gameserver.model.events.impl.creature.OnCreatureSee;
import org.l2jmobius.gameserver.network.Disconnection;
import org.l2jmobius.gameserver.network.serverpackets.DeleteObject;
@ -357,13 +355,6 @@ public class World
}
}
}
// Notify OnCreatureSee for creatures that do not trigger EVT_THINK.
if (!wo.isAttackable() && wo.isCreature() && object.isCreature())
{
EventDispatcher.getInstance().notifyEventAsync(new OnCreatureSee((Creature) wo, (Creature) object), (Creature) wo);
EventDispatcher.getInstance().notifyEventAsync(new OnCreatureSee((Creature) object, (Creature) wo), (Creature) object);
}
});
}
@ -577,13 +568,6 @@ public class World
}
}
}
// Notify OnCreatureSee for creatures that do not trigger EVT_THINK.
if (!wo.isAttackable() && wo.isCreature() && object.isCreature())
{
EventDispatcher.getInstance().notifyEventAsync(new OnCreatureSee((Creature) wo, (Creature) object), (Creature) wo);
EventDispatcher.getInstance().notifyEventAsync(new OnCreatureSee((Creature) object, (Creature) wo), (Creature) object);
}
}
}
}

View File

@ -158,6 +158,7 @@ import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
import org.l2jmobius.gameserver.network.serverpackets.TeleportToLocation;
import org.l2jmobius.gameserver.network.serverpackets.UserInfo;
import org.l2jmobius.gameserver.taskmanager.AttackStanceTaskManager;
import org.l2jmobius.gameserver.taskmanager.CreatureSeeTaskManager;
import org.l2jmobius.gameserver.taskmanager.GameTimeTaskManager;
import org.l2jmobius.gameserver.util.Util;
@ -1752,6 +1753,7 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
// Forget all seen creatures.
if (_seenCreatures != null)
{
CreatureSeeTaskManager.getInstance().remove(this);
_seenCreatures.clear();
}
@ -5478,6 +5480,8 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
}
}
}
CreatureSeeTaskManager.getInstance().add(this);
}
public void updateSeenCreatures()

View File

@ -1087,8 +1087,7 @@ public class Npc extends Creature
setClanId(getCastle().getOwnerId());
}
if (isAttackable() // OnCreatureSee for non attackables is triggered at World.
&& CREATURE_SEE_IDS.contains(getId()))
if (CREATURE_SEE_IDS.contains(getId()))
{
initSeenCreatures();
}

View File

@ -0,0 +1,71 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.l2jmobius.gameserver.taskmanager;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import org.l2jmobius.commons.concurrent.ThreadPool;
import org.l2jmobius.gameserver.model.actor.Creature;
/**
* @author Mobius
*/
public class CreatureSeeTaskManager
{
private static final Set<Creature> CREATURES = ConcurrentHashMap.newKeySet();
private static boolean _working = false;
public CreatureSeeTaskManager()
{
ThreadPool.scheduleAtFixedRate(() ->
{
if (_working)
{
return;
}
_working = true;
for (Creature creature : CREATURES)
{
creature.updateSeenCreatures();
}
_working = false;
}, 1000, 1000);
}
public void add(Creature creature)
{
CREATURES.add(creature);
}
public void remove(Creature creature)
{
CREATURES.remove(creature);
}
public static CreatureSeeTaskManager getInstance()
{
return SingletonHolder.INSTANCE;
}
private static class SingletonHolder
{
protected static final CreatureSeeTaskManager INSTANCE = new CreatureSeeTaskManager();
}
}

View File

@ -254,7 +254,6 @@ public abstract class AbstractAI implements Ctrl
{
case EVT_THINK:
{
_actor.updateSeenCreatures();
onEvtThink();
break;
}

View File

@ -37,8 +37,6 @@ import org.l2jmobius.gameserver.model.actor.Npc;
import org.l2jmobius.gameserver.model.actor.Summon;
import org.l2jmobius.gameserver.model.actor.instance.PetInstance;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.events.EventDispatcher;
import org.l2jmobius.gameserver.model.events.impl.creature.OnCreatureSee;
import org.l2jmobius.gameserver.network.Disconnection;
import org.l2jmobius.gameserver.network.serverpackets.DeleteObject;
@ -357,13 +355,6 @@ public class World
}
}
}
// Notify OnCreatureSee for creatures that do not trigger EVT_THINK.
if (!wo.isAttackable() && wo.isCreature() && object.isCreature())
{
EventDispatcher.getInstance().notifyEventAsync(new OnCreatureSee((Creature) wo, (Creature) object), (Creature) wo);
EventDispatcher.getInstance().notifyEventAsync(new OnCreatureSee((Creature) object, (Creature) wo), (Creature) object);
}
});
}
@ -577,13 +568,6 @@ public class World
}
}
}
// Notify OnCreatureSee for creatures that do not trigger EVT_THINK.
if (!wo.isAttackable() && wo.isCreature() && object.isCreature())
{
EventDispatcher.getInstance().notifyEventAsync(new OnCreatureSee((Creature) wo, (Creature) object), (Creature) wo);
EventDispatcher.getInstance().notifyEventAsync(new OnCreatureSee((Creature) object, (Creature) wo), (Creature) object);
}
}
}
}

View File

@ -157,6 +157,7 @@ import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
import org.l2jmobius.gameserver.network.serverpackets.TeleportToLocation;
import org.l2jmobius.gameserver.network.serverpackets.UserInfo;
import org.l2jmobius.gameserver.taskmanager.AttackStanceTaskManager;
import org.l2jmobius.gameserver.taskmanager.CreatureSeeTaskManager;
import org.l2jmobius.gameserver.taskmanager.GameTimeTaskManager;
import org.l2jmobius.gameserver.util.Util;
@ -1751,6 +1752,7 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
// Forget all seen creatures.
if (_seenCreatures != null)
{
CreatureSeeTaskManager.getInstance().remove(this);
_seenCreatures.clear();
}
@ -5445,6 +5447,8 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
}
}
}
CreatureSeeTaskManager.getInstance().add(this);
}
public void updateSeenCreatures()

View File

@ -1059,8 +1059,7 @@ public class Npc extends Creature
setClanId(getCastle().getOwnerId());
}
if (isAttackable() // OnCreatureSee for non attackables is triggered at World.
&& CREATURE_SEE_IDS.contains(getId()))
if (CREATURE_SEE_IDS.contains(getId()))
{
initSeenCreatures();
}

View File

@ -0,0 +1,71 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.l2jmobius.gameserver.taskmanager;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import org.l2jmobius.commons.concurrent.ThreadPool;
import org.l2jmobius.gameserver.model.actor.Creature;
/**
* @author Mobius
*/
public class CreatureSeeTaskManager
{
private static final Set<Creature> CREATURES = ConcurrentHashMap.newKeySet();
private static boolean _working = false;
public CreatureSeeTaskManager()
{
ThreadPool.scheduleAtFixedRate(() ->
{
if (_working)
{
return;
}
_working = true;
for (Creature creature : CREATURES)
{
creature.updateSeenCreatures();
}
_working = false;
}, 1000, 1000);
}
public void add(Creature creature)
{
CREATURES.add(creature);
}
public void remove(Creature creature)
{
CREATURES.remove(creature);
}
public static CreatureSeeTaskManager getInstance()
{
return SingletonHolder.INSTANCE;
}
private static class SingletonHolder
{
protected static final CreatureSeeTaskManager INSTANCE = new CreatureSeeTaskManager();
}
}

View File

@ -254,7 +254,6 @@ public abstract class AbstractAI implements Ctrl
{
case EVT_THINK:
{
_actor.updateSeenCreatures();
onEvtThink();
break;
}

View File

@ -37,8 +37,6 @@ import org.l2jmobius.gameserver.model.actor.Npc;
import org.l2jmobius.gameserver.model.actor.Summon;
import org.l2jmobius.gameserver.model.actor.instance.PetInstance;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.events.EventDispatcher;
import org.l2jmobius.gameserver.model.events.impl.creature.OnCreatureSee;
import org.l2jmobius.gameserver.network.Disconnection;
import org.l2jmobius.gameserver.network.serverpackets.DeleteObject;
@ -357,13 +355,6 @@ public class World
}
}
}
// Notify OnCreatureSee for creatures that do not trigger EVT_THINK.
if (!wo.isAttackable() && wo.isCreature() && object.isCreature())
{
EventDispatcher.getInstance().notifyEventAsync(new OnCreatureSee((Creature) wo, (Creature) object), (Creature) wo);
EventDispatcher.getInstance().notifyEventAsync(new OnCreatureSee((Creature) object, (Creature) wo), (Creature) object);
}
});
}
@ -577,13 +568,6 @@ public class World
}
}
}
// Notify OnCreatureSee for creatures that do not trigger EVT_THINK.
if (!wo.isAttackable() && wo.isCreature() && object.isCreature())
{
EventDispatcher.getInstance().notifyEventAsync(new OnCreatureSee((Creature) wo, (Creature) object), (Creature) wo);
EventDispatcher.getInstance().notifyEventAsync(new OnCreatureSee((Creature) object, (Creature) wo), (Creature) object);
}
}
}
}

View File

@ -158,6 +158,7 @@ import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
import org.l2jmobius.gameserver.network.serverpackets.TeleportToLocation;
import org.l2jmobius.gameserver.network.serverpackets.UserInfo;
import org.l2jmobius.gameserver.taskmanager.AttackStanceTaskManager;
import org.l2jmobius.gameserver.taskmanager.CreatureSeeTaskManager;
import org.l2jmobius.gameserver.taskmanager.GameTimeTaskManager;
import org.l2jmobius.gameserver.util.Util;
@ -1755,6 +1756,7 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
// Forget all seen creatures.
if (_seenCreatures != null)
{
CreatureSeeTaskManager.getInstance().remove(this);
_seenCreatures.clear();
}
@ -5488,6 +5490,8 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
}
}
}
CreatureSeeTaskManager.getInstance().add(this);
}
public void updateSeenCreatures()

View File

@ -1088,8 +1088,7 @@ public class Npc extends Creature
setClanId(getCastle().getOwnerId());
}
if (isAttackable() // OnCreatureSee for non attackables is triggered at World.
&& CREATURE_SEE_IDS.contains(getId()))
if (CREATURE_SEE_IDS.contains(getId()))
{
initSeenCreatures();
}

View File

@ -0,0 +1,71 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.l2jmobius.gameserver.taskmanager;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import org.l2jmobius.commons.concurrent.ThreadPool;
import org.l2jmobius.gameserver.model.actor.Creature;
/**
* @author Mobius
*/
public class CreatureSeeTaskManager
{
private static final Set<Creature> CREATURES = ConcurrentHashMap.newKeySet();
private static boolean _working = false;
public CreatureSeeTaskManager()
{
ThreadPool.scheduleAtFixedRate(() ->
{
if (_working)
{
return;
}
_working = true;
for (Creature creature : CREATURES)
{
creature.updateSeenCreatures();
}
_working = false;
}, 1000, 1000);
}
public void add(Creature creature)
{
CREATURES.add(creature);
}
public void remove(Creature creature)
{
CREATURES.remove(creature);
}
public static CreatureSeeTaskManager getInstance()
{
return SingletonHolder.INSTANCE;
}
private static class SingletonHolder
{
protected static final CreatureSeeTaskManager INSTANCE = new CreatureSeeTaskManager();
}
}

Some files were not shown because too many files have changed in this diff Show More