RuneHive-Game
Loading...
Searching...
No Matches
com.runehive.content.tittle.TitleManager Class Reference

Handles unlocking player titles. More...

Static Public Member Functions

static boolean click (Player player, int button)
 Handles clicking buttons on the title itemcontainer.
static void open (Player player)
 Opens the title itemcontainer.
static void redeem (Player player)
 Handles a player redeeming a title.
static void refresh (Player player)
 Handles refreshing (send all strings and data) the itemcontainer.
static void reset (Player player)
 Handles reseting the player title.

Static Private Attributes

static final int BUTTON_IDENTIFICATION = -26485
 The base button identification.

Detailed Description

Handles unlocking player titles.

Author
Daniel

Definition at line 13 of file TitleManager.java.

Member Function Documentation

◆ click()

boolean com.runehive.content.tittle.TitleManager.click ( Player player,
int button )
static

Handles clicking buttons on the title itemcontainer.

Definition at line 25 of file TitleManager.java.

25 {
26 int ordinal = (button - BUTTON_IDENTIFICATION) / 2;
27 if (Title.forOrdinal(ordinal).isPresent()) {
28 player.attributes.set("PLAYER_TITLE_KEY", ordinal);
29 refresh(player);
30 return true;
31 }
32 return false;
33 }
final GenericAttributes attributes
Definition Mob.java:95
public< K, E > void set(K key, E attribute)
Sets a generic attribute.

References com.runehive.game.world.entity.mob.Mob.attributes, BUTTON_IDENTIFICATION, com.runehive.content.tittle.Title.forOrdinal(), refresh(), and com.runehive.util.generic.GenericAttributes.set().

Here is the call graph for this function:

◆ open()

void com.runehive.content.tittle.TitleManager.open ( Player player)
static

Opens the title itemcontainer.

Definition at line 19 of file TitleManager.java.

19 {
20 refresh(player);
21 player.interfaceManager.open(39_000);
22 }
void open(int identification)
Opens an interface for the player.

References com.runehive.game.world.entity.mob.player.Player.interfaceManager, com.runehive.game.world.entity.mob.player.InterfaceManager.open(), and refresh().

Referenced by com.runehive.game.plugin.PluginContext.onClick().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ redeem()

void com.runehive.content.tittle.TitleManager.redeem ( Player player)
static

Handles a player redeeming a title.

Definition at line 69 of file TitleManager.java.

69 {
70 int ordinal = player.attributes.get("PLAYER_TITLE_KEY", Integer.class);
71 if (Title.forOrdinal(ordinal).isPresent()) {
72 Title title = Title.forOrdinal(ordinal).get();
73 if (!title.activated(player)) {
74 player.send(new SendMessage("You have not activated this title yet!"));
75 return;
76 }
77
78 player.playerTitle = title.getTitle();
79 player.updateFlags.add(UpdateFlag.APPEARANCE);
80 player.send(new SendMessage("You have successfully redeemed your title."));
81 }
82 }
final EnumSet< UpdateFlag > updateFlags
Definition Mob.java:94
public< K, E > E get(K key)
Gets a generic attribute.

References com.runehive.util.generic.BooleanInterface< T >.activated(), com.runehive.game.world.entity.mob.UpdateFlag.APPEARANCE, com.runehive.game.world.entity.mob.Mob.attributes, com.runehive.content.tittle.Title.forOrdinal(), com.runehive.util.generic.GenericAttributes.get(), com.runehive.content.tittle.Title.getTitle(), com.runehive.game.world.entity.mob.player.Player.send(), and com.runehive.game.world.entity.mob.Mob.updateFlags.

Here is the call graph for this function:

◆ refresh()

void com.runehive.content.tittle.TitleManager.refresh ( Player player)
static

Handles refreshing (send all strings and data) the itemcontainer.

Definition at line 36 of file TitleManager.java.

36 {
37 int ordinal = player.attributes.get("PLAYER_TITLE_KEY", Integer.class);
38 int string = 39_052;
39 int config = 750;
40 Title view = null;
41
42 for (Title title : Title.values()) {
43 if (title.ordinal() == ordinal) {
44 view = title;
45 }
46 player.send(new SendString((title.ordinal() == ordinal ? "<col=DEB07A>" : "<col=A8865E>") + title.getTitle().getTitle(), string));
47 player.send(new SendTooltip("View title: <col=db9423>" + title.getTitle().getTitle() + "</col>", string - 1));
48 player.send(new SendConfig(config, title.activated(player) ? 1 : 0));
49 string += 2;
50 config += 2;
51 }
52
53 if (view == null) {
54 return;
55 }
56
57 String color = Integer.toHexString(view.getTitle().getColor());
58 int scroll = Title.values().length * 26;
59
60 for (int index = 0; index < view.getRequirement().length; index++) {
61 player.send(new SendString(view.getRequirement()[index], 39006 + index));
62 }
63 player.send(new SendString("<col=" + (view.activated(player) ? "A1D490>- UNLOCKED -" : "E34F52>- LOCKED -"), 39019));
64 player.send(new SendString("<col=" + color + ">" + view.getTitle().getTitle() + "<col=DEB07A> " + Utility.formatName(player.getName()), 39_003));
65 player.send(new SendScrollbar(39_050, scroll));
66 }
String getName()
Gets the name of this entity.
Definition Player.java:774
val index

References com.runehive.util.generic.BooleanInterface< T >.activated(), com.runehive.game.world.entity.mob.Mob.attributes, com.runehive.util.Utility.formatName(), com.runehive.util.generic.GenericAttributes.get(), com.runehive.content.tittle.PlayerTitle.getColor(), com.runehive.game.world.entity.mob.player.Player.getName(), com.runehive.content.tittle.Title.getRequirement(), com.runehive.content.tittle.PlayerTitle.getTitle(), com.runehive.content.tittle.Title.getTitle(), and com.runehive.game.world.entity.mob.player.Player.send().

Referenced by click(), and open().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ reset()

void com.runehive.content.tittle.TitleManager.reset ( Player player)
static

Handles reseting the player title.

Definition at line 85 of file TitleManager.java.

85 {
86 player.playerTitle = PlayerTitle.empty();
87 player.updateFlags.add(UpdateFlag.APPEARANCE);
88 player.send(new SendMessage("You have successfully reset your title."));
89 }

References com.runehive.game.world.entity.mob.UpdateFlag.APPEARANCE, com.runehive.content.tittle.PlayerTitle.empty(), com.runehive.game.world.entity.mob.player.Player.send(), and com.runehive.game.world.entity.mob.Mob.updateFlags.

Here is the call graph for this function:

Member Data Documentation

◆ BUTTON_IDENTIFICATION

final int com.runehive.content.tittle.TitleManager.BUTTON_IDENTIFICATION = -26485
staticprivate

The base button identification.

Definition at line 16 of file TitleManager.java.

Referenced by click().


The documentation for this class was generated from the following file: