net.runelite.api.events.NpcSpawned Java Examples

The following examples show how to use net.runelite.api.events.NpcSpawned. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ImplingsPlugin.java    From plugins with GNU General Public License v3.0 6 votes vote down vote up
@Subscribe
private void onNpcSpawned(NpcSpawned npcSpawned)
{
	NPC npc = npcSpawned.getNpc();
	Impling impling = Impling.findImpling(npc.getId());

	if (impling != null)
	{
		if (showImplingType(impling.getImplingType()) == ImplingsConfig.ImplingMode.NOTIFY)
		{
			notifier.notify(impling.getImplingType().getName() + " impling is in the area");
		}

		implings.add(npc);
	}
}
 
Example #2
Source File: NpcIndicatorsPluginTest.java    From runelite with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Test
public void testAliveNpcMenuHighlight()
{
	when(npcIndicatorsConfig.getNpcToHighlight()).thenReturn("goblin");
	when(npcIndicatorsConfig.highlightMenuNames()).thenReturn(true);
	when(npcIndicatorsConfig.getHighlightColor()).thenReturn(Color.BLUE);

	ConfigChanged configChanged = new ConfigChanged();
	configChanged.setGroup("npcindicators");
	npcIndicatorsPlugin.onConfigChanged(configChanged);

	NPC npc = mock(NPC.class);
	when(npc.getName()).thenReturn("Goblin");
	npcIndicatorsPlugin.onNpcSpawned(new NpcSpawned(npc));

	when(client.getCachedNPCs()).thenReturn(new NPC[]{npc}); // id 0

	when(client.getMenuEntries()).thenReturn(new MenuEntry[]{new MenuEntry()});
	MenuEntryAdded menuEntryAdded = new MenuEntryAdded("", "Goblin", MenuAction.NPC_FIRST_OPTION.getId(), 0, -1, -1);
	npcIndicatorsPlugin.onMenuEntryAdded(menuEntryAdded);

	MenuEntry target = new MenuEntry();
	target.setTarget("<col=0000ff>Goblin"); // blue
	verify(client).setMenuEntries(new MenuEntry[]{target});
}
 
Example #3
Source File: NpcIndicatorsPluginTest.java    From runelite with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Test
public void testDeadNpcMenuHighlight()
{
	when(npcIndicatorsConfig.getNpcToHighlight()).thenReturn("goblin");
	when(npcIndicatorsConfig.deadNpcMenuColor()).thenReturn(Color.RED);

	ConfigChanged configChanged = new ConfigChanged();
	configChanged.setGroup("npcindicators");
	npcIndicatorsPlugin.onConfigChanged(configChanged);

	NPC npc = mock(NPC.class);
	when(npc.getName()).thenReturn("Goblin");
	when(npc.isDead()).thenReturn(true);
	npcIndicatorsPlugin.onNpcSpawned(new NpcSpawned(npc));

	when(client.getCachedNPCs()).thenReturn(new NPC[]{npc}); // id 0

	when(client.getMenuEntries()).thenReturn(new MenuEntry[]{new MenuEntry()});
	MenuEntryAdded menuEntryAdded = new MenuEntryAdded("", "Goblin", MenuAction.NPC_FIRST_OPTION.getId(), 0, -1, -1);
	npcIndicatorsPlugin.onMenuEntryAdded(menuEntryAdded);

	MenuEntry target = new MenuEntry();
	target.setTarget("<col=ff0000>Goblin"); // red
	verify(client).setMenuEntries(new MenuEntry[]{target});
}
 
Example #4
Source File: ImplingsPlugin.java    From runelite with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Subscribe
public void onNpcSpawned(NpcSpawned npcSpawned)
{
	NPC npc = npcSpawned.getNpc();
	Impling impling = Impling.findImpling(npc.getId());

	if (impling != null)
	{
		if (showImplingType(impling.getImplingType()) == ImplingsConfig.ImplingMode.NOTIFY)
		{
			notifier.notify(impling.getImplingType().getName() + " impling is in the area");
		}

		implings.add(npc);
	}
}
 
Example #5
Source File: CorpPlugin.java    From runelite with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Subscribe
public void onNpcSpawned(NpcSpawned npcSpawned)
{
	NPC npc = npcSpawned.getNpc();

	switch (npc.getId())
	{
		case NpcID.CORPOREAL_BEAST:
			log.debug("Corporeal beast spawn: {}", npc);
			corp = npc;
			yourDamage = 0;
			totalDamage = 0;
			players.clear();
			break;
		case NpcID.DARK_ENERGY_CORE:
			core = npc;
			break;
	}
}
 
