Compare commits
9
Commits
v1.1.0
..
3d9c5a5e21
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3d9c5a5e21 | ||
|
|
e91797d9ac | ||
|
|
83b66ce262 | ||
|
|
1bad62513f | ||
|
|
50840bdfb7 | ||
|
|
f91d289d8a | ||
|
|
aca7a81ad3 | ||
|
|
ec07769ff8 | ||
|
|
b2558b8855 |
@@ -23,7 +23,7 @@ jobs:
|
||||
- name: Set up Node
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 20
|
||||
node-version: 22.14.0
|
||||
|
||||
- name: Install Node dependencies
|
||||
run: npm install
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
FROM gradle:8.14-jdk21
|
||||
FROM gradle:9.3-jdk21
|
||||
|
||||
WORKDIR /workspace
|
||||
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.4-bin.zip
|
||||
networkTimeout=10000
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
|
||||
+4
-4
@@ -2,10 +2,10 @@
|
||||
"name": "prometheus-spigot",
|
||||
"private": true,
|
||||
"devDependencies": {
|
||||
"@commitlint/cli": "^19.5.0",
|
||||
"@commitlint/config-conventional": "^19.5.0",
|
||||
"@semantic-release/exec": "^6.0.3",
|
||||
"@commitlint/cli": "^20.0.0",
|
||||
"@commitlint/config-conventional": "^20.0.0",
|
||||
"@semantic-release/exec": "^7.0.0",
|
||||
"@semantic-release/git": "^10.0.1",
|
||||
"semantic-release": "^23.1.1"
|
||||
"semantic-release": "^25.0.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import com.prometheus.spigot.listeners.CommandListener;
|
||||
import com.prometheus.spigot.listeners.ConnectionListener;
|
||||
import com.prometheus.spigot.listeners.CraftListener;
|
||||
import com.prometheus.spigot.listeners.DeathListener;
|
||||
import com.prometheus.spigot.listeners.EntityKillListener;
|
||||
import com.prometheus.spigot.listeners.MoveListener;
|
||||
import com.prometheus.spigot.listeners.PluginListener;
|
||||
import com.prometheus.spigot.metrics.MetricsRegistry;
|
||||
@@ -82,6 +83,7 @@ public final class PrometheusSpigotPlugin extends JavaPlugin {
|
||||
pluginManager.registerEvents(new ChunkListener(metricsRegistry), this);
|
||||
pluginManager.registerEvents(new PluginListener(metricsRegistry), this);
|
||||
pluginManager.registerEvents(new CraftListener(metricsRegistry), this);
|
||||
pluginManager.registerEvents(new EntityKillListener(metricsRegistry), this);
|
||||
}
|
||||
|
||||
private void startHttpServer() {
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.prometheus.spigot.listeners;
|
||||
|
||||
import com.prometheus.spigot.metrics.MetricsRegistry;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityDeathEvent;
|
||||
|
||||
public final class EntityKillListener implements Listener {
|
||||
private final MetricsRegistry registry;
|
||||
|
||||
public EntityKillListener(MetricsRegistry registry) {
|
||||
this.registry = registry;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onEntityDeath(EntityDeathEvent event) {
|
||||
Player killer = event.getEntity().getKiller();
|
||||
String killerLabel = killer != null ? killer.getName() : "null";
|
||||
registry.incrementEntityKill(event.getEntity().getType(), killerLabel);
|
||||
}
|
||||
}
|
||||
@@ -51,6 +51,7 @@ public final class MetricsRegistry {
|
||||
private final ConcurrentHashMap<String, LongAdder> commandsBlocked = new ConcurrentHashMap<>();
|
||||
private final ConcurrentHashMap<LabelPair, LongAdder> commandsExecuted = new ConcurrentHashMap<>();
|
||||
private final ConcurrentHashMap<String, LongAdder> itemsCraftedByMaterial = new ConcurrentHashMap<>();
|
||||
private final ConcurrentHashMap<LabelPair, LongAdder> entityKills = new ConcurrentHashMap<>();
|
||||
|
||||
public MetricsRegistry(Server server, boolean enableJvm, boolean enableProcess) {
|
||||
this.server = server;
|
||||
@@ -133,6 +134,12 @@ public final class MetricsRegistry {
|
||||
incrementLabeledCounter(itemsCraftedByMaterial, material.name());
|
||||
}
|
||||
|
||||
public void incrementEntityKill(EntityType entityType, String killer) {
|
||||
String normalizedEntity = normalizeLabel(entityType.name());
|
||||
String normalizedKiller = normalizeLabel(killer);
|
||||
entityKills.computeIfAbsent(new LabelPair(normalizedEntity, normalizedKiller), key -> new LongAdder()).increment();
|
||||
}
|
||||
|
||||
public void refreshEntitySnapshots() {
|
||||
Map<String, Long> entityCounts = new HashMap<>();
|
||||
Map<String, Long> tileCounts = new HashMap<>();
|
||||
@@ -184,6 +191,7 @@ public final class MetricsRegistry {
|
||||
appendLabeledCounterAdder(builder, "spigot_commands_blocked_total", "Blocked commands by name", "command", commandsBlocked);
|
||||
appendLabeledCounterAdder(builder, "spigot_commands_executed_total", "Commands executed by source", "command", "source", commandsExecuted);
|
||||
appendLabeledCounterAdder(builder, "spigot_items_crafted_total", "Items crafted by material", "material", itemsCraftedByMaterial);
|
||||
appendLabeledCounterAdder(builder, "spigot_entities_killed_total", "Entities killed by player", "entity", "killer", entityKills);
|
||||
|
||||
appendGauge(builder, "spigot_players_online", "Online player count", server.getOnlinePlayers().size());
|
||||
appendGauge(builder, "spigot_players_max", "Max player slots", server.getMaxPlayers());
|
||||
|
||||
Reference in New Issue
Block a user