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

The following examples show how to use net.runelite.api.GameState#LOGIN_SCREEN . 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: IdleNotifierPlugin.java    From plugins with GNU General Public License v3.0 6 votes vote down vote up
private void resetTimers()
{
	final Player local = client.getLocalPlayer();

	// Reset animation idle timer
	lastAnimating = null;
	if (client.getGameState() == GameState.LOGIN_SCREEN || local == null || local.getAnimation() != lastAnimation)
	{
		lastAnimation = IDLE;
	}

	// Reset interaction idle timer
	lastInteracting = null;
	if (client.getGameState() == GameState.LOGIN_SCREEN || local == null || local.getInteracting() != lastInteract)
	{
		lastInteract = null;
	}
}
 
Example 2
Source File: LoginScreenPlugin.java    From plugins with GNU General Public License v3.0 6 votes vote down vote up
private void applyUsername()
{
	if (!config.syncUsername())
	{
		return;
	}

	GameState gameState = client.getGameState();
	if (gameState == GameState.LOGIN_SCREEN)
	{
		String username = config.username();

		if (Strings.isNullOrEmpty(username))
		{
			return;
		}

		// Save it only once
		if (usernameCache == null)
		{
			usernameCache = client.getPreferences().getRememberedUsername();
		}

		client.getPreferences().setRememberedUsername(username);
	}
}
 
Example 3
Source File: MotherlodePlugin.java    From plugins with GNU General Public License v3.0 6 votes vote down vote up
@Subscribe
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 4
Source File: RaidsPlugin.java    From runelite with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Subscribe
public void onGameStateChanged(GameStateChanged event)
{
	if (client.getGameState() == GameState.LOGGED_IN)
	{
		// skip event while the game decides if the player belongs in a raid or not
		if (client.getLocalPlayer() == null
			|| client.getLocalPlayer().getWorldLocation().equals(TEMP_LOCATION))
		{
			return;
		}

		checkInRaid = true;
	}
	else if (client.getGameState() == GameState.LOGIN_SCREEN
		|| client.getGameState() == GameState.CONNECTION_LOST)
	{
		loggedIn = false;
	}
	else if (client.getGameState() == GameState.HOPPING)
	{
		reset();
	}
}
 
Example 5
Source File: ClueScrollPlugin.java    From runelite with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Subscribe
public void onGameStateChanged(final GameStateChanged event)
{
	final GameState state = event.getGameState();

	if (state != GameState.LOGGED_IN)
	{
		namedObjectsToMark.clear();
	}

	if (state == GameState.LOGIN_SCREEN)
	{
		resetClue(true);
	}
}
 
Example 6
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();
	}
}
 
Example 7
Source File: NpcStatusPlugin.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)
	{
		memorizedNPCs.clear();
	}
}
 
Example 8
Source File: ClientUI.java    From runelite with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private boolean showWarningOnExit()
{
	if (config.warningOnExit() == WarningOnExit.ALWAYS)
	{
		return true;
	}

	if (config.warningOnExit() == WarningOnExit.LOGGED_IN && client instanceof Client)
	{
		return ((Client) client).getGameState() != GameState.LOGIN_SCREEN;
	}

	return false;
}
 
Example 9
Source File: MusicPlugin.java    From runelite with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Subscribe
public void onGameStateChanged(GameStateChanged gameStateChanged)
{
	if (gameStateChanged.getGameState() == GameState.LOGIN_SCREEN)
	{
		// Reset music filter on logout
		currentMusicFilter = MusicState.ALL;
		tracks = null;
	}
}
 
Example 10
Source File: StatusOrbsPlugin.java    From plugins with GNU General Public License v3.0 5 votes vote down vote up
@Subscribe
private void onGameStateChanged(GameStateChanged ev)
{
	if (ev.getGameState() == GameState.HOPPING || ev.getGameState() == GameState.LOGIN_SCREEN)
	{
		ticksSinceHPRegen = -2; // For some reason this makes this accurate
		ticksSinceSpecRegen = 0;
		ticksSinceRunRegen = -1;
	}
}
 
Example 11
Source File: FishingPlugin.java    From plugins with GNU General Public License v3.0 5 votes vote down vote up
@Subscribe
private void onGameStateChanged(GameStateChanged gameStateChanged)
{
	GameState gameState = gameStateChanged.getGameState();
	if (gameState == GameState.CONNECTION_LOST || gameState == GameState.LOGIN_SCREEN || gameState == GameState.HOPPING)
	{
		fishingSpots.clear();
		minnowSpots.clear();
	}
}
 
