RuneHive-Tarnish
Neural OSRS Enhancement Framework
Loading...
Searching...
No Matches
BuildableInterface.java
1package com.osroyale.content.skill.impl.construction;
2
3import com.osroyale.net.packet.out.SendItemOnInterface;
4import com.osroyale.net.packet.out.SendString;
5import com.osroyale.game.world.entity.mob.player.Player;
6import com.osroyale.game.world.object.GameObjectDefinition;
7import com.osroyale.util.Utility;
8
9import java.util.List;
10
32
33public class BuildableInterface {
34
35 public static void open(Player player, BuildableType type) {
36 player.attributes.set("CONSTRUCTION_BUILDTYPE_KEY", type);
37 refresh(player, 0, type);
38 click(player, -17995);
39 player.interfaceManager.open(47500);
40 }
41
42 public static void click(Player player, int button) {
43 int index = Math.abs((-17995 - button));
44 BuildableType type = player.attributes.get("CONSTRUCTION_BUILDTYPE_KEY", BuildableType.class);
45 List<BuildableObject> list = BuildableObject.get(type);
46
47 if (index >= list.size()) {
48 return;
49 }
50
51 display(player, list.get(index));
52 refresh(player, index, type);
53 }
54
55 public static void display(Player player, BuildableObject object) {
56 player.send(new SendString(object == null ? "" : "" + object.getName(), 47515));
57 player.send(new SendString(object == null ? "" : "</col>Size: <col=5cf442>" + GameObjectDefinition.forId(object.getObject()).getWidth(), 47518));
58 player.send(new SendString(object == null ? "" : "</col>Level: <col=5cf442>" + Utility.formatDigits(object.getLevel()), 47519));
59 player.send(new SendString(object == null ? "" : "</col>Experience: <col=5cf442>" + Utility.formatDigits(object.getExperience()), 47520));
60 player.send(new SendItemOnInterface(47517, object == null ? null : object.getItems()));
61 player.attributes.set("CONSTRUCTION_BUILDOBJECT_KEY", object);
62 }
63
64 public static void refresh(Player player, int selected, BuildableType type) {
65 List<BuildableObject> list = BuildableObject.get(type);
66
67 for (int index = 0; index < 50; index++) {
68 String name = index >= list.size() ? "" : ((selected == index ? "<col=5cf442>" : "</col>") + list.get(index).getName());
69 player.send(new SendString(name, 47541 + index));
70 }
71
72 player.send(new SendString("Total object: " + list.size(), 47514));
73 }
74}
static String formatDigits(final int amount)
Definition Utility.java:78