RuneHive-Game
Loading...
Searching...
No Matches
PlayerTitle.java
Go to the documentation of this file.
1package com.runehive.content.tittle;
2
3import java.util.Objects;
4
5/**
6 * The player title class.
7 *
8 * @author Daniel.
9 */
10public final class PlayerTitle {
11
12 /** An empty title. */
13 private static final PlayerTitle EMPTY = new PlayerTitle("", 0xC74C1C);
14
15 /** The title string. */
16 private final String title;
17
18 /** The title color. */
19 private final int color;
20
21 /** Constructs a new <code>PlayerTitle</code>. */
22 private PlayerTitle(String title, int color) {
23 this.title = title;
24 this.color = color;
25 }
26
27 /** Creates a player title. */
28 public static PlayerTitle create(String title, int color) {
29 return new PlayerTitle(title, color);
30 }
31
32 /** Creates a player title. */
33 public static PlayerTitle create(String title) {
34 return new PlayerTitle(title, 0xC74C1C);
35 }
36
37 /** Creates an empty player title. */
38 public static PlayerTitle empty() {
39 return EMPTY;
40 }
41
42 /** Gets the title. */
43 public String getTitle() {
44 return title;
45 }
46
47 /** Gets the color. */
48 public int getColor() {
49 return color;
50 }
51
52 @Override
53 public boolean equals(Object obj) {
54 if (!(obj instanceof PlayerTitle))
55 return false;
56 final PlayerTitle other = (PlayerTitle) obj;
57 return title.equals(other.getTitle()) && other.getColor() == getColor();
58 }
59
60 @Override
61 public int hashCode() {
62 return Objects.hash(title, color);
63 }
64}
static final PlayerTitle EMPTY
An empty title.
static PlayerTitle create(String title, int color)
Creates a player title.
PlayerTitle(String title, int color)
Constructs a new PlayerTitle.
static PlayerTitle create(String title)
Creates a player title.
static PlayerTitle empty()
Creates an empty player title.
final String title
The title string.