mirror of
https://github.com/YatopiaMC/Yatopia.git
synced 2024-11-26 04:25:39 +01:00
Restore incremental player saving
This patch was dropped in 1.14 and now gets ported to 1.16
This commit is contained in:
parent
3c761d7685
commit
bf33de221f
@ -6315,7 +6315,7 @@ index 885458d54c97ad597d84ebb414884bf9fc1e0d86..9aeecdafeed5b4bd7b13b91cfa71456e
|
||||
|
||||
public class ItemArmor extends Item implements ItemWearable {
|
||||
diff --git a/src/main/java/net/minecraft/server/ItemBlock.java b/src/main/java/net/minecraft/server/ItemBlock.java
|
||||
index 63d2294da4f0da628e62b782b71e34cb3eb959b5..8425d58ccae4d1462e225ef7f0e4d25ce26ac43c 100644
|
||||
index 2e3e373dedcf1c358da061c82ada8faf902421fb..65558af58dfaf8c92e4d6f766f97e007154ae709 100644
|
||||
--- a/src/main/java/net/minecraft/server/ItemBlock.java
|
||||
+++ b/src/main/java/net/minecraft/server/ItemBlock.java
|
||||
@@ -1,12 +1,12 @@
|
||||
@ -16078,30 +16078,30 @@ index d3281c81a4e8e0b8c2ad3a8d6628faf546746a2f..bb3400d2ccce6fb73550f80ef1df5a48
|
||||
* If you are getting: java.lang.ExceptionInInitializerError
|
||||
* at net.minecraft.server.StatisticList.<clinit>(SourceFile:58)
|
||||
diff --git a/src/test/java/org/bukkit/support/DummyServer.java b/src/test/java/org/bukkit/support/DummyServer.java
|
||||
index 97eb5fa880d009bef973467403323d022bea5d7a..1036bd4e8fcf5e7ae65388cdc54b770c125e2547 100644
|
||||
index 97eb5fa880d009bef973467403323d022bea5d7a..39411685ed566b738a40a050fad2159c72bca264 100644
|
||||
--- a/src/test/java/org/bukkit/support/DummyServer.java
|
||||
+++ b/src/test/java/org/bukkit/support/DummyServer.java
|
||||
@@ -1,10 +1,5 @@
|
||||
package org.bukkit.support;
|
||||
|
||||
-import java.lang.reflect.InvocationHandler;
|
||||
-import java.lang.reflect.Method;
|
||||
-import java.lang.reflect.Proxy;
|
||||
-import java.util.HashMap;
|
||||
-import java.util.logging.Logger;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.NamespacedKey;
|
||||
package org.bukkit.support;
|
||||
|
||||
-import java.lang.reflect.InvocationHandler;
|
||||
-import java.lang.reflect.Method;
|
||||
-import java.lang.reflect.Proxy;
|
||||
-import java.util.HashMap;
|
||||
-import java.util.logging.Logger;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.NamespacedKey;
|
||||
@@ -16,6 +11,12 @@ import org.bukkit.craftbukkit.util.CraftMagicNumbers;
|
||||
import org.bukkit.craftbukkit.util.CraftNamespacedKey;
|
||||
import org.bukkit.craftbukkit.util.Versioning;
|
||||
|
||||
import org.bukkit.craftbukkit.util.CraftNamespacedKey;
|
||||
import org.bukkit.craftbukkit.util.Versioning;
|
||||
|
||||
+import java.lang.reflect.InvocationHandler;
|
||||
+import java.lang.reflect.Method;
|
||||
+import java.lang.reflect.Proxy;
|
||||
+import java.util.HashMap;
|
||||
+import java.util.logging.Logger;
|
||||
+
|
||||
public final class DummyServer implements InvocationHandler {
|
||||
private static interface MethodHandler {
|
||||
Object handle(DummyServer server, Object[] args);
|
||||
public final class DummyServer implements InvocationHandler {
|
||||
private static interface MethodHandler {
|
||||
Object handle(DummyServer server, Object[] args);
|
||||
|
@ -21997,7 +21997,7 @@ index f3df5d48bf1dc4f960d0bc60d4ea8f5b048dbe42..94f29e4461104ce7314b28d4591e01e6
|
||||
|
||||
itemstack.subtract(1);
|
||||
diff --git a/src/main/java/net/minecraft/server/ItemBlock.java b/src/main/java/net/minecraft/server/ItemBlock.java
|
||||
index 8425d58ccae4d1462e225ef7f0e4d25ce26ac43c..4a7ed4ffbe9746cf2f41a6dc04b6fc0505673fe3 100644
|
||||
index 65558af58dfaf8c92e4d6f766f97e007154ae709..5cf0ff0b66e98459cf62b0fa49484127a6f6b2aa 100644
|
||||
--- a/src/main/java/net/minecraft/server/ItemBlock.java
|
||||
+++ b/src/main/java/net/minecraft/server/ItemBlock.java
|
||||
@@ -145,14 +145,14 @@ public class ItemBlock extends Item {
|
||||
|
98
patches/server/0032-Incremental-player-saving.patch
Normal file
98
patches/server/0032-Incremental-player-saving.patch
Normal file
@ -0,0 +1,98 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Sun, 9 Aug 2020 21:19:15 +0300
|
||||
Subject: [PATCH] Incremental player saving
|
||||
|
||||
Co-authored-by: MrIvanPlays <ivan@mrivanplays.com>
|
||||
Ported to Yatopia and 1.16.1 by MrIvanPlays
|
||||
|
||||
diff --git a/src/main/java/dev/tr7zw/yatopia/YatopiaConfig.java b/src/main/java/dev/tr7zw/yatopia/YatopiaConfig.java
|
||||
index 7503322478048cdcca7659202596aea4d95fd835..6d3a2c874077f3abaeda1e365963ce601c901085 100644
|
||||
--- a/src/main/java/dev/tr7zw/yatopia/YatopiaConfig.java
|
||||
+++ b/src/main/java/dev/tr7zw/yatopia/YatopiaConfig.java
|
||||
@@ -223,4 +223,15 @@ public class YatopiaConfig {
|
||||
fixFallDistance = getBoolean("settings.fixFallDistance", false);
|
||||
}
|
||||
|
||||
+ public static int maxPlayerAutoSavePerTick = 10;
|
||||
+ public static int playerAutoSaveRate = -1;
|
||||
+ private static void incrementalPlayerdataSaving() {
|
||||
+ playerAutoSaveRate = getInt("settings.player-auto-save-rate", -1);
|
||||
+ maxPlayerAutoSavePerTick = getInt("settings.max-player-auto-save-per-tick", -1);
|
||||
+ if (maxPlayerAutoSavePerTick == -1) { // -1 Automatic / "Recommended"
|
||||
+ // 10 should be safe for everyone unless you mass spamming player auto save
|
||||
+ maxPlayerAutoSavePerTick = (playerAutoSaveRate == -1 || playerAutoSaveRate > 100) ? 10 : 20;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
}
|
||||
\ No newline at end of file
|
||||
diff --git a/src/main/java/net/minecraft/server/EntityPlayer.java b/src/main/java/net/minecraft/server/EntityPlayer.java
|
||||
index f143624c072ddd300591bdadd3173c97e16973fe..348f25fb974a99e991090747cedb0acd7eade8e9 100644
|
||||
--- a/src/main/java/net/minecraft/server/EntityPlayer.java
|
||||
+++ b/src/main/java/net/minecraft/server/EntityPlayer.java
|
||||
@@ -29,6 +29,7 @@ import java.util.concurrent.CompletableFuture;
|
||||
public class EntityPlayer extends EntityHuman implements ICrafting {
|
||||
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
+ public long lastSave = MinecraftServer.currentTick; // Yatopia
|
||||
public PlayerConnection playerConnection;
|
||||
public NetworkManager networkManager; // Paper
|
||||
public final MinecraftServer server;
|
||||
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
index 440c7f15e2e081ec13d6ab32177c70ef4959e8bb..6a151e60b7f203b629c55c80ac998a80fef2f67d 100644
|
||||
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
@@ -1282,9 +1282,15 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
|
||||
//if (autosavePeriod > 0 && this.ticks % autosavePeriod == 0) { // CraftBukkit // Paper - move down
|
||||
//MinecraftServer.LOGGER.debug("Autosave started"); // Paper
|
||||
serverAutoSave = (autosavePeriod > 0 && this.ticks % autosavePeriod == 0); // Paper
|
||||
+ // Yatopia start
|
||||
+ int playerSaveInterval = dev.tr7zw.yatopia.YatopiaConfig.playerAutoSaveRate;
|
||||
+ if (playerSaveInterval < 0) {
|
||||
+ playerSaveInterval = autosavePeriod;
|
||||
+ }
|
||||
+ // Yatopia end
|
||||
//this.methodProfiler.enter("save"); // Akarin - remove caller
|
||||
- if (autosavePeriod > 0 && this.ticks % autosavePeriod == 0) { // Paper
|
||||
- this.playerList.savePlayers();
|
||||
+ if (playerSaveInterval > 0) { // Yatopia
|
||||
+ this.playerList.savePlayers(playerSaveInterval); // Yatopia
|
||||
}// Paper
|
||||
// Paper start
|
||||
for (WorldServer world : getWorlds()) {
|
||||
diff --git a/src/main/java/net/minecraft/server/PlayerList.java b/src/main/java/net/minecraft/server/PlayerList.java
|
||||
index 8498324704ea2e3178a46149b2cc2fd37682dbff..7ac8e538e98b027b5aea20231b2aad79f49e5cb5 100644
|
||||
--- a/src/main/java/net/minecraft/server/PlayerList.java
|
||||
+++ b/src/main/java/net/minecraft/server/PlayerList.java
|
||||
@@ -468,6 +468,7 @@ public abstract class PlayerList {
|
||||
protected void savePlayerFile(EntityPlayer entityplayer) {
|
||||
if (!entityplayer.getBukkitEntity().isPersistent()) return; // CraftBukkit
|
||||
if (!entityplayer.didPlayerJoinEvent) return; // Paper - If we never fired PJE, we disconnected during login. Data has not changed, and additionally, our saved vehicle is not loaded! If we save now, we will lose our vehicle (CraftBukkit bug)
|
||||
+ entityplayer.lastSave = MinecraftServer.currentTick; // Yatopia
|
||||
this.playerFileData.save(entityplayer);
|
||||
ServerStatisticManager serverstatisticmanager = entityplayer.getStatisticManager(); // CraftBukkit
|
||||
|
||||
@@ -1114,10 +1115,21 @@ public abstract class PlayerList {
|
||||
}
|
||||
|
||||
public void savePlayers() {
|
||||
+ // Yatopia start - incremental player saving
|
||||
+ savePlayers(null);
|
||||
+ }
|
||||
+ public void savePlayers(Integer interval) {
|
||||
MCUtil.ensureMain("Save Players" , () -> { // Paper - Ensure main
|
||||
MinecraftTimings.savePlayers.startTiming(); // Paper
|
||||
+ int numSaved = 0;
|
||||
+ long now = MinecraftServer.currentTick;
|
||||
for (int i = 0; i < this.players.size(); ++i) {
|
||||
- this.savePlayerFile(this.players.get(i));
|
||||
+ EntityPlayer entityplayer = this.players.get(i);
|
||||
+ if (interval == null || now - entityplayer.lastSave >= interval) {
|
||||
+ this.savePlayerFile(entityplayer);
|
||||
+ if (interval != null && ++numSaved <= dev.tr7zw.yatopia.YatopiaConfig.maxPlayerAutoSavePerTick) { break; }
|
||||
+ }
|
||||
+ // Yatopia end
|
||||
}
|
||||
MinecraftTimings.savePlayers.stopTiming(); // Paper
|
||||
return null; }); // Paper - ensure main
|
Loading…
Reference in New Issue
Block a user