Java Code Examples for net.runelite.api.GameState#LOADING

The following examples show how to use net.runelite.api.GameState#LOADING . 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: 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 2
Source File: MotherlodePlugin.java    From runelite with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Subscribe
public void onGameStateChanged(GameStateChanged event)
{
	if (event.getGameState() == GameState.LOADING)
	{
		// on region changes the tiles get set to null
		veins.clear();
		rocks.clear();

		inMlm = checkInMlm();
	}
	else if (event.getGameState() == GameState.LOGIN_SCREEN)
	{
		// Prevent code from running while logged out.
		inMlm = false;
	}
}
 
Example 3
Source File: ObjectIndicatorsPlugin.java    From runelite with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Subscribe
public 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 4
Source File: MotherlodePlugin.java    From plugins with GNU General Public License v3.0 6 votes vote down vote up
private boolean checkInMlm()
{
	GameState gameState = client.getGameState();
	if (gameState != GameState.LOGGED_IN
		&& gameState != GameState.LOADING)
	{
		return false;
	}

	int[] currentMapRegions = client.getMapRegions();

	// Verify that all regions exist in MOTHERLODE_MAP_REGIONS
	for (int region : currentMapRegions)
	{
		if (!MOTHERLODE_MAP_REGIONS.contains(region))
		{
			return false;
		}
	}

	return true;
}
 
Example 5
Source File: TelekineticRoom.java    From runelite with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Subscribe
public void onGameStateChanged(GameStateChanged event)
{
	if (event.getGameState() == GameState.LOADING)
	{
		// Game objects are nulled when loading new scenes, thus never trigger their respective
		// ObjectDespawned events.
		resetRoom();
	}
}
 
Example 6
Source File: PohPlugin.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.LOADING)
	{
		pohObjects.clear();
		incenseBurners.clear();
	}
}
 
Example 7
Source File: PohPlugin.java    From runelite with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Subscribe
public void onGameStateChanged(GameStateChanged event)
{
	if (event.getGameState() == GameState.LOADING)
	{
		pohObjects.clear();
		incenseBurners.clear();
	}
}
 
Example 8
Source File: PyramidPlunderPlugin.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.LOADING)
	{
		tilesToHighlight.clear();
		objectsToHighlight.clear();
	}
}
 
Example 9
Source File: RoguesDenPlugin.java    From runelite with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Subscribe
public void onGameStateChanged(GameStateChanged event)
{
	if (event.getGameState() == GameState.LOADING)
	{
		obstaclesHull.clear();
		obstaclesTile.clear();
	}
}
 
Example 10
Source File: ChatTranslationPlugin.java    From plugins with GNU General Public License v3.0 5 votes vote down vote up
@Subscribe
private void onChatMessage(ChatMessage chatMessage)
{
	if (client.getGameState() != GameState.LOADING && client.getGameState() != GameState.LOGGED_IN)
	{
		return;
	}
	switch (chatMessage.getType())
	{
		case PUBLICCHAT:
		case MODCHAT:
		case FRIENDSCHAT:
			break;
		default:
			return;
	}

	if (!playerNames.contains(Text.toJagexName(Text.removeTags(chatMessage.getName().toLowerCase()))))
	{
		return;
	}

	final String message = chatMessage.getMessage();

	try
	{
		final String translation = translator.translateIncoming(message);
		final MessageNode messageNode = chatMessage.getMessageNode();
		messageNode.setRuneLiteFormatMessage(translation);
		chatMessageManager.update(messageNode);
	}
	catch (IOException ignored)
	{
	}

	client.refreshChat();
}
 
Example 11
Source File: GroundItemsPlugin.java    From runelite with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Subscribe
public void onGameStateChanged(final GameStateChanged event)
{
	if (event.getGameState() == GameState.LOADING)
	{
		collectedGroundItems.clear();
	}
}
 
Example 12
Source File: BlastMinePlugin.java    From runelite with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Subscribe
public void onGameStateChanged(GameStateChanged event)
{
	if (event.getGameState() == GameState.LOADING)
	{
		rocks.clear();
	}
}
 
Example 13
Source File: RoguesDenPlugin.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.LOADING)
	{
		obstaclesHull.clear();
		obstaclesTile.clear();
	}
}
 
Example 14
Source File: BlastFurnacePlugin.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.LOADING)
	{
		conveyorBelt = null;
		barDispenser = null;
	}
}
 
Example 15
Source File: CorpPlugin.java    From plugins with GNU General Public License v3.0 5 votes vote down vote up
@Subscribe
private void onGameStateChanged(GameStateChanged gameStateChanged)
{
	if (gameStateChanged.getGameState() == GameState.LOADING)
	{
		players.clear();
	}
}
 
