diff --git a/.github/workflows/pr-build.yml b/.github/workflows/pr-build.yml index 2aa834b..cb7293a 100644 --- a/.github/workflows/pr-build.yml +++ b/.github/workflows/pr-build.yml @@ -9,37 +9,37 @@ jobs: strategy: matrix: - java: [16] + java: [17] fail-fast: true steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v2 - - name: Set up JDK ${{ matrix.java }} - uses: actions/setup-java@v2 - with: - java-version: ${{ matrix.java }} - distribution: 'adopt' + - name: Set up JDK ${{ matrix.java }} + uses: actions/setup-java@v2 + with: + java-version: ${{ matrix.java }} + distribution: 'adopt' - - name: Cache gradle - uses: actions/cache@v2 - with: - path: | - ~/.gradle/caches - ~/.gradle/jdks - ~/.gradle/native - ~/.gradle/wrapper - key: ${{ runner.os }}-parchment-2-${{ hashFiles('**/*.gradle*', 'gradle/**', 'gradle.properties') }} - restore-keys: ${{ runner.os }}-parchment-2 + - name: Cache gradle + uses: actions/cache@v2 + with: + path: | + ~/.gradle/caches + ~/.gradle/jdks + ~/.gradle/native + ~/.gradle/wrapper + key: ${{ runner.os }}-parchment-2-${{ hashFiles('**/*.gradle*', 'gradle/**', 'gradle.properties') }} + restore-keys: ${{ runner.os }}-parchment-2 - - name: Patch Parchment - run: | - git config --global user.email "no-reply@github.com" - git config --global user.name "GitHub Actions" - ./gradlew applyPatches - ./gradlew paperclipJar + - name: Patch Parchment + run: | + git config --global user.email "no-reply@github.com" + git config --global user.name "GitHub Actions" + ./gradlew applyPatches + ./gradlew createReobfPaperclipJar - - uses: actions/upload-artifact@v2 - with: - name: Parchment-PR${{ github.event.pull_request.number }}-JDK${{ matrix.java }} - path: build/libs/Parchment-*.jar + - uses: actions/upload-artifact@v2 + with: + name: Parchment-PR${{ github.event.pull_request.number }}-JDK${{ matrix.java }} + path: build/libs/parchment-paperclip-*-reobf.jar diff --git a/.github/workflows/push-build.yml b/.github/workflows/push-build.yml index dba9332..fcadd62 100644 --- a/.github/workflows/push-build.yml +++ b/.github/workflows/push-build.yml @@ -9,7 +9,7 @@ jobs: strategy: matrix: - java: [16] + java: [17] fail-fast: true steps: @@ -37,9 +37,9 @@ jobs: git config --global user.email "no-reply@github.com" git config --global user.name "GitHub Actions" ./gradlew applyPatches - ./gradlew paperclipJar + ./gradlew createReobfPaperclipJar - uses: actions/upload-artifact@v2 with: name: Parchment-JDK${{ matrix.java }} - path: build/libs/Parchment-*.jar + path: build/libs/parchment-paperclip-*-reobf.jar diff --git a/.gitignore b/.gitignore index c053360..7dd15a4 100644 --- a/.gitignore +++ b/.gitignore @@ -45,8 +45,10 @@ out/ # other stuff run/ -Parchment-Server -Parchment-API +/Parchment-Server/ +/parchment-server/ +/Parchment-API/ +/parchment-api/ # Compiled class file *.class diff --git a/Parchment-Common/build.gradle.kts b/Parchment-Common/build.gradle.kts deleted file mode 100644 index fc00571..0000000 --- a/Parchment-Common/build.gradle.kts +++ /dev/null @@ -1,41 +0,0 @@ -import java.util.Locale -import java.net.URI - -plugins { - `maven-publish` -} - -java { - withSourcesJar() - withJavadocJar() -} - -dependencies { - val annotations = "org.jetbrains:annotations:21.0.1" - compileOnly(annotations) - testCompileOnly(annotations) -} - -configure { - publications.create("maven") { - from(components["java"]) - groupId = project.group as String? - artifactId = "Parchment-Common" - version = "1.17-R0.1-SNAPSHOT" - - pom { - name.set(project.name) - description.set("Common annotations for Parchment and other software") - } - } - - repositories { - maven { - credentials { - username = properties["edenusr"] as String? - password = properties["edenpwd"] as String? - } - url = URI.create("https://sonatype.projecteden.gg/repository/maven-snapshots/") - } - } -} \ No newline at end of file diff --git a/Parchment-Common/src/main/java/me/lexikiq/HasUniqueId.java b/Parchment-Common/src/main/java/me/lexikiq/HasUniqueId.java deleted file mode 100644 index c061535..0000000 --- a/Parchment-Common/src/main/java/me/lexikiq/HasUniqueId.java +++ /dev/null @@ -1,17 +0,0 @@ -package me.lexikiq; - -import org.jetbrains.annotations.NotNull; - -import java.util.UUID; - -/** - * Represents an object that has a {@link UUID} - */ -public interface HasUniqueId extends OptionalUniqueId { - /** - * Returns a unique and persistent id for this object - * - * @return unique id - */ - @NotNull UUID getUniqueId(); // named getUniqueId to maintain compatibility with Bukkit -} diff --git a/Parchment-Common/src/main/java/me/lexikiq/OptionalUniqueId.java b/Parchment-Common/src/main/java/me/lexikiq/OptionalUniqueId.java deleted file mode 100644 index 337800e..0000000 --- a/Parchment-Common/src/main/java/me/lexikiq/OptionalUniqueId.java +++ /dev/null @@ -1,17 +0,0 @@ -package me.lexikiq; - -import org.jetbrains.annotations.Nullable; - -import java.util.UUID; - -/** - * Represents an object that may have a {@link UUID} - */ -public interface OptionalUniqueId { - /** - * Returns a unique and persistent id for this object which may be null - * - * @return unique id or null - */ - @Nullable UUID getUniqueId(); // named getUniqueId to maintain compatibility with Bukkit -} diff --git a/build.gradle.kts b/build.gradle.kts index dffd096..4239885 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -3,8 +3,8 @@ import io.papermc.paperweight.util.constants.* plugins { java `maven-publish` - id("com.github.johnrengelman.shadow") version "7.1.0" apply false - id("io.papermc.paperweight.patcher") version "1.2.0" + id("com.github.johnrengelman.shadow") version "7.1.2" apply false + id("io.papermc.paperweight.patcher") version "1.3.7" } repositories { @@ -15,9 +15,9 @@ repositories { } dependencies { - remapper("net.fabricmc:tiny-remapper:0.6.0:fat") - decompiler("net.minecraftforge:forgeflower:1.5.498.12") - paperclip("io.papermc:paperclip:2.0.1") + remapper("net.fabricmc:tiny-remapper:0.8.2:fat") + decompiler("net.minecraftforge:forgeflower:1.5.605.7") + paperclip("io.papermc:paperclip:3.0.2") } allprojects { @@ -26,15 +26,15 @@ allprojects { java { toolchain { - languageVersion.set(JavaLanguageVersion.of(16)) + languageVersion.set(JavaLanguageVersion.of(17)) } } } subprojects { - tasks.withType().configureEach { + tasks.withType { options.encoding = Charsets.UTF_8.name() - options.release.set(16) + options.release.set(17) } tasks.withType { options.encoding = Charsets.UTF_8.name() @@ -46,11 +46,16 @@ subprojects { repositories { mavenCentral() maven("https://papermc.io/repo/repository/maven-public/") + maven("https://sonatype.projecteden.gg/repository/maven-public/") + } + + dependencies { + implementation("gg.projecteden:eden-interfaces:2.1.0-SNAPSHOT") } } paperweight { - serverProject.set(project(":Parchment-Server")) + serverProject.set(project(":parchment-server")) remapRepo.set("https://maven.fabricmc.net/") decompileRepo.set("https://files.minecraftforge.net/maven/") @@ -58,10 +63,10 @@ paperweight { usePaperUpstream(providers.gradleProperty("paperRef")) { withPaperPatcher { apiPatchDir.set(layout.projectDirectory.dir("patches/api")) - apiOutputDir.set(layout.projectDirectory.dir("Parchment-API")) + apiOutputDir.set(layout.projectDirectory.dir("parchment-api")) serverPatchDir.set(layout.projectDirectory.dir("patches/server")) - serverOutputDir.set(layout.projectDirectory.dir("Parchment-Server")) + serverOutputDir.set(layout.projectDirectory.dir("parchment-server")) } } } @@ -71,16 +76,16 @@ paperweight { // tasks.generateDevelopmentBundle { - apiCoordinates.set("me.lexikiq:parchment-api") + apiCoordinates.set("gg.projecteden.parchment:parchment-api") mojangApiCoordinates.set("io.papermc.paper:paper-mojangapi") libraryRepositories.set( - listOf( - "https://repo.maven.apache.org/maven2/", - "https://libraries.minecraft.net/", - "https://papermc.io/repo/repository/maven-public/", - "https://maven.quiltmc.org/repository/release/", - "https://sonatype.projecteden.gg/repository/maven-public/" - ) + listOf( + "https://repo.maven.apache.org/maven2/", + "https://libraries.minecraft.net/", + "https://papermc.io/repo/repository/maven-public/", + "https://maven.quiltmc.org/repository/release/", + "https://sonatype.projecteden.gg/repository/maven-public/" + ) ) } diff --git a/createUpstreamCommit.sh b/createUpstreamCommit.sh new file mode 100755 index 0000000..b89a4c0 --- /dev/null +++ b/createUpstreamCommit.sh @@ -0,0 +1,53 @@ +#!/usr/bin/env bash + +# requires curl & jq +# borrowed from https://github.com/PurpurMC/Purpur which is licensed under the MIT license + +# createUpstreamCommit --paper HASH +# flag: --paper HASH - the commit hash to use for comparing commits between paper (PaperMC/Paper/compare/HASH...HEAD) + +function getCommits() { + echo "$(curl -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/"$1"/compare/"$2"...HEAD | jq -r '.commits[] | "'"$1"'@\(.sha[:7]) \(.commit.message | split("\r\n")[0] | split("\n")[0])"')" +} + +( +set -e +PS1="$" + +paperHash="" + +TEMP=$(getopt --long paper: -o "" -- "$@") +eval set -- "$TEMP" +while true; do + case "$1" in + --paper) + paperHash="$2" + shift 2 + ;; + *) + break + ;; + esac +done + +paper="" +updated="" +logsuffix="" + +# Paper updates +if [ -n "$paperHash" ]; then + paper=$(getCommits "PaperMC/Paper" "$paperHash") + + # Updates found + if [ -n "$paper" ]; then + updated="Paper" + logsuffix="$logsuffix\n\nPaper Changes:\n$paper" + fi +fi + +disclaimer="Upstream has released updates that appear to apply and compile correctly" +log="Updated Upstream ($updated)\n\n${disclaimer}${logsuffix}" + +echo -e "$log" | git commit -a -F - + +) || exit 1 \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 39b97eb..f013a30 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,9 +1,9 @@ -group = me.lexikiq -version = 1.17.1-R0.1-SNAPSHOT +group = gg.projecteden.parchment +version = 1.19-R0.1-SNAPSHOT -mcVersion = 1.17.1 -paperRef = 6625db387ea9fe5296a6c6f984975b387c3089f0 +mcVersion = 1.19 +paperRef = ed9cf5ca087991f38d9926665f268dece213a1e6 org.gradle.caching=true org.gradle.parallel=true -org.gradle.vfs.watch=false \ No newline at end of file +org.gradle.vfs.watch=false diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index e750102..aa991fc 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/patches/api/0002-Add-Getter-interfaces.patch b/patches/api/0001-Add-Getter-interfaces.patch similarity index 72% rename from patches/api/0002-Add-Getter-interfaces.patch rename to patches/api/0001-Add-Getter-interfaces.patch index 2fa32ee..09f1cca 100644 --- a/patches/api/0002-Add-Getter-interfaces.patch +++ b/patches/api/0001-Add-Getter-interfaces.patch @@ -8,7 +8,7 @@ Creates new interfaces for objects that have a reference to a player, offlinepla Also creates interfaces for objects that are like players in that they use all other interfaces and can receive Adventure messages. diff --git a/src/main/java/com/destroystokyo/paper/event/block/BeaconEffectEvent.java b/src/main/java/com/destroystokyo/paper/event/block/BeaconEffectEvent.java -index 978813b94a5eae0afccbd3b38b463091a46b56ac..14d057791db091e49b5be7cf9700435e8811edbc 100644 +index 978813b94a5eae0afccbd3b38b463091a46b56ac..617a4b17982e3dac47480cb16046233232f288b7 100644 --- a/src/main/java/com/destroystokyo/paper/event/block/BeaconEffectEvent.java +++ b/src/main/java/com/destroystokyo/paper/event/block/BeaconEffectEvent.java @@ -11,7 +11,7 @@ import org.jetbrains.annotations.NotNull; @@ -16,12 +16,12 @@ index 978813b94a5eae0afccbd3b38b463091a46b56ac..14d057791db091e49b5be7cf9700435e * Called when a beacon effect is being applied to a player. */ -public class BeaconEffectEvent extends BlockEvent implements Cancellable { -+public class BeaconEffectEvent extends BlockEvent implements Cancellable, me.lexikiq.HasPlayer { // Parchment ++public class BeaconEffectEvent extends BlockEvent implements Cancellable, gg.projecteden.parchment.HasPlayer { // Parchment private static final HandlerList handlers = new HandlerList(); private boolean cancelled; private PotionEffect effect; diff --git a/src/main/java/com/destroystokyo/paper/event/entity/EndermanAttackPlayerEvent.java b/src/main/java/com/destroystokyo/paper/event/entity/EndermanAttackPlayerEvent.java -index f530a3d9314e17d1da896cac633f6a422258d9a9..af6e9a654940ed0a9a434501d20dfe225155f4f2 100644 +index f530a3d9314e17d1da896cac633f6a422258d9a9..08897d13a8af33ed1cd40c46b0f168e0c4ebfd4a 100644 --- a/src/main/java/com/destroystokyo/paper/event/entity/EndermanAttackPlayerEvent.java +++ b/src/main/java/com/destroystokyo/paper/event/entity/EndermanAttackPlayerEvent.java @@ -38,7 +38,7 @@ import org.jetbrains.annotations.NotNull; @@ -29,12 +29,12 @@ index f530a3d9314e17d1da896cac633f6a422258d9a9..af6e9a654940ed0a9a434501d20dfe22 * */ -public class EndermanAttackPlayerEvent extends EntityEvent implements Cancellable { -+public class EndermanAttackPlayerEvent extends EntityEvent implements Cancellable, me.lexikiq.HasPlayer { // Parchment ++public class EndermanAttackPlayerEvent extends EntityEvent implements Cancellable, gg.projecteden.parchment.HasPlayer { // Parchment @NotNull private final Player player; public EndermanAttackPlayerEvent(@NotNull Enderman entity, @NotNull Player player) { diff --git a/src/main/java/com/destroystokyo/paper/event/entity/TurtleLayEggEvent.java b/src/main/java/com/destroystokyo/paper/event/entity/TurtleLayEggEvent.java -index a315c5185cd465dcf63c0ababef195da76dfc786..ea39b1dd25e00d9e8a8db86a05105297eb46d9bc 100644 +index a315c5185cd465dcf63c0ababef195da76dfc786..a65eae92b9f369f0864d872817d9ce96679256bc 100644 --- a/src/main/java/com/destroystokyo/paper/event/entity/TurtleLayEggEvent.java +++ b/src/main/java/com/destroystokyo/paper/event/entity/TurtleLayEggEvent.java @@ -10,7 +10,7 @@ import org.jetbrains.annotations.NotNull; @@ -42,12 +42,12 @@ index a315c5185cd465dcf63c0ababef195da76dfc786..ea39b1dd25e00d9e8a8db86a05105297 * Fired when a Turtle lays eggs */ -public class TurtleLayEggEvent extends EntityEvent implements Cancellable { -+public class TurtleLayEggEvent extends EntityEvent implements Cancellable, me.lexikiq.HasLocation { // Parchment ++public class TurtleLayEggEvent extends EntityEvent implements Cancellable, gg.projecteden.parchment.HasLocation { // Parchment private static final HandlerList handlers = new HandlerList(); private boolean cancelled = false; @NotNull diff --git a/src/main/java/com/destroystokyo/paper/event/entity/TurtleStartDiggingEvent.java b/src/main/java/com/destroystokyo/paper/event/entity/TurtleStartDiggingEvent.java -index abeb24fccda2acfdb0dfdadacb8fe688bd97cf78..03f8ddd864eac5d87aba29f791022a6719cd054f 100644 +index abeb24fccda2acfdb0dfdadacb8fe688bd97cf78..890069604ca78a9a3f3b4c5f40969a451a1b2067 100644 --- a/src/main/java/com/destroystokyo/paper/event/entity/TurtleStartDiggingEvent.java +++ b/src/main/java/com/destroystokyo/paper/event/entity/TurtleStartDiggingEvent.java @@ -10,7 +10,7 @@ import org.jetbrains.annotations.NotNull; @@ -55,25 +55,25 @@ index abeb24fccda2acfdb0dfdadacb8fe688bd97cf78..03f8ddd864eac5d87aba29f791022a67 * Fired when a Turtle starts digging to lay eggs */ -public class TurtleStartDiggingEvent extends EntityEvent implements Cancellable { -+public class TurtleStartDiggingEvent extends EntityEvent implements Cancellable, me.lexikiq.HasLocation { // Parchment ++public class TurtleStartDiggingEvent extends EntityEvent implements Cancellable, gg.projecteden.parchment.HasLocation { // Parchment private static final HandlerList handlers = new HandlerList(); private boolean cancelled = false; @NotNull private final Location location; diff --git a/src/main/java/com/destroystokyo/paper/event/player/PlayerHandshakeEvent.java b/src/main/java/com/destroystokyo/paper/event/player/PlayerHandshakeEvent.java -index a077962fa786a3291849abfa823c7f0ec4664fce..7895fe36f6f6f2e47d506a1704494d6cb71f3db7 100644 +index 59ae7bc3a0a2079fe4b3a92d777aca682a58e4e3..b0cc7665e6591c71b7cd4388d028a5f8abd65e64 100644 --- a/src/main/java/com/destroystokyo/paper/event/player/PlayerHandshakeEvent.java +++ b/src/main/java/com/destroystokyo/paper/event/player/PlayerHandshakeEvent.java -@@ -20,7 +20,7 @@ import org.jetbrains.annotations.Nullable; +@@ -20,7 +20,7 @@ import java.util.UUID; * *

WARNING: TAMPERING WITH THIS EVENT CAN BE DANGEROUS

