RuneHive-Tarnish
Neural OSRS Enhancement Framework
Loading...
Searching...
No Matches
EmoteHandler.java
1package com.osroyale.content.emote;
2
3import com.osroyale.net.packet.out.SendConfig;
4import com.osroyale.net.packet.out.SendMessage;
5import com.osroyale.game.action.impl.EmoteAction;
6import com.osroyale.game.world.entity.mob.player.Player;
7import com.osroyale.game.world.items.Item;
8import com.osroyale.game.world.items.containers.equipment.Equipment;
9import com.osroyale.util.Utility;
10
11import java.util.ArrayList;
12import java.util.Arrays;
13import java.util.List;
14
50
51* This class handles emotes from the emote tab and skill cape.
52 *
53 * @author Daniel | Obey
54 */
55public class EmoteHandler {
56
63 public static void refresh(Player player) {
64 for (Emote emote : Emote.values()) {
65 if (emote.getConfig() != -1) {
66 int flag = emote.activated(player) ? 0 : 1;
67 player.send(new SendConfig(emote.getConfig(), flag));
68 }
69 }
70 updateSkillcape(player);
71 }
72
79 public static void updateSkillcape(Player player) {
80 int flag = 1;
81 Item item = player.equipment.get(Equipment.CAPE_SLOT);
82
83 if (item != null) {
84 Skillcape skillcape = Skillcape.forId(item.getId());
85 if (skillcape != null) {
86 flag = 0;
87 }
88 }
89
90 player.send(new SendConfig(1114, flag));
91 }
92
93 public static boolean contains(Player player, EmoteUnlockable emote) {
94 return player.emoteUnlockable.contains(emote);
95 }
96
97 public static boolean containsAll(Player player, EmoteUnlockable... emotes) {
98 for (EmoteUnlockable emote : emotes) {
99 if (!contains(player, emote)) {
100 return false;
101 }
102 }
103 return true;
104 }
105
106 public static EmoteUnlockable selectRandom(Player player, EmoteUnlockable... emotes) {
107 List<EmoteUnlockable> selected = new ArrayList<>(emotes.length);
108 for (EmoteUnlockable emote : emotes) {
109 if (!contains(player, emote)) {
110 selected.add(emote);
111 }
112 }
113 return selected.isEmpty() ? null : Utility.randomElement(selected);
114 }
115
124 public static void unlock(Player player, EmoteUnlockable emote) {
125 if (!player.emoteUnlockable.contains(emote)) {
126 player.emoteUnlockable.add(emote);
127 refresh(player);
128 player.send(new SendMessage("Congratulations, you have unlocked the " + Utility.formatEnum(emote.name()) + " emote."));
129 }
130 }
131
138 public static void unlockAll(Player player) {
139 Arrays.stream(EmoteUnlockable.values()).forEach(e -> {
140 if (!player.emoteUnlockable.contains(e)) {
141 player.emoteUnlockable.add(e);
142 }
143 });
144 refresh(player);
145 player.send(new SendMessage("You have successfully unlocked all the emotes."));
146 }
147
148}
static void unlock(Player player, EmoteUnlockable emote)
static void updateSkillcape(Player player)
static void unlockAll(Player player)
static void refresh(Player player)
static String formatEnum(final String string)
Definition Utility.java:126