3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-11-15 04:20:04 +01:00

Use ? super in Consumer/Predicate API (#9939)

Dieser Commit ist enthalten in:
Jake Potrebic 2023-11-25 15:03:02 -08:00 committet von GitHub
Ursprung f9938d3949
Commit b37bbcfd98
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 4AEE18F83AFDEB23
21 geänderte Dateien mit 240 neuen und 277 gelöschten Zeilen

Datei anzeigen

@ -6,7 +6,7 @@ Subject: [PATCH] Additional world.getNearbyEntities API's
Provides more methods to get nearby entities, and filter by types and predicates Provides more methods to get nearby entities, and filter by types and predicates
diff --git a/src/main/java/org/bukkit/World.java b/src/main/java/org/bukkit/World.java diff --git a/src/main/java/org/bukkit/World.java b/src/main/java/org/bukkit/World.java
index 609e4908ed21f69b9e813500e702bbe784bff00c..7a6caf93606203198369030a295f1edbffde3c31 100644 index 609e4908ed21f69b9e813500e702bbe784bff00c..a5be4e073d3406e876e54824aca5449f3262ee75 100644
--- a/src/main/java/org/bukkit/World.java --- a/src/main/java/org/bukkit/World.java
+++ b/src/main/java/org/bukkit/World.java +++ b/src/main/java/org/bukkit/World.java
@@ -1,6 +1,9 @@ @@ -1,6 +1,9 @@
@ -19,20 +19,19 @@ index 609e4908ed21f69b9e813500e702bbe784bff00c..7a6caf93606203198369030a295f1edb
import java.util.Collection; import java.util.Collection;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
@@ -625,6 +628,256 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient @@ -625,6 +628,238 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient
@NotNull @NotNull
public Collection<Entity> getEntitiesByClasses(@NotNull Class<?>... classes); public Collection<Entity> getEntitiesByClasses(@NotNull Class<?>... classes);
+ // Paper start + // Paper start - additional getNearbyEntities API
+ /** + /**
+ * Gets nearby LivingEntities within the specified radius (bounding box) + * Gets nearby LivingEntities within the specified radius (bounding box)
+ * @param loc Center location + * @param loc Center location
+ * @param radius Radius + * @param radius Radius
+ * @return the collection of entities near location. This will always be a non-null collection. + * @return the collection of entities near location. This will always be a non-null collection.
+ */ + */
+ @NotNull + default @NotNull Collection<LivingEntity> getNearbyLivingEntities(final @NotNull Location loc, final double radius) {
+ public default Collection<LivingEntity> getNearbyLivingEntities(@NotNull Location loc, double radius) { + return this.getNearbyEntitiesByType(LivingEntity.class, loc, radius, radius, radius);
+ return getNearbyEntitiesByType(org.bukkit.entity.LivingEntity.class, loc, radius, radius, radius);
+ } + }
+ +
+ /** + /**
@ -42,9 +41,8 @@ index 609e4908ed21f69b9e813500e702bbe784bff00c..7a6caf93606203198369030a295f1edb
+ * @param yRadius Y Radius + * @param yRadius Y Radius
+ * @return the collection of entities near location. This will always be a non-null collection. + * @return the collection of entities near location. This will always be a non-null collection.
+ */ + */
+ @NotNull + default @NotNull Collection<LivingEntity> getNearbyLivingEntities(final @NotNull Location loc, final double xzRadius, final double yRadius) {
+ public default Collection<LivingEntity> getNearbyLivingEntities(@NotNull Location loc, double xzRadius, double yRadius) { + return this.getNearbyEntitiesByType(LivingEntity.class, loc, xzRadius, yRadius, xzRadius);
+ return getNearbyEntitiesByType(org.bukkit.entity.LivingEntity.class, loc, xzRadius, yRadius, xzRadius);
+ } + }
+ +
+ /** + /**
@ -55,9 +53,8 @@ index 609e4908ed21f69b9e813500e702bbe784bff00c..7a6caf93606203198369030a295f1edb
+ * @param zRadius Z radius + * @param zRadius Z radius
+ * @return the collection of entities near location. This will always be a non-null collection. + * @return the collection of entities near location. This will always be a non-null collection.
+ */ + */
+ @NotNull + default @NotNull Collection<LivingEntity> getNearbyLivingEntities(final @NotNull Location loc, final double xRadius, final double yRadius, final double zRadius) {
+ public default Collection<LivingEntity> getNearbyLivingEntities(@NotNull Location loc, double xRadius, double yRadius, double zRadius) { + return this.getNearbyEntitiesByType(LivingEntity.class, loc, xRadius, yRadius, zRadius);
+ return getNearbyEntitiesByType(org.bukkit.entity.LivingEntity.class, loc, xRadius, yRadius, zRadius);
+ } + }
+ +
+ /** + /**
@ -67,9 +64,8 @@ index 609e4908ed21f69b9e813500e702bbe784bff00c..7a6caf93606203198369030a295f1edb
+ * @param predicate a predicate used to filter results + * @param predicate a predicate used to filter results
+ * @return the collection of living entities near location. This will always be a non-null collection + * @return the collection of living entities near location. This will always be a non-null collection
+ */ + */
+ @NotNull + default @NotNull Collection<LivingEntity> getNearbyLivingEntities(final @NotNull Location loc, final double radius, final @Nullable Predicate<? super LivingEntity> predicate) {
+ public default Collection<LivingEntity> getNearbyLivingEntities(@NotNull Location loc, double radius, @Nullable Predicate<LivingEntity> predicate) { + return this.getNearbyEntitiesByType(LivingEntity.class, loc, radius, radius, radius, predicate);
+ return getNearbyEntitiesByType(org.bukkit.entity.LivingEntity.class, loc, radius, radius, radius, predicate);
+ } + }
+ +
+ /** + /**
@ -80,9 +76,8 @@ index 609e4908ed21f69b9e813500e702bbe784bff00c..7a6caf93606203198369030a295f1edb
+ * @param predicate a predicate used to filter results + * @param predicate a predicate used to filter results
+ * @return the collection of living entities near location. This will always be a non-null collection + * @return the collection of living entities near location. This will always be a non-null collection
+ */ + */
+ @NotNull + default @NotNull Collection<LivingEntity> getNearbyLivingEntities(final @NotNull Location loc, final double xzRadius, final double yRadius, final @Nullable Predicate<? super LivingEntity> predicate) {
+ public default Collection<LivingEntity> getNearbyLivingEntities(@NotNull Location loc, double xzRadius, double yRadius, @Nullable Predicate<LivingEntity> predicate) { + return this.getNearbyEntitiesByType(LivingEntity.class, loc, xzRadius, yRadius, xzRadius, predicate);
+ return getNearbyEntitiesByType(org.bukkit.entity.LivingEntity.class, loc, xzRadius, yRadius, xzRadius, predicate);
+ } + }
+ +
+ /** + /**
@ -94,9 +89,8 @@ index 609e4908ed21f69b9e813500e702bbe784bff00c..7a6caf93606203198369030a295f1edb
+ * @param predicate a predicate used to filter results + * @param predicate a predicate used to filter results
+ * @return the collection of living entities near location. This will always be a non-null collection. + * @return the collection of living entities near location. This will always be a non-null collection.
+ */ + */
+ @NotNull + default @NotNull Collection<LivingEntity> getNearbyLivingEntities(final @NotNull Location loc, final double xRadius, final double yRadius, final double zRadius, final @Nullable Predicate<? super LivingEntity> predicate) {
+ public default Collection<LivingEntity> getNearbyLivingEntities(@NotNull Location loc, double xRadius, double yRadius, double zRadius, @Nullable Predicate<LivingEntity> predicate) { + return this.getNearbyEntitiesByType(LivingEntity.class, loc, xRadius, yRadius, zRadius, predicate);
+ return getNearbyEntitiesByType(org.bukkit.entity.LivingEntity.class, loc, xRadius, yRadius, zRadius, predicate);
+ } + }
+ +
+ /** + /**
@ -105,9 +99,8 @@ index 609e4908ed21f69b9e813500e702bbe784bff00c..7a6caf93606203198369030a295f1edb
+ * @param radius X/Y/Z Radius + * @param radius X/Y/Z Radius
+ * @return the collection of living entities near location. This will always be a non-null collection. + * @return the collection of living entities near location. This will always be a non-null collection.
+ */ + */
+ @NotNull + default @NotNull Collection<Player> getNearbyPlayers(final @NotNull Location loc, final double radius) {
+ public default Collection<Player> getNearbyPlayers(@NotNull Location loc, double radius) { + return this.getNearbyEntitiesByType(Player.class, loc, radius, radius, radius);
+ return getNearbyEntitiesByType(org.bukkit.entity.Player.class, loc, radius, radius, radius);
+ } + }
+ +
+ /** + /**
@ -117,9 +110,8 @@ index 609e4908ed21f69b9e813500e702bbe784bff00c..7a6caf93606203198369030a295f1edb
+ * @param yRadius Y Radius + * @param yRadius Y Radius
+ * @return the collection of living entities near location. This will always be a non-null collection. + * @return the collection of living entities near location. This will always be a non-null collection.
+ */ + */
+ @NotNull + default @NotNull Collection<Player> getNearbyPlayers(final @NotNull Location loc, final double xzRadius, final double yRadius) {
+ public default Collection<Player> getNearbyPlayers(@NotNull Location loc, double xzRadius, double yRadius) { + return this.getNearbyEntitiesByType(Player.class, loc, xzRadius, yRadius, xzRadius);
+ return getNearbyEntitiesByType(org.bukkit.entity.Player.class, loc, xzRadius, yRadius, xzRadius);
+ } + }
+ +
+ /** + /**
@ -130,9 +122,8 @@ index 609e4908ed21f69b9e813500e702bbe784bff00c..7a6caf93606203198369030a295f1edb
+ * @param zRadius Z Radius + * @param zRadius Z Radius
+ * @return the collection of players near location. This will always be a non-null collection. + * @return the collection of players near location. This will always be a non-null collection.
+ */ + */
+ @NotNull + default @NotNull Collection<Player> getNearbyPlayers(final @NotNull Location loc, final double xRadius, final double yRadius, final double zRadius) {
+ public default Collection<Player> getNearbyPlayers(@NotNull Location loc, double xRadius, double yRadius, double zRadius) { + return this.getNearbyEntitiesByType(Player.class, loc, xRadius, yRadius, zRadius);
+ return getNearbyEntitiesByType(org.bukkit.entity.Player.class, loc, xRadius, yRadius, zRadius);
+ } + }
+ +
+ /** + /**
@ -142,9 +133,8 @@ index 609e4908ed21f69b9e813500e702bbe784bff00c..7a6caf93606203198369030a295f1edb
+ * @param predicate a predicate used to filter results + * @param predicate a predicate used to filter results
+ * @return the collection of players near location. This will always be a non-null collection. + * @return the collection of players near location. This will always be a non-null collection.
+ */ + */
+ @NotNull + default @NotNull Collection<Player> getNearbyPlayers(final @NotNull Location loc, final double radius, final @Nullable Predicate<? super Player> predicate) {
+ public default Collection<Player> getNearbyPlayers(@NotNull Location loc, double radius, @Nullable Predicate<Player> predicate) { + return this.getNearbyEntitiesByType(Player.class, loc, radius, radius, radius, predicate);
+ return getNearbyEntitiesByType(org.bukkit.entity.Player.class, loc, radius, radius, radius, predicate);
+ } + }
+ +
+ /** + /**
@ -155,9 +145,8 @@ index 609e4908ed21f69b9e813500e702bbe784bff00c..7a6caf93606203198369030a295f1edb
+ * @param predicate a predicate used to filter results + * @param predicate a predicate used to filter results
+ * @return the collection of players near location. This will always be a non-null collection. + * @return the collection of players near location. This will always be a non-null collection.
+ */ + */
+ @NotNull + default @NotNull Collection<Player> getNearbyPlayers(final @NotNull Location loc, final double xzRadius, final double yRadius, final @Nullable Predicate<? super Player> predicate) {
+ public default Collection<Player> getNearbyPlayers(@NotNull Location loc, double xzRadius, double yRadius, @Nullable Predicate<Player> predicate) { + return this.getNearbyEntitiesByType(Player.class, loc, xzRadius, yRadius, xzRadius, predicate);
+ return getNearbyEntitiesByType(org.bukkit.entity.Player.class, loc, xzRadius, yRadius, xzRadius, predicate);
+ } + }
+ +
+ /** + /**
@ -169,9 +158,8 @@ index 609e4908ed21f69b9e813500e702bbe784bff00c..7a6caf93606203198369030a295f1edb
+ * @param predicate a predicate used to filter results + * @param predicate a predicate used to filter results
+ * @return the collection of players near location. This will always be a non-null collection. + * @return the collection of players near location. This will always be a non-null collection.
+ */ + */
+ @NotNull + default @NotNull Collection<Player> getNearbyPlayers(final @NotNull Location loc, final double xRadius, final double yRadius, final double zRadius, final @Nullable Predicate<? super Player> predicate) {
+ public default Collection<Player> getNearbyPlayers(@NotNull Location loc, double xRadius, double yRadius, double zRadius, @Nullable Predicate<Player> predicate) { + return this.getNearbyEntitiesByType(Player.class, loc, xRadius, yRadius, zRadius, predicate);
+ return getNearbyEntitiesByType(org.bukkit.entity.Player.class, loc, xRadius, yRadius, zRadius, predicate);
+ } + }
+ +
+ /** + /**
@ -182,9 +170,8 @@ index 609e4908ed21f69b9e813500e702bbe784bff00c..7a6caf93606203198369030a295f1edb
+ * @param <T> the entity type + * @param <T> the entity type
+ * @return the collection of entities near location. This will always be a non-null collection. + * @return the collection of entities near location. This will always be a non-null collection.
+ */ + */
+ @NotNull + default @NotNull <T extends Entity> Collection<T> getNearbyEntitiesByType(final @Nullable Class<? extends T> clazz, final @NotNull Location loc, final double radius) {
+ public default <T extends Entity> Collection<T> getNearbyEntitiesByType(@Nullable Class<? extends T> clazz, @NotNull Location loc, double radius) { + return this.getNearbyEntitiesByType(clazz, loc, radius, radius, radius, null);
+ return getNearbyEntitiesByType(clazz, loc, radius, radius, radius, null);
+ } + }
+ +
+ /** + /**
@ -196,9 +183,8 @@ index 609e4908ed21f69b9e813500e702bbe784bff00c..7a6caf93606203198369030a295f1edb
+ * @param <T> the entity type + * @param <T> the entity type
+ * @return the collection of entities near location. This will always be a non-null collection. + * @return the collection of entities near location. This will always be a non-null collection.
+ */ + */
+ @NotNull + default @NotNull <T extends Entity> Collection<T> getNearbyEntitiesByType(final @Nullable Class<? extends T> clazz, final @NotNull Location loc, final double xzRadius, final double yRadius) {
+ public default <T extends Entity> Collection<T> getNearbyEntitiesByType(@Nullable Class<? extends T> clazz, @NotNull Location loc, double xzRadius, double yRadius) { + return this.getNearbyEntitiesByType(clazz, loc, xzRadius, yRadius, xzRadius, null);
+ return getNearbyEntitiesByType(clazz, loc, xzRadius, yRadius, xzRadius, null);
+ } + }
+ +
+ /** + /**
@ -211,9 +197,8 @@ index 609e4908ed21f69b9e813500e702bbe784bff00c..7a6caf93606203198369030a295f1edb
+ * @param <T> the entity type + * @param <T> the entity type
+ * @return the collection of entities near location. This will always be a non-null collection. + * @return the collection of entities near location. This will always be a non-null collection.
+ */ + */
+ @NotNull + default @NotNull <T extends Entity> Collection<T> getNearbyEntitiesByType(final @Nullable Class<? extends T> clazz, final @NotNull Location loc, final double xRadius, final double yRadius, final double zRadius) {
+ public default <T extends Entity> Collection<T> getNearbyEntitiesByType(@Nullable Class<? extends T> clazz, @NotNull Location loc, double xRadius, double yRadius, double zRadius) { + return this.getNearbyEntitiesByType(clazz, loc, xRadius, yRadius, zRadius, null);
+ return getNearbyEntitiesByType(clazz, loc, xRadius, yRadius, zRadius, null);
+ } + }
+ +
+ /** + /**
@ -225,9 +210,8 @@ index 609e4908ed21f69b9e813500e702bbe784bff00c..7a6caf93606203198369030a295f1edb
+ * @param <T> the entity type + * @param <T> the entity type
+ * @return the collection of entities near location. This will always be a non-null collection. + * @return the collection of entities near location. This will always be a non-null collection.
+ */ + */
+ @NotNull + default @NotNull <T extends Entity> Collection<T> getNearbyEntitiesByType(final @Nullable Class<? extends T> clazz, final @NotNull Location loc, final double radius, final @Nullable Predicate<? super T> predicate) {
+ public default <T extends Entity> Collection<T> getNearbyEntitiesByType(@Nullable Class<? extends T> clazz, @NotNull Location loc, double radius, @Nullable Predicate<T> predicate) { + return this.getNearbyEntitiesByType(clazz, loc, radius, radius, radius, predicate);
+ return getNearbyEntitiesByType(clazz, loc, radius, radius, radius, predicate);
+ } + }
+ +
+ /** + /**
@ -240,9 +224,8 @@ index 609e4908ed21f69b9e813500e702bbe784bff00c..7a6caf93606203198369030a295f1edb
+ * @param <T> the entity type + * @param <T> the entity type
+ * @return the collection of entities near location. This will always be a non-null collection. + * @return the collection of entities near location. This will always be a non-null collection.
+ */ + */
+ @NotNull + default @NotNull <T extends Entity> Collection<T> getNearbyEntitiesByType(final @Nullable Class<? extends T> clazz, final @NotNull Location loc, final double xzRadius, final double yRadius, final @Nullable Predicate<? super T> predicate) {
+ public default <T extends Entity> Collection<T> getNearbyEntitiesByType(@Nullable Class<? extends T> clazz, @NotNull Location loc, double xzRadius, double yRadius, @Nullable Predicate<T> predicate) { + return this.getNearbyEntitiesByType(clazz, loc, xzRadius, yRadius, xzRadius, predicate);
+ return getNearbyEntitiesByType(clazz, loc, xzRadius, yRadius, xzRadius, predicate);
+ } + }
+ +
+ /** + /**
@ -256,13 +239,12 @@ index 609e4908ed21f69b9e813500e702bbe784bff00c..7a6caf93606203198369030a295f1edb
+ * @param <T> the entity type + * @param <T> the entity type
+ * @return the collection of entities near location. This will always be a non-null collection. + * @return the collection of entities near location. This will always be a non-null collection.
+ */ + */
+ @NotNull + default <T extends Entity> @NotNull Collection<T> getNearbyEntitiesByType(@Nullable Class<? extends Entity> clazz, final @NotNull Location loc, final double xRadius, final double yRadius, final double zRadius, final @Nullable Predicate<? super T> predicate) {
+ public default <T extends Entity> Collection<T> getNearbyEntitiesByType(@Nullable Class<? extends Entity> clazz, @NotNull Location loc, double xRadius, double yRadius, double zRadius, @Nullable Predicate<T> predicate) {
+ if (clazz == null) { + if (clazz == null) {
+ clazz = Entity.class; + clazz = Entity.class;
+ } + }
+ List<T> nearby = new ArrayList<>(); + final List<T> nearby = new ArrayList<>();
+ for (Entity bukkitEntity : getNearbyEntities(loc, xRadius, yRadius, zRadius)) { + for (final Entity bukkitEntity : this.getNearbyEntities(loc, xRadius, yRadius, zRadius)) {
+ //noinspection unchecked + //noinspection unchecked
+ if (clazz.isAssignableFrom(bukkitEntity.getClass()) && (predicate == null || predicate.test((T) bukkitEntity))) { + if (clazz.isAssignableFrom(bukkitEntity.getClass()) && (predicate == null || predicate.test((T) bukkitEntity))) {
+ //noinspection unchecked + //noinspection unchecked
@ -271,7 +253,7 @@ index 609e4908ed21f69b9e813500e702bbe784bff00c..7a6caf93606203198369030a295f1edb
+ } + }
+ return nearby; + return nearby;
+ } + }
+ // Paper end + // Paper end - additional getNearbyEntities API
+ +
/** /**
* Get a list of all players in this World * Get a list of all players in this World

Datei anzeigen

@ -523,10 +523,10 @@ index e2adb9901cc92ede9d44ca9939c6a54d4762eb4b..81bd12c8addcee754c71e5e030c729c7
* Options which can be applied to redstone dust particles - a particle * Options which can be applied to redstone dust particles - a particle
* color and size. * color and size.
diff --git a/src/main/java/org/bukkit/World.java b/src/main/java/org/bukkit/World.java diff --git a/src/main/java/org/bukkit/World.java b/src/main/java/org/bukkit/World.java
index c7e6e1ef1191ffde924600ed3beb46ffe129c15f..d02b6743e4401004e75501e99b717b58e5acc5ae 100644 index 58a15d8fd57d55848b37bfc8fffa101692efce87..93c46d40efd73293d84c7eaadf4e360cc3706e2a 100644
--- a/src/main/java/org/bukkit/World.java --- a/src/main/java/org/bukkit/World.java
+++ b/src/main/java/org/bukkit/World.java +++ b/src/main/java/org/bukkit/World.java
@@ -2859,7 +2859,57 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient @@ -2841,7 +2841,57 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient
* @param data the data to use for the particle or null, * @param data the data to use for the particle or null,
* the type of this depends on {@link Particle#getDataType()} * the type of this depends on {@link Particle#getDataType()}
*/ */

Datei anzeigen

@ -6,15 +6,15 @@ Subject: [PATCH] Location.toBlockLocation/toCenterLocation()
Convert location objects to their block coordinates, or the center of the block Convert location objects to their block coordinates, or the center of the block
diff --git a/src/main/java/org/bukkit/Location.java b/src/main/java/org/bukkit/Location.java diff --git a/src/main/java/org/bukkit/Location.java b/src/main/java/org/bukkit/Location.java
index e71beb48f2e35d97b9d5bf8dbf5ddbc0673565fe..5a219f132747eb62204e98de4cb850748a43c9b4 100644 index 251d26e6870490abd3e915c5e7c06ce1075a24ab..24a872dfc8cf1f4a567b6ebd5a5e742593616ede 100644
--- a/src/main/java/org/bukkit/Location.java --- a/src/main/java/org/bukkit/Location.java
+++ b/src/main/java/org/bukkit/Location.java +++ b/src/main/java/org/bukkit/Location.java
@@ -534,6 +534,31 @@ public class Location implements Cloneable, ConfigurationSerializable, io.paperm @@ -534,6 +534,32 @@ public class Location implements Cloneable, ConfigurationSerializable, io.paperm
} }
public boolean isChunkLoaded() { return this.getWorld().isChunkLoaded(locToBlock(x) >> 4, locToBlock(z) >> 4); } // Paper public boolean isChunkLoaded() { return this.getWorld().isChunkLoaded(locToBlock(x) >> 4, locToBlock(z) >> 4); } // Paper
+ +
+ // Paper start + // Paper start - expand Location API
+ /** + /**
+ * @return A new location where X/Y/Z are on the Block location (integer value of X/Y/Z) + * @return A new location where X/Y/Z are on the Block location (integer value of X/Y/Z)
+ */ + */
@ -37,7 +37,8 @@ index e71beb48f2e35d97b9d5bf8dbf5ddbc0673565fe..5a219f132747eb62204e98de4cb85074
+ centerLoc.setZ(getBlockZ() + 0.5); + centerLoc.setZ(getBlockZ() + 0.5);
+ return centerLoc; + return centerLoc;
+ } + }
+ // Paper end + // Paper end - expand Location API
+
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
if (obj == null) { if (obj == null) {

Datei anzeigen

@ -5,7 +5,7 @@ Subject: [PATCH] Add "getNearbyXXX" methods to Location
diff --git a/src/main/java/org/bukkit/Location.java b/src/main/java/org/bukkit/Location.java diff --git a/src/main/java/org/bukkit/Location.java b/src/main/java/org/bukkit/Location.java
index 5a219f132747eb62204e98de4cb850748a43c9b4..6693e3d8dc2519facb12db981a6b6325faa095bf 100644 index 24a872dfc8cf1f4a567b6ebd5a5e742593616ede..3161eae2fa5f03b7d3a5e9945ab659c15cf568c6 100644
--- a/src/main/java/org/bukkit/Location.java --- a/src/main/java/org/bukkit/Location.java
+++ b/src/main/java/org/bukkit/Location.java +++ b/src/main/java/org/bukkit/Location.java
@@ -12,6 +12,15 @@ import org.bukkit.util.Vector; @@ -12,6 +12,15 @@ import org.bukkit.util.Vector;
@ -24,24 +24,23 @@ index 5a219f132747eb62204e98de4cb850748a43c9b4..6693e3d8dc2519facb12db981a6b6325
/** /**
* Represents a 3-dimensional position in a world. * Represents a 3-dimensional position in a world.
* <br> * <br>
@@ -558,6 +567,248 @@ public class Location implements Cloneable, ConfigurationSerializable, io.paperm @@ -560,6 +569,231 @@ public class Location implements Cloneable, ConfigurationSerializable, io.paperm
centerLoc.setZ(getBlockZ() + 0.5);
return centerLoc;
} }
+ // Paper end - expand Location API
+ // Paper start - additional getNearbyEntities API
+ /** + /**
+ * Returns a list of entities within a bounding box centered around a Location. + * Returns a list of entities within a bounding box centered around a Location.
+ * + * <p>
+ * Some implementations may impose artificial restrictions on the size of the search bounding box. + * Some implementations may impose artificial restrictions on the size of the search bounding box.
+ * + *
+ * @param x 1/2 the size of the box along x axis + * @param x 1/2 the size of the box along the x-axis
+ * @param y 1/2 the size of the box along y axis + * @param y 1/2 the size of the box along the y-axis
+ * @param z 1/2 the size of the box along z axis + * @param z 1/2 the size of the box along the z-axis
+ * @return the collection of entities near location. This will always be a non-null collection. + * @return the collection of entities near location. This will always be a non-null collection.
+ */ + */
+ @NotNull + public @NotNull Collection<Entity> getNearbyEntities(final double x, final double y, final double z) {
+ public Collection<Entity> getNearbyEntities(double x, double y, double z) { + final World world = this.getWorld();
+ World world = this.getWorld();
+ if (world == null) { + if (world == null) {
+ throw new IllegalArgumentException("Location has no world"); + throw new IllegalArgumentException("Location has no world");
+ } + }
@ -53,9 +52,8 @@ index 5a219f132747eb62204e98de4cb850748a43c9b4..6693e3d8dc2519facb12db981a6b6325
+ * @param radius X Radius + * @param radius X Radius
+ * @return the collection of entities near location. This will always be a non-null collection. + * @return the collection of entities near location. This will always be a non-null collection.
+ */ + */
+ @NotNull + public @NotNull Collection<LivingEntity> getNearbyLivingEntities(final double radius) {
+ public Collection<LivingEntity> getNearbyLivingEntities(double radius) { + return this.getNearbyEntitiesByType(LivingEntity.class, radius, radius, radius);
+ return getNearbyEntitiesByType(org.bukkit.entity.LivingEntity.class, radius, radius, radius);
+ } + }
+ +
+ /** + /**
@ -64,9 +62,8 @@ index 5a219f132747eb62204e98de4cb850748a43c9b4..6693e3d8dc2519facb12db981a6b6325
+ * @param yRadius Y Radius + * @param yRadius Y Radius
+ * @return the collection of living entities near location. This will always be a non-null collection. + * @return the collection of living entities near location. This will always be a non-null collection.
+ */ + */
+ @NotNull + public @NotNull Collection<LivingEntity> getNearbyLivingEntities(final double xzRadius, final double yRadius) {
+ public Collection<LivingEntity> getNearbyLivingEntities(double xzRadius, double yRadius) { + return this.getNearbyEntitiesByType(LivingEntity.class, xzRadius, yRadius, xzRadius);
+ return getNearbyEntitiesByType(org.bukkit.entity.LivingEntity.class, xzRadius, yRadius, xzRadius);
+ } + }
+ +
+ /** + /**
@ -76,9 +73,8 @@ index 5a219f132747eb62204e98de4cb850748a43c9b4..6693e3d8dc2519facb12db981a6b6325
+ * @param zRadius Z radius + * @param zRadius Z radius
+ * @return the collection of living entities near location. This will always be a non-null collection. + * @return the collection of living entities near location. This will always be a non-null collection.
+ */ + */
+ @NotNull + public @NotNull Collection<LivingEntity> getNearbyLivingEntities(final double xRadius, final double yRadius, final double zRadius) {
+ public Collection<LivingEntity> getNearbyLivingEntities(double xRadius, double yRadius, double zRadius) { + return this.getNearbyEntitiesByType(LivingEntity.class, xRadius, yRadius, zRadius);
+ return getNearbyEntitiesByType(org.bukkit.entity.LivingEntity.class, xRadius, yRadius, zRadius);
+ } + }
+ +
+ /** + /**
@ -87,9 +83,8 @@ index 5a219f132747eb62204e98de4cb850748a43c9b4..6693e3d8dc2519facb12db981a6b6325
+ * @param predicate a predicate used to filter results + * @param predicate a predicate used to filter results
+ * @return the collection of living entities near location. This will always be a non-null collection. + * @return the collection of living entities near location. This will always be a non-null collection.
+ */ + */
+ @NotNull + public @NotNull Collection<LivingEntity> getNearbyLivingEntities(final double radius, final @Nullable Predicate<? super LivingEntity> predicate) {
+ public Collection<LivingEntity> getNearbyLivingEntities(double radius, @Nullable Predicate<LivingEntity> predicate) { + return this.getNearbyEntitiesByType(LivingEntity.class, radius, radius, radius, predicate);
+ return getNearbyEntitiesByType(org.bukkit.entity.LivingEntity.class, radius, radius, radius, predicate);
+ } + }
+ +
+ /** + /**
@ -99,9 +94,8 @@ index 5a219f132747eb62204e98de4cb850748a43c9b4..6693e3d8dc2519facb12db981a6b6325
+ * @param predicate a predicate used to filter results + * @param predicate a predicate used to filter results
+ * @return the collection of living entities near location. This will always be a non-null collection. + * @return the collection of living entities near location. This will always be a non-null collection.
+ */ + */
+ @NotNull + public @NotNull Collection<LivingEntity> getNearbyLivingEntities(final double xzRadius, final double yRadius, final @Nullable Predicate<? super LivingEntity> predicate) {
+ public Collection<LivingEntity> getNearbyLivingEntities(double xzRadius, double yRadius, @Nullable Predicate<LivingEntity> predicate) { + return this.getNearbyEntitiesByType(LivingEntity.class, xzRadius, yRadius, xzRadius, predicate);
+ return getNearbyEntitiesByType(org.bukkit.entity.LivingEntity.class, xzRadius, yRadius, xzRadius, predicate);
+ } + }
+ +
+ /** + /**
@ -112,9 +106,8 @@ index 5a219f132747eb62204e98de4cb850748a43c9b4..6693e3d8dc2519facb12db981a6b6325
+ * @param predicate a predicate used to filter results + * @param predicate a predicate used to filter results
+ * @return the collection of living entities near location. This will always be a non-null collection. + * @return the collection of living entities near location. This will always be a non-null collection.
+ */ + */
+ @NotNull + public @NotNull Collection<LivingEntity> getNearbyLivingEntities(final double xRadius, final double yRadius, final double zRadius, final @Nullable Predicate<? super LivingEntity> predicate) {
+ public Collection<LivingEntity> getNearbyLivingEntities(double xRadius, double yRadius, double zRadius, @Nullable Predicate<LivingEntity> predicate) { + return this.getNearbyEntitiesByType(LivingEntity.class, xRadius, yRadius, zRadius, predicate);
+ return getNearbyEntitiesByType(org.bukkit.entity.LivingEntity.class, xRadius, yRadius, zRadius, predicate);
+ } + }
+ +
+ /** + /**
@ -122,9 +115,8 @@ index 5a219f132747eb62204e98de4cb850748a43c9b4..6693e3d8dc2519facb12db981a6b6325
+ * @param radius X/Y/Z Radius + * @param radius X/Y/Z Radius
+ * @return the collection of players near location. This will always be a non-null collection. + * @return the collection of players near location. This will always be a non-null collection.
+ */ + */
+ @NotNull + public @NotNull Collection<Player> getNearbyPlayers(final double radius) {
+ public Collection<Player> getNearbyPlayers(double radius) { + return this.getNearbyEntitiesByType(Player.class, radius, radius, radius);
+ return getNearbyEntitiesByType(org.bukkit.entity.Player.class, radius, radius, radius);
+ } + }
+ +
+ /** + /**
@ -133,9 +125,8 @@ index 5a219f132747eb62204e98de4cb850748a43c9b4..6693e3d8dc2519facb12db981a6b6325
+ * @param yRadius Y Radius + * @param yRadius Y Radius
+ * @return the collection of players near location. This will always be a non-null collection. + * @return the collection of players near location. This will always be a non-null collection.
+ */ + */
+ @NotNull + public @NotNull Collection<Player> getNearbyPlayers(final double xzRadius, final double yRadius) {
+ public Collection<Player> getNearbyPlayers(double xzRadius, double yRadius) { + return this.getNearbyEntitiesByType(Player.class, xzRadius, yRadius, xzRadius);
+ return getNearbyEntitiesByType(org.bukkit.entity.Player.class, xzRadius, yRadius, xzRadius);
+ } + }
+ +
+ /** + /**
@ -145,9 +136,8 @@ index 5a219f132747eb62204e98de4cb850748a43c9b4..6693e3d8dc2519facb12db981a6b6325
+ * @param zRadius Z Radius + * @param zRadius Z Radius
+ * @return the collection of players near location. This will always be a non-null collection. + * @return the collection of players near location. This will always be a non-null collection.
+ */ + */
+ @NotNull + public @NotNull Collection<Player> getNearbyPlayers(final double xRadius, final double yRadius, final double zRadius) {
+ public Collection<Player> getNearbyPlayers(double xRadius, double yRadius, double zRadius) { + return this.getNearbyEntitiesByType(Player.class, xRadius, yRadius, zRadius);
+ return getNearbyEntitiesByType(org.bukkit.entity.Player.class, xRadius, yRadius, zRadius);
+ } + }
+ +
+ /** + /**
@ -156,9 +146,8 @@ index 5a219f132747eb62204e98de4cb850748a43c9b4..6693e3d8dc2519facb12db981a6b6325
+ * @param predicate a predicate used to filter results + * @param predicate a predicate used to filter results
+ * @return the collection of players near location. This will always be a non-null collection. + * @return the collection of players near location. This will always be a non-null collection.
+ */ + */
+ @NotNull + public @NotNull Collection<Player> getNearbyPlayers(final double radius, final @Nullable Predicate<? super Player> predicate) {
+ public Collection<Player> getNearbyPlayers(double radius, @Nullable Predicate<Player> predicate) { + return this.getNearbyEntitiesByType(Player.class, radius, radius, radius, predicate);
+ return getNearbyEntitiesByType(org.bukkit.entity.Player.class, radius, radius, radius, predicate);
+ } + }
+ +
+ /** + /**
@ -168,9 +157,8 @@ index 5a219f132747eb62204e98de4cb850748a43c9b4..6693e3d8dc2519facb12db981a6b6325
+ * @param predicate a predicate used to filter results + * @param predicate a predicate used to filter results
+ * @return the collection of players near location. This will always be a non-null collection. + * @return the collection of players near location. This will always be a non-null collection.
+ */ + */
+ @NotNull + public @NotNull Collection<Player> getNearbyPlayers(final double xzRadius, final double yRadius, final @Nullable Predicate<? super Player> predicate) {
+ public Collection<Player> getNearbyPlayers(double xzRadius, double yRadius, @Nullable Predicate<Player> predicate) { + return this.getNearbyEntitiesByType(Player.class, xzRadius, yRadius, xzRadius, predicate);
+ return getNearbyEntitiesByType(org.bukkit.entity.Player.class, xzRadius, yRadius, xzRadius, predicate);
+ } + }
+ +
+ /** + /**
@ -181,9 +169,8 @@ index 5a219f132747eb62204e98de4cb850748a43c9b4..6693e3d8dc2519facb12db981a6b6325
+ * @param predicate a predicate used to filter results + * @param predicate a predicate used to filter results
+ * @return the collection of players near location. This will always be a non-null collection. + * @return the collection of players near location. This will always be a non-null collection.
+ */ + */
+ @NotNull + public @NotNull Collection<Player> getNearbyPlayers(final double xRadius, final double yRadius, final double zRadius, final @Nullable Predicate<? super Player> predicate) {
+ public Collection<Player> getNearbyPlayers(double xRadius, double yRadius, double zRadius, @Nullable Predicate<Player> predicate) { + return this.getNearbyEntitiesByType(Player.class, xRadius, yRadius, zRadius, predicate);
+ return getNearbyEntitiesByType(org.bukkit.entity.Player.class, xRadius, yRadius, zRadius, predicate);
+ } + }
+ +
+ /** + /**
@ -193,9 +180,8 @@ index 5a219f132747eb62204e98de4cb850748a43c9b4..6693e3d8dc2519facb12db981a6b6325
+ * @param <T> the entity type + * @param <T> the entity type
+ * @return the collection of entities of type clazz near location. This will always be a non-null collection. + * @return the collection of entities of type clazz near location. This will always be a non-null collection.
+ */ + */
+ @NotNull + public @NotNull <T extends Entity> Collection<T> getNearbyEntitiesByType(final @Nullable Class<? extends T> clazz, final double radius) {
+ public <T extends Entity> Collection<T> getNearbyEntitiesByType(@Nullable Class<? extends T> clazz, double radius) { + return this.getNearbyEntitiesByType(clazz, radius, radius, radius, null);
+ return getNearbyEntitiesByType(clazz, radius, radius, radius, null);
+ } + }
+ +
+ /** + /**
@ -206,9 +192,8 @@ index 5a219f132747eb62204e98de4cb850748a43c9b4..6693e3d8dc2519facb12db981a6b6325
+ * @param <T> the entity type + * @param <T> the entity type
+ * @return the collection of entities near location. This will always be a non-null collection. + * @return the collection of entities near location. This will always be a non-null collection.
+ */ + */
+ @NotNull + public @NotNull <T extends Entity> Collection<T> getNearbyEntitiesByType(final @Nullable Class<? extends T> clazz, final double xzRadius, final double yRadius) {
+ public <T extends Entity> Collection<T> getNearbyEntitiesByType(@Nullable Class<? extends T> clazz, double xzRadius, double yRadius) { + return this.getNearbyEntitiesByType(clazz, xzRadius, yRadius, xzRadius, null);
+ return getNearbyEntitiesByType(clazz, xzRadius, yRadius, xzRadius, null);
+ } + }
+ +
+ /** + /**
@ -220,9 +205,8 @@ index 5a219f132747eb62204e98de4cb850748a43c9b4..6693e3d8dc2519facb12db981a6b6325
+ * @param <T> the entity type + * @param <T> the entity type
+ * @return the collection of entities near location. This will always be a non-null collection. + * @return the collection of entities near location. This will always be a non-null collection.
+ */ + */
+ @NotNull + public @NotNull <T extends Entity> Collection<T> getNearbyEntitiesByType(final @Nullable Class<? extends T> clazz, final double xRadius, final double yRadius, final double zRadius) {
+ public <T extends Entity> Collection<T> getNearbyEntitiesByType(@Nullable Class<? extends T> clazz, double xRadius, double yRadius, double zRadius) { + return this.getNearbyEntitiesByType(clazz, xRadius, yRadius, zRadius, null);
+ return getNearbyEntitiesByType(clazz, xRadius, yRadius, zRadius, null);
+ } + }
+ +
+ /** + /**
@ -233,9 +217,8 @@ index 5a219f132747eb62204e98de4cb850748a43c9b4..6693e3d8dc2519facb12db981a6b6325
+ * @param <T> the entity type + * @param <T> the entity type
+ * @return the collection of entities near location. This will always be a non-null collection. + * @return the collection of entities near location. This will always be a non-null collection.
+ */ + */
+ @NotNull + public @NotNull <T extends Entity> Collection<T> getNearbyEntitiesByType(final @Nullable Class<? extends T> clazz, final double radius, final @Nullable Predicate<? super T> predicate) {
+ public <T extends Entity> Collection<T> getNearbyEntitiesByType(@Nullable Class<? extends T> clazz, double radius, @Nullable Predicate<T> predicate) { + return this.getNearbyEntitiesByType(clazz, radius, radius, radius, predicate);
+ return getNearbyEntitiesByType(clazz, radius, radius, radius, predicate);
+ } + }
+ +
+ /** + /**
@ -247,9 +230,8 @@ index 5a219f132747eb62204e98de4cb850748a43c9b4..6693e3d8dc2519facb12db981a6b6325
+ * @param <T> the entity type + * @param <T> the entity type
+ * @return the collection of entities near location. This will always be a non-null collection. + * @return the collection of entities near location. This will always be a non-null collection.
+ */ + */
+ @NotNull + public @NotNull <T extends Entity> Collection<T> getNearbyEntitiesByType(final @Nullable Class<? extends T> clazz, final double xzRadius, final double yRadius, final @Nullable Predicate<? super T> predicate) {
+ public <T extends Entity> Collection<T> getNearbyEntitiesByType(@Nullable Class<? extends T> clazz, double xzRadius, double yRadius, @Nullable Predicate<T> predicate) { + return this.getNearbyEntitiesByType(clazz, xzRadius, yRadius, xzRadius, predicate);
+ return getNearbyEntitiesByType(clazz, xzRadius, yRadius, xzRadius, predicate);
+ } + }
+ +
+ /** + /**
@ -262,14 +244,15 @@ index 5a219f132747eb62204e98de4cb850748a43c9b4..6693e3d8dc2519facb12db981a6b6325
+ * @param <T> the entity type + * @param <T> the entity type
+ * @return the collection of entities near location. This will always be a non-null collection. + * @return the collection of entities near location. This will always be a non-null collection.
+ */ + */
+ @NotNull + public @NotNull <T extends Entity> Collection<T> getNearbyEntitiesByType(final @Nullable Class<? extends Entity> clazz, final double xRadius, final double yRadius, final double zRadius, final @Nullable Predicate<? super T> predicate) {
+ public <T extends Entity> Collection<T> getNearbyEntitiesByType(@Nullable Class<? extends Entity> clazz, double xRadius, double yRadius, double zRadius, @Nullable Predicate<T> predicate) { + final World world = this.getWorld();
+ World world = this.getWorld();
+ if (world == null) { + if (world == null) {
+ throw new IllegalArgumentException("Location has no world"); + throw new IllegalArgumentException("Location has no world");
+ } + }
+ return world.getNearbyEntitiesByType(clazz, this, xRadius, yRadius, zRadius, predicate); + return world.getNearbyEntitiesByType(clazz, this, xRadius, yRadius, zRadius, predicate);
+ } + }
// Paper end + // Paper end - additional getNearbyEntities API
+
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
if (obj == null) {

Datei anzeigen

@ -6,7 +6,7 @@ Subject: [PATCH] Expand Explosions API
Add Entity as a Source capability, and add more API choices, and on Location. Add Entity as a Source capability, and add more API choices, and on Location.
diff --git a/src/main/java/org/bukkit/Location.java b/src/main/java/org/bukkit/Location.java diff --git a/src/main/java/org/bukkit/Location.java b/src/main/java/org/bukkit/Location.java
index 556e4524c30f8c7faeb591e272546c78090170fc..e8067e91dea3c5f8654c65ea5ec4d3db36d85a6c 100644 index 3161eae2fa5f03b7d3a5e9945ab659c15cf568c6..af737017ee397f80c44ee02c6cc60cefa07f59c1 100644
--- a/src/main/java/org/bukkit/Location.java --- a/src/main/java/org/bukkit/Location.java
+++ b/src/main/java/org/bukkit/Location.java +++ b/src/main/java/org/bukkit/Location.java
@@ -7,6 +7,7 @@ import java.util.HashMap; @@ -7,6 +7,7 @@ import java.util.HashMap;
@ -17,14 +17,14 @@ index 556e4524c30f8c7faeb591e272546c78090170fc..e8067e91dea3c5f8654c65ea5ec4d3db
import org.bukkit.util.NumberConversions; import org.bukkit.util.NumberConversions;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@@ -568,6 +569,89 @@ public class Location implements Cloneable, ConfigurationSerializable, io.paperm @@ -569,6 +570,89 @@ public class Location implements Cloneable, ConfigurationSerializable, io.paperm
return centerLoc;
} }
// Paper end - expand Location API
+ // Paper start - Expand Explosions API + // Paper start - Expand Explosions API
+ /** + /**
+ * Creates explosion at this location with given power + * Creates explosion at this location with given power
+ * + * <p>
+ * Will break blocks and ignite blocks on fire. + * Will break blocks and ignite blocks on fire.
+ * + *
+ * @param power The power of explosion, where 4F is TNT + * @param power The power of explosion, where 4F is TNT
@ -37,11 +37,11 @@ index 556e4524c30f8c7faeb591e272546c78090170fc..e8067e91dea3c5f8654c65ea5ec4d3db
+ /** + /**
+ * Creates explosion at this location with given power and optionally + * Creates explosion at this location with given power and optionally
+ * setting blocks on fire. + * setting blocks on fire.
+ * + * <p>
+ * Will break blocks. + * Will break blocks.
+ * + *
+ * @param power The power of explosion, where 4F is TNT + * @param power The power of explosion, where 4F is TNT
+ * @param setFire Whether or not to set blocks on fire + * @param setFire Whether to set blocks on fire
+ * @return false if explosion was canceled, otherwise true + * @return false if explosion was canceled, otherwise true
+ */ + */
+ public boolean createExplosion(float power, boolean setFire) { + public boolean createExplosion(float power, boolean setFire) {
@ -53,8 +53,8 @@ index 556e4524c30f8c7faeb591e272546c78090170fc..e8067e91dea3c5f8654c65ea5ec4d3db
+ * setting blocks on fire. + * setting blocks on fire.
+ * + *
+ * @param power The power of explosion, where 4F is TNT + * @param power The power of explosion, where 4F is TNT
+ * @param setFire Whether or not to set blocks on fire + * @param setFire Whether to set blocks on fire
+ * @param breakBlocks Whether or not to have blocks be destroyed + * @param breakBlocks Whether to have blocks be destroyed
+ * @return false if explosion was canceled, otherwise true + * @return false if explosion was canceled, otherwise true
+ */ + */
+ public boolean createExplosion(float power, boolean setFire, boolean breakBlocks) { + public boolean createExplosion(float power, boolean setFire, boolean breakBlocks) {
@ -63,7 +63,7 @@ index 556e4524c30f8c7faeb591e272546c78090170fc..e8067e91dea3c5f8654c65ea5ec4d3db
+ +
+ /** + /**
+ * Creates explosion at this location with given power, with the specified entity as the source. + * Creates explosion at this location with given power, with the specified entity as the source.
+ * + * <p>
+ * Will break blocks and ignite blocks on fire. + * Will break blocks and ignite blocks on fire.
+ * + *
+ * @param source The source entity of the explosion + * @param source The source entity of the explosion
@ -77,12 +77,12 @@ index 556e4524c30f8c7faeb591e272546c78090170fc..e8067e91dea3c5f8654c65ea5ec4d3db
+ /** + /**
+ * Creates explosion at this location with given power and optionally + * Creates explosion at this location with given power and optionally
+ * setting blocks on fire, with the specified entity as the source. + * setting blocks on fire, with the specified entity as the source.
+ * + * <p>
+ * Will break blocks. + * Will break blocks.
+ * + *
+ * @param source The source entity of the explosion + * @param source The source entity of the explosion
+ * @param power The power of explosion, where 4F is TNT + * @param power The power of explosion, where 4F is TNT
+ * @param setFire Whether or not to set blocks on fire + * @param setFire Whether to set blocks on fire
+ * @return false if explosion was canceled, otherwise true + * @return false if explosion was canceled, otherwise true
+ */ + */
+ public boolean createExplosion(@Nullable Entity source, float power, boolean setFire) { + public boolean createExplosion(@Nullable Entity source, float power, boolean setFire) {
@ -95,8 +95,8 @@ index 556e4524c30f8c7faeb591e272546c78090170fc..e8067e91dea3c5f8654c65ea5ec4d3db
+ * + *
+ * @param source The source entity of the explosion + * @param source The source entity of the explosion
+ * @param power The power of explosion, where 4F is TNT + * @param power The power of explosion, where 4F is TNT
+ * @param setFire Whether or not to set blocks on fire + * @param setFire Whether to set blocks on fire
+ * @param breakBlocks Whether or not to have blocks be destroyed + * @param breakBlocks Whether to have blocks be destroyed
+ * @return false if explosion was canceled, otherwise true + * @return false if explosion was canceled, otherwise true
+ */ + */
+ public boolean createExplosion(@Nullable Entity source, float power, boolean setFire, boolean breakBlocks) { + public boolean createExplosion(@Nullable Entity source, float power, boolean setFire, boolean breakBlocks) {
@ -104,14 +104,14 @@ index 556e4524c30f8c7faeb591e272546c78090170fc..e8067e91dea3c5f8654c65ea5ec4d3db
+ } + }
+ // Paper end - Expand Explosions API + // Paper end - Expand Explosions API
+ +
// Paper start - additional getNearbyEntities API
/** /**
* Returns a list of entities within a bounding box centered around a Location. * Returns a list of entities within a bounding box centered around a Location.
*
diff --git a/src/main/java/org/bukkit/World.java b/src/main/java/org/bukkit/World.java diff --git a/src/main/java/org/bukkit/World.java b/src/main/java/org/bukkit/World.java
index d02b6743e4401004e75501e99b717b58e5acc5ae..de896af6006f791625bb388b105983fb64489071 100644 index 93c46d40efd73293d84c7eaadf4e360cc3706e2a..cd946f2de8a09fdb6ff9b256ca7eba64e6ed9aab 100644
--- a/src/main/java/org/bukkit/World.java --- a/src/main/java/org/bukkit/World.java
+++ b/src/main/java/org/bukkit/World.java +++ b/src/main/java/org/bukkit/World.java
@@ -1398,6 +1398,88 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient @@ -1380,6 +1380,88 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient
*/ */
public boolean createExplosion(@NotNull Location loc, float power, boolean setFire); public boolean createExplosion(@NotNull Location loc, float power, boolean setFire);

Datei anzeigen

@ -5,10 +5,10 @@ Subject: [PATCH] Add World.getEntity(UUID) API
diff --git a/src/main/java/org/bukkit/World.java b/src/main/java/org/bukkit/World.java diff --git a/src/main/java/org/bukkit/World.java b/src/main/java/org/bukkit/World.java
index 266ed71b79d32f9b812be322563c247051ccd9d0..ffe6c8be86fc93d39e256a89e5016e3025afbe5c 100644 index c0e45f4c964ae262a894d92cff8f0750660cd41d..17b9e695a3f2eab94714b2124c657ee4d8b5ef51 100644
--- a/src/main/java/org/bukkit/World.java --- a/src/main/java/org/bukkit/World.java
+++ b/src/main/java/org/bukkit/World.java +++ b/src/main/java/org/bukkit/World.java
@@ -912,6 +912,17 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient @@ -894,6 +894,17 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient
@NotNull @NotNull
public Collection<Entity> getNearbyEntities(@NotNull Location location, double x, double y, double z); public Collection<Entity> getNearbyEntities(@NotNull Location location, double x, double y, double z);

Datei anzeigen

@ -6,18 +6,20 @@ Subject: [PATCH] Expand Location Manipulation API
Adds set(x, y, z), add(base, x, y, z), subtract(base, x, y, z); Adds set(x, y, z), add(base, x, y, z), subtract(base, x, y, z);
diff --git a/src/main/java/org/bukkit/Location.java b/src/main/java/org/bukkit/Location.java diff --git a/src/main/java/org/bukkit/Location.java b/src/main/java/org/bukkit/Location.java
index b7ff09ffdd3aecc1843d175bc76fe5fae1f48dde..aa6821aa33d3c579a139bd7c0378253c43b3754a 100644 index 14aa275b0fb89d361ee5ec690684053e5e8b4e11..189c2159941712a6f22bb5aaf1e8ca80b4eb54f6 100644
--- a/src/main/java/org/bukkit/Location.java --- a/src/main/java/org/bukkit/Location.java
+++ b/src/main/java/org/bukkit/Location.java +++ b/src/main/java/org/bukkit/Location.java
@@ -546,6 +546,54 @@ public class Location implements Cloneable, ConfigurationSerializable, io.paperm @@ -545,6 +545,59 @@ public class Location implements Cloneable, ConfigurationSerializable, io.paperm
public boolean isChunkLoaded() { return this.getWorld().isChunkLoaded(locToBlock(x) >> 4, locToBlock(z) >> 4); } // Paper public boolean isChunkLoaded() { return this.getWorld().isChunkLoaded(locToBlock(x) >> 4, locToBlock(z) >> 4); } // Paper
// Paper start + // Paper start - expand location manipulation API
+ +
+ /** + /**
+ * Sets the position of this Location and returns itself + * Sets the position of this Location and returns itself
+ * + * <p>
+ * This mutates this object, clone first. + * This mutates this object, clone first.
+ *
+ * @param x X coordinate + * @param x X coordinate
+ * @param y Y coordinate + * @param y Y coordinate
+ * @param z Z coordinate + * @param z Z coordinate
@ -33,8 +35,9 @@ index b7ff09ffdd3aecc1843d175bc76fe5fae1f48dde..aa6821aa33d3c579a139bd7c0378253c
+ +
+ /** + /**
+ * Takes the x/y/z from base and adds the specified x/y/z to it and returns self + * Takes the x/y/z from base and adds the specified x/y/z to it and returns self
+ * + * <p>
+ * This mutates this object, clone first. + * This mutates this object, clone first.
+ *
+ * @param base The base coordinate to modify + * @param base The base coordinate to modify
+ * @param x X coordinate to add to base + * @param x X coordinate to add to base
+ * @param y Y coordinate to add to base + * @param y Y coordinate to add to base
@ -48,8 +51,9 @@ index b7ff09ffdd3aecc1843d175bc76fe5fae1f48dde..aa6821aa33d3c579a139bd7c0378253c
+ +
+ /** + /**
+ * Takes the x/y/z from base and subtracts the specified x/y/z to it and returns self + * Takes the x/y/z from base and subtracts the specified x/y/z to it and returns self
+ * + * <p>
+ * This mutates this object, clone first. + * This mutates this object, clone first.
+ *
+ * @param base The base coordinate to modify + * @param base The base coordinate to modify
+ * @param x X coordinate to subtract from base + * @param x X coordinate to subtract from base
+ * @param y Y coordinate to subtract from base + * @param y Y coordinate to subtract from base
@ -60,7 +64,8 @@ index b7ff09ffdd3aecc1843d175bc76fe5fae1f48dde..aa6821aa33d3c579a139bd7c0378253c
+ public Location subtract(@NotNull Location base, double x, double y, double z) { + public Location subtract(@NotNull Location base, double x, double y, double z) {
+ return this.set(base.x - x, base.y - y, base.z - z); + return this.set(base.x - x, base.y - y, base.z - z);
+ } + }
+ // Paper end - expand location manipulation API
+ +
// Paper start - expand Location API
/** /**
* @return A new location where X/Y/Z are on the Block location (integer value of X/Y/Z) * @return A new location where X/Y/Z are on the Block location (integer value of X/Y/Z)
*/

Datei anzeigen

@ -5,7 +5,7 @@ Subject: [PATCH] Ability to get Tile Entities from a chunk without snapshots
diff --git a/src/main/java/org/bukkit/Chunk.java b/src/main/java/org/bukkit/Chunk.java diff --git a/src/main/java/org/bukkit/Chunk.java b/src/main/java/org/bukkit/Chunk.java
index 766d643f0fe79660942fdad25e39e488e9379419..4418c41f75e9a190dd77abdd6048b0a4fb2a57ed 100644 index 766d643f0fe79660942fdad25e39e488e9379419..eca55d8d3464f0e13a3b7984f74559ccda87edba 100644
--- a/src/main/java/org/bukkit/Chunk.java --- a/src/main/java/org/bukkit/Chunk.java
+++ b/src/main/java/org/bukkit/Chunk.java +++ b/src/main/java/org/bukkit/Chunk.java
@@ -122,7 +122,30 @@ public interface Chunk extends PersistentDataHolder { @@ -122,7 +122,30 @@ public interface Chunk extends PersistentDataHolder {
@ -35,7 +35,7 @@ index 766d643f0fe79660942fdad25e39e488e9379419..4418c41f75e9a190dd77abdd6048b0a4
+ * @return The tile entities. + * @return The tile entities.
+ */ + */
+ @NotNull + @NotNull
+ Collection<BlockState> getTileEntities(java.util.function.@NotNull Predicate<Block> blockPredicate, boolean useSnapshot); + Collection<BlockState> getTileEntities(java.util.function.@NotNull Predicate<? super Block> blockPredicate, boolean useSnapshot);
+ // Paper end + // Paper end
/** /**

Datei anzeigen

@ -18,7 +18,7 @@ Y range: [0, 1023]
X, Z range: [-67 108 864, 67 108 863] X, Z range: [-67 108 864, 67 108 863]
diff --git a/src/main/java/org/bukkit/Location.java b/src/main/java/org/bukkit/Location.java diff --git a/src/main/java/org/bukkit/Location.java b/src/main/java/org/bukkit/Location.java
index aa6821aa33d3c579a139bd7c0378253c43b3754a..6e6e65c40813ccce618fa7a3df2c0030aa0a3bbe 100644 index 189c2159941712a6f22bb5aaf1e8ca80b4eb54f6..09d1f9f909c971d6a785e9f98278f8c55cd44637 100644
--- a/src/main/java/org/bukkit/Location.java --- a/src/main/java/org/bukkit/Location.java
+++ b/src/main/java/org/bukkit/Location.java +++ b/src/main/java/org/bukkit/Location.java
@@ -15,7 +15,6 @@ import org.jetbrains.annotations.Nullable; @@ -15,7 +15,6 @@ import org.jetbrains.annotations.Nullable;
@ -29,7 +29,7 @@ index aa6821aa33d3c579a139bd7c0378253c43b3754a..6e6e65c40813ccce618fa7a3df2c0030
import java.util.function.Predicate; import java.util.function.Predicate;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
@@ -605,6 +604,19 @@ public class Location implements Cloneable, ConfigurationSerializable, io.paperm @@ -610,6 +609,19 @@ public class Location implements Cloneable, ConfigurationSerializable, io.paperm
blockLoc.setZ(getBlockZ()); blockLoc.setZ(getBlockZ());
return blockLoc; return blockLoc;
} }
@ -50,7 +50,7 @@ index aa6821aa33d3c579a139bd7c0378253c43b3754a..6e6e65c40813ccce618fa7a3df2c0030
* @return A new location where X/Y/Z are the center of the block * @return A new location where X/Y/Z are the center of the block
*/ */
diff --git a/src/main/java/org/bukkit/World.java b/src/main/java/org/bukkit/World.java diff --git a/src/main/java/org/bukkit/World.java b/src/main/java/org/bukkit/World.java
index 315ecb5dc0f33edfef893ead1297c8165d292250..ad5afa7a05636cee82b517c673d281f0f4e38644 100644 index f21d3ab534a64a5445975968b63fc78d7dc2fa72..fef21d398d9c9349e10e59b62cbbe28e9538482d 100644
--- a/src/main/java/org/bukkit/World.java --- a/src/main/java/org/bukkit/World.java
+++ b/src/main/java/org/bukkit/World.java +++ b/src/main/java/org/bukkit/World.java
@@ -97,6 +97,41 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient @@ -97,6 +97,41 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient

Datei anzeigen

@ -5,7 +5,7 @@ Subject: [PATCH] isChunkGenerated API
diff --git a/src/main/java/org/bukkit/Location.java b/src/main/java/org/bukkit/Location.java diff --git a/src/main/java/org/bukkit/Location.java b/src/main/java/org/bukkit/Location.java
index 6e6e65c40813ccce618fa7a3df2c0030aa0a3bbe..8508aa2c6fb7c9f41f3d185f5228c86dd3b8b627 100644 index 09d1f9f909c971d6a785e9f98278f8c55cd44637..7fea9af96c97d9f60af6fe30fed1ec05d05a1a25 100644
--- a/src/main/java/org/bukkit/Location.java --- a/src/main/java/org/bukkit/Location.java
+++ b/src/main/java/org/bukkit/Location.java +++ b/src/main/java/org/bukkit/Location.java
@@ -3,6 +3,7 @@ package org.bukkit; @@ -3,6 +3,7 @@ package org.bukkit;
@ -16,10 +16,11 @@ index 6e6e65c40813ccce618fa7a3df2c0030aa0a3bbe..8508aa2c6fb7c9f41f3d185f5228c86d
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import org.bukkit.block.Block; import org.bukkit.block.Block;
@@ -545,6 +546,16 @@ public class Location implements Cloneable, ConfigurationSerializable, io.paperm @@ -544,6 +545,19 @@ public class Location implements Cloneable, ConfigurationSerializable, io.paperm
public boolean isChunkLoaded() { return this.getWorld().isChunkLoaded(locToBlock(x) >> 4, locToBlock(z) >> 4); } // Paper public boolean isChunkLoaded() { return this.getWorld().isChunkLoaded(locToBlock(x) >> 4, locToBlock(z) >> 4); } // Paper
// Paper start + // Paper start - isGenerated API
+ /** + /**
+ * Checks if a {@link Chunk} has been generated at this location. + * Checks if a {@link Chunk} has been generated at this location.
+ * + *
@ -30,11 +31,13 @@ index 6e6e65c40813ccce618fa7a3df2c0030aa0a3bbe..8508aa2c6fb7c9f41f3d185f5228c86d
+ Preconditions.checkNotNull(world, "Location has no world!"); + Preconditions.checkNotNull(world, "Location has no world!");
+ return world.isChunkGenerated(locToBlock(x) >> 4, locToBlock(z) >> 4); + return world.isChunkGenerated(locToBlock(x) >> 4, locToBlock(z) >> 4);
+ } + }
+ // Paper end - isGenerated API
+
// Paper start - expand location manipulation API
/** /**
* Sets the position of this Location and returns itself
diff --git a/src/main/java/org/bukkit/World.java b/src/main/java/org/bukkit/World.java diff --git a/src/main/java/org/bukkit/World.java b/src/main/java/org/bukkit/World.java
index ad5afa7a05636cee82b517c673d281f0f4e38644..880ff5ee1237096ac2da115b665dc663c677e57b 100644 index fef21d398d9c9349e10e59b62cbbe28e9538482d..213ec372ab639179da65e67a1326c1e08bfbc943 100644
--- a/src/main/java/org/bukkit/World.java --- a/src/main/java/org/bukkit/World.java
+++ b/src/main/java/org/bukkit/World.java +++ b/src/main/java/org/bukkit/World.java
@@ -246,6 +246,19 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient @@ -246,6 +246,19 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient

Datei anzeigen

@ -8,14 +8,14 @@ Adds API's to load or generate chunks asynchronously.
Also adds utility methods to Entity to teleport asynchronously. Also adds utility methods to Entity to teleport asynchronously.
diff --git a/src/main/java/org/bukkit/World.java b/src/main/java/org/bukkit/World.java diff --git a/src/main/java/org/bukkit/World.java b/src/main/java/org/bukkit/World.java
index 880ff5ee1237096ac2da115b665dc663c677e57b..fc6b99e4f37179b15254bf0b398b1a800de1b73f 100644 index 213ec372ab639179da65e67a1326c1e08bfbc943..e4a0d57535fa0fb51765ccdbf0e41d0478a28ee5 100644
--- a/src/main/java/org/bukkit/World.java --- a/src/main/java/org/bukkit/World.java
+++ b/src/main/java/org/bukkit/World.java +++ b/src/main/java/org/bukkit/World.java
@@ -955,6 +955,482 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient @@ -939,6 +939,472 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient
} }
return nearby; // Paper end - additional getNearbyEntities API
}
+ + // Paper start - async chunks API
+ /** + /**
+ * This is the Legacy API before Java 8 was supported. Java 8 Consumer is provided, + * This is the Legacy API before Java 8 was supported. Java 8 Consumer is provided,
+ * as well as future support + * as well as future support
@ -139,8 +139,8 @@ index 880ff5ee1237096ac2da115b665dc663c677e57b..fc6b99e4f37179b15254bf0b398b1a80
+ * @param cb Callback to receive the chunk when it is loaded. + * @param cb Callback to receive the chunk when it is loaded.
+ * will be executed synchronously + * will be executed synchronously
+ */ + */
+ public default void getChunkAtAsync(int x, int z, @NotNull java.util.function.Consumer<Chunk> cb) { + default void getChunkAtAsync(final int x, final int z, final @NotNull Consumer<? super Chunk> cb) {
+ getChunkAtAsync(x, z, true).thenAccept(cb).exceptionally((ex) -> { + this.getChunkAtAsync(x, z, true).thenAccept(cb).exceptionally((ex) -> {
+ Bukkit.getLogger().log(java.util.logging.Level.WARNING, "Exception in chunk load callback", ex); + Bukkit.getLogger().log(java.util.logging.Level.WARNING, "Exception in chunk load callback", ex);
+ return null; + return null;
+ }); + });
@ -165,8 +165,8 @@ index 880ff5ee1237096ac2da115b665dc663c677e57b..fc6b99e4f37179b15254bf0b398b1a80
+ * @param cb Callback to receive the chunk when it is loaded. + * @param cb Callback to receive the chunk when it is loaded.
+ * will be executed synchronously + * will be executed synchronously
+ */ + */
+ public default void getChunkAtAsync(int x, int z, boolean gen, @NotNull java.util.function.Consumer<Chunk> cb) { + default void getChunkAtAsync(final int x, final int z, final boolean gen, final @NotNull Consumer<? super Chunk> cb) {
+ getChunkAtAsync(x, z, gen).thenAccept(cb).exceptionally((ex) -> { + this.getChunkAtAsync(x, z, gen).thenAccept(cb).exceptionally((ex) -> {
+ Bukkit.getLogger().log(java.util.logging.Level.WARNING, "Exception in chunk load callback", ex); + Bukkit.getLogger().log(java.util.logging.Level.WARNING, "Exception in chunk load callback", ex);
+ return null; + return null;
+ }); + });
@ -189,8 +189,8 @@ index 880ff5ee1237096ac2da115b665dc663c677e57b..fc6b99e4f37179b15254bf0b398b1a80
+ * @param cb Callback to receive the chunk when it is loaded. + * @param cb Callback to receive the chunk when it is loaded.
+ * will be executed synchronously + * will be executed synchronously
+ */ + */
+ public default void getChunkAtAsync(@NotNull Location loc, @NotNull java.util.function.Consumer<Chunk> cb) { + default void getChunkAtAsync(final @NotNull Location loc, final @NotNull Consumer<? super Chunk> cb) {
+ getChunkAtAsync((int)Math.floor(loc.getX()) >> 4, (int)Math.floor(loc.getZ()) >> 4, true, cb); + this.getChunkAtAsync((int) Math.floor(loc.getX()) >> 4, (int) Math.floor(loc.getZ()) >> 4, true, cb);
+ } + }
+ +
+ /** + /**
@ -211,8 +211,8 @@ index 880ff5ee1237096ac2da115b665dc663c677e57b..fc6b99e4f37179b15254bf0b398b1a80
+ * @param cb Callback to receive the chunk when it is loaded. + * @param cb Callback to receive the chunk when it is loaded.
+ * will be executed synchronously + * will be executed synchronously
+ */ + */
+ public default void getChunkAtAsync(@NotNull Location loc, boolean gen, @NotNull java.util.function.Consumer<Chunk> cb) { + default void getChunkAtAsync(final @NotNull Location loc, final boolean gen, final @NotNull Consumer<? super Chunk> cb) {
+ getChunkAtAsync((int)Math.floor(loc.getX()) >> 4, (int)Math.floor(loc.getZ()) >> 4, gen, cb); + this.getChunkAtAsync((int) Math.floor(loc.getX()) >> 4, (int) Math.floor(loc.getZ()) >> 4, gen, cb);
+ } + }
+ +
+ /** + /**
@ -232,8 +232,8 @@ index 880ff5ee1237096ac2da115b665dc663c677e57b..fc6b99e4f37179b15254bf0b398b1a80
+ * @param cb Callback to receive the chunk when it is loaded. + * @param cb Callback to receive the chunk when it is loaded.
+ * will be executed synchronously + * will be executed synchronously
+ */ + */
+ public default void getChunkAtAsync(@NotNull Block block, @NotNull java.util.function.Consumer<Chunk> cb) { + default void getChunkAtAsync(final @NotNull Block block, final @NotNull Consumer<? super Chunk> cb) {
+ getChunkAtAsync(block.getX() >> 4, block.getZ() >> 4, true, cb); + this.getChunkAtAsync(block.getX() >> 4, block.getZ() >> 4, true, cb);
+ } + }
+ +
+ /** + /**
@ -254,8 +254,8 @@ index 880ff5ee1237096ac2da115b665dc663c677e57b..fc6b99e4f37179b15254bf0b398b1a80
+ * @param cb Callback to receive the chunk when it is loaded. + * @param cb Callback to receive the chunk when it is loaded.
+ * will be executed synchronously + * will be executed synchronously
+ */ + */
+ public default void getChunkAtAsync(@NotNull Block block, boolean gen, @NotNull java.util.function.Consumer<Chunk> cb) { + default void getChunkAtAsync(final @NotNull Block block, final boolean gen, final @NotNull Consumer<? super Chunk> cb) {
+ getChunkAtAsync(block.getX() >> 4, block.getZ() >> 4, gen, cb); + this.getChunkAtAsync(block.getX() >> 4, block.getZ() >> 4, gen, cb);
+ } + }
+ +
+ /** + /**
@ -273,9 +273,8 @@ index 880ff5ee1237096ac2da115b665dc663c677e57b..fc6b99e4f37179b15254bf0b398b1a80
+ * @param loc Location to load the corresponding chunk from + * @param loc Location to load the corresponding chunk from
+ * @return Future that will resolve when the chunk is loaded + * @return Future that will resolve when the chunk is loaded
+ */ + */
+ @NotNull + default @NotNull java.util.concurrent.CompletableFuture<Chunk> getChunkAtAsync(final @NotNull Location loc) {
+ public default java.util.concurrent.CompletableFuture<Chunk> getChunkAtAsync(@NotNull Location loc) { + return this.getChunkAtAsync((int) Math.floor(loc.getX()) >> 4, (int) Math.floor(loc.getZ()) >> 4, true);
+ return getChunkAtAsync((int)Math.floor(loc.getX()) >> 4, (int)Math.floor(loc.getZ()) >> 4, true);
+ } + }
+ +
+ /** + /**
@ -294,9 +293,8 @@ index 880ff5ee1237096ac2da115b665dc663c677e57b..fc6b99e4f37179b15254bf0b398b1a80
+ * @param gen Should the chunk generate if it doesn't exist + * @param gen Should the chunk generate if it doesn't exist
+ * @return Future that will resolve when the chunk is loaded + * @return Future that will resolve when the chunk is loaded
+ */ + */
+ @NotNull + default @NotNull java.util.concurrent.CompletableFuture<Chunk> getChunkAtAsync(final @NotNull Location loc, final boolean gen) {
+ public default java.util.concurrent.CompletableFuture<Chunk> getChunkAtAsync(@NotNull Location loc, boolean gen) { + return this.getChunkAtAsync((int) Math.floor(loc.getX()) >> 4, (int) Math.floor(loc.getZ()) >> 4, gen);
+ return getChunkAtAsync((int)Math.floor(loc.getX()) >> 4, (int)Math.floor(loc.getZ()) >> 4, gen);
+ } + }
+ +
+ /** + /**
@ -314,9 +312,8 @@ index 880ff5ee1237096ac2da115b665dc663c677e57b..fc6b99e4f37179b15254bf0b398b1a80
+ * @param block Block to load the corresponding chunk from + * @param block Block to load the corresponding chunk from
+ * @return Future that will resolve when the chunk is loaded + * @return Future that will resolve when the chunk is loaded
+ */ + */
+ @NotNull + default @NotNull java.util.concurrent.CompletableFuture<Chunk> getChunkAtAsync(final @NotNull Block block) {
+ public default java.util.concurrent.CompletableFuture<Chunk> getChunkAtAsync(@NotNull Block block) { + return this.getChunkAtAsync(block.getX() >> 4, block.getZ() >> 4, true);
+ return getChunkAtAsync(block.getX() >> 4, block.getZ() >> 4, true);
+ } + }
+ +
+ /** + /**
@ -335,9 +332,8 @@ index 880ff5ee1237096ac2da115b665dc663c677e57b..fc6b99e4f37179b15254bf0b398b1a80
+ * @param gen Should the chunk generate if it doesn't exist + * @param gen Should the chunk generate if it doesn't exist
+ * @return Future that will resolve when the chunk is loaded + * @return Future that will resolve when the chunk is loaded
+ */ + */
+ @NotNull + default @NotNull java.util.concurrent.CompletableFuture<Chunk> getChunkAtAsync(final @NotNull Block block, final boolean gen) {
+ public default java.util.concurrent.CompletableFuture<Chunk> getChunkAtAsync(@NotNull Block block, boolean gen) { + return this.getChunkAtAsync(block.getX() >> 4, block.getZ() >> 4, gen);
+ return getChunkAtAsync(block.getX() >> 4, block.getZ() >> 4, gen);
+ } + }
+ +
+ /** + /**
@ -357,9 +353,8 @@ index 880ff5ee1237096ac2da115b665dc663c677e57b..fc6b99e4f37179b15254bf0b398b1a80
+ * @param z Chunk Z-coordinate of the chunk - floor(world coordinate / 16) + * @param z Chunk Z-coordinate of the chunk - floor(world coordinate / 16)
+ * @return Future that will resolve when the chunk is loaded + * @return Future that will resolve when the chunk is loaded
+ */ + */
+ @NotNull + default @NotNull java.util.concurrent.CompletableFuture<Chunk> getChunkAtAsync(final int x, final int z) {
+ public default java.util.concurrent.CompletableFuture<Chunk> getChunkAtAsync(int x, int z) { + return this.getChunkAtAsync(x, z, true);
+ return getChunkAtAsync(x, z, true);
+ } + }
+ +
+ /** + /**
@ -380,9 +375,8 @@ index 880ff5ee1237096ac2da115b665dc663c677e57b..fc6b99e4f37179b15254bf0b398b1a80
+ * @param gen Should we generate a chunk if it doesn't exist or not + * @param gen Should we generate a chunk if it doesn't exist or not
+ * @return Future that will resolve when the chunk is loaded + * @return Future that will resolve when the chunk is loaded
+ */ + */
+ @NotNull + default @NotNull java.util.concurrent.CompletableFuture<Chunk> getChunkAtAsync(final int x, final int z, final boolean gen) {
+ public default java.util.concurrent.CompletableFuture<Chunk> getChunkAtAsync(int x, int z, boolean gen) { + return this.getChunkAtAsync(x, z, gen, false);
+ return getChunkAtAsync(x, z, gen, false);
+ } + }
+ +
+ /** + /**
@ -400,9 +394,8 @@ index 880ff5ee1237096ac2da115b665dc663c677e57b..fc6b99e4f37179b15254bf0b398b1a80
+ * @param loc Location to load the corresponding chunk from + * @param loc Location to load the corresponding chunk from
+ * @return Future that will resolve when the chunk is loaded + * @return Future that will resolve when the chunk is loaded
+ */ + */
+ @NotNull + default @NotNull java.util.concurrent.CompletableFuture<Chunk> getChunkAtAsyncUrgently(final @NotNull Location loc) {
+ public default java.util.concurrent.CompletableFuture<Chunk> getChunkAtAsyncUrgently(@NotNull Location loc) { + return this.getChunkAtAsync((int) Math.floor(loc.getX()) >> 4, (int) Math.floor(loc.getZ()) >> 4, true, true);
+ return getChunkAtAsync((int)Math.floor(loc.getX()) >> 4, (int)Math.floor(loc.getZ()) >> 4, true, true);
+ } + }
+ +
+ /** + /**
@ -421,9 +414,8 @@ index 880ff5ee1237096ac2da115b665dc663c677e57b..fc6b99e4f37179b15254bf0b398b1a80
+ * @param gen Should the chunk generate if it doesn't exist + * @param gen Should the chunk generate if it doesn't exist
+ * @return Future that will resolve when the chunk is loaded + * @return Future that will resolve when the chunk is loaded
+ */ + */
+ @NotNull + default @NotNull java.util.concurrent.CompletableFuture<Chunk> getChunkAtAsyncUrgently(final @NotNull Location loc, final boolean gen) {
+ public default java.util.concurrent.CompletableFuture<Chunk> getChunkAtAsyncUrgently(@NotNull Location loc, boolean gen) { + return this.getChunkAtAsync((int) Math.floor(loc.getX()) >> 4, (int) Math.floor(loc.getZ()) >> 4, gen, true);
+ return getChunkAtAsync((int)Math.floor(loc.getX()) >> 4, (int)Math.floor(loc.getZ()) >> 4, gen, true);
+ } + }
+ +
+ /** + /**
@ -441,9 +433,8 @@ index 880ff5ee1237096ac2da115b665dc663c677e57b..fc6b99e4f37179b15254bf0b398b1a80
+ * @param block Block to load the corresponding chunk from + * @param block Block to load the corresponding chunk from
+ * @return Future that will resolve when the chunk is loaded + * @return Future that will resolve when the chunk is loaded
+ */ + */
+ @NotNull + default @NotNull java.util.concurrent.CompletableFuture<Chunk> getChunkAtAsyncUrgently(final @NotNull Block block) {
+ public default java.util.concurrent.CompletableFuture<Chunk> getChunkAtAsyncUrgently(@NotNull Block block) { + return this.getChunkAtAsync(block.getX() >> 4, block.getZ() >> 4, true, true);
+ return getChunkAtAsync(block.getX() >> 4, block.getZ() >> 4, true, true);
+ } + }
+ +
+ /** + /**
@ -462,9 +453,8 @@ index 880ff5ee1237096ac2da115b665dc663c677e57b..fc6b99e4f37179b15254bf0b398b1a80
+ * @param gen Should the chunk generate if it doesn't exist + * @param gen Should the chunk generate if it doesn't exist
+ * @return Future that will resolve when the chunk is loaded + * @return Future that will resolve when the chunk is loaded
+ */ + */
+ @NotNull + default @NotNull java.util.concurrent.CompletableFuture<Chunk> getChunkAtAsyncUrgently(final @NotNull Block block, final boolean gen) {
+ public default java.util.concurrent.CompletableFuture<Chunk> getChunkAtAsyncUrgently(@NotNull Block block, boolean gen) { + return this.getChunkAtAsync(block.getX() >> 4, block.getZ() >> 4, gen, true);
+ return getChunkAtAsync(block.getX() >> 4, block.getZ() >> 4, gen, true);
+ } + }
+ +
+ /** + /**
@ -484,16 +474,16 @@ index 880ff5ee1237096ac2da115b665dc663c677e57b..fc6b99e4f37179b15254bf0b398b1a80
+ * @param z Z Coord + * @param z Z Coord
+ * @return Future that will resolve when the chunk is loaded + * @return Future that will resolve when the chunk is loaded
+ */ + */
+ @NotNull + default @NotNull java.util.concurrent.CompletableFuture<Chunk> getChunkAtAsyncUrgently(final int x, final int z) {
+ public default java.util.concurrent.CompletableFuture<Chunk> getChunkAtAsyncUrgently(int x, int z) { + return this.getChunkAtAsync(x, z, true, true);
+ return getChunkAtAsync(x, z, true, true);
+ } + }
+ +
+ @NotNull + java.util.concurrent.@NotNull CompletableFuture<Chunk> getChunkAtAsync(int x, int z, boolean gen, boolean urgent);
+ java.util.concurrent.CompletableFuture<Chunk> getChunkAtAsync(int x, int z, boolean gen, boolean urgent); + // Paper end - async chunks API
// Paper end +
/** /**
* Get a list of all players in this World
*
diff --git a/src/main/java/org/bukkit/entity/Entity.java b/src/main/java/org/bukkit/entity/Entity.java diff --git a/src/main/java/org/bukkit/entity/Entity.java b/src/main/java/org/bukkit/entity/Entity.java
index 5fc085f785719933eef7ab1b3cf173579c64739b..711d95bfafac0d415895023bdaac4059395667ab 100644 index 5fc085f785719933eef7ab1b3cf173579c64739b..711d95bfafac0d415895023bdaac4059395667ab 100644
--- a/src/main/java/org/bukkit/entity/Entity.java --- a/src/main/java/org/bukkit/entity/Entity.java

Datei anzeigen

@ -5,10 +5,10 @@ Subject: [PATCH] Add sun related API
diff --git a/src/main/java/org/bukkit/World.java b/src/main/java/org/bukkit/World.java diff --git a/src/main/java/org/bukkit/World.java b/src/main/java/org/bukkit/World.java
index 7aa4103fdfd8a637ad77c2cb6d3521a9c4442459..3727e136dce6eb41c316c3607c946489cf7df7c8 100644 index 99a31572fa393a2482548ec55a96cb8568d07199..561cfe701d76fa0c85cea4a76affa7e90de82da0 100644
--- a/src/main/java/org/bukkit/World.java --- a/src/main/java/org/bukkit/World.java
+++ b/src/main/java/org/bukkit/World.java +++ b/src/main/java/org/bukkit/World.java
@@ -1788,6 +1788,16 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient @@ -1760,6 +1760,16 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient
*/ */
public void setFullTime(long time); public void setFullTime(long time);

Datei anzeigen

@ -254,7 +254,7 @@ index f9c9ae463aacd593e3aa9caf037ea1e23d56c780..f8ae143acbf586d5279b44f7311ca97f
/** /**
diff --git a/src/main/java/org/bukkit/Location.java b/src/main/java/org/bukkit/Location.java diff --git a/src/main/java/org/bukkit/Location.java b/src/main/java/org/bukkit/Location.java
index 16df0568143a956309e6cab91a0818582fa4ed67..9e80988c71b77bbda1aca27a859537600a1439a6 100644 index 0b202d378d50946f43434e70d9d511cac06749b0..cf42f6e57e96aa9cb4465e34a6e3f8709de4ca09 100644
--- a/src/main/java/org/bukkit/Location.java --- a/src/main/java/org/bukkit/Location.java
+++ b/src/main/java/org/bukkit/Location.java +++ b/src/main/java/org/bukkit/Location.java
@@ -46,7 +46,7 @@ public class Location implements Cloneable, ConfigurationSerializable, io.paperm @@ -46,7 +46,7 @@ public class Location implements Cloneable, ConfigurationSerializable, io.paperm
@ -600,7 +600,7 @@ index e455eb21abf121dc6ff10ff8a13dd06f67096a8f..bbc01e7c192ae6689c301670047ff114
return origin; return origin;
} }
diff --git a/src/main/java/org/bukkit/World.java b/src/main/java/org/bukkit/World.java diff --git a/src/main/java/org/bukkit/World.java b/src/main/java/org/bukkit/World.java
index 3727e136dce6eb41c316c3607c946489cf7df7c8..f827e55a8dc57e8d29fce4c2c0545de89b54a800 100644 index 561cfe701d76fa0c85cea4a76affa7e90de82da0..8a200ffe1851b24110c92bb3a9f7ffc39b8c63f2 100644
--- a/src/main/java/org/bukkit/World.java --- a/src/main/java/org/bukkit/World.java
+++ b/src/main/java/org/bukkit/World.java +++ b/src/main/java/org/bukkit/World.java
@@ -416,9 +416,8 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient @@ -416,9 +416,8 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient
@ -614,7 +614,7 @@ index 3727e136dce6eb41c316c3607c946489cf7df7c8..f827e55a8dc57e8d29fce4c2c0545de8
public boolean refreshChunk(int x, int z); public boolean refreshChunk(int x, int z);
/** /**
@@ -3790,6 +3789,10 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient @@ -3762,6 +3761,10 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient
// Paper end - view distance api // Paper end - view distance api
// Spigot start // Spigot start
@ -625,7 +625,7 @@ index 3727e136dce6eb41c316c3607c946489cf7df7c8..f827e55a8dc57e8d29fce4c2c0545de8
public class Spigot { public class Spigot {
/** /**
@@ -3798,8 +3801,12 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient @@ -3770,8 +3773,12 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient
* @param loc The location to strike lightning * @param loc The location to strike lightning
* @param isSilent Whether this strike makes no sound * @param isSilent Whether this strike makes no sound
* @return The lightning entity. * @return The lightning entity.
@ -638,7 +638,7 @@ index 3727e136dce6eb41c316c3607c946489cf7df7c8..f827e55a8dc57e8d29fce4c2c0545de8
public LightningStrike strikeLightning(@NotNull Location loc, boolean isSilent) { public LightningStrike strikeLightning(@NotNull Location loc, boolean isSilent) {
throw new UnsupportedOperationException("Not supported yet."); throw new UnsupportedOperationException("Not supported yet.");
} }
@@ -3810,14 +3817,22 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient @@ -3782,14 +3789,22 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient
* @param loc The location to strike lightning * @param loc The location to strike lightning
* @param isSilent Whether this strike makes no sound * @param isSilent Whether this strike makes no sound
* @return The lightning entity. * @return The lightning entity.
@ -661,7 +661,7 @@ index 3727e136dce6eb41c316c3607c946489cf7df7c8..f827e55a8dc57e8d29fce4c2c0545de8
Spigot spigot(); Spigot spigot();
// Spigot end // Spigot end
@@ -3948,9 +3963,9 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient @@ -3920,9 +3935,9 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient
* Gets the dimension ID of this environment * Gets the dimension ID of this environment
* *
* @return dimension ID * @return dimension ID
@ -673,7 +673,7 @@ index 3727e136dce6eb41c316c3607c946489cf7df7c8..f827e55a8dc57e8d29fce4c2c0545de8
public int getId() { public int getId() {
return id; return id;
} }
@@ -3960,9 +3975,9 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient @@ -3932,9 +3947,9 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient
* *
* @param id The ID of the environment * @param id The ID of the environment
* @return The environment * @return The environment

Datei anzeigen

@ -51,12 +51,12 @@ index 0000000000000000000000000000000000000000..1c832d69bb3717dcfccf21e45f6f060a
+ SOLID_OR_LIQUID_NO_LEAVES; + SOLID_OR_LIQUID_NO_LEAVES;
+} +}
diff --git a/src/main/java/org/bukkit/Location.java b/src/main/java/org/bukkit/Location.java diff --git a/src/main/java/org/bukkit/Location.java b/src/main/java/org/bukkit/Location.java
index f7564581c18425c903e54f949728dd3742ca7bf2..1bfe465b9aaeea7d3c871140145b7de1b8f1d93d 100644 index dc7e69380e421f64d65b6dcb80909fc770d157fa..5edee59f24ef5f8adf2aa1f2f3c0289cf4bc0ec3 100644
--- a/src/main/java/org/bukkit/Location.java --- a/src/main/java/org/bukkit/Location.java
+++ b/src/main/java/org/bukkit/Location.java +++ b/src/main/java/org/bukkit/Location.java
@@ -640,6 +640,46 @@ public class Location implements Cloneable, ConfigurationSerializable, io.paperm @@ -649,6 +649,46 @@ public class Location implements Cloneable, ConfigurationSerializable, io.paperm
return centerLoc;
} }
// Paper end - expand Location API
+ // Paper start - Add heightmap api + // Paper start - Add heightmap api
+ /** + /**
@ -102,7 +102,7 @@ index f7564581c18425c903e54f949728dd3742ca7bf2..1bfe465b9aaeea7d3c871140145b7de1
/** /**
* Creates explosion at this location with given power * Creates explosion at this location with given power
diff --git a/src/main/java/org/bukkit/World.java b/src/main/java/org/bukkit/World.java diff --git a/src/main/java/org/bukkit/World.java b/src/main/java/org/bukkit/World.java
index e673e05c3d94c28d6809a0de7f7d070712b85741..5d3b645eb24f5c0e3309143fc0e53545c6de8083 100644 index fe5cc7b038516dd61d2d1af97073a60b76874db5..518158d70a8e7ba9a6aa54c22913d8a881adff1f 100644
--- a/src/main/java/org/bukkit/World.java --- a/src/main/java/org/bukkit/World.java
+++ b/src/main/java/org/bukkit/World.java +++ b/src/main/java/org/bukkit/World.java
@@ -151,6 +151,87 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient @@ -151,6 +151,87 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient

Datei anzeigen

@ -5,10 +5,10 @@ Subject: [PATCH] More World API
diff --git a/src/main/java/org/bukkit/World.java b/src/main/java/org/bukkit/World.java diff --git a/src/main/java/org/bukkit/World.java b/src/main/java/org/bukkit/World.java
index 7d2a7aff5b15a66663ef896fb1a7e0c6804e936a..372e3e40bb21f0185c59973d5c8ee48c07ea9725 100644 index dd498e3ba46bd001028f7f9f94e18de42e875ff6..8735a0a359450a6cbea44c1b01c85a4135ba1f86 100644
--- a/src/main/java/org/bukkit/World.java --- a/src/main/java/org/bukkit/World.java
+++ b/src/main/java/org/bukkit/World.java +++ b/src/main/java/org/bukkit/World.java
@@ -3797,6 +3797,122 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient @@ -3769,6 +3769,122 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient
@Nullable @Nullable
StructureSearchResult locateNearestStructure(@NotNull Location origin, @NotNull Structure structure, int radius, boolean findUnexplored); StructureSearchResult locateNearestStructure(@NotNull Location origin, @NotNull Structure structure, int radius, boolean findUnexplored);

Datei anzeigen

@ -6,7 +6,7 @@ Subject: [PATCH] Custom Potion Mixes
diff --git a/src/main/java/io/papermc/paper/potion/PotionMix.java b/src/main/java/io/papermc/paper/potion/PotionMix.java diff --git a/src/main/java/io/papermc/paper/potion/PotionMix.java b/src/main/java/io/papermc/paper/potion/PotionMix.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..ae1f30e88fc5048627295187214aa7a288f4c184 index 0000000000000000000000000000000000000000..3fc922ebf972418b84181cd02e68d8ef0efd739b
--- /dev/null --- /dev/null
+++ b/src/main/java/io/papermc/paper/potion/PotionMix.java +++ b/src/main/java/io/papermc/paper/potion/PotionMix.java
@@ -0,0 +1,105 @@ @@ -0,0 +1,105 @@
@ -42,13 +42,25 @@ index 0000000000000000000000000000000000000000..ae1f30e88fc5048627295187214aa7a2
+ * @param input the input placed into the bottom 3 slots + * @param input the input placed into the bottom 3 slots
+ * @param ingredient the ingredient placed into the top slot + * @param ingredient the ingredient placed into the top slot
+ */ + */
+ public PotionMix(@NotNull NamespacedKey key, @NotNull ItemStack result, @NotNull RecipeChoice input, @NotNull RecipeChoice ingredient) { + public PotionMix(final @NotNull NamespacedKey key, final @NotNull ItemStack result, final @NotNull RecipeChoice input, final @NotNull RecipeChoice ingredient) {
+ this.key = key; + this.key = key;
+ this.result = result; + this.result = result;
+ this.input = input; + this.input = input;
+ this.ingredient = ingredient; + this.ingredient = ingredient;
+ } + }
+ +
+ /**
+ * Create a {@link RecipeChoice} based on a Predicate. These RecipeChoices are only
+ * valid for {@link PotionMix}, not anywhere else RecipeChoices may be used.
+ *
+ * @param stackPredicate a predicate for an itemstack.
+ * @return a new RecipeChoice
+ */
+ @Contract(value = "_ -> new", pure = true)
+ public static @NotNull RecipeChoice createPredicateChoice(final @NotNull Predicate<? super ItemStack> stackPredicate) {
+ return new PredicateRecipeChoice(stackPredicate);
+ }
+
+ @Override + @Override
+ public @NotNull NamespacedKey getKey() { + public @NotNull NamespacedKey getKey() {
+ return this.key; + return this.key;
@ -81,18 +93,6 @@ index 0000000000000000000000000000000000000000..ae1f30e88fc5048627295187214aa7a2
+ return this.ingredient; + return this.ingredient;
+ } + }
+ +
+ /**
+ * Create a {@link RecipeChoice} based on a Predicate. These RecipeChoices are only
+ * valid for {@link PotionMix}, not anywhere else RecipeChoices may be used.
+ *
+ * @param stackPredicate a predicate for an itemstack.
+ * @return a new RecipeChoice
+ */
+ @Contract(value = "_ -> new", pure = true)
+ public static @NotNull RecipeChoice createPredicateChoice(@NotNull Predicate<ItemStack> stackPredicate) {
+ return new PredicateRecipeChoice(stackPredicate);
+ }
+
+ @Override + @Override
+ public String toString() { + public String toString() {
+ return "PotionMix{" + + return "PotionMix{" +
@ -103,10 +103,10 @@ index 0000000000000000000000000000000000000000..ae1f30e88fc5048627295187214aa7a2
+ } + }
+ +
+ @Override + @Override
+ public boolean equals(Object o) { + public boolean equals(final Object o) {
+ if (this == o) return true; + if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false; + if (o == null || this.getClass() != o.getClass()) return false;
+ PotionMix potionMix = (PotionMix) o; + final PotionMix potionMix = (PotionMix) o;
+ return this.key.equals(potionMix.key) && this.result.equals(potionMix.result) && this.input.equals(potionMix.input) && this.ingredient.equals(potionMix.ingredient); + return this.key.equals(potionMix.key) && this.result.equals(potionMix.result) && this.input.equals(potionMix.input) && this.ingredient.equals(potionMix.ingredient);
+ } + }
+ +
@ -117,7 +117,7 @@ index 0000000000000000000000000000000000000000..ae1f30e88fc5048627295187214aa7a2
+} +}
diff --git a/src/main/java/io/papermc/paper/potion/PredicateRecipeChoice.java b/src/main/java/io/papermc/paper/potion/PredicateRecipeChoice.java diff --git a/src/main/java/io/papermc/paper/potion/PredicateRecipeChoice.java b/src/main/java/io/papermc/paper/potion/PredicateRecipeChoice.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..1bf964605f681469fb364baaa18381c090260a94 index 0000000000000000000000000000000000000000..3ede1e8f7bf0436fdc5bf395c0f9eaf11c252453
--- /dev/null --- /dev/null
+++ b/src/main/java/io/papermc/paper/potion/PredicateRecipeChoice.java +++ b/src/main/java/io/papermc/paper/potion/PredicateRecipeChoice.java
@@ -0,0 +1,33 @@ @@ -0,0 +1,33 @@
@ -132,7 +132,7 @@ index 0000000000000000000000000000000000000000..1bf964605f681469fb364baaa18381c0
+ +
+@ApiStatus.Internal +@ApiStatus.Internal
+@DefaultQualifier(NonNull.class) +@DefaultQualifier(NonNull.class)
+record PredicateRecipeChoice(Predicate<ItemStack> itemStackPredicate) implements RecipeChoice, Cloneable { +record PredicateRecipeChoice(Predicate<? super ItemStack> itemStackPredicate) implements RecipeChoice, Cloneable {
+ +
+ @Override + @Override
+ @Deprecated + @Deprecated
@ -144,7 +144,7 @@ index 0000000000000000000000000000000000000000..1bf964605f681469fb364baaa18381c0
+ public RecipeChoice clone() { + public RecipeChoice clone() {
+ try { + try {
+ return (PredicateRecipeChoice) super.clone(); + return (PredicateRecipeChoice) super.clone();
+ } catch (CloneNotSupportedException ex) { + } catch (final CloneNotSupportedException ex) {
+ throw new AssertionError(ex); + throw new AssertionError(ex);
+ } + }
+ } + }

Datei anzeigen

@ -10,10 +10,10 @@ Subject: [PATCH] Expand FallingBlock API
Co-authored-by: Lukas Planz <lukas.planz@web.de> Co-authored-by: Lukas Planz <lukas.planz@web.de>
diff --git a/src/main/java/org/bukkit/World.java b/src/main/java/org/bukkit/World.java diff --git a/src/main/java/org/bukkit/World.java b/src/main/java/org/bukkit/World.java
index 94e6fe6257b30112066b98ec4fdb1561dbcc93c4..bc6630345bb42eb365ba0057a4c52b1e10c6a05a 100644 index b191d304832fe3475b76fdce131db51e5042ac01..298e63e0ca9d4cbac3172fd93a217af79fad91df 100644
--- a/src/main/java/org/bukkit/World.java --- a/src/main/java/org/bukkit/World.java
+++ b/src/main/java/org/bukkit/World.java +++ b/src/main/java/org/bukkit/World.java
@@ -2248,8 +2248,10 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient @@ -2220,8 +2220,10 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient
* @return The spawned {@link FallingBlock} instance * @return The spawned {@link FallingBlock} instance
* @throws IllegalArgumentException if {@link Location} or {@link * @throws IllegalArgumentException if {@link Location} or {@link
* MaterialData} are null or {@link Material} of the {@link MaterialData} is not a block * MaterialData} are null or {@link Material} of the {@link MaterialData} is not a block
@ -24,7 +24,7 @@ index 94e6fe6257b30112066b98ec4fdb1561dbcc93c4..bc6630345bb42eb365ba0057a4c52b1e
public FallingBlock spawnFallingBlock(@NotNull Location location, @NotNull MaterialData data) throws IllegalArgumentException; public FallingBlock spawnFallingBlock(@NotNull Location location, @NotNull MaterialData data) throws IllegalArgumentException;
/** /**
@@ -2262,8 +2264,10 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient @@ -2234,8 +2236,10 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient
* @return The spawned {@link FallingBlock} instance * @return The spawned {@link FallingBlock} instance
* @throws IllegalArgumentException if {@link Location} or {@link * @throws IllegalArgumentException if {@link Location} or {@link
* BlockData} are null * BlockData} are null
@ -35,7 +35,7 @@ index 94e6fe6257b30112066b98ec4fdb1561dbcc93c4..bc6630345bb42eb365ba0057a4c52b1e
public FallingBlock spawnFallingBlock(@NotNull Location location, @NotNull BlockData data) throws IllegalArgumentException; public FallingBlock spawnFallingBlock(@NotNull Location location, @NotNull BlockData data) throws IllegalArgumentException;
/** /**
@@ -2280,7 +2284,7 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient @@ -2252,7 +2256,7 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient
* @return The spawned {@link FallingBlock} instance * @return The spawned {@link FallingBlock} instance
* @throws IllegalArgumentException if {@link Location} or {@link * @throws IllegalArgumentException if {@link Location} or {@link
* Material} are null or {@link Material} is not a block * Material} are null or {@link Material} is not a block

Datei anzeigen

@ -5,15 +5,15 @@ 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 diff --git a/src/main/java/org/bukkit/projectiles/ProjectileSource.java b/src/main/java/org/bukkit/projectiles/ProjectileSource.java
index eabd8b926ec1c934cd7e77b7cc6adfae16771021..5a2dcb1dbd0a875ff9cf5fd01445196a947f2fdc 100644 index eabd8b926ec1c934cd7e77b7cc6adfae16771021..96ebd30d339060758e726e9e1e7428d1d0813c17 100644
--- a/src/main/java/org/bukkit/projectiles/ProjectileSource.java --- a/src/main/java/org/bukkit/projectiles/ProjectileSource.java
+++ b/src/main/java/org/bukkit/projectiles/ProjectileSource.java +++ b/src/main/java/org/bukkit/projectiles/ProjectileSource.java
@@ -31,4 +31,24 @@ public interface ProjectileSource { @@ -31,4 +31,23 @@ public interface ProjectileSource {
*/ */
@NotNull @NotNull
public <T extends Projectile> T launchProjectile(@NotNull Class<? extends T> projectile, @Nullable Vector velocity); public <T extends Projectile> T launchProjectile(@NotNull Class<? extends T> projectile, @Nullable Vector velocity);
+ +
+ // Paper start + // Paper start - add consumer to launchProjectile
+ /** + /**
+ * Launches a {@link Projectile} from the ProjectileSource with an + * Launches a {@link Projectile} from the ProjectileSource with an
+ * initial velocity, with the supplied function run before the + * initial velocity, with the supplied function run before the
@ -29,7 +29,6 @@ index eabd8b926ec1c934cd7e77b7cc6adfae16771021..5a2dcb1dbd0a875ff9cf5fd01445196a
+ * @param function the function to be run before the entity is spawned + * @param function the function to be run before the entity is spawned
+ * @return the launched projectile + * @return the launched projectile
+ */ + */
+ @NotNull + <T extends Projectile> @NotNull T launchProjectile(@NotNull Class<? extends T> projectile, @Nullable Vector velocity, java.util.function.@Nullable Consumer<? super T> function);
+ public <T extends Projectile> T launchProjectile(@NotNull Class<? extends T> projectile, @Nullable Vector velocity, @Nullable java.util.function.Consumer<T> function); + // Paper end - add consumer to launchProjectile
+ // Paper end
} }

Datei anzeigen

@ -5,10 +5,10 @@ Subject: [PATCH] Add predicate for blocks when raytracing
diff --git a/src/main/java/org/bukkit/World.java b/src/main/java/org/bukkit/World.java diff --git a/src/main/java/org/bukkit/World.java b/src/main/java/org/bukkit/World.java
index bc6630345bb42eb365ba0057a4c52b1e10c6a05a..5eb3521f5f91b0684b4beebf4f7ba2c795b41c42 100644 index 298e63e0ca9d4cbac3172fd93a217af79fad91df..f72f0f0f8eee95f95adc969d55ba7de82ee30e2a 100644
--- a/src/main/java/org/bukkit/World.java --- a/src/main/java/org/bukkit/World.java
+++ b/src/main/java/org/bukkit/World.java +++ b/src/main/java/org/bukkit/World.java
@@ -1720,6 +1720,27 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient @@ -1692,6 +1692,27 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient
@Nullable @Nullable
public RayTraceResult rayTraceEntities(@NotNull Location start, @NotNull Vector direction, double maxDistance, double raySize, @Nullable Predicate<? super Entity> filter); public RayTraceResult rayTraceEntities(@NotNull Location start, @NotNull Vector direction, double maxDistance, double raySize, @Nullable Predicate<? super Entity> filter);
@ -36,7 +36,7 @@ index bc6630345bb42eb365ba0057a4c52b1e10c6a05a..5eb3521f5f91b0684b4beebf4f7ba2c7
/** /**
* Performs a ray trace that checks for block collisions using the blocks' * Performs a ray trace that checks for block collisions using the blocks'
* precise collision shapes. * precise collision shapes.
@@ -1783,6 +1804,34 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient @@ -1755,6 +1776,34 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient
@Nullable @Nullable
public RayTraceResult rayTraceBlocks(@NotNull Location start, @NotNull Vector direction, double maxDistance, @NotNull FluidCollisionMode fluidCollisionMode, boolean ignorePassableBlocks); public RayTraceResult rayTraceBlocks(@NotNull Location start, @NotNull Vector direction, double maxDistance, @NotNull FluidCollisionMode fluidCollisionMode, boolean ignorePassableBlocks);
@ -71,7 +71,7 @@ index bc6630345bb42eb365ba0057a4c52b1e10c6a05a..5eb3521f5f91b0684b4beebf4f7ba2c7
/** /**
* Performs a ray trace that checks for both block and entity collisions. * Performs a ray trace that checks for both block and entity collisions.
* <p> * <p>
@@ -1816,6 +1865,42 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient @@ -1788,6 +1837,42 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient
@Nullable @Nullable
public RayTraceResult rayTrace(@NotNull Location start, @NotNull Vector direction, double maxDistance, @NotNull FluidCollisionMode fluidCollisionMode, boolean ignorePassableBlocks, double raySize, @Nullable Predicate<? super Entity> filter); public RayTraceResult rayTrace(@NotNull Location start, @NotNull Vector direction, double maxDistance, @NotNull FluidCollisionMode fluidCollisionMode, boolean ignorePassableBlocks, double raySize, @Nullable Predicate<? super Entity> filter);

Datei anzeigen

@ -5,7 +5,7 @@ Subject: [PATCH] Ability to get Tile Entities from a chunk without snapshots
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftChunk.java b/src/main/java/org/bukkit/craftbukkit/CraftChunk.java diff --git a/src/main/java/org/bukkit/craftbukkit/CraftChunk.java b/src/main/java/org/bukkit/craftbukkit/CraftChunk.java
index df02963faaf8f514f4175d394e67d2df10c8a3ea..593cfd68dc0f3679c684b6a1d2036419d4f3bc0c 100644 index df02963faaf8f514f4175d394e67d2df10c8a3ea..545b14f02ac72dda30891d681eba585d19fd5e1d 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftChunk.java --- a/src/main/java/org/bukkit/craftbukkit/CraftChunk.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftChunk.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftChunk.java
@@ -127,6 +127,13 @@ public class CraftChunk implements Chunk { @@ -127,6 +127,13 @@ public class CraftChunk implements Chunk {
@ -35,7 +35,7 @@ index df02963faaf8f514f4175d394e67d2df10c8a3ea..593cfd68dc0f3679c684b6a1d2036419
+ } + }
+ +
+ @Override + @Override
+ public Collection<BlockState> getTileEntities(Predicate<Block> blockPredicate, boolean useSnapshot) { + public Collection<BlockState> getTileEntities(Predicate<? super Block> blockPredicate, boolean useSnapshot) {
+ Preconditions.checkNotNull(blockPredicate, "blockPredicate"); + Preconditions.checkNotNull(blockPredicate, "blockPredicate");
+ if (!this.isLoaded()) { + if (!this.isLoaded()) {
+ this.getWorld().getChunkAt(this.x, this.z); // Transient load for this tick + this.getWorld().getChunkAt(this.x, this.z); // Transient load for this tick

Datei anzeigen

@ -5,7 +5,7 @@ Subject: [PATCH] Add a consumer parameter to ProjectileSource#launchProjectile
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
index 03b1b9d8bf7b12343564ff6eb4fb865e4626b1e4..b31356c042b5262ccb47fe1ec56bed0791e84262 100644 index 0faed04c7794dd4fd758a151d15ad5956e4f4907..c9396a55fddba47124ad5aebe7f816d99a03659c 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
@@ -509,8 +509,15 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity { @@ -509,8 +509,15 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
@ -20,7 +20,7 @@ index 03b1b9d8bf7b12343564ff6eb4fb865e4626b1e4..b31356c042b5262ccb47fe1ec56bed07
+ +
+ @Override + @Override
+ @SuppressWarnings("unchecked") + @SuppressWarnings("unchecked")
+ public <T extends Projectile> T launchProjectile(Class<? extends T> projectile, Vector velocity, java.util.function.Consumer<T> function) { + public <T extends Projectile> T launchProjectile(Class<? extends T> projectile, Vector velocity, java.util.function.Consumer<? super T> function) {
+ // Paper end - launchProjectile consumer + // Paper end - launchProjectile consumer
Preconditions.checkState(!this.getHandle().generation, "Cannot launch projectile during world generation"); Preconditions.checkState(!this.getHandle().generation, "Cannot launch projectile during world generation");
@ -38,7 +38,7 @@ index 03b1b9d8bf7b12343564ff6eb4fb865e4626b1e4..b31356c042b5262ccb47fe1ec56bed07
world.addFreshEntity(launch); world.addFreshEntity(launch);
return (T) launch.getBukkitEntity(); return (T) launch.getBukkitEntity();
diff --git a/src/main/java/org/bukkit/craftbukkit/projectiles/CraftBlockProjectileSource.java b/src/main/java/org/bukkit/craftbukkit/projectiles/CraftBlockProjectileSource.java diff --git a/src/main/java/org/bukkit/craftbukkit/projectiles/CraftBlockProjectileSource.java b/src/main/java/org/bukkit/craftbukkit/projectiles/CraftBlockProjectileSource.java
index 7f9a716ea65f98d1c8487438949f1d5bc8becc4a..f880b0def6ee12d1e88a732ade348ac062f8ab69 100644 index 7f9a716ea65f98d1c8487438949f1d5bc8becc4a..ab684fc1b09d4eade7dd11a95065e72b842a3667 100644
--- a/src/main/java/org/bukkit/craftbukkit/projectiles/CraftBlockProjectileSource.java --- a/src/main/java/org/bukkit/craftbukkit/projectiles/CraftBlockProjectileSource.java
+++ b/src/main/java/org/bukkit/craftbukkit/projectiles/CraftBlockProjectileSource.java +++ b/src/main/java/org/bukkit/craftbukkit/projectiles/CraftBlockProjectileSource.java
@@ -56,6 +56,13 @@ public class CraftBlockProjectileSource implements BlockProjectileSource { @@ -56,6 +56,13 @@ public class CraftBlockProjectileSource implements BlockProjectileSource {
@ -50,7 +50,7 @@ index 7f9a716ea65f98d1c8487438949f1d5bc8becc4a..f880b0def6ee12d1e88a732ade348ac0
+ } + }
+ +
+ @Override + @Override
+ public <T extends Projectile> T launchProjectile(Class<? extends T> projectile, Vector velocity, java.util.function.Consumer<T> function) { + public <T extends Projectile> T launchProjectile(Class<? extends T> projectile, Vector velocity, java.util.function.Consumer<? super T> function) {
+ // Paper end - launchProjectile consumer + // Paper end - launchProjectile consumer
Preconditions.checkArgument(this.getBlock().getType() == Material.DISPENSER, "Block is no longer dispenser"); Preconditions.checkArgument(this.getBlock().getType() == Material.DISPENSER, "Block is no longer dispenser");
// Copied from BlockDispenser.dispense() // Copied from BlockDispenser.dispense()