Example #6
Source File: NpcIndicatorsPluginTest.java    From plugins with GNU General Public License v3.0 6 votes vote down vote up
@Test
public void testAliveNpcMenuHighlight()
{
	when(npcIndicatorsConfig.getNpcToHighlight()).thenReturn("goblin");
	when(npcIndicatorsConfig.highlightMenuNames()).thenReturn(true);
	when(npcIndicatorsConfig.getHighlightColor()).thenReturn(Color.BLUE);

	ConfigChanged configChanged = new ConfigChanged();
	configChanged.setGroup("npcindicators");
	npcIndicatorsPlugin.onConfigChanged(configChanged);

	NPC npc = mock(NPC.class);
	when(npc.getName()).thenReturn("Goblin");
	npcIndicatorsPlugin.onNpcSpawned(new NpcSpawned(npc));

	when(client.getCachedNPCs()).thenReturn(new NPC[]{npc}); // id 0

	when(client.getMenuEntries()).thenReturn(new MenuEntry[]{new MenuEntry()});
	MenuEntryAdded menuEntryAdded = new MenuEntryAdded("", "Goblin", MenuOpcode.NPC_FIRST_OPTION.getId(), 0, -1, -1, false);
	npcIndicatorsPlugin.onMenuEntryAdded(menuEntryAdded);

	MenuEntry target = new MenuEntry();
	target.setTarget("<col=0000ff>Goblin"); // blue
	verify(client).setMenuEntries(new MenuEntry[]{target});
}
 
Example #7
Source File: NpcIndicatorsPluginTest.java    From plugins with GNU General Public License v3.0 6 votes vote down vote up
@Test
public void testDeadNpcMenuHighlight()
{
	when(npcIndicatorsConfig.getNpcToHighlight()).thenReturn("goblin");
	when(npcIndicatorsConfig.deadNpcMenuColor()).thenReturn(Color.RED);

	ConfigChanged configChanged = new ConfigChanged();
	configChanged.setGroup("npcindicators");
	npcIndicatorsPlugin.onConfigChanged(configChanged);

	NPC npc = mock(NPC.class);
	when(npc.getName()).thenReturn("Goblin");
	when(npc.isDead()).thenReturn(true);
	npcIndicatorsPlugin.onNpcSpawned(new NpcSpawned(npc));

	when(client.getCachedNPCs()).thenReturn(new NPC[]{npc}); // id 0

	when(client.getMenuEntries()).thenReturn(new MenuEntry[]{new MenuEntry()});
	MenuEntryAdded menuEntryAdded = new MenuEntryAdded("", "Goblin", MenuOpcode.NPC_FIRST_OPTION.getId(), 0, -1, -1, false);
	npcIndicatorsPlugin.onMenuEntryAdded(menuEntryAdded);

	MenuEntry target = new MenuEntry();
	target.setTarget("<col=ff0000>Goblin"); // red
	verify(client).setMenuEntries(new MenuEntry[]{target});
}
 
Example #8
Source File: CorpPlugin.java    From plugins with GNU General Public License v3.0 6 votes vote down vote up
@Subscribe
private void onNpcSpawned(NpcSpawned npcSpawned)
{
	NPC npc = npcSpawned.getNpc();

	switch (npc.getId())
	{
		case NpcID.CORPOREAL_BEAST:
			log.debug("Corporeal beast spawn: {}", npc);
			corp = npc;
			yourDamage = 0;
			totalDamage = 0;
			players.clear();
			break;
		case NpcID.DARK_ENERGY_CORE:
			core = npc;
			break;
	}
}
 
Example #9
Source File: NpcStatusPlugin.java    From plugins with GNU General Public License v3.0 6 votes vote down vote up
@Subscribe
private void onNpcSpawned(NpcSpawned npcSpawned)
{
	final NPC npc = npcSpawned.getNpc();
	final String npcName = npc.getName();

	if (npcName == null || !Arrays.asList(npc.getDefinition().getActions()).contains("Attack"))
	{
		return;
	}
	int AttackSpeed = npcManager.getAttackSpeed(npc.getId());
	if (AttackSpeed == 0)
	{
		AttackSpeed = 4;
	}
	memorizedNPCs.add(new MemorizedNPC(npc, AttackSpeed, npc.getWorldArea()));
}
 
