diff --git a/.editorconfig b/.editorconfig index 2874476cf..6def68162 100644 --- a/.editorconfig +++ b/.editorconfig @@ -8,6 +8,8 @@ ij_any_block_comment_add_space = false ij_any_block_comment_at_first_column = false ij_any_line_comment_at_first_column = false ij_any_line_comment_add_space = true +max_line_length = 120 +ij_visual_guides = 80 [*.tiny] indent_style=tab diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 000000000..2ebd41bdf --- /dev/null +++ b/.gitattributes @@ -0,0 +1,7 @@ +* text=auto eol=lf + +*.sh text eol=lf +gradlew text eol=lf +*.bat text eol=crlf + +*.jar binary diff --git a/build.gradle.kts b/build.gradle.kts index d0c6d450a..0cace9db6 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,5 +1,6 @@ import org.gradle.api.tasks.testing.logging.TestExceptionFormat import org.gradle.api.tasks.testing.logging.TestLogEvent +import kotlin.io.path.createSymbolicLinkPointingTo plugins { java @@ -19,9 +20,7 @@ kotlin.jvmToolchain(jdkVersion) repositories { mavenCentral() maven("https://papermc.io/repo/repository/maven-public/") { - content { - onlyForConfigurations(configurations.paperclip.name) - } + content { onlyForConfigurations(configurations.paperclip.name) } } } @@ -59,19 +58,22 @@ allprojects { subprojects { tasks { withType().configureEach { - options.compilerArgs.addAll(listOf("--add-modules=jdk.incubator.vector", "-Xmaxwarns", "1")) options.encoding = Charsets.UTF_8.name() options.release = jdkVersion + options.compilerArgs.addAll(listOf( + "--add-modules=jdk.incubator.vector", + "-Xmaxwarns", "1" + )) } - + withType { options.encoding = Charsets.UTF_8.name() } - + withType { filteringCharset = Charsets.UTF_8.name() } - + withType { testLogging { showStackTraces = true @@ -85,7 +87,6 @@ subprojects { mavenCentral() maven("https://jitpack.io") maven("https://papermc.io/repo/repository/maven-public/") - maven("https://s01.oss.sonatype.org/content/repositories/snapshots/") } } @@ -110,23 +111,16 @@ paperweight { patchDir = layout.projectDirectory.dir("patches/generated-api") outputDir = layout.projectDirectory.dir("paper-api-generator/generated") } - - patchTasks.register("mojangApi") { - isBareDirectory = true - upstreamDirPath = "Paper-MojangAPI" - patchDir = layout.projectDirectory.dir("patches/mojang-api") - outputDir = layout.projectDirectory.dir("$projectName-MojangAPI") - } } } alwaysUpToDate { - paperRepoName.set("org.plazmamc.alwaysuptodate.paper.repository") + paperRepoName.set("paperRepo") paperBranchName.set("paperBranch") paperCommitName.set("paperCommit") - purpurRepoName.set("org.plazmamc.alwaysuptodate.purpur.repository") + purpurRepoName.set("purpurRepo") purpurBranchName.set("purpurBranch") purpurCommitName.set("purpurCommit") @@ -147,7 +141,6 @@ tasks { generateDevelopmentBundle { apiCoordinates.set("${project.group}:${projectName.lowercase()}-api") - mojangApiCoordinates.set("${project.group}:${projectName.lowercase()}-mojangapi") libraryRepositories.addAll( "https://repo.maven.apache.org/maven2/", "https://maven.pkg.github.com/$projectRepo", @@ -155,25 +148,35 @@ tasks { ) } + register("reApplyServerPatches") { + doFirst { + projectDir.resolve("$projectName-Server").deleteRecursively() + } + + finalizedBy("applyServerPatches") + } + clean { doLast { - projectDir.resolve(".gradle/caches").deleteRecursively() - listOf("$projectName-API", "$projectName-MojangAPI", "$projectName-Server", "paper-api-generator", "run").forEach { + listOf( + ".gradle/caches", + "$projectName-API", + "$projectName-Server", + "paper-api-generator", + "run", + + // remove dev environment files + "0001-fixup.patch", + "compare.txt" + ).forEach { projectDir.resolve(it).deleteRecursively() } - - // remove dev environment files - listOf("0001-fixup.patch", "compare.txt").forEach { - projectDir.resolve(it).delete() - } } } } publishing { publications.create("devBundle") { - artifact(tasks.generateDevelopmentBundle) { - artifactId = "dev-bundle" - } + artifact(tasks.generateDevelopmentBundle) { artifactId = "dev-bundle" } } } diff --git a/fxapi b/fxapi deleted file mode 100755 index d51569928..000000000 --- a/fxapi +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/env bash - -# FixupAPI - -PS1="$" - -cd Plazma-API - -git add . -git commit -m "fixup" -git format-patch -1 -mv 0001-fixup.patch ../ - -cd ../ diff --git a/fxsrv b/fxsrv deleted file mode 100755 index bba81b5ba..000000000 --- a/fxsrv +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/env bash - -# FixupServer - -PS1="$" - -cd Plazma-Server - -git add . -git commit -m "fixup" -git format-patch -1 -mv 0001-fixup.patch ../ - -cd ../ diff --git a/gradle.properties b/gradle.properties index 88d5038ed..26fb1d672 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,3 @@ -group = org.plazmamc.plazma org.gradle.daemon = true org.gradle.caching = true org.gradle.parallel = true @@ -8,9 +7,7 @@ org.gradle.jvmargs = -Xmx4G -Dfile.encoding=UTF-8 -Dgraal.CompilerConfiguration= paper.runMemoryGb = 8 paper.runDisableWatchdog = true -org.plazmamc.alwaysuptodate.paper.repository = https://github.com/PaperMC/Paper -org.plazmamc.alwaysuptodate.purpur.repository = https://github.com/PurpurMC/Purpur - +group = org.plazmamc.plazma projectName = Plazma projectRepo = PlazmaMC/PlazmaBukkit @@ -18,10 +15,12 @@ version = 1.20.6-R0.1-SNAPSHOT mcVersion = 1.20.6 jdkVersion = 21 +paperRepo = https://github.com/PaperMC/Paper paperBranch = master +purpurRepo = https://github.com/PurpurMC/Purpur purpurBranch = ver/1.20.6 pufferfishBranch = ver/1.20 usePufferfish = false -paperCommit = eee55d019fe80372c2e08ccd1d0a94c066cda926 -purpurCommit = f9258cd522c14caea3ade7480b01e7e146aa8661 +paperCommit = 3fc93581bb876e8149b2ca423375a98f5ca12d27 +purpurCommit = c637b74bade41e7be96ed3478bab7c3b923e7d84 diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 8b73478cc..cb994e20c 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,6 +1,6 @@ [versions] shadow = "8.1.1" -paperweight = "1.6.3" +paperweight = "1.7.1" paperclip = "3.0.3" decompiler = "1.10.1" remapper = "0.10.1" diff --git a/initDev b/initDev new file mode 100644 index 000000000..11a77c5e7 --- /dev/null +++ b/initDev @@ -0,0 +1,52 @@ +# To initialize your development environment, +# run below command in your terminal: +# source ./initDev + +export PROJECT_DIR=$(pwd) + +alias api="cd $PROJECT_DIR/*-API" +alias srv="cd $PROJECT_DIR/*-Server" + +alias ap="./gradlew --no-rebuild applyPatches" +alias aap="./gradlew --no-rebuild applyAPIPatches" +alias agp="./gradlew --no-rebuild applyGeneratedAPIPatches" +alias asp="./gradlew --no-rebuild applyServerPatches" + +alias rp="./gradlew --no-rebuild rebuildPatches" +alias rap="./gradlew --no-rebuild rebuildAPIPatches" +alias rgp="./gradlew --no-rebuild rebuildGeneratedAPIPatches" +alias rsp="./gradlew --no-rebuild rebuildServerPatches" + +alias lg="git log --oneline base..HEAD" +alias rc="git rebase --autosquash -i base" +alias rcc="git rebase --continue" + +# generate Fixup patches for Server +function fs() { + cd *-Server + + git add . + git commit -m "fixup" + git format-patch -1 + mv 0001-fixup.patch ../ + + cd ../ +} + +# generate Fixup patches for API +function fa() { + cd *-API + + git add . + git commit -m "fixup" + git format-patch -1 + mv 0001-fixup.patch ../ + + cd ../ +} + +# ReApply Server Patches +function rasp() { + rm -rf *-Server + ./gradlew applyServerPatches +} diff --git a/libs/api.versions.toml b/libs/api.versions.toml index 346e2dd76..830c512c3 100644 --- a/libs/api.versions.toml +++ b/libs/api.versions.toml @@ -6,6 +6,7 @@ sentry = "5.4.0" fastutil = "8.5.6" findbugs = "1.3.9" slf4j-api = "2.0.9" +brigadier = "1.2.9" bungeechat = "1.20-R0.2" json-simple = "1.1.1" annotations = "24.0.1" @@ -18,6 +19,7 @@ guava = { group = "com.google.guava", name = "guava", version.ref = "guava" } sentry = { group = "io.sentry", name = "sentry", version.ref = "sentry" } fastutil = { group = "it.unimi.dsi", name = "fastutil", version.ref = "fastutil" } findbugs = { group = "com.google.code.findbugs", name = "jsr305", version.ref = "findbugs" } +brigadier = { group = "com.mojang", name = "brigadier", version.ref = "brigadier" } slf4j-api = { group = "org.slf4j", name = "slf4j-api", version.ref = "slf4j-api" } bungeechat = { group = "net.md-5", name = "bungeecord-chat", version.ref = "bungeechat" } jsonsimple = { group = "com.googlecode.json-simple", name = "json-simple", version.ref = "json-simple" } @@ -25,5 +27,5 @@ annotations = { group = "org.jetbrains", name = "annotations", version.ref = "an checkerqual = { group = "org.checkerframework", name = "checker-qual", version.ref = "checkerqual" } [bundles] -api = [ "guava", "gson", "joml", "fastutil", "slf4j-api", "sentry" ] +api = [ "guava", "gson", "joml", "fastutil", "slf4j-api", "sentry", "brigadier" ] annotations = [ "annotations", "checkerqual" ] diff --git a/libs/common.versions.toml b/libs/common.versions.toml index 9144180d0..269bd5bed 100644 --- a/libs/common.versions.toml +++ b/libs/common.versions.toml @@ -5,7 +5,7 @@ mockito = "5.5.0" jupiter = "5.10.0" hamcrest = "2.2" snakeyaml = "2.2" -adventure = "4.17.0-SNAPSHOT" +adventure = "4.17.0" commons-lang2 = "2.6" commons-lang3 = "3.12.0" maven-provider = "3.9.6" diff --git a/mkapi b/mkapi deleted file mode 100755 index 1819b6a1a..000000000 --- a/mkapi +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/env bash - -# PatchAPI - -PS1="$" - -cd Plazma-API - -git add . -git commit -m $1 - -cd ../ - -./gradlew rebuildAPIPatches \ No newline at end of file diff --git a/mksrv b/mksrv deleted file mode 100755 index 05c6ab30d..000000000 --- a/mksrv +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/env bash - -# PatchServer - -PS1="$" - -cd Plazma-Server - -git add . -git commit -m $1 - -cd ../ - -./gradlew rebuildServerPatches \ No newline at end of file diff --git a/patches/0006-Reduce-allocations.patch b/patches/0006-Reduce-allocations.patch deleted file mode 100644 index d4f7df74c..000000000 --- a/patches/0006-Reduce-allocations.patch +++ /dev/null @@ -1,897 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: AlphaKR93 -Date: Wed, 10 Jan 2024 12:43:26 +0900 -Subject: [PATCH] Reduce allocations - - -diff --git a/src/main/java/ca/spottedleaf/starlight/common/light/StarLightEngine.java b/src/main/java/ca/spottedleaf/starlight/common/light/StarLightEngine.java -index ad1eeebe6de219143492b94da309cb54ae9e0a5b..f83bdcf5d2d6f676b2dc83bc1fc0a7453fc2b36a 100644 ---- a/src/main/java/ca/spottedleaf/starlight/common/light/StarLightEngine.java -+++ b/src/main/java/ca/spottedleaf/starlight/common/light/StarLightEngine.java -@@ -38,6 +38,7 @@ public abstract class StarLightEngine { - AxisDirection.POSITIVE_X, AxisDirection.NEGATIVE_X, - AxisDirection.POSITIVE_Z, AxisDirection.NEGATIVE_Z - }; -+ private static final AxisDirection[] EMPTY_DIRECTIONS = new AxisDirection[0]; // Plazma - Reduce allocations - - protected static enum AxisDirection { - -@@ -1094,7 +1095,7 @@ public abstract class StarLightEngine { - for (int bitset = i, len = Integer.bitCount(i), index = 0; index < len; ++index, bitset ^= IntegerUtil.getTrailingBit(bitset)) { - directions.add(AXIS_DIRECTIONS[IntegerUtil.trailingZeros(bitset)]); - } -- OLD_CHECK_DIRECTIONS[i] = directions.toArray(new AxisDirection[0]); -+ OLD_CHECK_DIRECTIONS[i] = directions.toArray(EMPTY_DIRECTIONS); // Plazma - Reduce allocations - } - } - -diff --git a/src/main/java/com/destroystokyo/paper/antixray/ChunkPacketBlockControllerAntiXray.java b/src/main/java/com/destroystokyo/paper/antixray/ChunkPacketBlockControllerAntiXray.java -index e7fe98ea30ae6d0baea3ec1f9f98a89502a49a12..7663ccd247b9942ccfb7a320b047ee621fc1bebe 100644 ---- a/src/main/java/com/destroystokyo/paper/antixray/ChunkPacketBlockControllerAntiXray.java -+++ b/src/main/java/com/destroystokyo/paper/antixray/ChunkPacketBlockControllerAntiXray.java -@@ -97,8 +97,8 @@ public final class ChunkPacketBlockControllerAntiXray extends ChunkPacketBlockCo - Set presetBlockStateSet = new LinkedHashSet<>(); - // Therefore addAll(Collection) is used, which guarantees this order in the doc - presetBlockStateSet.addAll(presetBlockStateList); -- presetBlockStates = presetBlockStateSet.isEmpty() ? new BlockState[]{Blocks.DIAMOND_ORE.defaultBlockState()} : presetBlockStateSet.toArray(new BlockState[0]); -- presetBlockStatesFull = presetBlockStateSet.isEmpty() ? new BlockState[]{Blocks.DIAMOND_ORE.defaultBlockState()} : presetBlockStateList.toArray(new BlockState[0]); -+ presetBlockStates = presetBlockStateSet.isEmpty() ? new BlockState[]{Blocks.DIAMOND_ORE.defaultBlockState()} : presetBlockStateSet.toArray(org.plazmamc.plazma.constants.Empty.BLOCK_STATE); // Plazma - Reduce allocations -+ presetBlockStatesFull = presetBlockStateSet.isEmpty() ? new BlockState[]{Blocks.DIAMOND_ORE.defaultBlockState()} : presetBlockStateList.toArray(org.plazmamc.plazma.constants.Empty.BLOCK_STATE); // Plazma - Reduce allocations - presetBlockStatesStone = null; - presetBlockStatesDeepslate = null; - presetBlockStatesNetherrack = null; -diff --git a/src/main/java/com/destroystokyo/paper/util/maplist/EntityList.java b/src/main/java/com/destroystokyo/paper/util/maplist/EntityList.java -index 0133ea6feb1ab88f021f66855669f58367e7420b..a04049bc7738225633ac0b01c470cfbfde86c032 100644 ---- a/src/main/java/com/destroystokyo/paper/util/maplist/EntityList.java -+++ b/src/main/java/com/destroystokyo/paper/util/maplist/EntityList.java -@@ -17,9 +17,9 @@ public final class EntityList implements Iterable { - this.entityToIndex.defaultReturnValue(Integer.MIN_VALUE); - } - -- protected static final Entity[] EMPTY_LIST = new Entity[0]; -+ //protected static final Entity[] EMPTY_LIST = new Entity[0]; // Plazma - Reduce allocations - -- protected Entity[] entities = EMPTY_LIST; -+ protected Entity[] entities = org.plazmamc.plazma.constants.Empty.ENTITY; // Plazma - Reduce allocations - protected int count; - - public int size() { -diff --git a/src/main/java/com/destroystokyo/paper/util/maplist/IBlockDataList.java b/src/main/java/com/destroystokyo/paper/util/maplist/IBlockDataList.java -index 277cfd9d1e8fff5d9b5e534b75c3c5162d58b0b7..30d8d9c2dce5e4eb26cc52a03bc395c16c04c256 100644 ---- a/src/main/java/com/destroystokyo/paper/util/maplist/IBlockDataList.java -+++ b/src/main/java/com/destroystokyo/paper/util/maplist/IBlockDataList.java -@@ -20,9 +20,9 @@ public final class IBlockDataList { - this.map.defaultReturnValue(Long.MAX_VALUE); - } - -- private static final long[] EMPTY_LIST = new long[0]; -+ //private static final long[] EMPTY_LIST = new long[0]; // Plazma - Reduce allocations - -- private long[] byIndex = EMPTY_LIST; -+ private long[] byIndex = org.plazmamc.plazma.constants.Empty.LONG; // Plazma - Reduce allocations - private int size; - - public static int getLocationKey(final int x, final int y, final int z) { -diff --git a/src/main/java/com/destroystokyo/paper/util/maplist/ReferenceList.java b/src/main/java/com/destroystokyo/paper/util/maplist/ReferenceList.java -index 190c5f0b02a3d99054704ae1afbffb3498ddffe1..042ea49ec61ee327c0f67ddcf080774042e44c02 100644 ---- a/src/main/java/com/destroystokyo/paper/util/maplist/ReferenceList.java -+++ b/src/main/java/com/destroystokyo/paper/util/maplist/ReferenceList.java -@@ -15,9 +15,9 @@ public final class ReferenceList implements Iterable { - this.referenceToIndex.defaultReturnValue(Integer.MIN_VALUE); - } - -- protected static final Object[] EMPTY_LIST = new Object[0]; -+ //protected static final Object[] EMPTY_LIST = new Object[0]; // Plazma - Reduce allocations - -- protected Object[] references = EMPTY_LIST; -+ protected Object[] references = org.plazmamc.plazma.constants.Empty.OBJECT; // Plazma - Reduce allocations - protected int count; - - public int size() { -diff --git a/src/main/java/io/papermc/paper/chunk/system/scheduling/ChunkTaskScheduler.java b/src/main/java/io/papermc/paper/chunk/system/scheduling/ChunkTaskScheduler.java -index 049e20407..bbd0b944c 100644 ---- a/src/main/java/io/papermc/paper/chunk/system/scheduling/ChunkTaskScheduler.java -+++ b/src/main/java/io/papermc/paper/chunk/system/scheduling/ChunkTaskScheduler.java -@@ -42,6 +42,7 @@ import java.util.function.Consumer; - public final class ChunkTaskScheduler { - - private static final Logger LOGGER = LogUtils.getClassLogger(); -+ private static final ChunkInfo[] EMPTY_INFO = new ChunkInfo[0]; // Plazma - Reduce allocations - - static int newChunkSystemIOThreads; - static int newChunkSystemWorkerThreads; -@@ -854,7 +855,7 @@ public final class ChunkTaskScheduler { - - public static ChunkInfo[] getChunkInfos() { - synchronized (WAITING_CHUNKS) { -- return WAITING_CHUNKS.toArray(new ChunkInfo[0]); -+ return WAITING_CHUNKS.toArray(EMPTY_INFO); // Plazma - Reduce allocations - } - } - -diff --git a/src/main/java/io/papermc/paper/command/subcommands/VersionCommand.java b/src/main/java/io/papermc/paper/command/subcommands/VersionCommand.java -index ae60bd96b5284d54676d8e7e4dd5d170b526ec1e..359c4b080bd47234e569dce7055da03ddb7b1e90 100644 ---- a/src/main/java/io/papermc/paper/command/subcommands/VersionCommand.java -+++ b/src/main/java/io/papermc/paper/command/subcommands/VersionCommand.java -@@ -14,7 +14,7 @@ public final class VersionCommand implements PaperSubcommand { - public boolean execute(final CommandSender sender, final String subCommand, final String[] args) { - final @Nullable Command ver = MinecraftServer.getServer().server.getCommandMap().getCommand("version"); - if (ver != null) { -- ver.execute(sender, "paper", new String[0]); -+ ver.execute(sender, "paper", org.plazmamc.plazma.constants.Empty.STRING); // Plazma - Reduce allocations - } - return true; - } -diff --git a/src/main/java/io/papermc/paper/plugin/manager/PaperPluginInstanceManager.java b/src/main/java/io/papermc/paper/plugin/manager/PaperPluginInstanceManager.java -index 3e82ea07c..692bef556 100644 ---- a/src/main/java/io/papermc/paper/plugin/manager/PaperPluginInstanceManager.java -+++ b/src/main/java/io/papermc/paper/plugin/manager/PaperPluginInstanceManager.java -@@ -47,6 +47,8 @@ import java.util.logging.Level; - class PaperPluginInstanceManager { - - private static final FileProviderSource FILE_PROVIDER_SOURCE = new FileProviderSource("File '%s'"::formatted); -+ private static final JavaPlugin[] EMPTY_JPLUGIN = new JavaPlugin[0]; // Plazma - Reduce allocations -+ private static final Plugin[] EMPTY_PLUGIN = new Plugin[0]; // Plazma - Reduce allocations - - private final List plugins = new ArrayList<>(); - private final Map lookupNames = new HashMap<>(); -@@ -68,7 +70,7 @@ class PaperPluginInstanceManager { - } - - public @NotNull Plugin[] getPlugins() { -- return this.plugins.toArray(new Plugin[0]); -+ return this.plugins.toArray(EMPTY_PLUGIN); // Plazma - Reduce allocations - } - - public boolean isPluginEnabled(@NotNull String name) { -@@ -133,7 +135,7 @@ class PaperPluginInstanceManager { - this.server.getLogger().log(Level.SEVERE, "Unknown error occurred while loading plugins through PluginManager.", e); - } - -- return runtimePluginEntrypointHandler.getPluginProviderStorage().getLoaded().toArray(new JavaPlugin[0]); -+ return runtimePluginEntrypointHandler.getPluginProviderStorage().getLoaded().toArray(EMPTY_JPLUGIN); // Plazma - Reduce allocations - } - - // The behavior of this is that all errors are logged instead of being thrown -diff --git a/src/main/java/io/papermc/paper/util/CollisionUtil.java b/src/main/java/io/papermc/paper/util/CollisionUtil.java -index ee8e9c0e3..f2598e139 100644 ---- a/src/main/java/io/papermc/paper/util/CollisionUtil.java -+++ b/src/main/java/io/papermc/paper/util/CollisionUtil.java -@@ -1149,7 +1149,7 @@ public final class CollisionUtil { - } - - private static final MergedVoxelCoordinateList EMPTY = new MergedVoxelCoordinateList( -- new double[] { 0.0 }, 0.0, new int[0], new int[0], 0 -+ new double[] { 0.0 }, 0.0, org.plazmamc.plazma.constants.Empty.INT, org.plazmamc.plazma.constants.Empty.INT, 0 // Plazma - Reduce allocations - ); - - private static int[] getIndices(final int length) { -diff --git a/src/main/java/io/papermc/paper/world/ChunkEntitySlices.java b/src/main/java/io/papermc/paper/world/ChunkEntitySlices.java -index c78cbec447032de9fe69748591bef6be300160ed..8ca248e844e73685a8d44a966144657315a799aa 100644 ---- a/src/main/java/io/papermc/paper/world/ChunkEntitySlices.java -+++ b/src/main/java/io/papermc/paper/world/ChunkEntitySlices.java -@@ -304,7 +304,7 @@ public final class ChunkEntitySlices { - - protected static final class BasicEntityList { - -- protected static final Entity[] EMPTY = new Entity[0]; -+ //protected static final Entity[] EMPTY = new Entity[0]; // Plazma - Reduce allocations - protected static final int DEFAULT_CAPACITY = 4; - - protected E[] storage; -@@ -315,7 +315,7 @@ public final class ChunkEntitySlices { - } - - public BasicEntityList(final int cap) { -- this.storage = (E[])(cap <= 0 ? EMPTY : new Entity[cap]); -+ this.storage = (E[])(cap <= 0 ? org.plazmamc.plazma.constants.Empty.ENTITY : new Entity[cap]); - } - - public boolean isEmpty() { -@@ -327,7 +327,7 @@ public final class ChunkEntitySlices { - } - - private void resize() { -- if (this.storage == EMPTY) { -+ if (this.storage == org.plazmamc.plazma.constants.Empty.ENTITY) { - this.storage = (E[])new Entity[DEFAULT_CAPACITY]; - } else { - this.storage = Arrays.copyOf(this.storage, this.storage.length * 2); -diff --git a/src/main/java/net/minecraft/CrashReport.java b/src/main/java/net/minecraft/CrashReport.java -index c5a3f9c2daf3da135cccecb757353534e1688821..e5585c6befeef62ecf130e8dabbe6b78f9e90a65 100644 ---- a/src/main/java/net/minecraft/CrashReport.java -+++ b/src/main/java/net/minecraft/CrashReport.java -@@ -30,7 +30,7 @@ public class CrashReport { - @Nullable - private File saveFile; - private boolean trackingStackTrace = true; -- private StackTraceElement[] uncategorizedStackTrace = new StackTraceElement[0]; -+ private StackTraceElement[] uncategorizedStackTrace = org.plazmamc.plazma.constants.Empty.TRACE; // Plazma - Reduce allocations - private final SystemReport systemReport = new SystemReport(); - - public CrashReport(String message, Throwable cause) { -diff --git a/src/main/java/net/minecraft/CrashReportCategory.java b/src/main/java/net/minecraft/CrashReportCategory.java -index 2176171954609fd88f97f93408e14e018c1d6eaa..2a5576dc66a9b1f56e06ba47bef4fe882935c382 100644 ---- a/src/main/java/net/minecraft/CrashReportCategory.java -+++ b/src/main/java/net/minecraft/CrashReportCategory.java -@@ -12,7 +12,7 @@ import net.minecraft.world.level.block.state.BlockState; - public class CrashReportCategory { - private final String title; - private final List entries = Lists.newArrayList(); -- private StackTraceElement[] stackTrace = new StackTraceElement[0]; -+ private StackTraceElement[] stackTrace = org.plazmamc.plazma.constants.Empty.TRACE; // Plazma - Reduce allocations - - public CrashReportCategory(String title) { - this.title = title; -diff --git a/src/main/java/net/minecraft/Util.java b/src/main/java/net/minecraft/Util.java -index 01a12f4d6f3c2f09bffc78692443b9fd391db45a..9a6e4538dd09263544f39c93f5f1480dc589fb4d 100644 ---- a/src/main/java/net/minecraft/Util.java -+++ b/src/main/java/net/minecraft/Util.java -@@ -409,7 +409,7 @@ public class Util { - } else if (futures.size() == 1) { - return futures.get(0).thenApply(List::of); - } else { -- CompletableFuture completableFuture = CompletableFuture.allOf(futures.toArray(new CompletableFuture[0])); -+ CompletableFuture completableFuture = CompletableFuture.allOf(futures.toArray(org.plazmamc.plazma.constants.Empty.FUTURE)); // Plazma - Reduce allocations - return completableFuture.thenApply(void_ -> futures.stream().map(CompletableFuture::join).toList()); - } - } -diff --git a/src/main/java/net/minecraft/nbt/ByteArrayTag.java b/src/main/java/net/minecraft/nbt/ByteArrayTag.java -index 06648f9751fd8a322d0809ffebf6a544596ee1a4..b0ea87e2ed8f9bf04b33c2ff8a827d4f6f57a435 100644 ---- a/src/main/java/net/minecraft/nbt/ByteArrayTag.java -+++ b/src/main/java/net/minecraft/nbt/ByteArrayTag.java -@@ -175,7 +175,7 @@ public class ByteArrayTag extends CollectionTag { - } - - public void clear() { -- this.data = new byte[0]; -+ this.data = org.plazmamc.plazma.constants.Empty.BYTE; // Plazma - Reduce allocations - } - - @Override -diff --git a/src/main/java/net/minecraft/nbt/CompoundTag.java b/src/main/java/net/minecraft/nbt/CompoundTag.java -index 4e005b7b0..059a1e49f 100644 ---- a/src/main/java/net/minecraft/nbt/CompoundTag.java -+++ b/src/main/java/net/minecraft/nbt/CompoundTag.java -@@ -409,7 +409,7 @@ public class CompoundTag implements Tag { - throw new ReportedException(this.createReport(key, ByteArrayTag.TYPE, var3)); - } - -- return new byte[0]; -+ return org.plazmamc.plazma.constants.Empty.BYTE; // Plazma - Reduce allocations - } - - public int[] getIntArray(String key) { -@@ -421,7 +421,7 @@ public class CompoundTag implements Tag { - throw new ReportedException(this.createReport(key, IntArrayTag.TYPE, var3)); - } - -- return new int[0]; -+ return org.plazmamc.plazma.constants.Empty.INT; // Plazma - Reduce allocations - } - - public long[] getLongArray(String key) { -@@ -433,7 +433,7 @@ public class CompoundTag implements Tag { - throw new ReportedException(this.createReport(key, LongArrayTag.TYPE, var3)); - } - -- return new long[0]; -+ return org.plazmamc.plazma.constants.Empty.LONG; // Plazma - Reduce allocations - } - - public CompoundTag getCompound(String key) { -diff --git a/src/main/java/net/minecraft/nbt/IntArrayTag.java b/src/main/java/net/minecraft/nbt/IntArrayTag.java -index ff13d67151c50ea11a45117e524c7524e2b1a202..5048ec707c147b9a5b2dd8736d518d938ba95df0 100644 ---- a/src/main/java/net/minecraft/nbt/IntArrayTag.java -+++ b/src/main/java/net/minecraft/nbt/IntArrayTag.java -@@ -186,7 +186,7 @@ public class IntArrayTag extends CollectionTag { - } - - public void clear() { -- this.data = new int[0]; -+ this.data = org.plazmamc.plazma.constants.Empty.INT; // Plazma - Reduce allocations - } - - @Override -diff --git a/src/main/java/net/minecraft/nbt/ListTag.java b/src/main/java/net/minecraft/nbt/ListTag.java -index 154bffd34..83c36d452 100644 ---- a/src/main/java/net/minecraft/nbt/ListTag.java -+++ b/src/main/java/net/minecraft/nbt/ListTag.java -@@ -258,7 +258,7 @@ public class ListTag extends CollectionTag { - } - } - -- return new int[0]; -+ return org.plazmamc.plazma.constants.Empty.INT; // Plazma - Reduce allocations - } - - public long[] getLongArray(int index) { -@@ -269,7 +269,7 @@ public class ListTag extends CollectionTag { - } - } - -- return new long[0]; -+ return org.plazmamc.plazma.constants.Empty.LONG; // Plazma - Reduce allocations - } - - public double getDouble(int index) { -diff --git a/src/main/java/net/minecraft/nbt/LongArrayTag.java b/src/main/java/net/minecraft/nbt/LongArrayTag.java -index 2e5c34ebb94a1536cf09d71bdf052a49ecb9159d..144d3bbe80fc0f459a06017a19929e3e849aabd0 100644 ---- a/src/main/java/net/minecraft/nbt/LongArrayTag.java -+++ b/src/main/java/net/minecraft/nbt/LongArrayTag.java -@@ -185,7 +185,7 @@ public class LongArrayTag extends CollectionTag { - - @Override - public void clear() { -- this.data = new long[0]; -+ this.data = org.plazmamc.plazma.constants.Empty.LONG; // Plazma - Reduce allocations - } - - @Override -diff --git a/src/main/java/net/minecraft/nbt/NbtIo.java b/src/main/java/net/minecraft/nbt/NbtIo.java -index 9f659af04..d2969c1ce 100644 ---- a/src/main/java/net/minecraft/nbt/NbtIo.java -+++ b/src/main/java/net/minecraft/nbt/NbtIo.java -@@ -277,7 +277,7 @@ public class NbtIo { - - @Nullable - public static CompoundTag read(Path path) throws IOException { -- if (!Files.exists(path, new LinkOption[0])) { -+ if (!Files.exists(path/*, new LinkOption[0]*/)) { // Plazma - Reduce allocations - return null; - } else { - InputStream inputstream = Files.newInputStream(path); -diff --git a/src/main/java/net/minecraft/network/CipherBase.java b/src/main/java/net/minecraft/network/CipherBase.java -index a2920b8a9eff77d9c5d1d7f70ad3abdacba8f0fa..70d776d5cfdb0612f65d92333d6f872afedc2207 100644 ---- a/src/main/java/net/minecraft/network/CipherBase.java -+++ b/src/main/java/net/minecraft/network/CipherBase.java -@@ -7,8 +7,8 @@ import javax.crypto.ShortBufferException; - - public class CipherBase { - private final Cipher cipher; -- private byte[] heapIn = new byte[0]; -- private byte[] heapOut = new byte[0]; -+ private byte[] heapIn = org.plazmamc.plazma.constants.Empty.BYTE; // Plazma - Reduce allocations -+ private byte[] heapOut = org.plazmamc.plazma.constants.Empty.BYTE; // Plazma - Reduce allocations - - protected CipherBase(Cipher cipher) { - this.cipher = cipher; -diff --git a/src/main/java/net/minecraft/network/Connection.java b/src/main/java/net/minecraft/network/Connection.java -index 9f274048b..ba54c16f1 100644 ---- a/src/main/java/net/minecraft/network/Connection.java -+++ b/src/main/java/net/minecraft/network/Connection.java -@@ -316,7 +316,7 @@ public class Connection extends SimpleChannelInboundHandler> { - } - - private void validateListener(ProtocolInfo state, PacketListener listener) { -- Validate.notNull(listener, "packetListener", new Object[0]); -+ Validate.notNull(listener, "packetListener"/*, new Object[0]*/); // Plazma - Reduce allocations - PacketFlow enumprotocoldirection = listener.flow(); - String s; - -diff --git a/src/main/java/net/minecraft/network/chat/Component.java b/src/main/java/net/minecraft/network/chat/Component.java -index 6dcade427..4a0b4b0fa 100644 ---- a/src/main/java/net/minecraft/network/chat/Component.java -+++ b/src/main/java/net/minecraft/network/chat/Component.java -@@ -189,7 +189,7 @@ public interface Component extends Message, FormattedText, Iterable { - } - - static MutableComponent translatable(String key) { -- return MutableComponent.create(new TranslatableContents(key, (String) null, TranslatableContents.NO_ARGS)); -+ return MutableComponent.create(new TranslatableContents(key, (String) null, org.plazmamc.plazma.constants.Empty.OBJECT)); // Plazma - Reduce allocations - } - - static MutableComponent translatable(String key, Object... args) { -@@ -209,7 +209,7 @@ public interface Component extends Message, FormattedText, Iterable { - } - - static MutableComponent translatableWithFallback(String key, @Nullable String fallback) { -- return MutableComponent.create(new TranslatableContents(key, fallback, TranslatableContents.NO_ARGS)); -+ return MutableComponent.create(new TranslatableContents(key, fallback, org.plazmamc.plazma.constants.Empty.OBJECT)); // Plazma - Reduce allocations - } - - static MutableComponent translatableWithFallback(String key, @Nullable String fallback, Object... args) { -diff --git a/src/main/java/net/minecraft/network/chat/contents/TranslatableContents.java b/src/main/java/net/minecraft/network/chat/contents/TranslatableContents.java -index 4aa6232bf..84e8a29f0 100644 ---- a/src/main/java/net/minecraft/network/chat/contents/TranslatableContents.java -+++ b/src/main/java/net/minecraft/network/chat/contents/TranslatableContents.java -@@ -29,7 +29,7 @@ import net.minecraft.util.ExtraCodecs; - import net.minecraft.world.entity.Entity; - - public class TranslatableContents implements ComponentContents { -- public static final Object[] NO_ARGS = new Object[0]; -+ // public static final Object[] NO_ARGS = new Object[0]; // Plazma - Reduce allocations - private static final Codec PRIMITIVE_ARG_CODEC = ExtraCodecs.JAVA.validate(TranslatableContents::filterAllowedArguments); - private static final Codec ARG_CODEC = Codec.either(PRIMITIVE_ARG_CODEC, ComponentSerialization.CODEC) - .xmap( -@@ -69,7 +69,7 @@ public class TranslatableContents implements ComponentContents { - } - - private static Object[] adjustArgs(Optional> args) { -- return args.map(list -> list.isEmpty() ? NO_ARGS : list.toArray()).orElse(NO_ARGS); -+ return args.map(list -> list.isEmpty() ? org.plazmamc.plazma.constants.Empty.OBJECT : list.toArray()).orElse(org.plazmamc.plazma.constants.Empty.OBJECT); // Plazma - Reduce allocations - } - - private static TranslatableContents create(String key, Optional fallback, Optional> args) { -diff --git a/src/main/java/net/minecraft/network/protocol/game/ClientboundSectionBlocksUpdatePacket.java b/src/main/java/net/minecraft/network/protocol/game/ClientboundSectionBlocksUpdatePacket.java -index 1a37654af..0e61f8cb3 100644 ---- a/src/main/java/net/minecraft/network/protocol/game/ClientboundSectionBlocksUpdatePacket.java -+++ b/src/main/java/net/minecraft/network/protocol/game/ClientboundSectionBlocksUpdatePacket.java -@@ -66,7 +66,7 @@ public class ClientboundSectionBlocksUpdatePacket implements Packet blockChanges) { - this.sectionPos = sectionPos; - this.positions = blockChanges.keySet().toShortArray(); -- this.states = blockChanges.values().toArray(new BlockState[0]); -+ this.states = blockChanges.values().toArray(org.plazmamc.plazma.constants.Empty.BLOCK_STATE); // Plazma - Reduce allocations - } - // Paper end - Multi Block Change API - -diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index e121cc57e..7b27af22a 100644 ---- a/src/main/java/net/minecraft/server/MinecraftServer.java -+++ b/src/main/java/net/minecraft/server/MinecraftServer.java -@@ -1541,13 +1541,10 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop loadStatusIcon() { -- Optional optional = Optional.of(this.getFile("server-icon.png").toPath()).filter((path) -> { -- return Files.isRegularFile(path, new LinkOption[0]); -- }).or(() -> { -- return this.storageSource.getIconFile().filter((path) -> { -- return Files.isRegularFile(path, new LinkOption[0]); -- }); -- }); -+ // Plazma start - Reduce allocations -+ Optional optional = Optional.of(this.getFile("server-icon.png").toPath()).filter(Files::isRegularFile) -+ .or(() -> this.storageSource.getIconFile().filter(Files::isRegularFile)); -+ // Plazma end - - return optional.flatMap((path) -> { - try { -diff --git a/src/main/java/net/minecraft/server/PlayerAdvancements.java b/src/main/java/net/minecraft/server/PlayerAdvancements.java -index ef520d1dd..b3b0c18b4 100644 ---- a/src/main/java/net/minecraft/server/PlayerAdvancements.java -+++ b/src/main/java/net/minecraft/server/PlayerAdvancements.java -@@ -130,7 +130,7 @@ public class PlayerAdvancements { - } - - private void load(ServerAdvancementManager advancementLoader) { -- if (Files.isRegularFile(this.playerSavePath, new LinkOption[0])) { -+ if (Files.isRegularFile(this.playerSavePath/*, new LinkOption[0]*/)) { // Plazma - Reduce allocations - try { - JsonReader jsonreader = new JsonReader(Files.newBufferedReader(this.playerSavePath, StandardCharsets.UTF_8)); - -diff --git a/src/main/java/net/minecraft/server/RunningOnDifferentThreadException.java b/src/main/java/net/minecraft/server/RunningOnDifferentThreadException.java -index 0f52e8a61ca7e57e9f52473dceb9cc3464c0c86d..f54bde32760541a653460682e5a3ddd0b2ceec51 100644 ---- a/src/main/java/net/minecraft/server/RunningOnDifferentThreadException.java -+++ b/src/main/java/net/minecraft/server/RunningOnDifferentThreadException.java -@@ -4,12 +4,12 @@ public final class RunningOnDifferentThreadException extends RuntimeException { - public static final RunningOnDifferentThreadException RUNNING_ON_DIFFERENT_THREAD = new RunningOnDifferentThreadException(); - - private RunningOnDifferentThreadException() { -- this.setStackTrace(new StackTraceElement[0]); -+ this.setStackTrace(org.plazmamc.plazma.constants.Empty.TRACE); // Plazma - Reduce allocations - } - - @Override - public synchronized Throwable fillInStackTrace() { -- this.setStackTrace(new StackTraceElement[0]); -+ this.setStackTrace(org.plazmamc.plazma.constants.Empty.TRACE); // Plazma - Reduce allocations - return this; - } - } -diff --git a/src/main/java/net/minecraft/server/ServerFunctionLibrary.java b/src/main/java/net/minecraft/server/ServerFunctionLibrary.java -index bae0d208b31aa0a6977c30f2f8484ab3c316bc71..981c3023044f3cc6dc22ada20cd4bedcf7a28db3 100644 ---- a/src/main/java/net/minecraft/server/ServerFunctionLibrary.java -+++ b/src/main/java/net/minecraft/server/ServerFunctionLibrary.java -@@ -92,7 +92,7 @@ public class ServerFunctionLibrary implements PreparableReloadListener { - }, prepareExecutor)); - } - -- CompletableFuture[] completableFutures = map.values().toArray(new CompletableFuture[0]); -+ CompletableFuture[] completableFutures = map.values().toArray(org.plazmamc.plazma.constants.Empty.FUTURE); // Plazma - Reduce allocations - return CompletableFuture.allOf(completableFutures).handle((unused, ex) -> map); - } - ); -diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java -index 4e6fccec4..618dc900d 100644 ---- a/src/main/java/net/minecraft/server/level/ChunkMap.java -+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java -@@ -112,6 +112,7 @@ import org.bukkit.craftbukkit.generator.CustomChunkGenerator; - - public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider { - -+ private static final ServerPlayerConnection[] EMPTY_CONNECTION = new ServerPlayerConnection[0]; // Plazma - Reduce allocations - private static final byte CHUNK_TYPE_REPLACEABLE = -1; - private static final byte CHUNK_TYPE_UNKNOWN = 0; - private static final byte CHUNK_TYPE_FULL = 1; -@@ -1361,7 +1362,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider - // stuff could have been removed, so we need to check the trackedPlayers set - // for players that were removed - -- for (ServerPlayerConnection conn : this.seenBy.toArray(new ServerPlayerConnection[0])) { // avoid CME -+ for (ServerPlayerConnection conn : this.seenBy.toArray(EMPTY_CONNECTION)) { // avoid CME // Plazma - Reduce allocations - if (newTrackerCandidates == null || !newTrackerCandidates.contains(conn.getPlayer())) { - this.updatePlayer(conn.getPlayer()); - } -diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java -index f72af2feb..0aaa0e63f 100644 ---- a/src/main/java/net/minecraft/server/level/ServerLevel.java -+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java -@@ -1439,7 +1439,7 @@ public class ServerLevel extends Level implements WorldGenLevel { - - public static List getCurrentlyTickingEntities() { - Entity ticking = currentlyTickingEntity.get(); -- List ret = java.util.Arrays.asList(ticking == null ? new Entity[0] : new Entity[] { ticking }); -+ List ret = java.util.Arrays.asList(ticking == null ? org.plazmamc.plazma.constants.Empty.ENTITY : new Entity[] { ticking }); // Plazma - Reduce allocations - - return ret; - } -diff --git a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java -index 3b4fadb37..f276fe09f 100644 ---- a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java -+++ b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java -@@ -165,12 +165,12 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener, - - @Override - public void handleHello(ServerboundHelloPacket packet) { -- Validate.validState(this.state == ServerLoginPacketListenerImpl.State.HELLO, "Unexpected hello packet", new Object[0]); -+ Validate.validState(this.state == ServerLoginPacketListenerImpl.State.HELLO, "Unexpected hello packet"/*, new Object[0]*/); // Plazma - Reduce allocations - // Paper start - Validate usernames - if (io.papermc.paper.configuration.GlobalConfiguration.get().proxies.isProxyOnlineMode() - && io.papermc.paper.configuration.GlobalConfiguration.get().unsupportedSettings.performUsernameValidation - && !this.iKnowThisMayNotBeTheBestIdeaButPleaseDisableUsernameValidation) { -- Validate.validState(StringUtil.isReasonablePlayerName(packet.name()), "Invalid characters in username", new Object[0]); -+ Validate.validState(StringUtil.isReasonablePlayerName(packet.name()), "Invalid characters in username"/*, new Object[0]*/); // Plazma - Reduce allocations - } - // Paper end - Validate usernames - this.requestedUsername = packet.name(); -@@ -268,7 +268,7 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener, - - @Override - public void handleKey(ServerboundKeyPacket packet) { -- Validate.validState(this.state == ServerLoginPacketListenerImpl.State.KEY, "Unexpected key packet", new Object[0]); -+ Validate.validState(this.state == ServerLoginPacketListenerImpl.State.KEY, "Unexpected key packet"/*, new Object[0]*/); // Plazma - Reduce allocations - - final String s; - -@@ -448,7 +448,7 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener, - - @Override - public void handleLoginAcknowledgement(ServerboundLoginAcknowledgedPacket packet) { -- Validate.validState(this.state == ServerLoginPacketListenerImpl.State.PROTOCOL_SWITCHING, "Unexpected login acknowledgement packet", new Object[0]); -+ Validate.validState(this.state == ServerLoginPacketListenerImpl.State.PROTOCOL_SWITCHING, "Unexpected login acknowledgement packet"/*, new Object[0]*/); // Plazma - Reduce allocations - this.connection.setupOutboundProtocol(ConfigurationProtocols.CLIENTBOUND); - CommonListenerCookie commonlistenercookie = CommonListenerCookie.createInitial((GameProfile) Objects.requireNonNull(this.authenticatedProfile), this.transferred); - ServerConfigurationPacketListenerImpl serverconfigurationpacketlistenerimpl = new ServerConfigurationPacketListenerImpl(this.server, this.connection, commonlistenercookie, this.player); // CraftBukkit -diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java -index b863f6fe6..068c7619b 100644 ---- a/src/main/java/net/minecraft/server/players/PlayerList.java -+++ b/src/main/java/net/minecraft/server/players/PlayerList.java -@@ -135,6 +135,7 @@ public abstract class PlayerList { - private static final Logger LOGGER = LogUtils.getLogger(); - private static final int SEND_PLAYER_INFO_INTERVAL = 600; - private static final SimpleDateFormat BAN_DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd 'at' HH:mm:ss z"); -+ private static final org.bukkit.event.player.PlayerRespawnEvent.RespawnFlag[] EMPTY_FLAG = new org.bukkit.event.player.PlayerRespawnEvent.RespawnFlag[0]; // Plazma - Reduce allocations - private final MinecraftServer server; - public final List players = new java.util.concurrent.CopyOnWriteArrayList(); // CraftBukkit - ArrayList -> CopyOnWriteArrayList: Iterator safety - private final Map playersByUUID = Maps.newHashMap(); -@@ -815,7 +816,7 @@ public abstract class PlayerList { - - public ServerPlayer respawn(ServerPlayer entityplayer, ServerLevel worldserver, boolean flag, Location location, boolean avoidSuffocation, RespawnReason reason) { - // Paper start - Expand PlayerRespawnEvent -- return respawn(entityplayer, worldserver, flag, location, avoidSuffocation, reason, new org.bukkit.event.player.PlayerRespawnEvent.RespawnFlag[0]); -+ return respawn(entityplayer, worldserver, flag, location, avoidSuffocation, reason, EMPTY_FLAG); // Plazma - Reduce allocations - } - - public ServerPlayer respawn(ServerPlayer entityplayer, ServerLevel worldserver, boolean flag, Location location, boolean avoidSuffocation, RespawnReason reason, org.bukkit.event.player.PlayerRespawnEvent.RespawnFlag...respawnFlags) { -diff --git a/src/main/java/net/minecraft/server/players/StoredUserList.java b/src/main/java/net/minecraft/server/players/StoredUserList.java -index c038da20b..b6cab933d 100644 ---- a/src/main/java/net/minecraft/server/players/StoredUserList.java -+++ b/src/main/java/net/minecraft/server/players/StoredUserList.java -@@ -76,7 +76,7 @@ public abstract class StoredUserList> { - } - - public String[] getUserList() { -- return (String[]) this.map.keySet().toArray(new String[0]); -+ return this.map.keySet().toArray(org.plazmamc.plazma.constants.Empty.STRING); // Plazma - Reduce allocations - } - - public boolean isEmpty() { -diff --git a/src/main/java/net/minecraft/util/MemoryReserve.java b/src/main/java/net/minecraft/util/MemoryReserve.java -index 0ee04fe6ff6a4d09754f326526ae04fe7226bab2..5663ce568a1daa638b7387bee8b9917ce1f64d14 100644 ---- a/src/main/java/net/minecraft/util/MemoryReserve.java -+++ b/src/main/java/net/minecraft/util/MemoryReserve.java -@@ -11,6 +11,6 @@ public class MemoryReserve { - } - - public static void release() { -- reserve = new byte[0]; -+ reserve = org.plazmamc.plazma.constants.Empty.BYTE; // Plazma - Reduce allocations - } - } -diff --git a/src/main/java/net/minecraft/util/ZeroBitStorage.java b/src/main/java/net/minecraft/util/ZeroBitStorage.java -index 01f5b946fabbe34f31110e75973dab9f39897346..2564c21900df7ca3c58872741ec8f68bce80a903 100644 ---- a/src/main/java/net/minecraft/util/ZeroBitStorage.java -+++ b/src/main/java/net/minecraft/util/ZeroBitStorage.java -@@ -5,7 +5,7 @@ import java.util.function.IntConsumer; - import org.apache.commons.lang3.Validate; - - public class ZeroBitStorage implements BitStorage { -- public static final long[] RAW = new long[0]; -+ // public static final long[] RAW = new long[0]; // Plazma - Reduce allocations - private final int size; - - public ZeroBitStorage(int size) { -@@ -33,7 +33,7 @@ public class ZeroBitStorage implements BitStorage { - - @Override - public long[] getRaw() { -- return RAW; -+ return org.plazmamc.plazma.constants.Empty.LONG; // Plazma - Reduce allocations - } - - @Override -diff --git a/src/main/java/net/minecraft/world/level/block/ComposterBlock.java b/src/main/java/net/minecraft/world/level/block/ComposterBlock.java -index f34159f8d..4088ec804 100644 ---- a/src/main/java/net/minecraft/world/level/block/ComposterBlock.java -+++ b/src/main/java/net/minecraft/world/level/block/ComposterBlock.java -@@ -57,6 +57,7 @@ public class ComposterBlock extends Block implements WorldlyContainerHolder { - public static final Object2FloatMap COMPOSTABLES = new Object2FloatOpenHashMap(); - private static final int AABB_SIDE_THICKNESS = 2; - private static final VoxelShape OUTER_SHAPE = Shapes.block(); -+ private static final int[] ZERO_INT = new int[]{0}; // Plazma - Reduce allocations // Plazma - Reduce allocations - private static final VoxelShape[] SHAPES = (VoxelShape[]) Util.make(new VoxelShape[9], (avoxelshape) -> { - for (int i = 0; i < 8; ++i) { - avoxelshape[i] = Shapes.join(ComposterBlock.OUTER_SHAPE, Block.box(2.0D, (double) Math.max(2, 1 + i * 2), 2.0D, 14.0D, 16.0D, 14.0D), BooleanOp.ONLY_FIRST); -@@ -458,7 +459,7 @@ public class ComposterBlock extends Block implements WorldlyContainerHolder { - - @Override - public int[] getSlotsForFace(Direction side) { -- return side == Direction.DOWN ? new int[]{0} : new int[0]; -+ return side == Direction.DOWN ? ZERO_INT : org.plazmamc.plazma.constants.Empty.INT; // Plazma - Reduce allocations - } - - @Override -@@ -507,7 +508,7 @@ public class ComposterBlock extends Block implements WorldlyContainerHolder { - - @Override - public int[] getSlotsForFace(Direction side) { -- return side == Direction.UP ? new int[]{0} : new int[0]; -+ return side == Direction.UP ? ZERO_INT : org.plazmamc.plazma.constants.Empty.INT; // Plazma - Reduce allocations - } - - @Override -@@ -549,7 +550,7 @@ public class ComposterBlock extends Block implements WorldlyContainerHolder { - - @Override - public int[] getSlotsForFace(Direction side) { -- return new int[0]; -+ return org.plazmamc.plazma.constants.Empty.INT; // Plazma - Reduce allocations - } - - @Override -diff --git a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFile.java b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFile.java -index 1362a4794..2490b63cb 100644 ---- a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFile.java -+++ b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFile.java -@@ -445,7 +445,7 @@ public class RegionFile implements AutoCloseable { - this.path = path; - initOversizedState(); // Paper - this.version = compressionFormat; -- if (!Files.isDirectory(directory, new LinkOption[0])) { -+ if (!Files.isDirectory(directory/*, new LinkOption[0]*/)) { // Plazma - Reduce allocations - throw new IllegalArgumentException("Expected directory, got " + String.valueOf(directory.toAbsolutePath())); - } else { - this.externalFileDir = directory; -@@ -717,7 +717,7 @@ public class RegionFile implements AutoCloseable { - private DataInputStream createExternalChunkInputStream(ChunkPos pos, byte flags) throws IOException { - Path path = this.getExternalChunkPath(pos); - -- if (!Files.isRegularFile(path, new LinkOption[0])) { -+ if (!Files.isRegularFile(path/*, new LinkOption[0]*/)) { // Plazma - Reduce allocations - RegionFile.LOGGER.error("External chunk path {} is not file", path); - return null; - } else { -@@ -769,7 +769,7 @@ public class RegionFile implements AutoCloseable { - return false; - } - -- if (!Files.isRegularFile(this.getExternalChunkPath(pos), new LinkOption[0])) { -+ if (!Files.isRegularFile(this.getExternalChunkPath(pos)/*, new LinkOption[0]*/)) { // Plazma - Reduce allocations - return false; - } - } else { -diff --git a/src/main/java/net/minecraft/world/level/levelgen/DebugLevelSource.java b/src/main/java/net/minecraft/world/level/levelgen/DebugLevelSource.java -index b8e333e79..b6012d360 100644 ---- a/src/main/java/net/minecraft/world/level/levelgen/DebugLevelSource.java -+++ b/src/main/java/net/minecraft/world/level/levelgen/DebugLevelSource.java -@@ -89,7 +89,7 @@ public class DebugLevelSource extends ChunkGenerator { - - @Override - public NoiseColumn getBaseColumn(int x, int z, LevelHeightAccessor world, RandomState noiseConfig) { -- return new NoiseColumn(0, new BlockState[0]); -+ return new NoiseColumn(0, org.plazmamc.plazma.constants.Empty.BLOCK_STATE); // Plazma - Reduce allocations - } - - @Override -diff --git a/src/main/java/net/minecraft/world/level/storage/LevelStorageSource.java b/src/main/java/net/minecraft/world/level/storage/LevelStorageSource.java -index 399da9d43aefbb95897df4697860d5bce5317152..df7816c1c5f069d89a22dbd876a2d663ba68949f 100644 ---- a/src/main/java/net/minecraft/world/level/storage/LevelStorageSource.java -+++ b/src/main/java/net/minecraft/world/level/storage/LevelStorageSource.java -@@ -110,7 +110,7 @@ public class LevelStorageSource { - } - - public static DirectoryValidator parseValidator(Path allowedSymlinksFile) { -- if (Files.exists(allowedSymlinksFile, new LinkOption[0])) { -+ if (Files.exists(allowedSymlinksFile/*, new LinkOption[0]*/)) { // Plazma - Reduce allocations - try { - BufferedReader bufferedreader = Files.newBufferedReader(allowedSymlinksFile); - -@@ -189,7 +189,7 @@ public class LevelStorageSource { - } - - public LevelStorageSource.LevelCandidates findLevelCandidates() throws LevelStorageException { -- if (!Files.isDirectory(this.baseDir, new LinkOption[0])) { -+ if (!Files.isDirectory(this.baseDir/*, new LinkOption[0]*/)) { // Plazma - Reduce allocations - throw new LevelStorageException(Component.translatable("selectWorld.load_folder_access")); - } else { - try { -@@ -198,11 +198,12 @@ public class LevelStorageSource { - LevelStorageSource.LevelCandidates convertable_a; - - try { -- List list = stream.filter((path) -> { -- return Files.isDirectory(path, new LinkOption[0]); -- }).map(LevelStorageSource.LevelDirectory::new).filter((convertable_b) -> { -- return Files.isRegularFile(convertable_b.dataFile(), new LinkOption[0]) || Files.isRegularFile(convertable_b.oldDataFile(), new LinkOption[0]); -- }).toList(); -+ // Plazma start - Reduce allocations -+ List list = stream.filter(Files::isDirectory) -+ .map(LevelStorageSource.LevelDirectory::new) -+ .filter(convertable_b -> Files.isRegularFile(convertable_b.dataFile()) || Files.isRegularFile(convertable_b.oldDataFile())) -+ .toList(); -+ // Plazma end - - convertable_a = new LevelStorageSource.LevelCandidates(list); - } catch (Throwable throwable) { -@@ -312,7 +313,7 @@ public class LevelStorageSource { - private LevelSummary readLevelSummary(LevelStorageSource.LevelDirectory save, boolean locked) { - Path path = save.dataFile(); - -- if (Files.exists(path, new LinkOption[0])) { -+ if (Files.exists(path/*, new LinkOption[0]*/)) { // Plazma - Reduce allocations - try { - if (Files.isSymbolicLink(path)) { - List list = this.worldDirValidator.validateSymlink(path); -@@ -411,7 +412,7 @@ public class LevelStorageSource { - - public boolean levelExists(String name) { - try { -- return Files.isDirectory(this.getLevelPath(name), new LinkOption[0]); -+ return Files.isDirectory(this.getLevelPath(name)/*, new LinkOption[0]*/); // Plazma - Reduce allocations - } catch (InvalidPathException invalidpathexception) { - return false; - } -@@ -752,7 +753,7 @@ public class LevelStorageSource { - } - - public boolean hasWorldData() { -- return Files.exists(this.levelDirectory.dataFile(), new LinkOption[0]) || Files.exists(this.levelDirectory.oldDataFile(), new LinkOption[0]); -+ return Files.exists(this.levelDirectory.dataFile()/*, new LinkOption[0]*/) || Files.exists(this.levelDirectory.oldDataFile()/*, new LinkOption[0]*/); // Plazma - Reduce allocations - } - - public void close() throws IOException { -diff --git a/src/main/java/net/minecraft/world/level/storage/PlayerDataStorage.java b/src/main/java/net/minecraft/world/level/storage/PlayerDataStorage.java -index 63e187c65cb855031f286aad0d25ac4694f7a331..e0f085169fafa5e574caf368efa343514540b348 100644 ---- a/src/main/java/net/minecraft/world/level/storage/PlayerDataStorage.java -+++ b/src/main/java/net/minecraft/world/level/storage/PlayerDataStorage.java -@@ -124,7 +124,7 @@ public class PlayerDataStorage { - String[] astring = this.playerDir.list(); - - if (astring == null) { -- astring = new String[0]; -+ astring = org.plazmamc.plazma.constants.Empty.STRING; // Plazma - Reduce allocations - } - - for (int i = 0; i < astring.length; ++i) { -diff --git a/src/main/java/net/minecraft/world/scores/Team.java b/src/main/java/net/minecraft/world/scores/Team.java -index f00791b89fdb1bb0fb358eff2af2e687bda15e85..aa16c93a4333b603729e2704b92f6d38aec0fd7b 100644 ---- a/src/main/java/net/minecraft/world/scores/Team.java -+++ b/src/main/java/net/minecraft/world/scores/Team.java -@@ -70,7 +70,7 @@ public abstract class Team { - public final int id; - - public static String[] getAllNames() { -- return BY_NAME.keySet().toArray(new String[0]); -+ return BY_NAME.keySet().toArray(org.plazmamc.plazma.constants.Empty.STRING); // Plazma - Reduce allocations - } - - @Nullable -diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java -index fb2d05e43df3bfb72b1f6e325736dd3cbc6c3096..de4e1d713e5ec182ea8d4832b8359556095ac214 100644 ---- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java -+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java -@@ -426,7 +426,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { - public void sendTitle(Title title) { - Preconditions.checkNotNull(title, "Title is null"); - setTitleTimes(title.getFadeIn(), title.getStay(), title.getFadeOut()); -- setSubtitle(title.getSubtitle() == null ? new BaseComponent[0] : title.getSubtitle()); -+ setSubtitle(title.getSubtitle() == null ? org.plazmamc.plazma.constants.Empty.BASE_COMPONENT : title.getSubtitle()); // Plazma - Reduce allocations - showTitle(title.getTitle()); - } - -diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBook.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBook.java -index c5d1ba7a1be3f102edcdfdc05fc50b30ef1f775b..66006d9ff581ac96f13389261de0cd647279b98a 100644 ---- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBook.java -+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBook.java -@@ -610,7 +610,7 @@ public class CraftMetaBook extends CraftMetaItem implements BookMeta { - throw new IllegalArgumentException("Invalid page number " + page + "/" + CraftMetaBook.this.getPageCount()); - } - -- BaseComponent[] newText = text == null ? new BaseComponent[0] : text; -+ BaseComponent[] newText = text == null ? org.plazmamc.plazma.constants.Empty.BASE_COMPONENT : text; // Plazma - Reduce allocations - CraftMetaBook.this.pages.set(page - 1, this.componentsToPage(newText)); - } - -@@ -623,7 +623,7 @@ public class CraftMetaBook extends CraftMetaItem implements BookMeta { - public void addPage(final BaseComponent[]... pages) { - for (BaseComponent[] page : pages) { - if (page == null) { -- page = new BaseComponent[0]; -+ page = org.plazmamc.plazma.constants.Empty.BASE_COMPONENT; // Plazma - Reduce allocations - } - - CraftMetaBook.this.internalAddPage(this.componentsToPage(page)); -diff --git a/src/main/java/org/bukkit/craftbukkit/util/WeakCollection.java b/src/main/java/org/bukkit/craftbukkit/util/WeakCollection.java -index b25dc23b81687dd4d4e70b3615ffb91f8c03c68b..acb98770b9d01e930642a5794f9179660b411c02 100644 ---- a/src/main/java/org/bukkit/craftbukkit/util/WeakCollection.java -+++ b/src/main/java/org/bukkit/craftbukkit/util/WeakCollection.java -@@ -164,7 +164,7 @@ public final class WeakCollection implements Collection { - - @Override - public Object[] toArray() { -- return this.toArray(new Object[0]); -+ return this.toArray(org.plazmamc.plazma.constants.Empty.OBJECT); // Plazma - Reduce allocations - } - - @Override -diff --git a/src/main/java/org/plazmamc/plazma/constants/Empty.java b/src/main/java/org/plazmamc/plazma/constants/Empty.java -new file mode 100644 -index 0000000000000000000000000000000000000000..2b6eb7997986ab73ccb3b1baca945a3234ae916e ---- /dev/null -+++ b/src/main/java/org/plazmamc/plazma/constants/Empty.java -@@ -0,0 +1,20 @@ -+package org.plazmamc.plazma.constants; -+ -+public interface Empty { -+ -+ int[] INT = new int[0]; -+ long[] LONG = new long[0]; -+ byte[] BYTE = new byte[0]; -+ -+ Object[] OBJECT = new Object[0]; -+ String[] STRING = new String[0]; -+ StackTraceElement[] TRACE = new StackTraceElement[0]; -+ java.util.concurrent.CompletableFuture[] FUTURE = new java.util.concurrent.CompletableFuture[0]; -+ -+ net.minecraft.world.level.block.state.BlockState[] BLOCK_STATE = new net.minecraft.world.level.block.state.BlockState[0]; -+ net.minecraft.world.entity.Entity[] ENTITY = new net.minecraft.world.entity.Entity[0]; -+ -+ @SuppressWarnings("deprecation") -+ net.md_5.bungee.api.chat.BaseComponent[] BASE_COMPONENT = new net.md_5.bungee.api.chat.BaseComponent[0]; -+ -+} -diff --git a/src/main/java/org/purpurmc/purpur/command/PurpurCommand.java b/src/main/java/org/purpurmc/purpur/command/PurpurCommand.java -index 2621e54879e9ab0029a875f1d09eee67878b90d5..e7e959368c01de69261618d1eb749bebba3527af 100644 ---- a/src/main/java/org/purpurmc/purpur/command/PurpurCommand.java -+++ b/src/main/java/org/purpurmc/purpur/command/PurpurCommand.java -@@ -57,7 +57,7 @@ public class PurpurCommand extends Command { - } else if (args[0].equalsIgnoreCase("version")) { - Command verCmd = org.bukkit.Bukkit.getServer().getCommandMap().getCommand("version"); - if (verCmd != null) { -- return verCmd.execute(sender, commandLabel, new String[0]); -+ return verCmd.execute(sender, commandLabel, org.plazmamc.plazma.constants.Empty.STRING); // Plazma - Reduce allocations - } - } - diff --git a/patches/api/0001-Purpur-API-Changes.patch b/patches/api/0001-Purpur-API-Changes.patch index e28813cc8..4c4fed9ba 100644 --- a/patches/api/0001-Purpur-API-Changes.patch +++ b/patches/api/0001-Purpur-API-Changes.patch @@ -1,6 +1,6 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: granny -Date: Wed, 8 May 2024 08:14:51 +0000 +Date: Tue, 14 May 2024 17:29:02 +0900 Subject: [PATCH] Purpur API Changes PurpurMC @@ -25,10 +25,10 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/build.gradle.kts b/build.gradle.kts -index 65e67b8726f1e19a6bcb1fe2f448e4ab68df11d1..892e78b1d2d29dc54def03fcb6d85a93ad56d84c 100644 +index fd39ed209b20c927054b8482c400beeeeab460a3..6aef83558a5ef7e84873b127c3bb43a6468c9a24 100644 --- a/build.gradle.kts +++ b/build.gradle.kts -@@ -121,6 +121,8 @@ tasks.jar { +@@ -142,6 +142,8 @@ tasks.jar { } tasks.withType { @@ -408,12 +408,12 @@ index 918a045165cdcde264bc24082b7afebb407271de..687d11619379aead7f665d4a5f8f8bcc + // Purpur end } diff --git a/src/main/java/org/bukkit/Material.java b/src/main/java/org/bukkit/Material.java -index 7a337fe908915f8ea487a0b9236c511cb07d5e66..1dd02e2782364bf25521088cf8858d3443643447 100644 +index 81f9ad99699a78b97e4accaaf1a98eacf29493ce..e3e996d932db689ba62a43f7f01d6f003f8337d3 100644 --- a/src/main/java/org/bukkit/Material.java +++ b/src/main/java/org/bukkit/Material.java -@@ -11657,4 +11657,40 @@ public enum Material implements Keyed, Translatable, net.kyori.adventure.transla - public boolean isEnabledByFeature(@NotNull World world) { - return Bukkit.getDataPackManager().isEnabledByFeature(this, world); +@@ -5701,4 +5701,40 @@ public enum Material implements Keyed, Translatable, net.kyori.adventure.transla + } + return Registry.BLOCK.get(material.key); } + + // Purpur start @@ -564,7 +564,7 @@ index 30298a629b39bd43ce14b414fc697b2dfcbea89c..ce00af9121de7a910aaea4e0685a06d4 + // Purpur end - OfflinePlayer API } diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java -index 30cbe3bdc7142769019765b03cc4fe1f9ba1ddb4..320422ff95773efa01e8205edcc5c6c9a84d5ecd 100644 +index c8595ffcfcbdd79794d464415287d46acef72b72..ec8b9b2cbe65838a194281f7d76d0e17defc5211 100644 --- a/src/main/java/org/bukkit/Server.java +++ b/src/main/java/org/bukkit/Server.java @@ -2257,6 +2257,18 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi @@ -586,7 +586,7 @@ index 30cbe3bdc7142769019765b03cc4fe1f9ba1ddb4..320422ff95773efa01e8205edcc5c6c9 /** * Sends the component to the player * -@@ -2540,4 +2552,105 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi +@@ -2542,4 +2554,105 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi */ boolean isOwnedByCurrentRegion(@NotNull Entity entity); // Paper end - Folia region threading API @@ -813,10 +813,10 @@ index 739911cda33b373f99df627a3a378b37d7d461aa..51e78c22cd021722b963fe31d1d9175d * Add an entity to the block. * diff --git a/src/main/java/org/bukkit/command/SimpleCommandMap.java b/src/main/java/org/bukkit/command/SimpleCommandMap.java -index ac9a28922f8a556944a4c3649d74c32c622f0cb0..5349f16136d9348c374a7dfe5b89a71dfcb0e66d 100644 +index c3a9cf65db73ed534bf20996c7f05b5eb0aaebe1..fdedac32544be6534288c8ba28abe7f5c4c56f3b 100644 --- a/src/main/java/org/bukkit/command/SimpleCommandMap.java +++ b/src/main/java/org/bukkit/command/SimpleCommandMap.java -@@ -143,6 +143,19 @@ public class SimpleCommandMap implements CommandMap { +@@ -152,6 +152,19 @@ public class SimpleCommandMap implements CommandMap { return false; } @@ -836,7 +836,7 @@ index ac9a28922f8a556944a4c3649d74c32c622f0cb0..5349f16136d9348c374a7dfe5b89a71d // Paper start - Plugins do weird things to workaround normal registration if (target.timings == null) { target.timings = co.aikar.timings.TimingsManager.getCommandTiming(null, target); -@@ -150,10 +163,10 @@ public class SimpleCommandMap implements CommandMap { +@@ -159,10 +172,10 @@ public class SimpleCommandMap implements CommandMap { // Paper end try { @@ -1440,10 +1440,10 @@ index c60be4fd24c7fdf65251dd6169e5e1ac3b588d95..569deccd2f1cf21da9b5906433ac493c + // Purpur end } diff --git a/src/main/java/org/bukkit/inventory/ItemStack.java b/src/main/java/org/bukkit/inventory/ItemStack.java -index 84a7bf0936d35bf42b5ed038d295d5c31740f472..6e9b4cbc81878616b1c48add5db534286d267b05 100644 +index c64413a6740b604282984dea2a8430a6e7478d68..5c609d916e2d2f08ba90ebd23f13c5c9a14bc73c 100644 --- a/src/main/java/org/bukkit/inventory/ItemStack.java +++ b/src/main/java/org/bukkit/inventory/ItemStack.java -@@ -17,6 +17,17 @@ import org.bukkit.inventory.meta.ItemMeta; +@@ -19,6 +19,17 @@ import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.material.MaterialData; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -1461,7 +1461,7 @@ index 84a7bf0936d35bf42b5ed038d295d5c31740f472..6e9b4cbc81878616b1c48add5db53428 /** * Represents a stack of items. -@@ -1073,4 +1084,565 @@ public class ItemStack implements Cloneable, ConfigurationSerializable, Translat +@@ -1079,4 +1090,565 @@ public class ItemStack implements Cloneable, ConfigurationSerializable, Translat return Bukkit.getUnsafe().computeTooltipLines(this, tooltipContext, player); } // Paper end - expose itemstack tooltip lines @@ -2028,7 +2028,7 @@ index 84a7bf0936d35bf42b5ed038d295d5c31740f472..6e9b4cbc81878616b1c48add5db53428 + // Purpur end } diff --git a/src/main/java/org/bukkit/inventory/RecipeChoice.java b/src/main/java/org/bukkit/inventory/RecipeChoice.java -index db8bcc66bdc4bedfffb4705db6338eda4c0ad29a..feda3ddfaaf37b6ee218a0e0b1fbc199899bd364 100644 +index c143b0d8b97d514566bac8413d0346cf50822aeb..032a21766ce91471cb7d91b663d70e0d9fa66a26 100644 --- a/src/main/java/org/bukkit/inventory/RecipeChoice.java +++ b/src/main/java/org/bukkit/inventory/RecipeChoice.java @@ -10,6 +10,7 @@ import java.util.function.Predicate; @@ -2039,7 +2039,7 @@ index db8bcc66bdc4bedfffb4705db6338eda4c0ad29a..feda3ddfaaf37b6ee218a0e0b1fbc199 /** * Represents a potential item match within a recipe. All choices within a -@@ -150,6 +151,7 @@ public interface RecipeChoice extends Predicate, Cloneable { +@@ -157,6 +158,7 @@ public interface RecipeChoice extends Predicate, Cloneable { public static class ExactChoice implements RecipeChoice { private List choices; @@ -2047,7 +2047,7 @@ index db8bcc66bdc4bedfffb4705db6338eda4c0ad29a..feda3ddfaaf37b6ee218a0e0b1fbc199 public ExactChoice(@NotNull ItemStack stack) { this(Arrays.asList(stack)); -@@ -194,6 +196,7 @@ public interface RecipeChoice extends Predicate, Cloneable { +@@ -206,6 +208,7 @@ public interface RecipeChoice extends Predicate, Cloneable { @Override public boolean test(@NotNull ItemStack t) { @@ -2055,7 +2055,7 @@ index db8bcc66bdc4bedfffb4705db6338eda4c0ad29a..feda3ddfaaf37b6ee218a0e0b1fbc199 for (ItemStack match : choices) { if (t.isSimilar(match)) { return true; -@@ -203,6 +206,17 @@ public interface RecipeChoice extends Predicate, Cloneable { +@@ -215,6 +218,17 @@ public interface RecipeChoice extends Predicate, Cloneable { return false; } diff --git a/patches/api/0002-Use-Gradle-Version-Catalogs.patch b/patches/api/0002-Use-Gradle-Version-Catalogs.patch index 78cdd585a..41df53d08 100644 --- a/patches/api/0002-Use-Gradle-Version-Catalogs.patch +++ b/patches/api/0002-Use-Gradle-Version-Catalogs.patch @@ -5,27 +5,28 @@ Subject: [PATCH] Use Gradle Version Catalogs diff --git a/build.gradle.kts b/build.gradle.kts -index 892e78b1d2d29dc54def03fcb6d85a93ad56d84c..cd64328dd664821a23ba2765e82dd633b696e3ab 100644 +index 6aef83558a5ef7e84873b127c3bb43a6468c9a24..dedd9703559dbff43adb4b0aee6765789f130d50 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -9,11 +9,13 @@ java { withJavadocJar() } -+/* ++/* // Plazma - Use Gradle Version Catalogs val annotationsVersion = "24.1.0" val bungeeCordChatVersion = "1.20-R0.2" - val adventureVersion = "4.17.0-SNAPSHOT" + val adventureVersion = "4.17.0" val slf4jVersion = "2.0.9" val log4jVersion = "2.17.1" -+ */ ++ */ // Plazma - Use Gradle Version Catalogs val apiAndDocs: Configuration by configurations.creating { attributes { attribute(Category.CATEGORY_ATTRIBUTE, objects.named(Category.DOCUMENTATION)) -@@ -27,54 +29,31 @@ configurations.api { +@@ -27,55 +29,31 @@ configurations.api { } dependencies { +- api("com.mojang:brigadier:1.2.9") // Paper - Brigadier command api - // api dependencies are listed transitively to API consumers - api("com.google.guava:guava:32.1.2-jre") - api("com.google.code.gson:gson:2.10.1") @@ -82,8 +83,8 @@ index 892e78b1d2d29dc54def03fcb6d85a93ad56d84c..cd64328dd664821a23ba2765e82dd633 + api(common.snakeyaml) + api(common.log4j.api) + api(common.maven.provider) -+ api(api.bungeechat) { exclude("com.google.guava", "guava") } + api(api.jsonsimple) { isTransitive = false } ++ api(api.bungeechat) { exclude("com.google.guava", "guava") } + apiAndDocs(platform(common.adventure.bom)) + apiAndDocs(common.bundles.adventure) + @@ -102,7 +103,7 @@ index 892e78b1d2d29dc54def03fcb6d85a93ad56d84c..cd64328dd664821a23ba2765e82dd633 } // Paper start -@@ -128,25 +107,16 @@ tasks.withType { +@@ -149,25 +127,16 @@ tasks.withType { options.use() options.isDocFilesSubDirs = true options.links( @@ -115,12 +116,12 @@ index 892e78b1d2d29dc54def03fcb6d85a93ad56d84c..cd64328dd664821a23ba2765e82dd633 - "https://www.javadoc.io/doc/com.google.code.gson/gson/2.10.1", - // Paper end - // Paper start -- //"https://jd.advntr.dev/api/$adventureVersion/", -- //"https://jd.advntr.dev/text-minimessage/$adventureVersion/", -- //"https://jd.advntr.dev/text-serializer-gson/$adventureVersion/", -- //"https://jd.advntr.dev/text-serializer-legacy/$adventureVersion/", -- //"https://jd.advntr.dev/text-serializer-plain/$adventureVersion/", -- //"https://jd.advntr.dev/text-logger-slf4j/$adventureVersion/", +- "https://jd.advntr.dev/api/$adventureVersion/", +- "https://jd.advntr.dev/text-minimessage/$adventureVersion/", +- "https://jd.advntr.dev/text-serializer-gson/$adventureVersion/", +- "https://jd.advntr.dev/text-serializer-legacy/$adventureVersion/", +- "https://jd.advntr.dev/text-serializer-plain/$adventureVersion/", +- "https://jd.advntr.dev/text-logger-slf4j/$adventureVersion/", - "https://javadoc.io/doc/org.slf4j/slf4j-api/$slf4jVersion/", - "https://javadoc.io/doc/org.apache.logging.log4j/log4j-api/$log4jVersion/", - // Paper end diff --git a/patches/api/0003-Rebrand.patch b/patches/api/0003-Rebrand.patch new file mode 100644 index 000000000..515c30393 --- /dev/null +++ b/patches/api/0003-Rebrand.patch @@ -0,0 +1,33 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: AlphaKR93 +Date: Tue, 14 May 2024 18:36:30 +0900 +Subject: [PATCH] Rebrand + + +diff --git a/MIT.txt b/MIT.txt +new file mode 100644 +index 0000000000000000000000000000000000000000..67d405764ed68083d0164b1af0eabc0af7f6efea +--- /dev/null ++++ b/MIT.txt +@@ -0,0 +1,21 @@ ++The MIT License (MIT) ++ ++Copyright (c) 2024 Paper Contributors ++ ++Permission is hereby granted, free of charge, to any person obtaining ++a copy of this software and associated documentation files (the "Software"), ++to deal in the Software without restriction, including without limitation ++the rights to use, copy, modify, merge, publish, distribute, sublicense, ++and/or sell copies of the Software, and to permit persons to whom ++the Software is furnished to do so, subject to the following conditions: ++ ++The above copyright notice and this permission notice shall be included ++in all copies or substantial portions of the Software. ++ ++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, ++EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE ++WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE ++AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS ++BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN ++AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF ++OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/patches/api/0003-Plazma-Configurations.patch b/patches/api/0004-Plazma-Configurations.patch similarity index 89% rename from patches/api/0003-Plazma-Configurations.patch rename to patches/api/0004-Plazma-Configurations.patch index f24fb4abd..31720c038 100644 --- a/patches/api/0003-Plazma-Configurations.patch +++ b/patches/api/0004-Plazma-Configurations.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Plazma Configurations diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java -index 320422ff95773efa01e8205edcc5c6c9a84d5ecd..f1b39968788f90ffc785b9dd434b2a3671553a14 100644 +index ec8b9b2cbe65838a194281f7d76d0e17defc5211..0062b2d4dc7a64d1e4da240bf8dc5b428eb242ee 100644 --- a/src/main/java/org/bukkit/Server.java +++ b/src/main/java/org/bukkit/Server.java @@ -2269,6 +2269,13 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi diff --git a/patches/api/0004-Various-API-Tweaks.patch b/patches/api/0005-Various-API-Tweaks.patch similarity index 100% rename from patches/api/0004-Various-API-Tweaks.patch rename to patches/api/0005-Various-API-Tweaks.patch diff --git a/patches/mojang-api/0001-Rebrand.patch b/patches/mojang-api/0001-Rebrand.patch deleted file mode 100644 index 2d26dc589..000000000 --- a/patches/mojang-api/0001-Rebrand.patch +++ /dev/null @@ -1,19 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Alpha -Date: Tue, 27 Feb 2024 18:36:43 +0900 -Subject: [PATCH] Rebrand - - -diff --git a/build.gradle.kts b/build.gradle.kts -index e60be45e2513ea49a8605682c3d80835df4c58ee..6e0d314343bca0c3742359c1734c775a4c2a2b18 100644 ---- a/build.gradle.kts -+++ b/build.gradle.kts -@@ -9,7 +9,7 @@ java { - } - - dependencies { -- implementation(project(":paper-api")) -+ implementation(project(":${parent!!.property("projectName").toString().lowercase()}-api")) // Plazma - Rebrand - api("com.mojang:brigadier:1.0.18") - - compileOnly("it.unimi.dsi:fastutil:8.5.6") diff --git a/patches/mojang-api/0002-Add-.gitignore-file.patch b/patches/mojang-api/0002-Add-.gitignore-file.patch deleted file mode 100644 index 5e140c6db..000000000 --- a/patches/mojang-api/0002-Add-.gitignore-file.patch +++ /dev/null @@ -1,52 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: AlphaKR93 -Date: Tue, 7 May 2024 23:07:33 +0900 -Subject: [PATCH] Add .gitignore file - - -diff --git a/.gitignore b/.gitignore -new file mode 100644 -index 0000000000000000000000000000000000000000..97e78e27ee0eea2c8b24886eeb19164d552323fe ---- /dev/null -+++ b/.gitignore -@@ -0,0 +1,40 @@ -+.gradle/ -+ -+# Eclipse stuff -+/.classpath -+/.project -+/.settings -+/.checkstyle -+/.factorypath -+ -+# netbeans -+/nbproject -+/nb-configuration.xml -+ -+# we use maven! -+/build.xml -+ -+# maven -+/target -+ -+# vim -+.*.sw[a-p] -+ -+# various other potential build files -+/build -+/bin -+/dist -+/manifest.mf -+ -+# Mac filesystem dust -+.DS_Store -+ -+# intellij -+*.iml -+*.ipr -+*.iws -+.idea/ -+ -+# vs code -+/.vscode -+/.factorypath diff --git a/patches/server/0001-Purpur-Server-Changes.patch b/patches/server/0001-Purpur-Server-Changes.patch index 7eb3572bf..36a753bdc 100644 --- a/patches/server/0001-Purpur-Server-Changes.patch +++ b/patches/server/0001-Purpur-Server-Changes.patch @@ -1,6 +1,6 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: granny -Date: Wed, 8 May 2024 08:14:50 +0000 +Date: Tue, 14 May 2024 17:29:02 +0900 Subject: [PATCH] Purpur Server Changes PurpurMC @@ -25,25 +25,19 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/build.gradle.kts b/build.gradle.kts -index 5d448d8a7cf6626a11791f30ad52baf41a099272..81996f00384674b29368e8bea944bdd14d631da3 100644 +index 87bb3fd9b97506f61734ae7f2e6860610ba794e7..89f21e21efc5f5ab99d1586f4f3b8f2f3c48ac06 100644 --- a/build.gradle.kts +++ b/build.gradle.kts -@@ -12,8 +12,12 @@ configurations.named(log4jPlugins.compileClasspathConfigurationName) { +@@ -12,7 +12,7 @@ configurations.named(log4jPlugins.compileClasspathConfigurationName) { val alsoShade: Configuration by configurations.creating dependencies { - implementation(project(":paper-api")) -- implementation(project(":paper-mojangapi")) -+ // Purpur start -+ implementation(project(":purpur-api")) -+ implementation("io.papermc.paper:paper-mojangapi:${project.version}") { -+ exclude("io.papermc.paper", "paper-api") -+ } -+ // Purpur end ++ implementation(project(":purpur-api")) // Purpur // Paper start implementation("org.jline:jline-terminal-jansi:3.21.0") implementation("net.minecrell:terminalconsoleappender:1.3.0") -@@ -47,6 +51,10 @@ dependencies { +@@ -46,6 +46,10 @@ dependencies { runtimeOnly("org.apache.maven.resolver:maven-resolver-connector-basic:1.9.18") runtimeOnly("org.apache.maven.resolver:maven-resolver-transport-http:1.9.18") @@ -54,7 +48,7 @@ index 5d448d8a7cf6626a11791f30ad52baf41a099272..81996f00384674b29368e8bea944bdd1 testImplementation("io.github.classgraph:classgraph:4.8.47") // Paper - mob goal test testImplementation("org.junit.jupiter:junit-jupiter:5.10.2") testImplementation("org.hamcrest:hamcrest:2.2") -@@ -79,7 +87,7 @@ tasks.jar { +@@ -78,7 +82,7 @@ tasks.jar { attributes( "Main-Class" to "org.bukkit.craftbukkit.Main", "Implementation-Title" to "CraftBukkit", @@ -63,7 +57,7 @@ index 5d448d8a7cf6626a11791f30ad52baf41a099272..81996f00384674b29368e8bea944bdd1 "Implementation-Vendor" to date, // Paper "Specification-Title" to "Bukkit", "Specification-Version" to project.version, -@@ -138,7 +146,7 @@ fun TaskContainer.registerRunTask( +@@ -137,7 +141,7 @@ fun TaskContainer.registerRunTask( name: String, block: JavaExec.() -> Unit ): TaskProvider = register(name) { @@ -491,6 +485,30 @@ index f0fce4113fb07c64adbec029d177c236cbdcbae8..e94224ed280247ee69dfdff8dc960f2b sender.sendMessage(component); } +diff --git a/src/main/java/io/papermc/paper/command/brigadier/bukkit/BukkitCommandNode.java b/src/main/java/io/papermc/paper/command/brigadier/bukkit/BukkitCommandNode.java +index 10a113b057b0a4d27cce3bae975e1108aaa7b517..02597f890ac7f2dc12c94c283356b8309638dd17 100644 +--- a/src/main/java/io/papermc/paper/command/brigadier/bukkit/BukkitCommandNode.java ++++ b/src/main/java/io/papermc/paper/command/brigadier/bukkit/BukkitCommandNode.java +@@ -75,16 +75,16 @@ public class BukkitCommandNode extends LiteralCommandNode { + + // Plugins do weird things to workaround normal registration + if (this.command.timings == null) { +- this.command.timings = co.aikar.timings.TimingsManager.getCommandTiming(null, this.command); ++ //this.command.timings = co.aikar.timings.TimingsManager.getCommandTiming(null, this.command); // Purpur + } + + String content = context.getRange().get(context.getInput()); + String[] args = org.apache.commons.lang3.StringUtils.split(content, ' '); // fix adjacent spaces (from console/plugins) causing empty array elements + +- try (Timing ignored = this.command.timings.startTiming()) { ++ //try (Timing ignored = this.command.timings.startTiming()) { // Purpur + // Note: we don't return the result of target.execute as thats success / failure, we return handled (true) or not handled (false) + this.command.execute(sender, this.literal, Arrays.copyOfRange(args, 1, args.length)); +- } ++ //} // Purpur + + // return true as command was handled + return 1; diff --git a/src/main/java/io/papermc/paper/logging/SysoutCatcher.java b/src/main/java/io/papermc/paper/logging/SysoutCatcher.java index a8e813ca89b033f061e695288b3383bdcf128531..1ab65af9359d19530bba7f985a604d2a430ee234 100644 --- a/src/main/java/io/papermc/paper/logging/SysoutCatcher.java @@ -656,10 +674,10 @@ index 4f3cc14d48690bb183d09bb7a5ba1e23e8a0c08a..c366d84518979e842a6f10f969a59515 stringbuilder.append(CrashReport.getErrorComment()); stringbuilder.append("\n\n"); diff --git a/src/main/java/net/minecraft/commands/CommandSourceStack.java b/src/main/java/net/minecraft/commands/CommandSourceStack.java -index e6c7f62ed379a78645933670299e4fcda8540ed1..7475aaac2673729091eabc741c8ebb561aeec8f1 100644 +index 59d7e8a3d83d3ab7aa28606401bb129ccaeff240..684536f600cca94ea346129a139ec4aac4d9f979 100644 --- a/src/main/java/net/minecraft/commands/CommandSourceStack.java +++ b/src/main/java/net/minecraft/commands/CommandSourceStack.java -@@ -230,6 +230,19 @@ public class CommandSourceStack implements ExecutionCommandSource parseresults, String s, String label) { // CraftBukkit +@@ -339,9 +347,9 @@ public class Commands { + // Paper end CommandSourceStack commandlistenerwrapper = (CommandSourceStack) parseresults.getContext().getSource(); - commandlistenerwrapper.getServer().getProfiler().push(() -> { @@ -761,7 +779,7 @@ index aa2fca6917fb67fe0e9ba067d11487c3a274f675..f9d0e8ee9414b3897f268ba78a1469dd ContextChain contextchain = this.finishParsing(parseresults, s, commandlistenerwrapper, label); // CraftBukkit // Paper - Add UnknownCommandEvent try { -@@ -358,7 +366,7 @@ public class Commands { +@@ -371,7 +379,7 @@ public class Commands { Commands.LOGGER.error("'/{}' threw an exception", s, exception); } } finally { @@ -770,7 +788,7 @@ index aa2fca6917fb67fe0e9ba067d11487c3a274f675..f9d0e8ee9414b3897f268ba78a1469dd } } -@@ -501,6 +509,7 @@ public class Commands { +@@ -514,6 +522,7 @@ public class Commands { private void runSync(ServerPlayer player, Collection bukkit, RootCommandNode rootcommandnode) { // Paper end - Perf: Async command map building new com.destroystokyo.paper.event.brigadier.AsyncPlayerSendCommandsEvent(player.getBukkitEntity(), (RootCommandNode) rootcommandnode, false).callEvent(); // Paper - Brigadier API @@ -778,7 +796,7 @@ index aa2fca6917fb67fe0e9ba067d11487c3a274f675..f9d0e8ee9414b3897f268ba78a1469dd PlayerCommandSendEvent event = new PlayerCommandSendEvent(player.getBukkitEntity(), new LinkedHashSet<>(bukkit)); event.getPlayer().getServer().getPluginManager().callEvent(event); -@@ -511,6 +520,7 @@ public class Commands { +@@ -524,6 +533,7 @@ public class Commands { } } // CraftBukkit end @@ -1050,7 +1068,7 @@ index 5443013060b62e3bfcc51cddca96d1c0bc59fe72..411f1f8c6be072cfc5ba88cbec38dbc4 Bootstrap.bootStrap(); Bootstrap.validate(); diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index 8dc2f9df367c849ca333bf1a1fd92ff91617b548..21327a92b75a460c7beb3aa408502f37a7db31fa 100644 +index 39303bb4e336732db0ab19dee0c1f8b609bbb134..dfe3d28bd97d1335457d1005ecf69afe75d5ff80 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java @@ -300,6 +300,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop processQueue = new java.util.concurrent.ConcurrentLinkedQueue(); public int autosavePeriod; - public Commands vanillaCommandDispatcher; + // Paper - don't store the vanilla dispatcher @@ -310,11 +311,13 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop 0 && this.tickCount % autosavePeriod == 0; try { this.isSaving = true; -@@ -1599,20 +1634,20 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop { entityplayer.connection.suspendFlushing(); }); @@ -1337,7 +1355,7 @@ index 8dc2f9df367c849ca333bf1a1fd92ff91617b548..21327a92b75a460c7beb3aa408502f37 // Paper start - Folia scheduler API ((io.papermc.paper.threadedregions.scheduler.FoliaGlobalRegionScheduler) Bukkit.getGlobalRegionScheduler()).tick(); getAllLevels().forEach(level -> { -@@ -1717,22 +1752,22 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop 0; // Paper - Add EntityMoveEvent net.minecraft.world.level.block.entity.HopperBlockEntity.skipHopperEvents = worldserver.paperConfig().hopper.disableMoveEvent || org.bukkit.event.inventory.InventoryMoveItemEvent.getHandlerList().getRegisteredListeners().length == 0; // Paper - Perf: Optimize Hoppers worldserver.updateLagCompensationTick(); // Paper - lag compensation @@ -1425,7 +1443,7 @@ index 8dc2f9df367c849ca333bf1a1fd92ff91617b548..21327a92b75a460c7beb3aa408502f37 } catch (Throwable throwable) { CrashReport crashreport = CrashReport.forThrowable(throwable, "Exception ticking world"); -@@ -1794,33 +1830,33 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop { this.executeBlocking(() -> { this.saveDebugReport(path.resolve("server")); -@@ -2806,40 +2843,40 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop> consumer, Set trackedPlayers) { this.trackedPlayers = trackedPlayers; diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java -index 0981d440d0dbfe4df668d1f3f1b5706a93bc4434..f72af2feb74626abbdfbfd090c15357457810240 100644 +index ca56a0b596976448da6bb2a0e82b3d5cd4133e12..7924e3c597164f71056cd58dd167ee8b1d41b9c3 100644 --- a/src/main/java/net/minecraft/server/level/ServerLevel.java +++ b/src/main/java/net/minecraft/server/level/ServerLevel.java @@ -220,6 +220,8 @@ public class ServerLevel extends Level implements WorldGenLevel { @@ -2759,7 +2777,7 @@ index 0981d440d0dbfe4df668d1f3f1b5706a93bc4434..f72af2feb74626abbdfbfd090c153574 } // Paper end - Fix merchant inventory not closing on entity removal diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java -index 8437316888c6056060a2780652147590b6fe7443..d7e4a9fe9676563845d9981523bff1a7ff12282c 100644 +index c10401e587a710d49c4af481c1e531b4bf51f755..37636343c1b62b7dfa426bd6ca2bd425fd1bfff3 100644 --- a/src/main/java/net/minecraft/server/level/ServerPlayer.java +++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java @@ -298,6 +298,10 @@ public class ServerPlayer extends Player { @@ -3116,7 +3134,7 @@ index 1351423a12c19a01f602a202832372a399e6a867..1e2025674eafcf56460c741083c91e2e Util.logAndPauseIfInIde("Detected setBlock in a far chunk [" + i + ", " + j + "], pos: " + String.valueOf(pos) + ", status: " + String.valueOf(this.generatingStatus) + (this.currentlyGenerating == null ? "" : ", currently generating: " + (String) this.currentlyGenerating.get())); hasSetFarWarned = true; diff --git a/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java -index 8ac5d8ccf731100a1be690cb2ed1be82cadba8ed..8368c5ff929df9d32cdb95cc2da0e9f7f3b85d2a 100644 +index 308aef9c4933b2bcdd622a34b68efab4a220fe4d..b82a72775f9de5ad65ae46a8b97f93a7ef852265 100644 --- a/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java @@ -73,11 +73,13 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack @@ -3190,8 +3208,8 @@ index 8ac5d8ccf731100a1be690cb2ed1be82cadba8ed..8368c5ff929df9d32cdb95cc2da0e9f7 + } else + // Purpur end + - if (!this.isSingleplayerOwner() && elapsedTime >= KEEPALIVE_LIMIT) { // Paper - check keepalive limit, don't fire if already disconnected - if (this.keepAlivePending && !this.processedDisconnect) { // Paper + if (!this.isSingleplayerOwner() && elapsedTime >= 15000L) { // Paper - use vanilla's 15000L between keep alive packets + if (this.keepAlivePending && !this.processedDisconnect && elapsedTime >= KEEPALIVE_LIMIT) { // Paper - check keepalive limit, don't fire if already disconnected this.disconnect(ServerCommonPacketListenerImpl.TIMEOUT_DISCONNECTION_MESSAGE, org.bukkit.event.player.PlayerKickEvent.Cause.TIMEOUT); // Paper - kick event cause @@ -264,7 +298,7 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack } @@ -3203,7 +3221,7 @@ index 8ac5d8ccf731100a1be690cb2ed1be82cadba8ed..8368c5ff929df9d32cdb95cc2da0e9f7 private boolean checkIfClosed(long time) { diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -index 5e9202bc7fc649764568b55d66ba0d684118c00c..478f3bba5e0768c8ab800d7cb591f07db1bc20da 100644 +index b9b3277c8ed94e0cd30b20b9c00a33eaad48e5ac..0c3768bb183451e9dfe94bbc9b203bd79e474b99 100644 --- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java @@ -332,6 +332,20 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl @@ -3443,34 +3461,7 @@ index 5e9202bc7fc649764568b55d66ba0d684118c00c..478f3bba5e0768c8ab800d7cb591f07d org.bukkit.event.player.PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(this.player, Action.RIGHT_CLICK_AIR, itemstack, enumhand); cancelled = event.useItemInHand() == Event.Result.DENY; } else { -@@ -2466,7 +2546,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl - - public void handleCommand(String s) { // Paper - private -> public - org.spigotmc.AsyncCatcher.catchOp("Command Dispatched Async: " + s); // Paper - Add async catcher -- co.aikar.timings.MinecraftTimings.playerCommandTimer.startTiming(); // Paper -+ //co.aikar.timings.MinecraftTimings.playerCommandTimer.startTiming(); // Paper // Purpur - if ( org.spigotmc.SpigotConfig.logCommands ) // Spigot - this.LOGGER.info(this.player.getScoreboardName() + " issued server command: " + s); - -@@ -2476,7 +2556,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl - this.cserver.getPluginManager().callEvent(event); - - if (event.isCancelled()) { -- co.aikar.timings.MinecraftTimings.playerCommandTimer.stopTiming(); // Paper -+ //co.aikar.timings.MinecraftTimings.playerCommandTimer.stopTiming(); // Paper // Purpur - return; - } - -@@ -2489,7 +2569,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl - java.util.logging.Logger.getLogger(ServerGamePacketListenerImpl.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); - return; - } finally { -- co.aikar.timings.MinecraftTimings.playerCommandTimer.stopTiming(); // Paper -+ //co.aikar.timings.MinecraftTimings.playerCommandTimer.stopTiming(); // Paper // Purpur - } - } - // CraftBukkit end -@@ -2776,6 +2856,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl +@@ -2759,6 +2839,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl AABB axisalignedbb = entity.getBoundingBox(); if (this.player.canInteractWithEntity(axisalignedbb, 1.0D)) { @@ -3478,7 +3469,7 @@ index 5e9202bc7fc649764568b55d66ba0d684118c00c..478f3bba5e0768c8ab800d7cb591f07d packet.dispatch(new ServerboundInteractPacket.Handler() { private void performInteraction(InteractionHand enumhand, ServerGamePacketListenerImpl.EntityInteraction playerconnection_a, PlayerInteractEntityEvent event) { // CraftBukkit ItemStack itemstack = ServerGamePacketListenerImpl.this.player.getItemInHand(enumhand); -@@ -2789,6 +2870,8 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl +@@ -2772,6 +2853,8 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl ServerGamePacketListenerImpl.this.cserver.getPluginManager().callEvent(event); @@ -3916,11 +3907,11 @@ index 99a7e9eb75231c15bd8bb24fbb4e296bc9fdedff..4fb025a63628eb60509d90b680922a02 } } diff --git a/src/main/java/net/minecraft/world/damagesource/DamageSource.java b/src/main/java/net/minecraft/world/damagesource/DamageSource.java -index 359a2f0492a9b938a4f015c546e100e0092ae1d4..25e614be19b2b29b36af136b823f27f85e1650fa 100644 +index dd9638bdb228a53e72820e0e7cf6fe6fcc08fe4b..1ce1235cbbf23fe975c85a0f713280b433459951 100644 --- a/src/main/java/net/minecraft/world/damagesource/DamageSource.java +++ b/src/main/java/net/minecraft/world/damagesource/DamageSource.java @@ -29,6 +29,8 @@ public class DamageSource { - private boolean withSweep = false; + private boolean sweep = false; private boolean melting = false; private boolean poison = false; + private boolean scissors = false; // Purpur @@ -3953,10 +3944,10 @@ index 359a2f0492a9b938a4f015c546e100e0092ae1d4..25e614be19b2b29b36af136b823f27f8 + // Purpur end + // Paper start - fix DamageSource API - public @Nullable Entity getCustomEventDamager() { - return (this.customEventDamager != null) ? this.customEventDamager : this.directEntity; -@@ -101,6 +123,8 @@ public class DamageSource { - damageSource.withSweep = this.isSweep(); + @Nullable + public Entity getCustomEventDamager() { +@@ -117,6 +139,8 @@ public class DamageSource { + damageSource.sweep = this.isSweep(); damageSource.poison = this.isPoison(); damageSource.melting = this.isMelting(); + damageSource.scissors = this.isScissors(); // Purpur @@ -3964,7 +3955,7 @@ index 359a2f0492a9b938a4f015c546e100e0092ae1d4..25e614be19b2b29b36af136b823f27f8 return damageSource; } // CraftBukkit end -@@ -173,10 +197,19 @@ public class DamageSource { +@@ -189,10 +213,19 @@ public class DamageSource { ItemStack itemstack1 = itemstack; @@ -3986,7 +3977,7 @@ index 359a2f0492a9b938a4f015c546e100e0092ae1d4..25e614be19b2b29b36af136b823f27f8 return this.type().msgId(); } diff --git a/src/main/java/net/minecraft/world/damagesource/DamageSources.java b/src/main/java/net/minecraft/world/damagesource/DamageSources.java -index a1c53f04c2dd505e6af72e512e111d7994786035..5ffe772e29dfd422b664e8123e7f5cf396158674 100644 +index 5ec8cbd07a1830876f58e1fd33de6df4466d7e95..b1fb94380b7d6bd2a3be31a4e8fe95367e948fe2 100644 --- a/src/main/java/net/minecraft/world/damagesource/DamageSources.java +++ b/src/main/java/net/minecraft/world/damagesource/DamageSources.java @@ -44,11 +44,15 @@ public class DamageSources { @@ -4648,7 +4639,7 @@ index 09fdea983772612ef3fff6b2da3cf469a34e4ec0..3e2ea26c23e88c395856b65001f2895d protected ParticleOptions getInkParticle() { return ParticleTypes.GLOW_SQUID_INK; diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java -index 6e043457a29a890bcefd27fc5bb07c1a7e4e30f7..53ff232129443ba3242cfc57fc57026bf76d96e8 100644 +index 517e10c3d8b1549cd30fd0e7cf2bcb35e88eb8ed..3776b9bf7abce6b3024c50f04741031ef0e8e9c4 100644 --- a/src/main/java/net/minecraft/world/entity/LivingEntity.java +++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java @@ -229,9 +229,9 @@ public abstract class LivingEntity extends Entity implements Attackable { @@ -4864,7 +4855,7 @@ index 6e043457a29a890bcefd27fc5bb07c1a7e4e30f7..53ff232129443ba3242cfc57fc57026b + } // Purpur } // CraftBukkit start - Call death event // Paper start - call advancement triggers with correct entity equipment - org.bukkit.event.entity.EntityDeathEvent deathEvent = CraftEventFactory.callEntityDeathEvent(this, this.drops, () -> { + org.bukkit.event.entity.EntityDeathEvent deathEvent = CraftEventFactory.callEntityDeathEvent(this, source, this.drops, () -> { @@ -2363,6 +2412,21 @@ public abstract class LivingEntity extends Entity implements Attackable { } } @@ -10230,7 +10221,7 @@ index d8e440e14b72dc48ae97244f1bed2c06abd997ab..15ca426701f1fc821da94a4dee577fdb this.remove(Entity.RemovalReason.KILLED, EntityRemoveEvent.Cause.DEATH); // CraftBukkit - add Bukkit remove cause } diff --git a/src/main/java/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java b/src/main/java/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java -index 6f14607a88761171a72e274b3c9b476b20a272f1..3da1f7a6e443954e4976dd59391ea19b9c903cf7 100644 +index 0e797e2714a2fd103cbd51548764577fd9b6412d..52e1dd6e064dc03312e18ca515a24e7d3e9be957 100644 --- a/src/main/java/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java +++ b/src/main/java/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java @@ -106,6 +106,7 @@ public class EnderDragon extends Mob implements Enemy { @@ -10694,7 +10685,7 @@ index 7ddca52f7fe3f289b4b867e134326b1ead1a2aee..4a98027a12c2535d1df3a9f6390eb851 } diff --git a/src/main/java/net/minecraft/world/entity/decoration/ArmorStand.java b/src/main/java/net/minecraft/world/entity/decoration/ArmorStand.java -index c2bd2e303f956d390319f6bbbe9a6492ebec5154..6697cd8a632becd72ee132007a61d1221e817abf 100644 +index a02ca704e98ef42f32c3c50b111ee3537f60bf7b..92521cbedcf89a855f10a3401933acaf84bc3f98 100644 --- a/src/main/java/net/minecraft/world/entity/decoration/ArmorStand.java +++ b/src/main/java/net/minecraft/world/entity/decoration/ArmorStand.java @@ -103,10 +103,12 @@ public class ArmorStand extends LivingEntity { @@ -10734,7 +10725,7 @@ index c2bd2e303f956d390319f6bbbe9a6492ebec5154..6697cd8a632becd72ee132007a61d122 // Paper start - Allow ArmorStands not to tick if (!this.canTick) { if (this.noTickPoseDirty) { -@@ -1003,4 +1008,18 @@ public class ArmorStand extends LivingEntity { +@@ -1008,4 +1013,18 @@ public class ArmorStand extends LivingEntity { } } // Paper end @@ -11132,7 +11123,7 @@ index 87e4b300ac248f6c13d9b4a8f24fd78b24b565b4..43b5a0e7993ae9daef1c1ea67722347f public boolean doHurtTarget(Entity target) { if (super.doHurtTarget(target)) { diff --git a/src/main/java/net/minecraft/world/entity/monster/Creeper.java b/src/main/java/net/minecraft/world/entity/monster/Creeper.java -index cbcb2bfa8f91099e5c374f590f48885390bdf7a7..1829bedfa8084c4932a0e67c36f48f19993e22b6 100644 +index 0ae4ba060b2ce2c79e1235c939f3c1926eb6e33e..76a0bc9bd6033f1c66e940392f5bed360e7db43c 100644 --- a/src/main/java/net/minecraft/world/entity/monster/Creeper.java +++ b/src/main/java/net/minecraft/world/entity/monster/Creeper.java @@ -61,21 +61,99 @@ public class Creeper extends Monster implements PowerableMob { @@ -11288,8 +11279,8 @@ index cbcb2bfa8f91099e5c374f590f48885390bdf7a7..1829bedfa8084c4932a0e67c36f48f19 if (!event.isCancelled()) { // CraftBukkit end this.dead = true; -- this.level().explode(this, this.getX(), this.getY(), this.getZ(), event.getRadius(), event.getFire(), Level.ExplosionInteraction.MOB); // CraftBukkit // Paper - fix DamageSource API -+ this.level().explode(this, this.getX(), this.getY(), this.getZ(), event.getRadius(), event.getFire(), this.level().getGameRules().getBoolean(net.minecraft.world.level.GameRules.RULE_MOBGRIEFING) && level().purpurConfig.creeperAllowGriefing ? Level.ExplosionInteraction.MOB : Level.ExplosionInteraction.NONE); // CraftBukkit // Paper - fix DamageSource API // Purpur +- this.level().explode(this, this.getX(), this.getY(), this.getZ(), event.getRadius(), event.getFire(), Level.ExplosionInteraction.MOB); // CraftBukkit // Paper - fix DamageSource API (revert to vanilla, no, just no, don't change this) ++ this.level().explode(this, this.getX(), this.getY(), this.getZ(), event.getRadius(), event.getFire(), this.level().getGameRules().getBoolean(net.minecraft.world.level.GameRules.RULE_MOBGRIEFING) && level().purpurConfig.creeperAllowGriefing ? Level.ExplosionInteraction.MOB : Level.ExplosionInteraction.NONE); // CraftBukkit // Paper - fix DamageSource API (revert to vanilla, no, just no, don't change this) // Purpur this.discard(EntityRemoveEvent.Cause.EXPLODE); // CraftBukkit - add Bukkit remove cause this.spawnLingeringCloud(); // CraftBukkit start @@ -15018,7 +15009,7 @@ index c72b6ea5530e54fc373c701028e1c147cea34b59..96e9fce5f9084737d2fcf4deb8330573 if (spawnplacementtype.isSpawnPositionOk(world, blockposition2, EntityType.WANDERING_TRADER)) { blockposition1 = blockposition2; diff --git a/src/main/java/net/minecraft/world/entity/player/Player.java b/src/main/java/net/minecraft/world/entity/player/Player.java -index 093d1388ff90ad59110a37536b6639f939549068..845c4af5d5d38d54de4a1b20fe32bf5dd4776a29 100644 +index 093d1388ff90ad59110a37536b6639f939549068..9bef8e88fb6c04388b329011a7ca2fc592a283bb 100644 --- a/src/main/java/net/minecraft/world/entity/player/Player.java +++ b/src/main/java/net/minecraft/world/entity/player/Player.java @@ -195,17 +195,40 @@ public abstract class Player extends LivingEntity { @@ -15156,6 +15147,15 @@ index 093d1388ff90ad59110a37536b6639f939549068..845c4af5d5d38d54de4a1b20fe32bf5d public boolean setEntityOnShoulder(CompoundTag entityNbt) { if (!this.isPassenger() && this.onGround() && !this.isInWater() && !this.isInPowderSnow) { if (this.getShoulderEntityLeft().isEmpty()) { +@@ -2312,7 +2368,7 @@ public abstract class Player extends LivingEntity { + } + } + +- return this.abilities.instabuild ? new ItemStack(Items.ARROW) : ItemStack.EMPTY; ++ return this.abilities.instabuild || (level().purpurConfig.infinityWorksWithoutArrows && net.minecraft.world.item.enchantment.EnchantmentHelper.getItemEnchantmentLevel(net.minecraft.world.item.enchantment.Enchantments.INFINITY, stack) > 0) ? new ItemStack(Items.ARROW) : ItemStack.EMPTY; // Purpur + } + } + } @@ -2321,7 +2377,7 @@ public abstract class Player extends LivingEntity { public ItemStack eat(Level world, ItemStack stack) { this.getFoodData().eat(stack); @@ -15318,10 +15318,10 @@ index 2b4d206c0d31ba38d7b2af654bd420e85145d441..1b9d0e28e518c501b4b93ae385ddd64a protected void onHit(HitResult hitResult) { super.onHit(hitResult); diff --git a/src/main/java/net/minecraft/world/entity/projectile/ThrownEnderpearl.java b/src/main/java/net/minecraft/world/entity/projectile/ThrownEnderpearl.java -index 1fb1e729d6879568d8b4943071fa940325b2e5b0..d9761d8fe746e925a7a32dfc15eb8045c6150fe5 100644 +index 519755b7f8bc7e8bb9fab135fc5bf7de3a9419f9..61bd2459f2b9164dce90134103abaddce42b0621 100644 --- a/src/main/java/net/minecraft/world/entity/projectile/ThrownEnderpearl.java +++ b/src/main/java/net/minecraft/world/entity/projectile/ThrownEnderpearl.java -@@ -71,10 +71,11 @@ public class ThrownEnderpearl extends ThrowableItemProjectile { +@@ -70,10 +70,11 @@ public class ThrownEnderpearl extends ThrowableItemProjectile { Bukkit.getPluginManager().callEvent(teleEvent); if (!teleEvent.isCancelled() && entityplayer.connection.isAcceptingMessages()) { @@ -15334,7 +15334,7 @@ index 1fb1e729d6879568d8b4943071fa940325b2e5b0..d9761d8fe746e925a7a32dfc15eb8045 entityendermite.moveTo(entity.getX(), entity.getY(), entity.getZ(), entity.getYRot(), entity.getXRot()); this.level().addFreshEntity(entityendermite, CreatureSpawnEvent.SpawnReason.ENDER_PEARL); } -@@ -86,7 +87,7 @@ public class ThrownEnderpearl extends ThrowableItemProjectile { +@@ -85,7 +86,7 @@ public class ThrownEnderpearl extends ThrowableItemProjectile { entityplayer.connection.teleport(teleEvent.getTo()); entity.resetFallDistance(); @@ -15857,10 +15857,10 @@ index 0dbfd23bbfc6ad203f048142f8c90ef741849fe1..9a80427d2bb470b6b1638e59aba57216 return new ChestMenu(MenuType.GENERIC_9x6, syncId, playerInventory, inventory, 6); } diff --git a/src/main/java/net/minecraft/world/inventory/EnchantmentMenu.java b/src/main/java/net/minecraft/world/inventory/EnchantmentMenu.java -index 5b3e33807e0e13480e3359c0cf067719e5749237..c3a644b0f8c7c5622acc9e1a496f95d432718806 100644 +index 480d093105073edfd3acdd7b079b4ca5aa5fdc6d..6d28f1097caa3e37c2917eb401018ebf48c13a39 100644 --- a/src/main/java/net/minecraft/world/inventory/EnchantmentMenu.java +++ b/src/main/java/net/minecraft/world/inventory/EnchantmentMenu.java -@@ -38,6 +38,12 @@ import org.bukkit.event.enchantment.PrepareItemEnchantEvent; +@@ -39,6 +39,12 @@ import org.bukkit.event.enchantment.PrepareItemEnchantEvent; import org.bukkit.entity.Player; // CraftBukkit end @@ -15873,7 +15873,7 @@ index 5b3e33807e0e13480e3359c0cf067719e5749237..c3a644b0f8c7c5622acc9e1a496f95d4 public class EnchantmentMenu extends AbstractContainerMenu { static final ResourceLocation EMPTY_SLOT_LAPIS_LAZULI = new ResourceLocation("item/empty_slot_lapis_lazuli"); -@@ -72,6 +78,22 @@ public class EnchantmentMenu extends AbstractContainerMenu { +@@ -73,6 +79,22 @@ public class EnchantmentMenu extends AbstractContainerMenu { return context.getLocation(); } // CraftBukkit end @@ -15896,7 +15896,7 @@ index 5b3e33807e0e13480e3359c0cf067719e5749237..c3a644b0f8c7c5622acc9e1a496f95d4 }; this.random = RandomSource.create(); this.enchantmentSeed = DataSlot.standalone(); -@@ -97,6 +119,17 @@ public class EnchantmentMenu extends AbstractContainerMenu { +@@ -98,6 +120,17 @@ public class EnchantmentMenu extends AbstractContainerMenu { } }); @@ -15914,7 +15914,7 @@ index 5b3e33807e0e13480e3359c0cf067719e5749237..c3a644b0f8c7c5622acc9e1a496f95d4 int j; for (j = 0; j < 3; ++j) { -@@ -332,6 +365,7 @@ public class EnchantmentMenu extends AbstractContainerMenu { +@@ -333,6 +366,7 @@ public class EnchantmentMenu extends AbstractContainerMenu { public void removed(net.minecraft.world.entity.player.Player player) { super.removed(player); this.access.execute((world, blockposition) -> { @@ -16128,7 +16128,7 @@ index 786e4a8700cb84b16dd9b8892a0d1d5803924d81..b108ca4c7900ccf6a14ebea01c21c103 // CraftBukkit start Level world = pointer.level(); diff --git a/src/main/java/net/minecraft/world/item/ArmorStandItem.java b/src/main/java/net/minecraft/world/item/ArmorStandItem.java -index 1634a7d5ff06583408cf2f02f2b5f90931b1e02a..dfe8473a880cbddfc3ac6a9c97f1a500624eeb38 100644 +index 1634a7d5ff06583408cf2f02f2b5f90931b1e02a..fd83261f64c6469aebde8ab13a6777b9b269cea2 100644 --- a/src/main/java/net/minecraft/world/item/ArmorStandItem.java +++ b/src/main/java/net/minecraft/world/item/ArmorStandItem.java @@ -58,6 +58,14 @@ public class ArmorStandItem extends Item { @@ -16139,7 +16139,7 @@ index 1634a7d5ff06583408cf2f02f2b5f90931b1e02a..dfe8473a880cbddfc3ac6a9c97f1a500 + if (!world.purpurConfig.persistentDroppableEntityDisplayNames) { + entityarmorstand.setCustomName(null); + } -+ if (world.purpurConfig.armorstandSetNameVisible) { ++ if (world.purpurConfig.armorstandSetNameVisible && entityarmorstand.getCustomName() != null) { + entityarmorstand.setCustomNameVisible(true); + } + // Purpur end @@ -16276,7 +16276,7 @@ index eb74d45ad458b80cf8455297c3bc550186adaea3..ef01856c487e4ab982996e0153761823 return InteractionResultHolder.fail(itemstack); } else { diff --git a/src/main/java/net/minecraft/world/item/BowItem.java b/src/main/java/net/minecraft/world/item/BowItem.java -index 5ca843df5b4caa668953e5e36a9b20fabeb35046..8bca38ec152f9612298bf6b3e10e7e0566ec3b78 100644 +index 5ca843df5b4caa668953e5e36a9b20fabeb35046..ec21d3d00deac4ad51f0a4beec2894675a461618 100644 --- a/src/main/java/net/minecraft/world/item/BowItem.java +++ b/src/main/java/net/minecraft/world/item/BowItem.java @@ -31,7 +31,7 @@ public class BowItem extends ProjectileWeaponItem { @@ -16288,15 +16288,6 @@ index 5ca843df5b4caa668953e5e36a9b20fabeb35046..8bca38ec152f9612298bf6b3e10e7e05 } world.playSound( -@@ -81,7 +81,7 @@ public class BowItem extends ProjectileWeaponItem { - public InteractionResultHolder use(Level world, Player user, InteractionHand hand) { - ItemStack itemStack = user.getItemInHand(hand); - boolean bl = !user.getProjectile(itemStack).isEmpty(); -- if (!user.hasInfiniteMaterials() && !bl) { -+ if (!(world.purpurConfig.infinityWorksWithoutArrows && net.minecraft.world.item.enchantment.EnchantmentHelper.getItemEnchantmentLevel(net.minecraft.world.item.enchantment.Enchantments.INFINITY, itemStack) > 0) && !user.hasInfiniteMaterials() && !bl) { // Purpur - return InteractionResultHolder.fail(itemStack); - } else { - user.startUsingItem(hand); diff --git a/src/main/java/net/minecraft/world/item/BucketItem.java b/src/main/java/net/minecraft/world/item/BucketItem.java index 49557d6f22c5725c663a231deab019d4f6fe95fa..046652e8f9c5dcdf7c90acb9391214cac46bd7d8 100644 --- a/src/main/java/net/minecraft/world/item/BucketItem.java @@ -16951,7 +16942,7 @@ index ea0aee88c7d901034427db201c1b2430f8a1d522..1f28bfb435c1e4d97da713f96c452aba if (range < 0.0 || d < range * range) { return true; diff --git a/src/main/java/net/minecraft/world/level/Explosion.java b/src/main/java/net/minecraft/world/level/Explosion.java -index dc88014c4d9f172cc54e5d77b488128f9ffbc73d..f5e84bf8817e2d53557e0909d8c9e0e0e8206a16 100644 +index 082b804f4793f72e76361f5427f0358273454b3d..133d994d9ac9d4f9527135ac0c77e5749917f8c3 100644 --- a/src/main/java/net/minecraft/world/level/Explosion.java +++ b/src/main/java/net/minecraft/world/level/Explosion.java @@ -98,7 +98,7 @@ public class Explosion { @@ -16983,7 +16974,7 @@ index dc88014c4d9f172cc54e5d77b488128f9ffbc73d..f5e84bf8817e2d53557e0909d8c9e0e0 + }else { + Location location = new Location(this.level.getWorld(), this.x, this.y, this.z); + org.bukkit.block.Block block = location.getBlock(); -+ org.bukkit.block.BlockState blockState = (this.damageSource.blockState != null) ? this.damageSource.blockState : block.getState(); ++ org.bukkit.block.BlockState blockState = (this.damageSource.getDirectBlockState() != null) ? this.damageSource.getDirectBlockState() : block.getState(); + if(!new org.purpurmc.purpur.event.PreBlockExplodeEvent(location.getBlock(), this.blockInteraction == Explosion.BlockInteraction.DESTROY_WITH_DECAY ? 1.0F / this.radius : 1.0F, blockState).callEvent()) { + this.wasCanceled = true; + return; @@ -17291,7 +17282,7 @@ index ce9f189bdafec26360bfadd0f36a8bc2726e132b..d5465b48531fd4b4094874c135274abf return true; } else { diff --git a/src/main/java/net/minecraft/world/level/block/BedBlock.java b/src/main/java/net/minecraft/world/level/block/BedBlock.java -index 4459685d1fb655f93a523ae50b62d6b97785ed90..a4a988ab1399702b943019e9c4e2cde3652b4e85 100644 +index 85d598c3354ee62f0fd1b26e485e0084967c0380..17c994a39a1b99cc7727e328ce7493d534247a21 100644 --- a/src/main/java/net/minecraft/world/level/block/BedBlock.java +++ b/src/main/java/net/minecraft/world/level/block/BedBlock.java @@ -104,7 +104,7 @@ public class BedBlock extends HorizontalDirectionalBlock implements EntityBlock @@ -17307,8 +17298,8 @@ index 4459685d1fb655f93a523ae50b62d6b97785ed90..a4a988ab1399702b943019e9c4e2cde3 Vec3 vec3d = blockposition.getCenter(); -- world.explode((Entity) null, world.damageSources().badRespawnPointExplosion(vec3d, world, iblockdata, blockposition, blockEntity), (ExplosionDamageCalculator) null, vec3d, 5.0F, true, Level.ExplosionInteraction.BLOCK); // CraftBukkit - add state // Paper - add BlockEntity -+ if (world.purpurConfig.bedExplode) world.explode((Entity) null, world.damageSources().badRespawnPointExplosion(vec3d, world, iblockdata, blockposition, blockEntity), (ExplosionDamageCalculator) null, vec3d, (float) world.purpurConfig.bedExplosionPower, world.purpurConfig.bedExplosionFire, world.purpurConfig.bedExplosionEffect); // CraftBukkit - add state // Paper - add BlockEntity // Purpur +- world.explode((Entity) null, world.damageSources().badRespawnPointExplosion(vec3d, blockState), (ExplosionDamageCalculator) null, vec3d, 5.0F, true, Level.ExplosionInteraction.BLOCK); // CraftBukkit - add state ++ if (world.purpurConfig.bedExplode) world.explode((Entity) null, world.damageSources().badRespawnPointExplosion(vec3d, blockState), (ExplosionDamageCalculator) null, vec3d, (float) world.purpurConfig.bedExplosionPower, world.purpurConfig.bedExplosionFire, world.purpurConfig.bedExplosionEffect); // CraftBukkit - add state // Purpur return InteractionResult.SUCCESS; } } @@ -18246,15 +18237,15 @@ index 9603d8c84ff483030dc08e82d3579b89e5c1f6e9..8fc65c32a3c6e6842a76b36f45e1b1c2 } else { int j = pos.getX(); diff --git a/src/main/java/net/minecraft/world/level/block/RespawnAnchorBlock.java b/src/main/java/net/minecraft/world/level/block/RespawnAnchorBlock.java -index 0699211428f182d8d56a2ba019d89ce05c920430..351fb74d2cccd7f63c2efee197a2968f822eda42 100644 +index 94d067e9eeee73183de25165d8c97043fe256103..00b6941951e1af9993f8f6da5425d31b8eaa85e4 100644 --- a/src/main/java/net/minecraft/world/level/block/RespawnAnchorBlock.java +++ b/src/main/java/net/minecraft/world/level/block/RespawnAnchorBlock.java -@@ -149,7 +149,7 @@ public class RespawnAnchorBlock extends Block { +@@ -150,7 +150,7 @@ public class RespawnAnchorBlock extends Block { }; Vec3 vec3d = explodedPos.getCenter(); -- world.explode((Entity) null, world.damageSources().badRespawnPointExplosion(vec3d, world, state, explodedPos, null), explosiondamagecalculator, vec3d, 5.0F, true, Level.ExplosionInteraction.BLOCK); // CraftBukkit - add state // Paper -+ if (world.purpurConfig.respawnAnchorExplode) world.explode((Entity) null, world.damageSources().badRespawnPointExplosion(vec3d, world, state, explodedPos, null), explosiondamagecalculator, vec3d, (float) world.purpurConfig.respawnAnchorExplosionPower, world.purpurConfig.respawnAnchorExplosionFire, world.purpurConfig.respawnAnchorExplosionEffect); // CraftBukkit - add state // Paper // Purpur +- world.explode((Entity) null, world.damageSources().badRespawnPointExplosion(vec3d, blockState), explosiondamagecalculator, vec3d, 5.0F, true, Level.ExplosionInteraction.BLOCK); // CraftBukkit - add state ++ if (world.purpurConfig.respawnAnchorExplode) world.explode((Entity) null, world.damageSources().badRespawnPointExplosion(vec3d, blockState), explosiondamagecalculator, vec3d, (float) world.purpurConfig.respawnAnchorExplosionPower, world.purpurConfig.respawnAnchorExplosionFire, world.purpurConfig.respawnAnchorExplosionEffect); // CraftBukkit - add state // Purpur } public static boolean canSetSpawn(Level world) { @@ -19692,10 +19683,10 @@ index 9d93130f23addb18b97d7f5ec013faef17a74529..29d2fb87a65778926aea2cfc7a5b486c + // Purpur end - OfflinePlayer API } diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -index 57db399bc1d3b6b015740b059987bc8d9bcc3101..19937ffa2c93cb75ea8dba58dd5a8214adc035fa 100644 +index da1aed63af837b193900bb85393611edbd56c363..b82c66c402823874e3a5fc9bb7b1df73c708aec5 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -@@ -268,7 +268,7 @@ import javax.annotation.Nullable; // Paper +@@ -269,7 +269,7 @@ import javax.annotation.Nullable; // Paper import javax.annotation.Nonnull; // Paper public final class CraftServer implements Server { @@ -19704,10 +19695,10 @@ index 57db399bc1d3b6b015740b059987bc8d9bcc3101..19937ffa2c93cb75ea8dba58dd5a8214 private final String serverVersion; private final String bukkitVersion = Versioning.getBukkitVersion(); private final Logger logger = Logger.getLogger("Minecraft"); -@@ -403,6 +403,20 @@ public final class CraftServer implements Server { - this.serverTickManager = new CraftServerTickManager(console.tickRateManager()); - - Bukkit.setServer(this); +@@ -410,6 +410,20 @@ public final class CraftServer implements Server { + this.paperPluginManager = new io.papermc.paper.plugin.manager.PaperPluginManagerImpl(this, this.commandMap, pluginManager); + this.pluginManager.paperPluginManager = this.paperPluginManager; + // Paper end + // Purpur start + org.purpurmc.purpur.language.Language.setLanguage(new org.purpurmc.purpur.language.Language() { + private net.minecraft.locale.Language language = net.minecraft.locale.Language.getInstance(); @@ -19725,7 +19716,7 @@ index 57db399bc1d3b6b015740b059987bc8d9bcc3101..19937ffa2c93cb75ea8dba58dd5a8214 CraftRegistry.setMinecraftRegistry(console.registryAccess()); -@@ -1054,6 +1068,7 @@ public final class CraftServer implements Server { +@@ -1038,6 +1052,7 @@ public final class CraftServer implements Server { org.spigotmc.SpigotConfig.init((File) this.console.options.valueOf("spigot-settings")); // Spigot this.console.paperConfigurations.reloadConfigs(this.console); @@ -19733,7 +19724,7 @@ index 57db399bc1d3b6b015740b059987bc8d9bcc3101..19937ffa2c93cb75ea8dba58dd5a8214 for (ServerLevel world : this.console.getAllLevels()) { // world.serverLevelData.setDifficulty(config.difficulty); // Paper - per level difficulty world.setSpawnSettings(world.serverLevelData.getDifficulty() != Difficulty.PEACEFUL && config.spawnMonsters, config.spawnAnimals); // Paper - per level difficulty (from MinecraftServer#setDifficulty(ServerLevel, Difficulty, boolean)) -@@ -1069,6 +1084,7 @@ public final class CraftServer implements Server { +@@ -1053,6 +1068,7 @@ public final class CraftServer implements Server { } } world.spigotConfig.init(); // Spigot @@ -19741,7 +19732,7 @@ index 57db399bc1d3b6b015740b059987bc8d9bcc3101..19937ffa2c93cb75ea8dba58dd5a8214 } Plugin[] pluginClone = pluginManager.getPlugins().clone(); // Paper -@@ -1084,6 +1100,7 @@ public final class CraftServer implements Server { +@@ -1069,6 +1085,7 @@ public final class CraftServer implements Server { this.reloadData(); org.spigotmc.SpigotConfig.registerCommands(); // Spigot io.papermc.paper.command.PaperCommands.registerCommands(this.console); // Paper @@ -19749,7 +19740,7 @@ index 57db399bc1d3b6b015740b059987bc8d9bcc3101..19937ffa2c93cb75ea8dba58dd5a8214 this.overrideAllCommandBlockCommands = this.commandsConfiguration.getStringList("command-block-overrides").contains("*"); this.ignoreVanillaPermissions = this.commandsConfiguration.getBoolean("ignore-vanilla-permissions"); -@@ -1586,6 +1603,55 @@ public final class CraftServer implements Server { +@@ -1577,6 +1594,55 @@ public final class CraftServer implements Server { return true; } @@ -19805,7 +19796,7 @@ index 57db399bc1d3b6b015740b059987bc8d9bcc3101..19937ffa2c93cb75ea8dba58dd5a8214 @Override public List getRecipesFor(ItemStack result) { Preconditions.checkArgument(result != null, "ItemStack cannot be null"); -@@ -3048,6 +3114,18 @@ public final class CraftServer implements Server { +@@ -3039,6 +3105,18 @@ public final class CraftServer implements Server { return CraftServer.this.console.paperConfigurations.createLegacyObject(CraftServer.this.console); } @@ -19824,7 +19815,7 @@ index 57db399bc1d3b6b015740b059987bc8d9bcc3101..19937ffa2c93cb75ea8dba58dd5a8214 @Override public void restart() { org.spigotmc.RestartCommand.restart(); -@@ -3077,6 +3155,7 @@ public final class CraftServer implements Server { +@@ -3068,6 +3146,7 @@ public final class CraftServer implements Server { @Override public double[] getTPS() { return new double[] { @@ -19832,7 +19823,7 @@ index 57db399bc1d3b6b015740b059987bc8d9bcc3101..19937ffa2c93cb75ea8dba58dd5a8214 net.minecraft.server.MinecraftServer.getServer().tps1.getAverage(), net.minecraft.server.MinecraftServer.getServer().tps5.getAverage(), net.minecraft.server.MinecraftServer.getServer().tps15.getAverage() -@@ -3278,4 +3357,16 @@ public final class CraftServer implements Server { +@@ -3269,4 +3348,16 @@ public final class CraftServer implements Server { return this.potionBrewer; } // Paper end @@ -20266,7 +20257,7 @@ index aa351df679f300018367244c7ccb3e5a59e9276f..b452ebbe11145987fb5e66b399938984 + // Purpur end } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLlama.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLlama.java -index 0ad16ee7b33582d214dab41eeee378d52c8e38ed..16bd1294c219f15ada653ef810bc2d748222d0da 100644 +index 351f42842b780d053cd2e5bad9ae299449141b10..4860574e7fad7a9527dda599703c573c5b4b234b 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLlama.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLlama.java @@ -90,4 +90,16 @@ public class CraftLlama extends CraftChestedHorse implements Llama, com.destroys @@ -20287,7 +20278,7 @@ index 0ad16ee7b33582d214dab41eeee378d52c8e38ed..16bd1294c219f15ada653ef810bc2d74 + // Purpur end } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java -index 5f896948d158651cd9837364759dbfbcce6b7d21..88948526f9acf4bb2157484b80891902fd843b02 100644 +index 561a7a8e96e2d91bbb87fe6230e94b5f38073d27..2c9726d0f2dec1136a2f45768e8f8169ce165a1d 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java @@ -574,10 +574,15 @@ public class CraftPlayer extends CraftHumanEntity implements Player { @@ -20318,7 +20309,7 @@ index 5f896948d158651cd9837364759dbfbcce6b7d21..88948526f9acf4bb2157484b80891902 return false; } -@@ -2736,6 +2745,28 @@ public class CraftPlayer extends CraftHumanEntity implements Player { +@@ -2733,6 +2742,28 @@ public class CraftPlayer extends CraftHumanEntity implements Player { return this.getHandle().getAbilities().walkingSpeed * 2f; } @@ -20347,7 +20338,7 @@ index 5f896948d158651cd9837364759dbfbcce6b7d21..88948526f9acf4bb2157484b80891902 private void validateSpeed(float value) { Preconditions.checkArgument(value <= 1f && value >= -1f, "Speed value (%s) need to be between -1f and 1f", value); } -@@ -3522,4 +3553,70 @@ public class CraftPlayer extends CraftHumanEntity implements Player { +@@ -3519,4 +3550,70 @@ public class CraftPlayer extends CraftHumanEntity implements Player { public void setSendViewDistance(final int viewDistance) { this.getHandle().setSendViewDistance(viewDistance); } @@ -20500,7 +20491,7 @@ index 86574da257731de7646a712ed73384955fe35aa3..e223234dd64b0e41441c3b9f649f0b64 + // Purpur end } diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java -index 547ab158cd0cbf51da06ea97740cfce34bca651b..6fed586c9a778f7a57e1b4ca2e6f2dbc15c8769d 100644 +index 34b91eff3190848bae38b20e1d956ece497b1473..e650b85464ac886b4adb1a8924026d34f805aba6 100644 --- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java +++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java @@ -592,6 +592,15 @@ public class CraftEventFactory { @@ -20519,8 +20510,8 @@ index 547ab158cd0cbf51da06ea97740cfce34bca651b..6fed586c9a778f7a57e1b4ca2e6f2dbc return event; } -@@ -1121,7 +1130,7 @@ public class CraftEventFactory { - return CraftEventFactory.callEntityDamageEvent(source.getDirectBlock(), entity, DamageCause.LAVA, bukkitDamageSource, modifiers, modifierFunctions, cancelled); +@@ -1123,7 +1132,7 @@ public class CraftEventFactory { + return CraftEventFactory.callEntityDamageEvent(source.getDirectBlock(), source.getDirectBlockState(), entity, DamageCause.LAVA, bukkitDamageSource, modifiers, modifierFunctions, cancelled); } else if (source.getDirectBlock() != null) { DamageCause cause; - if (source.is(DamageTypes.CACTUS) || source.is(DamageTypes.SWEET_BERRY_BUSH) || source.is(DamageTypes.STALAGMITE) || source.is(DamageTypes.FALLING_STALACTITE) || source.is(DamageTypes.FALLING_ANVIL)) { @@ -20528,7 +20519,7 @@ index 547ab158cd0cbf51da06ea97740cfce34bca651b..6fed586c9a778f7a57e1b4ca2e6f2dbc cause = DamageCause.CONTACT; } else if (source.is(DamageTypes.HOT_FLOOR)) { cause = DamageCause.HOT_FLOOR; -@@ -1179,6 +1188,7 @@ public class CraftEventFactory { +@@ -1181,6 +1190,7 @@ public class CraftEventFactory { EntityDamageEvent event; if (damager != null) { event = new EntityDamageByEntityEvent(damager.getBukkitEntity(), damagee.getBukkitEntity(), cause, bukkitDamageSource, modifiers, modifierFunctions, critical); @@ -20627,7 +20618,7 @@ index 6ba29875d78ede4aa7978ff689e588f7fed11528..4afec4387971612f62b825e9e56c2ead throw new IllegalArgumentException("Unknown recipe stack instance " + bukkit); } diff --git a/src/main/java/org/bukkit/craftbukkit/legacy/CraftLegacy.java b/src/main/java/org/bukkit/craftbukkit/legacy/CraftLegacy.java -index 71d057dc8c7362f8e7aaca5e31c9f02b2bf3f281..9d9405af0db28c0f3ffff2881b54f1dc84675a9d 100644 +index ae6d9453cbfb708ed00a61a221bd425110b291a4..9dba941b28e1f9d9b6f8d106cf8f6adcd5a436be 100644 --- a/src/main/java/org/bukkit/craftbukkit/legacy/CraftLegacy.java +++ b/src/main/java/org/bukkit/craftbukkit/legacy/CraftLegacy.java @@ -256,6 +256,7 @@ public final class CraftLegacy { @@ -20740,10 +20731,10 @@ index b3e1adeb932da9b3bed16acd94e2f16da48a7c72..d3ec817e95628f1fc8be4a29c9a0f13c // Paper end - add timings for scoreboard search } diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java -index a1c9989df460d7ae3666fffe7968750832a30b85..ad7f21566271260270db452e2f15c32f8a829d28 100644 +index 5a382907285a288f2a223189e690d3dbdf45594c..3daf674f1e0de3fdd89db5536cc1e34140a5abb8 100644 --- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java +++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java -@@ -507,7 +507,7 @@ public final class CraftMagicNumbers implements UnsafeValues { +@@ -511,7 +511,7 @@ public final class CraftMagicNumbers implements UnsafeValues { @Override public com.destroystokyo.paper.util.VersionFetcher getVersionFetcher() { @@ -21395,7 +21386,7 @@ index 0000000000000000000000000000000000000000..de70bfdbdd7740fdf20dd063a7a623a9 +} diff --git a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java new file mode 100644 -index 0000000000000000000000000000000000000000..d8de8710d9b8cf2ae5c434b2b0b27e76ffbbe4bf +index 0000000000000000000000000000000000000000..6717941d18dbd6871b4613106b9787063e11722f --- /dev/null +++ b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java @@ -0,0 +1,3306 @@ @@ -21498,7 +21489,7 @@ index 0000000000000000000000000000000000000000..d8de8710d9b8cf2ae5c434b2b0b27e76 + } + + public float armorstandStepHeight = 0.0F; -+ public boolean armorstandSetNameVisible = true; ++ public boolean armorstandSetNameVisible = false; + public boolean armorstandFixNametags = false; + public boolean armorstandMovement = true; + public boolean armorstandWaterMovement = true; diff --git a/patches/server/0002-Use-Gradle-Version-Catalogs.patch b/patches/server/0002-Use-Gradle-Version-Catalogs.patch index 0f8eb5824..e21d3f241 100644 --- a/patches/server/0002-Use-Gradle-Version-Catalogs.patch +++ b/patches/server/0002-Use-Gradle-Version-Catalogs.patch @@ -5,17 +5,17 @@ Subject: [PATCH] Use Gradle Version Catalogs diff --git a/build.gradle.kts b/build.gradle.kts -index 81996f00384674b29368e8bea944bdd14d631da3..feaff0406fa47ffb265ce316b057fb52aa367870 100644 +index 89f21e21efc5f5ab99d1586f4f3b8f2f3c48ac06..ec151f06541d7c3b4ffb1cac75e94bf3914dacaf 100644 --- a/build.gradle.kts +++ b/build.gradle.kts -@@ -18,57 +18,27 @@ dependencies { - exclude("io.papermc.paper", "paper-api") - } - // Purpur end +@@ -13,57 +13,26 @@ val alsoShade: Configuration by configurations.creating + + dependencies { + implementation(project(":purpur-api")) // Purpur - // Paper start - implementation("org.jline:jline-terminal-jansi:3.21.0") - implementation("net.minecrell:terminalconsoleappender:1.3.0") -- implementation("net.kyori:adventure-text-serializer-ansi:4.16.0") // Keep in sync with adventureVersion from Paper-API build file +- implementation("net.kyori:adventure-text-serializer-ansi:4.17.0") // Keep in sync with adventureVersion from Paper-API build file - /* - Required to add the missing Log4j2Plugins.dat file from log4j-core - which has been removed by Mojang. Without it, log4j has to classload @@ -24,22 +24,8 @@ index 81996f00384674b29368e8bea944bdd14d631da3..feaff0406fa47ffb265ce316b057fb52 - */ - implementation("org.apache.logging.log4j:log4j-core:2.19.0") // Paper - implementation - log4jPlugins.annotationProcessorConfigurationName("org.apache.logging.log4j:log4j-core:2.19.0") // Paper - Needed to generate meta for our Log4j plugins -+ -+ // Plazma start - Use Gradle Version Catalogs -+ implementation(server.bundles.implementation) -+ implementation(common.asm.commons) -+ implementation(common.log4j.iostreams) -+ implementation(common.commons.lang2) -+ implementation(server.velocity) { isTransitive = false } -+ -+ runtimeOnly(common.maven.provider) -+ runtimeOnly(common.bundles.maven) -+ runtimeOnly(server.bundles.runtime) -+ -+ implementation(common.log4j.core) // Paper - implementation -+ log4jPlugins.annotationProcessorConfigurationName(common.log4j.core) // Paper - Needed to generate meta for our Log4j plugins - runtimeOnly(log4jPlugins.output) - alsoShade(log4jPlugins.output) +- runtimeOnly(log4jPlugins.output) +- alsoShade(log4jPlugins.output) - implementation("io.netty:netty-codec-haproxy:4.1.97.Final") // Paper - Add support for proxy protocol - // Paper end - implementation("org.apache.logging.log4j:log4j-iostreams:2.22.1") // Paper - remove exclusion @@ -77,6 +63,21 @@ index 81996f00384674b29368e8bea944bdd14d631da3..feaff0406fa47ffb265ce316b057fb52 - implementation("io.papermc:reflection-rewriter-runtime:$reflectionRewriterVersion") - implementation("io.papermc:reflection-rewriter-proxy-generator:$reflectionRewriterVersion") - // Paper end - Remap reflection ++ // Plazma start - Use Gradle Version Catalogs ++ implementation(server.bundles.implementation) ++ implementation(common.asm.commons) ++ implementation(common.log4j.iostreams) ++ implementation(common.commons.lang2) ++ implementation(server.velocity) { isTransitive = false } ++ ++ runtimeOnly(common.maven.provider) ++ runtimeOnly(common.bundles.maven) ++ runtimeOnly(server.bundles.runtime) ++ ++ implementation(common.log4j.core) // Paper - implementation ++ log4jPlugins.annotationProcessorConfigurationName(common.log4j.core) // Paper - Needed to generate meta for our Log4j plugins ++ runtimeOnly(log4jPlugins.output) // Plazma - diff on patch ++ alsoShade(log4jPlugins.output) // Plazma - diff on patch + + testImplementation(server.bundles.test) + testImplementation(common.bundles.test) diff --git a/patches/server/0003-Rebrand.patch b/patches/server/0003-Rebrand.patch index db96353e6..87c34a523 100644 --- a/patches/server/0003-Rebrand.patch +++ b/patches/server/0003-Rebrand.patch @@ -4,33 +4,52 @@ Date: Wed, 21 Dec 2022 19:31:24 +0900 Subject: [PATCH] Rebrand +diff --git a/MIT.txt b/MIT.txt +new file mode 100644 +index 0000000000000000000000000000000000000000..67d405764ed68083d0164b1af0eabc0af7f6efea +--- /dev/null ++++ b/MIT.txt +@@ -0,0 +1,21 @@ ++The MIT License (MIT) ++ ++Copyright (c) 2024 Paper Contributors ++ ++Permission is hereby granted, free of charge, to any person obtaining ++a copy of this software and associated documentation files (the "Software"), ++to deal in the Software without restriction, including without limitation ++the rights to use, copy, modify, merge, publish, distribute, sublicense, ++and/or sell copies of the Software, and to permit persons to whom ++the Software is furnished to do so, subject to the following conditions: ++ ++The above copyright notice and this permission notice shall be included ++in all copies or substantial portions of the Software. ++ ++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, ++EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE ++WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE ++AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS ++BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN ++AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF ++OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/build.gradle.kts b/build.gradle.kts -index feaff0406fa47ffb265ce316b057fb52aa367870..279e1cfd24f29d3ac55e74759d8b542a7520de3d 100644 +index ec151f06541d7c3b4ffb1cac75e94bf3914dacaf..3cf30564db4e5cb2eeb09258940d0b2b5f9b0edc 100644 --- a/build.gradle.kts +++ b/build.gradle.kts -@@ -12,12 +12,10 @@ configurations.named(log4jPlugins.compileClasspathConfigurationName) { +@@ -12,7 +12,7 @@ configurations.named(log4jPlugins.compileClasspathConfigurationName) { val alsoShade: Configuration by configurations.creating dependencies { -- // Purpur start -- implementation(project(":purpur-api")) -- implementation("io.papermc.paper:paper-mojangapi:${project.version}") { -- exclude("io.papermc.paper", "paper-api") -- } -- // Purpur end -+ // Plazma start - Rebrand -+ implementation(project(":${parent!!.property("projectName").toString().lowercase()}-api")) -+ implementation(project(":${parent!!.property("projectName").toString().lowercase()}-mojangapi")) -+ // Plazma end - +- implementation(project(":purpur-api")) // Purpur ++ implementation(project(":${parent!!.property("projectName").toString().lowercase()}-api")) // Plazma - Rebrand // Plazma start - Use Gradle Version Catalogs implementation(server.bundles.implementation) -@@ -57,7 +55,7 @@ tasks.jar { + implementation(common.asm.commons) +@@ -51,7 +51,7 @@ tasks.jar { attributes( "Main-Class" to "org.bukkit.craftbukkit.Main", "Implementation-Title" to "CraftBukkit", - "Implementation-Version" to "git-Purpur-$implementationVersion", // Pufferfish // Purpur -+ "Implementation-Version" to "git-${parent!!.property("projectName")}-$implementationVersion", // Pufferfish // Purpur // Plazma - Setup Gradle Project ++ "Implementation-Version" to "git-${parent!!.property("projectName")}-$implementationVersion", // Pufferfish // Purpur // Plazma - Rebrand "Implementation-Vendor" to date, // Paper "Specification-Title" to "Bukkit", "Specification-Version" to project.version, @@ -225,10 +244,10 @@ index 411f1f8c6be072cfc5ba88cbec38dbc4300a41d1..0fb3eeab083a0b1e9b495bd2c5c556fc Main.LOGGER.error(awtException); return; diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index 21327a92b75a460c7beb3aa408502f37a7db31fa..6d549448e67a110a42dde6f8eeaab1f0033f3462 100644 +index dfe3d28bd97d1335457d1005ecf69afe75d5ff80..dc571ad9882a6c35e25b20086da1f2c51d3b4b57 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java -@@ -496,8 +496,8 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop S spin(Function serverFactory) { AtomicReference atomicreference = new AtomicReference(); -@@ -1741,17 +1742,15 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop> consumer, Set trackedPlayers) { this.trackedPlayers = trackedPlayers; -@@ -208,12 +209,16 @@ public class ServerEntity { +@@ -215,12 +216,15 @@ public class ServerEntity { if ((this.trackDelta || this.entity.hasImpulse || this.entity instanceof LivingEntity && ((LivingEntity) this.entity).isFallFlying()) && this.tickCount > 0) { Vec3 vec3d1 = this.entity.getDeltaMovement(); - double d0 = vec3d1.distanceToSqr(this.ap); -+ // Plazma start - SparklyPaper port; Skip distanceToSqr if the delta movement hasn't changed -+ if (!skipSqrWhenNoDeltaChanges && vec3d1 != this.ap) { -+ double d0 = vec3d1.distanceToSqr(this.ap); - +- - if (d0 > 1.0E-7D || d0 > 0.0D && vec3d1.lengthSqr() == 0.0D) { - this.ap = vec3d1; - this.broadcast.accept(new ClientboundSetEntityMotionPacket(this.entity.getId(), this.ap)); ++ // Plazma start - SparklyPaper port; Skip distanceToSqr if the delta movement hasn't changed ++ if (!skipSqrWhenNoDeltaChanges && vec3d1 != this.ap) { ++ double d0 = vec3d1.distanceToSqr(this.ap); + if (d0 > 1.0E-7D || d0 > 0.0D && vec3d1.lengthSqr() == 0.0D) { + this.ap = vec3d1; + this.broadcast.accept(new ClientboundSetEntityMotionPacket(this.entity.getId(), this.ap)); @@ -263,7 +263,7 @@ index 39e7dcf3c92c9203c190782be401c00c010b8aeb..b86ae3929ec5d3c4eb69d92774dc445a if (packet1 != null) { diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java -index aef5d7562e1636e85382ed60b694a9a0d5dccd9d..dc8cb0e9c8abdbefb0420599a243b1a4fe66bb05 100644 +index 5df20b97f3c88248ab70e7686b5fa0ca8e5a58c2..d1b2e68a702ce01c33cfe0e1297a8809e3acf088 100644 --- a/src/main/java/net/minecraft/server/level/ServerLevel.java +++ b/src/main/java/net/minecraft/server/level/ServerLevel.java @@ -233,6 +233,12 @@ public class ServerLevel extends Level implements WorldGenLevel { @@ -826,7 +826,7 @@ index 0000000000000000000000000000000000000000..f8c26e26025d7a7b5489ed5b3274ba73 + +} diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java -index 88948526f9acf4bb2157484b80891902fd843b02..20acef32cabdb8f860088341248fe9960f04fbfd 100644 +index 2c9726d0f2dec1136a2f45768e8f8169ce165a1d..4f199eea0c8a05f94e8443917c5a6f2c42f0b25e 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java @@ -976,7 +976,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { @@ -838,19 +838,23 @@ index 88948526f9acf4bb2157484b80891902fd843b02..20acef32cabdb8f860088341248fe996 for (Map.Entry entry : blockChanges.entrySet()) { BlockData blockData = entry.getValue(); -@@ -2240,6 +2240,12 @@ public class CraftPlayer extends CraftHumanEntity implements Player { - return this.equals(entity) || entity.isVisibleByDefault() ^ this.invertedVisibilityEntities.containsKey(entity.getUniqueId()); // SPIGOT-7312: Can always see self +@@ -2237,9 +2237,15 @@ public class CraftPlayer extends CraftHumanEntity implements Player { + + @Override + public boolean canSee(org.bukkit.entity.Entity entity) { +- return this.equals(entity) || entity.isVisibleByDefault() ^ this.invertedVisibilityEntities.containsKey(entity.getUniqueId()); // SPIGOT-7312: Can always see self ++ return this.equals(entity) || this.chunkMapCanSee(entity); // SPIGOT-7312: Can always see self // Plazma - Port SparklyPaper patches; Optimize canSee check } -+ // Plazma start - Port SparklyPaper patches; Optimize canSee check -+ public boolean canSeeChunkMapUpdatePlauer(org.bukkit.entity.Entity entity) { ++ // Plazma start - Port SparklyPaper patches; Optimize canSee check (The check in ChunkMap#updatePlayer already rejects if it is the same entity, so we don't need to check it twice, especially because CraftPlayer's equals check is a bit expensive) ++ public boolean chunkMapCanSee(org.bukkit.entity.Entity entity) { + return entity.isVisibleByDefault() ^ (!invertedVisibilityEntities.isEmpty() && this.invertedVisibilityEntities.containsKey(entity.getUniqueId())); + } + // Plazma end - Port SparklyPaper patches; Optimize canSee check + - public boolean canSee(UUID uuid) { + public boolean canSeePlayer(UUID uuid) { org.bukkit.entity.Entity entity = this.getServer().getPlayer(uuid); - if (entity == null) { + diff --git a/src/main/java/org/bukkit/craftbukkit/map/CraftMapColorCache.java b/src/main/java/org/bukkit/craftbukkit/map/CraftMapColorCache.java index 8149b9c51b78eb5c689b7218a2ca3aab60e73bcf..b9a303f6280a2f6ad3616da152922a4f4a504281 100644 --- a/src/main/java/org/bukkit/craftbukkit/map/CraftMapColorCache.java diff --git a/patches/server/0012-Optimize-default-configurations.patch b/patches/server/0012-Optimize-default-configurations.patch index c4e6f32c6..02e647536 100644 --- a/patches/server/0012-Optimize-default-configurations.patch +++ b/patches/server/0012-Optimize-default-configurations.patch @@ -324,10 +324,10 @@ index 55e16ed1151c5d53f492581f66a3406ac418b653..9af7df196ed74a48a6b6426df36353f9 this.enableJmxMonitoring = this.get("enable-jmx-monitoring", false); this.enableStatus = this.get("enable-status", true); diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -index 26e93a0c346204ccccf8255d0f87da03e943bcfb..d53be3e57e97cf9806b04f6d6bdd6a3a9fdb299b 100644 +index 841ce275ff3f49783a61af71d83020b8cda35473..509c7536b84019c854163471cb9d42b969747366 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -@@ -426,7 +426,7 @@ public final class CraftServer implements Server { +@@ -433,7 +433,7 @@ public final class CraftServer implements Server { this.configuration = YamlConfiguration.loadConfiguration(this.getConfigFile()); this.configuration.options().copyDefaults(true); @@ -398,7 +398,7 @@ index 85f4a9300aebfd4ee64d179dfa1f7ffd314cb3b8..fa209964eec7dae8e2a0fa7bb44e0e87 private static void networkSettings() { useUPnP = getBoolean("settings.network.upnp-port-forwarding", useUPnP); diff --git a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java -index d8de8710d9b8cf2ae5c434b2b0b27e76ffbbe4bf..72dc81d3015dc7c6365997de9abc269b261649b1 100644 +index 6717941d18dbd6871b4613106b9787063e11722f..b6a6a74dfd00a4536258c8693048c9d1ac4df435 100644 --- a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java +++ b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java @@ -433,7 +433,7 @@ public class PurpurWorldConfig { diff --git a/patches/server/0013-Tweak-console-logging.patch b/patches/server/0013-Tweak-console-logging.patch index fafc99d8c..c4fc70d20 100644 --- a/patches/server/0013-Tweak-console-logging.patch +++ b/patches/server/0013-Tweak-console-logging.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Tweak console logging diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java -index f661418d27f5692a51b880f64180866f7d19d66a..ddfbc49a693d3100e915f5083f1f8e99df2d4b64 100644 +index ca1e8da7540457ecba5684acd42129509c8204f5..9af4efcf9a2c8dee2208ddf37b1bb963a2894666 100644 --- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java +++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java @@ -193,16 +193,6 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface @@ -43,7 +43,7 @@ index f661418d27f5692a51b880f64180866f7d19d66a..ddfbc49a693d3100e915f5083f1f8e99 // Paper start - fix converting txt to json file; convert old users earlier after PlayerList creation but before file load/save if (this.convertOldUsers()) { this.getProfileCache().save(false); // Paper -@@ -331,6 +332,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface +@@ -330,6 +331,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface String proxyFlavor = (io.papermc.paper.configuration.GlobalConfiguration.get().proxies.velocity.enabled) ? "Velocity" : "BungeeCord"; String proxyLink = (io.papermc.paper.configuration.GlobalConfiguration.get().proxies.velocity.enabled) ? "https://docs.papermc.io/velocity/security" : "http://www.spigotmc.org/wiki/firewall-guide/"; // Paper end - Add Velocity IP Forwarding Support @@ -51,7 +51,7 @@ index f661418d27f5692a51b880f64180866f7d19d66a..ddfbc49a693d3100e915f5083f1f8e99 if (!this.usesAuthentication()) { DedicatedServer.LOGGER.warn("**** SERVER IS RUNNING IN OFFLINE/INSECURE MODE!"); DedicatedServer.LOGGER.warn("The server will make no attempt to authenticate usernames. Beware."); -@@ -344,7 +346,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface +@@ -343,7 +345,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface DedicatedServer.LOGGER.warn("While this makes the game possible to play without internet access, it also opens up the ability for hackers to connect with any username they choose."); } // Spigot end diff --git a/patches/server/0015-Completely-remove-Mojang-Profiler.patch b/patches/server/0015-Completely-remove-Mojang-Profiler.patch index 54d2f83a5..075f6248f 100644 --- a/patches/server/0015-Completely-remove-Mojang-Profiler.patch +++ b/patches/server/0015-Completely-remove-Mojang-Profiler.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Completely remove Mojang Profiler diff --git a/src/main/java/net/minecraft/commands/Commands.java b/src/main/java/net/minecraft/commands/Commands.java -index f9d0e8ee9414b3897f268ba78a1469ddf868f51a..58d89000af36f72d629d8e0873d6efbbbb720fe1 100644 +index 55b29e9a540cfc00dc32c7ae14d603c150e8863d..4f1976333662662bc6aa844bde9667b8c9a0b159 100644 --- a/src/main/java/net/minecraft/commands/Commands.java +++ b/src/main/java/net/minecraft/commands/Commands.java -@@ -429,7 +429,7 @@ public class Commands { +@@ -442,7 +442,7 @@ public class Commands { int j = minecraftserver.getGameRules().getInt(GameRules.RULE_MAX_COMMAND_FORK_COUNT); try { @@ -65,7 +65,7 @@ index f626a2f28f2aebb3237cebb6afef3c4fa1a6cb37..467e17bfce31d0919d603698c9d88a04 public int forkLimit() { return this.forkLimit; diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index eb4c8b516be77423c7decb247f261a264b1cfc89..da5275e9137023b39f7a0a20255e483b61a5237f 100644 +index 9d5257f810f9f88504b913fa0c7c214acc1da2cb..e0f50dcfe30abf439cea3ecd7837569802bd16c8 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java @@ -104,18 +104,18 @@ import net.minecraft.util.datafix.DataFixers; @@ -120,7 +120,7 @@ index eb4c8b516be77423c7decb247f261a264b1cfc89..da5275e9137023b39f7a0a20255e483b private ServerConnectionListener connection; public final ChunkProgressListenerFactory progressListenerFactory; @Nullable -@@ -2594,10 +2594,12 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop { -@@ -2867,12 +2870,12 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop resultConsumer, Consumer dumpConsumer) { @@ -156,7 +156,7 @@ index eb4c8b516be77423c7decb247f261a264b1cfc89..da5275e9137023b39f7a0a20255e483b } public void stopRecordingMetrics() { -@@ -2887,6 +2890,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop 0) { -@@ -288,6 +290,19 @@ public class ServerEntity { +@@ -295,6 +297,19 @@ public class ServerEntity { }); } @@ -40,7 +40,7 @@ index b86ae3929ec5d3c4eb69d92774dc445aa5b3093e..44e4a768a0ccde83cae5547c7ba07744 this.entity.stopSeenByPlayer(player); player.connection.send(new ClientboundRemoveEntitiesPacket(new int[]{this.entity.getId()})); diff --git a/src/main/java/org/plazmamc/plazma/configurations/WorldConfigurations.java b/src/main/java/org/plazmamc/plazma/configurations/WorldConfigurations.java -index 922d1d250f2e2e5a4177bcf5fe7487ff2b43413b..c8a3e91d0d6510b519e927027f5a534cddf7d0a3 100644 +index b83a1058484e3d4d46f91d659f795f59d7087b72..9debf554deb5b7aa021502ff7d600905f56fa25c 100644 --- a/src/main/java/org/plazmamc/plazma/configurations/WorldConfigurations.java +++ b/src/main/java/org/plazmamc/plazma/configurations/WorldConfigurations.java @@ -29,6 +29,8 @@ public class WorldConfigurations extends ConfigurationPart { diff --git a/patches/server/0027-Suppress-errors-from-dirty-attributes.patch b/patches/server/0027-Suppress-errors-from-dirty-attributes.patch index 19d252f34..25bf7c6a6 100644 --- a/patches/server/0027-Suppress-errors-from-dirty-attributes.patch +++ b/patches/server/0027-Suppress-errors-from-dirty-attributes.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Suppress errors from dirty attributes diff --git a/src/main/java/net/minecraft/server/level/ServerEntity.java b/src/main/java/net/minecraft/server/level/ServerEntity.java -index 44e4a768a0ccde83cae5547c7ba07744cec4c693..7954be9d04d88444601144bab560701c04274aa7 100644 +index 9fe8dcea8f5075a5420a4355bb3c27c2311d8f94..acf1cb25f75b35e064e7099d85693632073df858 100644 --- a/src/main/java/net/minecraft/server/level/ServerEntity.java +++ b/src/main/java/net/minecraft/server/level/ServerEntity.java -@@ -406,7 +406,8 @@ public class ServerEntity { +@@ -413,7 +413,8 @@ public class ServerEntity { } if (this.entity instanceof LivingEntity) { @@ -18,7 +18,7 @@ index 44e4a768a0ccde83cae5547c7ba07744cec4c693..7954be9d04d88444601144bab560701c if (!set.isEmpty()) { // CraftBukkit start - Send scaled max health -@@ -417,7 +418,7 @@ public class ServerEntity { +@@ -424,7 +425,7 @@ public class ServerEntity { this.broadcastAndSend(new ClientboundUpdateAttributesPacket(this.entity.getId(), set)); } @@ -28,7 +28,7 @@ index 44e4a768a0ccde83cae5547c7ba07744cec4c693..7954be9d04d88444601144bab560701c } diff --git a/src/main/java/org/plazmamc/plazma/configurations/WorldConfigurations.java b/src/main/java/org/plazmamc/plazma/configurations/WorldConfigurations.java -index 1e7c23c8851ba1d0f37d2b17fd334220e060888e..29514dd01d46ba9f6b123bf3af56981541f670db 100644 +index bc35244533621436e3c0fb871edf7834ad937f81..a9c8a5918184a2ea364261e279edf7169ae270c7 100644 --- a/src/main/java/org/plazmamc/plazma/configurations/WorldConfigurations.java +++ b/src/main/java/org/plazmamc/plazma/configurations/WorldConfigurations.java @@ -31,6 +31,7 @@ public class WorldConfigurations extends ConfigurationPart { diff --git a/patches/server/0033-Add-more-MSPT.patch b/patches/server/0033-Add-more-MSPT.patch index e5111f3c3..5d19b6a8b 100644 --- a/patches/server/0033-Add-more-MSPT.patch +++ b/patches/server/0033-Add-more-MSPT.patch @@ -94,7 +94,7 @@ index 03be23690a94a14d7343526acad67ccf53b85c70..416c0a736edf47f76a37be0bc5fe8678 ) ); diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index 33b7b4f544d3ec597075edcbd265815c65c9f8fa..3a7c0b25d160ca18a26ebd29cb3b0fcf78fef146 100644 +index 5a5661c3f4759c1e7501c2b59f541be11af0a83d..7f5ea3282f5069a4a911b69c758981b6f4dcadc0 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java @@ -257,8 +257,10 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop loadStatusIcon() { diff --git a/patches/server/0037-Implement-FreedomChat.patch b/patches/server/0037-Implement-FreedomChat.patch index b9d783972..c944c3cf0 100644 --- a/patches/server/0037-Implement-FreedomChat.patch +++ b/patches/server/0037-Implement-FreedomChat.patch @@ -20,10 +20,10 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java -index 6d39a0d5455fbb0af3916b751d02386af3aa3598..ba059d797251750ac866f8f2e077315597ae737f 100644 +index cbc884db2cacdcba264033dd06988150ba4ee0ba..99479a594f573aaac2a96bbecd9ef70e845f4677 100644 --- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java +++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java -@@ -705,6 +705,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface +@@ -704,6 +704,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface // Paper start - Add setting for proxy online mode status return dedicatedserverproperties.enforceSecureProfile && io.papermc.paper.configuration.GlobalConfiguration.get().proxies.isProxyOnlineMode() @@ -32,7 +32,7 @@ index 6d39a0d5455fbb0af3916b751d02386af3aa3598..ba059d797251750ac866f8f2e0773155 // Paper end - Add setting for proxy online mode status } diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java -index c36ebab552c480d34e7fd48a45f0a320a97b9677..361fcabfe5e6f54903fcbeddc96ad2311cfcfdb6 100644 +index c36ebab552c480d34e7fd48a45f0a320a97b9677..fdfe8f5bc5ad0e5f5ded41d87756a5866d041df1 100644 --- a/src/main/java/net/minecraft/server/players/PlayerList.java +++ b/src/main/java/net/minecraft/server/players/PlayerList.java @@ -135,6 +135,7 @@ public abstract class PlayerList { diff --git a/patches/unapplied/api/0007-Completely-remove-Timings.patch b/patches/unapplied/api/0007-Completely-remove-Timings.patch deleted file mode 100644 index 3ab5c347b..000000000 --- a/patches/unapplied/api/0007-Completely-remove-Timings.patch +++ /dev/null @@ -1,937 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: AlphaKR93 -Date: Sat, 27 Apr 2024 14:01:42 +0900 -Subject: [PATCH] Completely remove Timings - - -diff --git a/src/main/java/co/aikar/timings/FullServerTickHandler.java b/src/main/java/co/aikar/timings/FullServerTickHandler.java -index 36b8fe86335df851f9c85d6bb2a91368b4d945d1..acf3df70e17aa8b2b155c83a56226fcc69c2f367 100644 ---- a/src/main/java/co/aikar/timings/FullServerTickHandler.java -+++ b/src/main/java/co/aikar/timings/FullServerTickHandler.java -@@ -1,12 +1,14 @@ - package co.aikar.timings; - -+/* // Plazma - Remove timings - import static co.aikar.timings.TimingsManager.*; - - import org.bukkit.Bukkit; - import org.jetbrains.annotations.NotNull; -+ */ // Plazma - Remove timings - - @Deprecated(forRemoval = true) --public class FullServerTickHandler extends TimingHandler { -+interface FullServerTickHandler { /* extends TimingHandler { // Plazma - Remove timings - private static final TimingIdentifier IDENTITY = new TimingIdentifier("Minecraft", "Full Server Tick", null); - final TimingData minuteData; - double avgFreeMemory = -1D; -@@ -83,4 +85,5 @@ public class FullServerTickHandler extends TimingHandler { - boolean isViolated() { - return record.getCurTickTotal() > 50000000; - } -+ */ // Plazma - Remove timings - } -diff --git a/src/main/java/co/aikar/timings/NullTimingHandler.java b/src/main/java/co/aikar/timings/NullTimingHandler.java -index 81671cf40feeed2844ee8d92348d48062aaf2c46..ac3b2d321b43ed73bfe8c30742e3574e3603d1ae 100644 ---- a/src/main/java/co/aikar/timings/NullTimingHandler.java -+++ b/src/main/java/co/aikar/timings/NullTimingHandler.java -@@ -23,11 +23,13 @@ - */ - package co.aikar.timings; - -+/* // Plazma - Remove timings - import org.jetbrains.annotations.NotNull; - import org.jetbrains.annotations.Nullable; -+ */ // Plazma - Remove timings - - @Deprecated(forRemoval = true) --public final class NullTimingHandler implements Timing { -+interface NullTimingHandler { /* implements Timing { // Plazma - Remove timings - public static final Timing NULL = new NullTimingHandler(); - @NotNull - @Override -@@ -66,4 +68,5 @@ public final class NullTimingHandler implements Timing { - public void close() { - - } -+ */ // Plazma - Remove timings - } -diff --git a/src/main/java/co/aikar/timings/TimedEventExecutor.java b/src/main/java/co/aikar/timings/TimedEventExecutor.java -index 6fbc64e0f214d0c8e5afcbe385e414a4e1fe1c72..ed9580da2bfa1e3423bd63962008c00f29f6ff98 100644 ---- a/src/main/java/co/aikar/timings/TimedEventExecutor.java -+++ b/src/main/java/co/aikar/timings/TimedEventExecutor.java -@@ -23,6 +23,7 @@ - */ - package co.aikar.timings; - -+/* // Plazma - Remove timings - import org.bukkit.Bukkit; - import org.bukkit.event.Event; - import org.bukkit.event.EventException; -@@ -33,21 +34,14 @@ import org.bukkit.plugin.Plugin; - import java.lang.reflect.Method; - import org.jetbrains.annotations.NotNull; - import org.jetbrains.annotations.Nullable; -+ */ // Plazma - Remove timings - - @Deprecated(forRemoval = true) --public class TimedEventExecutor implements EventExecutor { -+interface TimedEventExecutor { /* implements EventExecutor { // Plazma - Remove timings - - private final EventExecutor executor; - private final Timing timings; - -- /** -- * Wraps an event executor and associates a timing handler to it. -- * -- * @param executor Executor to wrap -- * @param plugin Owning plugin -- * @param method EventHandler method -- * @param eventClass Owning class -- */ - public TimedEventExecutor(@NotNull EventExecutor executor, @NotNull Plugin plugin, @Nullable Method method, @NotNull Class eventClass) { - this.executor = executor; - String id; -@@ -87,4 +81,5 @@ public class TimedEventExecutor implements EventExecutor { - public String toString() { - return "TimedEventExecutor['" + this.executor.toString() + "']"; - } -+ */ // Plazma - Remove timings - } -diff --git a/src/main/java/co/aikar/timings/Timing.java b/src/main/java/co/aikar/timings/Timing.java -index 1d866e980abc542bdfee1ce082cd9cdd7761e9f7..409d698de83fb72569813d15d4fb5afbaecda68b 100644 ---- a/src/main/java/co/aikar/timings/Timing.java -+++ b/src/main/java/co/aikar/timings/Timing.java -@@ -23,8 +23,10 @@ - */ - package co.aikar.timings; - -+/* // Plazma - Remove timings - import org.jetbrains.annotations.NotNull; - import org.jetbrains.annotations.Nullable; -+ */ // Plazma - Remove timings - - /** - * Provides an ability to time sections of code within the Minecraft Server -@@ -32,61 +34,30 @@ import org.jetbrains.annotations.Nullable; - * @deprecated Timings will likely be replaced with Spark in the future - */ - @Deprecated(forRemoval = true) --public interface Timing extends AutoCloseable { -- /** -- * Starts timing the execution until {@link #stopTiming()} is called. -- * -- * @return Timing -- */ -+interface Timing { /* extends AutoCloseable { // Plazma - Remove timings - @NotNull - @io.papermc.paper.annotation.DoNotUse // Purpur - Timing startTiming(); - -- /** -- *

Stops timing and records the data. Propagates the data up to group handlers.

-- * -- * Will automatically be called when this Timing is used with try-with-resources -- */ - @io.papermc.paper.annotation.DoNotUse // Purpur - void stopTiming(); - -- /** -- * Starts timing the execution until {@link #stopTiming()} is called. -- * -- * But only if we are on the primary thread. -- * -- * @return Timing -- */ - @NotNull - @io.papermc.paper.annotation.DoNotUse // Purpur - Timing startTimingIfSync(); - -- /** -- *

Stops timing and records the data. Propagates the data up to group handlers.

-- * -- *

Will automatically be called when this Timing is used with try-with-resources

-- * -- * But only if we are on the primary thread. -- */ - @io.papermc.paper.annotation.DoNotUse // Purpur - void stopTimingIfSync(); - -- /** -- * @deprecated Doesn't do anything - Removed -- */ - @Deprecated - @io.papermc.paper.annotation.DoNotUse // Purpur - void abort(); - -- /** -- * Used internally to get the actual backing Handler in the case of delegated Handlers -- * -- * @return TimingHandler -- */ - @Nullable - TimingHandler getTimingHandler(); - - @Override - @io.papermc.paper.annotation.DoNotUse // Purpur - void close(); -+ */ // Plazma - Remove timings - } -diff --git a/src/main/java/co/aikar/timings/TimingData.java b/src/main/java/co/aikar/timings/TimingData.java -index a5d13a1e44edb861f45c83a9b4309fbf799d407d..51449d3bbf204f7fee4730af80121bdc1e2c467d 100644 ---- a/src/main/java/co/aikar/timings/TimingData.java -+++ b/src/main/java/co/aikar/timings/TimingData.java -@@ -23,17 +23,19 @@ - */ - package co.aikar.timings; - -+/* // Plazma - Remove timings - import java.util.List; - import org.jetbrains.annotations.NotNull; - - import static co.aikar.util.JSONUtil.toArray; -+ */ // Plazma - Remove timings - - /** - *

Lightweight object for tracking timing data

- * - * This is broken out to reduce memory usage - */ --class TimingData { -+interface TimingData { /* // Plazma - Remove timings - private final int id; - private int count = 0; - private int lagCount = 0; -@@ -119,4 +121,5 @@ class TimingData { - void setCurTickTotal(long curTickTotal) { - this.curTickTotal = curTickTotal; - } -+ */ // Plazma - Remove timings - } -diff --git a/src/main/java/co/aikar/timings/TimingHandler.java b/src/main/java/co/aikar/timings/TimingHandler.java -index 199789d56d22fcb1b77ebd56805cc28aa5a5ab0a..2a070b9882462226be4547da9a47907df2f64b9d 100644 ---- a/src/main/java/co/aikar/timings/TimingHandler.java -+++ b/src/main/java/co/aikar/timings/TimingHandler.java -@@ -23,6 +23,7 @@ - */ - package co.aikar.timings; - -+/* // Plazma - Remove timings - import co.aikar.util.LoadingIntMap; - import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; - -@@ -35,8 +36,9 @@ import java.util.logging.Logger; - import org.bukkit.Bukkit; - import org.jetbrains.annotations.NotNull; - import org.jetbrains.annotations.Nullable; -+ */ // Plazma - Remove timings - --class TimingHandler implements Timing { -+interface TimingHandler { /* implements Timing { // Plazma - Remove timings - - private static AtomicInteger idPool = new AtomicInteger(1); - private static Deque TIMING_STACK = new ArrayDeque<>(); -@@ -163,9 +165,6 @@ class TimingHandler implements Timing { - } - } - -- /** -- * Reset this timer, setting all values to zero. -- */ - void reset(boolean full) { - record.reset(); - if (full) { -@@ -194,9 +193,6 @@ class TimingHandler implements Timing { - return id; - } - -- /** -- * This is simply for the Closeable interface so it can be used with try-with-resources () -- */ - @Override - public void close() { - stopTimingIfSync(); -@@ -223,4 +219,5 @@ class TimingHandler implements Timing { - } - return clonedChildren; - } -+ */ // Plazma - Remove timings - } -diff --git a/src/main/java/co/aikar/timings/TimingHistory.java b/src/main/java/co/aikar/timings/TimingHistory.java -index 02e88db63be2d5e31da6b65157ba7b971b1f10f3..bda95eeacd244892ea3a114bfdcb8b24dfdfccfa 100644 ---- a/src/main/java/co/aikar/timings/TimingHistory.java -+++ b/src/main/java/co/aikar/timings/TimingHistory.java -@@ -23,6 +23,7 @@ - */ - package co.aikar.timings; - -+/* // Plazma - Remove timings - import co.aikar.timings.TimingHistory.RegionData.RegionId; - import com.google.common.base.Function; - import com.google.common.collect.Sets; -@@ -49,10 +50,11 @@ import org.jetbrains.annotations.Nullable; - import static co.aikar.timings.TimingsManager.FULL_SERVER_TICK; - import static co.aikar.timings.TimingsManager.MINUTE_REPORTS; - import static co.aikar.util.JSONUtil.*; -+ */ // Plazma - Remove timings - - @Deprecated(forRemoval = true) - @SuppressWarnings({"deprecation", "SuppressionAnnotation", "Convert2Lambda", "Anonymous2MethodRef"}) --public class TimingHistory { -+interface TimingHistory { /* - public static long lastMinuteTime; - public static long timedTicks; - public static long playerTicks; -@@ -352,4 +354,5 @@ public class TimingHistory { - return count; - } - } -+ */ // Plazma - Remove timings - } -diff --git a/src/main/java/co/aikar/timings/TimingHistoryEntry.java b/src/main/java/co/aikar/timings/TimingHistoryEntry.java -index 86d5ac6bd0d7d0003688761aceb3f3343575319f..c862c14eb99ac9c55cfb367cf3d8c2db59f8a50e 100644 ---- a/src/main/java/co/aikar/timings/TimingHistoryEntry.java -+++ b/src/main/java/co/aikar/timings/TimingHistoryEntry.java -@@ -23,14 +23,16 @@ - */ - package co.aikar.timings; - -+/* // Plazma - Remove timings - import com.google.common.base.Function; - - import java.util.List; - import org.jetbrains.annotations.NotNull; - - import static co.aikar.util.JSONUtil.toArrayMapper; -+ */ // Plazma - Remove timings - --class TimingHistoryEntry { -+interface TimingHistoryEntry { /* // Plazma - Remove timings - final TimingData data; - private final TimingData[] children; - -@@ -55,4 +57,5 @@ class TimingHistoryEntry { - } - return result; - } -+ */ // Plazma - Remove timings - } -diff --git a/src/main/java/co/aikar/timings/TimingIdentifier.java b/src/main/java/co/aikar/timings/TimingIdentifier.java -index df142a89b8c43acb81eb383eac0ef048a1f49a6e..b273b4bc96cc756fa246b8b4c8efa1cac23cd957 100644 ---- a/src/main/java/co/aikar/timings/TimingIdentifier.java -+++ b/src/main/java/co/aikar/timings/TimingIdentifier.java -@@ -23,6 +23,7 @@ - */ - package co.aikar.timings; - -+/* // Plazma - Remove timings - import co.aikar.util.LoadingMap; - - import java.util.ArrayList; -@@ -34,16 +35,14 @@ import java.util.concurrent.ConcurrentHashMap; - import java.util.concurrent.atomic.AtomicInteger; - import org.jetbrains.annotations.NotNull; - import org.jetbrains.annotations.Nullable; -+ */ // Plazma - Remove timings - - /** - *

Used as a basis for fast HashMap key comparisons for the Timing Map.

- * - * This class uses interned strings giving us the ability to do an identity check instead of equals() on the strings - */ --final class TimingIdentifier { -- /** -- * Holds all groups. Autoloads on request for a group by name. -- */ -+interface TimingIdentifier { /* // Plazma - Remove timings - static final Map GROUP_MAP = LoadingMap.of(new ConcurrentHashMap<>(64, .5F), TimingGroup::new); - private static final TimingGroup DEFAULT_GROUP = getGroup("Minecraft"); - final String group; -@@ -113,4 +112,5 @@ final class TimingIdentifier { - return id; - } - } -+ */ // Plazma - Remove timings - } -diff --git a/src/main/java/co/aikar/timings/Timings.java b/src/main/java/co/aikar/timings/Timings.java -index 752d54830aa8baa1450bf72da03ae55ed30293c2..d2bab3cc02f7dfef2852cd705870351c81376061 100644 ---- a/src/main/java/co/aikar/timings/Timings.java -+++ b/src/main/java/co/aikar/timings/Timings.java -@@ -23,6 +23,7 @@ - */ - package co.aikar.timings; - -+/* // Plazma - Remove timings - import com.google.common.base.Preconditions; - import com.google.common.collect.EvictingQueue; - import com.google.common.collect.Lists; -@@ -39,13 +40,14 @@ import java.util.Queue; - import java.util.logging.Level; - import org.jetbrains.annotations.NotNull; - import org.jetbrains.annotations.Nullable; -+ */ // Plazma - Remove timings - - /** - * @deprecated Timings will likely be replaced with Spark in the future - */ - @Deprecated(forRemoval = true) - @SuppressWarnings({"UnusedDeclaration", "WeakerAccess", "SameParameterValue"}) --public final class Timings { -+interface Timings { /* // Plazma - Remove timings - - final static List requestingReport = Lists.newArrayList(); - private static final int MAX_HISTORY_FRAMES = 12; -@@ -58,13 +60,6 @@ public final class Timings { - - private Timings() {} - -- /** -- * Returns a Timing for a plugin corresponding to a name. -- * -- * @param plugin Plugin to own the Timing -- * @param name Name of Timing -- * @return Handler -- */ - @NotNull - public static Timing of(@NotNull Plugin plugin, @NotNull String name) { - Timing pluginHandler = null; -@@ -74,18 +69,6 @@ public final class Timings { - return of(plugin, name, pluginHandler); - } - -- /** -- *

Returns a handler that has a groupHandler timer handler. Parent timers should not have their -- * start/stop methods called directly, as the children will call it for you.

-- * -- * Parent Timers are used to group multiple subsections together and get a summary of them combined -- * Parent Handler can not be changed after first call -- * -- * @param plugin Plugin to own the Timing -- * @param name Name of Timing -- * @param groupHandler Parent handler to mirror .start/stop calls to -- * @return Timing Handler -- */ - @NotNull - public static Timing of(@NotNull Plugin plugin, @NotNull String name, @Nullable Timing groupHandler) { - Preconditions.checkNotNull(plugin, "Plugin can not be null"); -@@ -93,34 +76,11 @@ public final class Timings { - return TimingsManager.getHandler(plugin.getName(), name, groupHandler); - } - -- /** -- * Returns a Timing object after starting it, useful for Java7 try-with-resources. -- * -- * try (Timing ignored = Timings.ofStart(plugin, someName)) { -- * // timed section -- * } -- * -- * @param plugin Plugin to own the Timing -- * @param name Name of Timing -- * @return Timing Handler -- */ - @NotNull - public static Timing ofStart(@NotNull Plugin plugin, @NotNull String name) { - return ofStart(plugin, name, null); - } - -- /** -- * Returns a Timing object after starting it, useful for Java7 try-with-resources. -- * -- * try (Timing ignored = Timings.ofStart(plugin, someName, groupHandler)) { -- * // timed section -- * } -- * -- * @param plugin Plugin to own the Timing -- * @param name Name of Timing -- * @param groupHandler Parent handler to mirror .start/stop calls to -- * @return Timing Handler -- */ - @NotNull - public static Timing ofStart(@NotNull Plugin plugin, @NotNull String name, @Nullable Timing groupHandler) { - Timing timing = of(plugin, name, groupHandler); -@@ -128,22 +88,10 @@ public final class Timings { - return timing; - } - -- /** -- * Gets whether or not the Spigot Timings system is enabled -- * -- * @return Enabled or not -- */ - public static boolean isTimingsEnabled() { - return timingsEnabled; - } - -- /** -- *

Sets whether or not the Spigot Timings system should be enabled

-- * -- * Calling this will reset timing data. -- * -- * @param enabled Should timings be reported -- */ - public static void setTimingsEnabled(boolean enabled) { - // Purpur start - we don't do that here... - timingsEnabled = false; -@@ -182,51 +130,19 @@ public final class Timings { - .build(); - } - -- /** -- *

Sets whether or not the Timings should monitor at Verbose level.

-- * -- *

When Verbose is disabled, high-frequency timings will not be available.

-- * -- * @return Enabled or not -- */ - public static boolean isVerboseTimingsEnabled() { - return verboseEnabled; - } - -- /** -- *

Sets whether or not the Timings should monitor at Verbose level.

-- * -- * When Verbose is disabled, high-frequency timings will not be available. -- * Calling this will reset timing data. -- * -- * @param enabled Should high-frequency timings be reported -- */ - public static void setVerboseTimingsEnabled(boolean enabled) { - verboseEnabled = enabled; - TimingsManager.needsRecheckEnabled = true; - } - -- /** -- *

Gets the interval between Timing History report generation.

-- * -- * Defaults to 5 minutes (6000 ticks) -- * -- * @return Interval in ticks -- */ - public static int getHistoryInterval() { - return historyInterval; - } - -- /** -- *

Sets the interval between Timing History report generations.

-- * -- *

Defaults to 5 minutes (6000 ticks)

-- * -- * This will recheck your history length, so lowering this value will lower your -- * history length if you need more than 60 history windows. -- * -- * @param interval Interval in ticks -- */ - public static void setHistoryInterval(int interval) { - historyInterval = Math.max(20*60, interval); - // Recheck the history length with the new Interval -@@ -235,28 +151,10 @@ public final class Timings { - } - } - -- /** -- * Gets how long in ticks Timings history is kept for the server. -- * -- * Defaults to 1 hour (72000 ticks) -- * -- * @return Duration in Ticks -- */ - public static int getHistoryLength() { - return historyLength; - } - -- /** -- * Sets how long Timing History reports are kept for the server. -- * -- * Defaults to 1 hours(72000 ticks) -- * -- * This value is capped at a maximum of getHistoryInterval() * MAX_HISTORY_FRAMES (12) -- * -- * Will not reset Timing Data but may truncate old history if the new length is less than old length. -- * -- * @param length Duration in ticks -- */ - public static void setHistoryLength(int length) { - // Cap at 12 History Frames, 1 hour at 5 minute frames. - int maxLength = historyInterval * MAX_HISTORY_FRAMES; -@@ -276,19 +174,10 @@ public final class Timings { - TimingsManager.HISTORY.addAll(oldQueue); - } - -- /** -- * Resets all Timing Data -- */ - public static void reset() { - TimingsManager.reset(); - } - -- /** -- * Generates a report and sends it to the specified command sender. -- * -- * If sender is null, ConsoleCommandSender will be used. -- * @param sender The sender to send to, or null to use the ConsoleCommandSender -- */ - public static void generateReport(@Nullable CommandSender sender) { - if (sender == null) { - sender = Bukkit.getConsoleSender(); -@@ -296,22 +185,11 @@ public final class Timings { - requestingReport.add(sender); - } - -- /** -- * Generates a report and sends it to the specified listener. -- * Use with {@link org.bukkit.command.BufferedCommandSender} to get full response when done! -- * @param sender The listener to send responses too. -- */ - public static void generateReport(@NotNull TimingsReportListener sender) { - Preconditions.checkNotNull(sender); - requestingReport.add(sender); - } - -- /* -- ================= -- Protected API: These are for internal use only in Bukkit/CraftBukkit -- These do not have isPrimaryThread() checks in the startTiming/stopTiming -- ================= -- */ - @NotNull - static TimingHandler ofSafe(@NotNull String name) { - return ofSafe(null, name, null); -@@ -335,5 +213,6 @@ public final class Timings { - static TimingHandler ofSafe(@Nullable String groupName, @NotNull String name, @Nullable Timing groupHandler) { - return TimingsManager.getHandler(groupName, name, groupHandler); - } -+ */ // Plazma - Remove timings - } - -diff --git a/src/main/java/co/aikar/timings/TimingsCommand.java b/src/main/java/co/aikar/timings/TimingsCommand.java -index 1abfcee0f6d632f4cd8d74b4994a90c9ea9d254c..18ddc321c4a23689d93c4340e0010dc67e84f138 100644 ---- a/src/main/java/co/aikar/timings/TimingsCommand.java -+++ b/src/main/java/co/aikar/timings/TimingsCommand.java -@@ -61,6 +61,7 @@ public class TimingsCommand extends BukkitCommand { - sender.sendMessage(mm.deserialize("https://spark.lucko.me/docs/Command-Usage")); - return true; - } -+ /* // Plazma - Remove timings - if (args.length < 1) { - sender.sendMessage(text("Usage: " + this.usageMessage, NamedTextColor.RED)); - return true; -@@ -109,6 +110,7 @@ public class TimingsCommand extends BukkitCommand { - } else { - sender.sendMessage(text("Usage: " + this.usageMessage, NamedTextColor.RED)); - } -+ */ // Plazma - Remove timings - return true; - } - -diff --git a/src/main/java/co/aikar/timings/TimingsManager.java b/src/main/java/co/aikar/timings/TimingsManager.java -index 5e1558ca3ffeeaf2645fa003965474a442d650bf..f6aa204db5ef216e1eb06be5e5e307067cfcf05c 100644 ---- a/src/main/java/co/aikar/timings/TimingsManager.java -+++ b/src/main/java/co/aikar/timings/TimingsManager.java -@@ -23,6 +23,7 @@ - */ - package co.aikar.timings; - -+/* // Plazma - Remove timings - import co.aikar.util.LoadingMap; - import com.google.common.collect.EvictingQueue; - import org.bukkit.Bukkit; -@@ -38,12 +39,13 @@ import java.util.concurrent.ConcurrentHashMap; - import java.util.logging.Level; - import org.jetbrains.annotations.NotNull; - import org.jetbrains.annotations.Nullable; -+ */ // Plazma - Remove timings - - /** - * @deprecated Timings will likely be replaced with Spark in the future - */ - @Deprecated(forRemoval = true) --public final class TimingsManager { -+interface TimingsManager { /* // Plazma - Remove timings - static final Map TIMING_MAP = LoadingMap.of( - new ConcurrentHashMap<>(4096, .5F), TimingHandler::new - ); -@@ -65,17 +67,10 @@ public final class TimingsManager { - - private TimingsManager() {} - -- /** -- * Resets all timing data on the next tick -- */ - static void reset() { - needsFullReset = true; - } - -- /** -- * Ticked every tick by CraftBukkit to count the number of times a timer -- * caused TPS loss. -- */ - static void tick() { - if (Timings.timingsEnabled) { - boolean violated = FULL_SERVER_TICK.isViolated(); -@@ -139,16 +134,6 @@ public final class TimingsManager { - return TIMING_MAP.get(new TimingIdentifier(group, name, parent)); - } - -- -- /** -- *

Due to access restrictions, we need a helper method to get a Command TimingHandler with String group

-- * -- * Plugins should never call this -- * -- * @param pluginName Plugin this command is associated with -- * @param command Command to get timings for -- * @return TimingHandler -- */ - @NotNull - public static Timing getCommandTiming(@Nullable String pluginName, @NotNull Command command) { - Plugin plugin = null; -@@ -170,13 +155,6 @@ public final class TimingsManager { - return Timings.ofSafe(plugin, "Command: " + pluginName + ":" + command.getTimingName()); - } - -- /** -- * Looks up the class loader for the specified class, and if it is a PluginClassLoader, return the -- * Plugin that created this class. -- * -- * @param clazz Class to check -- * @return Plugin if created by a plugin -- */ - @Nullable - public static Plugin getPluginByClassloader(@Nullable Class clazz) { - if (clazz == null) { -@@ -189,4 +167,5 @@ public final class TimingsManager { - } - return null; - } -+ */ // Plazma - Remove timings - } -diff --git a/src/main/java/co/aikar/timings/TimingsReportListener.java b/src/main/java/co/aikar/timings/TimingsReportListener.java -index 3af5b8ea795311582044c712de50d29412024b77..d5b52c8bf0bd23d9e3c0ba708c758694771a07ac 100644 ---- a/src/main/java/co/aikar/timings/TimingsReportListener.java -+++ b/src/main/java/co/aikar/timings/TimingsReportListener.java -@@ -1,5 +1,6 @@ - package co.aikar.timings; - -+/* // Plazma - Remove timings - import com.google.common.base.Preconditions; - import com.google.common.collect.Lists; - import org.bukkit.Bukkit; -@@ -11,10 +12,11 @@ import org.jetbrains.annotations.NotNull; - import org.jetbrains.annotations.Nullable; - - import java.util.List; -+ */ // Plazma - Remove timings - - @Deprecated(forRemoval = true) - @SuppressWarnings("WeakerAccess") --public class TimingsReportListener implements net.kyori.adventure.audience.ForwardingAudience, MessageCommandSender { -+interface TimingsReportListener { /* implements net.kyori.adventure.audience.ForwardingAudience, MessageCommandSender { // Plazma - Remove timings - private final List senders; - private final Runnable onDone; - private String timingsURL; -@@ -84,4 +86,5 @@ public class TimingsReportListener implements net.kyori.adventure.audience.Forwa - this.senders.add(Bukkit.getConsoleSender()); - } - } -+ */ // Plazma - Remove timings - } -diff --git a/src/main/java/co/aikar/timings/UnsafeTimingHandler.java b/src/main/java/co/aikar/timings/UnsafeTimingHandler.java -index 632c4961515f5052551f841cfa840e60bba7a257..0656b8e86eaee12161a8bb16d1b46301fd5cea13 100644 ---- a/src/main/java/co/aikar/timings/UnsafeTimingHandler.java -+++ b/src/main/java/co/aikar/timings/UnsafeTimingHandler.java -@@ -23,10 +23,12 @@ - */ - package co.aikar.timings; - -+/* // Plazma - Remove timings - import org.bukkit.Bukkit; - import org.jetbrains.annotations.NotNull; -+ */ // Plazma - Remove timings - --class UnsafeTimingHandler extends TimingHandler { -+interface UnsafeTimingHandler { /* extends TimingHandler { // Plazma - Remove timings - - UnsafeTimingHandler(@NotNull TimingIdentifier id) { - super(id); -@@ -50,4 +52,5 @@ class UnsafeTimingHandler extends TimingHandler { - checkThread(); - super.stopTiming(); - } -+ */ // Plazma - Remove timings - } -diff --git a/src/main/java/org/bukkit/command/Command.java b/src/main/java/org/bukkit/command/Command.java -index b791358f90fe92bc2264d9a26492245763813af3..8c10f2dc17cfede217f3a1b615777ea4dd308f76 100644 ---- a/src/main/java/org/bukkit/command/Command.java -+++ b/src/main/java/org/bukkit/command/Command.java -@@ -33,7 +33,7 @@ public abstract class Command { - protected String usageMessage; - private String permission; - private net.kyori.adventure.text.Component permissionMessage; // Paper -- public co.aikar.timings.Timing timings; // Paper -+ // public co.aikar.timings.Timing timings; // Paper // Plazma - Remove timings - @NotNull public String getTimingName() {return getName();} // Paper - - protected Command(@NotNull String name) { -diff --git a/src/main/java/org/bukkit/command/FormattedCommandAlias.java b/src/main/java/org/bukkit/command/FormattedCommandAlias.java -index 9d4f553c04784cca63901a56a7aea62a5cae1d72..321082710aa84627405d4f1453246b6a729659cc 100644 ---- a/src/main/java/org/bukkit/command/FormattedCommandAlias.java -+++ b/src/main/java/org/bukkit/command/FormattedCommandAlias.java -@@ -12,7 +12,7 @@ public class FormattedCommandAlias extends Command { - - public FormattedCommandAlias(@NotNull String alias, @NotNull String[] formatStrings) { - super(alias); -- timings = co.aikar.timings.TimingsManager.getCommandTiming("minecraft", this); // Spigot -+ //timings = co.aikar.timings.TimingsManager.getCommandTiming("minecraft", this); // Spigot // Plazma - Remove timings - this.formatStrings = formatStrings; - } - -diff --git a/src/main/java/org/bukkit/command/SimpleCommandMap.java b/src/main/java/org/bukkit/command/SimpleCommandMap.java -index 5349f16136d9348c374a7dfe5b89a71dfcb0e66d..c0c2f7671122f767af3a94a3aadefdfa4b492f3a 100644 ---- a/src/main/java/org/bukkit/command/SimpleCommandMap.java -+++ b/src/main/java/org/bukkit/command/SimpleCommandMap.java -@@ -34,7 +34,7 @@ public class SimpleCommandMap implements CommandMap { - register("bukkit", new VersionCommand("version")); - register("bukkit", new ReloadCommand("reload")); - //register("bukkit", new PluginsCommand("plugins")); // Paper -- register("bukkit", new co.aikar.timings.TimingsCommand("timings")); // Paper -+ //register("bukkit", new co.aikar.timings.TimingsCommand("timings")); // Paper // Plazma - Remove timings - } - - public void setFallbackCommands() { -@@ -66,7 +66,7 @@ public class SimpleCommandMap implements CommandMap { - */ - @Override - public boolean register(@NotNull String label, @NotNull String fallbackPrefix, @NotNull Command command) { -- command.timings = co.aikar.timings.TimingsManager.getCommandTiming(fallbackPrefix, command); // Paper -+ // command.timings = co.aikar.timings.TimingsManager.getCommandTiming(fallbackPrefix, command); // Paper // Plazma - Remove timings - label = label.toLowerCase(java.util.Locale.ENGLISH).trim(); - fallbackPrefix = fallbackPrefix.toLowerCase(java.util.Locale.ENGLISH).trim(); - boolean registered = register(label, command, false, fallbackPrefix); -@@ -156,11 +156,13 @@ public class SimpleCommandMap implements CommandMap { - parsedArgs = event.getArgs(); - // Purpur end - -+ /* // Plazma - Remove timings - // Paper start - Plugins do weird things to workaround normal registration - if (target.timings == null) { - target.timings = co.aikar.timings.TimingsManager.getCommandTiming(null, target); - } - // Paper end -+ */ // Plazma - Remove timings - - try { - //try (co.aikar.timings.Timing ignored = target.timings.startTiming()) { // Paper - use try with resources // Purpur -diff --git a/src/main/java/org/bukkit/plugin/SimplePluginManager.java b/src/main/java/org/bukkit/plugin/SimplePluginManager.java -index 899d67fa782fac639fe7fb096e05c551d75bd647..1d9906c508ca916297b8e121f8826532b66f83e2 100644 ---- a/src/main/java/org/bukkit/plugin/SimplePluginManager.java -+++ b/src/main/java/org/bukkit/plugin/SimplePluginManager.java -@@ -707,6 +707,7 @@ public final class SimplePluginManager implements PluginManager { - Preconditions.checkArgument(plugin != null, "Plugin cannot be null"); - if (true) {this.paperPluginManager.registerEvent(event, listener, priority, executor, plugin, ignoreCancelled); return;} // Paper - -+ /* // Plazma - Remove timings - if (!plugin.isEnabled()) { - throw new IllegalPluginAccessException("Plugin attempted to register " + event + " while not enabled"); - } -@@ -717,6 +718,7 @@ public final class SimplePluginManager implements PluginManager { - } else { - getEventListeners(event).register(new RegisteredListener(listener, executor, priority, plugin, ignoreCancelled)); - } -+ */ // Plazma - Remove timings - } - - @NotNull -@@ -946,8 +948,9 @@ public final class SimplePluginManager implements PluginManager { - - @Override - public boolean useTimings() { -- if (true) {return this.paperPluginManager.useTimings();} // Paper -- return co.aikar.timings.Timings.isTimingsEnabled(); // Spigot -+ return false; -+ // if (true) {return this.paperPluginManager.useTimings();} // Paper // Plazma - Remove timings -+ // return co.aikar.timings.Timings.isTimingsEnabled(); // Spigot // Plazma - Remove timings - } - - /** -@@ -956,7 +959,7 @@ public final class SimplePluginManager implements PluginManager { - * @param use True if per event timing code should be used - */ - public void useTimings(boolean use) { -- co.aikar.timings.Timings.setTimingsEnabled(use); // Paper -+ // co.aikar.timings.Timings.setTimingsEnabled(use); // Paper // Plazma - Remove timings - } - - // Paper start -diff --git a/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java b/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java -index 0c6ca7588fb3d6b6497ddf032fe75e5c6c9719e5..e5d4ac1b8b4ca3846e2a9ea63f6b6eb05f7b70bd 100644 ---- a/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java -+++ b/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java -@@ -43,7 +43,7 @@ import org.bukkit.plugin.TimedRegisteredListener; - import org.bukkit.plugin.UnknownDependencyException; - import org.jetbrains.annotations.NotNull; - import org.jetbrains.annotations.Nullable; --import org.spigotmc.CustomTimingsHandler; // Spigot -+// import org.spigotmc.CustomTimingsHandler; // Spigot // Plazma - Remove timings - import org.yaml.snakeyaml.error.YAMLException; - - /** -@@ -294,7 +294,7 @@ public final class JavaPluginLoader implements PluginLoader { - } - } - -- EventExecutor executor = new co.aikar.timings.TimedEventExecutor(new EventExecutor() { // Paper -+ EventExecutor executor = new EventExecutor() { // Paper // Plazma - Remove timings - @Override - public void execute(@NotNull Listener listener, @NotNull Event event) throws EventException { // Paper - try { -@@ -308,7 +308,7 @@ public final class JavaPluginLoader implements PluginLoader { - throw new EventException(t); - } - } -- }, plugin, method, eventClass); // Paper -+ }; // Paper // Plazma - Remove timings - if (false) { // Spigot - RL handles useTimings check now - eventSet.add(new TimedRegisteredListener(listener, executor, eh.priority(), plugin, eh.ignoreCancelled())); - } else { -diff --git a/src/main/java/org/spigotmc/CustomTimingsHandler.java b/src/main/java/org/spigotmc/CustomTimingsHandler.java -index 9c2d605c50cbf9aefa56ec209df9f6cea1392e89..cb2bd5f58544493a5ae0d2b765be806e35639baa 100644 ---- a/src/main/java/org/spigotmc/CustomTimingsHandler.java -+++ b/src/main/java/org/spigotmc/CustomTimingsHandler.java -@@ -23,6 +23,7 @@ - */ - package org.spigotmc; - -+/* // Plazma - Remove timings - import org.bukkit.Bukkit; - import org.jetbrains.annotations.NotNull; - import org.bukkit.plugin.AuthorNagException; -@@ -32,6 +33,7 @@ import co.aikar.timings.TimingsManager; - - import java.lang.reflect.Method; - import java.util.logging.Level; -+ */ // Plazma - Remove timings - - /** - * This is here for legacy purposes incase any plugin used it. -@@ -39,10 +41,9 @@ import java.util.logging.Level; - * If you use this, migrate ASAP as this will be removed in the future! - * - * @deprecated -- * @see co.aikar.timings.Timings#of - */ - @Deprecated(forRemoval = true) --public final class CustomTimingsHandler { -+interface CustomTimingsHandler { /* // Plazma - Remove timings - private final Timing handler; - - public CustomTimingsHandler(@NotNull String name) { -@@ -61,7 +62,7 @@ public final class CustomTimingsHandler { - handler = timing; - } - -- public void startTiming() { /*handler.startTiming();*/ } // Purpur -- public void stopTiming() { /*handler.stopTiming();*/ } // Purpur -- -+ public void startTiming() { handler.startTiming(); } // Purpur // Plazma - IDE Parsing problem -+ public void stopTiming() { handler.stopTiming(); } // Purpur // Plazma - IDE Parsing problem -+ */ // Plazma - Remove timings - } diff --git a/patches/unapplied/api/0004-Optimize-Spigot-event-bus.patch b/patches/unapplied/api/dropped/0004-Optimize-Spigot-event-bus.patch similarity index 100% rename from patches/unapplied/api/0004-Optimize-Spigot-event-bus.patch rename to patches/unapplied/api/dropped/0004-Optimize-Spigot-event-bus.patch diff --git a/patches/unapplied/server/dropped/0016-Completely-remove-Timings.patch b/patches/unapplied/server/dropped/0016-Completely-remove-Timings.patch deleted file mode 100644 index cfa8b93ba..000000000 --- a/patches/unapplied/server/dropped/0016-Completely-remove-Timings.patch +++ /dev/null @@ -1,641 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: AlphaKR93 -Date: Sat, 27 Apr 2024 14:02:18 +0900 -Subject: [PATCH] Completely remove Timings - - -diff --git a/src/main/java/co/aikar/timings/MinecraftTimings.java b/src/main/java/co/aikar/timings/MinecraftTimings.java -index 4b467f1af93452d13829f756d55dee18b8889d40..7e20ec279c9fb75b92ca3bf938adeeb126641aa5 100644 ---- a/src/main/java/co/aikar/timings/MinecraftTimings.java -+++ b/src/main/java/co/aikar/timings/MinecraftTimings.java -@@ -1,5 +1,6 @@ - package co.aikar.timings; - -+/* // Plazma - Completely remove Timings - import com.google.common.collect.MapMaker; - import io.papermc.paper.configuration.GlobalConfiguration; - import net.minecraft.commands.functions.CommandFunction; -@@ -12,10 +13,11 @@ import org.bukkit.scheduler.BukkitTask; - import org.bukkit.craftbukkit.scheduler.CraftTask; - - import java.util.Map; -+ */ // Plazma - Completely remove Timings - --// TODO: Re-implement missing timers -+// TODO: Re-implement missing timers // Plazma - nah you cant - @Deprecated(forRemoval = true) --public final class MinecraftTimings { -+interface MinecraftTimings { /* // Plazma - Completely remove Timings - - public static final Timing serverOversleep = Timings.ofSafe("Server Oversleep"); - public static final Timing playerListTimer = Timings.ofSafe("Player List"); -@@ -59,12 +61,6 @@ public final class MinecraftTimings { - return Timings.ofSafe(taskName); - } - -- /** -- * Gets a timer associated with a plugins tasks. -- * @param bukkitTask -- * @param period -- * @return -- */ - public static Timing getPluginTaskTimings(BukkitTask bukkitTask, long period) { - if (!bukkitTask.isSync()) { - return NullTimingHandler.NULL; -@@ -110,11 +106,6 @@ public final class MinecraftTimings { - return Timings.ofSafe(plugin, name.toString()); - } - -- /** -- * Get a named timer for the specified entity type to track type specific timings. -- * @param entityType -- * @return -- */ - public static Timing getEntityTimings(String entityType, String type) { - return Timings.ofSafe("Minecraft", "## tickEntity - " + entityType + " - " + type, tickEntityTimer); - } -@@ -127,11 +118,6 @@ public final class MinecraftTimings { - return Timings.ofSafe("## Sensor - " + type + " (Default rate: " + rate + ")"); - } - -- /** -- * Get a named timer for the specified tile entity type to track type specific timings. -- * @param entity -- * @return -- */ - public static Timing getTileEntityTimings(BlockEntity entity) { - String entityType = entity.getClass().getName(); - return Timings.ofSafe("Minecraft", "## tickTileEntity - " + entityType, tickTileEntityTimer); -@@ -150,10 +136,10 @@ public final class MinecraftTimings { - public static Timing getBlockTiming(Block block) { - return Timings.ofSafe("## Scheduled Block: " + block.toString(), scheduledBlocksTimer); - } --/* -+ - public static Timing getStructureTiming(StructureGenerator structureGenerator) { - return Timings.ofSafe("Structure Generator - " + structureGenerator.getName(), structureGenerationTimer); -- }*/ -+ } - - public static Timing getPacketTiming(Packet packet) { - return Timings.ofSafe("## Packet - " + packet.getClass().getName(), packetProcessTimer); -@@ -178,4 +164,6 @@ public final class MinecraftTimings { - co.aikar.timings.Timings.setHistoryInterval(config.historyInterval * 20); - co.aikar.timings.Timings.setHistoryLength(config.historyLength * 20); - } -+ */ // Plazma - Completely remove Timings -+ - } -diff --git a/src/main/java/co/aikar/timings/TimingsExport.java b/src/main/java/co/aikar/timings/TimingsExport.java -index b35a9f4c5f8960864c402ede8a51fb5ab9c4fcc0..46085a9c12efc6a1766e704c9bb0fbf454d60c8a 100644 ---- a/src/main/java/co/aikar/timings/TimingsExport.java -+++ b/src/main/java/co/aikar/timings/TimingsExport.java -@@ -23,6 +23,7 @@ - */ - package co.aikar.timings; - -+/* // Plazma - Completely remove Timings - import com.google.common.collect.Sets; - import io.papermc.paper.adventure.PaperAdventure; - import net.kyori.adventure.text.event.ClickEvent; -@@ -64,10 +65,11 @@ import static co.aikar.util.JSONUtil.toArray; - import static co.aikar.util.JSONUtil.toArrayMapper; - import static co.aikar.util.JSONUtil.toObjectMapper; - import static net.kyori.adventure.text.Component.text; -+ */ // Plazma - Completely remove Timings - - @SuppressWarnings({"rawtypes", "SuppressionAnnotation"}) - @Deprecated(forRemoval = true) --public class TimingsExport extends Thread { -+interface TimingsExport { /* extends Thread { // Plazma - Completely remove Timings - - private final TimingsReportListener listeners; - private final Map out; -@@ -81,9 +83,6 @@ public class TimingsExport extends Thread { - this.history = history; - } - -- /** -- * Checks if any pending reports are being requested, and builds one if needed. -- */ - public static void reportTimings() { - if (Timings.requestingReport.isEmpty()) { - return; -@@ -386,4 +385,6 @@ public class TimingsExport extends Thread { - } - } - } -+ */ // Plazma - Completely remove Timings -+ - } -diff --git a/src/main/java/co/aikar/timings/WorldTimingsHandler.java b/src/main/java/co/aikar/timings/WorldTimingsHandler.java -index 22687667ec69a954261e55e59261286ac1b8b8cd..9115fab47c5d69aa9c563b8ade7f916b99827e4f 100644 ---- a/src/main/java/co/aikar/timings/WorldTimingsHandler.java -+++ b/src/main/java/co/aikar/timings/WorldTimingsHandler.java -@@ -1,15 +1,18 @@ - package co.aikar.timings; - -+/* // Plazma - Completely remove Timings - import net.minecraft.server.level.ServerLevel; - import net.minecraft.world.level.Level; - import net.minecraft.world.level.storage.PrimaryLevelData; -+ */ // Plazma - Completely remove Timings - - /** - * Set of timers per world, to track world specific timings. - */ - // TODO: Re-implement missing timers - @Deprecated(forRemoval = true) --public class WorldTimingsHandler { -+interface WorldTimingsHandler { -+ /* // Plazma - Completely remove Timings - public final Timing mobSpawn; - public final Timing doChunkUnload; - public final Timing doPortalForcer; -@@ -137,4 +140,5 @@ public class WorldTimingsHandler { - public static Timing getTickList(ServerLevel worldserver, String timingsType) { - return Timings.ofSafe(((PrimaryLevelData) worldserver.getLevelData()).getLevelName() + " - Scheduled " + timingsType); - } -+ */ // Plazma - Completely remove Timings - } -diff --git a/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java b/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java -index c71daa5d3665cec2836770e5f04da222bc5f90ed..da06919b1911f87e64732716217f85d6ba606e8f 100644 ---- a/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java -+++ b/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java -@@ -1,6 +1,6 @@ - package io.papermc.paper.configuration; - --import co.aikar.timings.MinecraftTimings; -+// import co.aikar.timings.MinecraftTimings; // Plazma - Completely remove Timings - import com.mojang.logging.LogUtils; - import io.papermc.paper.configuration.constraint.Constraints; - import io.papermc.paper.configuration.type.number.IntOr; -@@ -91,6 +91,7 @@ public class GlobalConfiguration extends ConfigurationPart { - public boolean useDisplayNameInQuitMessage = false; - } - -+ /* // Plazma - Completely remove Timings - @Deprecated(forRemoval = true) - public Timings timings; - -@@ -113,6 +114,7 @@ public class GlobalConfiguration extends ConfigurationPart { - MinecraftTimings.processConfig(this); - } - } -+ */ // Plazma - Completely remove Timings - - public Proxies proxies; - -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 7ce9ebba8ce304d1f3f21d4f15ee5f3560d7700b..2a79e3423724b5005f1918b80e06051dfcfc5bf9 100644 ---- a/src/main/java/io/papermc/paper/plugin/manager/PaperEventManager.java -+++ b/src/main/java/io/papermc/paper/plugin/manager/PaperEventManager.java -@@ -1,6 +1,6 @@ - package io.papermc.paper.plugin.manager; - --import co.aikar.timings.TimedEventExecutor; -+// import co.aikar.timings.TimedEventExecutor; // Plazma - Completely remove Timings - import com.destroystokyo.paper.event.server.ServerExceptionEvent; - import com.destroystokyo.paper.exception.ServerEventException; - import com.google.common.collect.Sets; -@@ -95,7 +95,7 @@ class PaperEventManager { - throw new IllegalPluginAccessException("Plugin attempted to register " + event + " while not enabled"); - } - -- executor = new TimedEventExecutor(executor, plugin, null, event); -+ // executor = new TimedEventExecutor(executor, plugin, null, event); // Plazma - Completely remove Timings - this.getEventListeners(event).register(new RegisteredListener(listener, executor, priority, plugin, ignoreCancelled)); - } - -@@ -182,7 +182,7 @@ class PaperEventManager { - } - } - -- EventExecutor executor = new TimedEventExecutor(EventExecutor.create(method, eventClass), plugin, method, eventClass); -+ EventExecutor executor = EventExecutor.create(method, eventClass); // Plazma - Completely remove Timings - eventSet.add(new RegisteredListener(listener, executor, eh.priority(), plugin, eh.ignoreCancelled())); - } - return ret; -diff --git a/src/main/java/io/papermc/paper/plugin/manager/PaperPluginManagerImpl.java b/src/main/java/io/papermc/paper/plugin/manager/PaperPluginManagerImpl.java -index dab211c458311869c61779305580a1c7da830f71..efa194f99807a61c02923dbaf58fac542bd9229f 100644 ---- a/src/main/java/io/papermc/paper/plugin/manager/PaperPluginManagerImpl.java -+++ b/src/main/java/io/papermc/paper/plugin/manager/PaperPluginManagerImpl.java -@@ -227,7 +227,8 @@ public class PaperPluginManagerImpl implements PluginManager, DependencyContext - - @Override - public boolean useTimings() { -- return co.aikar.timings.Timings.isTimingsEnabled(); -+ return false; -+ // return co.aikar.timings.Timings.isTimingsEnabled(); // Plazma - Completely remove Timings - } - - @Override -diff --git a/src/main/java/net/minecraft/network/protocol/PacketUtils.java b/src/main/java/net/minecraft/network/protocol/PacketUtils.java -index 620edb63cacd15e38f7fc859efd4095bfb5e5f72..85e6a5d5d3266d0d042ee62a89adbb5f0d3880e6 100644 ---- a/src/main/java/net/minecraft/network/protocol/PacketUtils.java -+++ b/src/main/java/net/minecraft/network/protocol/PacketUtils.java -@@ -49,7 +49,7 @@ public class PacketUtils { - try { // Paper - detailed watchdog information - if (listener instanceof ServerCommonPacketListenerImpl serverCommonPacketListener && serverCommonPacketListener.processedDisconnect) return; // CraftBukkit - Don't handle sync packets for kicked players - if (listener.shouldHandleMessage(packet)) { -- co.aikar.timings.Timing timing = co.aikar.timings.MinecraftTimings.getPacketTiming(packet); // Paper - timings -+ // co.aikar.timings.Timing timing = co.aikar.timings.MinecraftTimings.getPacketTiming(packet); // Paper - timings // Plazma - Completely remove Timings - try { // Paper - timings // Purpur - packet.handle(listener); - } catch (Exception exception) { -diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index 93564ba734f6b82ffde07b1321180fc24a0ff50f..25d560594d2fb38a6b94bb4b1677ff79603d5645 100644 ---- a/src/main/java/net/minecraft/server/MinecraftServer.java -+++ b/src/main/java/net/minecraft/server/MinecraftServer.java -@@ -3,7 +3,7 @@ package net.minecraft.server; - import com.google.common.base.Preconditions; - import com.google.common.base.Splitter; - import com.google.common.collect.ImmutableList; --import co.aikar.timings.Timings; -+// import co.aikar.timings.Timings; // Plazma - Completely remove Timings - import com.destroystokyo.paper.event.server.PaperServerListPingEvent; - import com.google.common.base.Stopwatch; - import com.google.common.collect.Lists; -@@ -189,7 +189,7 @@ import org.bukkit.craftbukkit.Main; - import org.bukkit.event.server.ServerLoadEvent; - // CraftBukkit end - --import co.aikar.timings.MinecraftTimings; // Paper -+//import co.aikar.timings.MinecraftTimings; // Paper // Plazma - Completely remove Timings - - public abstract class MinecraftServer extends ReentrantBlockableEventLoop implements ServerInfo, CommandSource, AutoCloseable { - -@@ -975,7 +975,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop implements FeatureElement, EntityTypeT - this(factory, spawnGroup, saveable, summonable, fireImmune, spawnableFarFromPlayer, canSpawnInside, dimensions, maxTrackDistance, trackTickInterval, requiredFeatures, "custom"); - } - public EntityType(EntityType.EntityFactory factory, MobCategory spawnGroup, boolean saveable, boolean summonable, boolean fireImmune, boolean spawnableFarFromPlayer, ImmutableSet canSpawnInside, EntityDimensions dimensions, int maxTrackDistance, int trackTickInterval, FeatureFlagSet requiredFeatures, String id) { -- this.tickTimer = co.aikar.timings.MinecraftTimings.getEntityTimings(id, "tick"); -- this.inactiveTickTimer = co.aikar.timings.MinecraftTimings.getEntityTimings(id, "inactiveTick"); -- this.passengerTickTimer = co.aikar.timings.MinecraftTimings.getEntityTimings(id, "passengerTick"); -- this.passengerInactiveTickTimer = co.aikar.timings.MinecraftTimings.getEntityTimings(id, "passengerInactiveTick"); -+ // this.tickTimer = co.aikar.timings.MinecraftTimings.getEntityTimings(id, "tick"); // Plazma - Completely remove Timings -+ // this.inactiveTickTimer = co.aikar.timings.MinecraftTimings.getEntityTimings(id, "inactiveTick"); // Plazma - Completely remove Timings -+ // this.passengerTickTimer = co.aikar.timings.MinecraftTimings.getEntityTimings(id, "passengerTick"); // Plazma - Completely remove Timings -+ // this.passengerInactiveTickTimer = co.aikar.timings.MinecraftTimings.getEntityTimings(id, "passengerInactiveTick"); // Plazma - Completely remove Timings - // Paper end - this.builtInRegistryHolder = BuiltInRegistries.ENTITY_TYPE.createIntrusiveHolder(this); - this.factory = factory; -@@ -721,10 +721,10 @@ public class EntityType implements FeatureElement, EntityTypeT - } - - // Paper start - timings -- public final co.aikar.timings.Timing tickTimer; -- public final co.aikar.timings.Timing inactiveTickTimer; -- public final co.aikar.timings.Timing passengerTickTimer; -- public final co.aikar.timings.Timing passengerInactiveTickTimer; -+ // public final co.aikar.timings.Timing tickTimer; // Plazma - Completely remove Timings -+ // public final co.aikar.timings.Timing inactiveTickTimer; // Plazma - Completely remove Timings -+ // public final co.aikar.timings.Timing passengerTickTimer; // Plazma - Completely remove Timings -+ // public final co.aikar.timings.Timing passengerInactiveTickTimer; // Plazma - Completely remove Timings - // Paper end - public boolean trackDeltas() { - return this != EntityType.PLAYER && this != EntityType.LLAMA_SPIT && this != EntityType.WITHER && this != EntityType.BAT && this != EntityType.ITEM_FRAME && this != EntityType.GLOW_ITEM_FRAME && this != EntityType.LEASH_KNOT && this != EntityType.PAINTING && this != EntityType.END_CRYSTAL && this != EntityType.EVOKER_FANGS; -diff --git a/src/main/java/net/minecraft/world/entity/ai/behavior/Behavior.java b/src/main/java/net/minecraft/world/entity/ai/behavior/Behavior.java -index 8f7d9f8a5138bcd572691d66c814aaa7c308b317..5db4a2b790680ed86a6106473d43fb0b2887f875 100644 ---- a/src/main/java/net/minecraft/world/entity/ai/behavior/Behavior.java -+++ b/src/main/java/net/minecraft/world/entity/ai/behavior/Behavior.java -@@ -16,7 +16,7 @@ public abstract class Behavior implements BehaviorContro - private final int maxDuration; - // Paper start - configurable behavior tick rate and timings - private final String configKey; -- private final co.aikar.timings.Timing timing; -+ // private final co.aikar.timings.Timing timing; // Plazma - Completely remove Timings - // Paper end - configurable behavior tick rate and timings - - public Behavior(Map, MemoryStatus> requiredMemoryState) { -@@ -38,7 +38,7 @@ public abstract class Behavior implements BehaviorContro - key = key.substring(lastSeparator + 1); - } - this.configKey = key.toLowerCase(java.util.Locale.ROOT); -- this.timing = co.aikar.timings.MinecraftTimings.getBehaviorTimings(configKey); -+ // this.timing = co.aikar.timings.MinecraftTimings.getBehaviorTimings(configKey); // Plazma - Completely remove Timings - // Paper end - configurable behavior tick rate and timings - } - -diff --git a/src/main/java/net/minecraft/world/entity/ai/sensing/Sensor.java b/src/main/java/net/minecraft/world/entity/ai/sensing/Sensor.java -index e553f52de2e0b30511ac1b73cb436374017cd7d7..21f4e5c3dd3e528f3184940a2351259a02fcb131 100644 ---- a/src/main/java/net/minecraft/world/entity/ai/sensing/Sensor.java -+++ b/src/main/java/net/minecraft/world/entity/ai/sensing/Sensor.java -@@ -28,7 +28,7 @@ public abstract class Sensor { - private long timeToTick; - // Paper start - configurable sensor tick rate and timings - private final String configKey; -- private final co.aikar.timings.Timing timing; -+ // private final co.aikar.timings.Timing timing; // Plazma - Completely remove Timings - // Paper end - - public Sensor(int senseInterval) { -@@ -39,7 +39,7 @@ public abstract class Sensor { - key = key.substring(lastSeparator + 1); - } - this.configKey = key.toLowerCase(java.util.Locale.ROOT); -- this.timing = co.aikar.timings.MinecraftTimings.getSensorTimings(configKey, senseInterval); -+ // this.timing = co.aikar.timings.MinecraftTimings.getSensorTimings(configKey, senseInterval); // Plazma - Completely remove Timings - // Paper end - this.scanRate = senseInterval; - this.timeToTick = (long)RANDOM.nextInt(senseInterval); -diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java -index 16e6716f70d5b9090f29f8b2320302d98dd087c2..c20f3dfdfb4efced687da115be0293887d69f966 100644 ---- a/src/main/java/net/minecraft/world/level/Level.java -+++ b/src/main/java/net/minecraft/world/level/Level.java -@@ -179,7 +179,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { - // Plazma end - Configurable Plazma - public final com.destroystokyo.paper.antixray.ChunkPacketBlockController chunkPacketBlockController; // Paper - Anti-Xray - public final org.purpurmc.purpur.PurpurWorldConfig purpurConfig; // Purpur -- public final co.aikar.timings.WorldTimingsHandler timings; // Paper -+ // public final co.aikar.timings.WorldTimingsHandler timings; // Paper // Plazma - Completely remove Timings - public static BlockPos lastPhysicsProblem; // Spigot - private org.spigotmc.TickLimiter entityLimiter; - private org.spigotmc.TickLimiter tileLimiter; -@@ -352,7 +352,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { - public void onBorderSetDamageSafeZOne(WorldBorder border, double safeZoneRadius) {} - }); - // CraftBukkit end -- this.timings = new co.aikar.timings.WorldTimingsHandler(this); // Paper - code below can generate new world and access timings -+ // this.timings = new co.aikar.timings.WorldTimingsHandler(this); // Paper - code below can generate new world and access timings // Plazma - Completely remove Timings - this.keepSpawnInMemory = this.paperConfig().spawn.keepSpawnLoaded; // Paper - Option to keep spawn chunks loaded - this.entityLimiter = new org.spigotmc.TickLimiter(this.spigotConfig.entityMaxTickTime); - this.tileLimiter = new org.spigotmc.TickLimiter(this.spigotConfig.tileMaxTickTime); -@@ -1362,7 +1362,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { - - //this.timings.tileEntityTick.stopTiming(); // Spigot // Purpur - this.tickingBlockEntities = false; -- co.aikar.timings.TimingHistory.tileEntityTicks += this.blockEntityTickers.size(); // Paper -+ // co.aikar.timings.TimingHistory.tileEntityTicks += this.blockEntityTickers.size(); // Paper // Plazma - Completely remove Timings - //gameprofilerfiller.pop(); // Purpur - this.spigotConfig.currentPrimedTnt = 0; // Spigot - } -diff --git a/src/main/java/net/minecraft/world/level/block/Block.java b/src/main/java/net/minecraft/world/level/block/Block.java -index 284149925440f413d23a9ec3ce704e70a74f4c08..608a00e6be7c8c5ae922aaa738f875559ab708f5 100644 ---- a/src/main/java/net/minecraft/world/level/block/Block.java -+++ b/src/main/java/net/minecraft/world/level/block/Block.java -@@ -114,6 +114,7 @@ public class Block extends BlockBehaviour implements ItemLike { - this != Blocks.STRUCTURE_BLOCK && - this != Blocks.JIGSAW; - } -+ /* // Plazma - Completely remove Timings - public co.aikar.timings.Timing timing; - public co.aikar.timings.Timing getTiming() { - if (timing == null) { -@@ -121,6 +122,7 @@ public class Block extends BlockBehaviour implements ItemLike { - } - return timing; - } -+ */ // Plazma - Completely remove Timings - // Paper end - @Nullable - private String descriptionId; -diff --git a/src/main/java/net/minecraft/world/level/block/entity/BlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/BlockEntity.java -index e9701ed4e5b35ace1accd2b46f082191d8ab6497..f2200a6098210ae3137e266a1f079ffd6971504d 100644 ---- a/src/main/java/net/minecraft/world/level/block/entity/BlockEntity.java -+++ b/src/main/java/net/minecraft/world/level/block/entity/BlockEntity.java -@@ -23,14 +23,14 @@ import org.bukkit.craftbukkit.persistence.CraftPersistentDataTypeRegistry; - import org.bukkit.inventory.InventoryHolder; - // CraftBukkit end - --import org.spigotmc.CustomTimingsHandler; // Spigot --import co.aikar.timings.MinecraftTimings; // Paper --import co.aikar.timings.Timing; // Paper -+// import org.spigotmc.CustomTimingsHandler; // Spigot // Plazma - Completely remove Timings -+// import co.aikar.timings.MinecraftTimings; // Paper // Plazma - Completely remove Timings -+// import co.aikar.timings.Timing; // Paper // Plazma - Completely remove Timings - - public abstract class BlockEntity { - static boolean ignoreTileUpdates; // Paper - Perf: Optimize Hoppers - -- public Timing tickTimer = MinecraftTimings.getTileEntityTimings(this); // Paper -+ // public Timing tickTimer = MinecraftTimings.getTileEntityTimings(this); // Paper // Plazma - Completely remove Timings - // CraftBukkit start - data containers - private static final CraftPersistentDataTypeRegistry DATA_TYPE_REGISTRY = new CraftPersistentDataTypeRegistry(); - public CraftPersistentDataContainer persistentDataContainer; -diff --git a/src/main/java/org/bukkit/craftbukkit/Main.java b/src/main/java/org/bukkit/craftbukkit/Main.java -index e8df8e8520cea5d21197c61a172f7211a3a2c34d..27a106e3844309e5b7ca12d1fd2374cf20f4ba48 100644 ---- a/src/main/java/org/bukkit/craftbukkit/Main.java -+++ b/src/main/java/org/bukkit/craftbukkit/Main.java -@@ -366,8 +366,8 @@ public class Main { - tryPreloadClass("org.jline.terminal.impl.MouseSupport"); - tryPreloadClass("org.jline.terminal.impl.MouseSupport$1"); - tryPreloadClass("org.jline.terminal.Terminal$MouseTracking"); -- tryPreloadClass("co.aikar.timings.TimingHistory"); -- tryPreloadClass("co.aikar.timings.TimingHistory$MinuteReport"); -+ // tryPreloadClass("co.aikar.timings.TimingHistory"); // Plazma - Completely remove Timings -+ // tryPreloadClass("co.aikar.timings.TimingHistory$MinuteReport"); // Plazma - Completely remove Timings - tryPreloadClass("io.netty.channel.AbstractChannelHandlerContext"); - tryPreloadClass("io.netty.channel.AbstractChannelHandlerContext$11"); - tryPreloadClass("io.netty.channel.AbstractChannelHandlerContext$12"); -diff --git a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java -index 6bab5f9e40987d1a8ca9c17118d2a14135df5dff..14fd658f987f21993f334ae1524f880e3ce12b86 100644 ---- a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java -+++ b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java -@@ -1,6 +1,6 @@ - package org.bukkit.craftbukkit.scheduler; - --import co.aikar.timings.MinecraftTimings; // Paper -+// import co.aikar.timings.MinecraftTimings; // Paper // Plazma - Completely remove Timings - import com.google.common.base.Preconditions; - import com.google.common.util.concurrent.ThreadFactoryBuilder; - import java.util.ArrayList; -@@ -304,7 +304,7 @@ public class CraftScheduler implements BukkitScheduler { - } - return false; - } -- }){{this.timings=co.aikar.timings.MinecraftTimings.getCancelTasksTimer();}}; // Paper -+ });//{{this.timings=co.aikar.timings.MinecraftTimings.getCancelTasksTimer();}}; // Paper // Plazma - Completely remove Timings - this.handle(task, 0L); - for (CraftTask taskPending = this.head.getNext(); taskPending != null; taskPending = taskPending.getNext()) { - if (taskPending == task) { -@@ -344,7 +344,7 @@ public class CraftScheduler implements BukkitScheduler { - } - } - } -- }){{this.timings=co.aikar.timings.MinecraftTimings.getCancelTasksTimer(plugin);}}; // Paper -+ });//{{this.timings=co.aikar.timings.MinecraftTimings.getCancelTasksTimer(plugin);}}; // Paper // Plazma - Completely remove Timings - this.handle(task, 0L); - for (CraftTask taskPending = this.head.getNext(); taskPending != null; taskPending = taskPending.getNext()) { - if (taskPending == task) { -diff --git a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftTask.java b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftTask.java -index 5835dc236b3f5291a804f7fb14a12eb466d4e0ba..5b943a792f6b005a094bc06f59899bd28cf576a1 100644 ---- a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftTask.java -+++ b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftTask.java -@@ -2,14 +2,14 @@ package org.bukkit.craftbukkit.scheduler; - - import java.util.function.Consumer; - --import co.aikar.timings.NullTimingHandler; -+// import co.aikar.timings.NullTimingHandler; // Plazma - Completely remove Timings - import org.bukkit.Bukkit; - import org.bukkit.plugin.Plugin; - import org.bukkit.scheduler.BukkitTask; - --import org.spigotmc.CustomTimingsHandler; // Spigot --import co.aikar.timings.MinecraftTimings; // Paper --import co.aikar.timings.Timing; // Paper -+// import org.spigotmc.CustomTimingsHandler; // Spigot // Plazma - Completely remove Timings -+// import co.aikar.timings.MinecraftTimings; // Paper // Plazma - Completely remove Timings -+// import co.aikar.timings.Timing; // Paper // Plazma - Completely remove Timings - - public class CraftTask implements BukkitTask, Runnable { // Spigot - -@@ -31,7 +31,7 @@ public class CraftTask implements BukkitTask, Runnable { // Spigot - private long nextRun; - public final Runnable rTask; // Paper - public final Consumer cTask; // Paper -- public Timing timings; // Paper -+ // public Timing timings; // Paper // Plazma - Completely remove Timings - private final Plugin plugin; - private final int id; - private final long createdAt = System.nanoTime(); -@@ -55,7 +55,7 @@ public class CraftTask implements BukkitTask, Runnable { // Spigot - this.id = id; - this.period = CraftTask.NO_REPEATING; - this.taskName = taskName; -- this.timings = MinecraftTimings.getInternalTaskName(taskName); -+ // this.timings = MinecraftTimings.getInternalTaskName(taskName); // Plazma - Completely remove Timings - } - // Paper end - -@@ -76,7 +76,7 @@ public class CraftTask implements BukkitTask, Runnable { // Spigot - } - this.id = id; - this.period = period; -- timings = task != null ? MinecraftTimings.getPluginTaskTimings(this, period) : NullTimingHandler.NULL; // Paper -+ // timings = task != null ? MinecraftTimings.getPluginTaskTimings(this, period) : NullTimingHandler.NULL; // Paper // Plazma - Completely remove Timings - } - - @Override -diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java -index e29dc1101c7aa4b7b2a2d2e732e27a1a14a2a234..544d6f4831341802ac156080e30b2b500cd9f0da 100644 ---- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java -+++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java -@@ -217,7 +217,7 @@ public final class CraftMagicNumbers implements UnsafeValues { - // Paper start - @Override - public void reportTimings() { -- co.aikar.timings.TimingsExport.reportTimings(); -+ //co.aikar.timings.TimingsExport.reportTimings(); // Plazma - Completely remove Timings - } - // Paper end - -@@ -495,9 +495,9 @@ public final class CraftMagicNumbers implements UnsafeValues { - return new CraftDamageSourceBuilder(damageType); - } - // Paper start -- @Override -+ @Override @Deprecated // Plazma - Completely remove Timings - public String getTimingsServerName() { -- return io.papermc.paper.configuration.GlobalConfiguration.get().timings.serverName; -+ return null; //io.papermc.paper.configuration.GlobalConfiguration.get().timings.serverName; // Plazma - Completely remove Timings - } - - @Override -diff --git a/src/main/java/org/spigotmc/ActivationRange.java b/src/main/java/org/spigotmc/ActivationRange.java -index 56e52b16b419c882440a15947f037ae1a902bc70..e0e1c873703c1d3482d5bc82294490a44dd3a7a9 100644 ---- a/src/main/java/org/spigotmc/ActivationRange.java -+++ b/src/main/java/org/spigotmc/ActivationRange.java -@@ -35,7 +35,7 @@ import net.minecraft.world.entity.projectile.FireworkRocketEntity; - import net.minecraft.world.entity.projectile.ThrowableProjectile; - import net.minecraft.world.entity.projectile.ThrownTrident; - import net.minecraft.world.entity.raid.Raider; --import co.aikar.timings.MinecraftTimings; -+// import co.aikar.timings.MinecraftTimings; // Plazma - Completely remove Timings - import net.minecraft.world.entity.schedule.Activity; - import net.minecraft.world.level.Level; - import net.minecraft.world.phys.AABB; diff --git a/patches/unapplied/server/dropped/0038-Async-PathProcessing.patch b/patches/unapplied/server/dropped/0038-Async-PathProcessing.patch deleted file mode 100644 index ba58eeef7..000000000 --- a/patches/unapplied/server/dropped/0038-Async-PathProcessing.patch +++ /dev/null @@ -1,1178 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: AlphaKR93 -Date: Thu, 11 Jan 2024 14:06:28 +0900 -Subject: [PATCH] Async PathProcessing - - -diff --git a/src/main/java/net/minecraft/world/entity/ai/behavior/AcquirePoi.java b/src/main/java/net/minecraft/world/entity/ai/behavior/AcquirePoi.java -index abcc3ef59475ac170fd10b4dd4a4f3371faf17e0..4d9f3df83c1f30b7cd9446679429a7e6243a3287 100644 ---- a/src/main/java/net/minecraft/world/entity/ai/behavior/AcquirePoi.java -+++ b/src/main/java/net/minecraft/world/entity/ai/behavior/AcquirePoi.java -@@ -68,6 +68,31 @@ public class AcquirePoi { - io.papermc.paper.util.PoiAccess.findNearestPoiPositions(poiManager, poiPredicate, predicate2, entity.blockPosition(), 48, 48*48, PoiManager.Occupancy.HAS_SPACE, false, 5, poiposes); - Set, BlockPos>> set = new java.util.HashSet<>(poiposes); - // Paper end - optimise POI access -+ // Plazma start - Async PathProcessing -+ if (entity.level().plazmaConfig().entity.pathProcessing.enabled) { -+ org.plazmamc.plazma.entity.path.AsyncPathProcessor.await(findPathToPois(entity, set), path -> { -+ if (path == null || !path.canReach()) { -+ for (Pair, BlockPos> pair : set) { -+ long2ObjectMap.computeIfAbsent( -+ pair.getSecond().asLong(), -+ m -> new JitteredLinearRetry(entity.level().getRandom(), time) -+ ); -+ } -+ return; -+ } -+ -+ BlockPos pos = path.getTarget(); -+ poiManager.getType(pos).ifPresent(type -> { -+ poiManager.take(poiPredicate, (holder, blockPos2) -> blockPos2.equals(pos), pos, 1); -+ queryResult.set(GlobalPos.of(world.dimension(), pos)); -+ entityStatus.ifPresent(status -> world.broadcastEntityEvent(entity, status)); -+ long2ObjectMap.clear(); -+ DebugPackets.sendPoiTicketCountPacket(world, pos); -+ }); -+ }); -+ return true; -+ } -+ // Plazma end - Path path = findPathToPois(entity, set); - if (path != null && path.canReach()) { - BlockPos blockPos = path.getTarget(); -diff --git a/src/main/java/net/minecraft/world/entity/ai/behavior/MoveToTargetSink.java b/src/main/java/net/minecraft/world/entity/ai/behavior/MoveToTargetSink.java -index 1ab77f3518d1df30f66ae44d7d4fa69e5b32d93a..a5e202a1bca5648cc42912c0bbe6f8610a8c0aaf 100644 ---- a/src/main/java/net/minecraft/world/entity/ai/behavior/MoveToTargetSink.java -+++ b/src/main/java/net/minecraft/world/entity/ai/behavior/MoveToTargetSink.java -@@ -1,6 +1,8 @@ - package net.minecraft.world.entity.ai.behavior; - - import com.google.common.collect.ImmutableMap; -+ -+import java.util.Objects; - import java.util.Optional; - import javax.annotation.Nullable; - import net.minecraft.core.BlockPos; -@@ -21,6 +23,7 @@ public class MoveToTargetSink extends Behavior { - private int remainingCooldown; - @Nullable - private Path path; -+ private boolean finishedProcess; // Plazma - @Nullable - private BlockPos lastTargetPos; - private float speedModifier; -@@ -42,9 +45,11 @@ public class MoveToTargetSink extends Behavior { - Brain brain = entity.getBrain(); - WalkTarget walkTarget = brain.getMemory(MemoryModuleType.WALK_TARGET).get(); - boolean bl = this.reachedTarget(entity, walkTarget); -- if (!bl && this.tryComputePath(entity, walkTarget, world.getGameTime())) { -+ if (!world.plazmaConfig().entity.pathProcessing.enabled && !bl && this.tryComputePath(entity, walkTarget, world.getGameTime())) { // Plazma - this.lastTargetPos = walkTarget.getTarget().currentBlockPosition(); - return true; -+ } else if (world.plazmaConfig().entity.pathProcessing.enabled && !bl) { // Plazma -+ return true; // Plazma - } else { - brain.eraseMemory(MemoryModuleType.WALK_TARGET); - if (bl) { -@@ -58,6 +63,7 @@ public class MoveToTargetSink extends Behavior { - - @Override - protected boolean canStillUse(ServerLevel world, Mob entity, long time) { -+ if (world.plazmaConfig().entity.pathProcessing.enabled && !this.finishedProcess) return true; // Plazma - if (this.path != null && this.lastTargetPos != null) { - Optional optional = entity.getBrain().getMemory(MemoryModuleType.WALK_TARGET); - boolean bl = optional.map(MoveToTargetSink::isWalkTargetSpectator).orElse(false); -@@ -82,12 +88,66 @@ public class MoveToTargetSink extends Behavior { - - @Override - protected void start(ServerLevel serverLevel, Mob mob, long l) { -+ // Plazma start -+ if (serverLevel.plazmaConfig().entity.pathProcessing.enabled) { -+ Brain brain = mob.getBrain(); -+ WalkTarget target = brain.getMemory(MemoryModuleType.WALK_TARGET).orElse(null); -+ -+ this.finishedProcess = false; -+ this.lastTargetPos = Objects.requireNonNull(target).getTarget().currentBlockPosition(); -+ this.path = this.computePath(mob, target); -+ return; -+ } -+ // Plazma end - mob.getBrain().setMemory(MemoryModuleType.PATH, this.path); - mob.getNavigation().moveTo(this.path, (double)this.speedModifier); - } - - @Override - protected void tick(ServerLevel serverLevel, Mob mob, long l) { -+ // Plazma start - Async PathProcessing -+ if (serverLevel.plazmaConfig().entity.pathProcessing.enabled) { -+ if (this.path != null && !this.path.isProcessed()) return; // wait for processing -+ -+ Brain brain = mob.getBrain(); -+ if (!this.finishedProcess) { -+ this.finishedProcess = true; -+ -+ boolean canReach = this.path != null && this.path.canReach(); -+ -+ if (canReach) -+ brain.eraseMemory(MemoryModuleType.CANT_REACH_WALK_TARGET_SINCE); -+ else { -+ if (brain.hasMemoryValue(MemoryModuleType.CANT_REACH_WALK_TARGET_SINCE)) -+ brain.setMemory(MemoryModuleType.CANT_REACH_WALK_TARGET_SINCE, l); -+ -+ Optional target = brain.getMemory(MemoryModuleType.WALK_TARGET); -+ if (target.isEmpty()) return; -+ -+ BlockPos pos = target.get().getTarget().currentBlockPosition(); -+ Vec3 vec3 = DefaultRandomPos.getPosTowards((PathfinderMob)mob, 10, 7, Vec3.atBottomCenterOf(pos), (float)Math.PI / 2F); -+ -+ if (vec3 != null) { -+ this.path = mob.getNavigation().createPath(vec3.x, vec3.y, vec3.z, 0); -+ this.finishedProcess = false; -+ return; -+ } -+ } -+ -+ mob.getBrain().setMemory(MemoryModuleType.PATH, this.path); -+ mob.getNavigation().moveTo(this.path, this.speedModifier); -+ } -+ -+ Path path = mob.getNavigation().getPath(); -+ if (path != null && this.lastTargetPos != null && brain.hasMemoryValue(MemoryModuleType.WALK_TARGET)) { -+ WalkTarget target = brain.getMemory(MemoryModuleType.WALK_TARGET).orElseThrow(); // should be present -+ if (target.getTarget().currentBlockPosition().distSqr(this.lastTargetPos) > 4.0D) -+ this.start(serverLevel, mob, l); -+ } -+ return; -+ } -+ // Plazma end -+ - Path path = mob.getNavigation().getPath(); - Brain brain = mob.getBrain(); - if (this.path != path) { -@@ -105,6 +165,20 @@ public class MoveToTargetSink extends Behavior { - } - } - -+ // Plazma start - Async PathProcessing -+ @Nullable -+ private Path computePath(Mob entity, WalkTarget target) { -+ BlockPos pos = target.getTarget().currentBlockPosition(); -+ this.speedModifier = target.getSpeedModifier(); -+ -+ Brain brain = entity.getBrain(); -+ if (this.reachedTarget(entity, target)) -+ brain.eraseMemory(MemoryModuleType.CANT_REACH_WALK_TARGET_SINCE); -+ -+ return entity.getNavigation().createPath(pos, 0); -+ } -+ // Plazma end -+ - private boolean tryComputePath(Mob entity, WalkTarget walkTarget, long time) { - BlockPos blockPos = walkTarget.getTarget().currentBlockPosition(); - this.path = entity.getNavigation().createPath(blockPos, 0); -diff --git a/src/main/java/net/minecraft/world/entity/ai/behavior/SetClosestHomeAsWalkTarget.java b/src/main/java/net/minecraft/world/entity/ai/behavior/SetClosestHomeAsWalkTarget.java -index 271efbb027f6f5d69ac5bc5dc51102a1eb00ab31..4924b9d921455c061d9ff0e5f291f0df3c27a2c8 100644 ---- a/src/main/java/net/minecraft/world/entity/ai/behavior/SetClosestHomeAsWalkTarget.java -+++ b/src/main/java/net/minecraft/world/entity/ai/behavior/SetClosestHomeAsWalkTarget.java -@@ -57,6 +57,23 @@ public class SetClosestHomeAsWalkTarget { - Set, BlockPos>> set = poiManager.findAllWithType((poiType) -> { - return poiType.is(PoiTypes.HOME); - }, predicate, entity.blockPosition(), 48, PoiManager.Occupancy.ANY).collect(Collectors.toSet()); -+ // Plazma start - Async PathProcessing -+ if (entity.level().plazmaConfig().entity.pathProcessing.enabled) { -+ org.plazmamc.plazma.entity.path.AsyncPathProcessor.await(AcquirePoi.findPathToPois(entity, set), path -> { -+ if (path == null || !path.canReach() || mutableInt.getValue() < 5) { -+ long2LongMap.long2LongEntrySet().removeIf(entry -> entry.getLongValue() < mutableLong.getValue()); -+ return; -+ } -+ BlockPos pos = path.getTarget(); -+ Optional> optionalPoi = poiManager.getType(pos); -+ if (optionalPoi.isPresent()) { -+ walkTarget.set(new WalkTarget(pos, speed, 1)); -+ DebugPackets.sendPoiTicketCountPacket(world, pos); -+ } -+ }); -+ return true; -+ } -+ // Plazma end - Path path = AcquirePoi.findPathToPois(entity, set); - if (path != null && path.canReach()) { - BlockPos blockPos = path.getTarget(); -diff --git a/src/main/java/net/minecraft/world/entity/ai/goal/DoorInteractGoal.java b/src/main/java/net/minecraft/world/entity/ai/goal/DoorInteractGoal.java -index 6771f2dc974317b6b152288bf41d1a95bc78a8e4..788008b36cb18a3a6ff0182570e38393828bfe3a 100644 ---- a/src/main/java/net/minecraft/world/entity/ai/goal/DoorInteractGoal.java -+++ b/src/main/java/net/minecraft/world/entity/ai/goal/DoorInteractGoal.java -@@ -57,7 +57,7 @@ public abstract class DoorInteractGoal extends Goal { - } else { - GroundPathNavigation groundPathNavigation = (GroundPathNavigation)this.mob.getNavigation(); - Path path = groundPathNavigation.getPath(); -- if (path != null && !path.isDone() && groundPathNavigation.canOpenDoors()) { -+ if (path != null && path.isProcessed() && !path.isDone() && groundPathNavigation.canOpenDoors()) { // Plazma - Async PathProcessing - for(int i = 0; i < Math.min(path.getNextNodeIndex() + 2, path.getNodeCount()); ++i) { - Node node = path.getNode(i); - this.doorPos = new BlockPos(node.x, node.y + 1, node.z); -diff --git a/src/main/java/net/minecraft/world/entity/ai/navigation/AmphibiousPathNavigation.java b/src/main/java/net/minecraft/world/entity/ai/navigation/AmphibiousPathNavigation.java -index 9d3b32c852d660356e0f16d4cc10072b1c603e64..4a998ec6153de462f43380b5efa31946337cc226 100644 ---- a/src/main/java/net/minecraft/world/entity/ai/navigation/AmphibiousPathNavigation.java -+++ b/src/main/java/net/minecraft/world/entity/ai/navigation/AmphibiousPathNavigation.java -@@ -12,10 +12,23 @@ public class AmphibiousPathNavigation extends PathNavigation { - super(mob, world); - } - -+ // Plazma start - Async PathProcessing -+ private static final org.plazmamc.plazma.entity.path.evaluator.NodeEvaluatorGenerator generator = -+ (org.plazmamc.plazma.entity.path.evaluator.NodeEvaluatorFeatures features) -> { -+ AmphibiousNodeEvaluator evaluator = new AmphibiousNodeEvaluator(false); -+ evaluator.setCanPassDoors(features.canPassDoors()); -+ evaluator.setCanFloat(features.canFloat()); -+ evaluator.setCanWalkOverFences(features.canWalkOverFences()); -+ evaluator.setCanOpenDoors(features.canOpenDoors()); -+ return evaluator; -+ }; -+ // Plazma end -+ - @Override - protected PathFinder createPathFinder(int range) { - this.nodeEvaluator = new AmphibiousNodeEvaluator(false); - this.nodeEvaluator.setCanPassDoors(true); -+ if (this.level.plazmaConfig().entity.pathProcessing.enabled) return new PathFinder(this.nodeEvaluator, range, generator); // Plazma - return new PathFinder(this.nodeEvaluator, range); - } - -diff --git a/src/main/java/net/minecraft/world/entity/ai/navigation/FlyingPathNavigation.java b/src/main/java/net/minecraft/world/entity/ai/navigation/FlyingPathNavigation.java -index 027eef4ace908147285c8d72b612d16e4f925672..83db744d95a106c52381485d6d8d51db4ca17685 100644 ---- a/src/main/java/net/minecraft/world/entity/ai/navigation/FlyingPathNavigation.java -+++ b/src/main/java/net/minecraft/world/entity/ai/navigation/FlyingPathNavigation.java -@@ -16,10 +16,23 @@ public class FlyingPathNavigation extends PathNavigation { - super(entity, world); - } - -+ // Plazma start -+ private static final org.plazmamc.plazma.entity.path.evaluator.NodeEvaluatorGenerator generator = -+ (org.plazmamc.plazma.entity.path.evaluator.NodeEvaluatorFeatures features) -> { -+ FlyNodeEvaluator evaluator = new FlyNodeEvaluator(); -+ evaluator.setCanPassDoors(features.canPassDoors()); -+ evaluator.setCanOpenDoors(features.canOpenDoors()); -+ evaluator.setCanFloat(features.canFloat()); -+ evaluator.setCanWalkOverFences(features.canWalkOverFences()); -+ return evaluator; -+ }; -+ // Plazma end -+ - @Override - protected PathFinder createPathFinder(int range) { - this.nodeEvaluator = new FlyNodeEvaluator(); - this.nodeEvaluator.setCanPassDoors(true); -+ if (this.level.plazmaConfig().entity.pathProcessing.enabled) return new PathFinder(this.nodeEvaluator, range, generator); // Plazma - return new PathFinder(this.nodeEvaluator, range); - } - -@@ -50,6 +63,7 @@ public class FlyingPathNavigation extends PathNavigation { - this.recomputePath(); - } - -+ if (this.path != null && !this.path.isProcessed()) return; // Plazma - if (!this.isDone()) { - if (this.canUpdatePath()) { - this.followThePath(); -diff --git a/src/main/java/net/minecraft/world/entity/ai/navigation/GroundPathNavigation.java b/src/main/java/net/minecraft/world/entity/ai/navigation/GroundPathNavigation.java -index ac996b066415e461af1fcb71b19807401179c7f8..e9bcbd5a99462e8c8d1ab3029bcaaaddbb42e365 100644 ---- a/src/main/java/net/minecraft/world/entity/ai/navigation/GroundPathNavigation.java -+++ b/src/main/java/net/minecraft/world/entity/ai/navigation/GroundPathNavigation.java -@@ -23,10 +23,26 @@ public class GroundPathNavigation extends PathNavigation { - super(entity, world); - } - -+ // Plazma start - Async PathProcessing -+ protected static org.plazmamc.plazma.entity.path.evaluator.NodeEvaluatorGenerator evaluatorGenerator() { -+ return generator; -+ } -+ private static final org.plazmamc.plazma.entity.path.evaluator.NodeEvaluatorGenerator generator = -+ (org.plazmamc.plazma.entity.path.evaluator.NodeEvaluatorFeatures features) -> { -+ WalkNodeEvaluator evaluator = new WalkNodeEvaluator(); -+ evaluator.setCanPassDoors(features.canPassDoors()); -+ evaluator.setCanOpenDoors(features.canOpenDoors()); -+ evaluator.setCanFloat(features.canFloat()); -+ evaluator.setCanWalkOverFences(features.canWalkOverFences()); -+ return evaluator; -+ }; -+ // Plazma end -+ - @Override - protected PathFinder createPathFinder(int range) { - this.nodeEvaluator = new WalkNodeEvaluator(); - this.nodeEvaluator.setCanPassDoors(true); -+ if (this.level.plazmaConfig().entity.pathProcessing.enabled) return new PathFinder(this.nodeEvaluator, range, generator); // Plazma - return new PathFinder(this.nodeEvaluator, range); - } - -diff --git a/src/main/java/net/minecraft/world/entity/ai/navigation/PathNavigation.java b/src/main/java/net/minecraft/world/entity/ai/navigation/PathNavigation.java -index 0e36e3e672de4c806e2d534b437489a3a349a722..e1c89b31ac928afe9dffdc857cfa246e3db40114 100644 ---- a/src/main/java/net/minecraft/world/entity/ai/navigation/PathNavigation.java -+++ b/src/main/java/net/minecraft/world/entity/ai/navigation/PathNavigation.java -@@ -152,6 +152,8 @@ public abstract class PathNavigation { - return null; - } else if (!this.canUpdatePath()) { - return null; -+ } else if (this.path instanceof org.plazmamc.plazma.entity.path.AsyncPath async && !async.isProcessed() && async.hasSamePositions(positions)) { // Plazma -+ return this.path; // Plazma - } else if (this.path != null && !this.path.isDone() && positions.contains(this.targetPos)) { - return this.path; - } else { -@@ -177,6 +179,23 @@ public abstract class PathNavigation { - int i = (int)(followRange + (float)range); - PathNavigationRegion pathNavigationRegion = new PathNavigationRegion(this.level, blockPos.offset(-i, -i, -i), blockPos.offset(i, i, i)); - Path path = this.pathFinder.findPath(pathNavigationRegion, this.mob, positions, followRange, distance, this.maxVisitedNodesMultiplier); -+ // Plazma start -+ if (this.level.plazmaConfig().entity.pathProcessing.enabled) { -+ if (!positions.isEmpty()) this.targetPos = positions.iterator().next(); -+ -+ org.plazmamc.plazma.entity.path.AsyncPathProcessor.await(path, processed -> { -+ if (processed != this.path) return; -+ -+ //noinspection ConstantValue -+ if (processed != null && processed.getTarget() != null) { -+ this.targetPos = processed.getTarget(); -+ this.reachRange = distance; -+ this.resetStuckTimeout(); -+ } -+ }); -+ return path; -+ } -+ // Plazma end - //this.level.getProfiler().pop(); // Purpur - if (path != null && path.getTarget() != null) { - this.targetPos = path.getTarget(); -@@ -229,8 +248,8 @@ public abstract class PathNavigation { - if (this.isDone()) { - return false; - } else { -- this.trimPath(); -- if (this.path.getNodeCount() <= 0) { -+ if (path.isProcessed()) this.trimPath(); // Plazma -+ if (path.isProcessed() && this.path.getNodeCount() <= 0) { // Plazma - return false; - } else { - this.speedModifier = speed; -@@ -254,6 +273,7 @@ public abstract class PathNavigation { - this.recomputePath(); - } - -+ if (this.path != null && !this.path.isProcessed()) return; // Plazma - if (!this.isDone()) { - if (this.canUpdatePath()) { - this.followThePath(); -@@ -279,6 +299,7 @@ public abstract class PathNavigation { - } - - protected void followThePath() { -+ if (!this.path.isProcessed()) return; // Plazma - Vec3 vec3 = this.getTempMobPos(); - this.maxDistanceToWaypoint = this.mob.getBbWidth() > 0.75F ? this.mob.getBbWidth() / 2.0F : 0.75F - this.mob.getBbWidth() / 2.0F; - Vec3i vec3i = this.path.getNextNodePos(); -@@ -434,7 +455,7 @@ public abstract class PathNavigation { - public boolean shouldRecomputePath(BlockPos pos) { - if (this.hasDelayedRecomputation) { - return false; -- } else if (this.path != null && !this.path.isDone() && this.path.getNodeCount() != 0) { -+ } else if (this.path != null && this.path.isProcessed() && !this.path.isDone() && this.path.getNodeCount() != 0) { // Plazma - Node node = this.path.getEndNode(); - Vec3 vec3 = new Vec3(((double)node.x + this.mob.getX()) / 2.0D, ((double)node.y + this.mob.getY()) / 2.0D, ((double)node.z + this.mob.getZ()) / 2.0D); - return pos.closerToCenterThan(vec3, (double)(this.path.getNodeCount() - this.path.getNextNodeIndex())); -diff --git a/src/main/java/net/minecraft/world/entity/ai/navigation/WaterBoundPathNavigation.java b/src/main/java/net/minecraft/world/entity/ai/navigation/WaterBoundPathNavigation.java -index ee8543afbbd681bf327a353530a7a635aa5ef592..ac685819a1ebbd6db6685c7de11ed75b325e9f6a 100644 ---- a/src/main/java/net/minecraft/world/entity/ai/navigation/WaterBoundPathNavigation.java -+++ b/src/main/java/net/minecraft/world/entity/ai/navigation/WaterBoundPathNavigation.java -@@ -15,10 +15,23 @@ public class WaterBoundPathNavigation extends PathNavigation { - super(entity, world); - } - -+ // Plazma start - Async PathProcessing -+ private static final org.plazmamc.plazma.entity.path.evaluator.NodeEvaluatorGenerator generator = -+ (org.plazmamc.plazma.entity.path.evaluator.NodeEvaluatorFeatures features) -> { -+ SwimNodeEvaluator evaluator = new SwimNodeEvaluator(features.allowBreaching()); -+ evaluator.setCanPassDoors(features.canPassDoors()); -+ evaluator.setCanFloat(features.canFloat()); -+ evaluator.setCanWalkOverFences(features.canWalkOverFences()); -+ evaluator.setCanOpenDoors(features.canOpenDoors()); -+ return evaluator; -+ }; -+ // Plazma end -+ - @Override - protected PathFinder createPathFinder(int range) { - this.allowBreaching = this.mob.getType() == EntityType.DOLPHIN; - this.nodeEvaluator = new SwimNodeEvaluator(this.allowBreaching); -+ if (this.level.plazmaConfig().entity.pathProcessing.enabled) return new PathFinder(this.nodeEvaluator, range, generator); // Plazma - Async PathProcessing - return new PathFinder(this.nodeEvaluator, range); - } - -diff --git a/src/main/java/net/minecraft/world/entity/ai/sensing/NearestBedSensor.java b/src/main/java/net/minecraft/world/entity/ai/sensing/NearestBedSensor.java -index 8db20db72cd51046213625fac46c35854c59ec5d..51755c966cc9c778f746bc0f972d88870821c180 100644 ---- a/src/main/java/net/minecraft/world/entity/ai/sensing/NearestBedSensor.java -+++ b/src/main/java/net/minecraft/world/entity/ai/sensing/NearestBedSensor.java -@@ -57,6 +57,27 @@ public class NearestBedSensor extends Sensor { - java.util.List, BlockPos>> poiposes = new java.util.ArrayList<>(); - // don't ask me why it's unbounded. ask mojang. - io.papermc.paper.util.PoiAccess.findAnyPoiPositions(poiManager, type -> type.is(PoiTypes.HOME), predicate, entity.blockPosition(), 48, PoiManager.Occupancy.ANY, false, Integer.MAX_VALUE, poiposes); -+ -+ // Plazma start -+ if (world.plazmaConfig().entity.pathProcessing.enabled) { -+ Path possible = AcquirePoi.findPathToPois(entity, new java.util.HashSet<>(poiposes)); -+ org.plazmamc.plazma.entity.path.AsyncPathProcessor.await(possible, path -> { -+ //read canReach check -+ if ((path == null || !path.canReach()) && this.triedCount < 5) { -+ this.batchCache.long2LongEntrySet().removeIf(entry -> entry.getLongValue() < this.lastUpdate); -+ return; -+ } -+ if (path == null) return; -+ -+ BlockPos pos = path.getTarget(); -+ Optional> optional = poiManager.getType(pos); -+ -+ if (optional.isPresent()) entity.getBrain().setMemory(MemoryModuleType.NEAREST_BED, pos); -+ }); -+ return; -+ } -+ // Plazma end -+ - Path path = AcquirePoi.findPathToPois(entity, new java.util.HashSet<>(poiposes)); - // Paper end - optimise POI access - if (path != null && path.canReach()) { -diff --git a/src/main/java/net/minecraft/world/entity/animal/Bee.java b/src/main/java/net/minecraft/world/entity/animal/Bee.java -index 8f28c80cdb15005ddc0886581cd457e880f1f71c..8c341e6b67a601139053b99acb0fdb69848162dc 100644 ---- a/src/main/java/net/minecraft/world/entity/animal/Bee.java -+++ b/src/main/java/net/minecraft/world/entity/animal/Bee.java -@@ -1155,6 +1155,7 @@ public class Bee extends Animal implements NeutralMob, FlyingAnimal { - Bee.this.pathfindRandomlyTowards(Bee.this.hivePos); - } - } else { -+ if (navigation.getPath() == null || !navigation.getPath().isProcessed()) return; // Plazma - boolean flag = this.pathfindDirectlyTowards(Bee.this.hivePos); - - if (!flag) { -@@ -1216,7 +1217,7 @@ public class Bee extends Animal implements NeutralMob, FlyingAnimal { - } else { - Path pathentity = Bee.this.navigation.getPath(); - -- return pathentity != null && pathentity.getTarget().equals(pos) && pathentity.canReach() && pathentity.isDone(); -+ return pathentity != null && pathentity.isProcessed() && pathentity.getTarget().equals(pos) && pathentity.canReach() && pathentity.isDone(); // Plazma - Async PathProcessing - } - } - } -diff --git a/src/main/java/net/minecraft/world/entity/animal/frog/Frog.java b/src/main/java/net/minecraft/world/entity/animal/frog/Frog.java -index de5b3f19eea5f63732905fc1f2c95b05c720d134..0123fd94e1f415dd2dcc8262ada7ca8732cd75ea 100644 ---- a/src/main/java/net/minecraft/world/entity/animal/frog/Frog.java -+++ b/src/main/java/net/minecraft/world/entity/animal/frog/Frog.java -@@ -455,6 +455,18 @@ public class Frog extends Animal implements VariantHolder { - super(frog, world); - } - -+ // Plazma start - Async PathProcessing -+ private static final org.plazmamc.plazma.entity.path.evaluator.NodeEvaluatorGenerator generator = -+ (org.plazmamc.plazma.entity.path.evaluator.NodeEvaluatorFeatures features) -> { -+ FrogNodeEvaluator evaluator = new FrogNodeEvaluator(true); -+ evaluator.setCanPassDoors(features.canPassDoors()); -+ evaluator.setCanFloat(features.canFloat()); -+ evaluator.setCanWalkOverFences(features.canWalkOverFences()); -+ evaluator.setCanOpenDoors(features.canOpenDoors()); -+ return evaluator; -+ }; -+ // Plazma end -+ - @Override - public boolean canCutCorner(BlockPathTypes nodeType) { - return nodeType != BlockPathTypes.WATER_BORDER && super.canCutCorner(nodeType); -@@ -464,6 +476,7 @@ public class Frog extends Animal implements VariantHolder { - protected PathFinder createPathFinder(int range) { - this.nodeEvaluator = new Frog.FrogNodeEvaluator(true); - this.nodeEvaluator.setCanPassDoors(true); -+ if (this.level.plazmaConfig().entity.pathProcessing.enabled) return new PathFinder(this.nodeEvaluator, range, generator); // Plazma - return new PathFinder(this.nodeEvaluator, range); - } - } -diff --git a/src/main/java/net/minecraft/world/entity/monster/Drowned.java b/src/main/java/net/minecraft/world/entity/monster/Drowned.java -index 034bb2d1292dde6276885c3ea71d886c3894311c..7b0daf88a0f841ce23b01faf0bcc29a8bcc5795f 100644 ---- a/src/main/java/net/minecraft/world/entity/monster/Drowned.java -+++ b/src/main/java/net/minecraft/world/entity/monster/Drowned.java -@@ -293,7 +293,7 @@ public class Drowned extends Zombie implements RangedAttackMob { - protected boolean closeToNextPos() { - Path pathentity = this.getNavigation().getPath(); - -- if (pathentity != null) { -+ if (pathentity != null && pathentity.isProcessed()) { // Plazma - Async PathProcessing - BlockPos blockposition = pathentity.getTarget(); - - if (blockposition != null) { -diff --git a/src/main/java/net/minecraft/world/entity/monster/Strider.java b/src/main/java/net/minecraft/world/entity/monster/Strider.java -index 2f49b528601a1feb7246fe7a9b83ce828c2d78fc..23d3eb11ac84a1eac53690f6d5acceed01fb5f05 100644 ---- a/src/main/java/net/minecraft/world/entity/monster/Strider.java -+++ b/src/main/java/net/minecraft/world/entity/monster/Strider.java -@@ -100,6 +100,18 @@ public class Strider extends Animal implements ItemSteerable, Saddleable { - this.setPathfindingMalus(BlockPathTypes.DAMAGE_FIRE, 0.0F); - } - -+ // Plazma start -+ private static final org.plazmamc.plazma.entity.path.evaluator.NodeEvaluatorGenerator generator = -+ (org.plazmamc.plazma.entity.path.evaluator.NodeEvaluatorFeatures features) -> { -+ WalkNodeEvaluator evaluator = new WalkNodeEvaluator(); -+ evaluator.setCanPassDoors(features.canPassDoors()); -+ evaluator.setCanFloat(features.canFloat()); -+ evaluator.setCanWalkOverFences(features.canWalkOverFences()); -+ evaluator.setCanOpenDoors(features.canOpenDoors()); -+ return evaluator; -+ }; -+ // Plazma end -+ - // Purpur start - @Override - public boolean isRidable() { -@@ -613,6 +625,7 @@ public class Strider extends Animal implements ItemSteerable, Saddleable { - protected PathFinder createPathFinder(int range) { - this.nodeEvaluator = new WalkNodeEvaluator(); - this.nodeEvaluator.setCanPassDoors(true); -+ if (this.level.plazmaConfig().entity.pathProcessing.enabled) return new PathFinder(this.nodeEvaluator, range, generator); // Plazma - Async PathProcessing - return new PathFinder(this.nodeEvaluator, range); - } - -diff --git a/src/main/java/net/minecraft/world/entity/monster/warden/Warden.java b/src/main/java/net/minecraft/world/entity/monster/warden/Warden.java -index 0386aeaeee04b62cc30badb30dd6dcd34d6045b7..060203a6fd246224cbf59e39bf3dc29118b43892 100644 ---- a/src/main/java/net/minecraft/world/entity/monster/warden/Warden.java -+++ b/src/main/java/net/minecraft/world/entity/monster/warden/Warden.java -@@ -642,6 +642,15 @@ public class Warden extends Monster implements VibrationSystem { - protected PathFinder createPathFinder(int range) { - this.nodeEvaluator = new WalkNodeEvaluator(); - this.nodeEvaluator.setCanPassDoors(true); -+ // Plazma start -+ if (this.level.plazmaConfig().entity.pathProcessing.enabled) -+ return new PathFinder(this.nodeEvaluator, range, GroundPathNavigation.evaluatorGenerator()) { -+ @Override -+ protected float distance(Node a, Node b) { -+ return a.distanceToXZ(b); -+ } -+ }; -+ // Plazma end - return new PathFinder(this.nodeEvaluator, range) { - @Override - protected float distance(Node a, Node b) { -diff --git a/src/main/java/net/minecraft/world/level/pathfinder/Path.java b/src/main/java/net/minecraft/world/level/pathfinder/Path.java -index eea4c932d909145e7af848cf76e3f49dbb2deff2..8983dfdf3644d353462714c99809c99d66f8a7df 100644 ---- a/src/main/java/net/minecraft/world/level/pathfinder/Path.java -+++ b/src/main/java/net/minecraft/world/level/pathfinder/Path.java -@@ -27,6 +27,12 @@ public class Path { - this.reached = reachesTarget; - } - -+ // Plazma start - Async PathProcessing -+ public boolean isProcessed() { -+ return true; -+ } -+ // Plazma end -+ - public void advance() { - ++this.nextNodeIndex; - } -@@ -101,6 +107,7 @@ public class Path { - } - - public boolean sameAs(@Nullable Path o) { -+ if (o == this) return true; // Plazma - if (o == null) { - return false; - } else if (o.nodes.size() != this.nodes.size()) { -diff --git a/src/main/java/net/minecraft/world/level/pathfinder/PathFinder.java b/src/main/java/net/minecraft/world/level/pathfinder/PathFinder.java -index b9689131a7a46b46c0b75b86f2bb163d7de74921..1e718cfbb826d617bb724a41047327a53ffbdedf 100644 ---- a/src/main/java/net/minecraft/world/level/pathfinder/PathFinder.java -+++ b/src/main/java/net/minecraft/world/level/pathfinder/PathFinder.java -@@ -24,35 +24,71 @@ public class PathFinder { - public final NodeEvaluator nodeEvaluator; - private static final boolean DEBUG = false; - private final BinaryHeap openSet = new BinaryHeap(); -+ // Plazma start - Support NodeEvaluatorGenerator -+ private final @Nullable org.plazmamc.plazma.entity.path.evaluator.NodeEvaluatorGenerator generator; // we use this later to generate an evaluator - - public PathFinder(NodeEvaluator pathNodeMaker, int range) { -+ this(pathNodeMaker, range, null); -+ } -+ -+ public PathFinder(NodeEvaluator pathNodeMaker, int range, @Nullable org.plazmamc.plazma.entity.path.evaluator.NodeEvaluatorGenerator generator) { - this.nodeEvaluator = pathNodeMaker; - this.maxVisitedNodes = range; -+ this.generator = generator; - } -+ // Plazma end - - @Nullable - public Path findPath(PathNavigationRegion world, Mob mob, Set positions, float followRange, int distance, float rangeMultiplier) { -- this.openSet.clear(); -- this.nodeEvaluator.prepare(world, mob); -- Node node = this.nodeEvaluator.getStart(); -+ // Plazma start -+ //noinspection resource -+ if (!mob.level().plazmaConfig().entity.pathProcessing.enabled) this.openSet.clear(); -+ NodeEvaluator evaluator = this.generator == null ? this.nodeEvaluator : org.plazmamc.plazma.entity.path.evaluator.NodeEvaluatorCache.takeEvaluator(this.generator, this.nodeEvaluator); -+ evaluator.prepare(world, mob); -+ Node node = evaluator.getStart(); -+ //noinspection ConstantValue - if (node == null) { -+ org.plazmamc.plazma.entity.path.evaluator.NodeEvaluatorCache.returnEvaluator(evaluator); -+ // Plazma end - return null; - } else { - // Paper start - remove streams - and optimize collection - List> map = Lists.newArrayList(); - for (BlockPos pos : positions) { -- map.add(new java.util.AbstractMap.SimpleEntry<>(this.nodeEvaluator.getGoal(pos.getX(), pos.getY(), pos.getZ()), pos)); -+ map.add(new java.util.AbstractMap.SimpleEntry<>(evaluator.getGoal(pos.getX(), pos.getY(), pos.getZ()), pos)); // Plazma - } - // Paper end -- Path path = this.findPath(/*world.getProfiler(), */node, map, followRange, distance, rangeMultiplier); // Plazma - Completely remove profiler -- this.nodeEvaluator.done(); -- return path; -+ -+ if (this.generator == null) { -+ // it needs sync :( -+ org.plazmamc.plazma.entity.path.evaluator.NodeEvaluatorCache.removeEvaluator(evaluator); -+ return this.findPath(/*world.getProfiler(), */node, map, followRange, distance, rangeMultiplier); // Plazma - Completely remove profiler -+ } -+ -+ return new org.plazmamc.plazma.entity.path.AsyncPath(Lists.newArrayList(), positions, () -> { -+ try { -+ return this.processPath(evaluator, node, map, followRange, distance, rangeMultiplier); -+ } finally { -+ this.nodeEvaluator.done(); -+ } -+ }); - } - } - -- @Nullable -+ // Plazma start - Async PathProcessing -+ //@Nullable // Plazma - Always not null - // Paper start - optimize collection - private Path findPath(/*ProfilerFiller profiler, */Node startNode, List> positions, float followRange, int distance, float rangeMultiplier) { // Plazma - Completely remove profiler -+ try { -+ return this.processPath(this.nodeEvaluator, startNode, positions, followRange, distance, rangeMultiplier); -+ } finally { -+ this.nodeEvaluator.done(); -+ } -+ } -+ -+ private synchronized Path processPath(NodeEvaluator evaluator, Node startNode, List> positions, float followRange, int distance, float rangeMultiplier) { -+ org.apache.commons.lang3.Validate.isTrue(!positions.isEmpty()); // ensure that we have at least one position, which means we'll always return a path -+ // Plazma end - //profiler.push("find_path"); // Purpur - //profiler.markForCharting(MetricCategory.PATH_FINDING); // Purpur - // Set set = positions.keySet(); -@@ -76,8 +112,7 @@ public class PathFinder { - node.closed = true; - - // Paper start - optimize collection -- for(int i1 = 0; i1 < positions.size(); i1++) { -- final Map.Entry entry = positions.get(i1); -+ for (final Map.Entry entry : positions) { // Plazma - Improved for loop - Target target = entry.getKey(); - if (node.distanceManhattan(target) <= (float)distance) { - target.setReached(); -@@ -91,7 +126,7 @@ public class PathFinder { - } - - if (!(node.distanceTo(startNode) >= followRange)) { -- int k = this.nodeEvaluator.getNeighbors(this.neighbors, node); -+ int k = evaluator.getNeighbors(this.neighbors, node); // Plazma - - for(int l = 0; l < k; ++l) { - Node node2 = this.neighbors[l]; -@@ -123,7 +158,7 @@ public class PathFinder { - if (best == null || comparator.compare(path, best) < 0) - best = path; - } -- return best; -+ return java.util.Objects.requireNonNull(best); // Plazma - NotNull - // Paper end - } - -@@ -135,8 +170,8 @@ public class PathFinder { - float f = Float.MAX_VALUE; - - // Paper start - optimize collection -- for (int i = 0, targetsSize = targets.size(); i < targetsSize; i++) { -- final Target target = targets.get(i).getKey(); -+ for (Map.Entry targetBlockPosEntry : targets) { // Plazma - Improved for loop -+ final Target target = targetBlockPosEntry.getKey(); - // Paper end - float g = node.distanceTo(target); - target.updateBest(g, node); -diff --git a/src/main/java/net/minecraft/world/level/pathfinder/SwimNodeEvaluator.java b/src/main/java/net/minecraft/world/level/pathfinder/SwimNodeEvaluator.java -index 0e2b14e7dfedf209d63279c81723fd7955122d78..49bc50ea74a59e67a6d43ff9a68c17e97a30fbe4 100644 ---- a/src/main/java/net/minecraft/world/level/pathfinder/SwimNodeEvaluator.java -+++ b/src/main/java/net/minecraft/world/level/pathfinder/SwimNodeEvaluator.java -@@ -18,6 +18,7 @@ import net.minecraft.world.level.material.FluidState; - public class SwimNodeEvaluator extends NodeEvaluator { - private final boolean allowBreaching; - private final Long2ObjectMap pathTypesByPosCache = new Long2ObjectOpenHashMap<>(); -+ public boolean canJumpOutOfWater() { return this.allowBreaching; } // Plazma - Getter - - public SwimNodeEvaluator(boolean canJumpOutOfWater) { - this.allowBreaching = canJumpOutOfWater; -diff --git a/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java b/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java -index c83125338d0eea86c65a42450367b084c3c9df44..98f7a83628cdbe3e48cfefd14e29386a5ede3de1 100644 ---- a/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java -+++ b/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java -@@ -3,6 +3,7 @@ package org.plazmamc.plazma.configurations; - import io.papermc.paper.configuration.Configuration; - import io.papermc.paper.configuration.ConfigurationPart; - import org.jetbrains.annotations.NotNull; -+import org.spongepowered.configurate.objectmapping.meta.PostProcess; - import org.spongepowered.configurate.objectmapping.meta.Setting; - - @SuppressWarnings({"CanBeFinal", "FieldCanBeLocal", "FieldMayBeFinal", "InnerClassMayBeStatic"}) -@@ -65,6 +66,35 @@ public class GlobalConfiguration extends ConfigurationPart { - - } - -+ public Entity entity; -+ public class Entity extends ConfigurationPart { -+ -+ public AsyncPathProcessing pathProcessing; -+ public class AsyncPathProcessing extends ConfigurationPart { -+ -+ public boolean enabled = OPTIMIZE; -+ public int maxThreads = 0; -+ public int keepAlive = 60; -+ -+ @PostProcess -+ public void post() { -+ -+ if (maxThreads < 0) -+ maxThreads = Math.max(Runtime.getRuntime().availableProcessors() + maxThreads, 1); -+ else if (maxThreads == 0) -+ maxThreads = Math.max(Runtime.getRuntime().availableProcessors() / 4, 1); -+ -+ if (!enabled) -+ maxThreads = 0; -+ else -+ org.bukkit.Bukkit.getLogger().log(java.util.logging.Level.INFO, "Using " + maxThreads + " threads for async path processing"); -+ -+ } -+ -+ } -+ -+ } -+ - public ConsoleLogs consoleLogs; - public class ConsoleLogs extends ConfigurationPart { - -diff --git a/src/main/java/org/plazmamc/plazma/configurations/WorldConfigurations.java b/src/main/java/org/plazmamc/plazma/configurations/WorldConfigurations.java -index e5e0b0f0bd3b2249dc1db029682b8957b0addcac..1514ed0bed4189f0ad631cb7d9b70d63e88db1da 100644 ---- a/src/main/java/org/plazmamc/plazma/configurations/WorldConfigurations.java -+++ b/src/main/java/org/plazmamc/plazma/configurations/WorldConfigurations.java -@@ -3,6 +3,7 @@ package org.plazmamc.plazma.configurations; - import io.papermc.paper.configuration.Configuration; - import io.papermc.paper.configuration.ConfigurationPart; - import net.minecraft.resources.ResourceLocation; -+import org.spongepowered.configurate.objectmapping.meta.PostProcess; - import org.spongepowered.configurate.objectmapping.meta.Setting; - - @SuppressWarnings({"CanBeFinal", "FieldCanBeLocal", "FieldMayBeFinal", "InnerClassMayBeStatic"}) -@@ -62,6 +63,18 @@ public class WorldConfigurations extends ConfigurationPart { - - } - -+ public AsyncPathProcessing pathProcessing; -+ public class AsyncPathProcessing extends ConfigurationPart { -+ -+ public boolean enabled = GlobalConfiguration.get().entity.pathProcessing.enabled; -+ -+ @PostProcess -+ public void post() { -+ this.enabled = this.enabled && GlobalConfiguration.get().entity.pathProcessing.enabled; -+ } -+ -+ } -+ - } - - public Structure structure; -diff --git a/src/main/java/org/plazmamc/plazma/entity/path/AsyncPath.java b/src/main/java/org/plazmamc/plazma/entity/path/AsyncPath.java -new file mode 100644 -index 0000000000000000000000000000000000000000..cc694930e2c307d15cf951be33567657b27bb3d7 ---- /dev/null -+++ b/src/main/java/org/plazmamc/plazma/entity/path/AsyncPath.java -@@ -0,0 +1,196 @@ -+package org.plazmamc.plazma.entity.path; -+ -+import net.minecraft.core.BlockPos; -+import net.minecraft.world.entity.Entity; -+import net.minecraft.world.level.pathfinder.Node; -+import net.minecraft.world.level.pathfinder.Path; -+import net.minecraft.world.phys.Vec3; -+import org.checkerframework.framework.qual.DefaultQualifier; -+import org.jetbrains.annotations.NotNull; -+import org.jetbrains.annotations.Nullable; -+import java.util.ArrayList; -+import java.util.List; -+import java.util.Objects; -+import java.util.Set; -+import java.util.function.Supplier; -+ -+@DefaultQualifier(NotNull.class) -+public class AsyncPath extends Path { -+ -+ private final List postProcessors = new ArrayList<>(); -+ private final Set positions; -+ private final Supplier supplier; -+ private final List nodes; -+ -+ private volatile boolean processed = false; -+ private @Nullable BlockPos target; -+ private boolean canReach = true; -+ private float distToTarget = 0; -+ -+ public AsyncPath(final List emptyNodes, final Set positions, final Supplier supplier) { -+ //noinspection DataFlowIssue -+ super(emptyNodes, null, false); -+ -+ this.nodes = emptyNodes; -+ this.positions = positions; -+ this.supplier = supplier; -+ -+ AsyncPathProcessor.queue(this); -+ } -+ -+ @Override -+ public boolean isProcessed() { -+ return this.processed; -+ } -+ -+ public synchronized void postProcess(Runnable runnable) { -+ if (this.processed) runnable.run(); -+ else this.postProcessors.add(runnable); -+ } -+ -+ public boolean hasSamePositions(final Set positions) { -+ if (this.positions.size() != positions.size()) return false; -+ return this.positions.containsAll(positions); -+ } -+ -+ public synchronized void process() { -+ if (this.processed) return; -+ -+ final Path best = this.supplier.get(); -+ -+ this.nodes.addAll(best.nodes); -+ this.target = best.getTarget(); -+ this.distToTarget = best.getDistToTarget(); -+ this.canReach = best.canReach(); -+ -+ this.processed = true; -+ -+ this.postProcessors.forEach(Runnable::run); -+ } -+ -+ private void checkProcessed() { -+ if (!this.processed) this.process(); -+ } -+ -+ @Override -+ public BlockPos getTarget() { -+ this.checkProcessed(); -+ return Objects.requireNonNull(this.target); -+ } -+ -+ @Override -+ public float getDistToTarget() { -+ this.checkProcessed(); -+ return this.distToTarget; -+ } -+ -+ @Override -+ public boolean canReach() { -+ this.checkProcessed(); -+ return this.canReach; -+ } -+ -+ @Override -+ public boolean isDone() { -+ return this.isProcessed() && super.isDone(); -+ } -+ -+ @Override -+ public void advance() { -+ this.checkProcessed(); -+ super.advance(); -+ } -+ -+ @Override -+ public boolean notStarted() { -+ this.checkProcessed(); -+ return super.notStarted(); -+ } -+ -+ @Override -+ @Nullable -+ public Node getEndNode() { -+ this.checkProcessed(); -+ return super.getEndNode(); -+ } -+ -+ @Override -+ public Node getNode(final int index) { -+ this.checkProcessed(); -+ return super.getNode(index); -+ } -+ -+ @Override -+ public void truncateNodes(final int length) { -+ this.checkProcessed(); -+ super.truncateNodes(length); -+ } -+ -+ @Override -+ public void replaceNode(final int index, final Node node) { -+ this.checkProcessed(); -+ super.replaceNode(index, node); -+ } -+ -+ @Override -+ public int getNodeCount() { -+ this.checkProcessed(); -+ return super.getNodeCount(); -+ } -+ -+ @Override -+ public int getNextNodeIndex() { -+ this.checkProcessed(); -+ return super.getNextNodeIndex(); -+ } -+ -+ @Override -+ public void setNextNodeIndex(final int nodeIndex) { -+ this.checkProcessed(); -+ super.setNextNodeIndex(nodeIndex); -+ } -+ -+ @Override -+ public Vec3 getEntityPosAtNode(final Entity entity, final int index) { -+ this.checkProcessed(); -+ return super.getEntityPosAtNode(entity, index); -+ } -+ -+ @Override -+ public BlockPos getNodePos(final int index) { -+ this.checkProcessed(); -+ return super.getNodePos(index); -+ } -+ -+ @Override -+ public Vec3 getNextEntityPos(final Entity entity) { -+ this.checkProcessed(); -+ return super.getNextEntityPos(entity); -+ } -+ -+ @Override -+ public BlockPos getNextNodePos() { -+ this.checkProcessed(); -+ return super.getNextNodePos(); -+ } -+ -+ @Override -+ public Node getNextNode() { -+ this.checkProcessed(); -+ return super.getNextNode(); -+ } -+ -+ @Override -+ @Nullable -+ public Node getPreviousNode() { -+ this.checkProcessed(); -+ return super.getPreviousNode(); -+ } -+ -+ @Override -+ public boolean hasNext() { -+ this.checkProcessed(); -+ return super.hasNext(); -+ } -+ -+} -diff --git a/src/main/java/org/plazmamc/plazma/entity/path/AsyncPathProcessor.java b/src/main/java/org/plazmamc/plazma/entity/path/AsyncPathProcessor.java -new file mode 100644 -index 0000000000000000000000000000000000000000..5226688dc961ab7588cd2f6e7ef80eac7df53118 ---- /dev/null -+++ b/src/main/java/org/plazmamc/plazma/entity/path/AsyncPathProcessor.java -@@ -0,0 +1,43 @@ -+package org.plazmamc.plazma.entity.path; -+ -+import com.google.common.util.concurrent.ThreadFactoryBuilder; -+import net.minecraft.server.MinecraftServer; -+import net.minecraft.world.level.pathfinder.Path; -+import org.checkerframework.framework.qual.DefaultQualifier; -+import org.jetbrains.annotations.NotNull; -+import org.jetbrains.annotations.Nullable; -+import org.plazmamc.plazma.configurations.GlobalConfiguration; -+import java.util.concurrent.CompletableFuture; -+import java.util.concurrent.Executor; -+import java.util.concurrent.LinkedBlockingQueue; -+import java.util.concurrent.ThreadPoolExecutor; -+import java.util.concurrent.TimeUnit; -+import java.util.function.Consumer; -+ -+@DefaultQualifier(NotNull.class) -+public class AsyncPathProcessor { -+ -+ private static final Executor mainExecutor = MinecraftServer.getServer(); -+ private static final Executor pathExecutor = new ThreadPoolExecutor( -+ 1, -+ GlobalConfiguration.get().entity.pathProcessing.maxThreads, -+ GlobalConfiguration.get().entity.pathProcessing.keepAlive, TimeUnit.SECONDS, -+ new LinkedBlockingQueue<>(), -+ new ThreadFactoryBuilder() -+ .setNameFormat("plazma-path-processor-%d") -+ .setPriority(Thread.NORM_PRIORITY - 2) -+ .build() -+ ); -+ -+ protected static CompletableFuture queue(AsyncPath path) { -+ return CompletableFuture.runAsync(path::process, pathExecutor); -+ } -+ -+ public static void await(@Nullable Path path, Consumer<@Nullable Path> after) { -+ if (path != null && !path.isProcessed() && path instanceof AsyncPath async) -+ async.postProcess(() -> mainExecutor.execute(() -> after.accept(path))); -+ else -+ after.accept(path); -+ } -+ -+} -diff --git a/src/main/java/org/plazmamc/plazma/entity/path/evaluator/NodeEvaluatorCache.java b/src/main/java/org/plazmamc/plazma/entity/path/evaluator/NodeEvaluatorCache.java -new file mode 100644 -index 0000000000000000000000000000000000000000..9acfa55778419ad86dbff5c70a2944c7e31818dd ---- /dev/null -+++ b/src/main/java/org/plazmamc/plazma/entity/path/evaluator/NodeEvaluatorCache.java -@@ -0,0 +1,44 @@ -+package org.plazmamc.plazma.entity.path.evaluator; -+ -+import net.minecraft.world.level.pathfinder.NodeEvaluator; -+import org.checkerframework.framework.qual.DefaultQualifier; -+import org.jetbrains.annotations.NotNull; -+import org.jetbrains.annotations.Nullable; -+import java.util.Map; -+import java.util.Queue; -+import java.util.concurrent.ConcurrentHashMap; -+import java.util.concurrent.ConcurrentLinkedQueue; -+ -+@DefaultQualifier(NotNull.class) -+public class NodeEvaluatorCache { -+ -+ private static final Map> threadLocalEvaluators = new ConcurrentHashMap<>(); -+ private static final Map evaluatorGenerator = new ConcurrentHashMap<>(); -+ -+ private static Queue getQueue(final NodeEvaluatorFeatures features) { -+ return threadLocalEvaluators.computeIfAbsent(features, f -> new ConcurrentLinkedQueue<>()); -+ } -+ -+ public static NodeEvaluator takeEvaluator(final NodeEvaluatorGenerator generator, final NodeEvaluator localEvaluator) { -+ final NodeEvaluatorFeatures features = NodeEvaluatorFeatures.fromEvaluator(localEvaluator); -+ -+ @Nullable NodeEvaluator evaluator = getQueue(features).poll(); -+ if (evaluator == null) evaluator = generator.generate(features); -+ -+ evaluatorGenerator.put(evaluator, generator); -+ return evaluator; -+ } -+ -+ public static void returnEvaluator(final NodeEvaluator evaluator) { -+ final NodeEvaluatorGenerator generator = evaluatorGenerator.remove(evaluator); -+ if (generator == null) return; -+ -+ final NodeEvaluatorFeatures features = NodeEvaluatorFeatures.fromEvaluator(evaluator); -+ getQueue(features).offer(evaluator); -+ } -+ -+ public static void removeEvaluator(final NodeEvaluator evaluator) { -+ evaluatorGenerator.remove(evaluator); -+ } -+ -+} -diff --git a/src/main/java/org/plazmamc/plazma/entity/path/evaluator/NodeEvaluatorFeatures.java b/src/main/java/org/plazmamc/plazma/entity/path/evaluator/NodeEvaluatorFeatures.java -new file mode 100644 -index 0000000000000000000000000000000000000000..dc238f15e1a93b18188d6e22ecbef30dcb741e12 ---- /dev/null -+++ b/src/main/java/org/plazmamc/plazma/entity/path/evaluator/NodeEvaluatorFeatures.java -@@ -0,0 +1,31 @@ -+package org.plazmamc.plazma.entity.path.evaluator; -+ -+import net.minecraft.world.level.pathfinder.NodeEvaluator; -+import net.minecraft.world.level.pathfinder.SwimNodeEvaluator; -+import org.jetbrains.annotations.Contract; -+import org.jetbrains.annotations.NotNull; -+ -+public record NodeEvaluatorFeatures( -+ NodeEvaluatorType type, -+ boolean canPassDoors, -+ boolean canFloat, -+ boolean canWalkOverFences, -+ boolean canOpenDoors, -+ boolean allowBreaching -+) { -+ -+ @Contract("_ -> new") -+ public static @NotNull NodeEvaluatorFeatures fromEvaluator(NodeEvaluator evaluator) { -+ -+ return new NodeEvaluatorFeatures( -+ NodeEvaluatorType.fromEvaluator(evaluator), -+ evaluator.canPassDoors(), -+ evaluator.canFloat(), -+ evaluator.canWalkOverFences(), -+ evaluator.canOpenDoors(), -+ evaluator instanceof SwimNodeEvaluator swim && swim.canJumpOutOfWater() -+ ); -+ -+ } -+ -+} -diff --git a/src/main/java/org/plazmamc/plazma/entity/path/evaluator/NodeEvaluatorGenerator.java b/src/main/java/org/plazmamc/plazma/entity/path/evaluator/NodeEvaluatorGenerator.java -new file mode 100644 -index 0000000000000000000000000000000000000000..17282ff1d7a13c0f0dac2dbbd53e3cdd7817b882 ---- /dev/null -+++ b/src/main/java/org/plazmamc/plazma/entity/path/evaluator/NodeEvaluatorGenerator.java -@@ -0,0 +1,10 @@ -+package org.plazmamc.plazma.entity.path.evaluator; -+ -+import net.minecraft.world.level.pathfinder.NodeEvaluator; -+import org.jetbrains.annotations.NotNull; -+ -+public interface NodeEvaluatorGenerator { -+ -+ @NotNull NodeEvaluator generate(NodeEvaluatorFeatures features); -+ -+} -diff --git a/src/main/java/org/plazmamc/plazma/entity/path/evaluator/NodeEvaluatorType.java b/src/main/java/org/plazmamc/plazma/entity/path/evaluator/NodeEvaluatorType.java -new file mode 100644 -index 0000000000000000000000000000000000000000..5e0eed93f376e26dd84c970198dc022dcfdb2c7b ---- /dev/null -+++ b/src/main/java/org/plazmamc/plazma/entity/path/evaluator/NodeEvaluatorType.java -@@ -0,0 +1,22 @@ -+package org.plazmamc.plazma.entity.path.evaluator; -+ -+import net.minecraft.world.level.pathfinder.AmphibiousNodeEvaluator; -+import net.minecraft.world.level.pathfinder.FlyNodeEvaluator; -+import net.minecraft.world.level.pathfinder.NodeEvaluator; -+import net.minecraft.world.level.pathfinder.SwimNodeEvaluator; -+import net.minecraft.world.level.pathfinder.WalkNodeEvaluator; -+ -+public enum NodeEvaluatorType { -+ WALK, -+ SWIM, -+ AMPHIBIOUS, -+ FLY; -+ -+ public static NodeEvaluatorType fromEvaluator(NodeEvaluator evaluator) { -+ if (evaluator instanceof SwimNodeEvaluator) return SWIM; -+ if (evaluator instanceof FlyNodeEvaluator) return FLY; -+ if (evaluator instanceof AmphibiousNodeEvaluator) return AMPHIBIOUS; -+ if (evaluator instanceof WalkNodeEvaluator) return WALK; -+ throw new IllegalArgumentException("Unknown evaluator type"); -+ } -+} diff --git a/patches/placeholder/server/.gitkeep b/patches/unapplied/server/placeholder/.gitkeep similarity index 100% rename from patches/placeholder/server/.gitkeep rename to patches/unapplied/server/placeholder/.gitkeep diff --git a/settings.gradle.kts b/settings.gradle.kts index 2a341ead2..e6031b307 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -25,7 +25,8 @@ dependencyResolutionManagement { } rootProject.name = projectName.lowercase() -for (name in listOf("$projectName-API", "$projectName-Server", "$projectName-MojangAPI")) { +for (name in listOf("$projectName-API", "$projectName-Server")) { + if (!rootDir.resolve("$name/MIT.txt").isFile) continue val projName = name.lowercase(Locale.ENGLISH) include(projName) findProject(":$projName")!!.projectDir = file(name) diff --git a/upstream b/upstream new file mode 120000 index 000000000..a5542abfa --- /dev/null +++ b/upstream @@ -0,0 +1 @@ +.gradle/caches/paperweight/upstreams/paper \ No newline at end of file