Skip to content

Commit

Permalink
Updated Metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
LOOHP committed Aug 15, 2020
1 parent d9e4069 commit b7cfea7
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/com/loohp/interactivechat/InteractiveChat.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import java.util.Optional;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicLong;

import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
Expand Down Expand Up @@ -142,6 +143,8 @@ public class InteractiveChat extends JavaPlugin {
public static boolean useCustomPlaceholderPermissions = false;

public static Optional<Character> chatAltColorCode = Optional.empty();

public static AtomicLong messagesCounter = new AtomicLong(0);

@Override
public void onEnable() {
Expand Down
1 change: 1 addition & 0 deletions src/com/loohp/interactivechat/Listeners/ChatPackets.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public static void chatMessageListener() {
InteractiveChat.protocolManager.addPacketListener(new PacketAdapter(InteractiveChat.plugin, ListenerPriority.MONITOR, PacketType.Play.Server.CHAT) {
@Override
public void onPacketSending(PacketEvent event) {
InteractiveChat.messagesCounter.getAndIncrement();
int debug = 0;
try {
if (!event.getPacketType().equals(PacketType.Play.Server.CHAT)) {
Expand Down
8 changes: 8 additions & 0 deletions src/com/loohp/interactivechat/Metrics/Charts.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@ public Integer call() throws Exception {
}
}));

metrics.addCustomChart(new Metrics.SingleLineChart("total_amount_of_chat_messages_processing_per_interval", new Callable<Integer>() {
@Override
public Integer call() throws Exception {
long amount = InteractiveChat.messagesCounter.getAndSet(0);
return amount > Integer.MAX_VALUE ? Integer.MAX_VALUE : (int) amount;
}
}));

}

}

0 comments on commit b7cfea7

Please sign in to comment.