RuneHive-Game
Loading...
Searching...
No Matches
Skillcape.java
Go to the documentation of this file.
1package com.runehive.content.emote;
2
3import com.runehive.content.store.StoreItem;
4import com.runehive.content.store.currency.CurrencyType;
5import com.runehive.game.world.entity.mob.player.Player;
6import com.runehive.game.world.entity.skill.Skill;
7import com.runehive.game.world.items.Item;
8import com.runehive.net.packet.out.SendMessage;
9
10import java.util.Arrays;
11import java.util.Optional;
12import java.util.OptionalInt;
13
14/**
15 * Holds the data for skillcape emotes.
16 *
17 * @author Daniel
18 */
19public enum Skillcape {
20 ATTACK_CAPE(new int[]{9747, 9748, 9479}, 823, 4959, Skill.ATTACK),
21 STRENGTH_CAPE(new int[]{9750, 9751, 9752}, 828, 4981, Skill.STRENGTH),
22 DEFENCE_CAPE(new int[]{9753, 9754, 9755}, 824, 4961, Skill.DEFENCE),
23 RANGING_CAPE(new int[]{9756, 9757, 9758}, 832, 4973, Skill.RANGED),
24 PRAYER_CAPE(new int[]{9759, 9760, 9761}, 829, 4979, Skill.PRAYER),
25 MAGIC_CAPE(new int[]{9762, 9763, 9764}, 813, 4939, Skill.MAGIC),
26 RUNECRAFT_CAPE(new int[]{9765, 9766, 9767}, 817, 4947, Skill.RUNECRAFTING),
27 HITPOINTS_CAPE(new int[]{9768, 9769, 9770}, 833, 4971, Skill.HITPOINTS),
28 AGILITY_CAPE(new int[]{9771, 9772, 9773}, 830, 4977, Skill.AGILITY),
29 HERBLORE_CAPE(new int[]{9774, 9775, 9776}, 835, 4969, Skill.HERBLORE),
30 THEIVING_CAPE(new int[]{9777, 9778, 9779}, 826, 4965, Skill.THIEVING),
31 CRAFTING_CAPE(new int[]{9780, 9781, 9782}, 818, 4949, Skill.CRAFTING),
32 FLETCHING_CAPE(new int[]{9783, 9784, 9785}, 812, 4937, Skill.FLETCHING),
33 SLAYER_CAPE(new int[]{9786, 9787, 9788}, 827, 4967, Skill.SLAYER),
34 CONSTRUCTION_CAPE(new int[]{9789, 9790, 9791}, 820, 4953, Skill.CONSTRUCTION),
35 MINING_CAPE(new int[]{9792, 9793, 9794}, 814, 4941, Skill.MINING),
36 SMITHING_CAPE(new int[]{9795, 9796, 9797}, 815, 4943, Skill.SMITHING),
37 FISHING_CAPE(new int[]{9798, 9799, 9800}, 819, 4951, Skill.FISHING),
38 COOKING_CAPE(new int[]{9801, 9802, 9803}, 821, 4955, Skill.COOKING),
39 FIREMAKING_CAPE(new int[]{9804, 9805, 9806}, 831, 4975, Skill.FIREMAKING),
40 WOODCUTTING_CAPE(new int[]{9807, 9808, 9809}, 822, 4957, Skill.WOODCUTTING),
41 FARMING_CAPE(new int[]{9810, 9811, 9812}, 825, 4963, Skill.FARMING),
42 HUNTER_CAPE(new int[]{9948, 9949, 9950}, 907, 5158, Skill.HUNTER),
43 QUEST_POINT_CAPE(new int[]{9813, 9814, 9815}, 816, 4945, -1),
44 ACHIEVEMENT_CAPE(new int[]{13069}, 323, 2709, -1),
45 MAX_CAPE(new int[]{13280, 13329, 13331, 13333, 13335, 13337}, 1286, 7121, -1);
46
47 private final int[] item;
48 private final int graphic;
49 private final int animation;
50 private final int skill;
51
52 Skillcape(int[] item, int graphic, int animation, int skill) {
53 this.item = item;
54 this.graphic = graphic;
55 this.animation = animation;
56 this.skill = skill;
57 }
58
59 public int getAnimation() {
60 return animation;
61 }
62
63 public int getGraphic() {
64 return graphic;
65 }
66
67 public int[] getSkillcape() {
68 return item;
69 }
70
71 public int getSkill() {
72 return skill;
73 }
74
75 public static Skillcape forId(int id) {
76 for (Skillcape data : Skillcape.values())
77 for (int index = 0; index < data.getSkillcape().length; index++)
78 if (data.getSkillcape()[index] == id)
79 return data;
80 return null;
81 }
82
83 public static Optional<Skillcape> forSkill(int skill) {
84 return Arrays.stream(values()).filter(s -> s.getSkill() == skill).findFirst();
85 }
86
87 public static StoreItem[] getItems() {
88 final StoreItem[] items = new StoreItem[Skill.SKILL_COUNT];
89
90 int index = 0;
91 for (Skillcape data : values()) {
92 if (data.skill == -1)
93 continue;
94 items[index] = new StoreItem(data.getSkillcape()[1], 1, OptionalInt.of(100000), Optional.of(CurrencyType.COINS));
95 index++;
96 }
97
98 return items;
99 }
100
101 public static boolean equip(Player player, Item item) {
102 Skillcape data = forId(item.getId());
103
104 if (data == null) {
105 return true;
106 }
107
108 if (data.getSkill() == -1) {
109 return true;
110 }
111
112 if (player.skills.getMaxLevel(data.getSkill()) != 99) {
113 player.send(new SendMessage("You need to have a " + Skill.getName(data.getSkill()) + " level of 99 to equip this item."));
114 return false;
115 }
116
117 return true;
118 }
119}
A simple wrapper class which holds extra attributes for the item object.
This class represents a character controlled by a player.
Definition Player.java:125
Represents a trainable and usable skill.
Definition Skill.java:18
static final int SLAYER
The slayer skill id.
Definition Skill.java:75
static final int WOODCUTTING
The woodcutting skill id.
Definition Skill.java:45
static String getName(int skill)
Gets the name for a skill id.
Definition Skill.java:465
static final int PRAYER
The prayer skill id.
Definition Skill.java:36
static final int RANGED
The ranged skill id.
Definition Skill.java:33
static final int CRAFTING
The crafting skill id.
Definition Skill.java:57
static final int HERBLORE
The herblore skill id.
Definition Skill.java:66
static final int SMITHING
The smithing skill id.
Definition Skill.java:60
static final int FISHING
The fishing skill id.
Definition Skill.java:51
static final int DEFENCE
The defence skill id.
Definition Skill.java:24
static final int CONSTRUCTION
The construction skill id.
Definition Skill.java:84
static final int SKILL_COUNT
The amount of available skills.
Definition Skill.java:90
static final int FLETCHING
The fletching skill id.
Definition Skill.java:48
static final int FIREMAKING
The firemaking skill id.
Definition Skill.java:54
static final int MAGIC
The magic skill id.
Definition Skill.java:39
static final int ATTACK
The attack skill id.
Definition Skill.java:21
static final int FARMING
The farming skill id.
Definition Skill.java:78
static final int AGILITY
The agility skill id.
Definition Skill.java:69
static final int THIEVING
The thieving skill id.
Definition Skill.java:72
static final int HUNTER
The hunter skill id.
Definition Skill.java:87
static final int STRENGTH
The strength skill id.
Definition Skill.java:27
static final int COOKING
The cooking skill id.
Definition Skill.java:42
static final int MINING
The mining skill id.
Definition Skill.java:63
static final int HITPOINTS
The hitpoints skill id.
Definition Skill.java:30
static final int RUNECRAFTING
The runecrafting skill id.
Definition Skill.java:81
int getMaxLevel(int id)
Gets the highest possible level of a skill.
The container class that represents an item that can be interacted with.
Definition Item.java:21
The OutgoingPacket that sends a message to a Players chatbox in the client.
Skillcape(int[] item, int graphic, int animation, int skill)
static boolean equip(Player player, Item item)
static Skillcape forId(int id)
static Optional< Skillcape > forSkill(int skill)
The enumerated type whom holds all the currencies usable for a server.