net.runelite.client.eventbus.Subscribe Java Examples

The following examples show how to use net.runelite.client.eventbus.Subscribe. 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: BlastMinePlugin.java    From plugins with GNU General Public License v3.0 6 votes vote down vote up
@Subscribe
private void onGameObjectSpawned(GameObjectSpawned event)
{
	final GameObject gameObject = event.getGameObject();
	BlastMineRockType blastMineRockType = BlastMineRockType.getRockType(gameObject.getId());
	if (blastMineRockType == null)
	{
		return;
	}

	final BlastMineRock newRock = new BlastMineRock(gameObject, blastMineRockType);
	final BlastMineRock oldRock = rocks.get(gameObject.getWorldLocation());

	if (oldRock == null || oldRock.getType() != newRock.getType())
	{
		rocks.put(gameObject.getWorldLocation(), newRock);
	}
}
 
Example #2
Source File: ObjectIndicatorsPlugin.java    From plugins with GNU General Public License v3.0 6 votes vote down vote up
@Subscribe
private void onGameStateChanged(GameStateChanged gameStateChanged)
{
	GameState gameState = gameStateChanged.getGameState();
	if (gameState == GameState.LOADING)
	{
		// Reload points with new map regions

		points.clear();
		for (int regionId : client.getMapRegions())
		{
			// load points for region
			final Set<ObjectPoint> regionPoints = loadPoints(regionId);
			if (regionPoints != null)
			{
				points.put(regionId, regionPoints);
			}
		}
	}

	if (gameStateChanged.getGameState() != GameState.LOGGED_IN)
	{
		objects.clear();
	}
}
 
Example #3
Source File: WoodcuttingPlugin.java    From plugins with GNU General Public License v3.0 6 votes vote down vote up
@Subscribe
private void onAnimationChanged(final AnimationChanged event)
{
	Player local = client.getLocalPlayer();

	if (event.getActor() != local)
	{
		return;
	}

	int animId = local.getAnimation();
	Axe axe = Axe.findAxeByAnimId(animId);
	if (axe != null)
	{
		this.axe = axe;
	}
}
 
Example #4
Source File: PartyPlugin.java    From plugins with GNU General Public License v3.0 6 votes vote down vote up
@Subscribe
private void onSkillUpdate(final SkillUpdate event)
{
	final PartyData partyData = getPartyData(event.getMemberId());

	if (partyData == null)
	{
		return;
	}

	if (event.getSkill() == Skill.HITPOINTS)
	{
		partyData.setHitpoints(event.getValue());
		partyData.setMaxHitpoints(event.getMax());
	}
	else if (event.getSkill() == Skill.PRAYER)
	{
		partyData.setPrayer(event.getValue());
		partyData.setMaxPrayer(event.getMax());
	}
}
 
Example #5
Source File: SlayerPlugin.java    From plugins with GNU General Public License v3.0 6 votes vote down vote up
@Subscribe
private void onConfigChanged(ConfigChanged event)
{
	if (!event.getGroup().equals("slayer"))
	{
		return;
	}

	if (event.getKey().equals("infobox"))
	{
		if (config.showInfobox())
		{
			clientThread.invoke(this::addCounter);
		}
		else
		{
			removeCounter();
		}
	}
}
 
Example #6
Source File: GroundItemsPlugin.java    From plugins with GNU General Public License v3.0 6 votes vote down vote up
@Subscribe
private void onItemSpawned(ItemSpawned itemSpawned)
{
	TileItem item = itemSpawned.getItem();
	Tile tile = itemSpawned.getTile();

	GroundItem groundItem = buildGroundItem(tile, item);

	GroundItem.GroundItemKey groundItemKey = new GroundItem.GroundItemKey(item.getId(), tile.getWorldLocation());
	GroundItem existing = collectedGroundItems.putIfAbsent(groundItemKey, groundItem);
	if (existing != null)
	{
		existing.setQuantity(existing.getQuantity() + groundItem.getQuantity());
		// The spawn time remains set at the oldest spawn
	}

	if (!config.onlyShowLoot())
	{
		notifyHighlightedItem(groundItem);
	}
}
 
Example #7
Source File: CorpPlugin.java    From plugins with GNU General Public License v3.0 6 votes vote down vote up
@Subscribe
private void onHitsplatApplied(HitsplatApplied hitsplatApplied)
{
	Actor actor = hitsplatApplied.getActor();

	if (actor != corp)
	{
		return;
	}

	int myDamage = client.getVar(Varbits.CORP_DAMAGE);
	// sometimes hitsplats are applied after the damage counter has been reset
	if (myDamage > 0)
	{
		yourDamage = myDamage;
	}
	totalDamage += hitsplatApplied.getHitsplat().getAmount();
}
 
