mirror of
https://hub.spigotmc.org/stash/scm/spigot/spigot.git
synced 2025-07-06 08:52:59 +00:00
99 lines
4.2 KiB
Diff
99 lines
4.2 KiB
Diff
From ea8312b9b0f0060a18177e6b74f82e34d1ffb8fe 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/stats/ServerStatisticManager.java b/src/main/java/net/minecraft/stats/ServerStatisticManager.java
|
|
index 1187b04ca..44c0ba553 100644
|
|
--- a/src/main/java/net/minecraft/stats/ServerStatisticManager.java
|
|
+++ b/src/main/java/net/minecraft/stats/ServerStatisticManager.java
|
|
@@ -70,6 +70,13 @@ public class ServerStatisticManager extends StatisticManager {
|
|
public ServerStatisticManager(MinecraftServer minecraftserver, File file) {
|
|
this.server = minecraftserver;
|
|
this.file = file;
|
|
+ // Spigot start
|
|
+ for ( Map.Entry<net.minecraft.resources.MinecraftKey, Integer> entry : org.spigotmc.SpigotConfig.forcedStats.entrySet() )
|
|
+ {
|
|
+ Statistic<net.minecraft.resources.MinecraftKey> wrapper = StatisticList.CUSTOM.get( entry.getKey() );
|
|
+ this.stats.put( wrapper, entry.getValue().intValue() );
|
|
+ }
|
|
+ // Spigot end
|
|
if (file.isFile()) {
|
|
try {
|
|
this.parseLocal(minecraftserver.getFixerUpper(), FileUtils.readFileToString(file));
|
|
@@ -83,6 +90,7 @@ public class ServerStatisticManager extends StatisticManager {
|
|
}
|
|
|
|
public void save() {
|
|
+ if ( org.spigotmc.SpigotConfig.disableStatSaving ) return; // Spigot
|
|
try {
|
|
FileUtils.writeStringToFile(this.file, this.toJson());
|
|
} catch (IOException ioexception) {
|
|
@@ -93,6 +101,7 @@ public class ServerStatisticManager extends StatisticManager {
|
|
|
|
@Override
|
|
public void setValue(EntityHuman entityhuman, Statistic<?> statistic, int i) {
|
|
+ if ( org.spigotmc.SpigotConfig.disableStatSaving ) return; // Spigot
|
|
super.setValue(entityhuman, statistic, i);
|
|
this.dirty.add(statistic);
|
|
}
|
|
diff --git a/src/main/java/org/spigotmc/SpigotConfig.java b/src/main/java/org/spigotmc/SpigotConfig.java
|
|
index 809177065..db04e7418 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 net.minecraft.core.registries.BuiltInRegistries;
|
|
+import net.minecraft.resources.MinecraftKey;
|
|
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;
|
|
|
|
@@ -231,4 +234,36 @@ public class SpigotConfig
|
|
System.setProperty( "io.netty.eventLoopThreads", Integer.toString( count ) );
|
|
Bukkit.getLogger().log( Level.INFO, "Using {0} threads for Netty based IO", count );
|
|
}
|
|
+
|
|
+ public static boolean disableStatSaving;
|
|
+ public static Map<MinecraftKey, Integer> forcedStats = new HashMap<>();
|
|
+ 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 ) )
|
|
+ {
|
|
+ try
|
|
+ {
|
|
+ MinecraftKey key = MinecraftKey.parse( name );
|
|
+ if ( BuiltInRegistries.CUSTOM_STAT.get( key ) == null )
|
|
+ {
|
|
+ Bukkit.getLogger().log(Level.WARNING, "Ignoring non existent stats.forced-stats " + name);
|
|
+ continue;
|
|
+ }
|
|
+ forcedStats.put( key, section.getInt( name ) );
|
|
+ } catch (Exception ex)
|
|
+ {
|
|
+ Bukkit.getLogger().log(Level.WARNING, "Ignoring invalid stats.forced-stats " + name);
|
|
+ }
|
|
+ }
|
|
+ }
|
|
+ }
|
|
}
|
|
--
|
|
2.49.0
|
|
|