hello, sorry, the nuisance, I managed to make the npc only see the one who calls them and that they disappear 60 seconds after using the item, I also made it so that they cannot spam the item but I can't get the npc to be automatically deleted when moving the player because I don't know where the player's movement is
this is how spawnservitors is
public void spawnServitors()
{
/** The _player. */
final L2PcInstance _player;
_player = L2PcInstance.this;
InstanceManager.getInstance().createInstance(getObjectId());
L2Spawn servitor;
float angle = Rnd.get(1000);
int sCount = 4;
for (int i = 0; i < sCount; i++)
{
final L2Spawn npc = servitor = getNpcServitor(i);
if (servitor != null)
{
servitor.setInstanceId(getObjectId());
_player.setInstanceId(_player.getObjectId());
_player.getAppearance().setInvisible();
servitor.setLocx(Math.round(getX() + (float) Math.cos(angle / 1000 * 2 * Math.PI) * 30));
servitor.setLocy(Math.round(getY() + (float) Math.sin(angle / 1000 * 2 * Math.PI) * 65));
servitor.setLocz(getZ());
int heading = (int) Math.round(Math.atan2(getY() - servitor.getLocy(), getX() - servitor.getLocx()) / Math.PI * 32768);
if (heading < 0)
{
heading = 65535 + heading;
}
servitor.setHeading(heading);
if (InstanceManager.getInstance().getInstance(getObjectId()) != null)
{
servitor.doSpawn();
ThreadPoolManager.getInstance().scheduleGeneral(() -> npc.getLastSpawn().decayMe(), 60000);
}
if (_player.isMoving() || !isInsideRadius(_player, Config.NPC_MAGIC_GEM_RADIUS, false, false))
{
ThreadPoolManager.getInstance().scheduleGeneral(() -> npc.getLastSpawn().decayMe(), 1000);
_player.setInstanceId(0);
}
}
angle += 1000 / sCount;
}
}
and this is the part of the item
if (!player.getFloodProtectors().getMagicGem().tryPerformAction("Magic Gem"))
{
return;
}
if (!GrandBossManager.getInstance().checkIfInZone(null, player) && player.getInstanceId() == 0 && !player.isInsideZone(ZoneId.ZONE_PVP) && (!player.isInsideZone(ZoneId.ZONE_NOSUMMONFRIEND) || !player.isInsideZone(ZoneId.ZONE_TOWN)) && !player.isInOlympiadMode()
&& !AttackStanceTaskManager.getInstance().getAttackStanceTask(player) && InstanceManager.getInstance().getInstance(player.getObjectId()) == null && player.getPvpFlag() == 0)
{
player.spawnServitors();
player.sendMessage("You use a Magic Gem.");
ThreadPoolManager.getInstance().scheduleGeneral(new Runnable()
{
@Override
public void run()
{
player.setInstanceId(0);
player.getAppearance().setVisible();
}
}, 59000);
}
else
{
player.sendMessage("You cannot use a Magic Gem right now.");
}