RuneHive-Tarnish
Neural OSRS Enhancement Framework
Loading...
Searching...
No Matches
DropSimulator.java
1package com.osroyale.content.simulator;
2
3import com.osroyale.game.world.entity.mob.npc.definition.NpcDefinition;
4import com.osroyale.game.world.entity.mob.npc.drop.NpcDropManager;
5import com.osroyale.game.world.entity.mob.player.Player;
6import com.osroyale.net.packet.out.SendScrollbar;
7import com.osroyale.net.packet.out.SendString;
8import com.osroyale.net.packet.out.SendTooltip;
9import com.osroyale.util.Utility;
10
11import java.util.ArrayList;
12import java.util.List;
13
14import 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 */
50public 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}
static void drawList(Player player, String context)
static void simulate(Player player, Simulation simulation, int id, int amount)
static< T > T randomElement(Collection< T > collection)
Definition Utility.java:285
static String formatEnum(final String string)
Definition Utility.java:126