2016-03-01 00:23:45 +00:00
|
|
|
From 20ba002dde049a8fad1402b4e976e38304e4018e Mon Sep 17 00:00:00 2001
|
2014-07-21 20:46:54 +00:00
|
|
|
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
|
2016-02-29 21:33:06 +00:00
|
|
|
index 76bd9c1..a08eb77 100644
|
2014-07-21 20:46:54 +00:00
|
|
|
--- a/src/main/java/net/minecraft/server/ServerStatisticManager.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/ServerStatisticManager.java
|
2014-11-28 01:17:45 +00:00
|
|
|
@@ -31,6 +31,14 @@ public class ServerStatisticManager extends StatisticManager {
|
|
|
|
public ServerStatisticManager(MinecraftServer minecraftserver, File file) {
|
2014-07-21 20:46:54 +00:00
|
|
|
this.c = minecraftserver;
|
2014-11-28 01:17:45 +00:00
|
|
|
this.d = file;
|
2014-07-21 20:46:54 +00:00
|
|
|
+ // Spigot start
|
|
|
|
+ for ( String name : org.spigotmc.SpigotConfig.forcedStats.keySet() )
|
|
|
|
+ {
|
|
|
|
+ StatisticWrapper wrapper = new StatisticWrapper();
|
|
|
|
+ wrapper.a( org.spigotmc.SpigotConfig.forcedStats.get( name ) );
|
|
|
|
+ a.put( StatisticList.getStatistic( name ), wrapper );
|
|
|
|
+ }
|
|
|
|
+ // Spigot end
|
|
|
|
}
|
|
|
|
|
|
|
|
public void a() {
|
|
|
|
@@ -48,6 +56,7 @@ public class ServerStatisticManager extends StatisticManager {
|
|
|
|
}
|
|
|
|
|
|
|
|
public void b() {
|
|
|
|
+ if ( org.spigotmc.SpigotConfig.disableStatSaving ) return; // Spigot
|
|
|
|
try {
|
|
|
|
FileUtils.writeStringToFile(this.d, a(this.a));
|
|
|
|
} catch (IOException ioexception) {
|
2014-11-28 01:17:45 +00:00
|
|
|
@@ -57,6 +66,7 @@ public class ServerStatisticManager extends StatisticManager {
|
2014-07-21 20:46:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public void setStatistic(EntityHuman entityhuman, Statistic statistic, int i) {
|
|
|
|
+ if ( org.spigotmc.SpigotConfig.disableStatSaving ) return; // Spigot
|
|
|
|
int j = statistic.d() ? this.getStatisticValue(statistic) : 0;
|
|
|
|
|
|
|
|
super.setStatistic(entityhuman, statistic, i);
|
|
|
|
diff --git a/src/main/java/org/spigotmc/SpigotConfig.java b/src/main/java/org/spigotmc/SpigotConfig.java
|
2015-05-25 19:09:58 +00:00
|
|
|
index 4edc6af..a2be9df 100644
|
2014-07-21 20:46:54 +00:00
|
|
|
--- a/src/main/java/org/spigotmc/SpigotConfig.java
|
|
|
|
+++ b/src/main/java/org/spigotmc/SpigotConfig.java
|
|
|
|
@@ -10,10 +10,12 @@ import java.util.HashMap;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.Map;
|
|
|
|
import java.util.logging.Level;
|
2014-11-28 01:17:45 +00:00
|
|
|
+import gnu.trove.map.hash.TObjectIntHashMap;
|
2014-07-21 20:46:54 +00:00
|
|
|
import net.minecraft.server.MinecraftServer;
|
|
|
|
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;
|
|
|
|
|
2015-05-25 19:09:58 +00:00
|
|
|
@@ -233,4 +235,31 @@ public class SpigotConfig
|
2014-07-21 20:46:54 +00:00
|
|
|
private static void lateBind() {
|
|
|
|
lateBind = getBoolean( "settings.late-bind", false );
|
|
|
|
}
|
|
|
|
+
|
|
|
|
+ public static boolean disableStatSaving;
|
|
|
|
+ public static TObjectIntHashMap<String> forcedStats = new TObjectIntHashMap<String>();
|
|
|
|
+ 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 ) )
|
|
|
|
+ {
|
|
|
|
+ forcedStats.put( name, section.getInt( name ) );
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if ( disableStatSaving && section.getInt( "achievement.openInventory", 0 ) < 1 )
|
|
|
|
+ {
|
|
|
|
+ Bukkit.getLogger().warning( "*** WARNING *** stats.disable-saving is true but stats.forced-stats.achievement.openInventory" +
|
|
|
|
+ " isn't set to 1. Disabling stat saving without forcing the achievement may cause it to get stuck on the player's " +
|
|
|
|
+ "screen." );
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
}
|
|
|
|
--
|
2016-02-29 21:33:06 +00:00
|
|
|
2.5.0
|
2014-07-21 20:46:54 +00:00
|
|
|
|