RuneHive-Game
Loading...
Searching...
No Matches
MimeBox.java
Go to the documentation of this file.
1package com.runehive.content.itemaction.impl;
2
3import com.runehive.net.packet.out.SendMessage;
4import com.runehive.game.world.entity.mob.player.Player;
5import com.runehive.content.emote.EmoteHandler;
6import com.runehive.content.emote.EmoteUnlockable;
7import com.runehive.content.itemaction.ItemAction;
8import com.runehive.game.world.items.Item;
9import com.runehive.util.Utility;
10
11public class MimeBox extends ItemAction {
12
14
15 private static final Item[] MIME_COSTUME = { new Item(3057), new Item(3058), new Item(3059), new Item(3060), new Item(3061) };
16
17 @Override
18 public String name() {
19 return "Mime box";
20 }
21
22 @Override
23 public boolean inventory(Player player, Item item, int opcode) {
24 if (opcode != 1)
25 return false;
26
27
28 player.inventory.remove(item);
29 int random = Utility.random(1, 5);
30
31 switch (random) {
32 case 1:
33 case 2:
34 if (!EmoteHandler.containsAll(player, EMOTES)) {
36 player.emoteUnlockable.add(emote);
37 EmoteHandler.refresh(player);
38 player.send(new SendMessage("You have unlocked the " + Utility.formatName(emote.name().toLowerCase().replace("_", "")) + " emote!"));
39 return true;
40 }
41 int random2 = Utility.random(1, 2);
42 if (random2 == 1) {
44 player.inventory.add(clothing);
45 player.send(new SendMessage("You have received the " + clothing.getName() + " item!"));
46 } else {
47 player.inventory.add(new Item(995, 75000));
48 }
49 break;
50 case 3:
51 case 4:
53 break;
54 case 5:
55 player.inventory.add(new Item(995, 75000));
56 break;
57 }
58 return true;
59 }
60}
This class handles emotes from the emote tab and skill cape.
static void refresh(Player player)
Handles refreshing the emote tab.
static boolean containsAll(Player player, EmoteUnlockable... emotes)
static EmoteUnlockable selectRandom(Player player, EmoteUnlockable... emotes)
Handles executing an item action.
static final EmoteUnlockable[] EMOTES
Definition MimeBox.java:13
boolean inventory(Player player, Item item, int opcode)
The execution method of the action.
Definition MimeBox.java:23
String name()
The name of the action.
Definition MimeBox.java:18
This class represents a character controlled by a player.
Definition Player.java:125
The container class that represents an item that can be interacted with.
Definition Item.java:21
boolean remove(Item item)
Attempts to withdraw item from this container.
boolean add(Item item)
Attempts to deposit item into this container.
The OutgoingPacket that sends a message to a Players chatbox in the client.
Handles miscellaneous methods.
Definition Utility.java:27
static String formatName(final String input)
Definition Utility.java:645
static int random(int bound)
Definition Utility.java:239
static< T > T randomElement(Collection< T > collection)
Picks a random element out of any array type.
Definition Utility.java:248