*/ -public class PlayerHandshakeEvent extends Event implements Cancellable { -+public class PlayerHandshakeEvent extends Event implements Cancellable, me.lexikiq.OptionalUniqueId { // Parchment ++public class PlayerHandshakeEvent extends Event implements Cancellable, gg.projecteden.api.interfaces.OptionalUniqueId { // Parchment private static final HandlerList HANDLERS = new HandlerList(); @NotNull private final String originalHandshake; diff --git a/src/main/java/com/destroystokyo/paper/event/profile/PreLookupProfileEvent.java b/src/main/java/com/destroystokyo/paper/event/profile/PreLookupProfileEvent.java -index 4dcf6242c9acc62d030a94f67b78729ed29f8c85..18fd6889457f1a9d7663c7631ce83b847eb458e2 100644 +index 4dcf6242c9acc62d030a94f67b78729ed29f8c85..33550df23fea251368b16dbebad27bdcb1de2e78 100644 --- a/src/main/java/com/destroystokyo/paper/event/profile/PreLookupProfileEvent.java +++ b/src/main/java/com/destroystokyo/paper/event/profile/PreLookupProfileEvent.java @@ -23,7 +23,7 @@ import org.jetbrains.annotations.Nullable; @@ -81,7 +81,7 @@ index 4dcf6242c9acc62d030a94f67b78729ed29f8c85..18fd6889457f1a9d7663c7631ce83b84 * event.isAsync() */ -public class PreLookupProfileEvent extends Event { -+public class PreLookupProfileEvent extends Event implements me.lexikiq.OptionalUniqueId { // Parchment ++public class PreLookupProfileEvent extends Event implements gg.projecteden.api.interfaces.OptionalUniqueId { // Parchment private static final HandlerList handlers = new HandlerList(); @NotNull private final String name; @@ -115,20 +115,20 @@ index 4dcf6242c9acc62d030a94f67b78729ed29f8c85..18fd6889457f1a9d7663c7631ce83b84 /** * Sets the UUID for this player name. This will skip the initial API call to find the players UUID. diff --git a/src/main/java/com/destroystokyo/paper/event/server/AsyncTabCompleteEvent.java b/src/main/java/com/destroystokyo/paper/event/server/AsyncTabCompleteEvent.java -index 4cd97cb102e1ec53b3fe1a451b65b4b640fde099..2de2df06dcb7099e42a097ec2c74d45529cceb21 100644 +index 9be64a95c2345433b6142d611077dedadcef9f5d..e3cea810881868fb5869de72f331733e6893fcee 100644 --- a/src/main/java/com/destroystokyo/paper/event/server/AsyncTabCompleteEvent.java +++ b/src/main/java/com/destroystokyo/paper/event/server/AsyncTabCompleteEvent.java -@@ -48,7 +48,7 @@ import org.jetbrains.annotations.Nullable; +@@ -47,7 +47,7 @@ import org.jetbrains.annotations.Nullable; * * Only 1 process will be allowed to provide completions, the Async Event, or the standard process. */ -public class AsyncTabCompleteEvent extends Event implements Cancellable { -+public class AsyncTabCompleteEvent extends Event implements Cancellable, me.lexikiq.OptionalLocation { // Parchment ++public class AsyncTabCompleteEvent extends Event implements Cancellable, gg.projecteden.parchment.OptionalLocation { // Parchment @NotNull private final CommandSender sender; @NotNull private final String buffer; private final boolean isCommand; diff --git a/src/main/java/com/destroystokyo/paper/exception/ServerPluginMessageException.java b/src/main/java/com/destroystokyo/paper/exception/ServerPluginMessageException.java -index 89e132525cfae0ce979e37b3e2793df781e47227..c06d406f0644aa7380581f81442878b95f555843 100644 +index 89e132525cfae0ce979e37b3e2793df781e47227..f14635ae3112862c1337398bf5f5f56a7f87d90f 100644 --- a/src/main/java/com/destroystokyo/paper/exception/ServerPluginMessageException.java +++ b/src/main/java/com/destroystokyo/paper/exception/ServerPluginMessageException.java @@ -8,7 +8,7 @@ import static com.google.common.base.Preconditions.*; @@ -136,50 +136,24 @@ index 89e132525cfae0ce979e37b3e2793df781e47227..c06d406f0644aa7380581f81442878b9 * Thrown when an incoming plugin message channel throws an exception */ -public class ServerPluginMessageException extends ServerPluginException { -+public class ServerPluginMessageException extends ServerPluginException implements me.lexikiq.HasPlayer { // Parchment ++public class ServerPluginMessageException extends ServerPluginException implements gg.projecteden.parchment.HasPlayer { // Parchment private final Player player; private final String channel; -diff --git a/src/main/java/io/papermc/paper/event/packet/PlayerChunkLoadEvent.java b/src/main/java/io/papermc/paper/event/packet/PlayerChunkLoadEvent.java -index 2c1cda1126e577a88f19071e958eddb5a38785af..a0994a7613a2b34a6b9ec850a8a0fc9254c89751 100644 ---- a/src/main/java/io/papermc/paper/event/packet/PlayerChunkLoadEvent.java -+++ b/src/main/java/io/papermc/paper/event/packet/PlayerChunkLoadEvent.java -@@ -14,7 +14,7 @@ import org.jetbrains.annotations.NotNull; - * Should only be used for packet/clientside related stuff. - * Not intended for modifying server side state. - */ --public class PlayerChunkLoadEvent extends ChunkEvent { -+public class PlayerChunkLoadEvent extends ChunkEvent implements me.lexikiq.HasPlayer { // Parchment - - private static final HandlerList handlers = new HandlerList(); - private final Player player; -diff --git a/src/main/java/io/papermc/paper/event/packet/PlayerChunkUnloadEvent.java b/src/main/java/io/papermc/paper/event/packet/PlayerChunkUnloadEvent.java -index 12163a7b0591a7d022dc7eb9ee6608a1b6c39d9b..80e7db5cbc82e0ed69ea1a0f659fd3259ef0beb2 100644 ---- a/src/main/java/io/papermc/paper/event/packet/PlayerChunkUnloadEvent.java -+++ b/src/main/java/io/papermc/paper/event/packet/PlayerChunkUnloadEvent.java -@@ -12,7 +12,7 @@ import org.jetbrains.annotations.NotNull; - * Should only be used for packet/clientside related stuff. - * Not intended for modifying server side. - */ --public class PlayerChunkUnloadEvent extends ChunkEvent { -+public class PlayerChunkUnloadEvent extends ChunkEvent implements me.lexikiq.HasPlayer { // Parchment - - private static final HandlerList handlers = new HandlerList(); - private final Player player; -diff --git a/src/main/java/me/lexikiq/HasHumanEntity.java b/src/main/java/me/lexikiq/HasHumanEntity.java +diff --git a/src/main/java/gg/projecteden/parchment/HasHumanEntity.java b/src/main/java/gg/projecteden/parchment/HasHumanEntity.java new file mode 100644 -index 0000000000000000000000000000000000000000..46efc8787afe2eda000fc71a6a1f3c0f0d7da320 +index 0000000000000000000000000000000000000000..ee1bc817a60b602f7d437a21852c3dc285d854df --- /dev/null -+++ b/src/main/java/me/lexikiq/HasHumanEntity.java ++++ b/src/main/java/gg/projecteden/parchment/HasHumanEntity.java @@ -0,0 +1,19 @@ -+package me.lexikiq; ++package gg.projecteden.parchment; + +import org.bukkit.entity.HumanEntity; +import org.jetbrains.annotations.NotNull; + +/** + * Represents an object that has a {@link HumanEntity} -+ * @see me.lexikiq.OptionalHumanEntity ++ * @see gg.projecteden.parchment.OptionalHumanEntity + */ +@FunctionalInterface +public interface HasHumanEntity extends OptionalHumanEntity { @@ -191,13 +165,13 @@ index 0000000000000000000000000000000000000000..46efc8787afe2eda000fc71a6a1f3c0f + @Override + @NotNull HumanEntity getPlayer(); +} -diff --git a/src/main/java/me/lexikiq/HasLocation.java b/src/main/java/me/lexikiq/HasLocation.java +diff --git a/src/main/java/gg/projecteden/parchment/HasLocation.java b/src/main/java/gg/projecteden/parchment/HasLocation.java new file mode 100644 -index 0000000000000000000000000000000000000000..ac380c3f767f2d7a86ca2f9a3f7dbfcfc172e2be +index 0000000000000000000000000000000000000000..e9f7bb3058639c94ee8e67627e5e34548d391df6 --- /dev/null -+++ b/src/main/java/me/lexikiq/HasLocation.java ++++ b/src/main/java/gg/projecteden/parchment/HasLocation.java @@ -0,0 +1,18 @@ -+package me.lexikiq; ++package gg.projecteden.parchment; + +import org.bukkit.Location; +import org.jetbrains.annotations.NotNull; @@ -215,13 +189,13 @@ index 0000000000000000000000000000000000000000..ac380c3f767f2d7a86ca2f9a3f7dbfcf + @Override + @NotNull Location getLocation(); +} -diff --git a/src/main/java/me/lexikiq/HasOfflinePlayer.java b/src/main/java/me/lexikiq/HasOfflinePlayer.java +diff --git a/src/main/java/gg/projecteden/parchment/HasOfflinePlayer.java b/src/main/java/gg/projecteden/parchment/HasOfflinePlayer.java new file mode 100644 -index 0000000000000000000000000000000000000000..33b04ae2dee02e53ffa070de6631f71e2ddaf998 +index 0000000000000000000000000000000000000000..15b72b693a32852f791c5578f701843c759737a7 --- /dev/null -+++ b/src/main/java/me/lexikiq/HasOfflinePlayer.java ++++ b/src/main/java/gg/projecteden/parchment/HasOfflinePlayer.java @@ -0,0 +1,17 @@ -+package me.lexikiq; ++package gg.projecteden.parchment; + +import org.bukkit.OfflinePlayer; +import org.jetbrains.annotations.NotNull; @@ -238,20 +212,20 @@ index 0000000000000000000000000000000000000000..33b04ae2dee02e53ffa070de6631f71e + */ + @NotNull OfflinePlayer getOfflinePlayer(); +} -diff --git a/src/main/java/me/lexikiq/HasPlayer.java b/src/main/java/me/lexikiq/HasPlayer.java +diff --git a/src/main/java/gg/projecteden/parchment/HasPlayer.java b/src/main/java/gg/projecteden/parchment/HasPlayer.java new file mode 100644 -index 0000000000000000000000000000000000000000..117e3994ffec1830f471b8810746f6e4088db298 +index 0000000000000000000000000000000000000000..68a2e2093405eb39d91b5b79f16a521a6a729d4e --- /dev/null -+++ b/src/main/java/me/lexikiq/HasPlayer.java ++++ b/src/main/java/gg/projecteden/parchment/HasPlayer.java @@ -0,0 +1,19 @@ -+package me.lexikiq; ++package gg.projecteden.parchment; + +import org.bukkit.entity.Player; +import org.jetbrains.annotations.NotNull; + +/** + * Represents an object that has a {@link Player} -+ * @see me.lexikiq.OptionalPlayer ++ * @see gg.projecteden.parchment.OptionalPlayer + */ +@FunctionalInterface +public interface HasPlayer extends OptionalPlayer, HasHumanEntity { @@ -263,13 +237,13 @@ index 0000000000000000000000000000000000000000..117e3994ffec1830f471b8810746f6e4 + @Override + @NotNull Player getPlayer(); +} -diff --git a/src/main/java/me/lexikiq/OptionalHumanEntity.java b/src/main/java/me/lexikiq/OptionalHumanEntity.java +diff --git a/src/main/java/gg/projecteden/parchment/OptionalHumanEntity.java b/src/main/java/gg/projecteden/parchment/OptionalHumanEntity.java new file mode 100644 -index 0000000000000000000000000000000000000000..139887822a853876508b937f5288bfd117d15da6 +index 0000000000000000000000000000000000000000..45410a77714ad28201520c188e280e4f5fa8bcab --- /dev/null -+++ b/src/main/java/me/lexikiq/OptionalHumanEntity.java ++++ b/src/main/java/gg/projecteden/parchment/OptionalHumanEntity.java @@ -0,0 +1,18 @@ -+package me.lexikiq; ++package gg.projecteden.parchment; + +import org.bukkit.entity.HumanEntity; +import org.jetbrains.annotations.Nullable; @@ -287,13 +261,13 @@ index 0000000000000000000000000000000000000000..139887822a853876508b937f5288bfd1 + */ + @Nullable HumanEntity getPlayer(); +} -diff --git a/src/main/java/me/lexikiq/OptionalLocation.java b/src/main/java/me/lexikiq/OptionalLocation.java +diff --git a/src/main/java/gg/projecteden/parchment/OptionalLocation.java b/src/main/java/gg/projecteden/parchment/OptionalLocation.java new file mode 100644 -index 0000000000000000000000000000000000000000..10d06b9af2a9cfb2e80991d9916ca9953a25e42c +index 0000000000000000000000000000000000000000..23897904c6e2d6195f3613c36d77454587afd8bc --- /dev/null -+++ b/src/main/java/me/lexikiq/OptionalLocation.java ++++ b/src/main/java/gg/projecteden/parchment/OptionalLocation.java @@ -0,0 +1,18 @@ -+package me.lexikiq; ++package gg.projecteden.parchment; + +import org.bukkit.Location; +import org.jetbrains.annotations.Nullable; @@ -311,13 +285,13 @@ index 0000000000000000000000000000000000000000..10d06b9af2a9cfb2e80991d9916ca995 + */ + @Nullable Location getLocation(); +} -diff --git a/src/main/java/me/lexikiq/OptionalPlayer.java b/src/main/java/me/lexikiq/OptionalPlayer.java +diff --git a/src/main/java/gg/projecteden/parchment/OptionalPlayer.java b/src/main/java/gg/projecteden/parchment/OptionalPlayer.java new file mode 100644 -index 0000000000000000000000000000000000000000..6de254b174966ff9cc9e0ec091639885cd925b56 +index 0000000000000000000000000000000000000000..31b9ab6512c9f06160c268e88d5bce486ed87523 --- /dev/null -+++ b/src/main/java/me/lexikiq/OptionalPlayer.java ++++ b/src/main/java/gg/projecteden/parchment/OptionalPlayer.java @@ -0,0 +1,19 @@ -+package me.lexikiq; ++package gg.projecteden.parchment; + +import org.bukkit.entity.Player; +import org.jetbrains.annotations.Nullable; @@ -336,37 +310,30 @@ index 0000000000000000000000000000000000000000..6de254b174966ff9cc9e0ec091639885 + */ + @Nullable Player getPlayer(); +} -diff --git a/src/main/java/me/lexikiq/OptionalPlayerLike.java b/src/main/java/me/lexikiq/OptionalPlayerLike.java +diff --git a/src/main/java/gg/projecteden/parchment/OptionalPlayerLike.java b/src/main/java/gg/projecteden/parchment/OptionalPlayerLike.java new file mode 100644 -index 0000000000000000000000000000000000000000..9ea2385c1f4de8bfd59bae284fb47e5a15026b55 +index 0000000000000000000000000000000000000000..4b2fa7abc6ce8f7e21e137d3cafab1ab2ac192a2 --- /dev/null -+++ b/src/main/java/me/lexikiq/OptionalPlayerLike.java -@@ -0,0 +1,189 @@ -+package me.lexikiq; ++++ b/src/main/java/gg/projecteden/parchment/OptionalPlayerLike.java +@@ -0,0 +1,48 @@ ++package gg.projecteden.parchment; + +import net.kyori.adventure.audience.Audience; -+import net.kyori.adventure.audience.MessageType; -+import net.kyori.adventure.bossbar.BossBar; ++import net.kyori.adventure.audience.ForwardingAudience; +import net.kyori.adventure.identity.Identified; +import net.kyori.adventure.identity.Identity; -+import net.kyori.adventure.inventory.Book; -+import net.kyori.adventure.sound.Sound; -+import net.kyori.adventure.sound.SoundStop; -+import net.kyori.adventure.text.Component; -+import net.kyori.adventure.title.Title; -+import org.apache.commons.lang3.Validate; +import org.bukkit.Location; +import org.bukkit.entity.Player; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + -+import java.util.function.Consumer; ++import java.util.Objects; + +/** + * Class that may be like a {@link org.bukkit.entity.Player} in that it has a {@link java.util.UUID}, {@link org.bukkit.OfflinePlayer}, {@link Identity}, and a nullable Player. -+ * @see me.lexikiq.PlayerLike ++ * @see gg.projecteden.parchment.PlayerLike + */ -+public interface OptionalPlayerLike extends OptionalPlayer, HasUniqueId, HasOfflinePlayer, OptionalLocation, Identified, Audience { ++public interface OptionalPlayerLike extends OptionalPlayer, gg.projecteden.api.interfaces.HasUniqueId, HasOfflinePlayer, OptionalLocation, Identified, ForwardingAudience.Single { + /** + * Gets the identity associated with this object + * @@ -386,143 +353,9 @@ index 0000000000000000000000000000000000000000..9ea2385c1f4de8bfd59bae284fb47e5a + return getPlayer() != null; + } + -+ /** -+ * Run a consumer with the {@link Player} associated with this object if the player is online. -+ *

-+ * Allows easily running a code on the player only if they are connected. -+ * -+ * @param consumer function that accepts a Player -+ */ -+ default void consumeIfOnline(final @NotNull Consumer<@NotNull Player> consumer) { -+ Validate.notNull(consumer, "Consumer should not be null"); -+ -+ final Player player = getPlayer(); -+ if (player != null) -+ consumer.accept(player); -+ } -+ -+ /** -+ * Sends a chat message. -+ * -+ * @param source the identity of the source of the message -+ * @param message a message -+ * @param type the type -+ */ + @Override -+ default void sendMessage(final @NotNull Identity source, final @NotNull Component message, final @NotNull MessageType type) { -+ consumeIfOnline(player -> player.sendMessage(source, message, type)); -+ } -+ -+ /** -+ * Sends a message on the action bar. -+ * -+ * @param message a message -+ */ -+ @Override -+ default void sendActionBar(final @NotNull Component message) { -+ consumeIfOnline(player -> player.sendActionBar(message)); -+ } -+ -+ /** -+ * Sends the player list header and footer. -+ * -+ * @param header the header -+ * @param footer the footer -+ */ -+ @Override -+ default void sendPlayerListHeaderAndFooter(final @NotNull Component header, final @NotNull Component footer) { -+ consumeIfOnline(player -> player.sendPlayerListHeaderAndFooter(header, footer)); -+ } -+ -+ /** -+ * Shows a title. -+ * -+ * @param title a title -+ */ -+ @Override -+ default void showTitle(final @NotNull Title title) { -+ consumeIfOnline(player -> player.showTitle(title)); -+ } -+ -+ /** -+ * Clears the title, if one is being displayed. -+ */ -+ @Override -+ default void clearTitle() { -+ consumeIfOnline(Audience::clearTitle); -+ } -+ -+ /** -+ * Resets the title and timings back to their default. -+ */ -+ @Override -+ default void resetTitle() { -+ consumeIfOnline(Audience::resetTitle); -+ } -+ -+ /** -+ * Shows a boss bar. -+ * -+ * @param bar a boss bar -+ */ -+ @Override -+ default void showBossBar(final @NotNull BossBar bar) { -+ consumeIfOnline(player -> player.showBossBar(bar)); -+ } -+ -+ /** -+ * Hides a boss bar. -+ * -+ * @param bar a boss bar -+ */ -+ @Override -+ default void hideBossBar(final @NotNull BossBar bar) { -+ consumeIfOnline(player -> player.hideBossBar(bar)); -+ } -+ -+ /** -+ * Plays a sound. -+ * -+ * @param sound a sound -+ */ -+ @Override -+ default void playSound(final @NotNull Sound sound) { -+ consumeIfOnline(player -> player.playSound(sound)); -+ } -+ -+ /** -+ * Plays a sound at a location. -+ * -+ * @param sound a sound -+ * @param x x coordinate -+ * @param y y coordinate -+ * @param z z coordinate -+ */ -+ @Override -+ default void playSound(final @NotNull Sound sound, final double x, final double y, final double z) { -+ consumeIfOnline(player -> player.playSound(sound, x, y, z)); -+ } -+ -+ /** -+ * Stops a sound, or many sounds. -+ * -+ * @param stop a sound stop -+ */ -+ @Override -+ default void stopSound(final @NotNull SoundStop stop) { -+ consumeIfOnline(player -> player.stopSound(stop)); -+ } -+ -+ /** -+ * Opens a book. -+ * -+ *

When possible, no item should persist after closing the book.

-+ * -+ * @param book a book -+ */ -+ @Override -+ default void openBook(final @NotNull Book book) { -+ consumeIfOnline(player -> player.openBook(book)); ++ default @NotNull Audience audience() { ++ return Objects.requireNonNullElse(getPlayer(), Audience.empty()); + } + + @Override @@ -531,28 +364,30 @@ index 0000000000000000000000000000000000000000..9ea2385c1f4de8bfd59bae284fb47e5a + return player == null ? null : player.getLocation(); + } +} -diff --git a/src/main/java/me/lexikiq/PlayerLike.java b/src/main/java/me/lexikiq/PlayerLike.java +diff --git a/src/main/java/gg/projecteden/parchment/PlayerLike.java b/src/main/java/gg/projecteden/parchment/PlayerLike.java new file mode 100644 -index 0000000000000000000000000000000000000000..314bf6e8cacfe8891f1354952c5ccfe7d2e21939 +index 0000000000000000000000000000000000000000..c70ddc6f92d62d2d5baa001c9009ddd30c31ae5d --- /dev/null -+++ b/src/main/java/me/lexikiq/PlayerLike.java -@@ -0,0 +1,28 @@ -+package me.lexikiq; ++++ b/src/main/java/gg/projecteden/parchment/PlayerLike.java +@@ -0,0 +1,30 @@ ++package gg.projecteden.parchment; + ++import net.kyori.adventure.audience.Audience; +import org.bukkit.Location; -+import org.bukkit.entity.Player; +import org.jetbrains.annotations.NotNull; + -+import java.util.function.Consumer; -+ +/** + * Class that is like a {@link org.bukkit.entity.Player} in that it has a Player, {@link java.util.UUID}, {@link org.bukkit.OfflinePlayer}, and an {@link net.kyori.adventure.identity.Identity}. -+ * @see me.lexikiq.OptionalPlayerLike ++ * @see gg.projecteden.parchment.OptionalPlayerLike + */ +public interface PlayerLike extends HasPlayer, HasLocation, OptionalPlayerLike { ++ ++ // reduce nullability checks by re-implementing the methods from OptionalPlayerLike ++ // (but without the null checks) ++ + @Override -+ default void consumeIfOnline(final @NotNull Consumer<@NotNull Player> consumer) { -+ consumer.accept(getPlayer()); ++ default @NotNull Audience audience() { ++ return getPlayer(); + } + + @Override @@ -565,8 +400,34 @@ index 0000000000000000000000000000000000000000..314bf6e8cacfe8891f1354952c5ccfe7 + return getPlayer().getLocation(); + } +} +diff --git a/src/main/java/io/papermc/paper/event/packet/PlayerChunkLoadEvent.java b/src/main/java/io/papermc/paper/event/packet/PlayerChunkLoadEvent.java +index 2c1cda1126e577a88f19071e958eddb5a38785af..39e746f0c8536642346abbb6909fd2053031d695 100644 +--- a/src/main/java/io/papermc/paper/event/packet/PlayerChunkLoadEvent.java ++++ b/src/main/java/io/papermc/paper/event/packet/PlayerChunkLoadEvent.java +@@ -14,7 +14,7 @@ import org.jetbrains.annotations.NotNull; + * Should only be used for packet/clientside related stuff. + * Not intended for modifying server side state. + */ +-public class PlayerChunkLoadEvent extends ChunkEvent { ++public class PlayerChunkLoadEvent extends ChunkEvent implements gg.projecteden.parchment.HasPlayer { // Parchment + + private static final HandlerList handlers = new HandlerList(); + private final Player player; +diff --git a/src/main/java/io/papermc/paper/event/packet/PlayerChunkUnloadEvent.java b/src/main/java/io/papermc/paper/event/packet/PlayerChunkUnloadEvent.java +index 12163a7b0591a7d022dc7eb9ee6608a1b6c39d9b..d81c7307127b135417e06a3b244416bee34b0abe 100644 +--- a/src/main/java/io/papermc/paper/event/packet/PlayerChunkUnloadEvent.java ++++ b/src/main/java/io/papermc/paper/event/packet/PlayerChunkUnloadEvent.java +@@ -12,7 +12,7 @@ import org.jetbrains.annotations.NotNull; + * Should only be used for packet/clientside related stuff. + * Not intended for modifying server side. + */ +-public class PlayerChunkUnloadEvent extends ChunkEvent { ++public class PlayerChunkUnloadEvent extends ChunkEvent implements gg.projecteden.parchment.HasPlayer { // Parchment + + private static final HandlerList handlers = new HandlerList(); + private final Player player; diff --git a/src/main/java/org/bukkit/Location.java b/src/main/java/org/bukkit/Location.java -index 8321441b8f528a05e297f485672f928e76fe017d..e6a66494941ccaeb62ec13c26a0e05c52e3af159 100644 +index ef0cb00ca4cb7d2f5e4ec1c950cce036566d1ae4..df53183beb4c438ea3c821e1ffd8e2719c08f269 100644 --- a/src/main/java/org/bukkit/Location.java +++ b/src/main/java/org/bukkit/Location.java @@ -30,7 +30,7 @@ import org.bukkit.entity.Player; @@ -574,7 +435,7 @@ index 8321441b8f528a05e297f485672f928e76fe017d..e6a66494941ccaeb62ec13c26a0e05c5 * representation by the implementation. */ -public class Location implements Cloneable, ConfigurationSerializable { -+public class Location implements Cloneable, ConfigurationSerializable, me.lexikiq.HasLocation { // Parchment ++public class Location implements Cloneable, ConfigurationSerializable, gg.projecteden.parchment.HasLocation { // Parchment private Reference world; private double x; private double y; @@ -593,19 +454,19 @@ index 8321441b8f528a05e297f485672f928e76fe017d..e6a66494941ccaeb62ec13c26a0e05c5 * Sets the world that this location resides in * diff --git a/src/main/java/org/bukkit/OfflinePlayer.java b/src/main/java/org/bukkit/OfflinePlayer.java -index 3afd5f5c0208a4ee93b5dbfc2aab2b9d2e8a7544..5898a13f0f90547ff6ecabee18969c7891d0beee 100644 +index a7d1f1e701f23e851f735584a30bedadb0d8b9bd..7b37b6f596b4ac6b8049c7bd195139ac03ba63bc 100644 --- a/src/main/java/org/bukkit/OfflinePlayer.java +++ b/src/main/java/org/bukkit/OfflinePlayer.java -@@ -9,7 +9,7 @@ import org.bukkit.permissions.ServerOperator; +@@ -10,7 +10,7 @@ import org.bukkit.profile.PlayerProfile; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -public interface OfflinePlayer extends ServerOperator, AnimalTamer, ConfigurationSerializable { -+public interface OfflinePlayer extends ServerOperator, AnimalTamer, ConfigurationSerializable, me.lexikiq.HasOfflinePlayer, me.lexikiq.OptionalPlayer { // Parchment ++public interface OfflinePlayer extends ServerOperator, AnimalTamer, ConfigurationSerializable, gg.projecteden.parchment.HasOfflinePlayer, gg.projecteden.parchment.OptionalPlayer { // Parchment /** * Checks if this player is currently online -@@ -126,6 +126,13 @@ public interface OfflinePlayer extends ServerOperator, AnimalTamer, Configuratio +@@ -139,6 +139,13 @@ public interface OfflinePlayer extends ServerOperator, AnimalTamer, Configuratio @Nullable public Player getPlayer(); @@ -620,7 +481,7 @@ index 3afd5f5c0208a4ee93b5dbfc2aab2b9d2e8a7544..5898a13f0f90547ff6ecabee18969c78 * Gets the first date and time that this player was witnessed on this * server. diff --git a/src/main/java/org/bukkit/Raid.java b/src/main/java/org/bukkit/Raid.java -index 983a8c20a06d2b509602b27f49c090598b8ecc42..bc6b6739ad46a076f3ac8f92814a027f9d2840a7 100644 +index 983a8c20a06d2b509602b27f49c090598b8ecc42..46dd8496f5a2c792ee7811e33c424e88edf8b5b3 100644 --- a/src/main/java/org/bukkit/Raid.java +++ b/src/main/java/org/bukkit/Raid.java @@ -9,7 +9,7 @@ import org.jetbrains.annotations.NotNull; @@ -628,25 +489,25 @@ index 983a8c20a06d2b509602b27f49c090598b8ecc42..bc6b6739ad46a076f3ac8f92814a027f * Represents a raid event. */ -public interface Raid { -+public interface Raid extends me.lexikiq.HasLocation { // Parchment ++public interface Raid extends gg.projecteden.parchment.HasLocation { // Parchment /** * Get whether this raid started. diff --git a/src/main/java/org/bukkit/Vibration.java b/src/main/java/org/bukkit/Vibration.java -index 8d568d21fcbf706f55cda087bd7222ac60889c0a..51b214313e7ee6b5eb1f0fa6f1e1fe383c6d04e1 100644 +index 209a302c3a2ed333780ed760314a6ed352fc0767..9d29f1c5af56954bc452fa251d6bc0215ab3fe79 100644 --- a/src/main/java/org/bukkit/Vibration.java +++ b/src/main/java/org/bukkit/Vibration.java -@@ -64,7 +64,7 @@ public class Vibration { +@@ -74,7 +74,7 @@ public class Vibration { } } - public static class BlockDestination implements Destination { -+ public static class BlockDestination implements Destination, me.lexikiq.HasLocation { // Parchment ++ public static class BlockDestination implements Destination, gg.projecteden.parchment.HasLocation { // Parchment private final Location block; diff --git a/src/main/java/org/bukkit/attribute/AttributeModifier.java b/src/main/java/org/bukkit/attribute/AttributeModifier.java -index ff8f1231f3e2e71740fd24fa8d4dac5d0e550ae7..4a1e40e0c7cff6ef8898771adf3bc600c715ee8d 100644 +index d124768378d6f0c5573f28ee815ea3886fe74868..11a00998b1cb5ee582e225553f15b1b7c1a65b2a 100644 --- a/src/main/java/org/bukkit/attribute/AttributeModifier.java +++ b/src/main/java/org/bukkit/attribute/AttributeModifier.java @@ -14,7 +14,7 @@ import org.jetbrains.annotations.Nullable; @@ -654,12 +515,12 @@ index ff8f1231f3e2e71740fd24fa8d4dac5d0e550ae7..4a1e40e0c7cff6ef8898771adf3bc600 * Concrete implementation of an attribute modifier. */ -public class AttributeModifier implements ConfigurationSerializable { -+public class AttributeModifier implements ConfigurationSerializable, me.lexikiq.HasUniqueId { // Parchment ++public class AttributeModifier implements ConfigurationSerializable, gg.projecteden.api.interfaces.HasUniqueId { // Parchment private final UUID uuid; private final String name; diff --git a/src/main/java/org/bukkit/block/Block.java b/src/main/java/org/bukkit/block/Block.java -index 70caaf05be813ba390412714ba0a39981edc2475..84525ded139292612256cba0ae3933a3b07f6fab 100644 +index e405c279f6135c94c775a856ab88fd3cace6bd5c..359cad4528e0c9b45ac3447655f24e7925bff7d2 100644 --- a/src/main/java/org/bukkit/block/Block.java +++ b/src/main/java/org/bukkit/block/Block.java @@ -31,7 +31,7 @@ import org.jetbrains.annotations.Nullable; @@ -667,12 +528,12 @@ index 70caaf05be813ba390412714ba0a39981edc2475..84525ded139292612256cba0ae3933a3 * generation when used in cases like BlockPhysicsEvent!!!! */ -public interface Block extends Metadatable, net.kyori.adventure.translation.Translatable { // Paper - translatable -+public interface Block extends Metadatable, net.kyori.adventure.translation.Translatable, me.lexikiq.HasLocation { // Paper - translatable ++public interface Block extends Metadatable, net.kyori.adventure.translation.Translatable, gg.projecteden.parchment.HasLocation { // Paper - translatable /** * Gets the metadata for this block diff --git a/src/main/java/org/bukkit/block/BlockState.java b/src/main/java/org/bukkit/block/BlockState.java -index 96cde879922c796f3ac8d14ee99d7b190ff67bd9..5b7a4a1c4e210ad7e8c81e2958e26d0394060fdb 100644 +index 10cbe71917bc32cca61748bcb0aa3395c554dbf8..280df0fc6f7344863f0fd2ba7592494bcd8bf2da 100644 --- a/src/main/java/org/bukkit/block/BlockState.java +++ b/src/main/java/org/bukkit/block/BlockState.java @@ -20,7 +20,7 @@ import org.jetbrains.annotations.Nullable; @@ -680,12 +541,12 @@ index 96cde879922c796f3ac8d14ee99d7b190ff67bd9..5b7a4a1c4e210ad7e8c81e2958e26d03 * block to another type entirely, causing your BlockState to become invalid. */ -public interface BlockState extends Metadatable { -+public interface BlockState extends Metadatable, me.lexikiq.HasLocation { // Parchment ++public interface BlockState extends Metadatable, gg.projecteden.parchment.HasLocation { // Parchment /** * Gets the block represented by this block state. diff --git a/src/main/java/org/bukkit/block/DoubleChest.java b/src/main/java/org/bukkit/block/DoubleChest.java -index a39d2f1acbbd84ae0e2cf29f85594e09e55e9355..19b54fc9f05a88849538a1ed28d8440306b8c81e 100644 +index a39d2f1acbbd84ae0e2cf29f85594e09e55e9355..4348b8961afe7a57350856622aff8c988cd4bbdd 100644 --- a/src/main/java/org/bukkit/block/DoubleChest.java +++ b/src/main/java/org/bukkit/block/DoubleChest.java @@ -11,7 +11,7 @@ import org.jetbrains.annotations.Nullable; @@ -693,12 +554,12 @@ index a39d2f1acbbd84ae0e2cf29f85594e09e55e9355..19b54fc9f05a88849538a1ed28d84403 * Represents a double chest. */ -public class DoubleChest implements InventoryHolder { -+public class DoubleChest implements InventoryHolder, me.lexikiq.HasLocation { // Parchment ++public class DoubleChest implements InventoryHolder, gg.projecteden.parchment.HasLocation { // Parchment private DoubleChestInventory inventory; public DoubleChest(@NotNull DoubleChestInventory chest) { diff --git a/src/main/java/org/bukkit/entity/AnimalTamer.java b/src/main/java/org/bukkit/entity/AnimalTamer.java -index 2e17b2d4f759531fbe9ee8e9b00c839186af09ca..3f87365f96b220cf58b5ab9405ec77b70d24039b 100644 +index 2e17b2d4f759531fbe9ee8e9b00c839186af09ca..8f4a293c131cb8b63c31b410ffa211bdb42b3338 100644 --- a/src/main/java/org/bukkit/entity/AnimalTamer.java +++ b/src/main/java/org/bukkit/entity/AnimalTamer.java @@ -4,7 +4,7 @@ import java.util.UUID; @@ -706,12 +567,12 @@ index 2e17b2d4f759531fbe9ee8e9b00c839186af09ca..3f87365f96b220cf58b5ab9405ec77b7 import org.jetbrains.annotations.Nullable; -public interface AnimalTamer { -+public interface AnimalTamer extends me.lexikiq.HasUniqueId { // Parchment ++public interface AnimalTamer extends gg.projecteden.api.interfaces.HasUniqueId { // Parchment /** * This is the name of the specified AnimalTamer. diff --git a/src/main/java/org/bukkit/entity/Entity.java b/src/main/java/org/bukkit/entity/Entity.java -index bafad5764cc3933fcd9602d37bd2e68424cbd575..c01d0c2bdd90a54ce853be610ed4554ce2030af4 100644 +index 8bc6876c82935988436597161fa0ec94c032174b..b27576e9c7f22e203251487334288239be0dcb9e 100644 --- a/src/main/java/org/bukkit/entity/Entity.java +++ b/src/main/java/org/bukkit/entity/Entity.java @@ -26,7 +26,7 @@ import org.jetbrains.annotations.Nullable; @@ -719,12 +580,12 @@ index bafad5764cc3933fcd9602d37bd2e68424cbd575..c01d0c2bdd90a54ce853be610ed4554c * Represents a base entity in the world */ -public interface Entity extends Metadatable, CommandSender, Nameable, PersistentDataHolder, net.kyori.adventure.text.event.HoverEventSource, net.kyori.adventure.sound.Sound.Emitter { // Paper -+public interface Entity extends Metadatable, CommandSender, Nameable, PersistentDataHolder, net.kyori.adventure.text.event.HoverEventSource, net.kyori.adventure.sound.Sound.Emitter, me.lexikiq.HasUniqueId, me.lexikiq.HasLocation { // Paper // Parchment ++public interface Entity extends Metadatable, CommandSender, Nameable, PersistentDataHolder, net.kyori.adventure.text.event.HoverEventSource, net.kyori.adventure.sound.Sound.Emitter, gg.projecteden.api.interfaces.HasUniqueId, gg.projecteden.parchment.HasLocation { // Paper // Parchment /** * Gets the entity's current position diff --git a/src/main/java/org/bukkit/entity/HumanEntity.java b/src/main/java/org/bukkit/entity/HumanEntity.java -index 28d1ff809e44bda0324ffac957c1d455be02e783..8b72f9e7514cffa5631186a4fd21671c7cf7c7d6 100644 +index 5dbbeb92aec212d2e849d16320ed9c084b99fc35..32e5150b14f5d7d19d82d15631065db376814e25 100644 --- a/src/main/java/org/bukkit/entity/HumanEntity.java +++ b/src/main/java/org/bukkit/entity/HumanEntity.java @@ -19,7 +19,15 @@ import org.jetbrains.annotations.Nullable; @@ -733,7 +594,7 @@ index 28d1ff809e44bda0324ffac957c1d455be02e783..8b72f9e7514cffa5631186a4fd21671c */ -public interface HumanEntity extends LivingEntity, AnimalTamer, InventoryHolder { +// Parchment start -+public interface HumanEntity extends LivingEntity, AnimalTamer, InventoryHolder, me.lexikiq.HasHumanEntity { ++public interface HumanEntity extends LivingEntity, AnimalTamer, InventoryHolder, gg.projecteden.parchment.HasHumanEntity { + + @NotNull + @Override @@ -745,22 +606,16 @@ index 28d1ff809e44bda0324ffac957c1d455be02e783..8b72f9e7514cffa5631186a4fd21671c // Paper start @Override diff --git a/src/main/java/org/bukkit/entity/Player.java b/src/main/java/org/bukkit/entity/Player.java -index 9a6e410206852029f1fea0c4409352d5743dcf64..2b38fdc2dad244927a38c779f9c87073d017c259 100644 +index 6cd0b10d1dc4506cfb1e4db5e1260cb705566cec..a3ff1cb4b2754900879c67638a3488cd9d76cdb1 100644 --- a/src/main/java/org/bukkit/entity/Player.java +++ b/src/main/java/org/bukkit/entity/Player.java -@@ -41,7 +41,7 @@ import org.jetbrains.annotations.Nullable; +@@ -40,7 +40,17 @@ import org.jetbrains.annotations.Nullable; /** * Represents a player, connected or not */ -public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginMessageRecipient, net.kyori.adventure.identity.Identified, com.destroystokyo.paper.network.NetworkClient { // Paper -+public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginMessageRecipient, net.kyori.adventure.identity.Identified, com.destroystokyo.paper.network.NetworkClient, me.lexikiq.HasPlayer { // Paper // Parchment - - // Paper start - @Override -@@ -49,6 +49,16 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM - return net.kyori.adventure.identity.Identity.identity(this.getUniqueId()); - } - ++public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginMessageRecipient, net.kyori.adventure.identity.Identified, com.destroystokyo.paper.network.NetworkClient, gg.projecteden.parchment.HasPlayer { // Paper // Parchment ++ + // Parchment start - fix defaults + /** + * Returns this player object. @@ -770,12 +625,11 @@ index 9a6e410206852029f1fea0c4409352d5743dcf64..2b38fdc2dad244927a38c779f9c87073 + @Override + @NotNull Player getPlayer(); + // Parchment end -+ - /** - * Gets the "friendly" name to display of this player. - * + + // Paper start + @Override diff --git a/src/main/java/org/bukkit/event/block/BlockBreakEvent.java b/src/main/java/org/bukkit/event/block/BlockBreakEvent.java -index 691733a642b3295bbe6d484be728c77cd32803bd..4481f9ea86fa18ea1fd2ea815784020cd2568740 100644 +index 691733a642b3295bbe6d484be728c77cd32803bd..a2eae7a9bad13d1ba2bd954888a0373834d30078 100644 --- a/src/main/java/org/bukkit/event/block/BlockBreakEvent.java +++ b/src/main/java/org/bukkit/event/block/BlockBreakEvent.java @@ -26,7 +26,7 @@ import org.jetbrains.annotations.NotNull; @@ -783,12 +637,12 @@ index 691733a642b3295bbe6d484be728c77cd32803bd..4481f9ea86fa18ea1fd2ea815784020c * experience will not drop. */ -public class BlockBreakEvent extends BlockExpEvent implements Cancellable { -+public class BlockBreakEvent extends BlockExpEvent implements Cancellable, me.lexikiq.HasPlayer { // Parchment ++public class BlockBreakEvent extends BlockExpEvent implements Cancellable, gg.projecteden.parchment.HasPlayer { // Parchment private final Player player; private boolean dropItems; private boolean cancel; diff --git a/src/main/java/org/bukkit/event/block/BlockCanBuildEvent.java b/src/main/java/org/bukkit/event/block/BlockCanBuildEvent.java -index a1350c0f74d445dca09eea6e10abac050bb06990..7d9573f88ab4333db2da42379344580087f7f561 100644 +index a1350c0f74d445dca09eea6e10abac050bb06990..11bb6f8f7363f31061d5fd0f2e4515099ac40649 100644 --- a/src/main/java/org/bukkit/event/block/BlockCanBuildEvent.java +++ b/src/main/java/org/bukkit/event/block/BlockCanBuildEvent.java @@ -19,7 +19,7 @@ import org.jetbrains.annotations.Nullable; @@ -796,25 +650,25 @@ index a1350c0f74d445dca09eea6e10abac050bb06990..7d9573f88ab4333db2da423793445800 * */ -public class BlockCanBuildEvent extends BlockEvent { -+public class BlockCanBuildEvent extends BlockEvent implements me.lexikiq.OptionalPlayer { // Parchment ++public class BlockCanBuildEvent extends BlockEvent implements gg.projecteden.parchment.OptionalPlayer { // Parchment private static final HandlerList handlers = new HandlerList(); protected boolean buildable; diff --git a/src/main/java/org/bukkit/event/block/BlockDamageEvent.java b/src/main/java/org/bukkit/event/block/BlockDamageEvent.java -index f70871e1ae7b1a1d77405d942d82666f03bf0498..fc40801a3d314b20b4334cffff7e6beeceba80cf 100644 +index cd04a0bd9d232857408b38605787016a217cb8d2..7035fe7c0f5adb981ac41804605c4fbcf57968bf 100644 --- a/src/main/java/org/bukkit/event/block/BlockDamageEvent.java +++ b/src/main/java/org/bukkit/event/block/BlockDamageEvent.java -@@ -12,7 +12,7 @@ import org.jetbrains.annotations.NotNull; - *

+@@ -13,7 +13,7 @@ import org.jetbrains.annotations.NotNull; * If a Block Damage event is cancelled, the block will not be damaged. + * @see BlockDamageAbortEvent */ -public class BlockDamageEvent extends BlockEvent implements Cancellable { -+public class BlockDamageEvent extends BlockEvent implements Cancellable, me.lexikiq.HasPlayer { // Parchment ++public class BlockDamageEvent extends BlockEvent implements Cancellable, gg.projecteden.parchment.HasPlayer { // Parchment private static final HandlerList handlers = new HandlerList(); private final Player player; private boolean instaBreak; diff --git a/src/main/java/org/bukkit/event/block/BlockDropItemEvent.java b/src/main/java/org/bukkit/event/block/BlockDropItemEvent.java -index 3dd4bd38e72c04e74e5787fb38ca9abd10bad06b..440792fcdd618b75d9387e8104562b86bfe33c13 100644 +index 3dd4bd38e72c04e74e5787fb38ca9abd10bad06b..3783fb96cc7086bc78dc06c573a1343c3a18c3cb 100644 --- a/src/main/java/org/bukkit/event/block/BlockDropItemEvent.java +++ b/src/main/java/org/bukkit/event/block/BlockDropItemEvent.java @@ -24,7 +24,7 @@ import org.jetbrains.annotations.NotNull; @@ -822,12 +676,12 @@ index 3dd4bd38e72c04e74e5787fb38ca9abd10bad06b..440792fcdd618b75d9387e8104562b86 * block. */ -public class BlockDropItemEvent extends BlockEvent implements Cancellable { -+public class BlockDropItemEvent extends BlockEvent implements Cancellable, me.lexikiq.HasPlayer { // Parchment ++public class BlockDropItemEvent extends BlockEvent implements Cancellable, gg.projecteden.parchment.HasPlayer { // Parchment private static final HandlerList handlers = new HandlerList(); private final Player player; diff --git a/src/main/java/org/bukkit/event/block/BlockFertilizeEvent.java b/src/main/java/org/bukkit/event/block/BlockFertilizeEvent.java -index 695309b4b7ef269ba2496408a5f874f61cd6c445..535e94fb4c2a021a89111ec98c7dbfef1534ac53 100644 +index 695309b4b7ef269ba2496408a5f874f61cd6c445..18207907e7b31ef9c136e857de046f9cce006111 100644 --- a/src/main/java/org/bukkit/event/block/BlockFertilizeEvent.java +++ b/src/main/java/org/bukkit/event/block/BlockFertilizeEvent.java @@ -15,7 +15,7 @@ import org.jetbrains.annotations.Nullable; @@ -835,12 +689,12 @@ index 695309b4b7ef269ba2496408a5f874f61cd6c445..535e94fb4c2a021a89111ec98c7dbfef * {@link StructureGrowEvent}. */ -public class BlockFertilizeEvent extends BlockEvent implements Cancellable { -+public class BlockFertilizeEvent extends BlockEvent implements Cancellable, me.lexikiq.HasPlayer { // Parchment ++public class BlockFertilizeEvent extends BlockEvent implements Cancellable, gg.projecteden.parchment.HasPlayer { // Parchment private static final HandlerList handlers = new HandlerList(); private boolean cancelled; diff --git a/src/main/java/org/bukkit/event/block/BlockIgniteEvent.java b/src/main/java/org/bukkit/event/block/BlockIgniteEvent.java -index 6dcd9f828c6c40e48593b0bad5a44a656eb01645..542cfd60a1f4775544fb040a7d8c05daaf7a5c67 100644 +index 6dcd9f828c6c40e48593b0bad5a44a656eb01645..0651bdd983e90e0e1e8a3565dcb5d97cfd69ce3e 100644 --- a/src/main/java/org/bukkit/event/block/BlockIgniteEvent.java +++ b/src/main/java/org/bukkit/event/block/BlockIgniteEvent.java @@ -14,7 +14,7 @@ import org.jetbrains.annotations.Nullable; @@ -848,12 +702,12 @@ index 6dcd9f828c6c40e48593b0bad5a44a656eb01645..542cfd60a1f4775544fb040a7d8c05da * If a Block Ignite event is cancelled, the block will not be ignited. */ -public class BlockIgniteEvent extends BlockEvent implements Cancellable { -+public class BlockIgniteEvent extends BlockEvent implements Cancellable, me.lexikiq.OptionalPlayer { // Parchment ++public class BlockIgniteEvent extends BlockEvent implements Cancellable, gg.projecteden.parchment.OptionalPlayer { // Parchment private static final HandlerList handlers = new HandlerList(); private final IgniteCause cause; private final Entity ignitingEntity; diff --git a/src/main/java/org/bukkit/event/block/BlockPlaceEvent.java b/src/main/java/org/bukkit/event/block/BlockPlaceEvent.java -index be0a2d1f234d8265d98e54e518a994957b1f3ab7..ef5471f00a6c308368dd92f40fd1f3abe60e3e2b 100644 +index be0a2d1f234d8265d98e54e518a994957b1f3ab7..54cd6735fbcad009330927d760f8bd93ea9c51ec 100644 --- a/src/main/java/org/bukkit/event/block/BlockPlaceEvent.java +++ b/src/main/java/org/bukkit/event/block/BlockPlaceEvent.java @@ -14,7 +14,7 @@ import org.jetbrains.annotations.NotNull; @@ -861,12 +715,12 @@ index be0a2d1f234d8265d98e54e518a994957b1f3ab7..ef5471f00a6c308368dd92f40fd1f3ab * If a Block Place event is cancelled, the block will not be placed. */ -public class BlockPlaceEvent extends BlockEvent implements Cancellable { -+public class BlockPlaceEvent extends BlockEvent implements Cancellable, me.lexikiq.HasPlayer { // Parchment ++public class BlockPlaceEvent extends BlockEvent implements Cancellable, gg.projecteden.parchment.HasPlayer { // Parchment private static final HandlerList handlers = new HandlerList(); protected boolean cancel; protected boolean canBuild; diff --git a/src/main/java/org/bukkit/event/block/SignChangeEvent.java b/src/main/java/org/bukkit/event/block/SignChangeEvent.java -index 1f79f704abf339150df08900b8ea7da4cefef258..d08d9a87c89effcc4882aeda67019f7278aa099c 100644 +index 1268066e30ddb0cd3792ea4b3de894eb04196669..1e20629da438651d3987258b93cf9caf9eff9452 100644 --- a/src/main/java/org/bukkit/event/block/SignChangeEvent.java +++ b/src/main/java/org/bukkit/event/block/SignChangeEvent.java @@ -12,7 +12,7 @@ import org.jetbrains.annotations.Nullable; @@ -874,12 +728,12 @@ index 1f79f704abf339150df08900b8ea7da4cefef258..d08d9a87c89effcc4882aeda67019f72 * If a Sign Change event is cancelled, the sign will not be changed. */ -public class SignChangeEvent extends BlockEvent implements Cancellable { -+public class SignChangeEvent extends BlockEvent implements Cancellable, me.lexikiq.HasPlayer { // Parchment ++public class SignChangeEvent extends BlockEvent implements Cancellable, gg.projecteden.parchment.HasPlayer { // Parchment private static final HandlerList handlers = new HandlerList(); private boolean cancel = false; private final Player player; diff --git a/src/main/java/org/bukkit/event/entity/EntityEnterLoveModeEvent.java b/src/main/java/org/bukkit/event/entity/EntityEnterLoveModeEvent.java -index 59aab10c2d27247eb77bd71d75b5f9126aa0fb12..6794fe6835ad8a5b1a3194288631f7178fa94b72 100644 +index 59aab10c2d27247eb77bd71d75b5f9126aa0fb12..b42465617e83d3413ab647cd9c78212b61ca5833 100644 --- a/src/main/java/org/bukkit/event/entity/EntityEnterLoveModeEvent.java +++ b/src/main/java/org/bukkit/event/entity/EntityEnterLoveModeEvent.java @@ -13,7 +13,7 @@ import org.jetbrains.annotations.Nullable; @@ -887,7 +741,7 @@ index 59aab10c2d27247eb77bd71d75b5f9126aa0fb12..6794fe6835ad8a5b1a3194288631f717 * make the entity enter into love mode. */ -public class EntityEnterLoveModeEvent extends EntityEvent implements Cancellable { -+public class EntityEnterLoveModeEvent extends EntityEvent implements Cancellable, me.lexikiq.OptionalHumanEntity { // Parchment ++public class EntityEnterLoveModeEvent extends EntityEvent implements Cancellable, gg.projecteden.parchment.OptionalHumanEntity { // Parchment private static final HandlerList handlers = new HandlerList(); private boolean cancel; @@ -921,7 +775,7 @@ index 59aab10c2d27247eb77bd71d75b5f9126aa0fb12..6794fe6835ad8a5b1a3194288631f717 /** * Gets the amount of ticks that the animal will fall in love for. diff --git a/src/main/java/org/bukkit/event/entity/EntityExplodeEvent.java b/src/main/java/org/bukkit/event/entity/EntityExplodeEvent.java -index 10d0e18dfd423b108fe381e8142867eb10399359..9877ca9ee25f4f10b130085b70e02eedf7b5b469 100644 +index 10d0e18dfd423b108fe381e8142867eb10399359..7f9f266057de42261fa06e4874d7bec5388c90c7 100644 --- a/src/main/java/org/bukkit/event/entity/EntityExplodeEvent.java +++ b/src/main/java/org/bukkit/event/entity/EntityExplodeEvent.java @@ -11,7 +11,7 @@ import org.jetbrains.annotations.NotNull; @@ -929,12 +783,12 @@ index 10d0e18dfd423b108fe381e8142867eb10399359..9877ca9ee25f4f10b130085b70e02eed * Called when an entity explodes */ -public class EntityExplodeEvent extends EntityEvent implements Cancellable { -+public class EntityExplodeEvent extends EntityEvent implements Cancellable, me.lexikiq.HasLocation { // Parchment ++public class EntityExplodeEvent extends EntityEvent implements Cancellable, gg.projecteden.parchment.HasLocation { // Parchment private static final HandlerList handlers = new HandlerList(); private boolean cancel; private final Location location; diff --git a/src/main/java/org/bukkit/event/entity/EntityPlaceEvent.java b/src/main/java/org/bukkit/event/entity/EntityPlaceEvent.java -index ea8f9ed43d8e4158e6c9c345252a94a5000c5561..d9000c142b4097ba17f7333864f0fa197f259300 100644 +index ea8f9ed43d8e4158e6c9c345252a94a5000c5561..98d308eda8287cb1f1a0aab5208c7c6f13047c05 100644 --- a/src/main/java/org/bukkit/event/entity/EntityPlaceEvent.java +++ b/src/main/java/org/bukkit/event/entity/EntityPlaceEvent.java @@ -16,7 +16,7 @@ import org.jetbrains.annotations.Nullable; @@ -942,12 +796,12 @@ index ea8f9ed43d8e4158e6c9c345252a94a5000c5561..d9000c142b4097ba17f7333864f0fa19 * armor stands, boats, minecarts, and end crystals. */ -public class EntityPlaceEvent extends EntityEvent implements Cancellable { -+public class EntityPlaceEvent extends EntityEvent implements Cancellable, me.lexikiq.OptionalPlayer { // Parchment ++public class EntityPlaceEvent extends EntityEvent implements Cancellable, gg.projecteden.parchment.OptionalPlayer { // Parchment private static final HandlerList handlers = new HandlerList(); private boolean cancelled; diff --git a/src/main/java/org/bukkit/event/entity/EntityPortalEnterEvent.java b/src/main/java/org/bukkit/event/entity/EntityPortalEnterEvent.java -index 6818e9f0ba32ca1a1e612703f7526b29f5a6438f..9bcc13260ed26a75a1325fe6598bfed51f63496c 100644 +index 6818e9f0ba32ca1a1e612703f7526b29f5a6438f..c9c4a6673fd3995bb9638b0d25fa212412cda807 100644 --- a/src/main/java/org/bukkit/event/entity/EntityPortalEnterEvent.java +++ b/src/main/java/org/bukkit/event/entity/EntityPortalEnterEvent.java @@ -8,7 +8,7 @@ import org.jetbrains.annotations.NotNull; @@ -955,12 +809,12 @@ index 6818e9f0ba32ca1a1e612703f7526b29f5a6438f..9bcc13260ed26a75a1325fe6598bfed5 * Called when an entity comes into contact with a portal */ -public class EntityPortalEnterEvent extends EntityEvent { -+public class EntityPortalEnterEvent extends EntityEvent implements me.lexikiq.HasLocation { // Parchment ++public class EntityPortalEnterEvent extends EntityEvent implements gg.projecteden.parchment.HasLocation { // Parchment private static final HandlerList handlers = new HandlerList(); private final Location location; diff --git a/src/main/java/org/bukkit/event/entity/EntitySpawnEvent.java b/src/main/java/org/bukkit/event/entity/EntitySpawnEvent.java -index 961ee511342cd3a12ff2ff74d7b4683c6753123d..35aaa2479ef2ede010162230a1b683de5811c4bb 100644 +index 961ee511342cd3a12ff2ff74d7b4683c6753123d..892732ab5ae58ec980c4fd05a5a3dfdcbd70a528 100644 --- a/src/main/java/org/bukkit/event/entity/EntitySpawnEvent.java +++ b/src/main/java/org/bukkit/event/entity/EntitySpawnEvent.java @@ -11,7 +11,7 @@ import org.jetbrains.annotations.NotNull; @@ -968,12 +822,12 @@ index 961ee511342cd3a12ff2ff74d7b4683c6753123d..35aaa2479ef2ede010162230a1b683de * If an Entity Spawn event is cancelled, the entity will not spawn. */ -public class EntitySpawnEvent extends EntityEvent implements Cancellable { -+public class EntitySpawnEvent extends EntityEvent implements Cancellable, me.lexikiq.HasLocation { // Parchment ++public class EntitySpawnEvent extends EntityEvent implements Cancellable, gg.projecteden.parchment.HasLocation { // Parchment private static final HandlerList handlers = new HandlerList(); private boolean canceled; diff --git a/src/main/java/org/bukkit/event/entity/ItemDespawnEvent.java b/src/main/java/org/bukkit/event/entity/ItemDespawnEvent.java -index 6fc66197eb2c5d59c70d8d028b7963748371edbe..f4c02474f16a009fccd480f6a59bb937c96bbfb7 100644 +index 6fc66197eb2c5d59c70d8d028b7963748371edbe..dc45ec5b6ae8e2958d83a113d23ab0b1a911de3f 100644 --- a/src/main/java/org/bukkit/event/entity/ItemDespawnEvent.java +++ b/src/main/java/org/bukkit/event/entity/ItemDespawnEvent.java @@ -13,7 +13,7 @@ import org.jetbrains.annotations.NotNull; @@ -981,12 +835,12 @@ index 6fc66197eb2c5d59c70d8d028b7963748371edbe..f4c02474f16a009fccd480f6a59bb937 * minutes. This behavior is not guaranteed and may change in future versions. */ -public class ItemDespawnEvent extends EntityEvent implements Cancellable { -+public class ItemDespawnEvent extends EntityEvent implements Cancellable, me.lexikiq.HasLocation { // Parchment ++public class ItemDespawnEvent extends EntityEvent implements Cancellable, gg.projecteden.parchment.HasLocation { // Parchment private static final HandlerList handlers = new HandlerList(); private boolean canceled; private final Location location; diff --git a/src/main/java/org/bukkit/event/entity/PlayerLeashEntityEvent.java b/src/main/java/org/bukkit/event/entity/PlayerLeashEntityEvent.java -index 5eb3fb72a13881b8bf0e40037b0002cb0a6eb883..6ab6bb4237418479156bd24d77bc1f24db637969 100644 +index 5eb3fb72a13881b8bf0e40037b0002cb0a6eb883..4d5d0b730ad957e44f549518366841492b537ab2 100644 --- a/src/main/java/org/bukkit/event/entity/PlayerLeashEntityEvent.java +++ b/src/main/java/org/bukkit/event/entity/PlayerLeashEntityEvent.java @@ -10,7 +10,7 @@ import org.jetbrains.annotations.NotNull; @@ -994,12 +848,12 @@ index 5eb3fb72a13881b8bf0e40037b0002cb0a6eb883..6ab6bb4237418479156bd24d77bc1f24 * Called immediately prior to a creature being leashed by a player. */ -public class PlayerLeashEntityEvent extends Event implements Cancellable { -+public class PlayerLeashEntityEvent extends Event implements Cancellable, me.lexikiq.HasPlayer { // Parchment ++public class PlayerLeashEntityEvent extends Event implements Cancellable, gg.projecteden.parchment.HasPlayer { // Parchment private static final HandlerList handlers = new HandlerList(); private final Entity leashHolder; private final Entity entity; diff --git a/src/main/java/org/bukkit/event/hanging/HangingPlaceEvent.java b/src/main/java/org/bukkit/event/hanging/HangingPlaceEvent.java -index 1bcff119ecd95012c568c777e5ca2e891e56831e..a92f0b6a1337cb09896291f3d7da39ae011ce9ce 100644 +index 1bcff119ecd95012c568c777e5ca2e891e56831e..517f115123fa2009ba0837b0754411e93808562f 100644 --- a/src/main/java/org/bukkit/event/hanging/HangingPlaceEvent.java +++ b/src/main/java/org/bukkit/event/hanging/HangingPlaceEvent.java @@ -13,7 +13,7 @@ import org.jetbrains.annotations.Nullable; @@ -1007,12 +861,12 @@ index 1bcff119ecd95012c568c777e5ca2e891e56831e..a92f0b6a1337cb09896291f3d7da39ae * Triggered when a hanging entity is created in the world */ -public class HangingPlaceEvent extends HangingEvent implements Cancellable { -+public class HangingPlaceEvent extends HangingEvent implements Cancellable, me.lexikiq.OptionalPlayer { // Parchment ++public class HangingPlaceEvent extends HangingEvent implements Cancellable, gg.projecteden.parchment.OptionalPlayer { // Parchment private static final HandlerList handlers = new HandlerList(); private boolean cancelled; private final Player player; diff --git a/src/main/java/org/bukkit/event/inventory/FurnaceExtractEvent.java b/src/main/java/org/bukkit/event/inventory/FurnaceExtractEvent.java -index 020739697a0b535cad0b15b574f77cdabbdfa3eb..db95a2096f12c42d84b44bada6048184074a20b4 100644 +index 020739697a0b535cad0b15b574f77cdabbdfa3eb..ee4fd41e66852d5d2c62222c7b884473d3f3001d 100644 --- a/src/main/java/org/bukkit/event/inventory/FurnaceExtractEvent.java +++ b/src/main/java/org/bukkit/event/inventory/FurnaceExtractEvent.java @@ -9,7 +9,7 @@ import org.jetbrains.annotations.NotNull; @@ -1020,12 +874,12 @@ index 020739697a0b535cad0b15b574f77cdabbdfa3eb..db95a2096f12c42d84b44bada6048184 * This event is called when a player takes items out of the furnace */ -public class FurnaceExtractEvent extends BlockExpEvent { -+public class FurnaceExtractEvent extends BlockExpEvent implements me.lexikiq.HasPlayer { // Parchment ++public class FurnaceExtractEvent extends BlockExpEvent implements gg.projecteden.parchment.HasPlayer { // Parchment private final Player player; private final Material itemType; private final int itemAmount; diff --git a/src/main/java/org/bukkit/event/inventory/InventoryCloseEvent.java b/src/main/java/org/bukkit/event/inventory/InventoryCloseEvent.java -index 21ad8888c0e403bfc63518502577d651c02dda05..4dd6182476a4a9b961089f34d5376780e1774fc4 100644 +index 21ad8888c0e403bfc63518502577d651c02dda05..1c59335a8f0a40162190f6fb73ffbfef0cd795d8 100644 --- a/src/main/java/org/bukkit/event/inventory/InventoryCloseEvent.java +++ b/src/main/java/org/bukkit/event/inventory/InventoryCloseEvent.java @@ -9,7 +9,7 @@ import org.jetbrains.annotations.NotNull; @@ -1033,12 +887,12 @@ index 21ad8888c0e403bfc63518502577d651c02dda05..4dd6182476a4a9b961089f34d5376780 * Represents a player related inventory event */ -public class InventoryCloseEvent extends InventoryEvent { -+public class InventoryCloseEvent extends InventoryEvent implements me.lexikiq.HasHumanEntity { // Parchment ++public class InventoryCloseEvent extends InventoryEvent implements gg.projecteden.parchment.HasHumanEntity { // Parchment private static final HandlerList handlers = new HandlerList(); // Paper start private final Reason reason; diff --git a/src/main/java/org/bukkit/event/inventory/InventoryOpenEvent.java b/src/main/java/org/bukkit/event/inventory/InventoryOpenEvent.java -index 9013d043503d175004ad276799e5935b7fa59dc4..2af2c43ba34de3ff6f6a82f5abb4f94f2fa5d19e 100644 +index 9013d043503d175004ad276799e5935b7fa59dc4..4095ca19e6ceff2432e0cbd372e9475f748278a7 100644 --- a/src/main/java/org/bukkit/event/inventory/InventoryOpenEvent.java +++ b/src/main/java/org/bukkit/event/inventory/InventoryOpenEvent.java @@ -9,7 +9,7 @@ import org.jetbrains.annotations.NotNull; @@ -1046,12 +900,12 @@ index 9013d043503d175004ad276799e5935b7fa59dc4..2af2c43ba34de3ff6f6a82f5abb4f94f * Represents a player related inventory event */ -public class InventoryOpenEvent extends InventoryEvent implements Cancellable { -+public class InventoryOpenEvent extends InventoryEvent implements Cancellable, me.lexikiq.HasHumanEntity { // Parchment ++public class InventoryOpenEvent extends InventoryEvent implements Cancellable, gg.projecteden.parchment.HasHumanEntity { // Parchment private static final HandlerList handlers = new HandlerList(); private boolean cancelled; diff --git a/src/main/java/org/bukkit/event/player/AsyncPlayerPreLoginEvent.java b/src/main/java/org/bukkit/event/player/AsyncPlayerPreLoginEvent.java -index 694a81769076ea58aae9f14f076ab80c9952c957..bea28949cc37a652427fc4ab1dfb225c65ea1d9b 100644 +index 635b8787fc235b61c0d5677def034656e4ec4cef..6f15f4adfa552e2f5960464663ee126282086bb1 100644 --- a/src/main/java/org/bukkit/event/player/AsyncPlayerPreLoginEvent.java +++ b/src/main/java/org/bukkit/event/player/AsyncPlayerPreLoginEvent.java @@ -14,7 +14,7 @@ import org.jetbrains.annotations.NotNull; @@ -1059,12 +913,12 @@ index 694a81769076ea58aae9f14f076ab80c9952c957..bea28949cc37a652427fc4ab1dfb225c * This event is asynchronous, and not run using main thread. */ -public class AsyncPlayerPreLoginEvent extends Event { -+public class AsyncPlayerPreLoginEvent extends Event implements me.lexikiq.HasUniqueId { // Parchment ++public class AsyncPlayerPreLoginEvent extends Event implements gg.projecteden.api.interfaces.HasUniqueId { // Parchment private static final HandlerList handlers = new HandlerList(); private Result result; private net.kyori.adventure.text.Component message; // Paper diff --git a/src/main/java/org/bukkit/event/player/PlayerEvent.java b/src/main/java/org/bukkit/event/player/PlayerEvent.java -index f6d3b817de3001f04ea4554c7c39a1290af3fd6d..309d4526816853dfc2d5c3061bd772238776ab74 100644 +index f6d3b817de3001f04ea4554c7c39a1290af3fd6d..44efb5cc62149b34b994eadac488a90269e8ae79 100644 --- a/src/main/java/org/bukkit/event/player/PlayerEvent.java +++ b/src/main/java/org/bukkit/event/player/PlayerEvent.java @@ -7,7 +7,7 @@ import org.jetbrains.annotations.NotNull; @@ -1072,12 +926,12 @@ index f6d3b817de3001f04ea4554c7c39a1290af3fd6d..309d4526816853dfc2d5c3061bd77223 * Represents a player related event */ -public abstract class PlayerEvent extends Event { -+public abstract class PlayerEvent extends Event implements me.lexikiq.HasPlayer { // Parchment ++public abstract class PlayerEvent extends Event implements gg.projecteden.parchment.HasPlayer { // Parchment protected Player player; public PlayerEvent(@NotNull final Player who) { diff --git a/src/main/java/org/bukkit/event/player/PlayerPreLoginEvent.java b/src/main/java/org/bukkit/event/player/PlayerPreLoginEvent.java -index 123979ed64939d615b061f91c19c630e1e1db8c7..0220c4f087fd6b5769a0fa4f03bfd096a1462359 100644 +index 6800132c6288b4588fd02b08d26f016c38f27129..8e333a361cdee30a83e9472285dfb0b30b2e72ca 100644 --- a/src/main/java/org/bukkit/event/player/PlayerPreLoginEvent.java +++ b/src/main/java/org/bukkit/event/player/PlayerPreLoginEvent.java @@ -16,7 +16,7 @@ import org.jetbrains.annotations.NotNull; @@ -1085,12 +939,12 @@ index 123979ed64939d615b061f91c19c630e1e1db8c7..0220c4f087fd6b5769a0fa4f03bfd096 @Deprecated @Warning(reason = "This event causes a login thread to synchronize with the main thread") -public class PlayerPreLoginEvent extends Event { -+public class PlayerPreLoginEvent extends Event implements me.lexikiq.HasUniqueId { // Parchment ++public class PlayerPreLoginEvent extends Event implements gg.projecteden.api.interfaces.HasUniqueId { // Parchment private static final HandlerList handlers = new HandlerList(); private Result result; private net.kyori.adventure.text.Component message; // Paper diff --git a/src/main/java/org/bukkit/event/player/PlayerUnleashEntityEvent.java b/src/main/java/org/bukkit/event/player/PlayerUnleashEntityEvent.java -index 68eab1563caba1ee4f52b308f390e4e172667fc5..7ebf60f80ac29f3969d2d70fa0cf668f2933b647 100644 +index 68eab1563caba1ee4f52b308f390e4e172667fc5..7f2be08b1e7b6df4bab8a8996bc276f369a8ff78 100644 --- a/src/main/java/org/bukkit/event/player/PlayerUnleashEntityEvent.java +++ b/src/main/java/org/bukkit/event/player/PlayerUnleashEntityEvent.java @@ -9,7 +9,7 @@ import org.jetbrains.annotations.NotNull; @@ -1098,12 +952,12 @@ index 68eab1563caba1ee4f52b308f390e4e172667fc5..7ebf60f80ac29f3969d2d70fa0cf668f * Called prior to an entity being unleashed due to a player's action. */ -public class PlayerUnleashEntityEvent extends EntityUnleashEvent implements Cancellable { -+public class PlayerUnleashEntityEvent extends EntityUnleashEvent implements Cancellable, me.lexikiq.HasPlayer { // Parchment ++public class PlayerUnleashEntityEvent extends EntityUnleashEvent implements Cancellable, gg.projecteden.parchment.HasPlayer { // Parchment private final Player player; private boolean cancelled = false; diff --git a/src/main/java/org/bukkit/event/raid/RaidTriggerEvent.java b/src/main/java/org/bukkit/event/raid/RaidTriggerEvent.java -index 128e43cf12205f82f2b119a773208502cdccfdd4..f0a5fc39fa35ec71cf9cadb7d0cff379f5d8c6cb 100644 +index 128e43cf12205f82f2b119a773208502cdccfdd4..ca1fed3081e2b0a3271a2dfa0f49cce78bdb8e23 100644 --- a/src/main/java/org/bukkit/event/raid/RaidTriggerEvent.java +++ b/src/main/java/org/bukkit/event/raid/RaidTriggerEvent.java @@ -11,7 +11,7 @@ import org.jetbrains.annotations.NotNull; @@ -1111,25 +965,25 @@ index 128e43cf12205f82f2b119a773208502cdccfdd4..f0a5fc39fa35ec71cf9cadb7d0cff379 * enters a village). */ -public class RaidTriggerEvent extends RaidEvent implements Cancellable { -+public class RaidTriggerEvent extends RaidEvent implements Cancellable, me.lexikiq.HasPlayer { // Parchment ++public class RaidTriggerEvent extends RaidEvent implements Cancellable, gg.projecteden.parchment.HasPlayer { // Parchment private static final HandlerList handlers = new HandlerList(); // diff --git a/src/main/java/org/bukkit/event/server/TabCompleteEvent.java b/src/main/java/org/bukkit/event/server/TabCompleteEvent.java -index f96c4ba53ab41ea66d4f9a4d54eeabb63f992b58..39fa65a2b130c00b2ba5d90e2fa673a6d9c85f4b 100644 +index 4a3451af454295ac3e1b688e6665cad9fc594c82..b88cebb219577d59cc338be89c6f391d10702095 100644 --- a/src/main/java/org/bukkit/event/server/TabCompleteEvent.java +++ b/src/main/java/org/bukkit/event/server/TabCompleteEvent.java -@@ -21,7 +21,7 @@ import org.jetbrains.annotations.Nullable; +@@ -19,7 +19,7 @@ import org.jetbrains.annotations.NotNull; * advised to ensure the client does not have permission for the relevant * commands, or use {@link PlayerCommandSendEvent}. */ -public class TabCompleteEvent extends Event implements Cancellable { -+public class TabCompleteEvent extends Event implements Cancellable, me.lexikiq.OptionalLocation { // Parchment ++public class TabCompleteEvent extends Event implements Cancellable, gg.projecteden.parchment.OptionalLocation { // Parchment private static final HandlerList handlers = new HandlerList(); // diff --git a/src/main/java/org/bukkit/event/world/GenericGameEvent.java b/src/main/java/org/bukkit/event/world/GenericGameEvent.java -index 1746b66510e7b9c8708018582034b04714c29867..8f667cd2f05144bdc863f81b213f0a99b7f695b6 100644 +index 2a2a329877d8da45c2d6afecf78ce88d52635cad..22cdf3662b02fb5751ac6d913d781084cd7eee5b 100644 --- a/src/main/java/org/bukkit/event/world/GenericGameEvent.java +++ b/src/main/java/org/bukkit/event/world/GenericGameEvent.java @@ -15,7 +15,7 @@ import org.jetbrains.annotations.Nullable; @@ -1137,12 +991,12 @@ index 1746b66510e7b9c8708018582034b04714c29867..8f667cd2f05144bdc863f81b213f0a99 * used internally by Sculk sensors. */ -public class GenericGameEvent extends WorldEvent implements Cancellable { -+public class GenericGameEvent extends WorldEvent implements Cancellable, me.lexikiq.HasLocation { // Parchment ++public class GenericGameEvent extends WorldEvent implements Cancellable, gg.projecteden.parchment.HasLocation { // Parchment private static final HandlerList handlers = new HandlerList(); private final GameEvent event; diff --git a/src/main/java/org/bukkit/event/world/StructureGrowEvent.java b/src/main/java/org/bukkit/event/world/StructureGrowEvent.java -index 7af8d6e51c824cf0592b722b834f1d4986e3cc08..8baaa32094bacb181848904f18184fe6f90289df 100644 +index 7af8d6e51c824cf0592b722b834f1d4986e3cc08..c28d62fc3dc359f9ebcf926094198ee3c92467aa 100644 --- a/src/main/java/org/bukkit/event/world/StructureGrowEvent.java +++ b/src/main/java/org/bukkit/event/world/StructureGrowEvent.java @@ -14,7 +14,7 @@ import org.jetbrains.annotations.Nullable; @@ -1150,12 +1004,12 @@ index 7af8d6e51c824cf0592b722b834f1d4986e3cc08..8baaa32094bacb181848904f18184fe6 * Tree), (Mushroom {@literal ->} Huge Mushroom), naturally or using bonemeal. */ -public class StructureGrowEvent extends WorldEvent implements Cancellable { -+public class StructureGrowEvent extends WorldEvent implements Cancellable, me.lexikiq.OptionalPlayer { // Parchment ++public class StructureGrowEvent extends WorldEvent implements Cancellable, gg.projecteden.parchment.OptionalPlayer { // Parchment private static final HandlerList handlers = new HandlerList(); private boolean cancelled = false; private final Location location; diff --git a/src/main/java/org/bukkit/inventory/Inventory.java b/src/main/java/org/bukkit/inventory/Inventory.java -index 8f00cb2e3bc9963e9657c1b2493e8b015a6664d0..7029f3e6fe4a5167265a70eb3113f25836c6e121 100644 +index 1b577c03c3152d22b70f8bdb321b28ad8fbbc3af..b3449a874666bcd67950ec12da41738f7c24ddee 100644 --- a/src/main/java/org/bukkit/inventory/Inventory.java +++ b/src/main/java/org/bukkit/inventory/Inventory.java @@ -25,7 +25,7 @@ import org.jetbrains.annotations.Nullable; @@ -1163,12 +1017,12 @@ index 8f00cb2e3bc9963e9657c1b2493e8b015a6664d0..7029f3e6fe4a5167265a70eb3113f258 * @see #getStorageContents() */ -public interface Inventory extends Iterable { -+public interface Inventory extends Iterable, me.lexikiq.OptionalLocation { // Parchment ++public interface Inventory extends Iterable, gg.projecteden.parchment.OptionalLocation { // Parchment /** * Returns the size of the inventory diff --git a/src/main/java/org/bukkit/inventory/InventoryView.java b/src/main/java/org/bukkit/inventory/InventoryView.java -index b06995aa57aa9cba0bb59f1d26d81015619a08e6..d599b72c2441a023dff8ee4bdaf587b21471f11f 100644 +index 2448e70d75ae7a678c6befac4506c103edb78875..65ca144618f74bc8e317a4b9c2732ad5ed13a208 100644 --- a/src/main/java/org/bukkit/inventory/InventoryView.java +++ b/src/main/java/org/bukkit/inventory/InventoryView.java @@ -14,7 +14,7 @@ import org.jetbrains.annotations.Nullable; @@ -1176,12 +1030,12 @@ index b06995aa57aa9cba0bb59f1d26d81015619a08e6..d599b72c2441a023dff8ee4bdaf587b2 * as it should. */ -public abstract class InventoryView { -+public abstract class InventoryView implements me.lexikiq.HasHumanEntity { // Parchment ++public abstract class InventoryView implements gg.projecteden.parchment.HasHumanEntity { // Parchment public static final int OUTSIDE = -999; /** * Represents various extra properties of certain inventory windows. diff --git a/src/main/java/org/bukkit/loot/LootContext.java b/src/main/java/org/bukkit/loot/LootContext.java -index e307f9fc45a4e5d742b78c4cda9a41d7f259a515..ab532552e4a10e03125b64e0884650a841275cca 100644 +index 71b7aa9d675e1714e286e6fd4015ead036d912e0..95e120068a7c5c96b1b8553df9cf8654ba63a325 100644 --- a/src/main/java/org/bukkit/loot/LootContext.java +++ b/src/main/java/org/bukkit/loot/LootContext.java @@ -11,7 +11,7 @@ import org.jetbrains.annotations.Nullable; @@ -1189,7 +1043,7 @@ index e307f9fc45a4e5d742b78c4cda9a41d7f259a515..ab532552e4a10e03125b64e0884650a8 * generated loot. */ -public final class LootContext { -+public final class LootContext implements me.lexikiq.HasLocation { // Parchment ++public final class LootContext implements gg.projecteden.parchment.HasLocation { // Parchment public static final int DEFAULT_LOOT_MODIFIER = -1; diff --git a/patches/api/0001-Build-changes.patch b/patches/api/0001-Build-changes.patch deleted file mode 100644 index 7915d70..0000000 --- a/patches/api/0001-Build-changes.patch +++ /dev/null @@ -1,18 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: lexikiq -Date: Fri, 2 Jul 2021 01:33:12 -0400 -Subject: [PATCH] Build changes - - -diff --git a/build.gradle.kts b/build.gradle.kts -index 689d470ebe2c7e25e4c87f6127978d1d283e55b5..2715c109829dbdb93de12b06652988f5cd3353c5 100644 ---- a/build.gradle.kts -+++ b/build.gradle.kts -@@ -39,6 +39,7 @@ dependencies { - apiAndDocs("net.kyori:adventure-text-serializer-plain") - api("org.apache.logging.log4j:log4j-api:2.14.1") // Paper - api("org.slf4j:slf4j-api:1.7.30") // Paper -+ api(project(":Parchment-Common")) // Parchment - - implementation("org.ow2.asm:asm:9.1") - implementation("org.ow2.asm:asm-commons:9.1") diff --git a/patches/api/0002-Add-SoundEvent.patch b/patches/api/0002-Add-SoundEvent.patch new file mode 100644 index 0000000..aa8b4de --- /dev/null +++ b/patches/api/0002-Add-SoundEvent.patch @@ -0,0 +1,394 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: lexikiq +Date: Sat, 19 Jun 2021 22:55:10 -0400 +Subject: [PATCH] Add SoundEvent + + +diff --git a/src/main/java/gg/projecteden/parchment/event/sound/SoundEvent.java b/src/main/java/gg/projecteden/parchment/event/sound/SoundEvent.java +new file mode 100644 +index 0000000000000000000000000000000000000000..e612cecc89b060a9c0fc882754e45c0409febb9d +--- /dev/null ++++ b/src/main/java/gg/projecteden/parchment/event/sound/SoundEvent.java +@@ -0,0 +1,382 @@ ++package gg.projecteden.parchment.event.sound; ++ ++import gg.projecteden.parchment.OptionalHumanEntity; ++import net.kyori.adventure.sound.Sound; ++import org.bukkit.Location; ++import org.bukkit.entity.Entity; ++import org.bukkit.entity.HumanEntity; ++import org.bukkit.entity.Player; ++import org.bukkit.event.Cancellable; ++import org.bukkit.event.Event; ++import org.jetbrains.annotations.NotNull; ++import org.jetbrains.annotations.Nullable; ++import org.slf4j.Logger; ++ ++import java.util.ArrayList; ++import java.util.List; ++import java.util.Objects; ++import java.util.function.BiFunction; ++import java.util.function.Function; ++ ++/** ++ * Called when a sound is sent to a player. ++ * Cancelling this event will prevent the packet from sending. ++ */ ++public final class SoundEvent extends Event implements Cancellable, OptionalHumanEntity { ++ private static final Logger LOGGER = org.slf4j.LoggerFactory.getLogger(SoundEvent.class); ++ ++ private static final org.bukkit.event.HandlerList handlers = new org.bukkit.event.HandlerList(); ++ public static final @NotNull Function DEFAULT_DISTANCE_FUNCTION = event -> event.volume() > 1.0F ? (double) (16.0F * event.volume()) : 16.0D; ++ public static final @NotNull Function> DEFAULT_RECIPIENTS_FUNCTION = new WrappedRecipientsFunction(event -> { ++ final double distance = event.calculateDistance(); ++ final Location loc = event.getEmitter().location(); ++ return loc.getWorld().getPlayers().stream() ++ .filter(player -> { ++ Location pl = player.getLocation(); ++ double x = loc.getX() - pl.getX(); ++ double y = loc.getY() - pl.getY(); ++ double z = loc.getZ() - pl.getZ(); ++ return x * x + y * y + z * z < distance * distance; ++ }) ++ .toList(); ++ }); ++ ++ private @Nullable HumanEntity except; ++ private @NotNull Function<@NotNull Sound, @NotNull Double> distanceFunction; ++ private @NotNull Function<@NotNull SoundEvent, @NotNull List<@NotNull Player>> recipientsFunction; ++ private @NotNull Sound sound; ++ private @NotNull Emitter emitter; ++ private boolean cancelled; ++ private long seed; ++ private @Nullable BiFunction<@NotNull SoundEvent, @NotNull Player, @Nullable Sound> soundOverrideFunction; ++ private @Nullable BiFunction<@NotNull SoundEvent, @NotNull Player, @Nullable Emitter> emitterOverrideFunction; ++ ++ public SoundEvent(@Nullable HumanEntity except, @NotNull Sound sound, @NotNull Emitter emitter, long seed, @Nullable Function distanceFunction, @Nullable Function> recipientsFunction) { ++ super(true); ++ this.except = except; ++ this.sound = Objects.requireNonNull(sound, "sound cannot be null"); ++ this.emitter = Objects.requireNonNull(emitter, "emitter cannot be null"); ++ this.seed = seed; ++ this.distanceFunction = Objects.requireNonNullElse(distanceFunction, DEFAULT_DISTANCE_FUNCTION); ++ this.recipientsFunction = wrapRecipientsFunction(Objects.requireNonNullElse(recipientsFunction, DEFAULT_RECIPIENTS_FUNCTION)); ++ } ++ ++ /** ++ * Gets the player that won't be receiving this sound. ++ * ++ * @return player excluded from receiving this sound ++ * @deprecated use {@link #getException()} for more clarity ++ */ ++ @Override ++ @Deprecated ++ public @Nullable HumanEntity getPlayer() { ++ return getException(); ++ } ++ ++ /** ++ * Gets the player that won't be receiving this sound. ++ * ++ * @return player excluded from receiving this sound ++ */ ++ public @Nullable HumanEntity getException() { ++ return except; ++ } ++ ++ /** ++ * Sets the player that won't be receiving this sound. ++ * ++ * @param except player excluded from receiving this sound ++ */ ++ public void setException(@Nullable HumanEntity except) { ++ this.except = except; ++ } ++ ++ /** ++ * Gets the sound that will be sent. ++ * ++ * @return sound that will be sent ++ */ ++ public @NotNull Sound getSound() { ++ return sound; ++ } ++ ++ /** ++ * Sets the sound that will be sent. ++ * ++ * @param sound sound that will be sent ++ */ ++ public void setSound(@NotNull Sound sound) { ++ this.sound = Objects.requireNonNull(sound, "sound cannot be null"); ++ } ++ ++ /** ++ * Gets the emitter which determines how and where the sound will be played from. ++ * ++ * @return emitter which determines how and where the sound will be played from ++ */ ++ public @NotNull Emitter getEmitter() { ++ return emitter; ++ } ++ ++ /** ++ * Sets the emitter which determines how and where the sound will be played from. ++ * ++ * @param emitter emitter which determines how and where the sound will be played from ++ */ ++ public void setEmitter(@NotNull Emitter emitter) { ++ this.emitter = Objects.requireNonNull(emitter, "emitter cannot be null"); ++ } ++ ++ /** ++ * Gets the seed used to generate the sound. ++ * ++ * @return seed used to generate the sound ++ */ ++ public long getSeed() { ++ return seed; ++ } ++ ++ /** ++ * Sets the seed used to generate the sound. ++ * ++ * @param seed seed used to generate the sound ++ */ ++ public void setSeed(long seed) { ++ this.seed = seed; ++ } ++ ++ /** ++ * Calculates the distance of the sound. ++ *

++ * The distance value is dynamically calculated using a ++ * {@link Function Function<SoundEvent, Double>}. ++ * In vanilla Minecraft, the default function is {@link #DEFAULT_DISTANCE_FUNCTION} ++ * ({@code event -> event.getVolume() > 1.0F ? (double) (16.0F * event.getVolume()) : 16.0D}). ++ *

++ * This is used by the vanilla implementation of {@link #calculateRecipients()}, though custom ++ * implementations won't always use this method. ++ * ++ * @return calculated distance ++ * @see #getDistanceFunction() ++ * @see #setDistanceFunction(Function) ++ */ ++ public double calculateDistance() { ++ return distanceFunction.apply(sound); ++ } ++ ++ /** ++ * Gets the function that calculates the distance of the sound. ++ * ++ * @return distance function ++ * @see #calculateDistance() ++ * @see #setDistanceFunction(Function) ++ */ ++ public @NotNull Function<@NotNull Sound, @NotNull Double> getDistanceFunction() { ++ return distanceFunction; ++ } ++ ++ /** ++ * Sets the function that calculates the distance of the sound. ++ * ++ * @param distanceFunction distance function ++ * @see #calculateDistance() ++ * @see #getDistanceFunction() ++ */ ++ public void setDistanceFunction(@NotNull Function<@NotNull Sound, @NotNull Double> distanceFunction) { ++ this.distanceFunction = Objects.requireNonNull(distanceFunction, "distanceFunction cannot be null"); ++ } ++ ++ /** ++ * Determines which players will receive this sound packet. ++ * ++ * @return immutable list of players ++ * @see #getRecipientsFunction() ++ * @see #setRecipientsFunction(Function) ++ */ ++ public @NotNull List calculateRecipients() { ++ return recipientsFunction.apply(this); ++ } ++ ++ /** ++ * Gets the function that determines which players will receive the sound packet. ++ * ++ * @return recipients function ++ * @see #calculateRecipients() ++ * @see #setRecipientsFunction(Function) ++ */ ++ public @NotNull Function<@NotNull SoundEvent, @NotNull List<@NotNull Player>> getRecipientsFunction() { ++ return recipientsFunction; ++ } ++ ++ /** ++ * Sets the function that determines which players will receive the sound packet. ++ *

++ * This function does not need to query {@link #getException()} as this is done automatically. ++ * ++ * @param recipientsFunction recipients function ++ * @see #calculateRecipients() ++ * @see #getRecipientsFunction() ++ */ ++ public void setRecipientsFunction(@NotNull Function<@NotNull SoundEvent, @NotNull List<@NotNull Player>> recipientsFunction) { ++ this.recipientsFunction = wrapRecipientsFunction(Objects.requireNonNull(recipientsFunction, "recipientsFunction cannot be null")); ++ } ++ ++ /** ++ * Gets the function that overrides what {@link Sound} is sent to a {@link Player}. ++ * ++ * @return sound override function (or {@code null} if not overridden) ++ */ ++ public @Nullable BiFunction<@NotNull SoundEvent, @NotNull Player, @Nullable Sound> getSoundOverrideFunction() { ++ return soundOverrideFunction; ++ } ++ ++ /** ++ * Sets the function that overrides what {@link Sound} is sent to a {@link Player}. ++ * ++ * @param soundOverrideFunction function which accepts a sound event and a player and returns ++ * a sound (or {@code null} if the default sound should be used) ++ */ ++ public void setSoundOverrideFunction(@Nullable BiFunction<@NotNull SoundEvent, @NotNull Player, @Nullable Sound> soundOverrideFunction) { ++ this.soundOverrideFunction = soundOverrideFunction; ++ } ++ ++ /** ++ * Calculates the sound that will be sent to a {@link Player}. ++ * ++ * @param player player to calculate the sound for ++ * @return sound that will be sent to the player ++ */ ++ public @NotNull Sound calculateSound(@NotNull Player player) { ++ if (soundOverrideFunction != null) { ++ try { ++ Sound override = soundOverrideFunction.apply(this, player); ++ if (override != null) { ++ return override; ++ } ++ } catch (Throwable e) { ++ LOGGER.error("Error while overriding sound for player " + player.getName(), e); ++ } ++ } ++ return sound; ++ } ++ ++ /** ++ * Gets the function that overrides what {@link Emitter} is used when playing this sound to a ++ * {@link Player}. ++ * ++ * @return emitter override function (or {@code null} if not overridden) ++ */ ++ public @Nullable BiFunction<@NotNull SoundEvent, @NotNull Player, @Nullable Emitter> getEmitterOverrideFunction() { ++ return emitterOverrideFunction; ++ } ++ ++ /** ++ * Sets the function that overrides what {@link Emitter} is used when playing this sound to a ++ * {@link Player}. ++ * ++ * @param emitterOverrideFunction function which accepts a sound event and a player and returns ++ * an emitter ++ * (or {@code null} if the default emitter should be used) ++ */ ++ public void setEmitterOverrideFunction(@Nullable BiFunction<@NotNull SoundEvent, @NotNull Player, @Nullable Emitter> emitterOverrideFunction) { ++ this.emitterOverrideFunction = emitterOverrideFunction; ++ } ++ ++ /** ++ * Calculates the emitter that will be used when playing this sound to a {@link Player}. ++ * ++ * @param player player to calculate the emitter for ++ * @return emitter that will be used when playing the sound to the player ++ */ ++ public @NotNull Emitter calculateEmitter(@NotNull Player player) { ++ if (emitterOverrideFunction != null) { ++ try { ++ Emitter override = emitterOverrideFunction.apply(this, player); ++ if (override != null) { ++ return override; ++ } ++ } catch (Throwable e) { ++ LOGGER.error("Error while overriding emitter for player " + player.getName(), e); ++ } ++ } ++ return emitter; ++ } ++ ++ @Override ++ public boolean isCancelled() { ++ return cancelled; ++ } ++ ++ @Override ++ public void setCancelled(boolean cancelled) { ++ this.cancelled = cancelled; ++ } ++ ++ @NotNull ++ public static org.bukkit.event.HandlerList getHandlerList() { ++ return handlers; ++ } ++ ++ @Override ++ public @NotNull org.bukkit.event.HandlerList getHandlers() { ++ return handlers; ++ } ++ ++ private record WrappedRecipientsFunction(@NotNull Function> wrapped) implements Function> { ++ @Override ++ public List apply(SoundEvent event) { ++ List recipients = wrapped.apply(event); ++ HumanEntity except = event.getException(); ++ if (except != null) { ++ List filteredRecipients = new ArrayList<>(recipients.size()); ++ for (Player player : recipients) { ++ if (!player.getUniqueId().equals(except.getUniqueId())) ++ filteredRecipients.add(player); ++ } ++ return filteredRecipients; ++ } ++ return recipients; ++ } ++ } ++ ++ @NotNull ++ private static Function> wrapRecipientsFunction(@NotNull Function> recipientsFunction) { ++ if (recipientsFunction instanceof WrappedRecipientsFunction) ++ return recipientsFunction; ++ else ++ return new WrappedRecipientsFunction(recipientsFunction); ++ } ++ ++ /** ++ * The class which determines where a sound will emit from. ++ */ ++ public sealed interface Emitter permits EntityEmitter, LocationEmitter { ++ /** ++ * Gets the location at which the sound will be played. ++ * ++ * @return sound's location ++ */ ++ @NotNull ++ Location location(); ++ } ++ ++ /** ++ * An emitter which plays a sound from an entity. ++ * ++ * @param entity the entity from which the sound will be played ++ */ ++ public record EntityEmitter(@NotNull Entity entity) implements Emitter { ++ @Override ++ public @NotNull Location location() { ++ return entity.getLocation(); ++ } ++ } ++ ++ /** ++ * An emitter which plays a sound from a location. ++ * ++ * @param location the location from which the sound will be played ++ */ ++ public record LocationEmitter(@NotNull Location location) implements Emitter { ++ } ++} diff --git a/patches/api/0004-Add-PlayerUseRespawnAnchorEvent.patch b/patches/api/0003-Add-PlayerUseRespawnAnchorEvent.patch similarity index 88% rename from patches/api/0004-Add-PlayerUseRespawnAnchorEvent.patch rename to patches/api/0003-Add-PlayerUseRespawnAnchorEvent.patch index c4c485f..ff2b8a9 100644 --- a/patches/api/0004-Add-PlayerUseRespawnAnchorEvent.patch +++ b/patches/api/0003-Add-PlayerUseRespawnAnchorEvent.patch @@ -4,13 +4,13 @@ Date: Thu, 13 May 2021 23:55:02 -0400 Subject: [PATCH] Add PlayerUseRespawnAnchorEvent -diff --git a/src/main/java/me/lexikiq/event/player/PlayerUseRespawnAnchorEvent.java b/src/main/java/me/lexikiq/event/player/PlayerUseRespawnAnchorEvent.java +diff --git a/src/main/java/gg/projecteden/parchment/event/player/PlayerUseRespawnAnchorEvent.java b/src/main/java/gg/projecteden/parchment/event/player/PlayerUseRespawnAnchorEvent.java new file mode 100644 -index 0000000000000000000000000000000000000000..fcf552bb84a10794dda178b337768efe4781facd +index 0000000000000000000000000000000000000000..c2dfb2e8dfe6462b12c2425225d2f7a66a53de8b --- /dev/null -+++ b/src/main/java/me/lexikiq/event/player/PlayerUseRespawnAnchorEvent.java ++++ b/src/main/java/gg/projecteden/parchment/event/player/PlayerUseRespawnAnchorEvent.java @@ -0,0 +1,117 @@ -+package me.lexikiq.event.player; ++package gg.projecteden.parchment.event.player; + +import com.google.common.base.Preconditions; +import org.bukkit.block.Block; diff --git a/patches/api/0003-Add-SoundEvent.patch b/patches/api/0003-Add-SoundEvent.patch deleted file mode 100644 index ee90024..0000000 --- a/patches/api/0003-Add-SoundEvent.patch +++ /dev/null @@ -1,721 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: lexikiq -Date: Sat, 19 Jun 2021 22:55:10 -0400 -Subject: [PATCH] Add SoundEvent - - -diff --git a/src/main/java/me/lexikiq/event/sound/EntitySoundEvent.java b/src/main/java/me/lexikiq/event/sound/EntitySoundEvent.java -new file mode 100644 -index 0000000000000000000000000000000000000000..19c9f7af91402d5f966915ebc80d76ab9ac92872 ---- /dev/null -+++ b/src/main/java/me/lexikiq/event/sound/EntitySoundEvent.java -@@ -0,0 +1,67 @@ -+package me.lexikiq.event.sound; -+ -+import org.apache.commons.lang.Validate; -+import org.bukkit.Sound; -+import org.bukkit.SoundCategory; -+import org.bukkit.World; -+import org.bukkit.entity.Entity; -+import org.bukkit.entity.HumanEntity; -+import org.bukkit.entity.Player; -+import org.bukkit.util.Vector; -+import org.jetbrains.annotations.NotNull; -+import org.jetbrains.annotations.Nullable; -+ -+import java.util.List; -+import java.util.Objects; -+import java.util.function.Function; -+ -+/** -+ * Called when an entity sound is sent to a player. -+ * Cancelling this event will prevent the packet from sending. -+ *

-+ * This type of sound represents one that will follow the {@link #getOrigin() originating} entity. -+ */ -+public class EntitySoundEvent extends NamedSoundEvent { -+ private @NotNull Entity origin; -+ -+ @Deprecated -+ public EntitySoundEvent(@Nullable HumanEntity except, @NotNull Entity origin, @NotNull Sound sound, @NotNull SoundCategory category, float volume, float pitch) { -+ this(except, origin, sound, category, volume, pitch, null, null); -+ } -+ -+ public EntitySoundEvent(@Nullable HumanEntity except, @NotNull Entity origin, @NotNull Sound sound, @NotNull SoundCategory category, float volume, float pitch, @Nullable Function distanceFunction, @Nullable Function> recipientsFunction) { -+ super(except, sound, category, volume, pitch, distanceFunction, recipientsFunction); -+ this.origin = Objects.requireNonNull(origin, "origin cannot be null"); -+ } -+ -+ /** -+ * Gets the entity that the sound is originating from. -+ * -+ * @return originating entity -+ */ -+ public @NotNull Entity getOrigin() { -+ return origin; -+ } -+ -+ /** -+ * Sets the entity that the sound will originate from. -+ * -+ * @param origin originating entity -+ */ -+ public void setOrigin(@NotNull Entity origin) { -+ Validate.notNull(origin, "origin cannot be null"); -+ if (!this.origin.getWorld().equals(origin.getWorld())) -+ throw new IllegalArgumentException("Entity must be in same world as originating location"); -+ this.origin = origin; -+ } -+ -+ @Override -+ public @NotNull World getWorld() { -+ return origin.getWorld(); -+ } -+ -+ @Override -+ public @NotNull Vector getPosition() { -+ return origin.getLocation().toVector(); -+ } -+} -diff --git a/src/main/java/me/lexikiq/event/sound/LocationCustomSoundEvent.java b/src/main/java/me/lexikiq/event/sound/LocationCustomSoundEvent.java -new file mode 100644 -index 0000000000000000000000000000000000000000..9d7f3656c55a0bb7a8258a0418954563f8730551 ---- /dev/null -+++ b/src/main/java/me/lexikiq/event/sound/LocationCustomSoundEvent.java -@@ -0,0 +1,139 @@ -+package me.lexikiq.event.sound; -+ -+import me.lexikiq.HasLocation; -+import org.apache.commons.lang.Validate; -+import org.bukkit.Keyed; -+import org.bukkit.Location; -+import org.bukkit.NamespacedKey; -+import org.bukkit.SoundCategory; -+import org.bukkit.World; -+import org.bukkit.entity.HumanEntity; -+import org.bukkit.entity.Player; -+import org.bukkit.event.HandlerList; -+import org.bukkit.util.Vector; -+import org.jetbrains.annotations.NotNull; -+import org.jetbrains.annotations.Nullable; -+ -+import java.util.List; -+import java.util.Objects; -+import java.util.function.Function; -+ -+import static com.google.common.base.Preconditions.checkNotNull; -+ -+/** -+ * Called when a sound not available in {@link org.bukkit.Sound} is sent to a player from a -+ * {@link Location}. Cancelling this event will prevent the packet from sending. -+ */ -+public class LocationCustomSoundEvent extends SoundEvent implements Keyed, HasLocation { -+ private @NotNull World world; -+ private @NotNull Vector vector; -+ private @NotNull NamespacedKey key; -+ -+ @Deprecated -+ public LocationCustomSoundEvent(@Nullable HumanEntity except, -+ @NotNull World world, -+ @NotNull Vector vector, -+ @NotNull NamespacedKey key, -+ @NotNull SoundCategory category, -+ float volume, -+ float pitch) { -+ this(except, world, vector, key, category, volume, pitch, null, null); -+ } -+ -+ @Deprecated -+ public LocationCustomSoundEvent(@Nullable HumanEntity except, -+ @NotNull Location location, -+ @NotNull NamespacedKey key, -+ @NotNull SoundCategory category, -+ float volume, -+ float pitch) { -+ this(except, location, key, category, volume, pitch, null, null); -+ } -+ -+ public LocationCustomSoundEvent(@Nullable HumanEntity except, -+ @NotNull World world, -+ @NotNull Vector vector, -+ @NotNull NamespacedKey key, -+ @NotNull SoundCategory category, -+ float volume, -+ float pitch, -+ @Nullable Function distanceFunction, -+ @Nullable Function> recipientsFunction) { -+ super(except, category, volume, pitch, distanceFunction, recipientsFunction); -+ this.world = Objects.requireNonNull(world, "world cannot be null"); -+ this.vector = Objects.requireNonNull(vector, "vector cannot be null"); -+ this.key = Objects.requireNonNull(key, "key cannot be null"); -+ } -+ -+ public LocationCustomSoundEvent(@Nullable HumanEntity except, -+ @NotNull Location location, -+ @NotNull NamespacedKey key, -+ @NotNull SoundCategory category, -+ float volume, -+ float pitch, -+ @Nullable Function distanceFunction, -+ @Nullable Function> recipientsFunction) { -+ this(except, checkNotNull(location, "location").getWorld(), location.toVector(), key, category, volume, pitch, distanceFunction, recipientsFunction); -+ } -+ -+ @Override -+ public @NotNull Vector getPosition() { -+ return vector; -+ } -+ -+ /** -+ * Sets the position of the sound. -+ * -+ * @param position position in the world -+ */ -+ public void setPosition(@NotNull Vector position) { -+ this.vector = Objects.requireNonNull(position, "position cannot be null"); -+ } -+ -+ /** -+ * Sets the position of the sound. -+ * -+ * @param vector position in the world -+ * @deprecated use {@link #setPosition(Vector)} instead -+ */ -+ @Deprecated -+ public void setVector(@NotNull Vector vector) { -+ setPosition(vector); -+ } -+ -+ /** -+ * Gets the resource pack key of the sound. -+ * -+ * @return asset key -+ */ -+ public @NotNull NamespacedKey getKey() { -+ return key; -+ } -+ -+ // boilerplate -+ -+ /** -+ * Sets the resource pack key of the sound. -+ * -+ * @param key asset key -+ */ -+ public void setKey(@NotNull NamespacedKey key) { -+ this.key = Objects.requireNonNull(key, "key cannot be null"); -+ } -+ -+ @Override -+ public @NotNull World getWorld() { -+ return world; -+ } -+ -+ /** -+ * Sets the world in which the sound is played. -+ *

-+ * This may not have an effect if the {@link #getRecipientsFunction()} has been modified. -+ * -+ * @param world world to play the sound in -+ */ -+ public void setWorld(@NotNull World world) { -+ this.world = Objects.requireNonNull(world, "world cannot be null"); -+ } -+} -diff --git a/src/main/java/me/lexikiq/event/sound/LocationNamedSoundEvent.java b/src/main/java/me/lexikiq/event/sound/LocationNamedSoundEvent.java -new file mode 100644 -index 0000000000000000000000000000000000000000..7f42c904362107c55cc5877eab1b513bcdf34571 ---- /dev/null -+++ b/src/main/java/me/lexikiq/event/sound/LocationNamedSoundEvent.java -@@ -0,0 +1,112 @@ -+package me.lexikiq.event.sound; -+ -+import me.lexikiq.HasLocation; -+import org.bukkit.Location; -+import org.bukkit.Sound; -+import org.bukkit.SoundCategory; -+import org.bukkit.World; -+import org.bukkit.entity.HumanEntity; -+import org.bukkit.entity.Player; -+import org.bukkit.util.Vector; -+import org.jetbrains.annotations.NotNull; -+import org.jetbrains.annotations.Nullable; -+ -+import java.util.List; -+import java.util.Objects; -+import java.util.function.Function; -+ -+/** -+ * Called when a sound available in {@link Sound} is sent to a {@link Location}. -+ * Cancelling this event will prevent the packet from sending. -+ */ -+public class LocationNamedSoundEvent extends NamedSoundEvent implements HasLocation { -+ private @NotNull World world; -+ private @NotNull Vector vector; -+ -+ @Deprecated -+ public LocationNamedSoundEvent(@Nullable HumanEntity except, -+ @NotNull World world, -+ @NotNull Vector vector, -+ @NotNull Sound sound, -+ @NotNull SoundCategory category, -+ float volume, -+ float pitch) { -+ this(except, world, vector, sound, category, volume, pitch, null, null); -+ } -+ -+ @Deprecated -+ public LocationNamedSoundEvent(@Nullable HumanEntity except, -+ @NotNull Location location, -+ @NotNull Sound sound, -+ @NotNull SoundCategory category, -+ float volume, -+ float pitch) { -+ this(except, location, sound, category, volume, pitch, null, null); -+ } -+ -+ public LocationNamedSoundEvent(@Nullable HumanEntity except, -+ @NotNull World world, -+ @NotNull Vector vector, -+ @NotNull Sound sound, -+ @NotNull SoundCategory category, -+ float volume, -+ float pitch, -+ @Nullable Function distanceFunction, -+ @Nullable Function> recipientsFunction) { -+ super(except, sound, category, volume, pitch, distanceFunction, recipientsFunction); -+ this.world = Objects.requireNonNull(world, "world cannot be null"); -+ this.vector = Objects.requireNonNull(vector, "vector cannot be null"); -+ } -+ -+ public LocationNamedSoundEvent(@Nullable HumanEntity except, -+ @NotNull Location location, -+ @NotNull Sound sound, -+ @NotNull SoundCategory category, -+ float volume, -+ float pitch, -+ @Nullable Function distanceFunction, -+ @Nullable Function> recipientsFunction) { -+ this(except, Objects.requireNonNull(location, "location cannot be null").getWorld(), location.toVector(), sound, category, volume, pitch, distanceFunction, recipientsFunction); -+ } -+ -+ @Override -+ public @NotNull Vector getPosition() { -+ return vector; -+ } -+ -+ /** -+ * Sets the position of the sound. -+ * -+ * @param position position in the world -+ */ -+ public void setPosition(@NotNull Vector position) { -+ this.vector = Objects.requireNonNull(position, "position cannot be null"); -+ } -+ -+ /** -+ * Sets the position of the sound. -+ * -+ * @param vector position in the world -+ * @deprecated use {@link #setPosition(Vector)} instead -+ */ -+ @Deprecated -+ public void setVector(@NotNull Vector vector) { -+ setPosition(vector); -+ } -+ -+ @Override -+ public @NotNull World getWorld() { -+ return world; -+ } -+ -+ /** -+ * Sets the world in which the sound is played. -+ *

-+ * This may not have an effect if the {@link #getRecipientsFunction()} has been modified. -+ * -+ * @param world world to play the sound in -+ */ -+ public void setWorld(@NotNull World world) { -+ this.world = Objects.requireNonNull(world, "world cannot be null"); -+ } -+} -diff --git a/src/main/java/me/lexikiq/event/sound/NamedSoundEvent.java b/src/main/java/me/lexikiq/event/sound/NamedSoundEvent.java -new file mode 100644 -index 0000000000000000000000000000000000000000..3ca767cfeb7fc0982830e49cde6bb0e87075c3f9 ---- /dev/null -+++ b/src/main/java/me/lexikiq/event/sound/NamedSoundEvent.java -@@ -0,0 +1,54 @@ -+package me.lexikiq.event.sound; -+ -+import org.apache.commons.lang.Validate; -+import org.bukkit.Sound; -+import org.bukkit.SoundCategory; -+import org.bukkit.entity.HumanEntity; -+import org.bukkit.entity.Player; -+import org.bukkit.event.HandlerList; -+import org.jetbrains.annotations.NotNull; -+import org.jetbrains.annotations.Nullable; -+ -+import java.util.List; -+import java.util.Objects; -+import java.util.function.Function; -+ -+/** -+ * Called when a sound available in {@link Sound} is sent to a player. -+ * Cancelling this event will prevent the packet from sending. -+ */ -+public abstract class NamedSoundEvent extends SoundEvent { -+ private @NotNull Sound sound; -+ -+ -+ @Deprecated -+ protected NamedSoundEvent(@Nullable HumanEntity except, @NotNull Sound sound, @NotNull SoundCategory category, float volume, float pitch) { -+ super(except, category, volume, pitch); -+ this.sound = Objects.requireNonNull(sound, "sound cannot be null"); -+ } -+ -+ public NamedSoundEvent(@Nullable HumanEntity except, @NotNull Sound sound, @NotNull SoundCategory category, float volume, float pitch, @Nullable Function distanceFunction, @Nullable Function> recipientsFunction) { -+ super(except, category, volume, pitch, distanceFunction, recipientsFunction); -+ this.sound = Objects.requireNonNull(sound, "sound cannot be null"); -+ } -+ -+ // boilerplate -+ -+ /** -+ * Gets the sound being played. -+ * -+ * @return sound to play -+ */ -+ public @NotNull Sound getSound() { -+ return sound; -+ } -+ -+ /** -+ * Sets the sound to be played. -+ * -+ * @param sound sound to play -+ */ -+ public void setSound(@NotNull Sound sound) { -+ this.sound = Objects.requireNonNull(sound, "sound cannot be null"); -+ } -+} -diff --git a/src/main/java/me/lexikiq/event/sound/SoundEvent.java b/src/main/java/me/lexikiq/event/sound/SoundEvent.java -new file mode 100644 -index 0000000000000000000000000000000000000000..6cc614b9e1b187f43433d13624d74672c97c2174 ---- /dev/null -+++ b/src/main/java/me/lexikiq/event/sound/SoundEvent.java -@@ -0,0 +1,313 @@ -+package me.lexikiq.event.sound; -+ -+import me.lexikiq.OptionalHumanEntity; -+import org.apache.commons.lang.Validate; -+import org.bukkit.Location; -+import org.bukkit.SoundCategory; -+import org.bukkit.World; -+import org.bukkit.entity.HumanEntity; -+import org.bukkit.entity.Player; -+import org.bukkit.event.Cancellable; -+import org.bukkit.event.Event; -+import org.bukkit.util.Vector; -+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.function.Function; -+ -+/** -+ * Called when a sound is sent to a player. -+ * Cancelling this event will prevent the packet from sending. -+ */ -+// TODO 1.18: use sealed class -+public abstract class SoundEvent extends Event implements Cancellable, OptionalHumanEntity { -+ -+ private static final org.bukkit.event.HandlerList handlers = new org.bukkit.event.HandlerList(); -+ public static final @NotNull Function DEFAULT_DISTANCE_FUNCTION = event -> event.getVolume() > 1.0F ? (double) (16.0F * event.getVolume()) : 16.0D; -+ public static final @NotNull Function> DEFAULT_RECIPIENTS_FUNCTION = new WrappedRecipientsFunction(event -> { -+ final double distance = event.calculateDistance(); -+ return event.getWorld().getPlayers().stream() -+ .filter(player -> { -+ Location pl = player.getLocation(); -+ Vector sv = event.getPosition(); -+ double x = sv.getX() - pl.getX(); -+ double y = sv.getY() - pl.getY(); -+ double z = sv.getZ() - pl.getZ(); -+ return x * x + y * y + z * z < distance * distance; -+ }) -+ .toList(); -+ }); -+ -+ private @Nullable HumanEntity except; -+ private @NotNull Function<@NotNull SoundEvent, @NotNull Double> distanceFunction; -+ private @NotNull Function<@NotNull SoundEvent, @NotNull List<@NotNull Player>> recipientsFunction; -+ // -+ private @NotNull SoundCategory category; -+ private float volume; -+ private float pitch; -+ private boolean cancelled; -+ -+ @Deprecated -+ protected SoundEvent(@Nullable HumanEntity except, @NotNull SoundCategory category, float volume, float pitch) { -+ this(except, category, volume, pitch, null, null); -+ } -+ -+ protected SoundEvent(@Nullable HumanEntity except, @NotNull SoundCategory category, float volume, float pitch, @Nullable Function distanceFunction, @Nullable Function> recipientsFunction) { -+ super(true); -+ this.except = except; -+ this.category = Objects.requireNonNull(category, "category cannot be null"); -+ this.volume = volume; -+ this.pitch = pitch; -+ this.distanceFunction = Objects.requireNonNullElse(distanceFunction, DEFAULT_DISTANCE_FUNCTION); -+ this.recipientsFunction = wrapRecipientsFunction(Objects.requireNonNullElse(recipientsFunction, DEFAULT_RECIPIENTS_FUNCTION)); -+ } -+ -+ /** -+ * Gets the player that won't be receiving this sound. -+ * -+ * @return player excluded from receiving this sound -+ * @deprecated use {@link #getException()} for more clarity -+ */ -+ @Override -+ @Deprecated -+ public @Nullable HumanEntity getPlayer() { -+ return getException(); -+ } -+ -+ /** -+ * Gets the player that won't be receiving this sound. -+ * -+ * @return player excluded from receiving this sound -+ */ -+ public @Nullable HumanEntity getException() { -+ return except; -+ } -+ -+ /** -+ * Sets the player that won't be receiving this sound. -+ * -+ * @param except player excluded from receiving this sound -+ */ -+ public void setException(@Nullable HumanEntity except) { -+ this.except = except; -+ } -+ -+ /** -+ * Gets the category of sounds this will be played with. -+ * -+ * @return category of sounds -+ */ -+ public @NotNull SoundCategory getCategory() { -+ return category; -+ } -+ -+ /** -+ * Sets the category of sounds this will be played with. -+ * -+ * @param category category of sounds -+ */ -+ public void setCategory(@NotNull SoundCategory category) { -+ this.category = Objects.requireNonNull(category, "category cannot be null"); -+ } -+ -+ /** -+ * Gets the volume of the sound to be played. Should be non-negative. -+ * -+ * @return sound volume -+ */ -+ public float getVolume() { -+ return volume; -+ } -+ -+ /** -+ * Sets the volume of the sound to be played. Must be non-negative. -+ * -+ * @param volume sound volume -+ */ -+ public void setVolume(float volume) { -+ Validate.isTrue(volume >= 0, "volume should be non-negative"); -+ this.volume = volume; -+ } -+ -+ /** -+ * Gets the pitch of the sound to be played. Should be within the range [0,2]. -+ * -+ * @return sound pitch -+ */ -+ public float getPitch() { -+ return pitch; -+ } -+ -+ /** -+ * Sets the pitch of the sound to be played. Must be within the range [0,2]. -+ * -+ * @param pitch sound pitch -+ */ -+ public void setPitch(float pitch) { -+ Validate.isTrue(pitch >= 0 && pitch <= 2, "pitch should be within range [0,2]"); -+ this.pitch = pitch; -+ } -+ -+ /** -+ * Calculates the distance of the sound. -+ *

-+ * The distance value is dynamically calculated using a -+ * {@link Function Function<SoundEvent, Double>}. -+ * In vanilla Minecraft, the default function is {@link #DEFAULT_DISTANCE_FUNCTION} -+ * ({@code event -> event.getVolume() > 1.0F ? (double) (16.0F * event.getVolume()) : 16.0D}). -+ *

-+ * This is used by the vanilla implementation of {@link #calculateRecipients()}, though custom -+ * implementations won't always use this method. -+ * -+ * @return calculated distance -+ * @see #getDistanceFunction() -+ * @see #setDistanceFunction(Function) -+ */ -+ public double calculateDistance() { -+ return distanceFunction.apply(this); -+ } -+ -+ /** -+ * Gets the function that calculates the distance of the sound. -+ * -+ * @return distance function -+ * @see #calculateDistance() -+ * @see #setDistanceFunction(Function) -+ */ -+ public @NotNull Function<@NotNull SoundEvent, @NotNull Double> getDistanceFunction() { -+ return distanceFunction; -+ } -+ -+ /** -+ * Sets the function that calculates the distance of the sound. -+ * -+ * @param distanceFunction distance function -+ * @see #calculateDistance() -+ * @see #getDistanceFunction() -+ */ -+ public void setDistanceFunction(@NotNull Function<@NotNull SoundEvent, @NotNull Double> distanceFunction) { -+ this.distanceFunction = Objects.requireNonNull(distanceFunction, "distanceFunction cannot be null"); -+ } -+ -+ /** -+ * Determines which players will receive this sound packet. -+ * -+ * @return immutable list of players -+ * @see #getRecipientsFunction() -+ * @see #setRecipientsFunction(Function) -+ */ -+ public @NotNull List calculateRecipients() { -+ return recipientsFunction.apply(this); -+ } -+ -+ /** -+ * Gets the function that determines which players will receive the sound packet. -+ * -+ * @return recipients function -+ * @see #calculateRecipients() -+ * @see #setRecipientsFunction(Function) -+ */ -+ public @NotNull Function<@NotNull SoundEvent, @NotNull List<@NotNull Player>> getRecipientsFunction() { -+ return recipientsFunction; -+ } -+ -+ /** -+ * Sets the function that determines which players will receive the sound packet. -+ *

-+ * This function does not need to query {@link #getException()} as this is done automatically. -+ * -+ * @param recipientsFunction recipients function -+ * @see #calculateRecipients() -+ * @see #getRecipientsFunction() -+ */ -+ public void setRecipientsFunction(@NotNull Function<@NotNull SoundEvent, @NotNull List<@NotNull Player>> recipientsFunction) { -+ this.recipientsFunction = wrapRecipientsFunction(Objects.requireNonNull(recipientsFunction, "recipientsFunction cannot be null")); -+ } -+ -+ /** -+ * Gets the world in which the sound is being played. -+ * -+ * @return sound's world -+ */ -+ @NotNull -+ public abstract World getWorld(); -+ -+ /** -+ * Gets the position at which the sound is being played. -+ * -+ * @return sound's position -+ */ -+ @NotNull -+ public abstract Vector getPosition(); -+ -+ /** -+ * Gets the position at which the sound is being played. -+ * -+ * @return sound's position -+ * @deprecated use {@link #getPosition()} instead for clarity -+ */ -+ @Deprecated -+ @NotNull -+ public Vector getVector() { -+ return getPosition(); -+ } -+ -+ /** -+ * Gets the location of the sound being played. -+ * -+ * @return copy of sound location -+ * @see #getPosition() -+ */ -+ public @NotNull Location getLocation() { -+ Vector pos = getPosition(); -+ return new Location(getWorld(), pos.getX(), pos.getY(), pos.getZ()); -+ } -+ -+ @Override -+ public boolean isCancelled() { -+ return cancelled; -+ } -+ -+ @Override -+ public void setCancelled(boolean cancelled) { -+ this.cancelled = cancelled; -+ } -+ -+ @NotNull -+ public static org.bukkit.event.HandlerList getHandlerList() { -+ return handlers; -+ } -+ -+ @Override -+ public @NotNull org.bukkit.event.HandlerList getHandlers() { -+ return handlers; -+ } -+ -+ private record WrappedRecipientsFunction(@NotNull Function> wrapped) implements Function> { -+ @Override -+ public List apply(SoundEvent event) { -+ List recipients = wrapped.apply(event); -+ HumanEntity except = event.getException(); -+ if (except != null) { -+ List filteredRecipients = new ArrayList<>(recipients.size()); -+ for (Player player : recipients) { -+ if (!player.getUniqueId().equals(except.getUniqueId())) -+ filteredRecipients.add(player); -+ } -+ return filteredRecipients; -+ } -+ return recipients; -+ } -+ } -+ -+ @NotNull -+ private static Function> wrapRecipientsFunction(@NotNull Function> recipientsFunction) { -+ if (recipientsFunction instanceof WrappedRecipientsFunction) -+ return recipientsFunction; -+ else -+ return new WrappedRecipientsFunction(recipientsFunction); -+ } -+} diff --git a/patches/api/0005-Add-origin-location-to-EntityDamageByBlockEvent.patch b/patches/api/0004-Add-origin-location-to-EntityDamageByBlockEvent.patch similarity index 100% rename from patches/api/0005-Add-origin-location-to-EntityDamageByBlockEvent.patch rename to patches/api/0004-Add-origin-location-to-EntityDamageByBlockEvent.patch diff --git a/patches/api/0006-Expanded-Adventure-support.patch b/patches/api/0005-Expanded-Adventure-support.patch similarity index 84% rename from patches/api/0006-Expanded-Adventure-support.patch rename to patches/api/0005-Expanded-Adventure-support.patch index eb36c78..1d9e1a9 100644 --- a/patches/api/0006-Expanded-Adventure-support.patch +++ b/patches/api/0005-Expanded-Adventure-support.patch @@ -6,7 +6,7 @@ Subject: [PATCH] Expanded Adventure support Adds support for Adventure in a few places where it was previously missing. diff --git a/src/main/java/org/bukkit/ChatColor.java b/src/main/java/org/bukkit/ChatColor.java -index 4594701d77c5d0f744bece871b98d9f6f73eb5a7..136f87f6cd2f3a56cfa645084fd6446a20f2e88e 100644 +index f6eb30f53dad684f156102cf7147b2f00c82c71e..1b4e9840f0e829be533ad0bd1c918489642245c2 100644 --- a/src/main/java/org/bukkit/ChatColor.java +++ b/src/main/java/org/bukkit/ChatColor.java @@ -11,7 +11,7 @@ import org.jetbrains.annotations.Nullable; @@ -120,10 +120,10 @@ index 4594701d77c5d0f744bece871b98d9f6f73eb5a7..136f87f6cd2f3a56cfa645084fd6446a * Gets the char value associated with this color * diff --git a/src/main/java/org/bukkit/Color.java b/src/main/java/org/bukkit/Color.java -index deae003b7e9a96bbf1c0167d3e1d864e61b07f82..53afcd97fc34bceff741ee118f63226781f9c895 100644 +index d2f8f5a8e49f60422b6a41e51248a6710251d61b..40b09a861ba365b126c2b28bb7f18c8fb8b3e5b5 100644 --- a/src/main/java/org/bukkit/Color.java +++ b/src/main/java/org/bukkit/Color.java -@@ -13,7 +13,7 @@ import org.jetbrains.annotations.NotNull; +@@ -15,7 +15,7 @@ import org.jetbrains.annotations.NotNull; * but subject to change. */ @SerializableAs("Color") @@ -132,7 +132,7 @@ index deae003b7e9a96bbf1c0167d3e1d864e61b07f82..53afcd97fc34bceff741ee118f632267 private static final int BIT_MASK = 0xff; /** -@@ -242,6 +242,13 @@ public final class Color implements ConfigurationSerializable { +@@ -244,6 +244,13 @@ public final class Color implements ConfigurationSerializable { return getRed() << 16 | getGreen() << 8 | getBlue() << 0; } @@ -188,28 +188,3 @@ index bd213cabddd8752e609544f24cfba95405726155..7e89cadecde96f9c2394446669dc4d98 /** * Gets the DyeColor with the given wool data value. * -diff --git a/src/main/java/org/bukkit/Keyed.java b/src/main/java/org/bukkit/Keyed.java -index 32c92621c2c15eec14c50965f5ecda00c46e6c80..3876a03ab9df9a0aef7a5c05a38b39b07a6dd285 100644 ---- a/src/main/java/org/bukkit/Keyed.java -+++ b/src/main/java/org/bukkit/Keyed.java -@@ -5,7 +5,7 @@ import org.jetbrains.annotations.NotNull; - /** - * Represents an object which has a {@link NamespacedKey} attached to it. - */ --public interface Keyed { -+public interface Keyed extends net.kyori.adventure.key.Keyed { // Parchment - - /** - * Return the namespaced identifier for this object. -@@ -14,4 +14,11 @@ public interface Keyed { - */ - @NotNull - NamespacedKey getKey(); -+ -+ // Parchment start -+ @Override -+ default net.kyori.adventure.key.@org.checkerframework.checker.nullness.qual.NonNull Key key() { -+ return getKey(); -+ } -+ // Parchment end - } diff --git a/patches/api/0007-Add-UnsafeValues-canPlaceItemOn.patch b/patches/api/0006-Add-UnsafeValues-canPlaceItemOn.patch similarity index 74% rename from patches/api/0007-Add-UnsafeValues-canPlaceItemOn.patch rename to patches/api/0006-Add-UnsafeValues-canPlaceItemOn.patch index 618cfb1..7f5a91f 100644 --- a/patches/api/0007-Add-UnsafeValues-canPlaceItemOn.patch +++ b/patches/api/0006-Add-UnsafeValues-canPlaceItemOn.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Add UnsafeValues#canPlaceItemOn diff --git a/src/main/java/org/bukkit/UnsafeValues.java b/src/main/java/org/bukkit/UnsafeValues.java -index 014c9984018ad5e51a26228a137e1ba4eb3e80c8..5606c09f62b7ad0cf33bb507d71830581114afd4 100644 +index 4fcafddf3792b66c618f91e04d102f374de565a8..716d5371c0ceb5b97c7008a6ac0c7ddf58b01a9f 100644 --- a/src/main/java/org/bukkit/UnsafeValues.java +++ b/src/main/java/org/bukkit/UnsafeValues.java -@@ -218,4 +218,17 @@ public interface UnsafeValues { +@@ -243,4 +243,17 @@ public interface UnsafeValues { */ boolean isCollidable(@org.jetbrains.annotations.NotNull Material material); // Paper end @@ -23,6 +23,6 @@ index 014c9984018ad5e51a26228a137e1ba4eb3e80c8..5606c09f62b7ad0cf33bb507d7183058 + * @param face cardinal direction + * @return if the item can be placed + */ -+ java.util.concurrent.CompletableFuture canPlaceItemOn(@org.jetbrains.annotations.NotNull ItemStack item, @org.jetbrains.annotations.Nullable me.lexikiq.OptionalHumanEntity player, @org.jetbrains.annotations.NotNull org.bukkit.block.Block block, @org.jetbrains.annotations.NotNull org.bukkit.block.BlockFace face); ++ java.util.concurrent.CompletableFuture canPlaceItemOn(@org.jetbrains.annotations.NotNull ItemStack item, @org.jetbrains.annotations.Nullable gg.projecteden.parchment.OptionalHumanEntity player, @org.jetbrains.annotations.NotNull org.bukkit.block.Block block, @org.jetbrains.annotations.NotNull org.bukkit.block.BlockFace face); + // Parchment end } diff --git a/patches/api/0008-Expose-NMS-ordinals.patch b/patches/api/0007-Expose-NMS-ordinals.patch similarity index 68% rename from patches/api/0008-Expose-NMS-ordinals.patch rename to patches/api/0007-Expose-NMS-ordinals.patch index f25a1d6..a3bbffd 100644 --- a/patches/api/0008-Expose-NMS-ordinals.patch +++ b/patches/api/0007-Expose-NMS-ordinals.patch @@ -5,13 +5,13 @@ Subject: [PATCH] Expose NMS ordinals diff --git a/src/main/java/org/bukkit/UnsafeValues.java b/src/main/java/org/bukkit/UnsafeValues.java -index 5606c09f62b7ad0cf33bb507d71830581114afd4..91ce90be864c20cab92525693d37b07f94d978af 100644 +index 716d5371c0ceb5b97c7008a6ac0c7ddf58b01a9f..16a332a6f8dad6a2758fd2bf3ab37637b9f26711 100644 --- a/src/main/java/org/bukkit/UnsafeValues.java +++ b/src/main/java/org/bukkit/UnsafeValues.java -@@ -230,5 +230,12 @@ public interface UnsafeValues { +@@ -255,5 +255,12 @@ public interface UnsafeValues { * @return if the item can be placed */ - java.util.concurrent.CompletableFuture canPlaceItemOn(@org.jetbrains.annotations.NotNull ItemStack item, @org.jetbrains.annotations.Nullable me.lexikiq.OptionalHumanEntity player, @org.jetbrains.annotations.NotNull org.bukkit.block.Block block, @org.jetbrains.annotations.NotNull org.bukkit.block.BlockFace face); + java.util.concurrent.CompletableFuture canPlaceItemOn(@org.jetbrains.annotations.NotNull ItemStack item, @org.jetbrains.annotations.Nullable gg.projecteden.parchment.OptionalHumanEntity player, @org.jetbrains.annotations.NotNull org.bukkit.block.Block block, @org.jetbrains.annotations.NotNull org.bukkit.block.BlockFace face); + + /** + * Gets the ID/ordinal of an entity according to NMS. diff --git a/patches/api/0009-Expose-MCUtil-Executors.patch b/patches/api/0008-Expose-MCUtil-Executors.patch similarity index 77% rename from patches/api/0009-Expose-MCUtil-Executors.patch rename to patches/api/0008-Expose-MCUtil-Executors.patch index 704cd7f..dceba84 100644 --- a/patches/api/0009-Expose-MCUtil-Executors.patch +++ b/patches/api/0008-Expose-MCUtil-Executors.patch @@ -5,12 +5,12 @@ Subject: [PATCH] Expose MCUtil Executors diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java -index c34cfba8f9ed7e9dbd0b6b8ffef9fba46abff046..451ea2c118b661725047f344c91814668d25cea5 100644 +index 30b49aed62fa67276e8964922ea3f84458d854bb..c78ca045a0a7fa651a34f76c802bb82cd6ac4d13 100644 --- a/src/main/java/org/bukkit/Server.java +++ b/src/main/java/org/bukkit/Server.java -@@ -1837,4 +1837,20 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi - @NotNull - io.papermc.paper.datapack.DatapackManager getDatapackManager(); +@@ -2065,4 +2065,20 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi + */ + @NotNull org.bukkit.potion.PotionBrewer getPotionBrewer(); // Paper end + + // Parchment start diff --git a/patches/api/0010-Add-BlockDropResourcesEvent.patch b/patches/api/0009-Add-BlockDropResourcesEvent.patch similarity index 81% rename from patches/api/0010-Add-BlockDropResourcesEvent.patch rename to patches/api/0009-Add-BlockDropResourcesEvent.patch index 016b41b..79b52b4 100644 --- a/patches/api/0010-Add-BlockDropResourcesEvent.patch +++ b/patches/api/0009-Add-BlockDropResourcesEvent.patch @@ -7,13 +7,13 @@ Adds an event which allows plugin developers to easily get the items being dropped by any block instead of only blocks broken by players. -diff --git a/src/main/java/me/lexikiq/event/block/BlockDropResourcesEvent.java b/src/main/java/me/lexikiq/event/block/BlockDropResourcesEvent.java +diff --git a/src/main/java/gg/projecteden/parchment/event/block/BlockDropResourcesEvent.java b/src/main/java/gg/projecteden/parchment/event/block/BlockDropResourcesEvent.java new file mode 100644 -index 0000000000000000000000000000000000000000..5ac4994b3e530f7e7636dddfdf24dec12e74ebf7 +index 0000000000000000000000000000000000000000..1547d962e9c27411915a34efe0db0c3dff99c6e5 --- /dev/null -+++ b/src/main/java/me/lexikiq/event/block/BlockDropResourcesEvent.java ++++ b/src/main/java/gg/projecteden/parchment/event/block/BlockDropResourcesEvent.java @@ -0,0 +1,45 @@ -+package me.lexikiq.event.block; ++package gg.projecteden.parchment.event.block; + +import org.bukkit.block.Block; +import org.bukkit.event.HandlerList; diff --git a/patches/api/0011-Add-Furnace-Recipe-API.patch b/patches/api/0010-Add-Furnace-Recipe-API.patch similarity index 71% rename from patches/api/0011-Add-Furnace-Recipe-API.patch rename to patches/api/0010-Add-Furnace-Recipe-API.patch index bcc1d6d..c5a23d8 100644 --- a/patches/api/0011-Add-Furnace-Recipe-API.patch +++ b/patches/api/0010-Add-Furnace-Recipe-API.patch @@ -7,13 +7,13 @@ Temporary API to get the result of smelting an item in a (type of) furnace. Will eventually (hopefully) be replaced by a more extensive Paper PR with support for all recipes. -diff --git a/src/main/java/me/lexikiq/inventory/RecipeType.java b/src/main/java/me/lexikiq/inventory/RecipeType.java +diff --git a/src/main/java/gg/projecteden/parchment/inventory/RecipeType.java b/src/main/java/gg/projecteden/parchment/inventory/RecipeType.java new file mode 100644 -index 0000000000000000000000000000000000000000..f8f707483bf08142cdaf6c6ff9b1241832e9134f +index 0000000000000000000000000000000000000000..28c01caa9d6379046f6af6612719b40459a89d17 --- /dev/null -+++ b/src/main/java/me/lexikiq/inventory/RecipeType.java ++++ b/src/main/java/gg/projecteden/parchment/inventory/RecipeType.java @@ -0,0 +1,50 @@ -+package me.lexikiq.inventory; ++package gg.projecteden.parchment.inventory; + +/** + * A type of crafting recipe. @@ -64,10 +64,10 @@ index 0000000000000000000000000000000000000000..f8f707483bf08142cdaf6c6ff9b12418 + } +} diff --git a/src/main/java/org/bukkit/World.java b/src/main/java/org/bukkit/World.java -index 4f673e9123145dc78564dc3eef0edf75795dafc2..85902538dae4a76ee79bc2d9921f2b4ec9f3c30d 100644 +index 7ad1cabe05277c1f3238da6e121c35d8a9f0d952..2fd4f6a97a5964e187ee06a66d48e7e6021155d4 100644 --- a/src/main/java/org/bukkit/World.java +++ b/src/main/java/org/bukkit/World.java -@@ -3764,6 +3764,36 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient +@@ -3909,6 +3909,36 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient @Nullable public DragonBattle getEnderDragonBattle(); @@ -80,17 +80,17 @@ index 4f673e9123145dc78564dc3eef0edf75795dafc2..85902538dae4a76ee79bc2d9921f2b4e + */ + @Nullable + default ItemStack smeltItem(@NotNull ItemStack toSmelt) { -+ return smeltItem(toSmelt, me.lexikiq.inventory.RecipeType.SMELTING); ++ return smeltItem(toSmelt, gg.projecteden.parchment.inventory.RecipeType.SMELTING); + } + + /** + * Returns the item that will result from smelting the input item, if applicable. + *

+ * Applicable values for {@code recipeType} are -+ * {@link me.lexikiq.inventory.RecipeType#SMELTING SMELTING}, -+ * {@link me.lexikiq.inventory.RecipeType#BLASTING BLASTING}, -+ * {@link me.lexikiq.inventory.RecipeType#SMOKING SMOKING}, -+ * and {@link me.lexikiq.inventory.RecipeType#CAMPFIRE_COOKING CAMPFIRE_COOKING}. ++ * {@link gg.projecteden.parchment.inventory.RecipeType#SMELTING SMELTING}, ++ * {@link gg.projecteden.parchment.inventory.RecipeType#BLASTING BLASTING}, ++ * {@link gg.projecteden.parchment.inventory.RecipeType#SMOKING SMOKING}, ++ * and {@link gg.projecteden.parchment.inventory.RecipeType#CAMPFIRE_COOKING CAMPFIRE_COOKING}. + * An {@link IllegalArgumentException} will be thrown if another value is supplied. + * + * @param toSmelt the item to simulate smelting @@ -98,7 +98,7 @@ index 4f673e9123145dc78564dc3eef0edf75795dafc2..85902538dae4a76ee79bc2d9921f2b4e + * @return the resulting item, or null + */ + @Nullable -+ ItemStack smeltItem(@NotNull ItemStack toSmelt, me.lexikiq.inventory.@NotNull RecipeType recipeType); ++ ItemStack smeltItem(@NotNull ItemStack toSmelt, gg.projecteden.parchment.inventory.@NotNull RecipeType recipeType); + // Parchment end + /** diff --git a/patches/server/0001-Build-changes.patch b/patches/server/0001-Build-changes.patch index 566fd12..01455a4 100644 --- a/patches/server/0001-Build-changes.patch +++ b/patches/server/0001-Build-changes.patch @@ -5,21 +5,21 @@ Subject: [PATCH] Build changes diff --git a/build.gradle.kts b/build.gradle.kts -index c236fe5dc388f8bc0a929f1de04af94c63514208..9fa28ef9ebcae299f7839f9341ab1da80660f61f 100644 +index 68b8f275f9c9e77a949ca29749a05b469bcdb910..82d6922ca22eee74de2140789787e6e5da51378c 100644 --- a/build.gradle.kts +++ b/build.gradle.kts -@@ -13,8 +13,8 @@ plugins { +@@ -9,8 +9,8 @@ plugins { } dependencies { -- implementation(project(":Paper-API")) -- implementation(project(":Paper-MojangAPI")) -+ implementation(project(":Parchment-API")) // Parchment -+ implementation("io.papermc.paper:paper-mojangapi:1.17.1-R0.1-SNAPSHOT") // Parchment +- implementation(project(":paper-api")) +- implementation(project(":paper-mojangapi")) ++ implementation(project(":parchment-api")) // Parchment ++ implementation("io.papermc.paper:paper-mojangapi:1.18.1-R0.1-SNAPSHOT") // Parchment // Paper start implementation("org.jline:jline-terminal-jansi:3.21.0") implementation("net.minecrell:terminalconsoleappender:1.3.0") -@@ -66,7 +66,7 @@ tasks.jar { +@@ -64,7 +64,7 @@ tasks.jar { attributes( "Main-Class" to "org.bukkit.craftbukkit.Main", "Implementation-Title" to "CraftBukkit", @@ -28,11 +28,13 @@ index c236fe5dc388f8bc0a929f1de04af94c63514208..9fa28ef9ebcae299f7839f9341ab1da8 "Implementation-Vendor" to date, // Paper "Specification-Title" to "Bukkit", "Specification-Version" to project.version, -@@ -88,6 +88,26 @@ publishing { - classifier = null - } - artifact(tasks.shadowJar) -+ // Parchment start +@@ -81,7 +81,27 @@ tasks.jar { + + publishing { + publications.create("maven") { +- artifact(tasks.shadowJar) ++ // Parchment start ++ artifact(tasks.reobfJar) + groupId = project.group as String? + artifactId = "parchment" + version = project.version as String? @@ -55,26 +57,17 @@ index c236fe5dc388f8bc0a929f1de04af94c63514208..9fa28ef9ebcae299f7839f9341ab1da8 } } -@@ -132,7 +152,7 @@ tasks.shadowJar { - - // Needed for Paperclip's install to maven local feature - from(generatePom) { -- into("META-INF/maven/io.papermc.paper/paper") -+ into("META-INF/maven/${project.group}/${project.name.toLowerCase(Locale.ENGLISH)}") // Parchment - rename { "pom.xml" } - } - -@@ -193,7 +213,7 @@ tasks.test { - fun TaskContainer.registerRunTask( - name: String, block: JavaExec.() -> Unit +@@ -152,7 +172,7 @@ fun TaskContainer.registerRunTask( + name: String, + block: JavaExec.() -> Unit ): TaskProvider = register(name) { - group = "paper" + group = "paperweight" // Parchment + mainClass.set("org.bukkit.craftbukkit.Main") standardInput = System.`in` - workingDir = rootProject.layout.projectDirectory.dir( - providers.gradleProperty("runWorkDir").forUseAtConfigurationTime().orElse("run") + workingDir = rootProject.layout.projectDirectory diff --git a/src/main/java/com/destroystokyo/paper/Metrics.java b/src/main/java/com/destroystokyo/paper/Metrics.java -index 218f5bafeed8551b55b91c7fccaf6935c8b631ca..52126870f1fc15a9ddce4452673b236ea692860f 100644 +index 7b1843e16745ca8db2244e17490d291401f22679..c340575e9c2a114f2165b74feb4481975821811c 100644 --- a/src/main/java/com/destroystokyo/paper/Metrics.java +++ b/src/main/java/com/destroystokyo/paper/Metrics.java @@ -73,7 +73,7 @@ public class Metrics { @@ -87,7 +80,7 @@ index 218f5bafeed8551b55b91c7fccaf6935c8b631ca..52126870f1fc15a9ddce4452673b236e /** diff --git a/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java b/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java -index ece77f5ea4b14bbed7c070131b3251ea86764538..71bf426f7fb58fff6739bb1332d1286db810d434 100644 +index bf42969859545a8a520923ef1836ffa4a5cc24a0..2532e265c5dade55f71c34fcab6d1e74bbb58a87 100644 --- a/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java +++ b/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java @@ -31,8 +31,8 @@ public class PaperVersionFetcher implements VersionFetcher { @@ -111,10 +104,10 @@ index ece77f5ea4b14bbed7c070131b3251ea86764538..71bf426f7fb58fff6739bb1332d1286d org.bukkit.Bukkit.getLogger().warning("Version: " + org.bukkit.Bukkit.getBukkitVersion()); } diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index 8091a901106a1085da9dfd8627dadcbe50f00872..50ebf237f85b789efdcba76aff2e5e6b8d2d74c6 100644 +index 32dc0cd20a4dd8fc02be1f7ba3d727db826dbe5d..d48ac4df6f9cde9ccdc068010e977206dd838eaf 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java -@@ -1729,7 +1729,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop DISTANCE_FUNCTION = sound -> { ++ Optional soundEvent = PaperAdventure.asVanillaSound(sound.name()); ++ if (soundEvent.isPresent()) ++ return Double.valueOf(soundEvent.get().getRange(sound.volume())); ++ return gg.projecteden.parchment.event.sound.SoundEvent.DEFAULT_DISTANCE_FUNCTION.apply(sound); ++ }; ++ ++ public static gg.projecteden.parchment.event.sound.SoundEvent.Emitter createEmitter(Level level, double x, double y, double z) { ++ return new gg.projecteden.parchment.event.sound.SoundEvent.LocationEmitter(new Location(level.getWorld(), x, y, z)); ++ } ++ ++ public static gg.projecteden.parchment.event.sound.SoundEvent.Emitter createEmitter(Entity entity) { ++ return new gg.projecteden.parchment.event.sound.SoundEvent.EntityEmitter(entity.getBukkitEntity()); ++ } ++} +diff --git a/src/main/java/io/papermc/paper/adventure/PaperAdventure.java b/src/main/java/io/papermc/paper/adventure/PaperAdventure.java +index 3f25a9b1a74cfa0c9a4d0379ecda109d99f33db3..b954cda43afbfd367f7f8f436dca65f900706ccb 100644 +--- a/src/main/java/io/papermc/paper/adventure/PaperAdventure.java ++++ b/src/main/java/io/papermc/paper/adventure/PaperAdventure.java +@@ -302,6 +302,32 @@ public final class PaperAdventure { + return asVanilla(source); + } + ++ // Parchment start ++ public static Sound.Source asAdventure(final SoundSource source) { ++ return switch (source) { ++ case MASTER -> Sound.Source.MASTER; ++ case MUSIC -> Sound.Source.MUSIC; ++ case RECORDS -> Sound.Source.RECORD; ++ case WEATHER -> Sound.Source.WEATHER; ++ case BLOCKS -> Sound.Source.BLOCK; ++ case HOSTILE -> Sound.Source.HOSTILE; ++ case NEUTRAL -> Sound.Source.NEUTRAL; ++ case PLAYERS -> Sound.Source.PLAYER; ++ case AMBIENT -> Sound.Source.AMBIENT; ++ case VOICE -> Sound.Source.VOICE; ++ }; ++ } ++ ++ public static java.util.Optional asVanillaSound(final Key key) { ++ return net.minecraft.core.Registry.SOUND_EVENT.getOptional(asVanilla(key)); ++ } ++ ++ @SuppressWarnings("PatternValidation") ++ public static Key asAdventure(final ResourceLocation key) { ++ return Key.key(key.getNamespace(), key.getPath()); ++ } ++ // Parchment end ++ + // NBT + + public static @Nullable BinaryTagHolder asBinaryTagHolder(final @Nullable CompoundTag tag) { diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java -index a002713686e66faf0d18662586a7a236c27ca7d2..14fc9abcba864620148dcdab921a5d95f98a9391 100644 +index 2b9669df574cf95c2643344a66ad18b213bd9cd7..ce354a3bd5deea844f86c89d555b438c50de31b8 100644 --- a/src/main/java/net/minecraft/server/level/ServerLevel.java +++ b/src/main/java/net/minecraft/server/level/ServerLevel.java -@@ -1495,12 +1495,12 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -1541,12 +1541,40 @@ public class ServerLevel extends Level implements WorldGenLevel { @Override - public void playSound(@Nullable Player except, double x, double y, double z, SoundEvent sound, SoundSource category, float volume, float pitch) { -- this.server.getPlayerList().broadcast(except, x, y, z, volume > 1.0F ? (double) (16.0F * volume) : 16.0D, this.dimension(), new ClientboundSoundPacket(sound, category, x, y, z, volume, pitch)); -+ CraftEventFactory.playSoundEvent(new me.lexikiq.event.sound.LocationNamedSoundEvent(except == null ? null : except.getBukkitEntity(), getWorld(), new org.bukkit.util.Vector(x, y, z), org.bukkit.craftbukkit.CraftSound.getBukkit(sound), org.bukkit.SoundCategory.valueOf(category.name()), volume, pitch, null, null)); // Parchment + public void playSeededSound(@Nullable Player except, double x, double y, double z, SoundEvent sound, SoundSource category, float volume, float pitch, long seed) { +- this.server.getPlayerList().broadcast(except, x, y, z, (double) sound.getRange(volume), this.dimension(), new ClientboundSoundPacket(sound, category, x, y, z, volume, pitch, seed)); ++ // Parchment start - sound event ++ CraftEventFactory.playSoundEvent(new gg.projecteden.parchment.event.sound.SoundEvent( ++ except == null ? null : except.getBukkitEntity(), ++ net.kyori.adventure.sound.Sound.sound( ++ io.papermc.paper.adventure.PaperAdventure.asAdventure(sound.getLocation()), ++ io.papermc.paper.adventure.PaperAdventure.asAdventure(category), ++ volume, ++ pitch ++ ), ++ gg.projecteden.parchment.event.sound.ParchmentSoundEvent.createEmitter(this, x, y, z), ++ seed, ++ gg.projecteden.parchment.event.sound.ParchmentSoundEvent.DISTANCE_FUNCTION, ++ null ++ )); ++ // Parchment end } @Override - public void playSound(@Nullable Player except, Entity entity, SoundEvent sound, SoundSource category, float volume, float pitch) { -- this.server.getPlayerList().broadcast(except, entity.getX(), entity.getY(), entity.getZ(), volume > 1.0F ? (double) (16.0F * volume) : 16.0D, this.dimension(), new ClientboundSoundEntityPacket(sound, category, entity, volume, pitch)); -+ CraftEventFactory.playSoundEvent(new me.lexikiq.event.sound.EntitySoundEvent(except == null ? null : except.getBukkitEntity(), entity.getBukkitEntity(), org.bukkit.craftbukkit.CraftSound.getBukkit(sound), org.bukkit.SoundCategory.valueOf(category.name()), volume, pitch, null, null)); // Parchment + public void playSeededSound(@Nullable Player except, Entity entity, SoundEvent sound, SoundSource category, float volume, float pitch, long seed) { +- this.server.getPlayerList().broadcast(except, entity.getX(), entity.getY(), entity.getZ(), (double) sound.getRange(volume), this.dimension(), new ClientboundSoundEntityPacket(sound, category, entity, volume, pitch, seed)); ++ // Parchment start - sound event ++ CraftEventFactory.playSoundEvent(new gg.projecteden.parchment.event.sound.SoundEvent( ++ except == null ? null : except.getBukkitEntity(), ++ net.kyori.adventure.sound.Sound.sound( ++ io.papermc.paper.adventure.PaperAdventure.asAdventure(sound.getLocation()), ++ io.papermc.paper.adventure.PaperAdventure.asAdventure(category), ++ volume, ++ pitch ++ ), ++ gg.projecteden.parchment.event.sound.ParchmentSoundEvent.createEmitter(entity), ++ seed, ++ gg.projecteden.parchment.event.sound.ParchmentSoundEvent.DISTANCE_FUNCTION, ++ null ++ )); ++ // Parchment end } @Override diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java -index 78fda0c982810b8b881a87099f355247566e513a..1ec20f19c8d6a606f608e0293eaf5f8f764b3b92 100644 +index 353463084d90eb684717e65c56da52cd25a1e375..e7fb384822966c149777148792723f7f36681f76 100644 --- a/src/main/java/net/minecraft/server/level/ServerPlayer.java +++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java -@@ -2174,7 +2174,13 @@ public class ServerPlayer extends Player { +@@ -2227,7 +2227,19 @@ public class ServerPlayer extends Player { @Override public void playNotifySound(SoundEvent event, SoundSource category, float volume, float pitch) { -- this.connection.send(new ClientboundSoundPacket(event, category, this.getX(), this.getY(), this.getZ(), volume, pitch)); -+ // Parchment start -+ List recipients = java.util.Collections.singletonList(getBukkitEntity()); -+ org.bukkit.Location location = getBukkitEntity().getLocation(); -+ org.bukkit.Sound sound = org.bukkit.craftbukkit.CraftSound.getBukkit(event); -+ org.bukkit.SoundCategory bukkitCategory = org.bukkit.SoundCategory.valueOf(category.name()); -+ CraftEventFactory.playSoundEvent(new me.lexikiq.event.sound.LocationNamedSoundEvent(null, location, sound, bukkitCategory, volume, pitch, $ -> 0d, $ -> recipients)); +- this.connection.send(new ClientboundSoundPacket(event, category, this.getX(), this.getY(), this.getZ(), volume, pitch, this.random.nextLong())); ++ // Parchment start - sound event ++ CraftEventFactory.playSoundEvent(new gg.projecteden.parchment.event.sound.SoundEvent( ++ null, ++ net.kyori.adventure.sound.Sound.sound( ++ io.papermc.paper.adventure.PaperAdventure.asAdventure(event.getLocation()), ++ io.papermc.paper.adventure.PaperAdventure.asAdventure(category), ++ volume, ++ pitch ++ ), ++ gg.projecteden.parchment.event.sound.ParchmentSoundEvent.createEmitter(level, getX(), getY(), getZ()), ++ this.random.nextLong(), sound -> 0d, soundEvent -> java.util.Collections.singletonList(getBukkitEntity()) ++ )); + // Parchment end } @Override diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java -index 46e6e68f78d07c04cd2f4d477dca7a06313c20e9..f7d9316645ba94089a867c6348caaf77756c44f6 100644 +index 20cdfdb3b9351f74e89bc45b3ab972384165659a..aaef762c95584103937955413629aa11f7cf2bd0 100644 --- a/src/main/java/net/minecraft/server/players/PlayerList.java +++ b/src/main/java/net/minecraft/server/players/PlayerList.java -@@ -965,7 +965,7 @@ public abstract class PlayerList { +@@ -977,7 +977,7 @@ public abstract class PlayerList { if (flag2 && !isLocAltered) { BlockState data = worldserver1.getBlockState(blockposition); - worldserver1.setBlock(blockposition, data.setValue(RespawnAnchorBlock.CHARGE, data.getValue(RespawnAnchorBlock.CHARGE) - 1), 3); -- entityplayer1.connection.send(new ClientboundSoundPacket(SoundEvents.RESPAWN_ANCHOR_DEPLETE, SoundSource.BLOCKS, (double) location.getX(), (double) location.getY(), (double) location.getZ(), 1.0F, 1.0F)); -+ entityplayer1.playNotifySound(SoundEvents.RESPAWN_ANCHOR_DEPLETE, SoundSource.BLOCKS, 1.0F, 1.0F); // Parchment + worldserver1.setBlock(blockposition, data.setValue(net.minecraft.world.level.block.RespawnAnchorBlock.CHARGE, data.getValue(net.minecraft.world.level.block.RespawnAnchorBlock.CHARGE) - 1), 3); +- entityplayer1.connection.send(new ClientboundSoundPacket(SoundEvents.RESPAWN_ANCHOR_DEPLETE, SoundSource.BLOCKS, (double) location.getX(), (double) location.getY(), (double) location.getZ(), 1.0F, 1.0F, worldserver1.getRandom().nextLong())); ++ entityplayer1.playNotifySound(SoundEvents.RESPAWN_ANCHOR_DEPLETE, SoundSource.BLOCKS, 1.0F, 1.0F); // Parchment - use existing play sound method // Paper end } // Added from changeDimension 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 94e76e295dbd0f3bac4b30a3e7338cd56a971207..e951db59902fafa41832f73bab4086b63fe76f46 100644 +index cd9cbfa5ef94994b3f7f2ecdde843620e7e6c071..bc6bdc8752718777ac698cfda2a0e7f35fcf9896 100644 --- a/src/main/java/net/minecraft/world/entity/player/Player.java +++ b/src/main/java/net/minecraft/world/entity/player/Player.java -@@ -1832,7 +1832,14 @@ public abstract class Player extends LivingEntity { +@@ -1898,7 +1898,21 @@ public abstract class Player extends LivingEntity { private static void sendSoundEffect(Player fromEntity, double x, double y, double z, SoundEvent soundEffect, SoundSource soundCategory, float volume, float pitch) { fromEntity.level.playSound(fromEntity, x, y, z, soundEffect, soundCategory, volume, pitch); // This will not send the effect to the entity himself if (fromEntity instanceof ServerPlayer) { -- ((ServerPlayer) fromEntity).connection.send(new ClientboundSoundPacket(soundEffect, soundCategory, x, y, z, volume, pitch)); -+ // Parchment start -+ List recipients = java.util.Collections.singletonList(((net.minecraft.server.level.ServerPlayer) fromEntity).getBukkitEntity()); -+ org.bukkit.World world = fromEntity.level.getWorld(); -+ org.bukkit.util.Vector vector = new org.bukkit.util.Vector(x, y, z); -+ org.bukkit.Sound sound = org.bukkit.craftbukkit.CraftSound.getBukkit(soundEffect); -+ org.bukkit.SoundCategory category = org.bukkit.SoundCategory.valueOf(soundCategory.name()); -+ CraftEventFactory.playSoundEvent(new me.lexikiq.event.sound.LocationNamedSoundEvent(null, world, vector, sound, category, volume, pitch, event -> 0d, event -> recipients)); +- ((ServerPlayer) fromEntity).connection.send(new net.minecraft.network.protocol.game.ClientboundSoundPacket(soundEffect, soundCategory, x, y, z, volume, pitch, fromEntity.random.nextLong())); ++ // Parchment start - sound event ++ CraftEventFactory.playSoundEvent(new gg.projecteden.parchment.event.sound.SoundEvent( ++ null, ++ net.kyori.adventure.sound.Sound.sound( ++ io.papermc.paper.adventure.PaperAdventure.asAdventure(soundEffect.getLocation()), ++ io.papermc.paper.adventure.PaperAdventure.asAdventure(soundCategory), ++ volume, ++ pitch ++ ), ++ gg.projecteden.parchment.event.sound.ParchmentSoundEvent.createEmitter(fromEntity.level, x, y, z), ++ fromEntity.random.nextLong(), ++ sound -> 0d, ++ soundEvent -> java.util.Collections.singletonList(((ServerPlayer) fromEntity).getBukkitEntity()) ++ )); + // Parchment end } } // Paper end diff --git a/src/main/java/net/minecraft/world/entity/raid/Raid.java b/src/main/java/net/minecraft/world/entity/raid/Raid.java -index a79ba23ecf887ecbb6e095140f019ebb6fd0a6f7..5112edc5e68a386e9bb16ac0ec9d998e7df06f3c 100644 +index 6a0a1731fd6804eb69d3641213712d31bce085b2..81819d12e0becde85b6d66f3b3ffedde847a72f6 100644 --- a/src/main/java/net/minecraft/world/entity/raid/Raid.java +++ b/src/main/java/net/minecraft/world/entity/raid/Raid.java -@@ -27,7 +27,7 @@ import net.minecraft.nbt.ListTag; - import net.minecraft.nbt.NbtUtils; - import net.minecraft.network.chat.Component; - import net.minecraft.network.chat.TranslatableComponent; --import net.minecraft.network.protocol.game.ClientboundSoundPacket; -+//import net.minecraft.network.protocol.game.ClientboundSoundPacket; // Parchment - import net.minecraft.server.level.ServerBossEvent; - import net.minecraft.server.level.ServerLevel; - import net.minecraft.server.level.ServerPlayer; -@@ -537,7 +537,7 @@ public class Raid { +@@ -526,7 +526,7 @@ public class Raid { + float f = 13.0F; + boolean flag = true; + Collection collection = this.raidEvent.getPlayers(); +- long i = this.random.nextLong(); ++ //long i = this.random.nextLong(); // Parchment - remove redundant variable + Iterator iterator = this.level.players().iterator(); + + while (iterator.hasNext()) { +@@ -538,7 +538,7 @@ public class Raid { double d2 = vec3d.z + 13.0D / d0 * (vec3d1.z - vec3d.z); if (d0 <= 64.0D || collection.contains(entityplayer)) { -- entityplayer.connection.send(new ClientboundSoundPacket(SoundEvents.RAID_HORN, SoundSource.NEUTRAL, d1, entityplayer.getY(), d2, 64.0F, 1.0F)); -+ entityplayer.playNotifySound(SoundEvents.RAID_HORN, SoundSource.NEUTRAL, 64.0F, 1.0F); // Parchment +- entityplayer.connection.send(new ClientboundSoundPacket(SoundEvents.RAID_HORN, SoundSource.NEUTRAL, d1, entityplayer.getY(), d2, 64.0F, 1.0F, i)); ++ entityplayer.playNotifySound(SoundEvents.RAID_HORN, SoundSource.NEUTRAL, 64.0F, 1.0F); // Parchment - use existing play sound method } } diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java -index ea01507f96d81c6fbcfeb65902017bbc332de650..b774a27eb4d11cd1bef807193a6df6012dde3794 100644 +index 1d8ec0f85ec42f2dcd9405df83b526ae1c59de6f..5204590757f5f0890f72e915d30a8c52497090a3 100644 --- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java +++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java -@@ -1888,4 +1888,41 @@ public class CraftEventFactory { +@@ -2,7 +2,6 @@ package org.bukkit.craftbukkit.event; + + import com.google.common.base.Function; + import com.google.common.base.Functions; +-import com.google.common.collect.Lists; + import com.mojang.datafixers.util.Either; + import java.net.InetAddress; + import java.util.ArrayList; +@@ -1919,4 +1918,52 @@ public class CraftEventFactory { return event.callEvent(); } // Paper end + + // Parchment start -+ private static net.minecraft.network.protocol.Packet handleSoundEvent(me.lexikiq.event.sound.SoundEvent _event) { -+ if (!_event.callEvent()) { -+ return null; -+ } -+ float volume = _event.getVolume(); -+ float pitch = _event.getPitch(); -+ net.minecraft.sounds.SoundSource source = net.minecraft.sounds.SoundSource.valueOf(_event.getCategory().name()); -+ -+ if (_event instanceof me.lexikiq.event.sound.NamedSoundEvent namedSoundEvent) { -+ net.minecraft.sounds.SoundEvent sound = org.bukkit.craftbukkit.CraftSound.getSoundEffect(namedSoundEvent.getSound()); -+ -+ if (_event instanceof me.lexikiq.event.sound.LocationNamedSoundEvent event) { -+ org.bukkit.util.Vector pos = event.getPosition(); -+ return new net.minecraft.network.protocol.game.ClientboundSoundPacket(sound, source, pos.getX(), pos.getY(), pos.getZ(), volume, pitch); -+ } else if (_event instanceof me.lexikiq.event.sound.EntitySoundEvent event) { -+ return new net.minecraft.network.protocol.game.ClientboundSoundEntityPacket(sound, source, ((CraftEntity) event.getOrigin()).getHandle(), volume, pitch); ++ private static net.minecraft.network.protocol.@org.jetbrains.annotations.NotNull Packet handleSoundEvent(gg.projecteden.parchment.event.sound.SoundEvent event, CraftPlayer recipient) { ++ // init variables ++ net.kyori.adventure.sound.Sound sound = event.calculateSound(recipient); ++ gg.projecteden.parchment.event.sound.SoundEvent.Emitter emitter = event.calculateEmitter(recipient); ++ net.minecraft.sounds.SoundSource source = io.papermc.paper.adventure.PaperAdventure.asVanilla(sound.source()); ++ float volume = sound.volume(); ++ float pitch = sound.pitch(); ++ long seed = event.getSeed(); ++ java.util.Optional soundEvent = io.papermc.paper.adventure.PaperAdventure.asVanillaSound(sound.name()); ++ // handle vanilla sounds ++ if (soundEvent.isPresent()) { ++ if (emitter instanceof gg.projecteden.parchment.event.sound.SoundEvent.EntityEmitter entityEmitter) ++ return new net.minecraft.network.protocol.game.ClientboundSoundEntityPacket(soundEvent.get(), source, ((CraftEntity) entityEmitter.entity()).getHandle(), volume, pitch, seed); ++ else if (emitter instanceof gg.projecteden.parchment.event.sound.SoundEvent.LocationEmitter locationEmitter) { ++ Location loc = locationEmitter.location(); ++ return new net.minecraft.network.protocol.game.ClientboundSoundPacket(soundEvent.get(), source, loc.getX(), loc.getY(), loc.getZ(), volume, pitch, seed); + } -+ } else if (_event instanceof me.lexikiq.event.sound.LocationCustomSoundEvent event) { -+ org.bukkit.util.Vector pos = event.getPosition(); -+ return new net.minecraft.network.protocol.game.ClientboundCustomSoundPacket(CraftNamespacedKey.toMinecraft(event.getKey()), source, org.bukkit.craftbukkit.util.CraftVector.toNMS(pos), volume, pitch); ++ else ++ throw new IllegalArgumentException("Unknown emitter type: " + emitter.getClass().getName()); ++ } ++ // handle custom sounds ++ else { ++ // warn if trying to use EntityEmitter with custom sound ++ if (emitter instanceof gg.projecteden.parchment.event.sound.SoundEvent.EntityEmitter) ++ org.slf4j.LoggerFactory.getLogger("SoundEvent").warn("Sound event is using a custom sound ({}) which cannot be used with EntityEmitter. Falling back to playing at the entity's location.", sound.name().asString()); ++ Vec3 pos = org.bukkit.craftbukkit.util.CraftVector.toNMS(emitter.location().toVector()); ++ return new net.minecraft.network.protocol.game.ClientboundCustomSoundPacket(io.papermc.paper.adventure.PaperAdventure.asVanilla(sound.name()), source, pos, volume, pitch, seed); + } -+ throw new IllegalArgumentException("Unknown sound event: " + _event.getClass().getName()); + } + -+ public static void playSoundEvent(me.lexikiq.event.sound.SoundEvent event) { ++ public static void playSoundEvent(gg.projecteden.parchment.event.sound.SoundEvent event) { + org.apache.commons.lang3.Validate.notNull(event, "event"); -+ java.util.concurrent.CompletableFuture.supplyAsync(() -> handleSoundEvent(event), net.minecraft.server.MCUtil.asyncExecutor).handleAsync((packet, throwable) -> { -+ if (packet != null) -+ event.calculateRecipients().forEach(recipient -> ((org.bukkit.craftbukkit.entity.CraftPlayer) recipient).getHandle().connection.send(packet)); -+ else if (throwable != null) -+ org.slf4j.LoggerFactory.getLogger("SoundEvent").error("Error while handling sound event", throwable); -+ return null; -+ }, net.minecraft.server.MCUtil.asyncExecutor); ++ net.minecraft.server.MCUtil.asyncExecutor.execute(() -> { ++ if (!event.callEvent()) ++ return; ++ try { ++ for (Player _player : event.calculateRecipients()) { ++ CraftPlayer player = (CraftPlayer) _player; ++ player.getHandle().connection.send(handleSoundEvent(event, player)); ++ } ++ } catch (Throwable e) { ++ org.slf4j.LoggerFactory.getLogger("SoundEvent").error("Error playing sound event", e); ++ } ++ }); + } + // Parchment end } diff --git a/patches/server/0004-Add-PlayerUseRespawnAnchorEvent.patch b/patches/server/0004-Add-PlayerUseRespawnAnchorEvent.patch index 019522e..208b071 100644 --- a/patches/server/0004-Add-PlayerUseRespawnAnchorEvent.patch +++ b/patches/server/0004-Add-PlayerUseRespawnAnchorEvent.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Add PlayerUseRespawnAnchorEvent 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 0a5d563700c9f806139001181f01fa9d0111f792..88439b8f82a97a9763dadfc6c9dbaf0912ab3eb7 100644 +index 491ad2098e982f3c947fcae6f258f0b1aa44a562..7d33dae2617991bce244ad906df7053c22e3f515 100644 --- a/src/main/java/net/minecraft/world/level/block/RespawnAnchorBlock.java +++ b/src/main/java/net/minecraft/world/level/block/RespawnAnchorBlock.java -@@ -52,33 +52,51 @@ public class RespawnAnchorBlock extends Block { +@@ -51,23 +51,48 @@ public class RespawnAnchorBlock extends Block { @Override public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) { ItemStack itemStack = player.getItemInHand(hand); @@ -16,30 +16,33 @@ index 0a5d563700c9f806139001181f01fa9d0111f792..88439b8f82a97a9763dadfc6c9dbaf09 + // Parchment start -- PlayerUseRespawnAnchorEvent + org.bukkit.entity.Player bukkitPlayer = player.getBukkitEntity() instanceof org.bukkit.entity.Player ? (org.bukkit.entity.Player) player.getBukkitEntity() : null; + org.bukkit.block.Block block = org.bukkit.craftbukkit.block.CraftBlock.at(world, pos); -+ me.lexikiq.event.player.PlayerUseRespawnAnchorEvent.RespawnAnchorResult result; ++ gg.projecteden.parchment.event.player.PlayerUseRespawnAnchorEvent.RespawnAnchorResult result; ++ // Parchment end if (hand == InteractionHand.MAIN_HAND && !isRespawnFuel(itemStack) && isRespawnFuel(player.getItemInHand(InteractionHand.OFF_HAND))) { return InteractionResult.PASS; } else if (isRespawnFuel(itemStack) && canBeCharged(state)) { -+ result = me.lexikiq.event.player.PlayerUseRespawnAnchorEvent.RespawnAnchorResult.CHARGE; ++ // Parchment start -- PlayerUseRespawnAnchorEvent ++ result = gg.projecteden.parchment.event.player.PlayerUseRespawnAnchorEvent.RespawnAnchorResult.CHARGE; + } else if (state.getValue(CHARGE) == 0) { -+ result = me.lexikiq.event.player.PlayerUseRespawnAnchorEvent.RespawnAnchorResult.NOTHING; ++ result = gg.projecteden.parchment.event.player.PlayerUseRespawnAnchorEvent.RespawnAnchorResult.NOTHING; + } else if (!canSetSpawn(world) && !world.isClientSide) { -+ result = me.lexikiq.event.player.PlayerUseRespawnAnchorEvent.RespawnAnchorResult.EXPLODE; ++ result = gg.projecteden.parchment.event.player.PlayerUseRespawnAnchorEvent.RespawnAnchorResult.EXPLODE; + } else if (!world.isClientSide) { -+ result = me.lexikiq.event.player.PlayerUseRespawnAnchorEvent.RespawnAnchorResult.SET_SPAWN; ++ result = gg.projecteden.parchment.event.player.PlayerUseRespawnAnchorEvent.RespawnAnchorResult.SET_SPAWN; + } else { + return InteractionResult.SUCCESS; + } + + if (bukkitPlayer != null) { -+ me.lexikiq.event.player.PlayerUseRespawnAnchorEvent event = new me.lexikiq.event.player.PlayerUseRespawnAnchorEvent(bukkitPlayer, block, result); ++ gg.projecteden.parchment.event.player.PlayerUseRespawnAnchorEvent event = new gg.projecteden.parchment.event.player.PlayerUseRespawnAnchorEvent(bukkitPlayer, block, result); + event.callEvent(); + result = event.getResult(); + } + -+ if (result == me.lexikiq.event.player.PlayerUseRespawnAnchorEvent.RespawnAnchorResult.NOTHING) { ++ if (result == gg.projecteden.parchment.event.player.PlayerUseRespawnAnchorEvent.RespawnAnchorResult.NOTHING) { + return InteractionResult.PASS; -+ } else if (result == me.lexikiq.event.player.PlayerUseRespawnAnchorEvent.RespawnAnchorResult.CHARGE) { ++ } else if (result == gg.projecteden.parchment.event.player.PlayerUseRespawnAnchorEvent.RespawnAnchorResult.CHARGE) { ++ // Parchment end charge(world, pos, state); if (!player.getAbilities().instabuild) { itemStack.shrink(1); @@ -54,25 +57,19 @@ index 0a5d563700c9f806139001181f01fa9d0111f792..88439b8f82a97a9763dadfc6c9dbaf09 - } - - return InteractionResult.sidedSuccess(world.isClientSide); -+ } else if (result == me.lexikiq.event.player.PlayerUseRespawnAnchorEvent.RespawnAnchorResult.EXPLODE) { ++ // Parchment start -- PlayerUseRespawnAnchorEvent ++ } else if (result == gg.projecteden.parchment.event.player.PlayerUseRespawnAnchorEvent.RespawnAnchorResult.EXPLODE) { + this.explode(state, world, pos); + return InteractionResult.CONSUME; ++ // Parchment end } else { -- if (!world.isClientSide) { -- ServerPlayer serverPlayer = (ServerPlayer)player; -- if (serverPlayer.getRespawnDimension() != world.dimension() || !pos.equals(serverPlayer.getRespawnPosition())) { -- serverPlayer.setRespawnPosition(world.dimension(), pos, 0.0F, false, true, com.destroystokyo.paper.event.player.PlayerSetSpawnEvent.Cause.RESPAWN_ANCHOR); // Paper - PlayerSetSpawnEvent -- world.playSound((Player)null, (double)pos.getX() + 0.5D, (double)pos.getY() + 0.5D, (double)pos.getZ() + 0.5D, SoundEvents.RESPAWN_ANCHOR_SET_SPAWN, SoundSource.BLOCKS, 1.0F, 1.0F); -- return InteractionResult.SUCCESS; -- } -+ ServerPlayer serverPlayer = (ServerPlayer)player; -+ if (serverPlayer.getRespawnDimension() != world.dimension() || !pos.equals(serverPlayer.getRespawnPosition())) { -+ serverPlayer.setRespawnPosition(world.dimension(), pos, 0.0F, false, true, com.destroystokyo.paper.event.player.PlayerSetSpawnEvent.Cause.RESPAWN_ANCHOR); // Paper - PlayerSetSpawnEvent -+ world.playSound((Player)null, (double)pos.getX() + 0.5D, (double)pos.getY() + 0.5D, (double)pos.getZ() + 0.5D, SoundEvents.RESPAWN_ANCHOR_SET_SPAWN, SoundSource.BLOCKS, 1.0F, 1.0F); -+ return InteractionResult.SUCCESS; + if (!world.isClientSide) { + ServerPlayer serverPlayer = (ServerPlayer)player; +@@ -82,7 +107,6 @@ public class RespawnAnchorBlock extends Block { + // Paper end + } } - -+ // Parchment end return InteractionResult.CONSUME; } } diff --git a/patches/server/0005-Add-origin-location-to-EntityDamageByBlockEvent.patch b/patches/server/0005-Add-origin-location-to-EntityDamageByBlockEvent.patch index 2781282..2f8c488 100644 --- a/patches/server/0005-Add-origin-location-to-EntityDamageByBlockEvent.patch +++ b/patches/server/0005-Add-origin-location-to-EntityDamageByBlockEvent.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Add origin location to EntityDamageByBlockEvent diff --git a/src/main/java/net/minecraft/world/damagesource/BadRespawnPointDamage.java b/src/main/java/net/minecraft/world/damagesource/BadRespawnPointDamage.java -index f5a18fb39eb69b2a9842d3f96aa1cd6a8dff6d9b..456d93305f524da6142bad320edb817b27c6c1e6 100644 +index 968c915cc494bb3c57169b7b3640002c3a4a8810..0c2b2cb4be57b11d748d13a0ec24b7470619267f 100644 --- a/src/main/java/net/minecraft/world/damagesource/BadRespawnPointDamage.java +++ b/src/main/java/net/minecraft/world/damagesource/BadRespawnPointDamage.java -@@ -9,12 +9,20 @@ import net.minecraft.network.chat.TranslatableComponent; +@@ -7,12 +7,20 @@ import net.minecraft.network.chat.HoverEvent; import net.minecraft.world.entity.LivingEntity; public class BadRespawnPointDamage extends DamageSource { @@ -28,9 +28,9 @@ index f5a18fb39eb69b2a9842d3f96aa1cd6a8dff6d9b..456d93305f524da6142bad320edb817b + @Override public Component getLocalizedDeathMessage(LivingEntity entity) { - Component component = ComponentUtils.wrapInSquareBrackets(new TranslatableComponent("death.attack.badRespawnPoint.link")).withStyle((style) -> { + Component component = ComponentUtils.wrapInSquareBrackets(Component.translatable("death.attack.badRespawnPoint.link")).withStyle((style) -> { diff --git a/src/main/java/net/minecraft/world/damagesource/DamageSource.java b/src/main/java/net/minecraft/world/damagesource/DamageSource.java -index a828cad27fcd39f8bfbaefa97052a2a3b6650ee7..52cce7422c2a99e3de37f87ac704151682578718 100644 +index 67bce77093dcc126098731047447da2031e3388d..051cf78fe9f7700e1f639c804f35903c8079eae9 100644 --- a/src/main/java/net/minecraft/world/damagesource/DamageSource.java +++ b/src/main/java/net/minecraft/world/damagesource/DamageSource.java @@ -77,6 +77,18 @@ public class DamageSource { @@ -52,7 +52,7 @@ index a828cad27fcd39f8bfbaefa97052a2a3b6650ee7..52cce7422c2a99e3de37f87ac7041516 public static DamageSource sting(LivingEntity attacker) { return new EntityDamageSource("sting", attacker); -@@ -127,17 +139,24 @@ public class DamageSource { +@@ -127,7 +139,7 @@ public class DamageSource { } public static DamageSource explosion(@Nullable Explosion explosion) { @@ -61,7 +61,8 @@ index a828cad27fcd39f8bfbaefa97052a2a3b6650ee7..52cce7422c2a99e3de37f87ac7041516 } public static DamageSource explosion(@Nullable LivingEntity attacker) { - return attacker != null ? (new EntityDamageSource("explosion.player", attacker)).setScalesWithDifficulty().setExplosion() : (new DamageSource("explosion")).setScalesWithDifficulty().setExplosion(); +@@ -138,10 +150,17 @@ public class DamageSource { + return (new EntityDamageSource("sonic_boom", attacker)).bypassArmor().bypassEnchantments().setMagic(); } + @Deprecated // Parchment @@ -79,27 +80,31 @@ index a828cad27fcd39f8bfbaefa97052a2a3b6650ee7..52cce7422c2a99e3de37f87ac7041516 return "DamageSource (" + this.msgId + ")"; } 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 29aa428e019681af8d6b0020c12b18660ff6af6c..9b2276555e0d52996cb84cc6ca492263e6905780 100644 +index 219877901fb5fc6401646253d6e5d7bd8416ffe1..caffd9b78d370019e98c9049a121c7d3734372e6 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 -@@ -101,10 +101,11 @@ public class EnderDragon extends Mob implements Enemy { +@@ -98,7 +98,7 @@ public class EnderDragon extends Mob implements Enemy { private final Node[] nodes = new Node[24]; private final int[] nodeAdjacency = new int[24]; private final BinaryHeap openSet = new BinaryHeap(); - private Explosion explosionSource = new Explosion(null, this, null, null, Double.NaN, Double.NaN, Double.NaN, Float.NaN, true, Explosion.BlockInteraction.DESTROY); // CraftBukkit - reusable source for CraftTNTPrimed.getSource() -+ private Explosion explosionSource; // Parchment - moved into constructor to fix null world ++ private Explosion explosionSource;// = new Explosion(null, this, null, null, Double.NaN, Double.NaN, Double.NaN, Float.NaN, true, Explosion.BlockInteraction.DESTROY); // CraftBukkit - reusable source for CraftTNTPrimed.getSource() // Parchment - moved into constructor to fix null world + // Paper start - add var for save custom podium + @Nullable + private BlockPos podium; +@@ -106,6 +106,7 @@ public class EnderDragon extends Mob implements Enemy { public EnderDragon(EntityType entitytypes, Level world) { super(EntityType.ENDER_DRAGON, world); -+ explosionSource = new Explosion(world, this, null, null, Double.NaN, Double.NaN, Double.NaN, Float.NaN, true, Explosion.BlockInteraction.DESTROY); // CraftBukkit - reusable source for CraftTNTPrimed.getSource() // Parchment - fix null world ++ explosionSource = new Explosion(world, this, null, null, Double.NaN, Double.NaN, Double.NaN, Float.NaN, true, Explosion.BlockInteraction.DESTROY); // Parchment - fix null world this.subEntities = new EnderDragonPart[]{this.head, this.neck, this.body, this.tail1, this.tail2, this.tail3, this.wing1, this.wing2}; this.setHealth(this.getMaxHealth()); this.noPhysics = true; diff --git a/src/main/java/net/minecraft/world/level/Explosion.java b/src/main/java/net/minecraft/world/level/Explosion.java -index 132140e00865fcf84ebe03ffcbc2f30ac11a0b35..8245ec990c7a37839b0eedbcdbf834df2b421e61 100644 +index 01477e7240f9e33d08d416a7d40ee10f3e5d4abf..e8e1501f31b27d2e4448475db46f98304874575f 100644 --- a/src/main/java/net/minecraft/world/level/Explosion.java +++ b/src/main/java/net/minecraft/world/level/Explosion.java -@@ -453,6 +453,13 @@ public class Explosion { +@@ -474,6 +474,13 @@ public class Explosion { return this.toBlow; } @@ -114,10 +119,10 @@ index 132140e00865fcf84ebe03ffcbc2f30ac11a0b35..8245ec990c7a37839b0eedbcdbf834df NONE, BREAK, DESTROY; 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 e3ff04fe21761db65fb03c5e58ecd5823f0507c6..943857d58d68628d3a79d2d687006a4fb89b75f3 100644 +index 654a859a37bf991c7a7fa8a44a3d20f8feb223db..52e6c9ea22273759ea9a827125bf561a62272ad9 100644 --- a/src/main/java/net/minecraft/world/level/block/BedBlock.java +++ b/src/main/java/net/minecraft/world/level/block/BedBlock.java -@@ -146,7 +146,10 @@ public class BedBlock extends HorizontalDirectionalBlock implements EntityBlock +@@ -145,7 +145,10 @@ public class BedBlock extends HorizontalDirectionalBlock implements EntityBlock world.removeBlock(blockposition1, false); } @@ -130,10 +135,10 @@ index e3ff04fe21761db65fb03c5e58ecd5823f0507c6..943857d58d68628d3a79d2d687006a4f } } 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 88439b8f82a97a9763dadfc6c9dbaf0912ab3eb7..73a9b765b58bb547712c014c8b9086535b3cf6fa 100644 +index 6be6adf73dc48ebbac22fe2a9be635f675f18cb1..e814c791137da2a10f4d4dd65f201fc220399975 100644 --- a/src/main/java/net/minecraft/world/level/block/RespawnAnchorBlock.java +++ b/src/main/java/net/minecraft/world/level/block/RespawnAnchorBlock.java -@@ -138,7 +138,10 @@ public class RespawnAnchorBlock extends Block { +@@ -148,7 +148,10 @@ public class RespawnAnchorBlock extends Block { return pos.equals(explodedPos) && bl2 ? Optional.of(Blocks.WATER.getExplosionResistance()) : super.getBlockExplosionResistance(explosion, world, pos, blockState, fluidState); } }; @@ -146,10 +151,10 @@ index 88439b8f82a97a9763dadfc6c9dbaf0912ab3eb7..73a9b765b58bb547712c014c8b908653 public static boolean canSetSpawn(Level world) { diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java -index b774a27eb4d11cd1bef807193a6df6012dde3794..911c0dd8a5863ae93dbd82fd3d6aafc267994081 100644 +index 1547cd54b805e46ebcf8d7a910533f29537c2c55..de6ec4c6d59d1b9fa203b0d373452e466a89e1ec 100644 --- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java +++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java -@@ -961,7 +961,7 @@ public class CraftEventFactory { +@@ -968,7 +968,7 @@ public class CraftEventFactory { CraftEventFactory.entityDamage = null; EntityDamageEvent event; if (damager == null) { @@ -158,21 +163,21 @@ index b774a27eb4d11cd1bef807193a6df6012dde3794..911c0dd8a5863ae93dbd82fd3d6aafc2 } else if (entity instanceof EnderDragon && /*PAIL FIXME ((EntityEnderDragon) entity).target == damager*/ false) { event = new EntityDamageEvent(entity.getBukkitEntity(), DamageCause.ENTITY_EXPLOSION, modifiers, modifierFunctions); } else { -@@ -997,7 +997,7 @@ public class CraftEventFactory { +@@ -1008,7 +1008,7 @@ public class CraftEventFactory { return CraftEventFactory.callEntityDamageEvent(damager, entity, cause, modifiers, modifierFunctions, cancelled, source.isCritical()); // Paper - add critical damage API } else if (source == DamageSource.OUT_OF_WORLD) { - EntityDamageEvent event = new EntityDamageByBlockEvent(null, entity.getBukkitEntity(), DamageCause.VOID, modifiers, modifierFunctions); -+ EntityDamageEvent event = new EntityDamageByBlockEvent(null, entity.getBukkitEntity(), DamageCause.VOID, entity.getBukkitEntity().getLocation(), modifiers, modifierFunctions); // Parchment ++ EntityDamageEvent event = new EntityDamageByBlockEvent(null, entity.getBukkitEntity(), DamageCause.VOID, entity.getBukkitEntity().getLocation(), modifiers, modifierFunctions); // Parchment - add location event.setCancelled(cancelled); CraftEventFactory.callEvent(event); if (!event.isCancelled()) { -@@ -1005,7 +1005,7 @@ public class CraftEventFactory { +@@ -1018,7 +1018,7 @@ public class CraftEventFactory { } return event; } else if (source == DamageSource.LAVA) { -- EntityDamageEvent event = (new EntityDamageByBlockEvent(null, entity.getBukkitEntity(), DamageCause.LAVA, modifiers, modifierFunctions)); -+ EntityDamageEvent event = (new EntityDamageByBlockEvent(null, entity.getBukkitEntity(), DamageCause.LAVA, entity.getBukkitEntity().getLocation().toBlockLocation(), modifiers, modifierFunctions)); // Parchment +- EntityDamageEvent event = (new EntityDamageByBlockEvent(CraftEventFactory.blockDamage, entity.getBukkitEntity(), DamageCause.LAVA, modifiers, modifierFunctions)); ++ EntityDamageEvent event = (new EntityDamageByBlockEvent(CraftEventFactory.blockDamage, entity.getBukkitEntity(), DamageCause.LAVA, entity.getBukkitEntity().getLocation().toBlockLocation(), modifiers, modifierFunctions)); // Parchment - add location event.setCancelled(cancelled); - CraftEventFactory.callEvent(event); - if (!event.isCancelled()) { + + Block damager = CraftEventFactory.blockDamage; diff --git a/patches/server/0006-Add-UnsafeValues-canPlaceItemOn.patch b/patches/server/0006-Add-UnsafeValues-canPlaceItemOn.patch index f1de4de..50b69d6 100644 --- a/patches/server/0006-Add-UnsafeValues-canPlaceItemOn.patch +++ b/patches/server/0006-Add-UnsafeValues-canPlaceItemOn.patch @@ -5,16 +5,16 @@ Subject: [PATCH] Add UnsafeValues#canPlaceItemOn diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java -index 424f3a9a645d57ad43c52932f5b388b5f146b9f0..a50eb7ba668ba4410c7a7fee629bdac958734311 100644 +index 88abd2d3a9626501b1800ee754b98c6c29c75fb9..0507e40c97567fc379ebe4d0b001af16922ddb3e 100644 --- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java +++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java -@@ -559,6 +559,55 @@ public final class CraftMagicNumbers implements UnsafeValues { +@@ -606,6 +606,55 @@ public final class CraftMagicNumbers implements UnsafeValues { } // Paper end + // Parchment start + @Override -+ public java.util.concurrent.CompletableFuture canPlaceItemOn(ItemStack item, me.lexikiq.OptionalHumanEntity player, org.bukkit.block.Block block, org.bukkit.block.BlockFace face) { ++ public java.util.concurrent.CompletableFuture canPlaceItemOn(ItemStack item, gg.projecteden.parchment.OptionalHumanEntity player, org.bukkit.block.Block block, org.bukkit.block.BlockFace face) { + org.apache.commons.lang3.Validate.notNull(item, "item"); + org.apache.commons.lang3.Validate.notNull(block, "block"); + org.apache.commons.lang3.Validate.notNull(face, "face"); diff --git a/patches/server/0007-Expose-EntityType-Ordinals.patch b/patches/server/0007-Expose-EntityType-Ordinals.patch index 590b667..feb69fe 100644 --- a/patches/server/0007-Expose-EntityType-Ordinals.patch +++ b/patches/server/0007-Expose-EntityType-Ordinals.patch @@ -5,32 +5,32 @@ Subject: [PATCH] Expose EntityType Ordinals diff --git a/src/main/java/net/minecraft/world/entity/EntityType.java b/src/main/java/net/minecraft/world/entity/EntityType.java -index 1c446dba5de89698397041ee38a2e1a00bec8a56..d12e936920c03cafd18f6c9a509c85c31ab7ba45 100644 +index ac0f0a4da4282c13f6e1f37710cb615d66b8ef2c..aa98cea349a3929cbb29fa01962ae98d9136cda7 100644 --- a/src/main/java/net/minecraft/world/entity/EntityType.java +++ b/src/main/java/net/minecraft/world/entity/EntityType.java -@@ -149,6 +149,8 @@ import org.apache.logging.log4j.Logger; +@@ -154,6 +154,8 @@ import org.slf4j.Logger; public class EntityType implements EntityTypeTest { + private static int ordinal = 0; // Parchment + private static final java.util.Map ordinals = new java.util.HashMap<>(); // Parchment - private static final Logger LOGGER = LogManager.getLogger(); + private static final Logger LOGGER = LogUtils.getLogger(); public static final String ENTITY_TAG = "EntityTag"; - private static final float MAGIC_HORSE_WIDTH = 1.3964844F; -@@ -283,9 +285,31 @@ public class EntityType implements EntityTypeTest { + private final Holder.Reference> builtInRegistryHolder; +@@ -294,9 +296,31 @@ public class EntityType implements EntityTypeTest { private final EntityDimensions dimensions; private static EntityType register(String id, EntityType.Builder type) { // CraftBukkit - decompile error -- return (EntityType) Registry.register((Registry) Registry.ENTITY_TYPE, id, (Object) type.build(id)); +- return (EntityType) Registry.register(Registry.ENTITY_TYPE, id, (EntityType) type.build(id)); // CraftBukkit - decompile error + // Parchment start + EntityType build = type.build(id); + ordinals.put(build, ordinal); + ordinal += 1; -+ return (EntityType) Registry.register((Registry) Registry.ENTITY_TYPE, id, (Object) build); ++ return (EntityType) Registry.register(Registry.ENTITY_TYPE, id, (EntityType) build); } + public int ordinal() { -+ return ordinals.get(this); ++ return ordinals.get(this); // CraftBukkit - decompile error + } + + @Override @@ -51,10 +51,10 @@ index 1c446dba5de89698397041ee38a2e1a00bec8a56..d12e936920c03cafd18f6c9a509c85c3 return Registry.ENTITY_TYPE.getKey(type); } diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java -index a50eb7ba668ba4410c7a7fee629bdac958734311..00a8ded3ae58b00f2c833953908f1d43765f4557 100644 +index ee4d1e3f0be4ac94bb03263425b2acfa97a85c0d..840017182f0c75af07bd461d59fc340b3c304b8a 100644 --- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java +++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java -@@ -606,6 +606,18 @@ public final class CraftMagicNumbers implements UnsafeValues { +@@ -653,6 +653,18 @@ public final class CraftMagicNumbers implements UnsafeValues { final net.minecraft.world.item.context.BlockPlaceContext ctx = context; return future.completeAsync(() -> blockItem.canPlace(ctx, blockState), net.minecraft.server.MCUtil.MAIN_EXECUTOR); } diff --git a/patches/server/0008-Add-Player-setGameProfile.patch b/patches/server/0008-Add-Player-setGameProfile.patch index 03ef0b4..128cdca 100644 --- a/patches/server/0008-Add-Player-setGameProfile.patch +++ b/patches/server/0008-Add-Player-setGameProfile.patch @@ -5,19 +5,19 @@ Subject: [PATCH] Add Player#setGameProfile 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 266d676118e17af48e21370211c015898eba9691..16bc55fb8efbbda971b704446a07e9f732c1dfa5 100644 +index bc6bdc8752718777ac698cfda2a0e7f35fcf9896..05584d344c9f7d6d89bb8fbdfa254c1dca91b590 100644 --- a/src/main/java/net/minecraft/world/entity/player/Player.java +++ b/src/main/java/net/minecraft/world/entity/player/Player.java -@@ -1451,6 +1451,12 @@ public abstract class Player extends LivingEntity { +@@ -1511,6 +1511,12 @@ public abstract class Player extends LivingEntity { return this.gameProfile; } -+ // Parchment start ++ // Parchment start | TODO: rename to match getter + public void setProfile(GameProfile gameProfile) { + this.gameProfile = gameProfile; + } + // Parchment end + - public Inventory getInventory() { - return this.inventory; - } + @Nullable + public ProfilePublicKey getProfilePublicKey() { + return this.profilePublicKey; diff --git a/patches/server/0009-Expose-MCUtil-Executors.patch b/patches/server/0009-Expose-MCUtil-Executors.patch index 8dfffad..9502756 100644 --- a/patches/server/0009-Expose-MCUtil-Executors.patch +++ b/patches/server/0009-Expose-MCUtil-Executors.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Expose MCUtil Executors diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -index 9f5bbb9e684ec11bc979ca2ece4eb73da0e3d1e8..9b92bd247f8752515830d1dea13f0137ae1621e1 100644 +index f4847a8671bd21f78af598faacea5c763669ddbc..97e60454716eacdfa4420efff2596b7f99d2bfd6 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -@@ -2720,4 +2720,16 @@ public final class CraftServer implements Server { +@@ -2869,4 +2869,16 @@ public final class CraftServer implements Server { } // Paper end diff --git a/patches/server/0010-Fix-missing-CraftMetaSkull-serializedProfile.patch b/patches/server/0010-Fix-missing-CraftMetaSkull-serializedProfile.patch index 67e0afb..3ff796b 100644 --- a/patches/server/0010-Fix-missing-CraftMetaSkull-serializedProfile.patch +++ b/patches/server/0010-Fix-missing-CraftMetaSkull-serializedProfile.patch @@ -6,20 +6,12 @@ Subject: [PATCH] Fix missing CraftMetaSkull serializedProfile Plugins (ab)using NMS may change the "profile" field using reflections instead of the "setProfile" method, especially if they are targeted towards old Minecraft versions. This fixes the potential discrepancies and NPEs. diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSkull.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSkull.java -index 7cacc61fed0c610845c67894d1cc68e44f5e46fe..18feaf0152b67b18989ca03fbb74194db489081e 100644 +index 292ae4a68093b7d939a755e1062cee57da186ab1..4afa90cb68aa31820abce6ab051de405daef6562 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSkull.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSkull.java -@@ -78,6 +78,7 @@ class CraftMetaSkull extends CraftMetaItem implements SkullMeta { - @Override - void serializeInternal(final Map internalTags) { - if (this.profile != null) { -+ refreshSerializedProfile(); // Parchment -- fix NPEs from plugins abusing NMS - internalTags.put(SKULL_PROFILE.NBT, serializedProfile); - } - } -@@ -91,6 +92,11 @@ class CraftMetaSkull extends CraftMetaItem implements SkullMeta { - } - // Paper end +@@ -80,6 +80,11 @@ class CraftMetaSkull extends CraftMetaItem implements SkullMeta { + + private void setProfile(GameProfile profile) { this.profile = profile; + // Parchment start -- fix NPEs from plugins abusing NMS + refreshSerializedProfile(); @@ -29,7 +21,7 @@ index 7cacc61fed0c610845c67894d1cc68e44f5e46fe..18feaf0152b67b18989ca03fbb74194d this.serializedProfile = (profile == null) ? null : NbtUtils.writeGameProfile(new CompoundTag(), profile); } -@@ -99,6 +105,7 @@ class CraftMetaSkull extends CraftMetaItem implements SkullMeta { +@@ -88,6 +93,7 @@ class CraftMetaSkull extends CraftMetaItem implements SkullMeta { super.applyToItem(tag); if (this.profile != null) { @@ -37,7 +29,7 @@ index 7cacc61fed0c610845c67894d1cc68e44f5e46fe..18feaf0152b67b18989ca03fbb74194d // SPIGOT-6558: Set initial textures tag.put(SKULL_OWNER.NBT, serializedProfile); // Fill in textures -@@ -234,6 +241,8 @@ class CraftMetaSkull extends CraftMetaItem implements SkullMeta { +@@ -243,6 +249,8 @@ class CraftMetaSkull extends CraftMetaItem implements SkullMeta { if (meta instanceof CraftMetaSkull) { CraftMetaSkull that = (CraftMetaSkull) meta; diff --git a/patches/server/0011-Add-BlockDropResourcesEvent.patch b/patches/server/0011-Add-BlockDropResourcesEvent.patch index afe3505..5266ba2 100644 --- a/patches/server/0011-Add-BlockDropResourcesEvent.patch +++ b/patches/server/0011-Add-BlockDropResourcesEvent.patch @@ -8,19 +8,19 @@ to easily get the items being dropped by any block instead of only blocks broken by players. 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 8c30e28b97ac7e8b54322c903e0b75ee8135620b..4ca85a02a1eb46b5958aae55946c67cefb85f461 100644 +index 224ce424b9a22548212ac157ec273c6dd80d6cfb..f33a8f7e46f9d88137de509e22d73edea3804cbe 100644 --- a/src/main/java/net/minecraft/world/level/block/Block.java +++ b/src/main/java/net/minecraft/world/level/block/Block.java -@@ -306,7 +306,7 @@ public class Block extends BlockBehaviour implements ItemLike { +@@ -308,7 +308,7 @@ public class Block extends BlockBehaviour implements ItemLike { ServerLevel worldserver = lootContext.getLevel(); BlockPos blockposition = new BlockPos((Vec3) lootContext.getParameter(LootContextParams.ORIGIN)); - state.getDrops(lootContext).forEach((itemstack) -> { + org.bukkit.craftbukkit.event.CraftEventFactory.callBlockDropResourcesEvent(worldserver, blockposition, state.getDrops(lootContext)).forEach((itemstack) -> { // Parchment - Block.popResource((Level) worldserver, blockposition, itemstack); + Block.popResource(worldserver, blockposition, itemstack); }); - state.spawnAfterBreak(worldserver, blockposition, ItemStack.EMPTY); -@@ -314,7 +314,7 @@ public class Block extends BlockBehaviour implements ItemLike { + state.spawnAfterBreak(worldserver, blockposition, ItemStack.EMPTY, true); +@@ -316,7 +316,7 @@ public class Block extends BlockBehaviour implements ItemLike { public static void dropResources(BlockState state, Level world, BlockPos pos) { if (world instanceof ServerLevel) { @@ -28,17 +28,17 @@ index 8c30e28b97ac7e8b54322c903e0b75ee8135620b..4ca85a02a1eb46b5958aae55946c67ce + org.bukkit.craftbukkit.event.CraftEventFactory.callBlockDropResourcesEvent(world, pos, Block.getDrops(state, (ServerLevel) world, pos, (BlockEntity) null)).forEach((itemstack) -> { // Parchment Block.popResource(world, pos, itemstack); }); - state.spawnAfterBreak((ServerLevel) world, pos, ItemStack.EMPTY); -@@ -324,7 +324,7 @@ public class Block extends BlockBehaviour implements ItemLike { + state.spawnAfterBreak((ServerLevel) world, pos, ItemStack.EMPTY, true); +@@ -326,7 +326,7 @@ public class Block extends BlockBehaviour implements ItemLike { public static void dropResources(BlockState state, LevelAccessor world, BlockPos pos, @Nullable BlockEntity blockEntity) { if (world instanceof ServerLevel) { - Block.getDrops(state, (ServerLevel) world, pos, blockEntity).forEach((itemstack) -> { + org.bukkit.craftbukkit.event.CraftEventFactory.callBlockDropResourcesEvent(world, pos, Block.getDrops(state, (ServerLevel) world, pos, blockEntity)).forEach((itemstack) -> { // Parchment - Block.popResource((Level) ((ServerLevel) world), pos, itemstack); + Block.popResource((ServerLevel) world, pos, itemstack); }); - state.spawnAfterBreak((ServerLevel) world, pos, ItemStack.EMPTY); -@@ -351,7 +351,7 @@ public class Block extends BlockBehaviour implements ItemLike { + state.spawnAfterBreak((ServerLevel) world, pos, ItemStack.EMPTY, true); +@@ -353,7 +353,7 @@ public class Block extends BlockBehaviour implements ItemLike { public static void dropResources(BlockState state, Level world, BlockPos pos, @Nullable BlockEntity blockEntity, Entity entity, ItemStack stack) { if (world instanceof ServerLevel) { @@ -46,20 +46,28 @@ index 8c30e28b97ac7e8b54322c903e0b75ee8135620b..4ca85a02a1eb46b5958aae55946c67ce + org.bukkit.craftbukkit.event.CraftEventFactory.callBlockDropResourcesEvent(world, pos, Block.getDrops(state, (ServerLevel) world, pos, blockEntity, entity, stack)).forEach((itemstack1) -> { // Parchment Block.popResource(world, pos, itemstack1); }); - state.spawnAfterBreak((ServerLevel) world, pos, stack); + state.spawnAfterBreak((ServerLevel) world, pos, stack, true); diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java -index 911c0dd8a5863ae93dbd82fd3d6aafc267994081..7aafe7cd3a8dae6b8f7b662049bf48bc6d698789 100644 +index de6ec4c6d59d1b9fa203b0d373452e466a89e1ec..6ff4c2cc4e49796e947dc70db1eff475e0eeaa3b 100644 --- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java +++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java -@@ -1924,5 +1924,11 @@ public class CraftEventFactory { - return null; - }, net.minecraft.server.MCUtil.asyncExecutor); +@@ -1965,5 +1965,19 @@ public class CraftEventFactory { + } + }); } + + public static List callBlockDropResourcesEvent(LevelAccessor world, BlockPos pos, List items) { -+ me.lexikiq.event.block.BlockDropResourcesEvent event = new me.lexikiq.event.block.BlockDropResourcesEvent(CraftBlock.at(world, pos), items.stream().map(CraftItemStack::asBukkitCopy).collect(Collectors.toCollection(ArrayList::new))); ++ List bukkitItems = new ArrayList<>(items.size()); ++ for (ItemStack item : items) { ++ bukkitItems.add(CraftItemStack.asBukkitCopy(item)); ++ } ++ gg.projecteden.parchment.event.block.BlockDropResourcesEvent event = new gg.projecteden.parchment.event.block.BlockDropResourcesEvent(CraftBlock.at(world, pos), bukkitItems); + event.callEvent(); -+ return event.getResources().stream().map(CraftItemStack::asNMSCopy).collect(Collectors.toList()); ++ items = new ArrayList<>(bukkitItems.size()); ++ for (org.bukkit.inventory.ItemStack item : bukkitItems) { ++ items.add(CraftItemStack.asNMSCopy(item)); ++ } ++ return items; + } // Parchment end } diff --git a/patches/server/0012-Add-Furnace-Recipe-API.patch b/patches/server/0012-Add-Furnace-Recipe-API.patch index 80152fa..0167924 100644 --- a/patches/server/0012-Add-Furnace-Recipe-API.patch +++ b/patches/server/0012-Add-Furnace-Recipe-API.patch @@ -7,13 +7,13 @@ Temporary API to get the result of smelting an item in a (type of) furnace. Will eventually (hopefully) be replaced by a more extensive Paper PR with support for all recipes. -diff --git a/src/main/java/me/lexikiq/inventory/CraftRecipeType.java b/src/main/java/me/lexikiq/inventory/CraftRecipeType.java +diff --git a/src/main/java/gg/projecteden/parchment/inventory/CraftRecipeType.java b/src/main/java/gg/projecteden/parchment/inventory/CraftRecipeType.java new file mode 100644 -index 0000000000000000000000000000000000000000..6a28791b12c309661e79e0e6a8f7a9ec8fd706a3 +index 0000000000000000000000000000000000000000..5549da2a0b0790699abff627148a6b15ca37febf --- /dev/null -+++ b/src/main/java/me/lexikiq/inventory/CraftRecipeType.java ++++ b/src/main/java/gg/projecteden/parchment/inventory/CraftRecipeType.java @@ -0,0 +1,44 @@ -+package me.lexikiq.inventory; ++package gg.projecteden.parchment.inventory; + +import net.minecraft.world.item.crafting.AbstractCookingRecipe; + @@ -57,13 +57,13 @@ index 0000000000000000000000000000000000000000..6a28791b12c309661e79e0e6a8f7a9ec + } + } +} -diff --git a/src/main/java/me/lexikiq/inventory/SingletonContainer.java b/src/main/java/me/lexikiq/inventory/SingletonContainer.java +diff --git a/src/main/java/gg/projecteden/parchment/inventory/SingletonContainer.java b/src/main/java/gg/projecteden/parchment/inventory/SingletonContainer.java new file mode 100644 -index 0000000000000000000000000000000000000000..e6d1e8faafe3fec48df51e5a25acef56a8428db3 +index 0000000000000000000000000000000000000000..e7114e456f818d7bdd4081620f4b9b9376679145 --- /dev/null -+++ b/src/main/java/me/lexikiq/inventory/SingletonContainer.java ++++ b/src/main/java/gg/projecteden/parchment/inventory/SingletonContainer.java @@ -0,0 +1,151 @@ -+package me.lexikiq.inventory; ++package gg.projecteden.parchment.inventory; + +import com.google.common.base.Preconditions; +import net.minecraft.world.Container; @@ -215,18 +215,18 @@ index 0000000000000000000000000000000000000000..e6d1e8faafe3fec48df51e5a25acef56 + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java -index 858e29ad77aee8a1b7797c2d82902abbfd662da2..cd98817b0dca964a5cbaa6c19169f37d0bee6682 100644 +index 25e56be9055c5c432e1180d45341f4e9d9fcb7ca..4e8dbefb953a8ca09dda1e195591c10ebd9b0243 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java -@@ -2162,4 +2162,11 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -2321,4 +2321,11 @@ public class CraftWorld extends CraftRegionAccessor implements World { return this.adventure$pointers; } // Paper end + + // Parchment start + @Override -+ public ItemStack smeltItem(ItemStack toSmelt, me.lexikiq.inventory.RecipeType recipeType) { -+ return world.getRecipeManager().getRecipeFor(me.lexikiq.inventory.CraftRecipeType.asCookingRecipe(recipeType), new me.lexikiq.inventory.SingletonContainer(toSmelt), world).map(recipe -> recipe.getResultItem().getBukkitStack()).orElse(null); ++ public ItemStack smeltItem(ItemStack toSmelt, gg.projecteden.parchment.inventory.RecipeType recipeType) { ++ return world.getRecipeManager().getRecipeFor(gg.projecteden.parchment.inventory.CraftRecipeType.asCookingRecipe(recipeType), new gg.projecteden.parchment.inventory.SingletonContainer(toSmelt), world).map(recipe -> recipe.getResultItem().getBukkitStack()).orElse(null); + } + // Parchment end } diff --git a/patches/server/0013-Disable-sleep-status-announcements.patch b/patches/server/0013-Disable-sleep-status-announcements.patch index 06eaea3..88e02b5 100644 --- a/patches/server/0013-Disable-sleep-status-announcements.patch +++ b/patches/server/0013-Disable-sleep-status-announcements.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Disable sleep status announcements diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java -index 933b577dd582d1624cbd587b726e96fc9cfef68a..d92740433c908f54b724b9d0ce37f51e228c4dcc 100644 +index 782be663520c27fccb58484ec56cc94def38f136..e33d731d4689963fa9c5b2feef24a6b7b202988b 100644 --- a/src/main/java/net/minecraft/server/level/ServerLevel.java +++ b/src/main/java/net/minecraft/server/level/ServerLevel.java -@@ -994,7 +994,7 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -918,7 +918,7 @@ public class ServerLevel extends Level implements WorldGenLevel { } private void announceSleepStatus() { @@ -16,4 +16,4 @@ index 933b577dd582d1624cbd587b726e96fc9cfef68a..d92740433c908f54b724b9d0ce37f51e + if (false && this.canSleepThroughNights()) { if (!this.getServer().isSingleplayer() || this.getServer().isPublished()) { int i = this.getGameRules().getInt(GameRules.RULE_PLAYERS_SLEEPING_PERCENTAGE); - TranslatableComponent chatmessage; + MutableComponent ichatmutablecomponent; diff --git a/patches/server/0014-Add-config-for-ticking-TIME_SINCE_REST.patch b/patches/server/0014-Add-config-for-ticking-TIME_SINCE_REST.patch new file mode 100644 index 0000000..4902236 --- /dev/null +++ b/patches/server/0014-Add-config-for-ticking-TIME_SINCE_REST.patch @@ -0,0 +1,31 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Lexi +Date: Fri, 17 Jun 2022 14:36:42 -0400 +Subject: [PATCH] Add config for ticking TIME_SINCE_REST + + +diff --git a/src/main/java/io/papermc/paper/configuration/WorldConfiguration.java b/src/main/java/io/papermc/paper/configuration/WorldConfiguration.java +index 32f0cd29d1198fe320d10ccfe0b02f8632ac12aa..7154ca5d729f44a7cbd0d47f23c10f44c0aef6b3 100644 +--- a/src/main/java/io/papermc/paper/configuration/WorldConfiguration.java ++++ b/src/main/java/io/papermc/paper/configuration/WorldConfiguration.java +@@ -252,6 +252,7 @@ public class WorldConfiguration extends ConfigurationPart { + } + + public boolean disablePlayerCrits = false; ++ public boolean tickTimeSinceSleep = true; // Parchment + public boolean nerfPigmenFromNetherPortals = false; + public PillagerPatrols pillagerPatrols; + +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 05584d344c9f7d6d89bb8fbdfa254c1dca91b590..aea543059600f093b96df985468a61da048acdb6 100644 +--- a/src/main/java/net/minecraft/world/entity/player/Player.java ++++ b/src/main/java/net/minecraft/world/entity/player/Player.java +@@ -293,7 +293,7 @@ public abstract class Player extends LivingEntity { + this.awardStat(Stats.CROUCH_TIME); + } + +- if (!this.isSleeping()) { ++ if (!this.isSleeping() && this.level.paperConfig().entities.behavior.tickTimeSinceSleep) { // Parchment + this.awardStat(Stats.TIME_SINCE_REST); + } + } diff --git a/settings.gradle.kts b/settings.gradle.kts index cd331be..db56c82 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -5,6 +5,6 @@ pluginManagement { } } -rootProject.name = "Parchment" +rootProject.name = "parchment" -include("Parchment-Common", "Parchment-API", "Parchment-Server") +include("parchment-api", "parchment-server")