RuneHive-Game
Loading...
Searching...
No Matches
ActivityLogger.java
Go to the documentation of this file.
1
package
com.runehive.content;
2
3
import
com.runehive.game.world.entity.mob.player.Player;
4
import
com.runehive.net.packet.out.SendScrollbar;
5
import
com.runehive.net.packet.out.SendString;
6
import
com.runehive.util.Utility;
7
8
9
/**
10
* Handles displaying player's activity log.
11
*
12
* @author Daniel
13
*/
14
public
class
ActivityLogger
{
15
private
final
Player
player
;
16
17
public
ActivityLogger
(
Player
player
) {
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
com.runehive.content.ActivityLogger.player
final Player player
Definition
ActivityLogger.java:15
com.runehive.content.ActivityLogger.add
void add(ActivityLog log, int amount)
Definition
ActivityLogger.java:25
com.runehive.content.ActivityLogger.ActivityLogger
ActivityLogger(Player player)
Definition
ActivityLogger.java:17
com.runehive.content.ActivityLogger.open
void open()
Definition
ActivityLogger.java:38
com.runehive.content.ActivityLogger.add
void add(ActivityLog log)
Definition
ActivityLogger.java:21
com.runehive.game.world.entity.mob.player.Player
This class represents a character controlled by a player.
Definition
Player.java:125
com.runehive.net.packet.out.SendScrollbar
Definition
SendScrollbar.java:6
com.runehive.net.packet.out.SendString
The OutgoingPacket that sends a string to a Players itemcontainer in the client.
Definition
SendString.java:14
com.runehive.util.Utility
Handles miscellaneous methods.
Definition
Utility.java:27
com.runehive.util.Utility.formatDigits
static String formatDigits(final int amount)
Formats digits for integers.
Definition
Utility.java:41
com.runehive.util.Utility.formatEnum
static String formatEnum(final String string)
Formats name of enum.
Definition
Utility.java:89
com.runehive.content.ActivityLog
The activity log class.
Definition
ActivityLog.java:8