mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-23 23:57:43 +01:00
94 lines
3.7 KiB
Diff
94 lines
3.7 KiB
Diff
From 7d85a02bae8626a374cf666af39fd49ee33d51b7 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 2f980cb..3f78728 100644
|
|
--- a/src/main/java/net/minecraft/server/ServerStatisticManager.java
|
|
+++ b/src/main/java/net/minecraft/server/ServerStatisticManager.java
|
|
@@ -32,6 +32,14 @@ public class ServerStatisticManager extends StatisticManager {
|
|
public ServerStatisticManager(MinecraftServer minecraftserver, File file1) {
|
|
this.c = minecraftserver;
|
|
this.d = file1;
|
|
+ // 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.a( 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) {
|
|
@@ -56,6 +65,7 @@ public class ServerStatisticManager extends StatisticManager {
|
|
}
|
|
|
|
public void a(EntityHuman entityhuman, Statistic statistic, int i) {
|
|
+ if ( org.spigotmc.SpigotConfig.disableStatSaving ) return; // Spigot
|
|
int j = statistic.d() ? this.a(statistic) : 0;
|
|
|
|
super.a(entityhuman, statistic, i);
|
|
diff --git a/src/main/java/org/spigotmc/SpigotConfig.java b/src/main/java/org/spigotmc/SpigotConfig.java
|
|
index 69306cb..eaafc2d 100644
|
|
--- a/src/main/java/org/spigotmc/SpigotConfig.java
|
|
+++ b/src/main/java/org/spigotmc/SpigotConfig.java
|
|
@@ -10,10 +10,13 @@ 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.MinecraftServer;
|
|
import org.bukkit.Bukkit;
|
|
import org.bukkit.ChatColor;
|
|
import org.bukkit.command.Command;
|
|
+import org.bukkit.configuration.ConfigurationSection;
|
|
import org.bukkit.configuration.file.YamlConfiguration;
|
|
|
|
public class SpigotConfig
|
|
@@ -203,4 +206,31 @@ public class SpigotConfig
|
|
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." );
|
|
+ }
|
|
+ }
|
|
}
|
|
--
|
|
1.8.3.2
|
|
|