use of net.runelite.api.Player in project runelite by runelite.
the class IdleNotifierPlugin method onAnimationChanged.
@Subscribe
public void onAnimationChanged(AnimationChanged event) {
if (client.getGameState() != GameState.LOGGED_IN) {
return;
}
Player localPlayer = client.getLocalPlayer();
if (localPlayer != event.getActor()) {
return;
}
int animation = localPlayer.getAnimation();
switch(animation) {
/* Woodcutting */
case WOODCUTTING_BRONZE:
case WOODCUTTING_IRON:
case WOODCUTTING_STEEL:
case WOODCUTTING_BLACK:
case WOODCUTTING_MITHRIL:
case WOODCUTTING_ADAMANT:
case WOODCUTTING_RUNE:
case WOODCUTTING_DRAGON:
case WOODCUTTING_INFERNAL:
/* Cooking(Fire, Range) */
case COOKING_FIRE:
case COOKING_RANGE:
/* Crafting(Gem Cutting, Glassblowing, Spinning) */
case GEM_CUTTING_OPAL:
case GEM_CUTTING_JADE:
case GEM_CUTTING_REDTOPAZ:
case GEM_CUTTING_SAPPHIRE:
case GEM_CUTTING_EMERALD:
case GEM_CUTTING_RUBY:
case GEM_CUTTING_DIAMOND:
case CRAFTING_GLASSBLOWING:
case CRAFTING_SPINNING:
/* Fletching(Cutting, Stringing) */
case FLETCHING_BOW_CUTTING:
case FLETCHING_STRING_NORMAL_SHORTBOW:
case FLETCHING_STRING_OAK_SHORTBOW:
case FLETCHING_STRING_WILLOW_SHORTBOW:
case FLETCHING_STRING_MAPLE_SHORTBOW:
case FLETCHING_STRING_YEW_SHORTBOW:
case FLETCHING_STRING_MAGIC_SHORTBOW:
case FLETCHING_STRING_NORMAL_LONGBOW:
case FLETCHING_STRING_OAK_LONGBOW:
case FLETCHING_STRING_WILLOW_LONGBOW:
case FLETCHING_STRING_MAPLE_LONGBOW:
case FLETCHING_STRING_YEW_LONGBOW:
case FLETCHING_STRING_MAGIC_LONGBOW:
/* Smithing(Anvil, Furnace, Cannonballs */
case SMITHING_ANVIL:
case SMITHING_SMELTING:
case SMITHING_CANNONBALL:
/* Fishing */
case FISHING_NET:
case FISHING_HARPOON:
case FISHING_BARBTAIL_HARPOON:
case FISHING_DRAGON_HARPOON:
case FISHING_CAGE:
case FISHING_POLE_CAST:
case FISHING_OILY_ROD:
case FISHING_KARAMBWAN:
/* Mining(Normal) */
case MINING_BRONZE_PICKAXE:
case MINING_IRON_PICKAXE:
case MINING_STEEL_PICKAXE:
case MINING_BLACK_PICKAXE:
case MINING_MITHRIL_PICKAXE:
case MINING_ADAMANT_PICKAXE:
case MINING_RUNE_PICKAXE:
case MINING_DRAGON_PICKAXE:
case MINING_DRAGON_PICKAXE_ORN:
case MINING_INFERNAL_PICKAXE:
/* Mining(Motherlode) */
case MINING_MOTHERLODE_BRONZE:
case MINING_MOTHERLODE_IRON:
case MINING_MOTHERLODE_STEEL:
case MINING_MOTHERLODE_BLACK:
case MINING_MOTHERLODE_MITHRIL:
case MINING_MOTHERLODE_ADAMANT:
case MINING_MOTHERLODE_RUNE:
case MINING_MOTHERLODE_DRAGON:
case MINING_MOTHERLODE_DRAGON_ORN:
case MINING_MOTHERLODE_INFERNAL:
/* Herblore */
case HERBLORE_POTIONMAKING:
case HERBLORE_MAKE_TAR:
/* Magic */
case MAGIC_CHARGING_ORBS:
resetTimers();
notifyIdle = true;
break;
}
}
use of net.runelite.api.Player in project runelite by runelite.
the class IdleNotifierPlugin method onGameTick.
@Subscribe
public void onGameTick(GameTick event) {
final Player local = client.getLocalPlayer();
final Duration waitDuration = Duration.ofMillis(config.getIdleNotificationDelay());
if (client.getGameState() != GameState.LOGGED_IN || local == null) {
return;
}
if (checkIdleLogout()) {
notifier.notify("[" + local.getName() + "] is about to log out from idling too long!");
}
if (check6hrLogout()) {
notifier.notify("[" + local.getName() + "] is about to log out from being online for 6 hours!");
}
if (config.animationIdle() && checkAnimationIdle(waitDuration, local)) {
notifier.notify("[" + local.getName() + "] is now idle!");
}
if (config.combatIdle() && checkOutOfCombat(waitDuration, local)) {
notifier.notify("[" + local.getName() + "] is now out of combat!");
}
if (checkLowHitpoints()) {
notifier.notify("[" + local.getName() + "] has low hitpoints!");
}
if (checkLowPrayer()) {
notifier.notify("[" + local.getName() + "] has low prayer!");
}
}
use of net.runelite.api.Player in project runelite by runelite.
the class TeamCapesPlugin method update.
@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)).limit(5).collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (e1, e2) -> e1, LinkedHashMap::new));
}
use of net.runelite.api.Player in project runelite by runelite.
the class PlayerIndicatorsPlugin method onMenuEntryAdd.
@Subscribe
public void onMenuEntryAdd(MenuEntryAdded menuEntryAdded) {
int type = menuEntryAdded.getType();
int identifier = menuEntryAdded.getIdentifier();
if (type == FOLLOW.getId() || type == TRADE.getId() || type == SPELL_CAST_ON_PLAYER.getId() || type == ITEM_USE_ON_PLAYER.getId() || type == PLAYER_FIRST_OPTION.getId() || type == PLAYER_SECOND_OPTION.getId() || type == PLAYER_THIRD_OPTION.getId() || type == PLAYER_FOURTH_OPTION.getId() || type == PLAYER_FIFTH_OPTION.getId() || type == PLAYER_SIXTH_OPTION.getId() || type == PLAYER_SEVENTH_OPTION.getId() || type == PLAYER_EIGTH_OPTION.getId()) {
final Player localPlayer = client.getLocalPlayer();
Player[] players = client.getCachedPlayers();
Player player = null;
if (identifier >= 0 && identifier < players.length) {
player = players[identifier];
}
if (player == null) {
return;
}
int image = -1;
Color color = null;
if (config.drawFriendNames() && player.isFriend()) {
color = config.getFriendNameColor();
} else if (config.drawClanMemberNames() && player.isClanMember()) {
color = config.getClanMemberColor();
ClanMemberRank rank = clanManager.getRank(player.getName());
if (rank != UNRANKED) {
image = clanManager.getIconNumber(rank);
}
} else if (config.drawTeamMemberNames() && player.getTeam() > 0 && localPlayer.getTeam() == player.getTeam()) {
color = config.getTeamMemberColor();
} else if (config.drawNonClanMemberNames() && !player.isClanMember()) {
color = config.getNonClanMemberColor();
}
if (image != -1 || color != null) {
MenuEntry[] menuEntries = client.getMenuEntries();
MenuEntry lastEntry = menuEntries[menuEntries.length - 1];
if (color != null) {
// strip out existing <col...
String target = lastEntry.getTarget();
int idx = target.indexOf('>');
if (idx != -1) {
target = target.substring(idx + 1);
}
lastEntry.setTarget("<col=" + Integer.toHexString(color.getRGB() & 0xFFFFFF) + ">" + target);
}
if (image != -1) {
lastEntry.setTarget("<img=" + image + ">" + lastEntry.getTarget());
}
client.setMenuEntries(menuEntries);
}
}
}
use of net.runelite.api.Player in project runelite by runelite.
the class RSActorMixin method getInteracting.
@Inject
@Override
public Actor getInteracting() {
int i = getRSInteracting();
if (i == -1) {
return null;
}
if (i < 0x8000) {
NPC[] npcs = client.getCachedNPCs();
return npcs[i];
}
i -= 0x8000;
Player[] players = client.getCachedPlayers();
return players[i];
}
Aggregations