RuneHive-Game
Loading...
Searching...
No Matches
PlayerRight.java
Go to the documentation of this file.
1package com.runehive.game.world.entity.mob.player;
2
3import java.util.Arrays;
4import java.util.Optional;
5
6/**
7 * Holds all the player right data.
8 *
9 * @author Daniel
10 */
11public enum PlayerRight {
12 PLAYER("Player", "000000", 0, -1, 4111),
13 MODERATOR("Moderator", "245EFF", 1, -1, 4116),
14 ADMINISTRATOR("Administrator", "D17417", 2, -1, 4116),
15 MANAGER("Manager", "D17417", 3, -1, 4116),
16 OWNER("Owner", "ED0C0C", 2, -1, 4117),
17 DEVELOPER("Developer", "7D0CED", 4, -1, 4117),
18
19 DONATOR("Donator", "9C4B2F", 5, 10, 4112),
20 SUPER_DONATOR("Super Donator", "2F809C", 6, 50, 4112),
21 EXTREME_DONATOR("Extreme Donator", "158A76", 7, 250, 4113),
22 ELITE_DONATOR("Elite Donator", "2CA395", 8, 500, 4114),
23 KING_DONATOR("King Donator", "8F7A42", 9, 1000, 4115),
24 VETERAN("Veteran", "B1800A", 10, -1, 4115),
25 YOUTUBER("Youtuber", "91111A", 11, -1, 4112),
26 IRONMAN("Ironman", "7A6F74", 12, -1, 4112),
27 ULTIMATE_IRONMAN("Ultimate Ironman", "7A6F74", 13, -1, 4113),
28 HARDCORE_IRONMAN("Hardcore Ironman", "7A6F74", 14, -1, 4114),
29 HELPER("Helper", "5C5858", 15, -1, 4115),
30 GRAPHIC("Graphic", "CE795A", 17, -1, 4112);
31
32 /**
33 * The rank name.
34 */
35 private final String name;
36
37 /**
38 * The crown identification.
39 */
40 private final int crown;
41
42 private final int moneyRequired;
43
44 /**
45 * The rank color.
46 */
47 private final String color;
48
49 /**
50 * The rank rest animation.
51 */
52 private final int restAnimation;
53
54 /**
55 * Constructs a new <code>PlayerRight</code>.
56 */
57 PlayerRight(String name, String color, int crown, int moneyRequired, int restAnimation) {
58 this.name = name;
59 this.color = color;
60 this.crown = crown;
61 this.moneyRequired = moneyRequired;
62 this.restAnimation = restAnimation;
63 }
64
65 public static Optional<PlayerRight> lookup(int id) {
66 return Arrays.stream(values()).filter(it -> it.crown == id).findFirst();
67 }
68
69 public static boolean isOwner(Player player) {
70 return player.right.equals(OWNER);
71 }
72
73 /**
74 * Checks if the player has developer status.
75 */
76 public static boolean isDeveloper(Player player) {
77 return player.right.equals(OWNER) || player.right.equals(DEVELOPER);
78 }
79
80 /**
81 * Checks if the player is a privileged member.
82 */
83 public static boolean isManager(Player player) {
84 return isDeveloper(player) || player.right.equals(MANAGER);
85 }
86
87 /**
88 * Checks if the player is a privileged member.
89 */
90 public static boolean isAdministrator(Player player) {
91 return isManager(player) || player.right.equals(ADMINISTRATOR);
92 }
93
94 /**
95 * Checks if the player is a management member.
96 */
97 public static boolean isModerator(Player player) {
98 return isAdministrator(player) || player.right.equals(MODERATOR);
99 }
100
101 /**
102 * Checks if the player is a HELPER member.
103 */
104 public static boolean isHelper(Player player) {
105 return isModerator(player) || player.right.equals(HELPER);
106 }
107
108 /**
109 * Checks if the player has donator status.
110 */
111 public static boolean isDonator(Player player) {
112 return isModerator(player) || isHelper(player) || player.donation.getSpent() >= DONATOR.getMoneyRequired();
113 }
114
115 /**
116 * Checks if the player has super donator status.
117 */
118 public static boolean isSuper(Player player) {
119 return isModerator(player) || isHelper(player) || player.donation.getSpent() >= SUPER_DONATOR.getMoneyRequired();
120 }
121
122 /**
123 * Checks if the player has extreme donator status.
124 */
125 public static boolean isExtreme(Player player) {
126 return isAdministrator(player) || player.donation.getSpent() >= EXTREME_DONATOR.getMoneyRequired();
127 }
128
129 /**
130 * Checks if the player has elite donator status.
131 */
132 public static boolean isElite(Player player) {
133 return isAdministrator(player) || player.donation.getSpent() >= ELITE_DONATOR.getMoneyRequired();
134 }
135
136 /**
137 * Checks if the player has king donator status.
138 */
139 public static boolean isKing(Player player) {
140 return isAdministrator(player) || player.donation.getSpent() >= KING_DONATOR.getMoneyRequired();
141 }
142
143 /**
144 * Checks if the player is an ironman.
145 */
146 public static boolean isIronman(Player player) {
147 return player.right.equals(IRONMAN) || player.right.equals(ULTIMATE_IRONMAN) || player.right.equals(HARDCORE_IRONMAN);
148 }
149
150 /**
151 * Gets the crown display.
152 */
153 public static String getCrown(Player player) {
154 return getCrown(player.right);
155 }
156
157 /**
158 * Gets the crown display.
159 */
160 public static String getCrown(PlayerRight right) {
161 return right.equals(PLAYER) ? "" : "<img=" + (right.getCrown() - 1) + ">";
162 }
163
164 public static String getColor(PlayerRight right) {
165 return "<col=" + right.getColor() + "><img=" + (right.getCrown() - 1) + ">";
166 }
167
168 public String getCrownText() {
169 return this == PLAYER ? "" : "<img=" + (crown - 1) + "> ";
170 }
171
172 public static int getForumGroupId(PlayerRight right) {
173 switch (right) {
174
175 case DONATOR:
176 return 10;
177
178 case SUPER_DONATOR:
179 return 14;
180
181 case EXTREME_DONATOR:
182 return 11;
183
184 case ELITE_DONATOR:
185 return 12;
186
187 case KING_DONATOR:
188 return 16;
189
190 default:
191 return -1;
192 }
193 }
194
195 /**
196 * Gets the deposit amount.
197 */
198 public static int getDepositAmount(Player player) {
199 if (isKing(player))
200 return 28;
201 else if (isElite(player))
202 return 20;
203 else if (isExtreme(player))
204 return 15;
205 else if (isSuper(player))
206 return 10;
207 else if (isDonator(player))
208 return 5;
209 return 1;
210 }
211
212 public static int getPresetAmount(Player player) {
213 if (isKing(player))
214 return 10;
215 else if (isElite(player))
216 return 9;
217 else if (isExtreme(player))
218 return 8;
219 else if (isSuper(player))
220 return 7;
221 else if (isDonator(player))
222 return 6;
223 return 5;
224 }
225
226 public static int getBloodMoney(Player player) {
227 if (isKing(player))
228 return 1500;
229 else if (isElite(player))
230 return 1400;
231 else if (isExtreme(player))
232 return 1300;
233 else if (isSuper(player))
234 return 1200;
235 else if (isDonator(player))
236 return 1100;
237 return 1000;
238 }
239
240 public static int dropRateIncrease(Player player, int roll) {
241 if (isKing(player)) return roll * 9 / 10; // 10%
242 else if (isElite(player)) return roll * 37 / 40; // 7.5%
243 else if (isExtreme(player)) return roll * 47 / 50; // 6%
244 else if (isSuper(player)) return roll * 189 / 200; // 5.5%
245 else if (isDonator(player)) return roll * 191 / 200; // 4.5%
246 else return roll * 97 / 100; // 3%
247 }
248
249 public static double getDropRateBonus(Player player) {
250 if (isKing(player)) return 10;
251 else if (isElite(player)) return 7.5;
252 else if (isExtreme(player)) return 6;
253 else if (isSuper(player)) return 5.5;
254 else if (isDonator(player)) return 4.5;
255 else return 3;
256 }
257
258 public static PlayerRight forSpent(int spent) {
259 if (spent >= PlayerRight.KING_DONATOR.getMoneyRequired())
260 return PlayerRight.KING_DONATOR;
261 if (spent >= PlayerRight.EXTREME_DONATOR.getMoneyRequired())
262 return PlayerRight.EXTREME_DONATOR;
263 if (spent >= PlayerRight.ELITE_DONATOR.getMoneyRequired())
264 return PlayerRight.ELITE_DONATOR;
265 if (spent >= PlayerRight.SUPER_DONATOR.getMoneyRequired())
266 return PlayerRight.SUPER_DONATOR;
267 if (spent >= PlayerRight.DONATOR.getMoneyRequired())
268 return PlayerRight.DONATOR;
269 return null;
270 }
271
272 /**
273 * Gets the name of the rank.
274 */
275 public String getName() {
276 return name;
277 }
278
279 /**
280 * Gets the crown of the rank.
281 */
282 public int getCrown() {
283 return crown;
284 }
285
286 public int getMoneyRequired() {
287 return moneyRequired;
288 }
289
290 /**
291 * Gets the color of the rank.
292 */
293 public String getColor() {
294 return color;
295 }
296
297 /**
298 * Gets the rest animation of the rank.
299 */
300 public int getRestAnimation() {
301 return restAnimation;
302 }
303
304 public final boolean greater(PlayerRight other) {
305 return ordinal() > other.ordinal();
306 }
307
308 public final boolean greaterOrEqual(PlayerRight other) {
309 return ordinal() >= other.ordinal();
310 }
311
312 public final boolean less(PlayerRight other) {
313 return ordinal() < other.ordinal();
314 }
315
316 public final boolean lessOrEqual(PlayerRight other) {
317 return ordinal() <= other.ordinal();
318 }
319}
This class represents a character controlled by a player.
Definition Player.java:125
static String getCrown(PlayerRight right)
Gets the crown display.
static boolean isKing(Player player)
Checks if the player has king donator status.
int getRestAnimation()
Gets the rest animation of the rank.
static boolean isDonator(Player player)
Checks if the player has donator status.
PlayerRight(String name, String color, int crown, int moneyRequired, int restAnimation)
Constructs a new PlayerRight.
static boolean isManager(Player player)
Checks if the player is a privileged member.
static Optional< PlayerRight > lookup(int id)
final int restAnimation
The rank rest animation.
static boolean isHelper(Player player)
Checks if the player is a HELPER member.
String getColor()
Gets the color of the rank.
static boolean isSuper(Player player)
Checks if the player has super donator status.
static int dropRateIncrease(Player player, int roll)
static String getCrown(Player player)
Gets the crown display.
static boolean isDeveloper(Player player)
Checks if the player has developer status.
static boolean isElite(Player player)
Checks if the player has elite donator status.
static boolean isIronman(Player player)
Checks if the player is an ironman.
static boolean isExtreme(Player player)
Checks if the player has extreme donator status.
static int getDepositAmount(Player player)
Gets the deposit amount.
static boolean isModerator(Player player)
Checks if the player is a management member.
static boolean isAdministrator(Player player)
Checks if the player is a privileged member.