From 6ac01e293717b92e541ff5a51cc75738863f7f25 Mon Sep 17 00:00:00 2001 From: Dreeam <61569423+Dreeam-qwq@users.noreply.github.com> Date: Sun, 18 Feb 2024 05:02:55 -0500 Subject: [PATCH] [ci skip] Update comments (36/60) --- patches/api/0007-KeYi-Player-Skull-API.patch | 10 +-- ...llow-unknown-event-thread-execution.patch} | 10 +-- .../server/0018-KeYi-Player-Skull-API.patch | 17 ++-- ...ble-arrow-despawn-counter-by-default.patch | 4 +- ...on-for-spigot-item-merging-mechanism.patch | 6 +- ...rpet-Fixes-Optimized-getBiome-method.patch | 6 +- ...et-Fixes-Use-optimized-RecipeManager.patch | 4 +- ...Akarin-Save-Json-list-asynchronously.patch | 83 +++++-------------- 8 files changed, 51 insertions(+), 89 deletions(-) rename patches/server/{0017-KTP-Optimize-spigot-event-bus.patch => 0017-KTP-Allow-unknown-event-thread-execution.patch} (85%) diff --git a/patches/api/0007-KeYi-Player-Skull-API.patch b/patches/api/0007-KeYi-Player-Skull-API.patch index f1bf2e16..a71bdf0c 100644 --- a/patches/api/0007-KeYi-Player-Skull-API.patch +++ b/patches/api/0007-KeYi-Player-Skull-API.patch @@ -7,17 +7,17 @@ Original license: MIT Original project: https://github.com/KeYiMC/KeYi diff --git a/src/main/java/org/bukkit/entity/Player.java b/src/main/java/org/bukkit/entity/Player.java -index f42b134854201a94601f2660cb62a8211a8f49f7..9c6b5799897237ce0095087fdc9eec446420cc1f 100644 +index f42b134854201a94601f2660cb62a8211a8f49f7..7d0dbadbc3010c3e348ba408c2e3fda8577d767f 100644 --- a/src/main/java/org/bukkit/entity/Player.java +++ b/src/main/java/org/bukkit/entity/Player.java @@ -9,6 +9,10 @@ import java.util.Date; import java.util.Map; import java.util.UUID; import org.bukkit.BanEntry; -+// KeYi start ++// Leaf start - KeYi - Player Skull API +import java.util.concurrent.CompletableFuture; +import net.kyori.adventure.text.Component; -+// KeYi end ++// Leaf start - KeYi import org.bukkit.DyeColor; import org.bukkit.Effect; import org.bukkit.GameMode; @@ -26,7 +26,7 @@ index f42b134854201a94601f2660cb62a8211a8f49f7..9c6b5799897237ce0095087fdc9eec44 } // Purpur end + -+ // KeYi start ++ // Leaf start - KeYi - Player Skull API + /** + * Get a skull item of a player. + * This method runs on main thread, which may freeze the server. @@ -42,5 +42,5 @@ index f42b134854201a94601f2660cb62a8211a8f49f7..9c6b5799897237ce0095087fdc9eec44 + * @return A CompletableFuture of the skull ItemStack of the player + */ + CompletableFuture getSkullAsynchronously(); -+ // KeYi end ++ // Leaf end - KeYi } diff --git a/patches/server/0017-KTP-Optimize-spigot-event-bus.patch b/patches/server/0017-KTP-Allow-unknown-event-thread-execution.patch similarity index 85% rename from patches/server/0017-KTP-Optimize-spigot-event-bus.patch rename to patches/server/0017-KTP-Allow-unknown-event-thread-execution.patch index bbab50d7..e06566c2 100644 --- a/patches/server/0017-KTP-Optimize-spigot-event-bus.patch +++ b/patches/server/0017-KTP-Allow-unknown-event-thread-execution.patch @@ -1,15 +1,15 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Bjarne Koll Date: Sun, 19 Feb 2023 16:14:28 +0100 -Subject: [PATCH] KTP: Optimize spigot event bus +Subject: [PATCH] KTP: Allow unknown event thread execution Original license: GPL v3 Original project: https://github.com/lynxplay/ktp -This patch contains a lot of small optimizations to the spigot event bus -to improve its speed as much as possible, allowing for a large amount of -events to be published by the server without impacting the overall -performance too much. +This patch allows events to actively define that they may or may not be +called on the main thread of the server. +This is preferred over passing the "asyncness" of the event as async +bool parameter to the event instance every time. diff --git a/src/main/java/io/papermc/paper/plugin/manager/PaperEventManager.java b/src/main/java/io/papermc/paper/plugin/manager/PaperEventManager.java index a1c9726d25479b5326fe2fa2b0f5a98d6b2da4c5..06dfd0b27ac0006a2be07f54a0702519a691c6ec 100644 diff --git a/patches/server/0018-KeYi-Player-Skull-API.patch b/patches/server/0018-KeYi-Player-Skull-API.patch index 3fcb835e..dbd7c5b9 100644 --- a/patches/server/0018-KeYi-Player-Skull-API.patch +++ b/patches/server/0018-KeYi-Player-Skull-API.patch @@ -7,18 +7,18 @@ Original license: MIT Original project: https://github.com/KeYiMC/KeYi diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java -index d6122c121d6e18d276fb78865c6a680e9afc3378..326197e40b97415346bac4fb00a4fba4891a4de2 100644 +index d6122c121d6e18d276fb78865c6a680e9afc3378..ce70f01611181e8f4c7324c7b9f9944a8605c710 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java @@ -29,6 +29,11 @@ import java.util.Optional; import java.util.Set; import java.util.UUID; import java.util.WeakHashMap; -+// KeYi start ++// Leaf start - KeYi - Player Skull API +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; -+// KeYi end ++// Leaf end - KeYi import java.util.logging.Level; import java.util.logging.Logger; import javax.annotation.Nullable; @@ -26,23 +26,22 @@ index d6122c121d6e18d276fb78865c6a680e9afc3378..326197e40b97415346bac4fb00a4fba4 import org.bukkit.inventory.EquipmentSlot; import org.bukkit.inventory.InventoryView.Property; import org.bukkit.inventory.ItemStack; -+import org.bukkit.inventory.meta.SkullMeta; ++import org.bukkit.inventory.meta.SkullMeta; // Leaf - KeYi - Player Skull API import org.bukkit.map.MapCursor; import org.bukkit.map.MapView; import org.bukkit.metadata.MetadataValue; -@@ -3524,4 +3530,28 @@ public class CraftPlayer extends CraftHumanEntity implements Player { +@@ -3524,4 +3530,27 @@ public class CraftPlayer extends CraftHumanEntity implements Player { this.getHandle().connection.send(new net.minecraft.network.protocol.game.ClientboundPlayerCombatKillPacket(getEntityId(), io.papermc.paper.adventure.PaperAdventure.asVanilla(message))); } // Purpur end + -+ // KeYi start ++ // Leaf start - KeYi - Player Skull API + @Override + public ItemStack getSkull() { + ItemStack skull = new ItemStack(Material.PLAYER_HEAD, 1); + SkullMeta meta = (SkullMeta) skull.getItemMeta(); + + meta.setOwningPlayer(this); -+ + skull.setItemMeta(meta); + + return skull; @@ -52,10 +51,10 @@ index d6122c121d6e18d276fb78865c6a680e9afc3378..326197e40b97415346bac4fb00a4fba4 + public CompletableFuture getSkullAsynchronously() { + ExecutorService executorService = Executors.newCachedThreadPool(); + -+ CompletableFuture future = (CompletableFuture) executorService.submit(() -> getSkull()); ++ CompletableFuture future = (CompletableFuture) executorService.submit(this::getSkull); + executorService.shutdown(); + + return future; + } -+ // KeYi end ++ // Leaf end - KeYi } diff --git a/patches/server/0019-KeYi-Disable-arrow-despawn-counter-by-default.patch b/patches/server/0019-KeYi-Disable-arrow-despawn-counter-by-default.patch index 65bffcbb..b7cb752c 100644 --- a/patches/server/0019-KeYi-Disable-arrow-despawn-counter-by-default.patch +++ b/patches/server/0019-KeYi-Disable-arrow-despawn-counter-by-default.patch @@ -7,7 +7,7 @@ Original license: MIT Original project: https://github.com/KeYiMC/KeYi diff --git a/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java b/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java -index 5fe6f626b63274e33f7c8b46441d17cf4ff9d533..1b1bf657993c2a96d7168e3b1161872839a6e67a 100644 +index 5fe6f626b63274e33f7c8b46441d17cf4ff9d533..fcc5d94b52036eb7b6c5e5316eef0919e7f6ea08 100644 --- a/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java +++ b/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java @@ -140,7 +140,7 @@ public class GaleWorldConfiguration extends ConfigurationPart { @@ -15,7 +15,7 @@ index 5fe6f626b63274e33f7c8b46441d17cf4ff9d533..1b1bf657993c2a96d7168e3b11618728 } - public boolean arrowMovementResetsDespawnCounter = true; // Gale - Purpur - make arrow movement resetting despawn counter configurable -+ public boolean arrowMovementResetsDespawnCounter = false; // Gale - Purpur - make arrow movement resetting despawn counter configurable // KeYi - disable arrow despawn counter by default ++ public boolean arrowMovementResetsDespawnCounter = false; // Gale - Purpur - make arrow movement resetting despawn counter configurable // Leaf - KeYi - disable arrow despawn counter by default public boolean entitiesCanRandomStrollIntoNonTickingChunks = true; // Gale - MultiPaper - prevent entities random strolling into non-ticking chunks public double entityWakeUpDurationRatioStandardDeviation = 0.2; // Gale - variable entity wake-up duration public boolean hideFlamesOnEntitiesWithFireResistance = false; // Gale - Slice - hide flames on entities with fire resistance diff --git a/patches/server/0020-KeYi-Add-an-option-for-spigot-item-merging-mechanism.patch b/patches/server/0020-KeYi-Add-an-option-for-spigot-item-merging-mechanism.patch index 40a0e240..4c79e371 100644 --- a/patches/server/0020-KeYi-Add-an-option-for-spigot-item-merging-mechanism.patch +++ b/patches/server/0020-KeYi-Add-an-option-for-spigot-item-merging-mechanism.patch @@ -7,7 +7,7 @@ Original license: MIT Original project: https://github.com/KeYiMC/KeYi diff --git a/src/main/java/net/minecraft/world/entity/item/ItemEntity.java b/src/main/java/net/minecraft/world/entity/item/ItemEntity.java -index d9bc196c653aff84913bbb0e495fe735e366d23f..1f61dc925624c493ae458748e8422383104b022f 100644 +index 2c19d6687e1554373e4c7f43a8fec8e770942f50..7f1803d073ba3a4be2c93c52dd1775f678ced7ae 100644 --- a/src/main/java/net/minecraft/world/entity/item/ItemEntity.java +++ b/src/main/java/net/minecraft/world/entity/item/ItemEntity.java @@ -349,7 +349,7 @@ public class ItemEntity extends Entity implements TraceableEntity { @@ -15,12 +15,12 @@ index d9bc196c653aff84913bbb0e495fe735e366d23f..1f61dc925624c493ae458748e8422383 if (Objects.equals(this.target, other.target) && ItemEntity.areMergable(itemstack, itemstack1)) { - if (true || itemstack1.getCount() < itemstack.getCount()) { // Spigot -+ if (org.dreeam.leaf.LeafConfig.useSpigotItemMergingMechanism || itemstack1.getCount() < itemstack.getCount()) { // Spigot // KeYi ++ if (org.dreeam.leaf.LeafConfig.useSpigotItemMergingMechanism || itemstack1.getCount() < itemstack.getCount()) { // Spigot // Leaf - KeYi - Configurable spigot item merging mechanism ItemEntity.merge(this, itemstack, other, itemstack1); } else { ItemEntity.merge(other, itemstack1, this, itemstack); diff --git a/src/main/java/org/dreeam/leaf/LeafConfig.java b/src/main/java/org/dreeam/leaf/LeafConfig.java -index 4ef2a90296dd4ca7c61e257821d794e112489735..08f794bbd19d596591b4c786f5b131f56bf88b2e 100644 +index df16a84545dd726e6f4eaaff13232e4d95dd11af..e81cb3b303a53b4d2edb80563be806c8ef9c8bed 100644 --- a/src/main/java/org/dreeam/leaf/LeafConfig.java +++ b/src/main/java/org/dreeam/leaf/LeafConfig.java @@ -196,6 +196,7 @@ public class LeafConfig { diff --git a/patches/server/0021-Carpet-Fixes-Optimized-getBiome-method.patch b/patches/server/0021-Carpet-Fixes-Optimized-getBiome-method.patch index a49ef831..f6b83ddb 100644 --- a/patches/server/0021-Carpet-Fixes-Optimized-getBiome-method.patch +++ b/patches/server/0021-Carpet-Fixes-Optimized-getBiome-method.patch @@ -10,7 +10,7 @@ Optimized the getBiome call to be 25% - 75% faster This is a fully vanilla optimization. diff --git a/src/main/java/net/minecraft/world/level/biome/BiomeManager.java b/src/main/java/net/minecraft/world/level/biome/BiomeManager.java -index 5695c5116c8a338b2e41aafcb2dc9f2146856970..aa65785ac89a876111e5f661e0b1db6650010475 100644 +index 5695c5116c8a338b2e41aafcb2dc9f2146856970..08895c4d8e2d179ca8ed77377e31420d7229fb9b 100644 --- a/src/main/java/net/minecraft/world/level/biome/BiomeManager.java +++ b/src/main/java/net/minecraft/world/level/biome/BiomeManager.java @@ -14,6 +14,7 @@ public class BiomeManager { @@ -51,7 +51,7 @@ index 5695c5116c8a338b2e41aafcb2dc9f2146856970..aa65785ac89a876111e5f661e0b1db66 - if (g > v) { - o = p; - g = v; -+ // KeYi ++ // Leaf start - Carpet-Fixes - Optimized getBiome method + int xMinus2 = pos.getX() - 2; + int yMinus2 = pos.getY() - 2; + int zMinus2 = pos.getZ() - 2; @@ -117,7 +117,7 @@ index 5695c5116c8a338b2e41aafcb2dc9f2146856970..aa65785ac89a876111e5f661e0b1db66 + (smallestX & 2) == 0 ? y : y + 1, + (smallestX & 1) == 0 ? z : z + 1 + ); -+ // KeYi end ++ // Leaf end - Carpet-Fixes } public Holder getNoiseBiomeAtPosition(double x, double y, double z) { diff --git a/patches/server/0022-Carpet-Fixes-Use-optimized-RecipeManager.patch b/patches/server/0022-Carpet-Fixes-Use-optimized-RecipeManager.patch index 423ca9e8..4b1e1caf 100644 --- a/patches/server/0022-Carpet-Fixes-Use-optimized-RecipeManager.patch +++ b/patches/server/0022-Carpet-Fixes-Use-optimized-RecipeManager.patch @@ -11,7 +11,7 @@ This is a fully vanilla optimization. Improves: [Blast]Furnace/Campfire/Smoker/S This was mostly made for the auto crafting table, since the performance boost is much more visible while using that mod diff --git a/src/main/java/net/minecraft/world/item/crafting/RecipeManager.java b/src/main/java/net/minecraft/world/item/crafting/RecipeManager.java -index b81e1802c8dcc8ebdef96d70088c18379598a66b..55e413c10b025435de20ff56954ce44cc8940ffa 100644 +index d87124f5356180a37e581febc6141fdc5f1395a7..800f063f2b9f5803b45ca65f389b3295b27e6f86 100644 --- a/src/main/java/net/minecraft/world/item/crafting/RecipeManager.java +++ b/src/main/java/net/minecraft/world/item/crafting/RecipeManager.java @@ -11,8 +11,8 @@ import com.google.gson.JsonParseException; @@ -29,7 +29,7 @@ index b81e1802c8dcc8ebdef96d70088c18379598a66b..55e413c10b025435de20ff56954ce44c public > List> getAllRecipesFor(RecipeType type) { - return List.copyOf(this.byType(type).values()); -+ return new ArrayList<>(this.byType(type).values()); // KeYi // Leaf ++ return new ArrayList<>(this.byType(type).values()); // Leaf - Carpet-Fixes } public > List> getRecipesFor(RecipeType type, C inventory, Level world) { diff --git a/patches/server/0023-Akarin-Save-Json-list-asynchronously.patch b/patches/server/0023-Akarin-Save-Json-list-asynchronously.patch index 300e0884..0f6a72ce 100644 --- a/patches/server/0023-Akarin-Save-Json-list-asynchronously.patch +++ b/patches/server/0023-Akarin-Save-Json-list-asynchronously.patch @@ -8,7 +8,7 @@ Original license: GPL v3 Original project: https://github.com/Akarin-project/Akarin diff --git a/src/main/java/net/minecraft/server/players/StoredUserList.java b/src/main/java/net/minecraft/server/players/StoredUserList.java -index 219e0059418e6d64f5b859ba253c3cf3e91713cf..a358d177c266841f79809053e5b158f8202e54dc 100644 +index 219e0059418e6d64f5b859ba253c3cf3e91713cf..ae5a8cd4d5a2d89918699f44b99f7332316553a0 100644 --- a/src/main/java/net/minecraft/server/players/StoredUserList.java +++ b/src/main/java/net/minecraft/server/players/StoredUserList.java @@ -23,6 +23,7 @@ import java.util.stream.Stream; @@ -19,71 +19,34 @@ index 219e0059418e6d64f5b859ba253c3cf3e91713cf..a358d177c266841f79809053e5b158f8 import net.minecraft.Util; import net.minecraft.util.GsonHelper; import org.slf4j.Logger; -@@ -104,37 +105,43 @@ public abstract class StoredUserList> { +@@ -104,6 +105,7 @@ public abstract class StoredUserList> { } public void save() throws IOException { -- this.removeExpired(); // Paper - remove expired values before saving -- JsonArray jsonarray = new JsonArray(); -- Stream stream = this.map.values().stream().map((jsonlistentry) -> { // CraftBukkit - decompile error -- JsonObject jsonobject = new JsonObject(); -+ Runnable saveTask = ()->{ // Akarin - Save json list async -+ this.removeExpired(); // Paper - remove expired values before saving -+ JsonArray jsonarray = new JsonArray(); -+ Stream stream = this.map.values().stream().map((jsonlistentry) -> { // CraftBukkit - decompile error -+ JsonObject jsonobject = new JsonObject(); ++ Runnable saveTask = () -> {// Leaf - Akarin - Save json list async + this.removeExpired(); // Paper - remove expired values before saving + JsonArray jsonarray = new JsonArray(); + Stream stream = this.map.values().stream().map((jsonlistentry) -> { // CraftBukkit - decompile error +@@ -115,6 +117,8 @@ public abstract class StoredUserList> { -- Objects.requireNonNull(jsonlistentry); -- return (JsonObject) Util.make(jsonobject, jsonlistentry::serialize); -- }); -+ Objects.requireNonNull(jsonlistentry); -+ return (JsonObject) Util.make(jsonobject, jsonlistentry::serialize); -+ }); - -- Objects.requireNonNull(jsonarray); -- stream.forEach(jsonarray::add); -- BufferedWriter bufferedwriter = Files.newWriter(this.file, StandardCharsets.UTF_8); -+ Objects.requireNonNull(jsonarray); -+ stream.forEach(jsonarray::add); -+ try { -+ BufferedWriter bufferedwriter = Files.newWriter(this.file, StandardCharsets.UTF_8); - -- try { -- StoredUserList.GSON.toJson(jsonarray, bufferedwriter); -- } catch (Throwable throwable) { -- if (bufferedwriter != null) { - try { -+ StoredUserList.GSON.toJson(jsonarray, bufferedwriter); -+ } catch (Throwable throwable) { -+ if (bufferedwriter != null) { -+ try { -+ bufferedwriter.close(); -+ } catch (Throwable throwable1) { -+ throwable.addSuppressed(throwable1); -+ } -+ } + Objects.requireNonNull(jsonarray); + stream.forEach(jsonarray::add); + -+ throw throwable; -+ } -+ -+ if (bufferedwriter != null) { - bufferedwriter.close(); -- } catch (Throwable throwable1) { -- throwable.addSuppressed(throwable1); - } -+ }catch (Exception e){ -+ StoredUserList.LOGGER.warn("Failed to async save " + this.file, e); // Akarin - Save json list async - } -- -- throw throwable; -- } -- -- if (bufferedwriter != null) { -- bufferedwriter.close(); -- } -- ++ try {// Leaf - Akarin - Save json list async + BufferedWriter bufferedwriter = Files.newWriter(this.file, StandardCharsets.UTF_8); + + try { +@@ -135,6 +139,13 @@ public abstract class StoredUserList> { + bufferedwriter.close(); + } + ++ // Leaf start - Akarin - Save json list async ++ } catch (Exception e) { ++ StoredUserList.LOGGER.warn("Failed to async save " + this.file, e); ++ } + }; -+ MCUtil.scheduleAsyncTask(saveTask); // Akarin - Save json list async ++ MCUtil.scheduleAsyncTask(saveTask); ++ // Leaf end - Akarin } public void load() throws IOException {