forked from Minecraft/QoL
Switched to Spark for TPS alerts (#8)
Switched to Spark for TPS alerts + Currently just looks at tps, but we could hook in mspt + Fixes #6 Co-authored-by: Joey Hines <joey@ahines.net> Reviewed-on: https://git.canopymc.net/Canopy/QoL/pulls/8 Reviewed-by: Etzelia <etzelia@hotmail.com> Co-Authored-By: ZeroHD <joey@ahines.net> Co-Committed-By: ZeroHD <joey@ahines.net>benamaurer-chatchatDiscod
parent
3c3fdc1725
commit
e3cf0d6d9f
21
pom.xml
21
pom.xml
|
@ -3,7 +3,7 @@
|
||||||
<groupId>xyz.etztech</groupId>
|
<groupId>xyz.etztech</groupId>
|
||||||
<artifactId>QoL</artifactId>
|
<artifactId>QoL</artifactId>
|
||||||
<!-- Version is used in plugin.yml -->
|
<!-- Version is used in plugin.yml -->
|
||||||
<version>1.10</version>
|
<version>1.11</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<!-- Plugin Information -->
|
<!-- Plugin Information -->
|
||||||
|
@ -39,11 +39,6 @@
|
||||||
<artifactId>plugin-api</artifactId>
|
<artifactId>plugin-api</artifactId>
|
||||||
<version>1.0.7</version>
|
<version>1.0.7</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>net.ess3</groupId>
|
|
||||||
<artifactId>EssentialsX</artifactId>
|
|
||||||
<version>2.18.1</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>us.dynmap</groupId>
|
<groupId>us.dynmap</groupId>
|
||||||
<artifactId>dynmap-api</artifactId>
|
<artifactId>dynmap-api</artifactId>
|
||||||
|
@ -60,6 +55,12 @@
|
||||||
<version>1.19.1</version>
|
<version>1.19.1</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>me.lucko</groupId>
|
||||||
|
<artifactId>spark-api</artifactId>
|
||||||
|
<version>0.1-SNAPSHOT</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<repositories>
|
<repositories>
|
||||||
|
@ -78,10 +79,6 @@
|
||||||
<repository>
|
<repository>
|
||||||
<id>dynmap-repo</id>
|
<id>dynmap-repo</id>
|
||||||
<url>https://repo.mikeprimm.com/</url>
|
<url>https://repo.mikeprimm.com/</url>
|
||||||
</repository>
|
|
||||||
<repository>
|
|
||||||
<id>ess-repo</id>
|
|
||||||
<url>https://ci.ender.zone/plugin/repository/everything/</url>
|
|
||||||
</repository>
|
</repository>
|
||||||
<repository>
|
<repository>
|
||||||
<id>mvn-repo</id>
|
<id>mvn-repo</id>
|
||||||
|
@ -95,6 +92,10 @@
|
||||||
<id>jitpack.io</id>
|
<id>jitpack.io</id>
|
||||||
<url>https://jitpack.io</url>
|
<url>https://jitpack.io</url>
|
||||||
</repository>
|
</repository>
|
||||||
|
<repository>
|
||||||
|
<id>sonatype-snapshots</id>
|
||||||
|
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
|
||||||
|
</repository>
|
||||||
</repositories>
|
</repositories>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
package xyz.etztech.qol;
|
package xyz.etztech.qol;
|
||||||
|
|
||||||
import net.ess3.api.IEssentials;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
import org.dynmap.DynmapAPI;
|
import org.dynmap.DynmapAPI;
|
||||||
import org.dynmap.markers.Marker;
|
import org.dynmap.markers.Marker;
|
||||||
|
@ -16,6 +16,7 @@ import xyz.etztech.qol.listeners.*;
|
||||||
import xyz.etztech.qol.other.LinkCommand;
|
import xyz.etztech.qol.other.LinkCommand;
|
||||||
import xyz.etztech.qol.other.Reminder;
|
import xyz.etztech.qol.other.Reminder;
|
||||||
import xyz.etztech.qol.other.TPSRunnable;
|
import xyz.etztech.qol.other.TPSRunnable;
|
||||||
|
import me.lucko.spark.api.Spark;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -28,7 +29,7 @@ public class QoL extends JavaPlugin {
|
||||||
private String qolMarkerIcon = null;
|
private String qolMarkerIcon = null;
|
||||||
|
|
||||||
private static QoL instance;
|
private static QoL instance;
|
||||||
private IEssentials essentials = null;
|
private Spark spark = null;
|
||||||
private DynmapAPI dynmap = null;
|
private DynmapAPI dynmap = null;
|
||||||
private MarkerAPI markerAPI = null;
|
private MarkerAPI markerAPI = null;
|
||||||
private MarkerSet playerMarkerSet = null;
|
private MarkerSet playerMarkerSet = null;
|
||||||
|
@ -53,10 +54,11 @@ public class QoL extends JavaPlugin {
|
||||||
reloadConfig();
|
reloadConfig();
|
||||||
saveResource("qol.png", true);
|
saveResource("qol.png", true);
|
||||||
|
|
||||||
//Essentials hook
|
//Spark hook
|
||||||
if (Bukkit.getPluginManager().isPluginEnabled("Essentials")) {
|
RegisteredServiceProvider<Spark> sparkProvider = Bukkit.getServicesManager().getRegistration(Spark.class);
|
||||||
log("Hooked into Essentials for TPS alert.");
|
if (sparkProvider != null) {
|
||||||
essentials = (IEssentials) Bukkit.getPluginManager().getPlugin("Essentials");
|
log("Hooked into Spark for TPS alert.");
|
||||||
|
spark = sparkProvider.getProvider();
|
||||||
}
|
}
|
||||||
|
|
||||||
//Dynmap hook
|
//Dynmap hook
|
||||||
|
@ -276,8 +278,6 @@ public class QoL extends JavaPlugin {
|
||||||
return links;
|
return links;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEssentials getEssentials() { return essentials; }
|
|
||||||
|
|
||||||
public DynmapAPI getDynmap() { return dynmap; }
|
public DynmapAPI getDynmap() { return dynmap; }
|
||||||
|
|
||||||
public void runTask(final String command) {
|
public void runTask(final String command) {
|
||||||
|
@ -330,5 +330,9 @@ public class QoL extends JavaPlugin {
|
||||||
return marker;
|
return marker;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Spark getSpark() {
|
||||||
|
return spark;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
package xyz.etztech.qol.other;
|
package xyz.etztech.qol.other;
|
||||||
|
|
||||||
import net.ess3.api.IEssentials;
|
import me.lucko.spark.api.statistic.StatisticWindow;
|
||||||
|
import me.lucko.spark.api.statistic.types.DoubleStatistic;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import xyz.etztech.core.web.Http;
|
import xyz.etztech.core.web.Http;
|
||||||
import xyz.etztech.qol.QoL;
|
import xyz.etztech.qol.QoL;
|
||||||
|
import me.lucko.spark.api.Spark;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -18,13 +20,13 @@ public class TPSRunnable implements Runnable {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
IEssentials essentials = plugin.getEssentials();
|
Spark spark = plugin.getSpark();
|
||||||
if (essentials != null) {
|
if (spark != null) {
|
||||||
double tps = essentials.getTimer().getAverageTPS();
|
DoubleStatistic<StatisticWindow.TicksPerSecond> tps = spark.tps();
|
||||||
int threshold = plugin.getConfig().getInt("tps.threshold", 0);
|
int threshold = plugin.getConfig().getInt("tps.threshold", 0);
|
||||||
String webhook = plugin.getConfig().getString("tps.webhook", "");
|
String webhook = plugin.getConfig().getString("tps.webhook", "");
|
||||||
String message = "@here TPS has fallen below " + threshold + "!";
|
String message = "@here TPS has fallen below " + threshold + "!";
|
||||||
if (tps < threshold) {
|
if (tps.poll(StatisticWindow.TicksPerSecond.SECONDS_10) < threshold) {
|
||||||
plugin.log(message);
|
plugin.log(message);
|
||||||
if (StringUtils.isNotEmpty(webhook)) {
|
if (StringUtils.isNotEmpty(webhook)) {
|
||||||
Map<String, String> data = new HashMap<>();
|
Map<String, String> data = new HashMap<>();
|
||||||
|
|
|
@ -4,7 +4,7 @@ description: ${description}
|
||||||
author: ${author}
|
author: ${author}
|
||||||
website: ${url}
|
website: ${url}
|
||||||
main: ${mainClass}
|
main: ${mainClass}
|
||||||
softdepend: [Essentials, dynmap, DiscordSRV]
|
softdepend: [spark, dynmap, DiscordSRV]
|
||||||
commands:
|
commands:
|
||||||
qol:
|
qol:
|
||||||
description: Base command
|
description: Base command
|
||||||
|
|
Loading…
Reference in New Issue