Skip to content

Commit

Permalink
Replace deprecated header function
Browse files Browse the repository at this point in the history
  • Loading branch information
Gamerboy59 authored Dec 29, 2021
1 parent 40c234f commit 05e9299
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions bukkit/Metrics.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@
import java.lang.reflect.Method;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
Expand All @@ -28,6 +30,7 @@
import java.util.zip.GZIPOutputStream;
import javax.net.ssl.HttpsURLConnection;
import org.bukkit.Bukkit;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
Expand All @@ -51,22 +54,23 @@ public Metrics(JavaPlugin plugin, int serviceId) {
// Get the config file
File bStatsFolder = new File(plugin.getDataFolder().getParentFile(), "bStats");
File configFile = new File(bStatsFolder, "config.yml");
YamlConfiguration config = YamlConfiguration.loadConfiguration(configFile);
FileConfiguration config = YamlConfiguration.loadConfiguration(configFile);
if (!config.isSet("serverUuid")) {
config.addDefault("enabled", true);
config.addDefault("serverUuid", UUID.randomUUID().toString());
config.addDefault("logFailedRequests", false);
config.addDefault("logSentData", false);
config.addDefault("logResponseStatusText", false);
// Inform the server owners about bStats
List<String> header = new ArrayList<String>();
header.add("bStats (https://bStats.org) collects some basic information for plugin authors, like how");
header.add("many people use their plugin and their total player count. It's recommended to keep bStats");
header.add("enabled, but if you're not comfortable with this, you can turn this setting off. There is no");
header.add("performance penalty associated with having metrics enabled, and data sent to bStats is fully");
header.add("anonymous.");
config
.options()
.header(
"bStats (https://bStats.org) collects some basic information for plugin authors, like how\n"
+ "many people use their plugin and their total player count. It's recommended to keep bStats\n"
+ "enabled, but if you're not comfortable with this, you can turn this setting off. There is no\n"
+ "performance penalty associated with having metrics enabled, and data sent to bStats is fully\n"
+ "anonymous.")
.setHeader(header)
.copyDefaults(true);
try {
config.save(configFile);
Expand Down

0 comments on commit 05e9299

Please sign in to comment.