mirror of
https://hub.spigotmc.org/stash/scm/spigot/spigot.git
synced 2025-08-05 16:48:51 +00:00
93 lines
3.8 KiB
Diff
93 lines
3.8 KiB
Diff
From b8257bbec8955bda3e6e3caa5e12a0f056ddabbc Mon Sep 17 00:00:00 2001
|
|
From: Thinkofdeath <thethinkofdeath@gmail.com>
|
|
Date: Tue, 7 Jan 2014 15:56:26 +0000
|
|
Subject: [PATCH] Allow statistics to be disabled/forced
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/ServerStatisticManager.java b/src/main/java/net/minecraft/server/ServerStatisticManager.java
|
|
index 38ff3b662..07e7db455 100644
|
|
--- a/src/main/java/net/minecraft/server/ServerStatisticManager.java
|
|
+++ b/src/main/java/net/minecraft/server/ServerStatisticManager.java
|
|
@@ -37,6 +37,13 @@ public class ServerStatisticManager extends StatisticManager {
|
|
public ServerStatisticManager(MinecraftServer minecraftserver, File file) {
|
|
this.c = minecraftserver;
|
|
this.d = file;
|
|
+ // Spigot start
|
|
+ for ( MinecraftKey name : org.spigotmc.SpigotConfig.forcedStats.keySet() )
|
|
+ {
|
|
+ Statistic<MinecraftKey> wrapper = StatisticList.CUSTOM.b( name );
|
|
+ a.put( wrapper, org.spigotmc.SpigotConfig.forcedStats.get( name ) );
|
|
+ }
|
|
+ // Spigot end
|
|
if (file.isFile()) {
|
|
try {
|
|
this.a(minecraftserver.aB(), FileUtils.readFileToString(file));
|
|
@@ -50,6 +57,7 @@ public class ServerStatisticManager extends StatisticManager {
|
|
}
|
|
|
|
public void a() {
|
|
+ if ( org.spigotmc.SpigotConfig.disableStatSaving ) return; // Spigot
|
|
try {
|
|
FileUtils.writeStringToFile(this.d, this.b());
|
|
} catch (IOException ioexception) {
|
|
@@ -59,6 +67,7 @@ public class ServerStatisticManager extends StatisticManager {
|
|
}
|
|
|
|
public void setStatistic(EntityHuman entityhuman, Statistic<?> statistic, int i) {
|
|
+ if ( org.spigotmc.SpigotConfig.disableStatSaving ) return; // Spigot
|
|
super.setStatistic(entityhuman, statistic, i);
|
|
this.e.add(statistic);
|
|
}
|
|
diff --git a/src/main/java/org/spigotmc/SpigotConfig.java b/src/main/java/org/spigotmc/SpigotConfig.java
|
|
index 33f0e3b87..5d3060c01 100644
|
|
--- a/src/main/java/org/spigotmc/SpigotConfig.java
|
|
+++ b/src/main/java/org/spigotmc/SpigotConfig.java
|
|
@@ -10,10 +10,14 @@ import java.util.HashMap;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.logging.Level;
|
|
+import gnu.trove.map.hash.TObjectIntHashMap;
|
|
+import net.minecraft.server.MinecraftKey;
|
|
import net.minecraft.server.MinecraftServer;
|
|
+import net.minecraft.server.StatisticList;
|
|
import org.bukkit.Bukkit;
|
|
import org.bukkit.ChatColor;
|
|
import org.bukkit.command.Command;
|
|
+import org.bukkit.configuration.ConfigurationSection;
|
|
import org.bukkit.configuration.InvalidConfigurationException;
|
|
import org.bukkit.configuration.file.YamlConfiguration;
|
|
|
|
@@ -236,4 +240,30 @@ public class SpigotConfig
|
|
private static void lateBind() {
|
|
lateBind = getBoolean( "settings.late-bind", false );
|
|
}
|
|
+
|
|
+ public static boolean disableStatSaving;
|
|
+ public static TObjectIntHashMap<MinecraftKey> forcedStats = new TObjectIntHashMap<MinecraftKey>();
|
|
+ private static void stats()
|
|
+ {
|
|
+ disableStatSaving = getBoolean( "stats.disable-saving", false );
|
|
+
|
|
+ if ( !config.contains( "stats.forced-stats" ) ) {
|
|
+ config.createSection( "stats.forced-stats" );
|
|
+ }
|
|
+
|
|
+ ConfigurationSection section = config.getConfigurationSection( "stats.forced-stats" );
|
|
+ for ( String name : section.getKeys( true ) )
|
|
+ {
|
|
+ if ( section.isInt( name ) )
|
|
+ {
|
|
+ MinecraftKey key = new MinecraftKey( name );
|
|
+ if ( StatisticList.REGISTRY_CUSTOM.get( key ) == null )
|
|
+ {
|
|
+ Bukkit.getLogger().log(Level.WARNING, "Ignoring non existent stats.forced-stats " + name);
|
|
+ continue;
|
|
+ }
|
|
+ forcedStats.put( key, section.getInt( name ) );
|
|
+ }
|
|
+ }
|
|
+ }
|
|
}
|
|
--
|
|
2.17.1
|
|
|