Update launchProjectile API (#11300)

This commit is contained in:
Lulu13022002 2024-09-21 21:19:02 +02:00 committed by GitHub
parent 593faf4fc3
commit 1ed64f8270
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
453 changed files with 280 additions and 136 deletions

View file

@ -1719,6 +1719,32 @@ index b84b37fe27d84574dc5897285f1d9a1437bd322c..281ae60a6be7e39aab4f27b4c7de3d49
* *
* @return Set containing all the channels that this client may accept. * @return Set containing all the channels that this client may accept.
*/ */
diff --git a/src/main/java/org/bukkit/projectiles/ProjectileSource.java b/src/main/java/org/bukkit/projectiles/ProjectileSource.java
index eabd8b926ec1c934cd7e77b7cc6adfae16771021..8557bfefaf02538dec95adb29734ae2cf50f3f8c 100644
--- a/src/main/java/org/bukkit/projectiles/ProjectileSource.java
+++ b/src/main/java/org/bukkit/projectiles/ProjectileSource.java
@@ -12,6 +12,10 @@ public interface ProjectileSource {
/**
* Launches a {@link Projectile} from the ProjectileSource.
+ * <p>
+ * The family of launchProjectile methods only promise the ability to launch projectile types
+ * that the {@link ProjectileSource} is capable of firing in vanilla.
+ * Any other types of projectiles *may* be implemented but are not part of the method contract.
*
* @param <T> a projectile subclass
* @param projectile class of the projectile to launch
@@ -23,6 +27,10 @@ public interface ProjectileSource {
/**
* Launches a {@link Projectile} from the ProjectileSource with an
* initial velocity.
+ * <p>
+ * The family of launchProjectile methods only promise the ability to launch projectile types
+ * that the {@link ProjectileSource} is capable of firing in vanilla.
+ * Any other types of projectiles *may* be implemented but are not part of the method contract.
*
* @param <T> a projectile subclass
* @param projectile class of the projectile to launch
diff --git a/src/main/java/org/bukkit/scoreboard/Objective.java b/src/main/java/org/bukkit/scoreboard/Objective.java diff --git a/src/main/java/org/bukkit/scoreboard/Objective.java b/src/main/java/org/bukkit/scoreboard/Objective.java
index 22b1dc5fd4d453161a5ee520072f8e8f955b3a80..a625bcab8e77b05b3341a52c708fae1542b7e3d5 100644 index 22b1dc5fd4d453161a5ee520072f8e8f955b3a80..a625bcab8e77b05b3341a52c708fae1542b7e3d5 100644
--- a/src/main/java/org/bukkit/scoreboard/Objective.java --- a/src/main/java/org/bukkit/scoreboard/Objective.java

View file

@ -5,6 +5,7 @@ Subject: [PATCH] More Projectile API
Co-authored-by: Nassim Jahnke <nassim@njahnke.dev> Co-authored-by: Nassim Jahnke <nassim@njahnke.dev>
Co-authored-by: SoSeDiK <mrsosedik@gmail.com> Co-authored-by: SoSeDiK <mrsosedik@gmail.com>
Co-authored-by: MelnCat <melncatuwu@gmail.com>
diff --git a/src/main/java/org/bukkit/entity/AbstractArrow.java b/src/main/java/org/bukkit/entity/AbstractArrow.java diff --git a/src/main/java/org/bukkit/entity/AbstractArrow.java b/src/main/java/org/bukkit/entity/AbstractArrow.java
index 8bf9bf7940d2911486e9d3a4f688cfae3f6173f2..9bf4b86e730f3d066f6ebfd4e516caf78145479e 100644 index 8bf9bf7940d2911486e9d3a4f688cfae3f6173f2..9bf4b86e730f3d066f6ebfd4e516caf78145479e 100644
@ -486,3 +487,34 @@ index c8015ff610e3c1222cb368ea1d8a0c2f3785d9c7..02584eced96944a551140f8150c65a7c
+ void setHasDealtDamage(boolean hasDealtDamage); + void setHasDealtDamage(boolean hasDealtDamage);
} }
// Paper end // Paper end
diff --git a/src/main/java/org/bukkit/projectiles/ProjectileSource.java b/src/main/java/org/bukkit/projectiles/ProjectileSource.java
index 8557bfefaf02538dec95adb29734ae2cf50f3f8c..03faf9a142f494e255258099a6b8831a0d4a879b 100644
--- a/src/main/java/org/bukkit/projectiles/ProjectileSource.java
+++ b/src/main/java/org/bukkit/projectiles/ProjectileSource.java
@@ -39,4 +39,26 @@ public interface ProjectileSource {
*/
@NotNull
public <T extends Projectile> T launchProjectile(@NotNull Class<? extends T> projectile, @Nullable Vector velocity);
+
+ // Paper start - add consumer to launchProjectile
+ /**
+ * Launches a {@link Projectile} from the ProjectileSource with an
+ * initial velocity, with the supplied function run before the
+ * entity is added to the world.
+ * <br>
+ * Note that when the function is run, the entity will not be actually in
+ * the world. Any operation involving such as teleporting the entity is undefined
+ * until after this function returns.
+ * <p>
+ * The family of launchProjectile methods only promise the ability to launch projectile types
+ * that the {@link ProjectileSource} is capable of firing in vanilla.
+ * Any other types of projectiles *may* be implemented but are not part of the method contract.
+ * @param <T> a projectile subclass
+ * @param projectile class of the projectile to launch
+ * @param velocity the velocity with which to launch
+ * @param function the function to be run before the entity is spawned
+ * @return the launched projectile
+ */
+ <T extends Projectile> @NotNull T launchProjectile(@NotNull Class<? extends T> projectile, @Nullable Vector velocity, java.util.function.@Nullable Consumer<? super T> function);
+ // Paper end - add consumer to launchProjectile
}

View file

@ -1,34 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: MelnCat <melncatuwu@gmail.com>
Date: Mon, 19 Sep 2022 14:04:13 -0700
Subject: [PATCH] Add a consumer parameter to ProjectileSource#launchProjectile
diff --git a/src/main/java/org/bukkit/projectiles/ProjectileSource.java b/src/main/java/org/bukkit/projectiles/ProjectileSource.java
index eabd8b926ec1c934cd7e77b7cc6adfae16771021..96ebd30d339060758e726e9e1e7428d1d0813c17 100644
--- a/src/main/java/org/bukkit/projectiles/ProjectileSource.java
+++ b/src/main/java/org/bukkit/projectiles/ProjectileSource.java
@@ -31,4 +31,23 @@ public interface ProjectileSource {
*/
@NotNull
public <T extends Projectile> T launchProjectile(@NotNull Class<? extends T> projectile, @Nullable Vector velocity);
+
+ // Paper start - add consumer to launchProjectile
+ /**
+ * Launches a {@link Projectile} from the ProjectileSource with an
+ * initial velocity, with the supplied function run before the
+ * entity is added to the world.
+ * <br>
+ * Note that when the function is run, the entity will not be actually in
+ * the world. Any operation involving such as teleporting the entity is undefined
+ * until after this function returns.
+ *
+ * @param <T> a projectile subclass
+ * @param projectile class of the projectile to launch
+ * @param velocity the velocity with which to launch
+ * @param function the function to be run before the entity is spawned
+ * @return the launched projectile
+ */
+ <T extends Projectile> @NotNull T launchProjectile(@NotNull Class<? extends T> projectile, @Nullable Vector velocity, java.util.function.@Nullable Consumer<? super T> function);
+ // Paper end - add consumer to launchProjectile
}

View file

@ -59,7 +59,7 @@ index ced419f8655bff72f0257b639d5f7d73afe3c2e2..bcc6ba95bd21c7972865838c636a03f5
/** /**
* Gets the item stack associated with this item drop. * Gets the item stack associated with this item drop.
diff --git a/src/main/java/org/bukkit/entity/LivingEntity.java b/src/main/java/org/bukkit/entity/LivingEntity.java diff --git a/src/main/java/org/bukkit/entity/LivingEntity.java b/src/main/java/org/bukkit/entity/LivingEntity.java
index c9c3b926c5bb408d964ed5acc9f95c8527837a25..7c027d7bbd6b8a1543fa92d44e99674925f093b3 100644 index 9f3e2903c955f2a5d1b25825c49188df62d20cef..016529563381a674db8050cb328f9e8f16e72e93 100644
--- a/src/main/java/org/bukkit/entity/LivingEntity.java --- a/src/main/java/org/bukkit/entity/LivingEntity.java
+++ b/src/main/java/org/bukkit/entity/LivingEntity.java +++ b/src/main/java/org/bukkit/entity/LivingEntity.java
@@ -27,7 +27,7 @@ import org.jetbrains.annotations.Nullable; @@ -27,7 +27,7 @@ import org.jetbrains.annotations.Nullable;

View file

@ -5,7 +5,7 @@ Subject: [PATCH] Add method to remove all active potion effects
diff --git a/src/main/java/org/bukkit/entity/LivingEntity.java b/src/main/java/org/bukkit/entity/LivingEntity.java diff --git a/src/main/java/org/bukkit/entity/LivingEntity.java b/src/main/java/org/bukkit/entity/LivingEntity.java
index f5149d54d6cb5019f398718b9aa52bc3ab34a5ae..ad3717d963f28751d410e6688ae64a4c1175871d 100644 index c610731928ac9b01b111a7ccf0340ad59fcfb867..4aab0144601788a7902c9fdabb68744d9e33a345 100644
--- a/src/main/java/org/bukkit/entity/LivingEntity.java --- a/src/main/java/org/bukkit/entity/LivingEntity.java
+++ b/src/main/java/org/bukkit/entity/LivingEntity.java +++ b/src/main/java/org/bukkit/entity/LivingEntity.java
@@ -657,6 +657,15 @@ public interface LivingEntity extends Attributable, Damageable, ProjectileSource @@ -657,6 +657,15 @@ public interface LivingEntity extends Attributable, Damageable, ProjectileSource

View file

@ -499,7 +499,7 @@ index 0000000000000000000000000000000000000000..a6b50c9d8af589cc4747e14d343d2045
+ } + }
+} +}
diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java
index 556e8c6cf90af9c90ded18be013167fa440d6505..9265ee60edfb3df797e425e854c7d3c9c034a85c 100644 index adc95cd1486791787950533ef8e4baaf5d3827cc..50efe16bb80c618c3dfae03b70c8c165183af8ec 100644
--- a/src/main/java/org/bukkit/Bukkit.java --- a/src/main/java/org/bukkit/Bukkit.java
+++ b/src/main/java/org/bukkit/Bukkit.java +++ b/src/main/java/org/bukkit/Bukkit.java
@@ -2672,6 +2672,141 @@ public final class Bukkit { @@ -2672,6 +2672,141 @@ public final class Bukkit {
@ -645,7 +645,7 @@ index 556e8c6cf90af9c90ded18be013167fa440d6505..9265ee60edfb3df797e425e854c7d3c9
public static Server.Spigot spigot() { public static Server.Spigot spigot() {
return server.spigot(); return server.spigot();
diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java
index a859d7bc870e5ef16793c2da453c84685b78ee47..968a5e18a023c92158a753f6d8fce4b2d0f0de48 100644 index 0648130a6ce2e08d96b05fde1cfd58c2bb24ae07..1b8d6a3333a4fa9155b79644e683e2343c134e12 100644
--- a/src/main/java/org/bukkit/Server.java --- a/src/main/java/org/bukkit/Server.java
+++ b/src/main/java/org/bukkit/Server.java +++ b/src/main/java/org/bukkit/Server.java
@@ -2333,4 +2333,119 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi @@ -2333,4 +2333,119 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi

View file

@ -5,7 +5,7 @@ Subject: [PATCH] API for updating recipes on clients
diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java
index 9265ee60edfb3df797e425e854c7d3c9c034a85c..f2753ef7d53ff3ff3531eaea89e816d7d8ce8b15 100644 index 50efe16bb80c618c3dfae03b70c8c165183af8ec..52c601328bbf5c1642aa620c8bb466a9d2d231be 100644
--- a/src/main/java/org/bukkit/Bukkit.java --- a/src/main/java/org/bukkit/Bukkit.java
+++ b/src/main/java/org/bukkit/Bukkit.java +++ b/src/main/java/org/bukkit/Bukkit.java
@@ -1004,6 +1004,26 @@ public final class Bukkit { @@ -1004,6 +1004,26 @@ public final class Bukkit {
@ -82,7 +82,7 @@ index 9265ee60edfb3df797e425e854c7d3c9c034a85c..f2753ef7d53ff3ff3531eaea89e816d7
* Gets a list of command aliases defined in the server properties. * Gets a list of command aliases defined in the server properties.
* *
diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java
index 968a5e18a023c92158a753f6d8fce4b2d0f0de48..b93359e86db14e3a680bcdd8d935e2692c8b64e0 100644 index 1b8d6a3333a4fa9155b79644e683e2343c134e12..8ba2fbaab7428a42b506fd000fbc162f68ddaed1 100644
--- a/src/main/java/org/bukkit/Server.java --- a/src/main/java/org/bukkit/Server.java
+++ b/src/main/java/org/bukkit/Server.java +++ b/src/main/java/org/bukkit/Server.java
@@ -853,6 +853,22 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi @@ -853,6 +853,22 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi

View file

@ -5,7 +5,7 @@ Subject: [PATCH] Deprecate and replace methods with old StructureType
diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java
index f2753ef7d53ff3ff3531eaea89e816d7d8ce8b15..7e70b9b34b170b1c00dd920fabc0e14ed4a14955 100644 index 52c601328bbf5c1642aa620c8bb466a9d2d231be..c8fa12acaf52cd3923a7a8702ccc50cfdc9170a2 100644
--- a/src/main/java/org/bukkit/Bukkit.java --- a/src/main/java/org/bukkit/Bukkit.java
+++ b/src/main/java/org/bukkit/Bukkit.java +++ b/src/main/java/org/bukkit/Bukkit.java
@@ -949,9 +949,6 @@ public final class Bukkit { @@ -949,9 +949,6 @@ public final class Bukkit {
@ -84,7 +84,7 @@ index f2753ef7d53ff3ff3531eaea89e816d7d8ce8b15..7e70b9b34b170b1c00dd920fabc0e14e
/** /**
* Reloads the server, refreshing settings and plugin information. * Reloads the server, refreshing settings and plugin information.
diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java
index b93359e86db14e3a680bcdd8d935e2692c8b64e0..f2be9647e015761ef7f56331be932a39cb6a5e8b 100644 index 8ba2fbaab7428a42b506fd000fbc162f68ddaed1..50ffca9bccfb582d58ccb13f0decf66e5d91aef3 100644
--- a/src/main/java/org/bukkit/Server.java --- a/src/main/java/org/bukkit/Server.java
+++ b/src/main/java/org/bukkit/Server.java +++ b/src/main/java/org/bukkit/Server.java
@@ -817,16 +817,15 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi @@ -817,16 +817,15 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi

View file

@ -49,7 +49,7 @@ index 62d2b3f950860dee0898d77b0a29635c3f9a7e23..98fdfc8978fea1937e31a7427433a192
@Override @Override
public @NotNull String translationKey() { public @NotNull String translationKey() {
diff --git a/src/main/java/org/bukkit/Registry.java b/src/main/java/org/bukkit/Registry.java diff --git a/src/main/java/org/bukkit/Registry.java b/src/main/java/org/bukkit/Registry.java
index 7870a796e719148a42d18f1497b56c0d8f651a43..ff82bf3ea959c78e71ec7b0972a2d472f20aaf04 100644 index 04dfab3fb9a9a3bc7e69cb0c1f5346f3c7d87d72..82381ea98af1c9216a2989ea83ba4aa90ba69741 100644
--- a/src/main/java/org/bukkit/Registry.java --- a/src/main/java/org/bukkit/Registry.java
+++ b/src/main/java/org/bukkit/Registry.java +++ b/src/main/java/org/bukkit/Registry.java
@@ -367,6 +367,79 @@ public interface Registry<T extends Keyed> extends Iterable<T> { @@ -367,6 +367,79 @@ public interface Registry<T extends Keyed> extends Iterable<T> {

View file

@ -5,7 +5,7 @@ Subject: [PATCH] Add HiddenPotionEffect API
diff --git a/src/main/java/org/bukkit/entity/LivingEntity.java b/src/main/java/org/bukkit/entity/LivingEntity.java diff --git a/src/main/java/org/bukkit/entity/LivingEntity.java b/src/main/java/org/bukkit/entity/LivingEntity.java
index ad3717d963f28751d410e6688ae64a4c1175871d..8369da45206d2606f0715f3d803163dd8028251e 100644 index 4aab0144601788a7902c9fdabb68744d9e33a345..51a428473e702be3ab79bd1e579d1114f747791b 100644
--- a/src/main/java/org/bukkit/entity/LivingEntity.java --- a/src/main/java/org/bukkit/entity/LivingEntity.java
+++ b/src/main/java/org/bukkit/entity/LivingEntity.java +++ b/src/main/java/org/bukkit/entity/LivingEntity.java
@@ -591,6 +591,9 @@ public interface LivingEntity extends Attributable, Damageable, ProjectileSource @@ -591,6 +591,9 @@ public interface LivingEntity extends Attributable, Damageable, ProjectileSource

View file

@ -68,7 +68,7 @@ index a77c0411a68a9bad33ddfb335b7a996a843e478c..739d9d3ec789e58c10c8d818a9ca59ce
/** /**
* Banned player names * Banned player names
diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java
index 7e70b9b34b170b1c00dd920fabc0e14ed4a14955..419c056faf0d49d9b0435feb01252e87e227b9a9 100644 index c8fa12acaf52cd3923a7a8702ccc50cfdc9170a2..e20e4239a5a1f952e1c70e899549989d5e42f73c 100644
--- a/src/main/java/org/bukkit/Bukkit.java --- a/src/main/java/org/bukkit/Bukkit.java
+++ b/src/main/java/org/bukkit/Bukkit.java +++ b/src/main/java/org/bukkit/Bukkit.java
@@ -1663,11 +1663,27 @@ public final class Bukkit { @@ -1663,11 +1663,27 @@ public final class Bukkit {
@ -100,7 +100,7 @@ index 7e70b9b34b170b1c00dd920fabc0e14ed4a14955..419c056faf0d49d9b0435feb01252e87
/** /**
* Gets a set containing all player operators. * Gets a set containing all player operators.
diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java
index f2be9647e015761ef7f56331be932a39cb6a5e8b..5aa64ea39ebd92e5067c53cea49a8685c0b9eee4 100644 index 50ffca9bccfb582d58ccb13f0decf66e5d91aef3..6246251caf2c6f025c824b8e7a944b8d48751fa1 100644
--- a/src/main/java/org/bukkit/Server.java --- a/src/main/java/org/bukkit/Server.java
+++ b/src/main/java/org/bukkit/Server.java +++ b/src/main/java/org/bukkit/Server.java
@@ -1425,10 +1425,25 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi @@ -1425,10 +1425,25 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi

Some files were not shown because too many files have changed in this diff Show more