mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-28 23:38:25 +01:00
Use ? super in Consumer/Predicate API (#9939)
This commit is contained in:
parent
3d12fa65fa
commit
cea171de11
13 changed files with 186 additions and 223 deletions
|
@ -35,7 +35,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ * @return The tile entities.
|
||||
+ */
|
||||
+ @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
|
||||
|
||||
/**
|
||||
|
|
|
@ -55,8 +55,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
--- a/src/main/java/org/bukkit/Location.java
|
||||
+++ b/src/main/java/org/bukkit/Location.java
|
||||
@@ -0,0 +0,0 @@ public class Location implements Cloneable, ConfigurationSerializable, io.paperm
|
||||
return centerLoc;
|
||||
}
|
||||
// Paper end - expand Location API
|
||||
|
||||
+ // Paper start - Add heightmap api
|
||||
+ /**
|
||||
|
|
|
@ -13,7 +13,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
@NotNull
|
||||
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
|
||||
+ * initial velocity, with the supplied function run before the
|
||||
|
@ -29,7 +29,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ * @param function the function to be run before the entity is spawned
|
||||
+ * @return the launched projectile
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ public <T extends Projectile> T launchProjectile(@NotNull Class<? extends T> projectile, @Nullable Vector velocity, @Nullable java.util.function.Consumer<T> function);
|
||||
+ // Paper end
|
||||
+ <T extends Projectile> @NotNull T launchProjectile(@NotNull Class<? extends T> projectile, @Nullable Vector velocity, java.util.function.@Nullable Consumer<? super T> function);
|
||||
+ // Paper end - add consumer to launchProjectile
|
||||
}
|
||||
|
|
|
@ -25,23 +25,22 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
* Represents a 3-dimensional position in a world.
|
||||
* <br>
|
||||
@@ -0,0 +0,0 @@ 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.
|
||||
+ *
|
||||
+ * <p>
|
||||
+ * 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 y 1/2 the size of the box along y axis
|
||||
+ * @param z 1/2 the size of the box along z axis
|
||||
+ * @param x 1/2 the size of the box along the x-axis
|
||||
+ * @param y 1/2 the size of the box along the y-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.
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ public Collection<Entity> getNearbyEntities(double x, double y, double z) {
|
||||
+ World world = this.getWorld();
|
||||
+ public @NotNull Collection<Entity> getNearbyEntities(final double x, final double y, final double z) {
|
||||
+ final World world = this.getWorld();
|
||||
+ if (world == null) {
|
||||
+ throw new IllegalArgumentException("Location has no world");
|
||||
+ }
|
||||
|
@ -53,9 +52,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ * @param radius X Radius
|
||||
+ * @return the collection of entities near location. This will always be a non-null collection.
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ public Collection<LivingEntity> getNearbyLivingEntities(double radius) {
|
||||
+ return getNearbyEntitiesByType(org.bukkit.entity.LivingEntity.class, radius, radius, radius);
|
||||
+ public @NotNull Collection<LivingEntity> getNearbyLivingEntities(final double radius) {
|
||||
+ return this.getNearbyEntitiesByType(LivingEntity.class, radius, radius, radius);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
|
@ -64,9 +62,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ * @param yRadius Y Radius
|
||||
+ * @return the collection of living entities near location. This will always be a non-null collection.
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ public Collection<LivingEntity> getNearbyLivingEntities(double xzRadius, double yRadius) {
|
||||
+ return getNearbyEntitiesByType(org.bukkit.entity.LivingEntity.class, xzRadius, yRadius, xzRadius);
|
||||
+ public @NotNull Collection<LivingEntity> getNearbyLivingEntities(final double xzRadius, final double yRadius) {
|
||||
+ return this.getNearbyEntitiesByType(LivingEntity.class, xzRadius, yRadius, xzRadius);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
|
@ -76,9 +73,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ * @param zRadius Z radius
|
||||
+ * @return the collection of living entities near location. This will always be a non-null collection.
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ public Collection<LivingEntity> getNearbyLivingEntities(double xRadius, double yRadius, double zRadius) {
|
||||
+ return getNearbyEntitiesByType(org.bukkit.entity.LivingEntity.class, xRadius, yRadius, zRadius);
|
||||
+ public @NotNull Collection<LivingEntity> getNearbyLivingEntities(final double xRadius, final double yRadius, final double zRadius) {
|
||||
+ return this.getNearbyEntitiesByType(LivingEntity.class, xRadius, yRadius, zRadius);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
|
@ -87,9 +83,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ * @param predicate a predicate used to filter results
|
||||
+ * @return the collection of living entities near location. This will always be a non-null collection.
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ public Collection<LivingEntity> getNearbyLivingEntities(double radius, @Nullable Predicate<LivingEntity> predicate) {
|
||||
+ return getNearbyEntitiesByType(org.bukkit.entity.LivingEntity.class, radius, radius, radius, predicate);
|
||||
+ public @NotNull Collection<LivingEntity> getNearbyLivingEntities(final double radius, final @Nullable Predicate<? super LivingEntity> predicate) {
|
||||
+ return this.getNearbyEntitiesByType(LivingEntity.class, radius, radius, radius, predicate);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
|
@ -99,9 +94,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ * @param predicate a predicate used to filter results
|
||||
+ * @return the collection of living entities near location. This will always be a non-null collection.
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ public Collection<LivingEntity> getNearbyLivingEntities(double xzRadius, double yRadius, @Nullable Predicate<LivingEntity> predicate) {
|
||||
+ return getNearbyEntitiesByType(org.bukkit.entity.LivingEntity.class, xzRadius, yRadius, xzRadius, predicate);
|
||||
+ public @NotNull Collection<LivingEntity> getNearbyLivingEntities(final double xzRadius, final double yRadius, final @Nullable Predicate<? super LivingEntity> predicate) {
|
||||
+ return this.getNearbyEntitiesByType(LivingEntity.class, xzRadius, yRadius, xzRadius, predicate);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
|
@ -112,9 +106,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ * @param predicate a predicate used to filter results
|
||||
+ * @return the collection of living entities near location. This will always be a non-null collection.
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ public Collection<LivingEntity> getNearbyLivingEntities(double xRadius, double yRadius, double zRadius, @Nullable Predicate<LivingEntity> predicate) {
|
||||
+ return getNearbyEntitiesByType(org.bukkit.entity.LivingEntity.class, xRadius, yRadius, zRadius, predicate);
|
||||
+ public @NotNull Collection<LivingEntity> getNearbyLivingEntities(final double xRadius, final double yRadius, final double zRadius, final @Nullable Predicate<? super LivingEntity> predicate) {
|
||||
+ return this.getNearbyEntitiesByType(LivingEntity.class, xRadius, yRadius, zRadius, predicate);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
|
@ -122,9 +115,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ * @param radius X/Y/Z Radius
|
||||
+ * @return the collection of players near location. This will always be a non-null collection.
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ public Collection<Player> getNearbyPlayers(double radius) {
|
||||
+ return getNearbyEntitiesByType(org.bukkit.entity.Player.class, radius, radius, radius);
|
||||
+ public @NotNull Collection<Player> getNearbyPlayers(final double radius) {
|
||||
+ return this.getNearbyEntitiesByType(Player.class, radius, radius, radius);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
|
@ -133,9 +125,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ * @param yRadius Y Radius
|
||||
+ * @return the collection of players near location. This will always be a non-null collection.
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ public Collection<Player> getNearbyPlayers(double xzRadius, double yRadius) {
|
||||
+ return getNearbyEntitiesByType(org.bukkit.entity.Player.class, xzRadius, yRadius, xzRadius);
|
||||
+ public @NotNull Collection<Player> getNearbyPlayers(final double xzRadius, final double yRadius) {
|
||||
+ return this.getNearbyEntitiesByType(Player.class, xzRadius, yRadius, xzRadius);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
|
@ -145,9 +136,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ * @param zRadius Z Radius
|
||||
+ * @return the collection of players near location. This will always be a non-null collection.
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ public Collection<Player> getNearbyPlayers(double xRadius, double yRadius, double zRadius) {
|
||||
+ return getNearbyEntitiesByType(org.bukkit.entity.Player.class, xRadius, yRadius, zRadius);
|
||||
+ public @NotNull Collection<Player> getNearbyPlayers(final double xRadius, final double yRadius, final double zRadius) {
|
||||
+ return this.getNearbyEntitiesByType(Player.class, xRadius, yRadius, zRadius);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
|
@ -156,9 +146,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ * @param predicate a predicate used to filter results
|
||||
+ * @return the collection of players near location. This will always be a non-null collection.
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ public Collection<Player> getNearbyPlayers(double radius, @Nullable Predicate<Player> predicate) {
|
||||
+ return getNearbyEntitiesByType(org.bukkit.entity.Player.class, radius, radius, radius, predicate);
|
||||
+ public @NotNull Collection<Player> getNearbyPlayers(final double radius, final @Nullable Predicate<? super Player> predicate) {
|
||||
+ return this.getNearbyEntitiesByType(Player.class, radius, radius, radius, predicate);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
|
@ -168,9 +157,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ * @param predicate a predicate used to filter results
|
||||
+ * @return the collection of players near location. This will always be a non-null collection.
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ public Collection<Player> getNearbyPlayers(double xzRadius, double yRadius, @Nullable Predicate<Player> predicate) {
|
||||
+ return getNearbyEntitiesByType(org.bukkit.entity.Player.class, xzRadius, yRadius, xzRadius, predicate);
|
||||
+ public @NotNull Collection<Player> getNearbyPlayers(final double xzRadius, final double yRadius, final @Nullable Predicate<? super Player> predicate) {
|
||||
+ return this.getNearbyEntitiesByType(Player.class, xzRadius, yRadius, xzRadius, predicate);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
|
@ -181,9 +169,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ * @param predicate a predicate used to filter results
|
||||
+ * @return the collection of players near location. This will always be a non-null collection.
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ public Collection<Player> getNearbyPlayers(double xRadius, double yRadius, double zRadius, @Nullable Predicate<Player> predicate) {
|
||||
+ return getNearbyEntitiesByType(org.bukkit.entity.Player.class, xRadius, yRadius, zRadius, predicate);
|
||||
+ public @NotNull Collection<Player> getNearbyPlayers(final double xRadius, final double yRadius, final double zRadius, final @Nullable Predicate<? super Player> predicate) {
|
||||
+ return this.getNearbyEntitiesByType(Player.class, xRadius, yRadius, zRadius, predicate);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
|
@ -193,9 +180,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ * @param <T> the entity type
|
||||
+ * @return the collection of entities of type clazz near location. This will always be a non-null collection.
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ public <T extends Entity> Collection<T> getNearbyEntitiesByType(@Nullable Class<? extends T> clazz, double radius) {
|
||||
+ return getNearbyEntitiesByType(clazz, radius, radius, radius, null);
|
||||
+ public @NotNull <T extends Entity> Collection<T> getNearbyEntitiesByType(final @Nullable Class<? extends T> clazz, final double radius) {
|
||||
+ return this.getNearbyEntitiesByType(clazz, radius, radius, radius, null);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
|
@ -206,9 +192,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ * @param <T> the entity type
|
||||
+ * @return the collection of entities near location. This will always be a non-null collection.
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ public <T extends Entity> Collection<T> getNearbyEntitiesByType(@Nullable Class<? extends T> clazz, double xzRadius, double yRadius) {
|
||||
+ return getNearbyEntitiesByType(clazz, xzRadius, yRadius, xzRadius, null);
|
||||
+ public @NotNull <T extends Entity> Collection<T> getNearbyEntitiesByType(final @Nullable Class<? extends T> clazz, final double xzRadius, final double yRadius) {
|
||||
+ return this.getNearbyEntitiesByType(clazz, xzRadius, yRadius, xzRadius, null);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
|
@ -220,9 +205,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ * @param <T> the entity type
|
||||
+ * @return the collection of entities near location. This will always be a non-null collection.
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ public <T extends Entity> Collection<T> getNearbyEntitiesByType(@Nullable Class<? extends T> clazz, double xRadius, double yRadius, double zRadius) {
|
||||
+ return getNearbyEntitiesByType(clazz, xRadius, yRadius, zRadius, null);
|
||||
+ public @NotNull <T extends Entity> Collection<T> getNearbyEntitiesByType(final @Nullable Class<? extends T> clazz, final double xRadius, final double yRadius, final double zRadius) {
|
||||
+ return this.getNearbyEntitiesByType(clazz, xRadius, yRadius, zRadius, null);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
|
@ -233,9 +217,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ * @param <T> the entity type
|
||||
+ * @return the collection of entities near location. This will always be a non-null collection.
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ public <T extends Entity> Collection<T> getNearbyEntitiesByType(@Nullable Class<? extends T> clazz, double radius, @Nullable Predicate<T> predicate) {
|
||||
+ return getNearbyEntitiesByType(clazz, radius, radius, radius, predicate);
|
||||
+ public @NotNull <T extends Entity> Collection<T> getNearbyEntitiesByType(final @Nullable Class<? extends T> clazz, final double radius, final @Nullable Predicate<? super T> predicate) {
|
||||
+ return this.getNearbyEntitiesByType(clazz, radius, radius, radius, predicate);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
|
@ -247,9 +230,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ * @param <T> the entity type
|
||||
+ * @return the collection of entities near location. This will always be a non-null collection.
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ public <T extends Entity> Collection<T> getNearbyEntitiesByType(@Nullable Class<? extends T> clazz, double xzRadius, double yRadius, @Nullable Predicate<T> predicate) {
|
||||
+ return getNearbyEntitiesByType(clazz, xzRadius, yRadius, xzRadius, predicate);
|
||||
+ 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) {
|
||||
+ return this.getNearbyEntitiesByType(clazz, xzRadius, yRadius, xzRadius, predicate);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
|
@ -262,14 +244,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ * @param <T> the entity type
|
||||
+ * @return the collection of entities near location. This will always be a non-null collection.
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ public <T extends Entity> Collection<T> getNearbyEntitiesByType(@Nullable Class<? extends Entity> clazz, double xRadius, double yRadius, double zRadius, @Nullable Predicate<T> predicate) {
|
||||
+ World world = this.getWorld();
|
||||
+ 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) {
|
||||
+ final World world = this.getWorld();
|
||||
+ if (world == null) {
|
||||
+ throw new IllegalArgumentException("Location has no world");
|
||||
+ }
|
||||
+ return world.getNearbyEntitiesByType(clazz, this, xRadius, yRadius, zRadius, predicate);
|
||||
+ }
|
||||
// Paper end
|
||||
+ // Paper end - additional getNearbyEntities API
|
||||
+
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == null) {
|
||||
|
|
|
@ -23,16 +23,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
@NotNull
|
||||
public Collection<Entity> getEntitiesByClasses(@NotNull Class<?>... classes);
|
||||
|
||||
+ // Paper start
|
||||
+ // Paper start - additional getNearbyEntities API
|
||||
+ /**
|
||||
+ * Gets nearby LivingEntities within the specified radius (bounding box)
|
||||
+ * @param loc Center location
|
||||
+ * @param radius Radius
|
||||
+ * @return the collection of entities near location. This will always be a non-null collection.
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ public default Collection<LivingEntity> getNearbyLivingEntities(@NotNull Location loc, double radius) {
|
||||
+ return getNearbyEntitiesByType(org.bukkit.entity.LivingEntity.class, loc, radius, radius, radius);
|
||||
+ default @NotNull Collection<LivingEntity> getNearbyLivingEntities(final @NotNull Location loc, final double radius) {
|
||||
+ return this.getNearbyEntitiesByType(LivingEntity.class, loc, radius, radius, radius);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
|
@ -42,9 +41,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ * @param yRadius Y Radius
|
||||
+ * @return the collection of entities near location. This will always be a non-null collection.
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ public default Collection<LivingEntity> getNearbyLivingEntities(@NotNull Location loc, double xzRadius, double yRadius) {
|
||||
+ return getNearbyEntitiesByType(org.bukkit.entity.LivingEntity.class, loc, xzRadius, yRadius, xzRadius);
|
||||
+ default @NotNull Collection<LivingEntity> getNearbyLivingEntities(final @NotNull Location loc, final double xzRadius, final double yRadius) {
|
||||
+ return this.getNearbyEntitiesByType(LivingEntity.class, loc, xzRadius, yRadius, xzRadius);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
|
@ -55,9 +53,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ * @param zRadius Z radius
|
||||
+ * @return the collection of entities near location. This will always be a non-null collection.
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ public default Collection<LivingEntity> getNearbyLivingEntities(@NotNull Location loc, double xRadius, double yRadius, double zRadius) {
|
||||
+ return getNearbyEntitiesByType(org.bukkit.entity.LivingEntity.class, loc, xRadius, yRadius, zRadius);
|
||||
+ default @NotNull Collection<LivingEntity> getNearbyLivingEntities(final @NotNull Location loc, final double xRadius, final double yRadius, final double zRadius) {
|
||||
+ return this.getNearbyEntitiesByType(LivingEntity.class, loc, xRadius, yRadius, zRadius);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
|
@ -67,9 +64,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ * @param predicate a predicate used to filter results
|
||||
+ * @return the collection of living entities near location. This will always be a non-null collection
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ public default Collection<LivingEntity> getNearbyLivingEntities(@NotNull Location loc, double radius, @Nullable Predicate<LivingEntity> predicate) {
|
||||
+ return getNearbyEntitiesByType(org.bukkit.entity.LivingEntity.class, loc, radius, radius, radius, predicate);
|
||||
+ default @NotNull Collection<LivingEntity> getNearbyLivingEntities(final @NotNull Location loc, final double radius, final @Nullable Predicate<? super LivingEntity> predicate) {
|
||||
+ return this.getNearbyEntitiesByType(LivingEntity.class, loc, radius, radius, radius, predicate);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
|
@ -80,9 +76,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ * @param predicate a predicate used to filter results
|
||||
+ * @return the collection of living entities near location. This will always be a non-null collection
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ public default Collection<LivingEntity> getNearbyLivingEntities(@NotNull Location loc, double xzRadius, double yRadius, @Nullable Predicate<LivingEntity> predicate) {
|
||||
+ return getNearbyEntitiesByType(org.bukkit.entity.LivingEntity.class, loc, xzRadius, yRadius, xzRadius, predicate);
|
||||
+ default @NotNull Collection<LivingEntity> getNearbyLivingEntities(final @NotNull Location loc, final double xzRadius, final double yRadius, final @Nullable Predicate<? super LivingEntity> predicate) {
|
||||
+ return this.getNearbyEntitiesByType(LivingEntity.class, loc, xzRadius, yRadius, xzRadius, predicate);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
|
@ -94,9 +89,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ * @param predicate a predicate used to filter results
|
||||
+ * @return the collection of living entities near location. This will always be a non-null collection.
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ public default Collection<LivingEntity> getNearbyLivingEntities(@NotNull Location loc, double xRadius, double yRadius, double zRadius, @Nullable Predicate<LivingEntity> predicate) {
|
||||
+ return getNearbyEntitiesByType(org.bukkit.entity.LivingEntity.class, loc, xRadius, yRadius, zRadius, predicate);
|
||||
+ default @NotNull Collection<LivingEntity> getNearbyLivingEntities(final @NotNull Location loc, final double xRadius, final double yRadius, final double zRadius, final @Nullable Predicate<? super LivingEntity> predicate) {
|
||||
+ return this.getNearbyEntitiesByType(LivingEntity.class, loc, xRadius, yRadius, zRadius, predicate);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
|
@ -105,9 +99,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ * @param radius X/Y/Z Radius
|
||||
+ * @return the collection of living entities near location. This will always be a non-null collection.
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ public default Collection<Player> getNearbyPlayers(@NotNull Location loc, double radius) {
|
||||
+ return getNearbyEntitiesByType(org.bukkit.entity.Player.class, loc, radius, radius, radius);
|
||||
+ default @NotNull Collection<Player> getNearbyPlayers(final @NotNull Location loc, final double radius) {
|
||||
+ return this.getNearbyEntitiesByType(Player.class, loc, radius, radius, radius);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
|
@ -117,9 +110,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ * @param yRadius Y Radius
|
||||
+ * @return the collection of living entities near location. This will always be a non-null collection.
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ public default Collection<Player> getNearbyPlayers(@NotNull Location loc, double xzRadius, double yRadius) {
|
||||
+ return getNearbyEntitiesByType(org.bukkit.entity.Player.class, loc, xzRadius, yRadius, xzRadius);
|
||||
+ default @NotNull Collection<Player> getNearbyPlayers(final @NotNull Location loc, final double xzRadius, final double yRadius) {
|
||||
+ return this.getNearbyEntitiesByType(Player.class, loc, xzRadius, yRadius, xzRadius);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
|
@ -130,9 +122,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ * @param zRadius Z Radius
|
||||
+ * @return the collection of players near location. This will always be a non-null collection.
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ public default Collection<Player> getNearbyPlayers(@NotNull Location loc, double xRadius, double yRadius, double zRadius) {
|
||||
+ return getNearbyEntitiesByType(org.bukkit.entity.Player.class, loc, xRadius, yRadius, zRadius);
|
||||
+ default @NotNull Collection<Player> getNearbyPlayers(final @NotNull Location loc, final double xRadius, final double yRadius, final double zRadius) {
|
||||
+ return this.getNearbyEntitiesByType(Player.class, loc, xRadius, yRadius, zRadius);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
|
@ -142,9 +133,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ * @param predicate a predicate used to filter results
|
||||
+ * @return the collection of players near location. This will always be a non-null collection.
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ public default Collection<Player> getNearbyPlayers(@NotNull Location loc, double radius, @Nullable Predicate<Player> predicate) {
|
||||
+ return getNearbyEntitiesByType(org.bukkit.entity.Player.class, loc, radius, radius, radius, predicate);
|
||||
+ default @NotNull Collection<Player> getNearbyPlayers(final @NotNull Location loc, final double radius, final @Nullable Predicate<? super Player> predicate) {
|
||||
+ return this.getNearbyEntitiesByType(Player.class, loc, radius, radius, radius, predicate);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
|
@ -155,9 +145,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ * @param predicate a predicate used to filter results
|
||||
+ * @return the collection of players near location. This will always be a non-null collection.
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ public default Collection<Player> getNearbyPlayers(@NotNull Location loc, double xzRadius, double yRadius, @Nullable Predicate<Player> predicate) {
|
||||
+ return getNearbyEntitiesByType(org.bukkit.entity.Player.class, loc, xzRadius, yRadius, xzRadius, predicate);
|
||||
+ default @NotNull Collection<Player> getNearbyPlayers(final @NotNull Location loc, final double xzRadius, final double yRadius, final @Nullable Predicate<? super Player> predicate) {
|
||||
+ return this.getNearbyEntitiesByType(Player.class, loc, xzRadius, yRadius, xzRadius, predicate);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
|
@ -169,9 +158,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ * @param predicate a predicate used to filter results
|
||||
+ * @return the collection of players near location. This will always be a non-null collection.
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ public default Collection<Player> getNearbyPlayers(@NotNull Location loc, double xRadius, double yRadius, double zRadius, @Nullable Predicate<Player> predicate) {
|
||||
+ return getNearbyEntitiesByType(org.bukkit.entity.Player.class, loc, xRadius, yRadius, zRadius, predicate);
|
||||
+ default @NotNull Collection<Player> getNearbyPlayers(final @NotNull Location loc, final double xRadius, final double yRadius, final double zRadius, final @Nullable Predicate<? super Player> predicate) {
|
||||
+ return this.getNearbyEntitiesByType(Player.class, loc, xRadius, yRadius, zRadius, predicate);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
|
@ -182,9 +170,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ * @param <T> the entity type
|
||||
+ * @return the collection of entities near location. This will always be a non-null collection.
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ public default <T extends Entity> Collection<T> getNearbyEntitiesByType(@Nullable Class<? extends T> clazz, @NotNull Location loc, double radius) {
|
||||
+ return getNearbyEntitiesByType(clazz, loc, radius, radius, radius, null);
|
||||
+ default @NotNull <T extends Entity> Collection<T> getNearbyEntitiesByType(final @Nullable Class<? extends T> clazz, final @NotNull Location loc, final double radius) {
|
||||
+ return this.getNearbyEntitiesByType(clazz, loc, radius, radius, radius, null);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
|
@ -196,9 +183,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ * @param <T> the entity type
|
||||
+ * @return the collection of entities near location. This will always be a non-null collection.
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ public default <T extends Entity> Collection<T> getNearbyEntitiesByType(@Nullable Class<? extends T> clazz, @NotNull Location loc, double xzRadius, double yRadius) {
|
||||
+ return getNearbyEntitiesByType(clazz, loc, xzRadius, yRadius, xzRadius, null);
|
||||
+ default @NotNull <T extends Entity> Collection<T> getNearbyEntitiesByType(final @Nullable Class<? extends T> clazz, final @NotNull Location loc, final double xzRadius, final double yRadius) {
|
||||
+ return this.getNearbyEntitiesByType(clazz, loc, xzRadius, yRadius, xzRadius, null);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
|
@ -211,9 +197,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ * @param <T> the entity type
|
||||
+ * @return the collection of entities near location. This will always be a non-null collection.
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ public default <T extends Entity> Collection<T> getNearbyEntitiesByType(@Nullable Class<? extends T> clazz, @NotNull Location loc, double xRadius, double yRadius, double zRadius) {
|
||||
+ return getNearbyEntitiesByType(clazz, loc, xRadius, yRadius, zRadius, null);
|
||||
+ 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) {
|
||||
+ return this.getNearbyEntitiesByType(clazz, loc, xRadius, yRadius, zRadius, null);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
|
@ -225,9 +210,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ * @param <T> the entity type
|
||||
+ * @return the collection of entities near location. This will always be a non-null collection.
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ public default <T extends Entity> Collection<T> getNearbyEntitiesByType(@Nullable Class<? extends T> clazz, @NotNull Location loc, double radius, @Nullable Predicate<T> predicate) {
|
||||
+ return getNearbyEntitiesByType(clazz, loc, radius, radius, radius, predicate);
|
||||
+ 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) {
|
||||
+ return this.getNearbyEntitiesByType(clazz, loc, radius, radius, radius, predicate);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
|
@ -240,9 +224,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ * @param <T> the entity type
|
||||
+ * @return the collection of entities near location. This will always be a non-null collection.
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ 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 getNearbyEntitiesByType(clazz, loc, xzRadius, yRadius, xzRadius, predicate);
|
||||
+ 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) {
|
||||
+ return this.getNearbyEntitiesByType(clazz, loc, xzRadius, yRadius, xzRadius, predicate);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
|
@ -256,13 +239,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ * @param <T> the entity type
|
||||
+ * @return the collection of entities near location. This will always be a non-null collection.
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ 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) {
|
||||
+ 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) {
|
||||
+ if (clazz == null) {
|
||||
+ clazz = Entity.class;
|
||||
+ }
|
||||
+ List<T> nearby = new ArrayList<>();
|
||||
+ for (Entity bukkitEntity : getNearbyEntities(loc, xRadius, yRadius, zRadius)) {
|
||||
+ final List<T> nearby = new ArrayList<>();
|
||||
+ for (final Entity bukkitEntity : this.getNearbyEntities(loc, xRadius, yRadius, zRadius)) {
|
||||
+ //noinspection unchecked
|
||||
+ if (clazz.isAssignableFrom(bukkitEntity.getClass()) && (predicate == null || predicate.test((T) bukkitEntity))) {
|
||||
+ //noinspection unchecked
|
||||
|
@ -271,7 +253,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ }
|
||||
+ return nearby;
|
||||
+ }
|
||||
+ // Paper end
|
||||
+ // Paper end - additional getNearbyEntities API
|
||||
+
|
||||
/**
|
||||
* Get a list of all players in this World
|
||||
|
|
|
@ -12,10 +12,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
--- a/src/main/java/org/bukkit/World.java
|
||||
+++ b/src/main/java/org/bukkit/World.java
|
||||
@@ -0,0 +0,0 @@ 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,
|
||||
+ * as well as future support
|
||||
|
@ -139,8 +139,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ * @param cb Callback to receive the chunk when it is loaded.
|
||||
+ * will be executed synchronously
|
||||
+ */
|
||||
+ public default void getChunkAtAsync(int x, int z, @NotNull java.util.function.Consumer<Chunk> cb) {
|
||||
+ getChunkAtAsync(x, z, true).thenAccept(cb).exceptionally((ex) -> {
|
||||
+ default void getChunkAtAsync(final int x, final int z, final @NotNull Consumer<? super Chunk> cb) {
|
||||
+ this.getChunkAtAsync(x, z, true).thenAccept(cb).exceptionally((ex) -> {
|
||||
+ Bukkit.getLogger().log(java.util.logging.Level.WARNING, "Exception in chunk load callback", ex);
|
||||
+ return null;
|
||||
+ });
|
||||
|
@ -165,8 +165,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ * @param cb Callback to receive the chunk when it is loaded.
|
||||
+ * will be executed synchronously
|
||||
+ */
|
||||
+ public default void getChunkAtAsync(int x, int z, boolean gen, @NotNull java.util.function.Consumer<Chunk> cb) {
|
||||
+ getChunkAtAsync(x, z, gen).thenAccept(cb).exceptionally((ex) -> {
|
||||
+ default void getChunkAtAsync(final int x, final int z, final boolean gen, final @NotNull Consumer<? super Chunk> cb) {
|
||||
+ this.getChunkAtAsync(x, z, gen).thenAccept(cb).exceptionally((ex) -> {
|
||||
+ Bukkit.getLogger().log(java.util.logging.Level.WARNING, "Exception in chunk load callback", ex);
|
||||
+ return null;
|
||||
+ });
|
||||
|
@ -189,8 +189,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ * @param cb Callback to receive the chunk when it is loaded.
|
||||
+ * will be executed synchronously
|
||||
+ */
|
||||
+ public default void getChunkAtAsync(@NotNull Location loc, @NotNull java.util.function.Consumer<Chunk> cb) {
|
||||
+ getChunkAtAsync((int)Math.floor(loc.getX()) >> 4, (int)Math.floor(loc.getZ()) >> 4, true, cb);
|
||||
+ default void getChunkAtAsync(final @NotNull Location loc, final @NotNull Consumer<? super Chunk> cb) {
|
||||
+ this.getChunkAtAsync((int) Math.floor(loc.getX()) >> 4, (int) Math.floor(loc.getZ()) >> 4, true, cb);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
|
@ -211,8 +211,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ * @param cb Callback to receive the chunk when it is loaded.
|
||||
+ * will be executed synchronously
|
||||
+ */
|
||||
+ public default void getChunkAtAsync(@NotNull Location loc, boolean gen, @NotNull java.util.function.Consumer<Chunk> cb) {
|
||||
+ getChunkAtAsync((int)Math.floor(loc.getX()) >> 4, (int)Math.floor(loc.getZ()) >> 4, gen, cb);
|
||||
+ default void getChunkAtAsync(final @NotNull Location loc, final boolean gen, final @NotNull Consumer<? super Chunk> cb) {
|
||||
+ this.getChunkAtAsync((int) Math.floor(loc.getX()) >> 4, (int) Math.floor(loc.getZ()) >> 4, gen, cb);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
|
@ -232,8 +232,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ * @param cb Callback to receive the chunk when it is loaded.
|
||||
+ * will be executed synchronously
|
||||
+ */
|
||||
+ public default void getChunkAtAsync(@NotNull Block block, @NotNull java.util.function.Consumer<Chunk> cb) {
|
||||
+ getChunkAtAsync(block.getX() >> 4, block.getZ() >> 4, true, cb);
|
||||
+ default void getChunkAtAsync(final @NotNull Block block, final @NotNull Consumer<? super Chunk> cb) {
|
||||
+ this.getChunkAtAsync(block.getX() >> 4, block.getZ() >> 4, true, cb);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
|
@ -254,8 +254,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ * @param cb Callback to receive the chunk when it is loaded.
|
||||
+ * will be executed synchronously
|
||||
+ */
|
||||
+ public default void getChunkAtAsync(@NotNull Block block, boolean gen, @NotNull java.util.function.Consumer<Chunk> cb) {
|
||||
+ getChunkAtAsync(block.getX() >> 4, block.getZ() >> 4, gen, cb);
|
||||
+ default void getChunkAtAsync(final @NotNull Block block, final boolean gen, final @NotNull Consumer<? super Chunk> cb) {
|
||||
+ this.getChunkAtAsync(block.getX() >> 4, block.getZ() >> 4, gen, cb);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
|
@ -273,9 +273,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ * @param loc Location to load the corresponding chunk from
|
||||
+ * @return Future that will resolve when the chunk is loaded
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ public default java.util.concurrent.CompletableFuture<Chunk> getChunkAtAsync(@NotNull Location loc) {
|
||||
+ return getChunkAtAsync((int)Math.floor(loc.getX()) >> 4, (int)Math.floor(loc.getZ()) >> 4, true);
|
||||
+ default @NotNull java.util.concurrent.CompletableFuture<Chunk> getChunkAtAsync(final @NotNull Location loc) {
|
||||
+ return this.getChunkAtAsync((int) Math.floor(loc.getX()) >> 4, (int) Math.floor(loc.getZ()) >> 4, true);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
|
@ -294,9 +293,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ * @param gen Should the chunk generate if it doesn't exist
|
||||
+ * @return Future that will resolve when the chunk is loaded
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ public default java.util.concurrent.CompletableFuture<Chunk> getChunkAtAsync(@NotNull Location loc, boolean gen) {
|
||||
+ return getChunkAtAsync((int)Math.floor(loc.getX()) >> 4, (int)Math.floor(loc.getZ()) >> 4, gen);
|
||||
+ default @NotNull java.util.concurrent.CompletableFuture<Chunk> getChunkAtAsync(final @NotNull Location loc, final boolean gen) {
|
||||
+ return this.getChunkAtAsync((int) Math.floor(loc.getX()) >> 4, (int) Math.floor(loc.getZ()) >> 4, gen);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
|
@ -314,9 +312,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ * @param block Block to load the corresponding chunk from
|
||||
+ * @return Future that will resolve when the chunk is loaded
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ public default java.util.concurrent.CompletableFuture<Chunk> getChunkAtAsync(@NotNull Block block) {
|
||||
+ return getChunkAtAsync(block.getX() >> 4, block.getZ() >> 4, true);
|
||||
+ default @NotNull java.util.concurrent.CompletableFuture<Chunk> getChunkAtAsync(final @NotNull Block block) {
|
||||
+ return this.getChunkAtAsync(block.getX() >> 4, block.getZ() >> 4, true);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
|
@ -335,9 +332,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ * @param gen Should the chunk generate if it doesn't exist
|
||||
+ * @return Future that will resolve when the chunk is loaded
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ public default java.util.concurrent.CompletableFuture<Chunk> getChunkAtAsync(@NotNull Block block, boolean gen) {
|
||||
+ return getChunkAtAsync(block.getX() >> 4, block.getZ() >> 4, gen);
|
||||
+ default @NotNull java.util.concurrent.CompletableFuture<Chunk> getChunkAtAsync(final @NotNull Block block, final boolean gen) {
|
||||
+ return this.getChunkAtAsync(block.getX() >> 4, block.getZ() >> 4, gen);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
|
@ -357,9 +353,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ * @param z Chunk Z-coordinate of the chunk - floor(world coordinate / 16)
|
||||
+ * @return Future that will resolve when the chunk is loaded
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ public default java.util.concurrent.CompletableFuture<Chunk> getChunkAtAsync(int x, int z) {
|
||||
+ return getChunkAtAsync(x, z, true);
|
||||
+ default @NotNull java.util.concurrent.CompletableFuture<Chunk> getChunkAtAsync(final int x, final int z) {
|
||||
+ return this.getChunkAtAsync(x, z, true);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
|
@ -380,9 +375,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ * @param gen Should we generate a chunk if it doesn't exist or not
|
||||
+ * @return Future that will resolve when the chunk is loaded
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ public default java.util.concurrent.CompletableFuture<Chunk> getChunkAtAsync(int x, int z, boolean gen) {
|
||||
+ return getChunkAtAsync(x, z, gen, false);
|
||||
+ default @NotNull java.util.concurrent.CompletableFuture<Chunk> getChunkAtAsync(final int x, final int z, final boolean gen) {
|
||||
+ return this.getChunkAtAsync(x, z, gen, false);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
|
@ -400,9 +394,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ * @param loc Location to load the corresponding chunk from
|
||||
+ * @return Future that will resolve when the chunk is loaded
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ public default java.util.concurrent.CompletableFuture<Chunk> getChunkAtAsyncUrgently(@NotNull Location loc) {
|
||||
+ return getChunkAtAsync((int)Math.floor(loc.getX()) >> 4, (int)Math.floor(loc.getZ()) >> 4, true, true);
|
||||
+ default @NotNull java.util.concurrent.CompletableFuture<Chunk> getChunkAtAsyncUrgently(final @NotNull Location loc) {
|
||||
+ return this.getChunkAtAsync((int) Math.floor(loc.getX()) >> 4, (int) Math.floor(loc.getZ()) >> 4, true, true);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
|
@ -421,9 +414,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ * @param gen Should the chunk generate if it doesn't exist
|
||||
+ * @return Future that will resolve when the chunk is loaded
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ public default java.util.concurrent.CompletableFuture<Chunk> getChunkAtAsyncUrgently(@NotNull Location loc, boolean gen) {
|
||||
+ return getChunkAtAsync((int)Math.floor(loc.getX()) >> 4, (int)Math.floor(loc.getZ()) >> 4, gen, true);
|
||||
+ default @NotNull java.util.concurrent.CompletableFuture<Chunk> getChunkAtAsyncUrgently(final @NotNull Location loc, final boolean gen) {
|
||||
+ return this.getChunkAtAsync((int) Math.floor(loc.getX()) >> 4, (int) Math.floor(loc.getZ()) >> 4, gen, true);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
|
@ -441,9 +433,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ * @param block Block to load the corresponding chunk from
|
||||
+ * @return Future that will resolve when the chunk is loaded
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ public default java.util.concurrent.CompletableFuture<Chunk> getChunkAtAsyncUrgently(@NotNull Block block) {
|
||||
+ return getChunkAtAsync(block.getX() >> 4, block.getZ() >> 4, true, true);
|
||||
+ default @NotNull java.util.concurrent.CompletableFuture<Chunk> getChunkAtAsyncUrgently(final @NotNull Block block) {
|
||||
+ return this.getChunkAtAsync(block.getX() >> 4, block.getZ() >> 4, true, true);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
|
@ -462,9 +453,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ * @param gen Should the chunk generate if it doesn't exist
|
||||
+ * @return Future that will resolve when the chunk is loaded
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ public default java.util.concurrent.CompletableFuture<Chunk> getChunkAtAsyncUrgently(@NotNull Block block, boolean gen) {
|
||||
+ return getChunkAtAsync(block.getX() >> 4, block.getZ() >> 4, gen, true);
|
||||
+ default @NotNull java.util.concurrent.CompletableFuture<Chunk> getChunkAtAsyncUrgently(final @NotNull Block block, final boolean gen) {
|
||||
+ return this.getChunkAtAsync(block.getX() >> 4, block.getZ() >> 4, gen, true);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
|
@ -484,16 +474,16 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ * @param z Z Coord
|
||||
+ * @return Future that will resolve when the chunk is loaded
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ public default java.util.concurrent.CompletableFuture<Chunk> getChunkAtAsyncUrgently(int x, int z) {
|
||||
+ return getChunkAtAsync(x, z, true, true);
|
||||
+ default @NotNull java.util.concurrent.CompletableFuture<Chunk> getChunkAtAsyncUrgently(final int x, final int z) {
|
||||
+ return this.getChunkAtAsync(x, z, true, true);
|
||||
+ }
|
||||
+
|
||||
+ @NotNull
|
||||
+ java.util.concurrent.CompletableFuture<Chunk> getChunkAtAsync(int x, int z, boolean gen, boolean urgent);
|
||||
// Paper end
|
||||
|
||||
+ java.util.concurrent.@NotNull CompletableFuture<Chunk> getChunkAtAsync(int x, int z, boolean gen, boolean urgent);
|
||||
+ // Paper end - async chunks API
|
||||
+
|
||||
/**
|
||||
* 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
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/org/bukkit/entity/Entity.java
|
||||
|
|
|
@ -42,13 +42,25 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ * @param input the input placed into the bottom 3 slots
|
||||
+ * @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.result = result;
|
||||
+ this.input = input;
|
||||
+ 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
|
||||
+ public @NotNull NamespacedKey getKey() {
|
||||
+ return this.key;
|
||||
|
@ -81,18 +93,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ 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
|
||||
+ public String toString() {
|
||||
+ return "PotionMix{" +
|
||||
|
@ -103,10 +103,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean equals(Object o) {
|
||||
+ public boolean equals(final Object o) {
|
||||
+ if (this == o) return true;
|
||||
+ if (o == null || getClass() != o.getClass()) return false;
|
||||
+ PotionMix potionMix = (PotionMix) o;
|
||||
+ if (o == null || this.getClass() != o.getClass()) return false;
|
||||
+ 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);
|
||||
+ }
|
||||
+
|
||||
|
@ -132,7 +132,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+
|
||||
+@ApiStatus.Internal
|
||||
+@DefaultQualifier(NonNull.class)
|
||||
+record PredicateRecipeChoice(Predicate<ItemStack> itemStackPredicate) implements RecipeChoice, Cloneable {
|
||||
+record PredicateRecipeChoice(Predicate<? super ItemStack> itemStackPredicate) implements RecipeChoice, Cloneable {
|
||||
+
|
||||
+ @Override
|
||||
+ @Deprecated
|
||||
|
@ -144,7 +144,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ public RecipeChoice clone() {
|
||||
+ try {
|
||||
+ return (PredicateRecipeChoice) super.clone();
|
||||
+ } catch (CloneNotSupportedException ex) {
|
||||
+ } catch (final CloneNotSupportedException ex) {
|
||||
+ throw new AssertionError(ex);
|
||||
+ }
|
||||
+ }
|
||||
|
|
|
@ -18,13 +18,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
import org.bukkit.util.Vector;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -0,0 +0,0 @@ public class Location implements Cloneable, ConfigurationSerializable, io.paperm
|
||||
return centerLoc;
|
||||
}
|
||||
// Paper end - expand Location API
|
||||
|
||||
+ // Paper start - Expand Explosions API
|
||||
+ /**
|
||||
+ * Creates explosion at this location with given power
|
||||
+ *
|
||||
+ * <p>
|
||||
+ * Will break blocks and ignite blocks on fire.
|
||||
+ *
|
||||
+ * @param power The power of explosion, where 4F is TNT
|
||||
|
@ -37,11 +37,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ /**
|
||||
+ * Creates explosion at this location with given power and optionally
|
||||
+ * setting blocks on fire.
|
||||
+ *
|
||||
+ * <p>
|
||||
+ * Will break blocks.
|
||||
+ *
|
||||
+ * @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
|
||||
+ */
|
||||
+ public boolean createExplosion(float power, boolean setFire) {
|
||||
|
@ -53,8 +53,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ * setting blocks on fire.
|
||||
+ *
|
||||
+ * @param power The power of explosion, where 4F is TNT
|
||||
+ * @param setFire Whether or not to set blocks on fire
|
||||
+ * @param breakBlocks Whether or not to have blocks be destroyed
|
||||
+ * @param setFire Whether to set blocks on fire
|
||||
+ * @param breakBlocks Whether to have blocks be destroyed
|
||||
+ * @return false if explosion was canceled, otherwise true
|
||||
+ */
|
||||
+ public boolean createExplosion(float power, boolean setFire, boolean breakBlocks) {
|
||||
|
@ -63,7 +63,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+
|
||||
+ /**
|
||||
+ * Creates explosion at this location with given power, with the specified entity as the source.
|
||||
+ *
|
||||
+ * <p>
|
||||
+ * Will break blocks and ignite blocks on fire.
|
||||
+ *
|
||||
+ * @param source The source entity of the explosion
|
||||
|
@ -77,12 +77,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ /**
|
||||
+ * Creates explosion at this location with given power and optionally
|
||||
+ * setting blocks on fire, with the specified entity as the source.
|
||||
+ *
|
||||
+ * <p>
|
||||
+ * Will break blocks.
|
||||
+ *
|
||||
+ * @param source The source entity of the explosion
|
||||
+ * @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
|
||||
+ */
|
||||
+ public boolean createExplosion(@Nullable Entity source, float power, boolean setFire) {
|
||||
|
@ -95,8 +95,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ *
|
||||
+ * @param source The source entity of the explosion
|
||||
+ * @param power The power of explosion, where 4F is TNT
|
||||
+ * @param setFire Whether or not to set blocks on fire
|
||||
+ * @param breakBlocks Whether or not to have blocks be destroyed
|
||||
+ * @param setFire Whether to set blocks on fire
|
||||
+ * @param breakBlocks Whether to have blocks be destroyed
|
||||
+ * @return false if explosion was canceled, otherwise true
|
||||
+ */
|
||||
+ public boolean createExplosion(@Nullable Entity source, float power, boolean setFire, boolean breakBlocks) {
|
||||
|
@ -104,9 +104,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ }
|
||||
+ // Paper end - Expand Explosions API
|
||||
+
|
||||
// Paper start - additional getNearbyEntities API
|
||||
/**
|
||||
* 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
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/org/bukkit/World.java
|
||||
|
|
|
@ -10,14 +10,16 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
--- a/src/main/java/org/bukkit/Location.java
|
||||
+++ b/src/main/java/org/bukkit/Location.java
|
||||
@@ -0,0 +0,0 @@ public class Location implements Cloneable, ConfigurationSerializable, io.paperm
|
||||
|
||||
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
|
||||
+ *
|
||||
+ * <p>
|
||||
+ * This mutates this object, clone first.
|
||||
+ *
|
||||
+ * @param x X coordinate
|
||||
+ * @param y Y coordinate
|
||||
+ * @param z Z coordinate
|
||||
|
@ -33,8 +35,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+
|
||||
+ /**
|
||||
+ * 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.
|
||||
+ *
|
||||
+ * @param base The base coordinate to modify
|
||||
+ * @param x X coordinate to add to base
|
||||
+ * @param y Y coordinate to add to base
|
||||
|
@ -48,8 +51,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+
|
||||
+ /**
|
||||
+ * 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.
|
||||
+ *
|
||||
+ * @param base The base coordinate to modify
|
||||
+ * @param x X coordinate to subtract from base
|
||||
+ * @param y Y coordinate to subtract from base
|
||||
|
@ -60,7 +64,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ public Location subtract(@NotNull Location base, double x, double y, double 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)
|
||||
*/
|
||||
|
|
|
@ -14,7 +14,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
|
||||
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)
|
||||
+ */
|
||||
|
@ -37,7 +37,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ centerLoc.setZ(getBlockZ() + 0.5);
|
||||
+ return centerLoc;
|
||||
+ }
|
||||
+ // Paper end
|
||||
+ // Paper end - expand Location API
|
||||
+
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == null) {
|
||||
|
|
|
@ -17,9 +17,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
import java.util.Map;
|
||||
import org.bukkit.block.Block;
|
||||
@@ -0,0 +0,0 @@ public class Location implements Cloneable, ConfigurationSerializable, io.paperm
|
||||
|
||||
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.
|
||||
+ *
|
||||
|
@ -30,9 +31,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ Preconditions.checkNotNull(world, "Location has no world!");
|
||||
+ 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
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/org/bukkit/World.java
|
||||
|
|
|
@ -35,7 +35,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public Collection<BlockState> getTileEntities(Predicate<Block> blockPredicate, boolean useSnapshot) {
|
||||
+ public Collection<BlockState> getTileEntities(Predicate<? super Block> blockPredicate, boolean useSnapshot) {
|
||||
+ Preconditions.checkNotNull(blockPredicate, "blockPredicate");
|
||||
+ if (!this.isLoaded()) {
|
||||
+ this.getWorld().getChunkAt(this.x, this.z); // Transient load for this tick
|
||||
|
|
|
@ -20,7 +20,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+
|
||||
+ @Override
|
||||
+ @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
|
||||
Preconditions.checkState(!this.getHandle().generation, "Cannot launch projectile during world generation");
|
||||
|
||||
|
@ -50,7 +50,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ }
|
||||
+
|
||||
+ @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
|
||||
Preconditions.checkArgument(this.getBlock().getType() == Material.DISPENSER, "Block is no longer dispenser");
|
||||
// Copied from BlockDispenser.dispense()
|
||||
|
|
Loading…
Reference in a new issue