RuneHive-Game
Loading...
Searching...
No Matches
ActivityLogger.java
Go to the documentation of this file.
1package com.runehive.content;
2
3import com.runehive.game.world.entity.mob.player.Player;
4import com.runehive.net.packet.out.SendScrollbar;
5import com.runehive.net.packet.out.SendString;
6import com.runehive.util.Utility;
7
8
9/**
10 * Handles displaying player's activity log.
11 *
12 * @author Daniel
13 */
14public class ActivityLogger {
15 private final Player player;
16
18 this.player = player;
19 }
20
21 public void add(ActivityLog log) {
22 add(log, 1);
23 }
24
25 public void add(ActivityLog log, int amount) {
26 int current = player.loggedActivities.computeIfAbsent(log, a -> 0);
27 player.loggedActivities.put(log, current + amount);
28 player.message("Your " + Utility.formatEnum(log.name()) + " count is now <col=FF0000>" + get(log) + "</col>.");
29 }
30
31 public int get(ActivityLog log) {
32 if (!player.loggedActivities.containsKey(log)) {
33 player.loggedActivities.put(log, 0);
34 }
35 return player.loggedActivities.get(log);
36 }
37
38 public void open() {
39 for (int index = 0, string = 37111; index < 80; index++) {
40 player.send(new SendString("", string));
41 string++;
42 player.send(new SendString("", string));
43 string++;
44 }
45
46 int string = 37111;
47 for (ActivityLog log : ActivityLog.values()) {
48 player.send(new SendString(Utility.formatEnum(log.name()) + ": <col=255>" + Utility.formatDigits(get(log)), string));
49 string++;
50 }
51
52 player.send(new SendString("", 37107));
53 player.send(new SendString("Activity Logger", 37103));
54 player.send(new SendScrollbar(37110, (player.loggedActivities.size() * 55)));
55 player.interfaceManager.open(37100);
56 }
57}
58
void add(ActivityLog log, int amount)
This class represents a character controlled by a player.
Definition Player.java:125
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 formatEnum(final String string)
Formats name of enum.
Definition Utility.java:89
The activity log class.