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

The following examples show how to use net.runelite.api.GameState#LOGGING_IN . 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: DailyTasksPlugin.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.LOGGING_IN)
	{
		loggingIn = true;
	}
}
 
Example 2
Source File: QuestListPlugin.java    From plugins with GNU General Public License v3.0 5 votes vote down vote up
@Subscribe
private void onGameStateChanged(GameStateChanged e)
{
	if (e.getGameState() == GameState.LOGGING_IN)
	{
		currentFilterState = QuestState.ALL;
	}
}
 
Example 3
Source File: AntiDragPlugin.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)
	{
		keyManager.unregisterKeyListener(toggleListener);
		keyManager.unregisterKeyListener(holdListener);
	}
	else if (event.getGameState() == GameState.LOGGING_IN)
	{
		updateKeyListeners();
	}
}
 
Example 4
Source File: DailyTasksPlugin.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.LOGGING_IN)
	{
		loggingIn = true;
	}
}
 
Example 5
Source File: QuestListPlugin.java    From runelite with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Subscribe
public void onGameStateChanged(GameStateChanged e)
{
	if (e.getGameState() == GameState.LOGGING_IN)
	{
		currentFilterState = QuestState.ALL;
	}
}
 
Example 6
Source File: XpTrackerPlugin.java    From plugins with GNU General Public License v3.0 4 votes vote down vote up
@Subscribe
void onGameStateChanged(GameStateChanged event)
{
	GameState state = event.getGameState();
	if (state == GameState.LOGGED_IN)
	{
		// LOGGED_IN is triggered between region changes too.
		// Check that the username changed or the world type changed.
		XpWorldType type = worldSetToType(client.getWorldType());

		if (!Objects.equals(client.getUsername(), lastUsername) || lastWorldType != type)
		{
			// Reset
			log.debug("World change: {} -> {}, {} -> {}",
				lastUsername, client.getUsername(),
				Objects.requireNonNullElse(lastWorldType, "<unknown>"),
				Objects.requireNonNullElse(type, "<unknown>"));

			lastUsername = client.getUsername();
			// xp is not available until after login is finished, so fetch it on the next gametick
			fetchXp = true;
			lastWorldType = type;
			resetState();
			// Must be set from hitting the LOGGING_IN or HOPPING case below
			assert initializeTracker;
		}
	}
	else if (state == GameState.LOGGING_IN || state == GameState.HOPPING)
	{
		initializeTracker = true;
	}
	else if (state == GameState.LOGIN_SCREEN)
	{
		Player local = client.getLocalPlayer();
		if (local == null)
		{
			return;
		}

		String username = local.getName();
		if (username == null)
		{
			return;
		}

		long totalXp = client.getOverallExperience();
		// Don't submit xptrack unless xp threshold is reached
		if (Math.abs(totalXp - lastXp) > XP_THRESHOLD)
		{
			xpClient.update(username);
			lastXp = totalXp;
		}
	}
}
 
Example 7
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 8
Source File: XpTrackerPlugin.java    From runelite with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Subscribe
public void onGameStateChanged(GameStateChanged event)
{
	GameState state = event.getGameState();
	if (state == GameState.LOGGED_IN)
	{
		// LOGGED_IN is triggered between region changes too.
		// Check that the username changed or the world type changed.
		XpWorldType type = worldSetToType(client.getWorldType());

		if (!Objects.equals(client.getUsername(), lastUsername) || lastWorldType != type)
		{
			// Reset
			log.debug("World change: {} -> {}, {} -> {}",
				lastUsername, client.getUsername(),
				firstNonNull(lastWorldType, "<unknown>"),
				firstNonNull(type, "<unknown>"));

			lastUsername = client.getUsername();
			// xp is not available until after login is finished, so fetch it on the next gametick
			fetchXp = true;
			lastWorldType = type;
			resetState();
			// Must be set from hitting the LOGGING_IN or HOPPING case below
			assert initializeTracker;
		}
	}
	else if (state == GameState.LOGGING_IN || state == GameState.HOPPING)
	{
		initializeTracker = true;
	}
	else if (state == GameState.LOGIN_SCREEN)
	{
		Player local = client.getLocalPlayer();
		if (local == null)
		{
			return;
		}

		String username = local.getName();
		if (username == null)
		{
			return;
		}

		long totalXp = client.getOverallExperience();
		// Don't submit xptrack unless xp threshold is reached
		if (Math.abs(totalXp - lastXp) > XP_THRESHOLD)
		{
			xpClient.update(username);
			lastXp = totalXp;
		}
	}
}