RuneHive-Game
Loading...
Searching...
No Matches
MysteryBoxManager.java
Go to the documentation of this file.
1
package
com.runehive.content.mysterybox;
2
3
import
com.runehive.game.world.World;
4
import
com.runehive.game.world.entity.mob.player.Player;
5
import
com.runehive.game.world.entity.mob.player.PlayerRight;
6
import
com.runehive.game.world.items.Item;
7
import
com.runehive.game.world.position.Area;
8
import
com.runehive.net.packet.out.*;
9
10
import
java.util.Optional;
11
12
public
class
MysteryBoxManager
{
13
private
final
Player
player
;
14
int
count
;
15
public
MysteryBox
box
;
16
17
public
MysteryBoxManager
(
Player
player
) {
18
this.player =
player
;
19
}
20
21
public
boolean
click
(
Item
item) {
22
Optional<MysteryBox> mBox =
MysteryBox
.
getMysteryBox
(item.
getId
());
23
24
if
(!mBox.isPresent()) {
25
return
false
;
26
}
27
28
if
(
Area
.
inWilderness
(
player
)) {
29
player
.dialogueFactory.sendStatement(
"You can not open a mystery box while in the wilderness!"
).execute();
30
return
true
;
31
}
32
33
if
(
player
.getCombat().inCombat()) {
34
player
.dialogueFactory.sendStatement(
"You can not open a mystery box while in combat!"
).execute();
35
return
true
;
36
}
37
38
if
(
player
.playerAssistant.busy() && !
player
.interfaceManager.isInterfaceOpen(59500)) {
39
player
.dialogueFactory.sendStatement(
"You can not open a mystery box right now!"
).execute();
40
return
true
;
41
}
42
box
= mBox.get();
43
count
=
player
.inventory.computeAmountForId(item.
getId
());
44
45
spin
();
46
/* for (int index = 0; index < 11; index++) {
47
player.send(new SendConfig((430 + index), 1));
48
}
49
player.send(new SendItemOnInterface(59581, mBox.get().rewards()));
50
player.send(new SendScrollbar(59580, mBox.get().rewards().length * 5));
51
player.send(new SendItemOnInterface(59512));
52
player.send(new SendColor(59508, 0x37991C));
53
player.send(new SendString(mBox.get().name(), 59503));
54
player.send(new SendString("You have " + count + " available!", 59507));
55
player.interfaceManager.open(59500);*/
56
return
true
;
57
}
58
59
public
void
spin
() {
60
if
(
box
==
null
) {
61
player
.interfaceManager.close();
62
return
;
63
}
64
if
(
count
== 0) {
65
player
.dialogueFactory.sendStatement(
"You do not have any "
+
box
.name() +
"!"
,
"To spin a different mystery box level click on the item first!"
).execute();
66
return
;
67
}
68
World
.
schedule
(
new
MysteryBoxEvent
(
player
));
69
}
70
}
com.runehive.content.mysterybox.MysteryBoxEvent
Definition
MysteryBoxEvent.java:13
com.runehive.content.mysterybox.MysteryBox
The mystery box class.
Definition
MysteryBox.java:17
com.runehive.content.mysterybox.MysteryBox.getMysteryBox
static Optional< MysteryBox > getMysteryBox(int item)
Handles getting the mystery box.
Definition
MysteryBox.java:36
com.runehive.content.mysterybox.MysteryBoxManager.MysteryBoxManager
MysteryBoxManager(Player player)
Definition
MysteryBoxManager.java:17
com.runehive.content.mysterybox.MysteryBoxManager.player
final Player player
Definition
MysteryBoxManager.java:13
com.runehive.content.mysterybox.MysteryBoxManager.click
boolean click(Item item)
Definition
MysteryBoxManager.java:21
com.runehive.content.mysterybox.MysteryBoxManager.box
MysteryBox box
Definition
MysteryBoxManager.java:15
com.runehive.content.mysterybox.MysteryBoxManager.count
int count
Definition
MysteryBoxManager.java:14
com.runehive.content.mysterybox.MysteryBoxManager.spin
void spin()
Definition
MysteryBoxManager.java:59
com.runehive.game.world.World
Represents the game world.
Definition
World.java:46
com.runehive.game.world.World.schedule
static void schedule(Task task)
Submits a new event.
Definition
World.java:247
com.runehive.game.world.entity.mob.player.Player
This class represents a character controlled by a player.
Definition
Player.java:125
com.runehive.game.world.items.Item
The container class that represents an item that can be interacted with.
Definition
Item.java:21
com.runehive.game.world.items.Item.getId
final int getId()
Gets the identification of this item.
Definition
Item.java:324
com.runehive.game.world.position.Area
Handles checking if mobs are in a certain area.
Definition
Area.java:13
com.runehive.game.world.position.Area.inWilderness
static boolean inWilderness(Position position)
Definition
Area.java:272