RuneHive-Tarnish
Neural OSRS Enhancement Framework
Loading...
Searching...
No Matches
TitleManager.java
1package com.osroyale.content.tittle;
2
3import com.osroyale.game.world.entity.mob.UpdateFlag;
4import com.osroyale.game.world.entity.mob.player.Player;
5import com.osroyale.net.packet.out.*;
6import com.osroyale.util.Utility;
7
44
45public class TitleManager {
46
48 private final static int BUTTON_IDENTIFICATION = -26485;
49
51 public static void open(Player player) {
52 refresh(player);
53 player.interfaceManager.open(39_000);
54 }
55
57 public static boolean click(Player player, int button) {
58 int ordinal = (button - BUTTON_IDENTIFICATION) / 2;
59 if (Title.forOrdinal(ordinal).isPresent()) {
60 player.attributes.set("PLAYER_TITLE_KEY", ordinal);
61 refresh(player);
62 return true;
63 }
64 return false;
65 }
66
68 public static void refresh(Player player) {
69 int ordinal = player.attributes.get("PLAYER_TITLE_KEY", Integer.class);
70 int string = 39_052;
71 int config = 750;
72 Title view = null;
73
74 for (Title title : Title.values()) {
75 if (title.ordinal() == ordinal) {
76 view = title;
77 }
78 player.send(new SendString((title.ordinal() == ordinal ? "<col=DEB07A>" : "<col=A8865E>") + title.getTitle().getTitle(), string));
79 player.send(new SendTooltip("View title: <col=db9423>" + title.getTitle().getTitle() + "</col>", string - 1));
80 player.send(new SendConfig(config, title.activated(player) ? 1 : 0));
81 string += 2;
82 config += 2;
83 }
84
85 if (view == null) {
86 return;
87 }
88
89 String color = Integer.toHexString(view.getTitle().getColor());
90 int scroll = Title.values().length * 26;
91
92 for (int index = 0; index < view.getRequirement().length; index++) {
93 player.send(new SendString(view.getRequirement()[index], 39006 + index));
94 }
95 player.send(new SendString("<col=" + (view.activated(player) ? "A1D490>- UNLOCKED -" : "E34F52>- LOCKED -"), 39019));
96 player.send(new SendString("<col=" + color + ">" + view.getTitle().getTitle() + "<col=DEB07A> " + Utility.formatName(player.getName()), 39_003));
97 player.send(new SendScrollbar(39_050, scroll));
98 }
99
101 public static void redeem(Player player) {
102 int ordinal = player.attributes.get("PLAYER_TITLE_KEY", Integer.class);
103 if (Title.forOrdinal(ordinal).isPresent()) {
104 Title title = Title.forOrdinal(ordinal).get();
105 if (!title.activated(player)) {
106 player.send(new SendMessage("You have not activated this title yet!"));
107 return;
108 }
109
110 player.playerTitle = title.getTitle();
111 player.updateFlags.add(UpdateFlag.APPEARANCE);
112 player.send(new SendMessage("You have successfully redeemed your title."));
113 }
114 }
115
117 public static void reset(Player player) {
118 player.playerTitle = PlayerTitle.empty();
119 player.updateFlags.add(UpdateFlag.APPEARANCE);
120 player.send(new SendMessage("You have successfully reset your title."));
121 }
122}
static boolean click(Player player, int button)