Example #8
Source File: PartyPlugin.java    From plugins with GNU General Public License v3.0 6 votes vote down vote up
@Subscribe
private void onTilePing(TilePing event)
{
	if (config.pings())
	{
		final PartyData partyData = getPartyData(event.getMemberId());
		final Color color = partyData != null ? partyData.getColor() : Color.RED;
		pendingTilePings.add(new PartyTilePingData(event.getPoint(), color));
	}

	if (config.sounds())
	{
		WorldPoint point = event.getPoint();

		if (point.getPlane() != client.getPlane() || !WorldPoint.isInScene(client, point.getX(), point.getY()))
		{
			return;
		}

		clientThread.invoke(() -> client.playSoundEffect(SoundEffectID.SMITH_ANVIL_TINK));
	}
}
 
Example #9
Source File: HerbiboarPlugin.java    From plugins with GNU General Public License v3.0 6 votes vote down vote up
@Subscribe
public void onMenuOptionClicked(MenuOptionClicked menuOpt)
{
	if (!inHerbiboarArea || started || MenuOpcode.GAME_OBJECT_FIRST_OPTION != menuOpt.getMenuOpcode())
	{
		return;
	}

	switch (Text.removeTags(menuOpt.getTarget()))
	{
		case "Rock":
		case "Mushroom":
		case "Driftwood":
			startPoint = WorldPoint.fromScene(client, menuOpt.getParam0(), menuOpt.getParam1(), client.getPlane());
	}
}
 
Example #10
Source File: TimersPlugin.java    From plugins with GNU General Public License v3.0 6 votes vote down vote up
@Subscribe
private void onStatChanged(StatChanged event)
{
	Skill skill = event.getSkill();

	if (skill != Skill.MAGIC || !config.showImbuedHeart() || !imbuedHeartClicked)
	{
		return;
	}

	int magicLvl = client.getRealSkillLevel(skill);
	int magicBoost = client.getBoostedSkillLevel(skill);
	int heartBoost = 1 + (int) (magicLvl * 0.1);

	if (magicBoost - magicLvl != heartBoost)
	{
		return;
	}

	imbuedHeartClicked = false;
	createGameTimer(IMBUEDHEART);
}
 
Example #11
Source File: PohPlugin.java    From plugins with GNU General Public License v3.0 6 votes vote down vote up
@Subscribe
private void onGameObjectSpawned(GameObjectSpawned event)
{
	final GameObject gameObject = event.getGameObject();

	if (!BURNER_LIT.contains(gameObject.getId()) && !BURNER_UNLIT.contains(gameObject.getId()))
	{
		if (PohIcons.getIcon(gameObject.getId()) != null)
		{
			pohObjects.put(gameObject, event.getTile());
		}

		return;
	}

	final double countdownTimer = 130.0; // Minimum amount of seconds a burner will light
	final double randomTimer = 30.0; // Minimum amount of seconds a burner will light
	incenseBurners.put(event.getTile(), new IncenseBurner(gameObject.getId(), countdownTimer, randomTimer, null));
}
 
Example #12
Source File: StatusOrbsPlugin.java    From plugins with GNU General Public License v3.0 6 votes vote down vote up
@Subscribe
private void onConfigChanged(ConfigChanged event)
{
	if (event.getGroup().equals("statusorbs"))
	{
		switch (event.getKey())
		{
			case "replaceOrbText":
				if (!config.replaceOrbText())
				{
					resetRunOrbText();
				}
				break;
			case "dynamicHpHeart":
				if (config.dynamicHpHeart())
				{
					checkHealthIcon();
				}
				else
				{
					resetHealthIcon();
				}
				break;
		}
	}
}
 
Example #13
Source File: BarrowsPlugin.java    From plugins with GNU General Public License v3.0 6 votes vote down vote up
@Subscribe
private void onWidgetLoaded(WidgetLoaded event)
{
	if (event.getGroupId() == WidgetID.BARROWS_PUZZLE_GROUP_ID)
	{
		final int answer = client.getWidget(WidgetInfo.BARROWS_FIRST_PUZZLE).getModelId() - 3;
		puzzleAnswer = null;

		for (WidgetInfo puzzleNode : POSSIBLE_SOLUTIONS)
		{
			final Widget widgetToCheck = client.getWidget(puzzleNode);

			if (widgetToCheck != null && widgetToCheck.getModelId() == answer)
			{
				puzzleAnswer = client.getWidget(puzzleNode);
				break;
			}
		}
	}
}
 
