mirror of
https://github.com/PaperMC/Waterfall.git
synced 2024-11-28 13:15:31 +01:00
87 lines
3.1 KiB
Diff
87 lines
3.1 KiB
Diff
From deab52d855171f7f411835d801e6edc3ef5f343a Mon Sep 17 00:00:00 2001
|
|
From: Techcable <Techcable@techcable.net>
|
|
Date: Thu, 19 May 2016 10:55:20 -0700
|
|
Subject: [PATCH] Configurable Waterfall Metrics
|
|
|
|
|
|
diff --git a/api/src/main/java/net/md_5/bungee/api/ProxyConfig.java b/api/src/main/java/net/md_5/bungee/api/ProxyConfig.java
|
|
index b30541be..293ec4e3 100644
|
|
--- a/api/src/main/java/net/md_5/bungee/api/ProxyConfig.java
|
|
+++ b/api/src/main/java/net/md_5/bungee/api/ProxyConfig.java
|
|
@@ -84,4 +84,8 @@ public interface ProxyConfig
|
|
// Waterfall Options
|
|
//
|
|
|
|
+ /**
|
|
+ * If metrics is enabled
|
|
+ */
|
|
+ boolean isMetrics();
|
|
}
|
|
diff --git a/proxy/src/main/java/io/github/waterfallmc/waterfall/conf/WaterfallConfiguration.java b/proxy/src/main/java/io/github/waterfallmc/waterfall/conf/WaterfallConfiguration.java
|
|
index f9e277dc..056b8040 100644
|
|
--- a/proxy/src/main/java/io/github/waterfallmc/waterfall/conf/WaterfallConfiguration.java
|
|
+++ b/proxy/src/main/java/io/github/waterfallmc/waterfall/conf/WaterfallConfiguration.java
|
|
@@ -9,10 +9,23 @@ import net.md_5.bungee.conf.YamlConfig;
|
|
|
|
public class WaterfallConfiguration extends Configuration {
|
|
|
|
+ /**
|
|
+ * If metrics is enabled
|
|
+ * <p>
|
|
+ * Default is true (enabled)
|
|
+ */
|
|
+ private boolean metrics = true;
|
|
+
|
|
@Override
|
|
public void load() {
|
|
super.load();
|
|
YamlConfig config = new YamlConfig(new File("waterfall.yml"));
|
|
config.load(false); // Load, but no permissions
|
|
+ metrics = config.getBoolean("metrics", metrics);
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public boolean isMetrics() {
|
|
+ return metrics;
|
|
}
|
|
}
|
|
diff --git a/proxy/src/main/java/net/md_5/bungee/BungeeCord.java b/proxy/src/main/java/net/md_5/bungee/BungeeCord.java
|
|
index 1144ec73..179e3a3a 100644
|
|
--- a/proxy/src/main/java/net/md_5/bungee/BungeeCord.java
|
|
+++ b/proxy/src/main/java/net/md_5/bungee/BungeeCord.java
|
|
@@ -294,7 +294,9 @@ public class BungeeCord extends ProxyServer
|
|
}
|
|
}
|
|
}, 0, TimeUnit.MINUTES.toMillis( 5 ) );
|
|
- metricsThread.scheduleAtFixedRate( new Metrics(), 0, TimeUnit.MINUTES.toMillis( Metrics.PING_INTERVAL ) );
|
|
+ if (config.isMetrics()) {
|
|
+ metricsThread.scheduleAtFixedRate( new Metrics(), 0, TimeUnit.MINUTES.toMillis( Metrics.PING_INTERVAL ) );
|
|
+ }
|
|
}
|
|
|
|
public void startListeners()
|
|
diff --git a/proxy/src/main/java/net/md_5/bungee/Metrics.java b/proxy/src/main/java/net/md_5/bungee/Metrics.java
|
|
index 95239878..e482e98c 100644
|
|
--- a/proxy/src/main/java/net/md_5/bungee/Metrics.java
|
|
+++ b/proxy/src/main/java/net/md_5/bungee/Metrics.java
|
|
@@ -9,6 +9,7 @@ import java.net.URL;
|
|
import java.net.URLConnection;
|
|
import java.net.URLEncoder;
|
|
import java.util.TimerTask;
|
|
+
|
|
import net.md_5.bungee.api.ProxyServer;
|
|
|
|
public class Metrics extends TimerTask
|
|
@@ -71,7 +72,7 @@ public class Metrics extends TimerTask
|
|
}
|
|
|
|
// Create the url
|
|
- URL url = new URL( BASE_URL + String.format( REPORT_URL, encode( "BungeeCord" ) ) );
|
|
+ URL url = new URL( BASE_URL + String.format( REPORT_URL, encode( "Waterfall" ) ) );
|
|
|
|
// Connect to the website
|
|
URLConnection connection;
|
|
--
|
|
2.16.1
|
|
|