Search in sources :

Example 6 with Player

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;
    }
}
Also used : Player(net.runelite.api.Player) Subscribe(com.google.common.eventbus.Subscribe)

Example 7 with Player

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!");
    }
}
Also used : Player(net.runelite.api.Player) Duration(java.time.Duration) Subscribe(com.google.common.eventbus.Subscribe)

Example 8 with Player

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));
}
Also used : Player(net.runelite.api.Player) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) LinkedHashMap(java.util.LinkedHashMap) Schedule(net.runelite.client.task.Schedule)

Example 9 with Player

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);
        }
    }
}
Also used : Player(net.runelite.api.Player) MenuEntry(net.runelite.api.MenuEntry) Color(java.awt.Color) ClanMemberRank(net.runelite.api.ClanMemberRank) Subscribe(com.google.common.eventbus.Subscribe)

Example 10 with Player

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];
}
Also used : NPC(net.runelite.api.NPC) Player(net.runelite.api.Player) LocalPoint(net.runelite.api.coords.LocalPoint) Point(net.runelite.api.Point) WorldPoint(net.runelite.api.coords.WorldPoint) Inject(net.runelite.api.mixins.Inject)

Aggregations

Player (net.runelite.api.Player)17 Subscribe (com.google.common.eventbus.Subscribe)6 LocalPoint (net.runelite.api.coords.LocalPoint)6 Point (net.runelite.api.Point)4 Color (java.awt.Color)3 WorldPoint (net.runelite.api.coords.WorldPoint)3 FontMetrics (java.awt.FontMetrics)2 GameObject (net.runelite.api.GameObject)2 NPC (net.runelite.api.NPC)2 Region (net.runelite.api.Region)2 Tile (net.runelite.api.Tile)2 Inject (net.runelite.api.mixins.Inject)2 Inject (com.google.inject.Inject)1 Dimension (java.awt.Dimension)1 Graphics2D (java.awt.Graphics2D)1 Polygon (java.awt.Polygon)1 Rectangle (java.awt.Rectangle)1 Rectangle2D (java.awt.geom.Rectangle2D)1 IOException (java.io.IOException)1 Duration (java.time.Duration)1