Example #10
Source File: BarbarianAssaultPlugin.java    From plugins with GNU General Public License v3.0 6 votes vote down vote up
@Subscribe
private void onNpcSpawned(NpcSpawned event)
{
	if (!isInGame())
	{
		return;
	}

	NPC npc = event.getNpc();

	if (npc == null)
	{
		return;
	}

	String name = event.getNpc().getName();

	if (name.equals("Penance Healer") && !healers.containsKey(npc.getIndex()))
	{
		healers.put(npc.getIndex(), new Healer(npc, healers.size(), stage));
	}
}
 
Example #11
Source File: SlayerPlugin.java    From runelite with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Subscribe
public void onNpcSpawned(NpcSpawned npcSpawned)
{
	NPC npc = npcSpawned.getNpc();
	if (isTarget(npc))
	{
		highlightedTargets.add(npc);
	}
}
 
Example #12
Source File: StealingArtefactsPlugin.java    From plugins with GNU General Public License v3.0 5 votes vote down vote up
@Subscribe
private void onNpcSpawned(NpcSpawned event)
{
	NPC npc = event.getNpc();

	if (displayHintArrow &&
		Objects.equals(npc.getName(), NPC_NAME_CAPTAIN_KHALED) &&
		stealingArtefactsHouse.equals(StealingArtefactsHouse.CAPTAIN_KHALED) &&
		!client.getHintArrowType().equals(HintArrowType.NPC))
	{
		removeHintArrow();
		client.setHintArrow(npc);
	}
}
 
Example #13
Source File: SlayerPlugin.java    From plugins with GNU General Public License v3.0 5 votes vote down vote up
@Subscribe
private void onNpcSpawned(NpcSpawned npcSpawned)
{
	NPC npc = npcSpawned.getNpc();
	if (isTarget(npc, targetNames))
	{
		highlightedTargets.add(npc);
	}
}
 
Example #14
Source File: FishingPlugin.java    From runelite with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Subscribe
public void onNpcSpawned(NpcSpawned event)
{
	final NPC npc = event.getNpc();

	if (FishingSpot.findSpot(npc.getId()) == null)
	{
		return;
	}

	fishingSpots.add(npc);
	inverseSortSpotDistanceFromPlayer();
}
 
Example #15
Source File: AgilityPlugin.java    From runelite with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Subscribe
public void onNpcSpawned(NpcSpawned npcSpawned)
{
	NPC npc = npcSpawned.getNpc();

	if (SEPULCHRE_NPCS.contains(npc.getId()))
	{
		npcs.add(npc);
	}
}
 
Example #16
Source File: NpcIndicatorsPlugin.java    From runelite with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Subscribe
public void onNpcSpawned(NpcSpawned npcSpawned)
{
	final NPC npc = npcSpawned.getNpc();
	final String npcName = npc.getName();

	if (npcName == null)
	{
		return;
	}

	if (npcTags.contains(npc.getIndex()))
	{
		memorizeNpc(npc);
		highlightedNpcs.add(npc);
		spawnedNpcsThisTick.add(npc);
		return;
	}

	for (String highlight : highlights)
	{
		if (WildcardMatcher.matches(highlight, npcName))
		{
			highlightedNpcs.add(npc);
			if (!client.isInInstancedRegion())
			{
				memorizeNpc(npc);
				spawnedNpcsThisTick.add(npc);
			}
			break;
		}
	}
}
 
Example #17
Source File: RunecraftPlugin.java    From runelite with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Subscribe
public void onNpcSpawned(NpcSpawned event)
{
	final NPC npc = event.getNpc();
	if (npc.getId() == NpcID.DARK_MAGE)
	{
		darkMage = npc;
	}
}
 
Example #18
Source File: KourendLibraryPlugin.java    From plugins with GNU General Public License v3.0 5 votes vote down vote up
@Subscribe
public void onNpcSpawned(NpcSpawned event)
{
	if (isLibraryCustomer(event.getNpc().getId()))
	{
		npcsToMark.add(event.getNpc());
	}
}
 
Example #19
Source File: NpcAggroAreaPlugin.java    From runelite with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Subscribe
public void onNpcSpawned(NpcSpawned event)
{
	if (config.alwaysActive())
	{
		return;
	}

	checkAreaNpcs(event.getNpc());
}
 
