This class handles the fame system.
More...
|
| static void | activate (Player player, FameEntry fameEntry) |
| | Checks if player should be entered in the hall of fame.
|
| static Map< FameEntry, Fame > | getEntries (FameType type) |
| | Filters the hall of fame entries for a certain fame type.
|
| static void | load () |
| | Loads the hall of fames and puts them into the map.
|
| static void | open (Player player, FameType type) |
| | Opens the hall of fame itemcontainer.
|
| static void | remove (FameEntry fameEntry) |
| | Removes a fame entry from the hall of fame.
|
| static void | save () |
| | Saves the hall of fames into a json file.
|
| static void | search (Player player, String context) |
| | Searches through all the fame entries for a specific player.
|
This class handles the fame system.
- Author
- Daniel
Definition at line 29 of file FameHandler.java.
◆ activate()
| void com.runehive.content.famehall.FameHandler.activate |
( |
Player | player, |
|
|
FameEntry | fameEntry ) |
|
static |
Checks if player should be entered in the hall of fame.
- Parameters
-
| player | The player instance. |
| fameEntry | The fame entry. |
Definition at line 42 of file FameHandler.java.
42 {
43 if (!HALL_OF_FAME.containsKey(fameEntry)) {
44 HALL_OF_FAME.put(fameEntry,
new Fame(fameEntry.getType(), PlayerRight.getCrown(player) +
" " + player.
getName(), Utility.getDate()));
45 player.
send(
new SendMessage(
"Congratulations, you have left your mark on the hall of fame!"));
46 World.sendBroadcast(1, player.
getName() +
" is now on the hall of fame for " + fameEntry.getEntry(),
false);
47 save();
48 }
49 }
String getName()
Gets the name of this entity.
void send(OutgoingPacket encoder)
References com.runehive.game.world.entity.mob.player.PlayerRight.getCrown(), com.runehive.util.Utility.getDate(), com.runehive.content.famehall.FameEntry.getEntry(), com.runehive.game.world.entity.mob.player.Player.getName(), com.runehive.content.famehall.FameEntry.getType(), HALL_OF_FAME, save(), com.runehive.game.world.entity.mob.player.Player.send(), and com.runehive.game.world.World.sendBroadcast().
◆ getEntries()
Filters the hall of fame entries for a certain fame type.
- Parameters
-
| type | The fame type to filer. |
- Returns
- Map of all the entries.
Definition at line 69 of file FameHandler.java.
69 {
70 Map<FameEntry, Fame> hall = new HashMap<>();
71 for (Entry<FameEntry, Fame> entries : HALL_OF_FAME.entrySet()) {
72 if (entries.getKey().getType() == type)
73 hall.put(entries.getKey(), entries.getValue());
74 }
75 return hall;
76 }
References HALL_OF_FAME.
Referenced by getEntry().
◆ getEntry()
| Fame com.runehive.content.famehall.FameHandler.getEntry |
( |
FameEntry | entry | ) |
|
|
staticprivate |
Gets the fame by the fame entry.
- Parameters
-
- Returns
- The fame.
Definition at line 85 of file FameHandler.java.
85 {
86 Fame result = null;
87 for (Entry<FameEntry, Fame> fame : getEntries(entry.getType()).entrySet()) {
88 if (fame.getKey().name().equalsIgnoreCase(entry.name())) {
89 result = fame.getValue();
90 break;
91 }
92 }
93 return result;
94 }
References getEntries(), and com.runehive.content.famehall.FameEntry.getType().
Referenced by open().
◆ load()
| void com.runehive.content.famehall.FameHandler.load |
( |
| ) |
|
|
static |
Loads the hall of fames and puts them into the map.
Definition at line 157 of file FameHandler.java.
157 {
158 Type type = new TypeToken<Map<FameEntry, Fame>>() {
159 }.getType();
160
161 Path path = Paths.get("data", "/content/fame/hall_of_fame_list.json");
162 try (FileReader reader = new FileReader(path.toFile())) {
163 JsonParser parser = new JsonParser();
164 HALL_OF_FAME = new GsonBuilder().create().fromJson(parser.parse(reader), type);
165 } catch (Exception e) {
166 e.printStackTrace();
167 }
168 }
References HALL_OF_FAME.
◆ open()
| void com.runehive.content.famehall.FameHandler.open |
( |
Player | player, |
|
|
FameType | type ) |
|
static |
Opens the hall of fame itemcontainer.
- Parameters
-
| player | The player instance. |
| type | The fame type tab. |
Definition at line 104 of file FameHandler.java.
104 {
105 int string = 58533;
106 List<FameEntry> entry_list = FameEntry.getEntries(type);
107 Item[] items = new Item[entry_list.size()];
108
109 for (
int index = 0;
index < entry_list.size();
index++) {
110 FameEntry display = entry_list.get(index);
111 Fame fame = getEntry(display);
112
113 items[
index] =
new Item(display.getDisplay());
114 player.
send(
new SendString(display ==
null ?
"" : display.getEntry(),
string));
115 string++;
116 player.
send(
new SendString(fame ==
null ?
"---" : fame.getName(),
string));
117 string++;
118 player.
send(
new SendString(fame ==
null ?
"---" : fame.getAccomplished(),
string));
119 string++;
120 string++;
121 }
122
123 player.
send(
new SendConfig(1150, type.ordinal()));
124 player.
send(
new SendString(HALL_OF_FAME.size() +
"/" + FameEntry.values().length +
" Remaining", 58523));
125 player.
send(
new SendString(
"<col=" + (type.ordinal() == 0 ?
"ffffff" :
"ff9933") +
">Player Killing", 58515));
126 player.
send(
new SendString(
"<col=" + (type.ordinal() == 1 ?
"ffffff" :
"ff9933") +
">Monster Killing", 58516));
127 player.
send(
new SendString(
"<col=" + (type.ordinal() == 2 ?
"ffffff" :
"ff9933") +
">Skilling", 58517));
128 player.
send(
new SendString(
"<col=" + (type.ordinal() == 3 ?
"ffffff" :
"ff9933") +
">Miscellaneous", 58518));
129 player.
send(
new SendItemOnInterface(58531, items));
130 player.
send(
new SendScrollbar(58530, (entry_list.size() * 34)));
132 }
void open(int identification)
Opens an interface for the player.
final InterfaceManager interfaceManager
References com.runehive.content.famehall.Fame.getAccomplished(), com.runehive.content.famehall.FameEntry.getDisplay(), com.runehive.content.famehall.FameEntry.getEntries(), com.runehive.content.famehall.FameEntry.getEntry(), getEntry(), com.runehive.content.famehall.Fame.getName(), HALL_OF_FAME, com.runehive.game.world.entity.mob.player.Player.interfaceManager, com.runehive.game.world.entity.mob.player.InterfaceManager.open(), and com.runehive.game.world.entity.mob.player.Player.send().
◆ remove()
| void com.runehive.content.famehall.FameHandler.remove |
( |
FameEntry | fameEntry | ) |
|
|
static |
Removes a fame entry from the hall of fame.
- Parameters
-
| fameEntry | The fame entry to withdraw. |
Definition at line 57 of file FameHandler.java.
57 {
58 if (HALL_OF_FAME.containsKey(fameEntry))
59 HALL_OF_FAME.remove(fameEntry);
60 }
References HALL_OF_FAME.
◆ save()
| void com.runehive.content.famehall.FameHandler.save |
( |
| ) |
|
|
static |
Saves the hall of fames into a json file.
Definition at line 173 of file FameHandler.java.
173 {
174 Gson
gson =
new GsonBuilder().setPrettyPrinting().disableHtmlEscaping().create();
175 try (FileWriter fw = new FileWriter("./data/content/fame/hall_of_fame_list.json")) {
176 fw.write(
gson.toJson(HALL_OF_FAME));
177 } catch (final Exception e) {
178 e.printStackTrace();
179 }
180 }
val object_examines.json val gson
References HALL_OF_FAME.
Referenced by activate().
◆ search()
| void com.runehive.content.famehall.FameHandler.search |
( |
Player | player, |
|
|
String | context ) |
|
static |
Searches through all the fame entries for a specific player.
- Parameters
-
| player | The player instance. |
| context | The context being searched. |
Definition at line 142 of file FameHandler.java.
142 {
144 for (Entry<FameEntry, Fame> entries : HALL_OF_FAME.entrySet()) {
145 if (entries.getValue().getName().equalsIgnoreCase(context)) {
147 }
148 }
149
150 String message =
index == 0 ? Utility.formatName(context) +
" was not found in the hall of fame." :
index +
" entries were found in the hall of fame for " + Utility.formatName(context) +
".";
151 player.
send(
new SendMessage(message));
152 }
References com.runehive.util.Utility.formatName(), HALL_OF_FAME, and com.runehive.game.world.entity.mob.player.Player.send().
◆ HALL_OF_FAME
| Map<FameEntry, Fame> com.runehive.content.famehall.FameHandler.HALL_OF_FAME = new HashMap<>() |
|
static |
The documentation for this class was generated from the following file: