Waterfall/BungeeCord-Patches/0004-Configurable-Waterfall-Metrics.patch
PunKeel 1720a14e08 Store last known dimension and don't send useless respawn packets
Improves server switching without lossing the advantages of the Respawn package (reset entities, for instance)

Merges SpigotMC/BungeeCord#1426
2016-06-29 19:54:36 -05:00

114 lines
4.2 KiB
Diff

From 19eb33404cbd686f8361f691520885331852481d 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 b30541b..293ec4e 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/net/md_5/bungee/Metrics.java b/proxy/src/main/java/io/github/waterfallmc/waterfall/Metrics.java
similarity index 96%
rename from proxy/src/main/java/net/md_5/bungee/Metrics.java
rename to proxy/src/main/java/io/github/waterfallmc/waterfall/Metrics.java
index 9523987..ae5a2a9 100644
--- a/proxy/src/main/java/net/md_5/bungee/Metrics.java
+++ b/proxy/src/main/java/io/github/waterfallmc/waterfall/Metrics.java
@@ -1,4 +1,4 @@
-package net.md_5.bungee;
+package io.github.waterfallmc.waterfall;
import java.io.BufferedReader;
import java.io.IOException;
@@ -9,6 +9,8 @@ import java.net.URL;
import java.net.URLConnection;
import java.net.URLEncoder;
import java.util.TimerTask;
+
+import net.md_5.bungee.BungeeCord;
import net.md_5.bungee.api.ProxyServer;
public class Metrics extends TimerTask
@@ -29,7 +31,7 @@ public class Metrics extends TimerTask
/**
* Interval of time to ping (in minutes)
*/
- final static int PING_INTERVAL = 10;
+ public final static int PING_INTERVAL = 10;
boolean firstPost = true;
@Override
@@ -71,7 +73,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;
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 03160da..1fa3ecd 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
@@ -10,10 +10,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 3dceb6e..3578aa4 100644
--- a/proxy/src/main/java/net/md_5/bungee/BungeeCord.java
+++ b/proxy/src/main/java/net/md_5/bungee/BungeeCord.java
@@ -23,6 +23,7 @@ import net.md_5.bungee.scheduler.BungeeScheduler;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
import com.google.gson.Gson;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
+import io.github.waterfallmc.waterfall.Metrics;
import io.github.waterfallmc.waterfall.conf.WaterfallConfiguration;
import io.netty.bootstrap.ServerBootstrap;
import io.netty.channel.Channel;
@@ -284,7 +285,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()
--
2.9.0