Example 12
Source File: PestControlPlugin.java    From runelite with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Subscribe
public void onGameStateChanged(GameStateChanged event)
{
	GameState gameState = event.getGameState();
	if (gameState == GameState.CONNECTION_LOST || gameState == GameState.LOGIN_SCREEN || gameState == GameState.HOPPING)
	{
		spinners.clear();
	}
}
 
Example 13
Source File: GrandExchangePlugin.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.LOGIN_SCREEN)
	{
		panel.getOffersPanel().resetOffers();
		loginBurstGeUpdates = true;
	}
}
 
Example 14
Source File: LoginScreenPlugin.java    From plugins with GNU General Public License v3.0 5 votes vote down vote up
@Subscribe
private void onGameStateChanged(GameStateChanged event)
{
	if (!config.syncUsername())
	{
		return;
	}

	if (event.getGameState() == GameState.LOGIN_SCREEN)
	{
		applyUsername();
	}
	else if (event.getGameState() == GameState.LOGGED_IN)
	{
		String username = "";

		if (client.getPreferences().getRememberedUsername() != null)
		{
			username = client.getUsername();
		}

		if (config.username().equals(username))
		{
			return;
		}

		log.debug("Saving username: {}", username);
		config.username(username);
	}
}
 
Example 15
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 16
Source File: ItemManager.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.HOPPING || event.getGameState() == GameState.LOGIN_SCREEN)
	{
		itemCompositions.invalidateAll();
	}
}
 
Example 17
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 18
Source File: DefaultWorldPlugin.java    From plugins with GNU General Public License v3.0 4 votes vote down vote up
private void changeWorld(int newWorld)
{
	if (!worldChangeRequired || client.getGameState() != GameState.LOGIN_SCREEN)
	{
		return;
	}

	worldChangeRequired = false;
	int correctedWorld = newWorld < 300 ? newWorld + 300 : newWorld;

	// Old School RuneScape worlds start on 301 so don't even bother trying to find lower id ones
	// and also do not try to set world if we are already on it
	if (correctedWorld <= 300 || client.getWorld() == correctedWorld)
	{
		return;
	}

	final WorldResult worldResult = worldService.getWorlds();

	if (worldResult == null)
	{
		log.warn("Failed to lookup worlds.");
		return;
	}

	final World world = worldResult.findWorld(correctedWorld);

	if (world != null)
	{
		final net.runelite.api.World rsWorld = client.createWorld();
		rsWorld.setActivity(world.getActivity());
		rsWorld.setAddress(world.getAddress());
		rsWorld.setId(world.getId());
		rsWorld.setPlayerCount(world.getPlayers());
		rsWorld.setLocation(world.getLocation());
		rsWorld.setTypes(WorldUtil.toWorldTypes(world.getTypes()));

		client.changeWorld(rsWorld);
		log.debug("Applied new world {}", correctedWorld);
	}
	else
	{
		log.warn("World {} not found.", correctedWorld);
	}
}
 
Example 19
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 20
Source File: WorldHopperPlugin.java    From plugins with GNU General Public License v3.0 4 votes vote down vote up
private void hop(int worldId)
{
	WorldResult worldResult = worldService.getWorlds();
	// Don't try to hop if the world doesn't exist
	@SuppressWarnings("ConstantConditions")
	World world = worldResult.findWorld(worldId);
	if (world == null)
	{
		return;
	}

	final net.runelite.api.World rsWorld = client.createWorld();
	rsWorld.setActivity(world.getActivity());
	rsWorld.setAddress(world.getAddress());
	rsWorld.setId(world.getId());
	rsWorld.setPlayerCount(world.getPlayers());
	rsWorld.setLocation(world.getLocation());
	rsWorld.setTypes(WorldUtil.toWorldTypes(world.getTypes()));

	if (client.getGameState() == GameState.LOGIN_SCREEN)
	{
		// on the login screen we can just change the world by ourselves
		client.changeWorld(rsWorld);
		return;
	}

	if (config.showWorldHopMessage())
	{
		String chatMessage = new ChatMessageBuilder()
			.append(ChatColorType.NORMAL)
			.append("Quick-hopping to World ")
			.append(ChatColorType.HIGHLIGHT)
			.append(Integer.toString(world.getId()))
			.append(ChatColorType.NORMAL)
			.append("..")
			.build();

		chatMessageManager
			.queue(QueuedMessage.builder()
				.type(ChatMessageType.CONSOLE)
				.runeLiteFormattedMessage(chatMessage)
				.build());
	}

	quickHopTargetWorld = rsWorld;
	displaySwitcherAttempts = 0;
}