RuneHive-Game
Loading...
Searching...
No Matches
BuildableInterface.java
Go to the documentation of this file.
1package com.runehive.content.skill.impl.construction;
2
3import com.runehive.net.packet.out.SendItemOnInterface;
4import com.runehive.net.packet.out.SendString;
5import com.runehive.game.world.entity.mob.player.Player;
6import com.runehive.game.world.object.GameObjectDefinition;
7import com.runehive.util.Utility;
8
9import java.util.List;
10
11public class BuildableInterface {
12
13 public static void open(Player player, BuildableType type) {
14 player.attributes.set("CONSTRUCTION_BUILDTYPE_KEY", type);
15 refresh(player, 0, type);
16 click(player, -17995);
17 player.interfaceManager.open(47500);
18 }
19
20 public static void click(Player player, int button) {
21 int index = Math.abs((-17995 - button));
22 BuildableType type = player.attributes.get("CONSTRUCTION_BUILDTYPE_KEY", BuildableType.class);
23 List<BuildableObject> list = BuildableObject.get(type);
24
25 if (index >= list.size()) {
26 return;
27 }
28
29 display(player, list.get(index));
30 refresh(player, index, type);
31 }
32
33 public static void display(Player player, BuildableObject object) {
34 player.send(new SendString(object == null ? "" : "" + object.getName(), 47515));
35 player.send(new SendString(object == null ? "" : "</col>Size: <col=5cf442>" + GameObjectDefinition.forId(object.getObject()).getWidth(), 47518));
36 player.send(new SendString(object == null ? "" : "</col>Level: <col=5cf442>" + Utility.formatDigits(object.getLevel()), 47519));
37 player.send(new SendString(object == null ? "" : "</col>Experience: <col=5cf442>" + Utility.formatDigits(object.getExperience()), 47520));
38 player.send(new SendItemOnInterface(47517, object == null ? null : object.getItems()));
39 player.attributes.set("CONSTRUCTION_BUILDOBJECT_KEY", object);
40 }
41
42 public static void refresh(Player player, int selected, BuildableType type) {
43 List<BuildableObject> list = BuildableObject.get(type);
44
45 for (int index = 0; index < 50; index++) {
46 String name = index >= list.size() ? "" : ((selected == index ? "<col=5cf442>" : "</col>") + list.get(index).getName());
47 player.send(new SendString(name, 47541 + index));
48 }
49
50 player.send(new SendString("Total object: " + list.size(), 47514));
51 }
52}
static void display(Player player, BuildableObject object)
static void refresh(Player player, int selected, BuildableType type)
final GenericAttributes attributes
Definition Mob.java:95
void open(int identification)
Opens an interface for the player.
This class represents a character controlled by a player.
Definition Player.java:125
static GameObjectDefinition forId(int id)
Gets an object definition by its id.
The OutgoingPacket that sends a string to a Players itemcontainer in the client.
Handles miscellaneous methods.
Definition Utility.java:27
static String formatDigits(final int amount)
Formats digits for integers.
Definition Utility.java:41
public< K, E > E get(K key)
Gets a generic attribute.
public< K, E > void set(K key, E attribute)
Sets a generic attribute.
static List< BuildableObject > get(BuildableType type)