net.runelite.api.Player Java Examples
The following examples show how to use
net.runelite.api.Player.
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: WoodcuttingPlugin.java From plugins with GNU General Public License v3.0 | 6 votes |
@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 #2
Source File: SpecialCounterPluginTest.java From plugins with GNU General Public License v3.0 | 6 votes |
@Test public void testSpecBlock() { NPC target = mock(NPC.class); Player player = mock(Player.class); when(client.getLocalPlayer()).thenReturn(player); // spec npc when(client.getVar(VarPlayer.SPECIAL_ATTACK_PERCENT)).thenReturn(50); specialCounterPlugin.onVarbitChanged(new VarbitChanged()); lenient().when(player.getInteracting()).thenReturn(target); specialCounterPlugin.onInteractingChanged(new InteractingChanged(player, target)); // block 0 specialCounterPlugin.onHitsplatApplied(hitsplat(target, Hitsplat.HitsplatType.BLOCK_ME)); // hit 1 specialCounterPlugin.onHitsplatApplied(hitsplat(target, Hitsplat.HitsplatType.DAMAGE_ME)); verify(infoBoxManager, never()).addInfoBox(any(SpecialCounter.class)); }
Example #3
Source File: SpecialCounterPluginTest.java From plugins with GNU General Public License v3.0 | 6 votes |
@Test public void testSpecDamage() { NPC target = mock(NPC.class); Player player = mock(Player.class); when(client.getLocalPlayer()).thenReturn(player); // spec npc when(client.getVar(VarPlayer.SPECIAL_ATTACK_PERCENT)).thenReturn(50); specialCounterPlugin.onVarbitChanged(new VarbitChanged()); lenient().when(player.getInteracting()).thenReturn(target); specialCounterPlugin.onInteractingChanged(new InteractingChanged(player, target)); // hit 1 specialCounterPlugin.onHitsplatApplied(hitsplat(target, Hitsplat.HitsplatType.DAMAGE_ME)); verify(infoBoxManager).addInfoBox(any(SpecialCounter.class)); }
Example #4
Source File: CannonPlugin.java From runelite with BSD 2-Clause "Simplified" License | 6 votes |
@Subscribe public void onGameObjectSpawned(GameObjectSpawned event) { GameObject gameObject = event.getGameObject(); Player localPlayer = client.getLocalPlayer(); if (gameObject.getId() == CANNON_BASE && !cannonPlaced) { if (localPlayer.getWorldLocation().distanceTo(gameObject.getWorldLocation()) <= 2 && localPlayer.getAnimation() == AnimationID.BURYING_BONES) { cannonPosition = gameObject.getWorldLocation(); cannon = gameObject; } } }
Example #5
Source File: SpecialCounterPluginTest.java From plugins with GNU General Public License v3.0 | 6 votes |
@Test public void testUnaggro() { NPC target = mock(NPC.class); Player player = mock(Player.class); when(client.getLocalPlayer()).thenReturn(player); // tick 1: attack npc when(player.getInteracting()).thenReturn(target); specialCounterPlugin.onInteractingChanged(new InteractingChanged(player, target)); // tick 2: spec fires and un-interact npc when(client.getVar(VarPlayer.SPECIAL_ATTACK_PERCENT)).thenReturn(50); specialCounterPlugin.onVarbitChanged(new VarbitChanged()); lenient().when(player.getInteracting()).thenReturn(null); specialCounterPlugin.onInteractingChanged(new InteractingChanged(player, null)); // tick 3: hit 1 specialCounterPlugin.onHitsplatApplied(hitsplat(target, Hitsplat.HitsplatType.DAMAGE_ME)); verify(infoBoxManager).addInfoBox(any(SpecialCounter.class)); }
Example #6
Source File: WoodcuttingPlugin.java From runelite with BSD 2-Clause "Simplified" License | 6 votes |
@Subscribe public 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 #7
Source File: ScreenshotPlugin.java From plugins with GNU General Public License v3.0 | 6 votes |
@Subscribe private void onPlayerDeath(PlayerDeath event) { Player player = event.getPlayer(); if (player == client.getLocalPlayer() && config.screenshotPlayerDeath()) { takeScreenshot("Death", "Deaths"); } if (config.screenshotKills() && (config.pvpKillScreenshotMode() == PvPKillScreenshotMode.ON_KILL || config.pvpKillScreenshotMode() == PvPKillScreenshotMode.BOTH)) { if (client.getLocalPlayer().getInteracting() != null && client.getLocalPlayer().getInteracting() == player) { takeScreenshot("KO " + player.getName(), "PvP Kills"); } } int tob = client.getVar(Varbits.THEATRE_OF_BLOOD); if (config.screenshotFriendDeath() && player != client.getLocalPlayer() && player.getName() != null && (player.isFriend() || player.isFriendsChatMember() || (client.getVar(Varbits.IN_RAID) == 1 || tob == 2 || tob == 3))) { takeScreenshot("Death " + player.getName(), "Deaths"); } }
Example #8
Source File: DevToolsOverlay.java From plugins with GNU General Public License v3.0 | 6 votes |
private void renderDecorObject(Graphics2D graphics, Tile tile, Player player) { DecorativeObject decorObject = tile.getDecorativeObject(); if (decorObject != null) { if (player.getLocalLocation().distanceTo(decorObject.getLocalLocation()) <= MAX_DISTANCE) { OverlayUtil.renderTileOverlay(graphics, decorObject, "ID: " + decorObject.getId(), DEEP_PURPLE); } Shape p = decorObject.getConvexHull(); if (p != null) { graphics.draw(p); } p = decorObject.getConvexHull2(); if (p != null) { graphics.draw(p); } } }
Example #9
Source File: SpecialCounterPluginTest.java From plugins with GNU General Public License v3.0 | 6 votes |
@Test public void testSameTick() { NPC targetA = mock(NPC.class); NPC targetB = mock(NPC.class); Player player = mock(Player.class); when(client.getLocalPlayer()).thenReturn(player); // tick 1: attack npc A when(player.getInteracting()).thenReturn(targetA); specialCounterPlugin.onInteractingChanged(new InteractingChanged(player, targetA)); // tick 2: spec npc B when(client.getVar(VarPlayer.SPECIAL_ATTACK_PERCENT)).thenReturn(50); specialCounterPlugin.onVarbitChanged(new VarbitChanged()); lenient().when(player.getInteracting()).thenReturn(targetB); specialCounterPlugin.onInteractingChanged(new InteractingChanged(player, targetB)); // tick 3: hitsplat A, hitsplat B specialCounterPlugin.onHitsplatApplied(hitsplat(targetA, Hitsplat.HitsplatType.DAMAGE_ME)); verify(infoBoxManager, never()).addInfoBox(any(SpecialCounter.class)); specialCounterPlugin.onHitsplatApplied(hitsplat(targetB, Hitsplat.HitsplatType.DAMAGE_ME)); verify(infoBoxManager).addInfoBox(any(SpecialCounter.class)); }
Example #10
Source File: Anonymizer.java From ExternalPlugins with GNU General Public License v3.0 | 6 votes |
@Subscribe public void onGameTick(GameTick event) { Player p = client.getLocalPlayer(); if (p == null) { return; } name = p.getName(); if (config.hideXp()) { Widget xp = client.getWidget(122, 9); if (xp != null && xp.getText() != null && !xp.isHidden()) { xp.setText("123,456,789"); xp.revalidate(); } } }
Example #11
Source File: ChatNotificationsPluginTest.java From plugins with GNU General Public License v3.0 | 6 votes |
@Test public void testHighlightOwnName() { Player player = mock(Player.class); when(player.getName()).thenReturn("Logic Knot"); when(client.getLocalPlayer()).thenReturn(player); when(config.highlightOwnName()).thenReturn(true); MessageNode messageNode = mock(MessageNode.class); when(messageNode.getValue()).thenReturn("<col=005f00>Logic Knot received a drop: Adamant longsword</col>"); ChatMessage chatMessage = new ChatMessage(messageNode, ChatMessageType.GAMEMESSAGE, "", "", "", 0); chatNotificationsPlugin.onChatMessage(chatMessage); verify(messageNode).setValue("<col=005f00><colHIGHLIGHT><u>Logic Knot</u><colNORMAL> received a drop: Adamant longsword</col>"); }
Example #12
Source File: DevToolsOverlay.java From runelite with BSD 2-Clause "Simplified" License | 6 votes |
private void renderPlayerWireframe(Graphics2D graphics, Player player, Color color) { Polygon[] polys = player.getPolygons(); if (polys == null) { return; } graphics.setColor(color); for (Polygon p : polys) { graphics.drawPolygon(p); } }
Example #13
Source File: EmojiPlugin.java From plugins with GNU General Public License v3.0 | 6 votes |
@Subscribe private void onOverheadTextChanged(final OverheadTextChanged event) { if (!(event.getActor() instanceof Player)) { return; } final String message = event.getOverheadText(); final String updatedMessage = updateMessage(message); if (updatedMessage == null) { return; } event.getActor().setOverheadText(updatedMessage); }
Example #14
Source File: SpecialCounterPluginTest.java From runelite with BSD 2-Clause "Simplified" License | 6 votes |
@Test public void testSpecDamage() { NPC target = mock(NPC.class); Player player = mock(Player.class); when(client.getLocalPlayer()).thenReturn(player); // spec npc when(client.getVar(VarPlayer.SPECIAL_ATTACK_PERCENT)).thenReturn(50); specialCounterPlugin.onVarbitChanged(new VarbitChanged()); lenient().when(player.getInteracting()).thenReturn(target); specialCounterPlugin.onInteractingChanged(new InteractingChanged(player, target)); // hit 1 specialCounterPlugin.onHitsplatApplied(hitsplat(target, Hitsplat.HitsplatType.DAMAGE_ME)); verify(infoBoxManager).addInfoBox(any(SpecialCounter.class)); }
Example #15
Source File: IdleNotifierPlugin.java From plugins with GNU General Public License v3.0 | 6 votes |
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 #16
Source File: SlayerPluginTest.java From runelite with BSD 2-Clause "Simplified" License | 6 votes |
@Test public void testCombatBraceletUpdate() { final Player player = mock(Player.class); when(player.getLocalLocation()).thenReturn(new LocalPoint(0, 0)); when(client.getLocalPlayer()).thenReturn(player); slayerPlugin.setTaskName("Suqahs"); slayerPlugin.setAmount(231); ChatMessage chatMessage = new ChatMessage(null, GAMEMESSAGE, "", TASK_UPDATE_COMBAT_BRACELET, null, 0); slayerPlugin.onChatMessage(chatMessage); assertEquals("Suqahs", slayerPlugin.getTaskName()); slayerPlugin.killedOne(); assertEquals(30, slayerPlugin.getAmount()); }
Example #17
Source File: DevToolsOverlay.java From runelite with BSD 2-Clause "Simplified" License | 6 votes |
private void renderDecorObject(Graphics2D graphics, Tile tile, Player player) { DecorativeObject decorObject = tile.getDecorativeObject(); if (decorObject != null) { if (player.getLocalLocation().distanceTo(decorObject.getLocalLocation()) <= MAX_DISTANCE) { OverlayUtil.renderTileOverlay(graphics, decorObject, "ID: " + decorObject.getId(), DEEP_PURPLE); } Shape p = decorObject.getConvexHull(); if (p != null) { graphics.draw(p); } p = decorObject.getConvexHull2(); if (p != null) { graphics.draw(p); } } }
Example #18
Source File: ChatFilterPlugin.java From plugins with GNU General Public License v3.0 | 6 votes |
@Subscribe private void onOverheadTextChanged(OverheadTextChanged event) { if (!(event.getActor() instanceof Player) || event.getActor().getName() == null || !shouldFilterPlayerMessage(event.getActor().getName())) { return; } String message = censorMessage(event.getActor().getName(), event.getOverheadText()); if (message == null) { message = " "; } event.getActor().setOverheadText(message); }
Example #19
Source File: EmojiPlugin.java From runelite with BSD 2-Clause "Simplified" License | 6 votes |
@Subscribe public void onOverheadTextChanged(final OverheadTextChanged event) { if (!(event.getActor() instanceof Player)) { return; } final String message = event.getOverheadText(); final String updatedMessage = updateMessage(message); if (updatedMessage == null) { return; } event.getActor().setOverheadText(updatedMessage); }
Example #20
Source File: StealingArtefactsPlugin.java From plugins with GNU General Public License v3.0 | 6 votes |
private boolean isPlayerInRegion(int regionId) { Player player = client.getLocalPlayer(); if (player == null) { return false; } WorldPoint worldPoint = player.getWorldLocation(); if (worldPoint == null) { return false; } return worldPoint.getRegionID() == regionId; }
Example #21
Source File: NpcAggroAreaPlugin.java From plugins with GNU General Public License v3.0 | 5 votes |
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 #22
Source File: PlayerComparisonOverlay.java From plugins with GNU General Public License v3.0 | 5 votes |
@Override public Dimension render(Graphics2D graphics) { if (!opponentInfoConfig.lookupOnInteraction()) { return null; } final Actor opponent = opponentInfoPlugin.getLastOpponent(); if (opponent == null) { return null; } // Don't try to look up NPC names if (!(opponent instanceof Player)) { return null; } final String opponentName = Text.removeTags(opponent.getName()); final HiscoreResult hiscoreResult = hiscoreManager.lookupAsync(opponentName, opponentInfoPlugin.getHiscoreEndpoint()); if (hiscoreResult == null) { return null; } panelComponent.getChildren().clear(); generateComparisonTable(panelComponent, hiscoreResult); return panelComponent.render(graphics); }
Example #23
Source File: AgilityPlugin.java From plugins with GNU General Public License v3.0 | 5 votes |
private boolean isInAgilityArena() { Player local = client.getLocalPlayer(); if (local == null) { return false; } WorldPoint location = local.getWorldLocation(); return location.getRegionID() == AGILITY_ARENA_REGION_ID; }
Example #24
Source File: TeamCapesPlugin.java From plugins with GNU General Public License v3.0 | 5 votes |
@Schedule( period = 1800, unit = ChronoUnit.MILLIS ) public void update() { if (client.getGameState() != GameState.LOGGED_IN) { return; } List<Player> players = client.getPlayers(); teams.clear(); for (Player player : players) { int team = player.getTeam(); if (team > 0) { if (teams.containsKey(team)) { teams.put(team, teams.get(team) + 1); } else { teams.put(team, 1); } } } // Sort teams by value in descending order and then by key in ascending order, limited to 5 entries teams = teams.entrySet().stream() .sorted( Comparator.comparing(Map.Entry<Integer, Integer>::getValue, Comparator.reverseOrder()) .thenComparingInt(Map.Entry::getKey) ) .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (e1, e2) -> e1, LinkedHashMap::new)); }
Example #25
Source File: PlayerIndicatorsPlugin.java From runelite with BSD 2-Clause "Simplified" License | 5 votes |
private Decorations getDecorations(Player player) { int image = -1; Color color = null; if (config.highlightFriends() && player.isFriend()) { color = config.getFriendColor(); } else if (config.drawFriendsChatMemberNames() && player.isFriendsChatMember()) { color = config.getFriendsChatMemberColor(); FriendsChatRank rank = friendChatManager.getRank(player.getName()); if (rank != UNRANKED) { image = friendChatManager.getIconNumber(rank); } } else if (config.highlightTeamMembers() && player.getTeam() > 0 && client.getLocalPlayer().getTeam() == player.getTeam()) { color = config.getTeamMemberColor(); } else if (config.highlightOthers() && !player.isFriendsChatMember()) { color = config.getOthersColor(); } if (image == -1 && color == null) { return null; } return new Decorations(image, color); }
Example #26
Source File: MotherlodeRocksOverlay.java From plugins with GNU General Public License v3.0 | 5 votes |
@Override public Dimension render(Graphics2D graphics) { if ((!config.showVeins() && !config.showRockFalls()) || !plugin.isInMlm()) { return null; } Player local = client.getLocalPlayer(); renderTiles(graphics, local); return null; }
Example #27
Source File: DriftNetPlugin.java From runelite with BSD 2-Clause "Simplified" License | 5 votes |
private boolean checkArea() { final Player localPlayer = client.getLocalPlayer(); if (localPlayer == null || !client.isInInstancedRegion()) { return false; } final WorldPoint point = WorldPoint.fromLocalInstance(client, localPlayer.getLocalLocation()); return point.getRegionID() == UNDERWATER_REGION; }
Example #28
Source File: KourendLibraryTutorialOverlay.java From runelite with BSD 2-Clause "Simplified" License | 5 votes |
@Override public Dimension render(Graphics2D graphics) { if (!config.showTutorialOverlay()) { return null; } Player player = client.getLocalPlayer(); if (player == null) { return null; } WorldPoint playerLoc = player.getWorldLocation(); if (playerLoc.getRegionID() != KourendLibraryPlugin.REGION) { return null; } switch (library.getState()) { case NO_DATA: panelComponent.getChildren().add(noDataMessageComponent); break; case INCOMPLETE: panelComponent.getChildren().add(incompleteMessageComponent); panelComponent.getChildren().add(sidebarMessageComponent); break; case COMPLETE: panelComponent.getChildren().add(completeMessageComponent); panelComponent.getChildren().add(sidebarMessageComponent); break; } return super.render(graphics); }
Example #29
Source File: ChatCommandsPluginTest.java From plugins with GNU General Public License v3.0 | 5 votes |
@Test public void testPlayerSkillLookup() throws IOException { Player player = mock(Player.class); when(player.getName()).thenReturn(PLAYER_NAME); when(client.getLocalPlayer()).thenReturn(player); when(chatCommandsConfig.lvl()).thenReturn(true); ArgumentCaptor<BiConsumer<ChatMessage, String>> captor = ArgumentCaptor.forClass(BiConsumer.class); verify(chatCommandManager).registerCommandAsync(eq("!lvl"), captor.capture()); BiConsumer<ChatMessage, String> value = captor.getValue(); SingleHiscoreSkillResult skillResult = new SingleHiscoreSkillResult(); skillResult.setPlayer(PLAYER_NAME); skillResult.setSkill(new Skill(10, 1000, -1)); when(hiscoreClient.lookup(PLAYER_NAME, HiscoreSkill.ZULRAH, null)).thenReturn(skillResult); MessageNode messageNode = mock(MessageNode.class); ChatMessage chatMessage = new ChatMessage(); chatMessage.setType(ChatMessageType.PUBLICCHAT); chatMessage.setName(PLAYER_NAME); chatMessage.setMessageNode(messageNode); value.accept(chatMessage, "!lvl zulrah"); verify(messageNode).setRuneLiteFormatMessage("<colNORMAL>Level <colHIGHLIGHT>Zulrah: 1000<colNORMAL> Rank: <colHIGHLIGHT>10"); }
Example #30
Source File: LeagueChatIconsPlugin.java From runelite with BSD 2-Clause "Simplified" License | 5 votes |
/** * Gets the default name, including possible icon, of the local player. * * @return String of icon + name */ private String getNameDefault() { Player player = client.getLocalPlayer(); if (player == null) { return null; } int iconIndex; switch (client.getAccountType()) { case IRONMAN: iconIndex = IconID.IRONMAN.getIndex(); break; case HARDCORE_IRONMAN: iconIndex = IconID.HARDCORE_IRONMAN.getIndex(); break; case ULTIMATE_IRONMAN: iconIndex = IconID.ULTIMATE_IRONMAN.getIndex(); break; default: return player.getName(); } return getNameWithIcon(iconIndex, player.getName()); }