RuneHive-Game
Loading...
Searching...
No Matches
ProfileViewer.java
Go to the documentation of this file.
1package com.runehive.content;
2
3import com.runehive.content.achievement.AchievementHandler;
4import com.runehive.game.world.entity.mob.player.Player;
5import com.runehive.game.world.entity.mob.player.PlayerRight;
6import com.runehive.game.world.entity.skill.Skill;
7import com.runehive.net.packet.out.SendMessage;
8import com.runehive.net.packet.out.SendPlayerIndex;
9import com.runehive.net.packet.out.SendString;
10import com.runehive.net.packet.out.SendTooltip;
11import com.runehive.util.Utility;
12
13import java.util.Optional;
14
15/**
16 * Handles viewing other player's profiles.
17 *
18 * @author Daniel
19 */
20public class ProfileViewer {
21
22 /** Gets the main strings to display. */
23 public static String[] string(Player player) {
24 return new String[]{
25 "Created: ", player.created,
26 "Total play time:", Utility.getTime(player.playTime),
27 "Networth:", "" + Utility.formatPrice(player.playerAssistant.networth()),
28 "Clan:", player.clanChannel == null ? "None" : player.clanChannel.getName(),
29 "Total level:", "" + Utility.formatDigits(player.skills.getTotalLevel()),
30 "Kills/Deaths/KDR", "" + player.kill + "/" + player.death + "/" + player.playerAssistant.kdr() + "",
31 "Current KC:", "" + player.killstreak.streak,
32 "Vote Points:", "" + Utility.formatDigits(player.votePoints),
33 "Total Votes:", "" + Utility.formatDigits(player.totalVotes),
34 "Skilling Points:", "" + Utility.formatDigits(player.skillingPoints),
35 "Mage's Arena Points:", "" + Utility.formatDigits(player.mageArenaPoints),
36 "Pest Control Points:", "" + Utility.formatDigits(player.pestPoints),
37 "Achievements Completed:", "" + AchievementHandler.getTotalCompleted(player) + "",
38 };
39 }
40
41 /** Opens the profile interface. */
42 public static void open(Player player, Player other) {
43 if (!other.getPosition().isWithinDistance(player.getPosition(), 26)) {
44 player.message("You must get closer to that player if you want to view their profile!");
45 return;
46 }
47
48 if (player.getCombat().inCombat()) {
49 player.send(new SendMessage("You can't view profiles whilst in combat!"));
50 return;
51 }
52
53 for (int index = 0, string = 51832; index < Skill.SKILL_COUNT; index++, string += 2) {
54 Skill skill = other.skills.get(index);
55 String color = Integer.toHexString(other.prestige.getPrestigeColor(index));
56 player.send(new SendString(skill.getMaxLevel() + "<col=" + color + "></col>/<col=" + color + ">" + skill.getMaxLevel(), string));
57 }
58
59 int string = 51902;
60 for (String context : string(other)) {
61 player.send(new SendString(context, string));
62 string += 2;
63 }
64
65 if (PlayerRight.isModerator(player) && !player.equals(other)) {
66 player.send(new SendString("Manage Player: " + other.getName(), 51811));
67 player.send(new SendTooltip("Manage Player: " + other.getName(), 51811));
68 player.managing = Optional.of(other);
69 } else {
70 player.send(new SendString("", 51811));
71 player.send(new SendTooltip("", 51811));
72 }
73
74 player.send(new SendPlayerIndex(other.getIndex()));
75 player.send(new SendString("", 51810));
76 player.send(new SendString("</col>Name: <col=FFB83F>" + other.getName(), 51807));
77 player.send(new SendString("</col>Rank: <col=FFB83F>" + PlayerRight.getCrown(other) + " " + other.right.getName(), 51808));
78 player.send(new SendString("</col>Level: <col=FFB83F>" + other.skills.getCombatLevel(), 51809));
79 player.send(new SendMessage("You are now viewing " + other.getName() + "'s profile."));
80 player.interfaceManager.open(51800);
81 }
82}
Handles viewing other player's profiles.
static void open(Player player, Player other)
Opens the profile interface.
static String[] string(Player player)
Gets the main strings to display.
static int getTotalCompleted(Player player)
Gets the total amount of achievements completed.
int getPrestigeColor(int skill)
Gets the current prestige color of the player.
void open(int identification)
Opens an interface for the player.
This class represents a character controlled by a player.
Definition Player.java:125
String getName()
Gets the name of this entity.
Definition Player.java:774
Combat< Player > getCombat()
The combat of the mob.
Definition Player.java:759
Represents a trainable and usable skill.
Definition Skill.java:18
static final int SKILL_COUNT
The amount of available skills.
Definition Skill.java:90
int getCombatLevel()
Gets the mob's combat level.
Skill get(int id)
Gets the skill for an id.
int getTotalLevel()
Gets the total level of the mob.
boolean isWithinDistance(Position other, int radius)
Checks if this location is within range of another.
The OutgoingPacket that sends a message to a Players chatbox in the client.
Sends a player index to the client.
The OutgoingPacket that sends a string to a Players itemcontainer in the client.
Handles miscellaneous methods.
Definition Utility.java:27
static String formatDigits(final int amount)
Formats digits for integers.
Definition Utility.java:41
static String getTime()
Gets the current server time and formats it.
Definition Utility.java:141
static String formatPrice(final long amount)
Formats a price for longs.
Definition Utility.java:56
static String getCrown(Player player)
Gets the crown display.
static boolean isModerator(Player player)
Checks if the player is a management member.