1package com.osroyale.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.osroyale.game.world.entity.mob.player.Player;
8import com.osroyale.game.world.entity.mob.player.PlayerRight;
9import com.osroyale.game.world.World;
10import com.osroyale.game.world.items.Item;
11import com.osroyale.net.packet.out.*;
12import com.osroyale.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;
62* This
class handles the fame system.
82 player.send(
new SendMessage(
"Congratulations, you have left your mark on the hall of fame!"));
107 Map<FameEntry, Fame> hall =
new HashMap<>();
108 for (Entry<FameEntry, Fame> entries :
HALL_OF_FAME.entrySet()) {
109 if (entries.getKey().getType() == type)
110 hall.put(entries.getKey(), entries.getValue());
125 if (fame.getKey().name().equalsIgnoreCase(entry.name())) {
126 result = fame.getValue();
144 Item[] items =
new Item[entry_list.size()];
146 for (
int index = 0; index < entry_list.size(); index++) {
147 FameEntry display = entry_list.get(index);
148 Fame fame = getEntry(display);
150 items[index] =
new Item(display.
getDisplay());
160 player.send(
new SendConfig(1150, type.ordinal()));
162 player.send(
new SendString(
"<col=" + (type.ordinal() == 0 ?
"ffffff" :
"ff9933") +
">Player Killing", 58515));
163 player.send(
new SendString(
"<col=" + (type.ordinal() == 1 ?
"ffffff" :
"ff9933") +
">Monster Killing", 58516));
164 player.send(
new SendString(
"<col=" + (type.ordinal() == 2 ?
"ffffff" :
"ff9933") +
">Skilling", 58517));
165 player.send(
new SendString(
"<col=" + (type.ordinal() == 3 ?
"ffffff" :
"ff9933") +
">Miscellaneous", 58518));
167 player.send(
new SendScrollbar(58530, (entry_list.size() * 34)));
168 player.interfaceManager.
open(58500);
181 for (Entry<FameEntry, Fame> entries :
HALL_OF_FAME.entrySet()) {
182 if (entries.getValue().getName().equalsIgnoreCase(context)) {
187 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) +
".";
195 Type type =
new TypeToken<Map<FameEntry, Fame>>() {
198 Path path = Paths.get(
"data",
"/content/fame/hall_of_fame_list.json");
199 try (FileReader reader =
new FileReader(path.toFile())) {
200 JsonParser parser =
new JsonParser();
201 HALL_OF_FAME =
new GsonBuilder().create().fromJson(parser.parse(reader), type);
202 }
catch (Exception e) {
211 Gson gson =
new GsonBuilder().setPrettyPrinting().disableHtmlEscaping().create();
212 try (FileWriter fw =
new FileWriter(
"./data/content/fame/hall_of_fame_list.json")) {
214 }
catch (
final Exception e) {
static void open(Player player, FameType type)
static void activate(Player player, FameEntry fameEntry)
static Map< FameEntry, Fame > HALL_OF_FAME
static Map< FameEntry, Fame > getEntries(FameType type)
static void search(Player player, String context)
static void sendBroadcast(int time, String message, boolean countdown)
void open(int identification)
static List< FameEntry > getEntries(FameType type)
static String getCrown(Player player)