Example #14
Source File: ShayzienInfirmaryPlugin.java    From plugins with GNU General Public License v3.0 6 votes vote down vote up
@Subscribe
private void onGameTick(GameTick event)
{
	if (isNotAtInfirmary())
	{
		return;
	}

	unhealedSoldiers.clear();

	for (NPC npc : client.getNpcs())
	{
		if (isUnhealedSoldierId(npc.getId()))
		{
			unhealedSoldiers.add(npc);
		}
	}
}
 
Example #15
Source File: DiscordPlugin.java    From plugins with GNU General Public License v3.0 6 votes vote down vote up
@Subscribe
private void onGameStateChanged(GameStateChanged event)
{
	switch (event.getGameState())
	{
		case LOGIN_SCREEN:
			checkForGameStateUpdate();
			return;
		case LOGGING_IN:
			loginFlag = true;
			break;
		case LOGGED_IN:
			if (loginFlag)
			{
				loginFlag = false;
				checkForGameStateUpdate();
			}

			break;
	}

	checkForAreaUpdate();
}
 
Example #16
Source File: TMorph.java    From plugins with GNU General Public License v3.0 6 votes vote down vote up
@Subscribe
public void onGameTick(GameTick event)
{
	if (client.getGameState() != GameState.LOGGED_IN)
	{
		return;
	}

	final Player player = client.getLocalPlayer();

	if (player == null
		|| player.getPlayerAppearance() == null
		|| client.getWidget(WidgetInfo.LOGIN_CLICK_TO_PLAY_SCREEN) != null
		|| client.getViewportWidget() == null)
	{
		return;
	}

	updateGear(panelMorph, player);
	updateGear(NEWLINE_SPLITTER.withKeyValueSeparator(':').split(config.set1()), player);
	updateGear(NEWLINE_SPLITTER.withKeyValueSeparator(':').split(config.set2()), player);
	updateGear(NEWLINE_SPLITTER.withKeyValueSeparator(':').split(config.set3()), player);
}
 
Example #17
Source File: MotherlodePlugin.java    From plugins with GNU General Public License v3.0 6 votes vote down vote up
@Subscribe
private void onGameObjectChanged(GameObjectChanged event)
{
	if (!inMlm)
	{
		return;
	}

	GameObject previous = event.getPrevious();
	GameObject gameObject = event.getGameObject();

	rocks.remove(previous);
	if (ROCK_OBSTACLES.contains(gameObject.getId()))
	{
		rocks.add(gameObject);
	}

}
 
Example #18
Source File: MotherlodePlugin.java    From plugins with GNU General Public License v3.0 6 votes vote down vote up
@Subscribe
void onItemContainerChanged(ItemContainerChanged event)
{
	final ItemContainer container = event.getItemContainer();

	if (!inMlm || !shouldUpdateOres || inventorySnapshot == null || container != client.getItemContainer(InventoryID.INVENTORY))
	{
		return;
	}

	// Build set of current inventory
	Multiset<Integer> current = HashMultiset.create();
	Arrays.stream(container.getItems())
		.filter(item -> MLM_ORE_TYPES.contains(item.getId()))
		.forEach(item -> current.add(item.getId(), item.getQuantity()));

	// Take the difference
	Multiset<Integer> delta = Multisets.difference(current, inventorySnapshot);

	// Update the session
	delta.forEachEntry(session::updateOreFound);
	inventorySnapshot = null;
	shouldUpdateOres = false;
}
 
Example #19
Source File: BronzeManPlugin.java    From plugins with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Loads players unlocks on login
 **/
@Subscribe
public void onGameStateChanged(GameStateChanged e)
{
	if (e.getGameState() == GameState.LOGGED_IN)
	{
		loadPlayerUnlocks();
		setupImages();
	}
	if (e.getGameState() == GameState.LOGIN_SCREEN)
	{
		itemEntries = null;
	}
}
 
Example #20
Source File: BarbarianAssaultPlugin.java    From plugins with GNU General Public License v3.0 5 votes vote down vote up
@Subscribe
private void onInteractingChanged(InteractingChanged event)
{
	if (!isInGame() || getRole() != Role.HEALER)
	{
		return;
	}

	Actor source = event.getSource();

	if (source != client.getLocalPlayer())
	{
		return;
	}

	Actor opponent = event.getTarget();

	if (opponent == null)
	{
		if (lastInteracted != -1 && StringUtils.equalsIgnoreCase(poisonUsed, getRole().getListen(client)) && healers.containsKey(lastInteracted))
		{
			Healer healer = healers.get(lastInteracted);
			healer.setFoodRemaining(healer.getFoodRemaining() - 1);
			healer.setTimeLastPoisoned(Instant.now());
		}

		lastInteracted = -1;
		poisonUsed = null;
	}
	else if (StringUtils.equals(opponent.getName(), "Penance Healer"))
	{
		lastInteracted = ((NPC) opponent).getIndex();
	}

}
 
