RuneHive-Tarnish
Neural OSRS Enhancement Framework
Loading...
Searching...
No Matches
DropSimulator.java
1
package
com.osroyale.content.simulator;
2
3
import
com.osroyale.game.world.entity.mob.npc.definition.NpcDefinition;
4
import
com.osroyale.game.world.entity.mob.npc.drop.NpcDropManager;
5
import
com.osroyale.game.world.entity.mob.player.Player;
6
import
com.osroyale.net.packet.out.SendScrollbar;
7
import
com.osroyale.net.packet.out.SendString;
8
import
com.osroyale.net.packet.out.SendTooltip;
9
import
com.osroyale.util.Utility;
10
11
import
java.util.ArrayList;
12
import
java.util.List;
13
14
import
static
com.osroyale.content.simulator.Simulation.BLOOD_MONEY_CHEST;
15
45
46
* This
class
simulates drops of an npc and places it on an itemcontainer.
47
*
48
* @author Daniel.
49
*/
50
public
class
DropSimulator
{
51
53
private
static
final
int
[] DEFAULT = {3080};
54
55
public
static
final
Simulation
[] CUSTOM_SIMULATIONS = { };
56
58
public
static
void
open
(
Player
player) {
59
int
npc =
Utility
.
randomElement
(DEFAULT);
60
String name =
NpcDefinition
.
get
(npc).
getName
();
61
drawList
(player, name);
62
simulate
(player,
Simulation
.NPC_DROP, npc, 100);
63
player.send(
new
SendString
(name, 26810,
true
));
64
player.interfaceManager.
open
(26800);
65
}
66
68
public
static
void
drawList
(
Player
player, String context) {
69
for
(
int
index = 0,
string
= 26851; index < CUSTOM_SIMULATIONS.length; index++,
string
++) {
70
Simulation
simuation = CUSTOM_SIMULATIONS[index];
71
String name =
Utility
.
formatEnum
(simuation.name());
72
73
player.send(
new
SendTooltip
(
"Open simulator for "
+ name,
string
));
74
player.send(
new
SendString
(name,
string
));
75
}
76
77
List<String> npc =
new
ArrayList<>();
78
List<Integer> button =
new
ArrayList<>();
79
for
(
NpcDefinition
definition :
NpcDefinition
.
DEFINITIONS
) {
80
if
(npc.size() >= 50)
81
break
;
82
if
(definition ==
null
)
83
continue
;
84
if
(!NpcDropManager.NPC_DROPS.containsKey(definition.
getId
())) {
85
continue
;
86
}
87
if
(!definition.
getName
().toLowerCase().contains(context.toLowerCase())) {
88
continue
;
89
}
90
if
(npc.contains(definition.
getName
()))
91
continue
;
92
npc.add(definition.
getName
());
93
button.add(definition.
getId
());
94
}
95
int
size = npc.size() < 14 ? 14 : npc.size();
96
for
(
int
index = 0,
string
= 26851 + CUSTOM_SIMULATIONS.length; index < size; index++,
string
++) {
97
String name = index >= npc.size() ?
""
: npc.get(index);
98
player.send(
new
SendTooltip
(name.isEmpty() ?
""
:
"Open drop simulator for "
+ name,
string
));
99
player.send(
new
SendString
(name,
string
));
100
}
101
player.attributes.set(
"DROP_SIMULATOR_BUTTON_KEY"
, button);
102
player.send(
new
SendScrollbar
(26850, size * 15));
103
}
104
106
public
static
void
simulate
(
Player
player,
Simulation
simulation,
int
id
,
int
amount) {
107
simulation.execute(player,
id
, amount);
108
}
109
}
com.osroyale.content.simulator.DropSimulator
Definition
DropSimulator.java:50
com.osroyale.content.simulator.DropSimulator.drawList
static void drawList(Player player, String context)
Definition
DropSimulator.java:68
com.osroyale.content.simulator.DropSimulator.simulate
static void simulate(Player player, Simulation simulation, int id, int amount)
Definition
DropSimulator.java:106
com.osroyale.content.simulator.DropSimulator.open
static void open(Player player)
Definition
DropSimulator.java:58
com.osroyale.game.world.entity.mob.npc.definition.NpcDefinition
Definition
NpcDefinition.java:59
com.osroyale.game.world.entity.mob.npc.definition.NpcDefinition.DEFINITIONS
static final NpcDefinition[] DEFINITIONS
Definition
NpcDefinition.java:62
com.osroyale.game.world.entity.mob.npc.definition.NpcDefinition.getName
String getName()
Definition
NpcDefinition.java:295
com.osroyale.game.world.entity.mob.npc.definition.NpcDefinition.get
static NpcDefinition get(int id)
Definition
NpcDefinition.java:249
com.osroyale.game.world.entity.mob.npc.definition.NpcDefinition.getId
int getId()
Definition
NpcDefinition.java:290
com.osroyale.game.world.entity.mob.player.InterfaceManager.open
void open(int identification)
Definition
InterfaceManager.java:66
com.osroyale.game.world.entity.mob.player.Player
Definition
Player.java:162
com.osroyale.net.packet.out.SendScrollbar
Definition
SendScrollbar.java:27
com.osroyale.net.packet.out.SendString
Definition
SendString.java:39
com.osroyale.net.packet.out.SendTooltip
Definition
SendTooltip.java:30
com.osroyale.util.Utility
Definition
Utility.java:64
com.osroyale.util.Utility.randomElement
static< T > T randomElement(Collection< T > collection)
Definition
Utility.java:285
com.osroyale.util.Utility.formatEnum
static String formatEnum(final String string)
Definition
Utility.java:126
com.osroyale.content.simulator.Simulation
Definition
Simulation.java:46