1package com.runehive.content.famehall;
3import com.google.gson.Gson;
4import com.google.gson.GsonBuilder;
5import com.google.gson.JsonParser;
6import com.google.gson.reflect.TypeToken;
7import com.runehive.game.world.entity.mob.player.Player;
8import com.runehive.game.world.entity.mob.player.PlayerRight;
9import com.runehive.game.world.World;
10import com.runehive.game.world.items.Item;
11import com.runehive.net.packet.out.*;
12import com.runehive.util.Utility;
14import java.io.FileReader;
15import java.io.FileWriter;
16import java.lang.reflect.Type;
17import java.nio.file.Path;
18import java.nio.file.Paths;
19import java.util.HashMap;
22import java.util.Map.Entry;
45 player.
send(
new SendMessage(
"Congratulations, you have left your mark on the hall of fame!"));
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());
88 if (fame.getKey().name().equalsIgnoreCase(entry.name())) {
89 result = fame.getValue();
107 Item[] items =
new Item[entry_list.size()];
109 for (
int index = 0; index < entry_list.size(); index++) {
110 FameEntry display = entry_list.get(index);
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));
144 for (Entry<FameEntry, Fame> entries :
HALL_OF_FAME.entrySet()) {
145 if (entries.getValue().getName().equalsIgnoreCase(context)) {
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) +
".";
158 Type type =
new TypeToken<Map<FameEntry, Fame>>() {
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) {
174 Gson gson =
new GsonBuilder().setPrettyPrinting().disableHtmlEscaping().create();
175 try (FileWriter fw =
new FileWriter(
"./data/content/fame/hall_of_fame_list.json")) {
177 }
catch (
final Exception e) {
This class handles the fame system.
static void search(Player player, String context)
Searches through all the fame entries for a specific player.
static void activate(Player player, FameEntry fameEntry)
Checks if player should be entered in the hall of fame.
static Fame getEntry(FameEntry entry)
Gets the fame by the fame entry.
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 Map< FameEntry, Fame > HALL_OF_FAME
Holds the hall of fame entries.
static void save()
Saves the hall of fames into a json file.
String getName()
Gets the player name.
String getAccomplished()
Gets the accomplished date.
Represents the game world.
static void sendBroadcast(int time, String message, boolean countdown)
Sends a game message.
void open(int identification)
Opens an interface for the player.
This class represents a character controlled by a player.
String getName()
Gets the name of this entity.
final InterfaceManager interfaceManager
void send(OutgoingPacket encoder)
The container class that represents an item that can be interacted with.
The OutgoingPacket responsible for changing settings on a client.
The OutgoingPacket that sends a message to a Players chatbox in the client.
The OutgoingPacket that sends a string to a Players itemcontainer in the client.
Handles miscellaneous methods.
static String formatName(final String input)
static String getDate()
Gets the date of server.
Holds all the fame entries.
String getEntry()
Gets the entry string.
static List< FameEntry > getEntries(FameType type)
Gets all the entries based on the fame type.
int getDisplay()
Gets the display item.
FameType getType()
Gets the fame type.
All the hall of fame types.
Holds all the player right data.
static String getCrown(Player player)
Gets the crown display.