Example #21
Source File: KourendLibraryPlugin.java    From plugins with GNU General Public License v3.0 5 votes vote down vote up
@Subscribe
public void onGameStateChanged(GameStateChanged event)
{
	if (event.getGameState() == GameState.LOGIN_SCREEN ||
		event.getGameState() == GameState.HOPPING)
	{
		npcsToMark.clear();
	}
}
 
Example #22
Source File: DiscordPlugin.java    From plugins with GNU General Public License v3.0 5 votes vote down vote up
@Subscribe
private void onUserSync(final UserSync event)
{
	final PartyMember localMember = partyService.getLocalMember();

	if (localMember != null && discordService.getCurrentUser() != null)
	{
		final DiscordUserInfo userInfo = new DiscordUserInfo(
			discordService.getCurrentUser().userId,
			discordService.getCurrentUser().avatar);

		userInfo.setMemberId(localMember.getMemberId());
		wsClient.send(userInfo);
	}
}
 
Example #23
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 #24
Source File: BanListPlugin.java    From plugins with GNU General Public License v3.0 5 votes vote down vote up
@Subscribe
private void onConfigChanged(ConfigChanged event)
{
	if (event.getGroup().equals("banlist") && event.getKey().equals("bannedPlayers"))
	{
		manualBans.clear();

		String newValue = event.getNewValue();

		manualBans.addAll(Text.fromCSV(Text.standardize(newValue)));
	}
}
 
Example #25
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 #26
Source File: FriendTaggingPlugin.java    From plugins with GNU General Public License v3.0 5 votes vote down vote up
@Subscribe
private void onNameableNameChanged(NameableNameChanged event)
{
	final Nameable nameable = event.getNameable();

	if (nameable instanceof Friend)
	{
		// Migrate a friend's note to their new display name
		final Friend friend = (Friend) nameable;
		if (friend.getName() != null && friend.getPrevName() != null)
		{
			migrateFriendTag(friend.getName(), friend.getPrevName());
		}
	}
}
 
Example #27
Source File: GrandExchangePlugin.java    From plugins with GNU General Public License v3.0 5 votes vote down vote up
@Subscribe
private void onMenuEntryAdded(MenuEntryAdded menuEntry)
{
	// At the moment, if the user disables quick lookup, the input listener gets disabled. Thus, isHotKeyPressed()
	// should always return false when quick lookup is disabled.
	// Replace the default option with "Search ..." when holding alt
	if (client.getGameState() != GameState.LOGGED_IN || !hotKeyPressed)
	{
		return;
	}

	final int widgetId = menuEntry.getParam1();
	final int groupId = WidgetInfo.TO_GROUP(widgetId);

	switch (groupId)
	{
		case WidgetID.BANK_GROUP_ID:
			// Don't show for view tabs and such
			if (WidgetInfo.TO_CHILD(widgetId) != WidgetInfo.BANK_ITEM_CONTAINER.getChildId())
			{
				break;
			}
		case WidgetID.INVENTORY_GROUP_ID:
		case WidgetID.BANK_INVENTORY_GROUP_ID:
		case WidgetID.GRAND_EXCHANGE_INVENTORY_GROUP_ID:
		case WidgetID.SHOP_INVENTORY_GROUP_ID:
			menuEntry.setOption(SEARCH_GRAND_EXCHANGE);
			menuEntry.setOpcode(MenuOpcode.RUNELITE.getId());
			menuEntry.setModified();
	}
}
 
Example #28
Source File: DiscordPlugin.java    From plugins with GNU General Public License v3.0 5 votes vote down vote up
@Subscribe
private void onDiscordJoinRequest(DiscordJoinRequest request)
{
	log.debug("Got discord join request {}", request);
	if (partyService.isOwner() && partyService.getMembers().isEmpty())
	{
		// First join, join also yourself
		partyService.changeParty(partyService.getLocalPartyId());
		updatePresence();
	}
}
 
Example #29
Source File: QuestListPlugin.java    From plugins with GNU General Public License v3.0 5 votes vote down vote up
@Subscribe
private void onScriptPostFired(ScriptPostFired event)
{
	if (event.getScriptId() != ScriptID.QUESTLIST_PROGRESS_LIST_SHOW)
	{
		return;
	}

	addQuestButtons();
}
 
Example #30
Source File: ImplingsPlugin.java    From plugins with GNU General Public License v3.0 5 votes vote down vote up
@Subscribe
private void onGameStateChanged(GameStateChanged event)
{
	if (event.getGameState() == GameState.LOGIN_SCREEN || event.getGameState() == GameState.HOPPING)
	{
		implings.clear();
		implingCounterMap.clear();
	}
}