Merge branch 'master' into pre/1.13
This commit is contained in:
commit
039d6f2f75
18 changed files with 225 additions and 87 deletions
|
@ -1,4 +1,4 @@
|
|||
From 7991f82af6e972ee2ff68cb2c3d777f5226999e8 Mon Sep 17 00:00:00 2001
|
||||
From 4ddcdfd0c5c246dc6af8d57823b7acfeb3dadc92 Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Mon, 30 Apr 2018 17:55:28 -0400
|
||||
Subject: [PATCH] Additional world.getNearbyEntities API's
|
||||
|
@ -6,7 +6,7 @@ Subject: [PATCH] Additional world.getNearbyEntities API's
|
|||
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
|
||||
index 4e07af2e..49d2cc45 100644
|
||||
index 9f3d805c2..f9d8b14c6 100644
|
||||
--- a/src/main/java/org/bukkit/World.java
|
||||
+++ b/src/main/java/org/bukkit/World.java
|
||||
@@ -2,11 +2,14 @@ package org.bukkit;
|
||||
|
@ -24,7 +24,7 @@ index 4e07af2e..49d2cc45 100644
|
|||
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.block.Block;
|
||||
@@ -435,6 +438,205 @@ public interface World extends PluginMessageRecipient, Metadatable {
|
||||
@@ -435,6 +438,238 @@ public interface World extends PluginMessageRecipient, Metadatable {
|
||||
*/
|
||||
public Collection<Entity> getEntitiesByClasses(Class<?>... classes);
|
||||
|
||||
|
@ -32,7 +32,8 @@ index 4e07af2e..49d2cc45 100644
|
|||
+ /**
|
||||
+ * Gets nearby players within the specified radius (bounding box)
|
||||
+ * @param loc Center location
|
||||
+ * @param radius X Radius
|
||||
+ * @param radius Radius
|
||||
+ * @return the collection of entities near location. This will always be a non-null collection.
|
||||
+ */
|
||||
+ public default Collection<LivingEntity> getNearbyLivingEntities(Location loc, double radius) {
|
||||
+ return getNearbyEntitiesByType(org.bukkit.entity.LivingEntity.class, loc, radius, radius, radius);
|
||||
|
@ -43,6 +44,7 @@ index 4e07af2e..49d2cc45 100644
|
|||
+ * @param loc Center location
|
||||
+ * @param xzRadius X/Z Radius
|
||||
+ * @param yRadius Y Radius
|
||||
+ * @return the collection of entities near location. This will always be a non-null collection.
|
||||
+ */
|
||||
+ public default Collection<LivingEntity> getNearbyLivingEntities(Location loc, double xzRadius, double yRadius) {
|
||||
+ return getNearbyEntitiesByType(org.bukkit.entity.LivingEntity.class, loc, xzRadius, yRadius, xzRadius);
|
||||
|
@ -54,6 +56,7 @@ index 4e07af2e..49d2cc45 100644
|
|||
+ * @param xRadius X Radius
|
||||
+ * @param yRadius Y Radius
|
||||
+ * @param zRadius Z radius
|
||||
+ * @return the collection of entities near location. This will always be a non-null collection.
|
||||
+ */
|
||||
+ public default Collection<LivingEntity> getNearbyLivingEntities(Location loc, double xRadius, double yRadius, double zRadius) {
|
||||
+ return getNearbyEntitiesByType(org.bukkit.entity.LivingEntity.class, loc, xRadius, yRadius, zRadius);
|
||||
|
@ -63,6 +66,8 @@ index 4e07af2e..49d2cc45 100644
|
|||
+ * Gets nearby players within the specified radius (bounding box)
|
||||
+ * @param loc Center location
|
||||
+ * @param radius X Radius
|
||||
+ * @param predicate a predicate used to filter results
|
||||
+ * @return the collection of living entities near location. This will always be a non-null collection
|
||||
+ */
|
||||
+ public default Collection<LivingEntity> getNearbyLivingEntities(Location loc, double radius, Predicate<LivingEntity> predicate) {
|
||||
+ return getNearbyEntitiesByType(org.bukkit.entity.LivingEntity.class, loc, radius, radius, radius, predicate);
|
||||
|
@ -73,6 +78,8 @@ index 4e07af2e..49d2cc45 100644
|
|||
+ * @param loc Center location
|
||||
+ * @param xzRadius X/Z Radius
|
||||
+ * @param yRadius Y Radius
|
||||
+ * @param predicate a predicate used to filter results
|
||||
+ * @return the collection of living entities near location. This will always be a non-null collection
|
||||
+ */
|
||||
+ public default Collection<LivingEntity> getNearbyLivingEntities(Location loc, double xzRadius, double yRadius, Predicate<LivingEntity> predicate) {
|
||||
+ return getNearbyEntitiesByType(org.bukkit.entity.LivingEntity.class, loc, xzRadius, yRadius, xzRadius, predicate);
|
||||
|
@ -84,6 +91,8 @@ index 4e07af2e..49d2cc45 100644
|
|||
+ * @param xRadius X Radius
|
||||
+ * @param yRadius Y Radius
|
||||
+ * @param zRadius Z radius
|
||||
+ * @param predicate a predicate used to filter results
|
||||
+ * @return the collection of living entities near location. This will always be a non-null collection.
|
||||
+ */
|
||||
+ public default Collection<LivingEntity> getNearbyLivingEntities(Location loc, double xRadius, double yRadius, double zRadius, Predicate<LivingEntity> predicate) {
|
||||
+ return getNearbyEntitiesByType(org.bukkit.entity.LivingEntity.class, loc, xRadius, yRadius, zRadius, predicate);
|
||||
|
@ -93,6 +102,7 @@ index 4e07af2e..49d2cc45 100644
|
|||
+ * Gets nearby players within the specified radius (bounding box)
|
||||
+ * @param loc Center location
|
||||
+ * @param radius X/Y/Z Radius
|
||||
+ * @return the collection of living entities near location. This will always be a non-null collection.
|
||||
+ */
|
||||
+ public default Collection<Player> getNearbyPlayers(Location loc, double radius) {
|
||||
+ return getNearbyEntitiesByType(org.bukkit.entity.Player.class, loc, radius, radius, radius);
|
||||
|
@ -103,6 +113,7 @@ index 4e07af2e..49d2cc45 100644
|
|||
+ * @param loc Center location
|
||||
+ * @param xzRadius X/Z Radius
|
||||
+ * @param yRadius Y Radius
|
||||
+ * @return the collection of living entities near location. This will always be a non-null collection.
|
||||
+ */
|
||||
+ public default Collection<Player> getNearbyPlayers(Location loc, double xzRadius, double yRadius) {
|
||||
+ return getNearbyEntitiesByType(org.bukkit.entity.Player.class, loc, xzRadius, yRadius, xzRadius);
|
||||
|
@ -114,6 +125,7 @@ index 4e07af2e..49d2cc45 100644
|
|||
+ * @param xRadius X Radius
|
||||
+ * @param yRadius Y Radius
|
||||
+ * @param zRadius Z Radius
|
||||
+ * @return the collection of players near location. This will always be a non-null collection.
|
||||
+ */
|
||||
+ public default Collection<Player> getNearbyPlayers(Location loc, double xRadius, double yRadius, double zRadius) {
|
||||
+ return getNearbyEntitiesByType(org.bukkit.entity.Player.class, loc, xRadius, yRadius, zRadius);
|
||||
|
@ -123,6 +135,8 @@ index 4e07af2e..49d2cc45 100644
|
|||
+ * Gets nearby players within the specified radius (bounding box)
|
||||
+ * @param loc Center location
|
||||
+ * @param radius X/Y/Z Radius
|
||||
+ * @param predicate a predicate used to filter results
|
||||
+ * @return the collection of players near location. This will always be a non-null collection.
|
||||
+ */
|
||||
+ public default Collection<Player> getNearbyPlayers(Location loc, double radius, Predicate<Player> predicate) {
|
||||
+ return getNearbyEntitiesByType(org.bukkit.entity.Player.class, loc, radius, radius, radius, predicate);
|
||||
|
@ -133,6 +147,8 @@ index 4e07af2e..49d2cc45 100644
|
|||
+ * @param loc Center location
|
||||
+ * @param xzRadius X/Z Radius
|
||||
+ * @param yRadius Y Radius
|
||||
+ * @param predicate a predicate used to filter results
|
||||
+ * @return the collection of players near location. This will always be a non-null collection.
|
||||
+ */
|
||||
+ public default Collection<Player> getNearbyPlayers(Location loc, double xzRadius, double yRadius, Predicate<Player> predicate) {
|
||||
+ return getNearbyEntitiesByType(org.bukkit.entity.Player.class, loc, xzRadius, yRadius, xzRadius, predicate);
|
||||
|
@ -144,6 +160,8 @@ index 4e07af2e..49d2cc45 100644
|
|||
+ * @param xRadius X Radius
|
||||
+ * @param yRadius Y Radius
|
||||
+ * @param zRadius Z Radius
|
||||
+ * @param predicate a predicate used to filter results
|
||||
+ * @return the collection of players near location. This will always be a non-null collection.
|
||||
+ */
|
||||
+ public default Collection<Player> getNearbyPlayers(Location loc, double xRadius, double yRadius, double zRadius, Predicate<Player> predicate) {
|
||||
+ return getNearbyEntitiesByType(org.bukkit.entity.Player.class, loc, xRadius, yRadius, zRadius, predicate);
|
||||
|
@ -154,6 +172,8 @@ index 4e07af2e..49d2cc45 100644
|
|||
+ * @param clazz Type to filter by
|
||||
+ * @param loc Center location
|
||||
+ * @param radius X/Y/Z radius to search within
|
||||
+ * @param <T> the entity type
|
||||
+ * @return the collection of entities near location. This will always be a non-null collection.
|
||||
+ */
|
||||
+ public default <T extends Entity> Collection<T> getNearbyEntitiesByType(Class<? extends T> clazz, Location loc, double radius) {
|
||||
+ return getNearbyEntitiesByType(clazz, loc, radius, radius, radius, null);
|
||||
|
@ -165,6 +185,8 @@ index 4e07af2e..49d2cc45 100644
|
|||
+ * @param loc Center location
|
||||
+ * @param xzRadius X/Z radius to search within
|
||||
+ * @param yRadius Y radius to search within
|
||||
+ * @param <T> the entity type
|
||||
+ * @return the collection of entities near location. This will always be a non-null collection.
|
||||
+ */
|
||||
+ public default <T extends Entity> Collection<T> getNearbyEntitiesByType(Class<? extends T> clazz, Location loc, double xzRadius, double yRadius) {
|
||||
+ return getNearbyEntitiesByType(clazz, loc, xzRadius, yRadius, xzRadius, null);
|
||||
|
@ -177,6 +199,8 @@ index 4e07af2e..49d2cc45 100644
|
|||
+ * @param xRadius X Radius
|
||||
+ * @param yRadius Y Radius
|
||||
+ * @param zRadius Z Radius
|
||||
+ * @param <T> the entity type
|
||||
+ * @return the collection of entities near location. This will always be a non-null collection.
|
||||
+ */
|
||||
+ public default <T extends Entity> Collection<T> getNearbyEntitiesByType(Class<? extends T> clazz, Location loc, double xRadius, double yRadius, double zRadius) {
|
||||
+ return getNearbyEntitiesByType(clazz, loc, xRadius, yRadius, zRadius, null);
|
||||
|
@ -187,6 +211,9 @@ index 4e07af2e..49d2cc45 100644
|
|||
+ * @param clazz Type to filter by
|
||||
+ * @param loc Center location
|
||||
+ * @param radius X/Y/Z radius to search within
|
||||
+ * @param predicate a predicate used to filter results
|
||||
+ * @param <T> the entity type
|
||||
+ * @return the collection of entities near location. This will always be a non-null collection.
|
||||
+ */
|
||||
+ public default <T extends Entity> Collection<T> getNearbyEntitiesByType(Class<? extends T> clazz, Location loc, double radius, Predicate<T> predicate) {
|
||||
+ return getNearbyEntitiesByType(clazz, loc, radius, radius, radius, predicate);
|
||||
|
@ -198,19 +225,25 @@ index 4e07af2e..49d2cc45 100644
|
|||
+ * @param loc Center location
|
||||
+ * @param xzRadius X/Z radius to search within
|
||||
+ * @param yRadius Y radius to search within
|
||||
+ * @param predicate a predicate used to filter results
|
||||
+ * @param <T> the entity type
|
||||
+ * @return the collection of entities near location. This will always be a non-null collection.
|
||||
+ */
|
||||
+ public default <T extends Entity> Collection<T> getNearbyEntitiesByType(Class<? extends T> clazz, Location loc, double xzRadius, double yRadius, Predicate<T> predicate) {
|
||||
+ return getNearbyEntitiesByType(clazz, loc, xzRadius, yRadius, xzRadius, predicate);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Gets all nearby entities of the specified type, within the specified radius (bounding box)
|
||||
+ * @param clazz Type to filter by
|
||||
+ * @param loc Center location
|
||||
+ * @param xRadius X Radius
|
||||
+ * @param yRadius Y Radius
|
||||
+ * @param zRadius Z Radius
|
||||
+ */
|
||||
+ * Gets all nearby entities of the specified type, within the specified radius (bounding box)
|
||||
+ * @param clazz Type to filter by
|
||||
+ * @param loc Center location
|
||||
+ * @param xRadius X Radius
|
||||
+ * @param yRadius Y Radius
|
||||
+ * @param zRadius Z Radius
|
||||
+ * @param predicate a predicate used to filter results
|
||||
+ * @param <T> the entity type
|
||||
+ * @return the collection of entities near location. This will always be a non-null collection.
|
||||
+ */
|
||||
+ public default <T extends Entity> Collection<T> getNearbyEntitiesByType(Class<? extends Entity> clazz, Location loc, double xRadius, double yRadius, double zRadius, Predicate<T> predicate) {
|
||||
+ if (clazz == null) {
|
||||
+ clazz = Entity.class;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue