Java Code Examples for net.runelite.api.Player#getCombatLevel()

The following examples show how to use net.runelite.api.Player#getCombatLevel() . 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: LootTrackerPlugin.java    From runelite with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Subscribe
public void onPlayerLootReceived(final PlayerLootReceived playerLootReceived)
{
	// Ignore Last Man Standing player loots
	if (isPlayerWithinMapRegion(LAST_MAN_STANDING_REGIONS))
	{
		return;
	}

	final Player player = playerLootReceived.getPlayer();
	final Collection<ItemStack> items = playerLootReceived.getItems();
	final String name = player.getName();
	final int combat = player.getCombatLevel();

	addLoot(name, combat, LootRecordType.PLAYER, items);

	if (config.pvpKillChatMessage())
	{
		lootReceivedChatMessage(items, name);
	}
}
 
Example 2
Source File: IdleNotifierPlugin.java    From plugins with GNU General Public License v3.0 5 votes vote down vote up
@Subscribe
private void onPlayerSpawned(PlayerSpawned event)
{
	final Player p = event.getPlayer();
	if (config.notifyPkers() && p != null && p != client.getLocalPlayer()
		&& PvPUtil.isAttackable(client, p) && !client.isFriended(p.getName(), false)
		&& !friendChatManager.isMember(p.getName()))
	{
		String playerName = p.getName();
		int combat = p.getCombatLevel();
		notifier.notify("PK'er warning! A level " + combat + " player named " + playerName +
			" appeared!", TrayIcon.MessageType.WARNING);
	}
}
 
Example 3
Source File: NpcAggroAreaPlugin.java    From plugins with GNU General Public License v3.0 5 votes vote down vote up
private boolean isNpcMatch(NPC npc)
{
	NPCDefinition composition = npc.getTransformedDefinition();
	if (composition == null)
	{
		return false;
	}

	if (Strings.isNullOrEmpty(composition.getName()))
	{
		return false;
	}

	// Most NPCs stop aggroing when the player has more than double
	// its combat level.
	final Player localPlayer = client.getLocalPlayer();
	if (localPlayer == null)
	{
		return false;
	}

	final int playerLvl = localPlayer.getCombatLevel();
	final int npcLvl = composition.getCombatLevel();
	final String npcName = composition.getName().toLowerCase();
	if (npcLvl > 0 && playerLvl > npcLvl * 2 && !isInWilderness(npc.getWorldLocation()))
	{
		return false;
	}

	for (String pattern : npcNamePatterns)
	{
		if (WildcardMatcher.matches(pattern, npcName))
		{
			return true;
		}
	}

	return false;
}
 
Example 4
Source File: LootTrackerPlugin.java    From plugins with GNU General Public License v3.0 4 votes vote down vote up
@Subscribe
private void onPlayerLootReceived(final PlayerLootReceived playerLootReceived)
{
	if (client.getLocalPlayer() == null)
	{
		return;
	}

	// Ignore Last Man Standing player loots
	if (isPlayerWithinMapRegion(LAST_MAN_STANDING_REGIONS))
	{
		return;
	}

	if (config.sendLootValueMessages())
	{
		if (WorldType.isDeadmanWorld(client.getWorldType()) || WorldType.isHighRiskWorld(client.getWorldType()) ||
			WorldType.isPvpWorld(client.getWorldType()) || client.getVar(Varbits.IN_WILDERNESS) == 1)
		{
			final String totalValue = QuantityFormatter.quantityToStackSize(playerLootReceived.getItems().stream()
				.mapToInt(itemStack -> itemManager.getItemPrice(itemStack.getId()) * itemStack.getQuantity()).sum());

			chatMessageManager.queue(QueuedMessage.builder().type(ChatMessageType.CONSOLE).runeLiteFormattedMessage(
				new ChatMessageBuilder().append("The total value of your loot is " + totalValue + " GP.")
					.build()).build());
		}
	}

	final Player player = playerLootReceived.getPlayer();
	final Collection<ItemStack> items = playerLootReceived.getItems();
	final String name = player.getName();
	final int combat = player.getCombatLevel();
	final LootTrackerItem[] entries = buildEntries(stack(items));
	String localUsername = client.getLocalPlayer().getName();
	LootRecord lootRecord = new LootRecord(name, localUsername, LootRecordType.PLAYER,
		toGameItems(items), Instant.now());
	SwingUtilities.invokeLater(() -> panel.add(name, localUsername, lootRecord.getType(), combat, entries));
	if (config.saveLoot())
	{
		synchronized (queuedLoots)
		{
			queuedLoots.add(lootRecord);
		}
	}
	if (config.localPersistence())
	{
		saveLocalLootRecord(lootRecord);
	}

	eventBus.post(LootReceived.class, new LootReceived(name, combat, LootRecordType.PLAYER, items));
}