RuneHive-Tarnish
Neural OSRS Enhancement Framework
Loading...
Searching...
No Matches
MysteryBoxManager.java
1package com.osroyale.content.mysterybox;
2
3import com.osroyale.game.world.World;
4import com.osroyale.game.world.entity.mob.player.Player;
5import com.osroyale.game.world.entity.mob.player.PlayerRight;
6import com.osroyale.game.world.items.Item;
7import com.osroyale.game.world.position.Area;
8import com.osroyale.net.packet.out.*;
9
10import java.util.Optional;
11
34
35public class MysteryBoxManager {
36 private final Player player;
37 int count;
38 public MysteryBox box;
39
40 public MysteryBoxManager(Player player) {
41 this.player = player;
42 }
43
44 public boolean click(Item item) {
45 Optional<MysteryBox> mBox = MysteryBox.getMysteryBox(item.getId());
46
47 if (!mBox.isPresent()) {
48 return false;
49 }
50
51 if (Area.inWilderness(player)) {
52 player.dialogueFactory.sendStatement("You can not open a mystery box while in the wilderness!").execute();
53 return true;
54 }
55
56 if (player.getCombat().inCombat()) {
57 player.dialogueFactory.sendStatement("You can not open a mystery box while in combat!").execute();
58 return true;
59 }
60
61 if (player.playerAssistant.busy() && !player.interfaceManager.isInterfaceOpen(59500)) {
62 player.dialogueFactory.sendStatement("You can not open a mystery box right now!").execute();
63 return true;
64 }
65 box = mBox.get();
66 count = player.inventory.computeAmountForId(item.getId());
67
68 spin();
69 /* for (int index = 0; index < 11; index++) {
70 player.send(new SendConfig((430 + index), 1));
71 }
72 player.send(new SendItemOnInterface(59581, mBox.get().rewards()));
73 player.send(new SendScrollbar(59580, mBox.get().rewards().length * 5));
74 player.send(new SendItemOnInterface(59512));
75 player.send(new SendColor(59508, 0x37991C));
76 player.send(new SendString(mBox.get().name(), 59503));
77 player.send(new SendString("You have " + count + " available!", 59507));
78 player.interfaceManager.open(59500);*/
79 return true;
80 }
81
82 public void spin() {
83 if (box == null) {
84 player.interfaceManager.close();
85 return;
86 }
87 if (count == 0) {
88 player.dialogueFactory.sendStatement("You do not have any " + box.name() + "!", "To spin a different mystery box level click on the item first!").execute();
89 return;
90 }
91 World.schedule(new MysteryBoxEvent(player));
92 }
93}
static void schedule(Task task)
Definition World.java:284