Example #20
Source File: TelekineticRoom.java    From runelite with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Subscribe
public void onNpcSpawned(NpcSpawned event)
{
	NPC npc = event.getNpc();

	if (npc.getId() == NpcID.MAZE_GUARDIAN)
	{
		guardian = npc;
	}
}
 
Example #21
Source File: PestControlPlugin.java    From runelite with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Subscribe
public void onNpcSpawned(NpcSpawned event)
{
	final NPC npc = event.getNpc();
	if (SPINNER_IDS.contains(npc.getId()))
	{
		spinners.add(npc);
	}
}
 
Example #22
Source File: KourendLibraryPlugin.java    From runelite with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Subscribe
public void onNpcSpawned(NpcSpawned event)
{
	if (isLibraryCustomer(event.getNpc().getId()))
	{
		npcsToMark.add(event.getNpc());
	}
}
 
Example #23
Source File: TelekineticRoom.java    From plugins with GNU General Public License v3.0 5 votes vote down vote up
private void onNpcSpawned(NpcSpawned event)
{
	NPC npc = event.getNpc();

	if (npc.getId() == NpcID.MAZE_GUARDIAN)
	{
		guardian = npc;
	}
}
 
Example #24
Source File: DriftNetPlugin.java    From runelite with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Subscribe
public void onNpcSpawned(NpcSpawned event)
{
	final NPC npc = event.getNpc();
	if (npc.getId() == NpcID.FISH_SHOAL)
	{
		fish.add(npc);
	}
}
 
Example #25
Source File: BasicBossSwapper.java    From ExternalPlugins with GNU General Public License v3.0 5 votes vote down vote up
@Subscribe
public void onNpcSpawned(NpcSpawned event)
{
	final NPC npc = event.getNpc();

	switch (npc.getId())
	{
		case NpcID.NYLOCAS_VASILIAS:
		case NpcID.NYLOCAS_VASILIAS_8355:
		case NpcID.NYLOCAS_VASILIAS_8356:
		case NpcID.NYLOCAS_VASILIAS_8357:
			nylo = npc;
			break;
	}
}
 
Example #26
Source File: FishingPlugin.java    From plugins with GNU General Public License v3.0 5 votes vote down vote up
@Subscribe
private void onNpcSpawned(NpcSpawned event)
{
	final NPC npc = event.getNpc();

	if (FishingSpot.findSpot(npc.getId()) == null)
	{
		return;
	}

	fishingSpots.add(npc);
	inverseSortSpotDistanceFromPlayer();
}
 
Example #27
Source File: DriftNetPlugin.java    From plugins with GNU General Public License v3.0 5 votes vote down vote up
@Subscribe
public void onNpcSpawned(NpcSpawned event)
{
	final NPC npc = event.getNpc();
	if (npc.getId() == NpcID.FISH_SHOAL)
	{
		fish.add(npc);
	}
}
 
Example #28
Source File: AgilityPlugin.java    From plugins with GNU General Public License v3.0 5 votes vote down vote up
@Subscribe
public void onNpcSpawned(NpcSpawned npcSpawned)
{
	NPC npc = npcSpawned.getNpc();

	if (SEPULCHRE_NPCS.contains(npc.getId()))
	{
		npcs.add(npc);
	}
}
 
Example #29
Source File: ZalcanoPlugin.java    From plugins with GNU General Public License v3.0 5 votes vote down vote up
@Subscribe
private void onNpcSpawned(NpcSpawned npcSpawned)
{
	switch (npcSpawned.getNpc().getId())
	{
		case NpcID.ZALCANO:
			log.debug("zalcano spawned");
			zalcano = npcSpawned.getNpc();
			break;
		case NpcID.GOLEM_9051:
			log.debug("golem spawned");
			golem = npcSpawned.getNpc();
			break;
	}
}
 
Example #30
Source File: NpcIndicatorsPlugin.java    From plugins with GNU General Public License v3.0 5 votes vote down vote up
@Subscribe
void onNpcSpawned(NpcSpawned npcSpawned)
{
	NPC npc = npcSpawned.getNpc();
	highlightNpcIfMatch(npc);

	if (memorizedNpcs.containsKey(npc.getIndex()))
	{
		spawnedNpcsThisTick.add(npc);
	}
}