Example 16
Source File: EnchantmentRoom.java    From plugins with GNU General Public License v3.0 5 votes vote down vote up
private void onGameStateChanged(GameStateChanged gameStateChanged)
{
	if (gameStateChanged.getGameState() == GameState.LOADING)
	{
		dragonstones.clear();
	}
}
 
Example 17
Source File: ChatTranslationPlugin.java    From plugins with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void keyPressed(KeyEvent event)
{
	if (client.getGameState() != GameState.LOADING && client.getGameState() != GameState.LOGGED_IN)
	{
		return;
	}

	final Widget chatboxParent = client.getWidget(WidgetInfo.CHATBOX_PARENT);

	if (chatboxParent == null || chatboxParent.getOnKeyListener() == null || event.getKeyCode() != 0xA)
	{
		return;
	}

	final String message = client.getVar(VarClientStr.CHATBOX_TYPED_TEXT);
	final String translated;

	try
	{
		translated = translator.translateOutgoing(message);
	}
	catch (IOException e)
	{
		return;
	}

	if (message.startsWith("/"))
	{
		client.setVar(VarClientStr.CHATBOX_TYPED_TEXT, translated.startsWith("/") ? translated : "/" + translated);
		return;
	}

	event.consume();

	client.setVar(VarClientStr.CHATBOX_TYPED_TEXT, translated);

	clientThread.invoke(() -> client.runScript(CHATBOX_INPUT, 0, translated));

	client.setVar(VarClientStr.CHATBOX_TYPED_TEXT, "");
}
 
Example 18
Source File: LootTrackerPlugin.java    From plugins with GNU General Public License v3.0 4 votes vote down vote up
@Subscribe
private void onGameStateChanged(final GameStateChanged event)
{
	if (client.getLocalPlayer() == null)
	{
		return;
	}

	if (event.getGameState() == GameState.LOADING && !client.isInInstancedRegion())
	{
		chestLooted = false;
	}

	if (event.getGameState() == GameState.LOGGING_IN)
	{
		clientThread.invokeLater(() ->
		{
			switch (client.getGameState())
			{
				case LOGGED_IN:
					break;
				case LOGGING_IN:
				case LOADING:
					return false;
				default:
					// Quit running if any other state
					return true;
			}

			String name = client.getLocalPlayer().getName();
			if (name != null)
			{
				userUuid(name);

				return true;
			}
			else
			{
				return false;
			}
		});
	}
}
 
Example 19
Source File: FriendsChatPlugin.java    From plugins with GNU General Public License v3.0 4 votes vote down vote up
@Subscribe
private void onChatMessage(ChatMessage chatMessage)
{
	if (client.getGameState() != GameState.LOADING && client.getGameState() != GameState.LOGGED_IN)
	{
		return;
	}

	FriendsChatManager friendsChatManager = client.getFriendsChatManager();
	if (friendsChatManager == null || friendsChatManager.getCount() == 0)
	{
		return;
	}

	switch (chatMessage.getType())
	{
		case PRIVATECHAT:
		case MODPRIVATECHAT:
			if (!config.privateMessageIcons())
			{
				return;
			}
			break;
		case PUBLICCHAT:
		case MODCHAT:
			if (!config.publicChatIcons())
			{
				return;
			}
			break;
		case FRIENDSCHAT:
			if (!config.chatIcons())
			{
				return;
			}
			break;
		default:
			return;
	}

	insertRankIcon(chatMessage);
}
 
Example 20
Source File: NpcIndicatorsPlugin.java    From runelite with BSD 2-Clause "Simplified" License 4 votes vote down vote up
private void rebuildAllNpcs()
{
	highlightedNpcs.clear();

	if (client.getGameState() != GameState.LOGGED_IN &&
		client.getGameState() != GameState.LOADING)
	{
		// NPCs are still in the client after logging out,
		// but we don't want to highlight those.
		return;
	}

	outer:
	for (NPC npc : client.getNpcs())
	{
		final String npcName = npc.getName();

		if (npcName == null)
		{
			continue;
		}

		if (npcTags.contains(npc.getIndex()))
		{
			highlightedNpcs.add(npc);
			continue;
		}

		for (String highlight : highlights)
		{
			if (WildcardMatcher.matches(highlight, npcName))
			{
				if (!client.isInInstancedRegion())
				{
					memorizeNpc(npc);
				}
				highlightedNpcs.add(npc);
				continue outer;
			}
		}

		// NPC is not highlighted
		memorizedNpcs.remove(npc.getIndex());
	}
}