mirror of
https://github.com/YatopiaMC/Yatopia.git
synced 2025-02-03 05:51:27 +01:00
More patches
This commit is contained in:
parent
8400c206f8
commit
7bc296d097
@ -0,0 +1,111 @@
|
|||||||
|
From 392f40cacbe54abdf40983ca6eba65a748d7989d Mon Sep 17 00:00:00 2001
|
||||||
|
From: tr7zw <tr7zw@live.de>
|
||||||
|
Date: Mon, 23 Mar 2020 23:11:10 +0100
|
||||||
|
Subject: [PATCH] Add option for only players to have collisions with Entities
|
||||||
|
|
||||||
|
---
|
||||||
|
src/main/java/de/tr7zw/yapfa/YapfaConfig.java | 6 ++
|
||||||
|
.../net/minecraft/server/EntityLiving.java | 68 ++++++++++---------
|
||||||
|
2 files changed, 43 insertions(+), 31 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/src/main/java/de/tr7zw/yapfa/YapfaConfig.java b/src/main/java/de/tr7zw/yapfa/YapfaConfig.java
|
||||||
|
index 35ac0206c..071e9f9a5 100644
|
||||||
|
--- a/src/main/java/de/tr7zw/yapfa/YapfaConfig.java
|
||||||
|
+++ b/src/main/java/de/tr7zw/yapfa/YapfaConfig.java
|
||||||
|
@@ -206,4 +206,10 @@ public class YapfaConfig {
|
||||||
|
disableEntityCollisionboxes = getBoolean("settings.disableEntityCollisionboxes", false);
|
||||||
|
}
|
||||||
|
|
||||||
|
+ public static boolean onlyPlayerCollisions = false;
|
||||||
|
+ private static void onlyPlayerCollisions() {
|
||||||
|
+ onlyPlayerCollisions = getBoolean("settings.onlyPlayerCollisions", false);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+
|
||||||
|
}
|
||||||
|
\ No newline at end of file
|
||||||
|
diff --git a/src/main/java/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java
|
||||||
|
index 0b92fda23..3b4d2ae5a 100644
|
||||||
|
--- a/src/main/java/net/minecraft/server/EntityLiving.java
|
||||||
|
+++ b/src/main/java/net/minecraft/server/EntityLiving.java
|
||||||
|
@@ -2836,40 +2836,46 @@ public abstract class EntityLiving extends Entity {
|
||||||
|
if (i <= 0 && world.paperConfig.maxCollisionsPerEntity <= 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
- // Paper - end don't run getEntities if we're not going to use its result
|
||||||
|
+ // Tuinity - end don't run getEntities if we're not going to use its result
|
||||||
|
+ // YAPFA start
|
||||||
|
// Tuinity start - reduce memory allocation from collideNearby
|
||||||
|
List<Entity> list = com.tuinity.tuinity.util.CachedLists.getTempGetEntitiesList();
|
||||||
|
- this.world.getEntities(this, this.getBoundingBox(), IEntitySelector.a(this), list);
|
||||||
|
try {
|
||||||
|
- // Tuinity end - reduce memory allocation from collideNearby
|
||||||
|
-
|
||||||
|
- if (!list.isEmpty()) {
|
||||||
|
- // Paper - move up
|
||||||
|
- int j;
|
||||||
|
-
|
||||||
|
- if (i > 0 && list.size() > i - 1 && this.random.nextInt(4) == 0) {
|
||||||
|
- j = 0;
|
||||||
|
-
|
||||||
|
- for (int k = 0; k < list.size(); ++k) {
|
||||||
|
- if (!((Entity) list.get(k)).isPassenger()) {
|
||||||
|
- ++j;
|
||||||
|
- }
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- if (j > i - 1) {
|
||||||
|
- this.damageEntity(DamageSource.CRAMMING, 6.0F);
|
||||||
|
- }
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- numCollisions = Math.max(0, numCollisions - world.paperConfig.maxCollisionsPerEntity); // Paper
|
||||||
|
- for (j = 0; j < list.size() && numCollisions < world.paperConfig.maxCollisionsPerEntity; ++j) { // Paper
|
||||||
|
- Entity entity = (Entity) list.get(j);
|
||||||
|
- entity.numCollisions++; // Paper
|
||||||
|
- numCollisions++; // Paper
|
||||||
|
-
|
||||||
|
- this.C(entity);
|
||||||
|
- }
|
||||||
|
- }
|
||||||
|
+ if(de.tr7zw.yapfa.YapfaConfig.onlyPlayerCollisions) {
|
||||||
|
+ this.world.getEntities(this, this.getBoundingBox(), entity -> entity.getEntityType() == EntityTypes.PLAYER, list);
|
||||||
|
+ } else {
|
||||||
|
+ this.world.getEntities(this, this.getBoundingBox(), IEntitySelector.a(this), list);
|
||||||
|
+ }
|
||||||
|
+ // Tuinity end - reduce memory allocation from collideNearby
|
||||||
|
+ // YAPFA end
|
||||||
|
+
|
||||||
|
+ if (!list.isEmpty()) {
|
||||||
|
+ // Paper - move up
|
||||||
|
+ int j;
|
||||||
|
+
|
||||||
|
+ if (i > 0 && list.size() > i - 1 && this.random.nextInt(4) == 0) {
|
||||||
|
+ j = 0;
|
||||||
|
+
|
||||||
|
+ for (int k = 0; k < list.size(); ++k) {
|
||||||
|
+ if (!((Entity) list.get(k)).isPassenger()) {
|
||||||
|
+ ++j;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ if (j > i - 1) {
|
||||||
|
+ this.damageEntity(DamageSource.CRAMMING, 6.0F);
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ numCollisions = Math.max(0, numCollisions - world.paperConfig.maxCollisionsPerEntity); // Paper
|
||||||
|
+ for (j = 0; j < list.size() && numCollisions < world.paperConfig.maxCollisionsPerEntity; ++j) { // Paper
|
||||||
|
+ Entity entity = (Entity) list.get(j);
|
||||||
|
+ entity.numCollisions++; // Paper
|
||||||
|
+ numCollisions++; // Paper
|
||||||
|
+
|
||||||
|
+ this.C(entity);
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
} finally { // Tuinity start - reduce memory allocation from collideNearby
|
||||||
|
com.tuinity.tuinity.util.CachedLists.returnTempGetEntitiesList(list);
|
||||||
|
} // Tuinity end - reduce memory allocation from collideNearby
|
||||||
|
--
|
||||||
|
2.25.1.windows.1
|
||||||
|
|
@ -0,0 +1,59 @@
|
|||||||
|
From 57f33a9c1b3edc95b89073c30746a1dd7215e466 Mon Sep 17 00:00:00 2001
|
||||||
|
From: tr7zw <tr7zw@live.de>
|
||||||
|
Date: Sun, 29 Mar 2020 00:35:03 +0100
|
||||||
|
Subject: [PATCH] Allow to change the piston push limit
|
||||||
|
|
||||||
|
---
|
||||||
|
src/main/java/de/tr7zw/yapfa/YapfaConfig.java | 4 ++++
|
||||||
|
.../java/net/minecraft/server/PistonExtendsChecker.java | 6 +++---
|
||||||
|
2 files changed, 7 insertions(+), 3 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/src/main/java/de/tr7zw/yapfa/YapfaConfig.java b/src/main/java/de/tr7zw/yapfa/YapfaConfig.java
|
||||||
|
index 071e9f9a5..716b2dea9 100644
|
||||||
|
--- a/src/main/java/de/tr7zw/yapfa/YapfaConfig.java
|
||||||
|
+++ b/src/main/java/de/tr7zw/yapfa/YapfaConfig.java
|
||||||
|
@@ -211,5 +211,9 @@ public class YapfaConfig {
|
||||||
|
onlyPlayerCollisions = getBoolean("settings.onlyPlayerCollisions", false);
|
||||||
|
}
|
||||||
|
|
||||||
|
+ public static int pistonPushLimit = 12;
|
||||||
|
+ private static void pistonPushLimit() {
|
||||||
|
+ pistonPushLimit = getInt("settings.pistonPushLimit", 12);
|
||||||
|
+ }
|
||||||
|
|
||||||
|
}
|
||||||
|
\ No newline at end of file
|
||||||
|
diff --git a/src/main/java/net/minecraft/server/PistonExtendsChecker.java b/src/main/java/net/minecraft/server/PistonExtendsChecker.java
|
||||||
|
index 95aeaaf0b..dd64aad1e 100644
|
||||||
|
--- a/src/main/java/net/minecraft/server/PistonExtendsChecker.java
|
||||||
|
+++ b/src/main/java/net/minecraft/server/PistonExtendsChecker.java
|
||||||
|
@@ -79,7 +79,7 @@ public class PistonExtendsChecker {
|
||||||
|
} else {
|
||||||
|
int i = 1;
|
||||||
|
|
||||||
|
- if (i + this.f.size() > 12) {
|
||||||
|
+ if (i + this.f.size() > de.tr7zw.yapfa.YapfaConfig.pistonPushLimit) { // YAPFA
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
while (a(block)) {
|
||||||
|
@@ -93,7 +93,7 @@ public class PistonExtendsChecker {
|
||||||
|
}
|
||||||
|
|
||||||
|
++i;
|
||||||
|
- if (i + this.f.size() > 12) {
|
||||||
|
+ if (i + this.f.size() > de.tr7zw.yapfa.YapfaConfig.pistonPushLimit) { // YAPFA
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@@ -141,7 +141,7 @@ public class PistonExtendsChecker {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
- if (this.f.size() >= 12) {
|
||||||
|
+ if (this.f.size() >= de.tr7zw.yapfa.YapfaConfig.pistonPushLimit) { // YAPFA
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
--
|
||||||
|
2.25.1.windows.1
|
||||||
|
|
27
patches/server/0009-Add-NBT-API-as-first-class-lib.patch
Normal file
27
patches/server/0009-Add-NBT-API-as-first-class-lib.patch
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
From 3d29c492e31430bd5ec8e6eaa596d11d69416010 Mon Sep 17 00:00:00 2001
|
||||||
|
From: tr7zw <tr7zw@live.de>
|
||||||
|
Date: Thu, 2 Apr 2020 18:49:38 +0200
|
||||||
|
Subject: [PATCH] Add NBT-API as first-class lib
|
||||||
|
|
||||||
|
---
|
||||||
|
pom.xml | 4 ++++
|
||||||
|
1 file changed, 4 insertions(+)
|
||||||
|
|
||||||
|
diff --git a/pom.xml b/pom.xml
|
||||||
|
index 8351a3d3d..748182c43 100644
|
||||||
|
--- a/pom.xml
|
||||||
|
+++ b/pom.xml
|
||||||
|
@@ -306,6 +306,10 @@
|
||||||
|
<pattern>net.minecraft.server</pattern>
|
||||||
|
<shadedPattern>net.minecraft.server.v${minecraft_version}</shadedPattern>
|
||||||
|
</relocation>
|
||||||
|
+ <relocation>
|
||||||
|
+ <pattern>de.tr7zw.changeme.nbtapi</pattern>
|
||||||
|
+ <shadedPattern>de.tr7zw.nbtapi</shadedPattern>
|
||||||
|
+ </relocation>
|
||||||
|
</relocations>
|
||||||
|
<transformers>
|
||||||
|
<transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
|
||||||
|
--
|
||||||
|
2.25.1.windows.1
|
||||||
|
|
367
patches/server/0010-Player-saving-async-FileIO.patch
Normal file
367
patches/server/0010-Player-saving-async-FileIO.patch
Normal file
@ -0,0 +1,367 @@
|
|||||||
|
From c8bbeeb2508aff00d20faa04226225750d4ba734 Mon Sep 17 00:00:00 2001
|
||||||
|
From: tr7zw <tr7zw@live.de>
|
||||||
|
Date: Sat, 4 Apr 2020 23:23:04 +0200
|
||||||
|
Subject: [PATCH] Player saving async FileIO
|
||||||
|
|
||||||
|
---
|
||||||
|
.../server/AdvancementDataPlayer.java | 106 ++++++++++--------
|
||||||
|
.../net/minecraft/server/EntityHuman.java | 16 ++-
|
||||||
|
.../java/net/minecraft/server/PlayerList.java | 28 ++++-
|
||||||
|
.../server/ServerStatisticManager.java | 21 +++-
|
||||||
|
.../net/minecraft/server/WorldNBTStorage.java | 29 +++--
|
||||||
|
5 files changed, 138 insertions(+), 62 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/src/main/java/net/minecraft/server/AdvancementDataPlayer.java b/src/main/java/net/minecraft/server/AdvancementDataPlayer.java
|
||||||
|
index 57b9d1344..540bd10f7 100644
|
||||||
|
--- a/src/main/java/net/minecraft/server/AdvancementDataPlayer.java
|
||||||
|
+++ b/src/main/java/net/minecraft/server/AdvancementDataPlayer.java
|
||||||
|
@@ -27,6 +27,8 @@ import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
import java.util.Set;
|
||||||
|
+import java.util.concurrent.ExecutorService;
|
||||||
|
+import java.util.concurrent.Executors;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
@@ -50,6 +52,7 @@ public class AdvancementDataPlayer {
|
||||||
|
@Nullable
|
||||||
|
private Advancement l;
|
||||||
|
private boolean m = true;
|
||||||
|
+ public static ExecutorService saveThread = Executors.newSingleThreadExecutor(); // YAPFA
|
||||||
|
|
||||||
|
public AdvancementDataPlayer(DataFixer datafixer, PlayerList playerlist, AdvancementDataWorld advancementdataworld, File file, EntityPlayer entityplayer) {
|
||||||
|
this.d = datafixer;
|
||||||
|
@@ -223,53 +226,66 @@ public class AdvancementDataPlayer {
|
||||||
|
|
||||||
|
jsonelement.getAsJsonObject().addProperty("DataVersion", SharedConstants.getGameVersion().getWorldVersion());
|
||||||
|
|
||||||
|
+ // YAPFA start
|
||||||
|
+ String gson = null;
|
||||||
|
try {
|
||||||
|
- FileOutputStream fileoutputstream = new FileOutputStream(this.f);
|
||||||
|
- Throwable throwable = null;
|
||||||
|
-
|
||||||
|
- try {
|
||||||
|
- OutputStreamWriter outputstreamwriter = new OutputStreamWriter(fileoutputstream, Charsets.UTF_8.newEncoder());
|
||||||
|
- Throwable throwable1 = null;
|
||||||
|
-
|
||||||
|
- try {
|
||||||
|
- AdvancementDataPlayer.b.toJson(jsonelement, outputstreamwriter);
|
||||||
|
- } catch (Throwable throwable2) {
|
||||||
|
- throwable1 = throwable2;
|
||||||
|
- throw throwable2;
|
||||||
|
- } finally {
|
||||||
|
- if (outputstreamwriter != null) {
|
||||||
|
- if (throwable1 != null) {
|
||||||
|
- try {
|
||||||
|
- outputstreamwriter.close();
|
||||||
|
- } catch (Throwable throwable3) {
|
||||||
|
- throwable1.addSuppressed(throwable3);
|
||||||
|
- }
|
||||||
|
- } else {
|
||||||
|
- outputstreamwriter.close();
|
||||||
|
- }
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- }
|
||||||
|
- } catch (Throwable throwable4) {
|
||||||
|
- throwable = throwable4;
|
||||||
|
- throw throwable4;
|
||||||
|
- } finally {
|
||||||
|
- if (fileoutputstream != null) {
|
||||||
|
- if (throwable != null) {
|
||||||
|
- try {
|
||||||
|
- fileoutputstream.close();
|
||||||
|
- } catch (Throwable throwable5) {
|
||||||
|
- throwable.addSuppressed(throwable5);
|
||||||
|
- }
|
||||||
|
- } else {
|
||||||
|
- fileoutputstream.close();
|
||||||
|
- }
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- }
|
||||||
|
- } catch (IOException ioexception) {
|
||||||
|
- AdvancementDataPlayer.LOGGER.error("Couldn't save player advancements to {}", this.f, ioexception);
|
||||||
|
+ gson = AdvancementDataPlayer.b.toJson(jsonelement);
|
||||||
|
+ } catch (Throwable throwable) {
|
||||||
|
+ throw throwable;
|
||||||
|
+ }
|
||||||
|
+ if(gson != null) {
|
||||||
|
+ final String fGson = gson;
|
||||||
|
+ saveThread.submit(() -> {
|
||||||
|
+ try {
|
||||||
|
+ FileOutputStream fileoutputstream = new FileOutputStream(this.f);
|
||||||
|
+ Throwable throwable = null;
|
||||||
|
+
|
||||||
|
+ try {
|
||||||
|
+ OutputStreamWriter outputstreamwriter = new OutputStreamWriter(fileoutputstream, Charsets.UTF_8.newEncoder());
|
||||||
|
+ Throwable throwable1 = null;
|
||||||
|
+
|
||||||
|
+ try {
|
||||||
|
+ outputstreamwriter.write(fGson);
|
||||||
|
+ } catch (Throwable throwable2) {
|
||||||
|
+ throwable1 = throwable2;
|
||||||
|
+ throw throwable2;
|
||||||
|
+ } finally {
|
||||||
|
+ if (outputstreamwriter != null) {
|
||||||
|
+ if (throwable1 != null) {
|
||||||
|
+ try {
|
||||||
|
+ outputstreamwriter.close();
|
||||||
|
+ } catch (Throwable throwable3) {
|
||||||
|
+ throwable1.addSuppressed(throwable3);
|
||||||
|
+ }
|
||||||
|
+ } else {
|
||||||
|
+ outputstreamwriter.close();
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ }
|
||||||
|
+ } catch (Throwable throwable4) {
|
||||||
|
+ throwable = throwable4;
|
||||||
|
+ throw throwable4;
|
||||||
|
+ } finally {
|
||||||
|
+ if (fileoutputstream != null) {
|
||||||
|
+ if (throwable != null) {
|
||||||
|
+ try {
|
||||||
|
+ fileoutputstream.close();
|
||||||
|
+ } catch (Throwable throwable5) {
|
||||||
|
+ throwable.addSuppressed(throwable5);
|
||||||
|
+ }
|
||||||
|
+ } else {
|
||||||
|
+ fileoutputstream.close();
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ }
|
||||||
|
+ } catch (IOException ioexception) {
|
||||||
|
+ AdvancementDataPlayer.LOGGER.error("Couldn't save player advancements to {}", this.f, ioexception);
|
||||||
|
+ }
|
||||||
|
+ });
|
||||||
|
}
|
||||||
|
+ // YAPFA end
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
diff --git a/src/main/java/net/minecraft/server/EntityHuman.java b/src/main/java/net/minecraft/server/EntityHuman.java
|
||||||
|
index 2cada09ce..321726139 100644
|
||||||
|
--- a/src/main/java/net/minecraft/server/EntityHuman.java
|
||||||
|
+++ b/src/main/java/net/minecraft/server/EntityHuman.java
|
||||||
|
@@ -700,11 +700,23 @@ public abstract class EntityHuman extends EntityLiving {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
+ // YAPFA start
|
||||||
|
+ private NBTTagList inventorySnapshot = null;
|
||||||
|
+ private NBTTagList enderchestSnapshot = null;
|
||||||
|
+
|
||||||
|
+
|
||||||
|
+ public void takeInventorySnapshot() {
|
||||||
|
+ inventorySnapshot = this.inventory.a(new NBTTagList());
|
||||||
|
+ enderchestSnapshot = this.enderChest.g();
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ // YAPFA end
|
||||||
|
+
|
||||||
|
@Override
|
||||||
|
public void saveData(NBTTagCompound nbttagcompound) {
|
||||||
|
super.saveData(nbttagcompound);
|
||||||
|
nbttagcompound.setInt("DataVersion", SharedConstants.getGameVersion().getWorldVersion());
|
||||||
|
- nbttagcompound.set("Inventory", this.inventory.a(new NBTTagList()));
|
||||||
|
+ nbttagcompound.set("Inventory", inventorySnapshot != null ? inventorySnapshot : this.inventory.a(new NBTTagList())); inventorySnapshot = null;// YAPFA
|
||||||
|
nbttagcompound.setInt("SelectedItemSlot", this.inventory.itemInHandIndex);
|
||||||
|
nbttagcompound.setShort("SleepTimer", (short) this.sleepTicks);
|
||||||
|
nbttagcompound.setFloat("XpP", this.exp);
|
||||||
|
@@ -714,7 +726,7 @@ public abstract class EntityHuman extends EntityLiving {
|
||||||
|
nbttagcompound.setInt("Score", this.getScore());
|
||||||
|
this.foodData.b(nbttagcompound);
|
||||||
|
this.abilities.a(nbttagcompound);
|
||||||
|
- nbttagcompound.set("EnderItems", this.enderChest.g());
|
||||||
|
+ nbttagcompound.set("EnderItems", enderchestSnapshot != null ? enderchestSnapshot : this.enderChest.g()); enderchestSnapshot = null;// YAPFA
|
||||||
|
if (!this.getShoulderEntityLeft().isEmpty()) {
|
||||||
|
nbttagcompound.set("ShoulderEntityLeft", this.getShoulderEntityLeft());
|
||||||
|
}
|
||||||
|
diff --git a/src/main/java/net/minecraft/server/PlayerList.java b/src/main/java/net/minecraft/server/PlayerList.java
|
||||||
|
index 35d7ac60f..c217bae5b 100644
|
||||||
|
--- a/src/main/java/net/minecraft/server/PlayerList.java
|
||||||
|
+++ b/src/main/java/net/minecraft/server/PlayerList.java
|
||||||
|
@@ -19,6 +19,8 @@ import java.util.Optional;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.UUID;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
+import java.util.concurrent.TimeUnit;
|
||||||
|
+
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
@@ -1241,6 +1243,28 @@ public abstract class PlayerList {
|
||||||
|
if (team != null) scoreboard.removeTeam(team);
|
||||||
|
}
|
||||||
|
// Paper end
|
||||||
|
+
|
||||||
|
+ // YAPFA start - make sure all saves are done
|
||||||
|
+ try {
|
||||||
|
+ ((WorldNBTStorage)playerFileData).saveThread.shutdown();
|
||||||
|
+ boolean done = ((WorldNBTStorage)playerFileData).saveThread.awaitTermination(60, TimeUnit.SECONDS);
|
||||||
|
+ if(!done) {
|
||||||
|
+ LOGGER.error("Players did not save completly!");
|
||||||
|
+ }
|
||||||
|
+ ServerStatisticManager.saveThread.shutdown();
|
||||||
|
+ done = ServerStatisticManager.saveThread.awaitTermination(60, TimeUnit.SECONDS);
|
||||||
|
+ if(!done) {
|
||||||
|
+ LOGGER.error("Stats did not save completly!");
|
||||||
|
+ }
|
||||||
|
+ AdvancementDataPlayer.saveThread.shutdown();
|
||||||
|
+ done = AdvancementDataPlayer.saveThread.awaitTermination(60, TimeUnit.SECONDS);
|
||||||
|
+ if(!done) {
|
||||||
|
+ LOGGER.error("Advancements did not save completly!");
|
||||||
|
+ }
|
||||||
|
+ } catch (InterruptedException e) {
|
||||||
|
+ e.printStackTrace();
|
||||||
|
+ }
|
||||||
|
+ // YAPFA end
|
||||||
|
}
|
||||||
|
// Paper end
|
||||||
|
|
||||||
|
@@ -1278,13 +1302,13 @@ public abstract class PlayerList {
|
||||||
|
File file = this.server.a(SavedFile.STATS).toFile();
|
||||||
|
File file1 = new File(file, uuid + ".json");
|
||||||
|
|
||||||
|
- if (!file1.exists()) {
|
||||||
|
+ /*if (!file1.exists()) { // YAPFA dont check for old stats files with sync File IO
|
||||||
|
File file2 = new File(file, displayName + ".json"); // CraftBukkit
|
||||||
|
|
||||||
|
if (file2.exists() && file2.isFile()) {
|
||||||
|
file2.renameTo(file1);
|
||||||
|
}
|
||||||
|
- }
|
||||||
|
+ }*/
|
||||||
|
|
||||||
|
serverstatisticmanager = new ServerStatisticManager(this.server, file1);
|
||||||
|
// this.o.put(uuid, serverstatisticmanager); // CraftBukkit
|
||||||
|
diff --git a/src/main/java/net/minecraft/server/ServerStatisticManager.java b/src/main/java/net/minecraft/server/ServerStatisticManager.java
|
||||||
|
index 18725272f..5033db43e 100644
|
||||||
|
--- a/src/main/java/net/minecraft/server/ServerStatisticManager.java
|
||||||
|
+++ b/src/main/java/net/minecraft/server/ServerStatisticManager.java
|
||||||
|
@@ -20,6 +20,10 @@ import java.util.Map;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.Set;
|
||||||
|
+import java.util.Map.Entry;
|
||||||
|
+import java.util.concurrent.ExecutorService;
|
||||||
|
+import java.util.concurrent.Executors;
|
||||||
|
+
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
|
@@ -30,6 +34,7 @@ public class ServerStatisticManager extends StatisticManager {
|
||||||
|
private final File d;
|
||||||
|
private final Set<Statistic<?>> e = Sets.newHashSet();
|
||||||
|
private int f = -300;
|
||||||
|
+ public static ExecutorService saveThread = Executors.newSingleThreadExecutor(); // YAPFA
|
||||||
|
|
||||||
|
public ServerStatisticManager(MinecraftServer minecraftserver, File file) {
|
||||||
|
this.c = minecraftserver;
|
||||||
|
@@ -40,7 +45,9 @@ public class ServerStatisticManager extends StatisticManager {
|
||||||
|
Statistic<MinecraftKey> wrapper = StatisticList.CUSTOM.b( entry.getKey() );
|
||||||
|
this.a.put( wrapper, entry.getValue().intValue() );
|
||||||
|
}
|
||||||
|
- // Spigot end
|
||||||
|
+ // Spigot ends
|
||||||
|
+ // YAPFA start
|
||||||
|
+ saveThread.submit(() -> {
|
||||||
|
if (file.isFile()) {
|
||||||
|
try {
|
||||||
|
this.a(minecraftserver.getDataFixer(), org.apache.commons.io.FileUtils.readFileToString(file));
|
||||||
|
@@ -50,17 +57,21 @@ public class ServerStatisticManager extends StatisticManager {
|
||||||
|
ServerStatisticManager.LOGGER.error("Couldn't parse statistics file {}", file, jsonparseexception);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
-
|
||||||
|
+ });
|
||||||
|
}
|
||||||
|
|
||||||
|
public void save() {
|
||||||
|
if ( org.spigotmc.SpigotConfig.disableStatSaving ) return; // Spigot
|
||||||
|
+ // YAPFA start
|
||||||
|
+ String str = this.b();
|
||||||
|
+ saveThread.submit(() -> {
|
||||||
|
try {
|
||||||
|
- org.apache.commons.io.FileUtils.writeStringToFile(this.d, this.b());
|
||||||
|
+ org.apache.commons.io.FileUtils.writeStringToFile(this.d, str);
|
||||||
|
} catch (IOException ioexception) {
|
||||||
|
ServerStatisticManager.LOGGER.error("Couldn't save stats", ioexception);
|
||||||
|
}
|
||||||
|
-
|
||||||
|
+ });
|
||||||
|
+ // YAPFA end
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@@ -111,7 +122,7 @@ public class ServerStatisticManager extends StatisticManager {
|
||||||
|
|
||||||
|
if (nbttagcompound2.hasKeyOfType(s2, 99)) {
|
||||||
|
SystemUtils.a(this.a(statisticwrapper, s2), (statistic) -> {
|
||||||
|
- this.a.put(statistic, nbttagcompound2.getInt(s2));
|
||||||
|
+ this.a.put(statistic, nbttagcompound2.getInt(s2) + this.a.getOrDefault(statistic, 0)); // YAPFA fix async load
|
||||||
|
}, () -> {
|
||||||
|
ServerStatisticManager.LOGGER.warn("Invalid statistic in {}: Don't know what {} is", this.d, s2);
|
||||||
|
});
|
||||||
|
diff --git a/src/main/java/net/minecraft/server/WorldNBTStorage.java b/src/main/java/net/minecraft/server/WorldNBTStorage.java
|
||||||
|
index 41a1b93a9..9517fb046 100644
|
||||||
|
--- a/src/main/java/net/minecraft/server/WorldNBTStorage.java
|
||||||
|
+++ b/src/main/java/net/minecraft/server/WorldNBTStorage.java
|
||||||
|
@@ -11,6 +11,10 @@ import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
|
// CraftBukkit start
|
||||||
|
+import java.util.UUID;
|
||||||
|
+import java.util.concurrent.ExecutorService;
|
||||||
|
+import java.util.concurrent.Executors;
|
||||||
|
+
|
||||||
|
import org.bukkit.craftbukkit.entity.CraftPlayer;
|
||||||
|
// CraftBukkit end
|
||||||
|
|
||||||
|
@@ -19,6 +23,7 @@ public class WorldNBTStorage {
|
||||||
|
private static final Logger LOGGER = LogManager.getLogger();
|
||||||
|
private final File playerDir;
|
||||||
|
protected final DataFixer a;
|
||||||
|
+ public ExecutorService saveThread = Executors.newSingleThreadExecutor(); // YAPFA
|
||||||
|
|
||||||
|
public WorldNBTStorage(Convertable.ConversionSession convertable_conversionsession, DataFixer datafixer) {
|
||||||
|
this.a = datafixer;
|
||||||
|
@@ -29,14 +34,22 @@ public class WorldNBTStorage {
|
||||||
|
public void save(EntityHuman entityhuman) {
|
||||||
|
if(!com.destroystokyo.paper.PaperConfig.savePlayerData) return; // Paper - Make player data saving configurable
|
||||||
|
try {
|
||||||
|
- NBTTagCompound nbttagcompound = entityhuman.save(new NBTTagCompound());
|
||||||
|
- File file = File.createTempFile(entityhuman.getUniqueIDString() + "-", ".dat", this.playerDir);
|
||||||
|
-
|
||||||
|
- NBTCompressedStreamTools.a(nbttagcompound, (OutputStream) (new FileOutputStream(file)));
|
||||||
|
- File file1 = new File(this.playerDir, entityhuman.getUniqueIDString() + ".dat");
|
||||||
|
- File file2 = new File(this.playerDir, entityhuman.getUniqueIDString() + ".dat_old");
|
||||||
|
-
|
||||||
|
- SystemUtils.a(file1, file, file2);
|
||||||
|
+ // YAPFA start
|
||||||
|
+ entityhuman.takeInventorySnapshot(); // Take a sync inventory/enderchest snapshot to prevent duping
|
||||||
|
+ saveThread.submit(() -> { // Save the tag async
|
||||||
|
+ try {
|
||||||
|
+ NBTTagCompound nbttagcompound = entityhuman.save(new NBTTagCompound());
|
||||||
|
+ File file = File.createTempFile(entityhuman.getUniqueIDString() + "-", ".dat", this.playerDir);
|
||||||
|
+ File file1 = new File(this.playerDir, entityhuman.getUniqueIDString() + ".dat");
|
||||||
|
+ File file2 = new File(this.playerDir, entityhuman.getUniqueIDString() + ".dat_old");
|
||||||
|
+
|
||||||
|
+ NBTCompressedStreamTools.a(nbttagcompound, (OutputStream) (new FileOutputStream(file)));
|
||||||
|
+ SystemUtils.a(file1, file, file2);
|
||||||
|
+ } catch (Exception exception) {
|
||||||
|
+ WorldNBTStorage.LOGGER.error("Failed to save player data for {}", entityhuman.getName(), exception); // Paper
|
||||||
|
+ }
|
||||||
|
+ });
|
||||||
|
+ // YAPFA end
|
||||||
|
} catch (Exception exception) {
|
||||||
|
WorldNBTStorage.LOGGER.error("Failed to save player data for {}", entityhuman.getName(), exception); // Paper
|
||||||
|
}
|
||||||
|
--
|
||||||
|
2.25.1.windows.1
|
||||||
|
|
Loading…
Reference in New Issue
Block a user