Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use ? super in Consumer/Predicate API #9939

Merged
merged 1 commit into from
Nov 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
102 changes: 42 additions & 60 deletions patches/api/0099-Additional-world.getNearbyEntities-API-s.patch

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -523,10 +523,10 @@ index e2adb9901cc92ede9d44ca9939c6a54d4762eb4b..81bd12c8addcee754c71e5e030c729c7
* Options which can be applied to redstone dust particles - a particle
* color and size.
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
+++ 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,
* the type of this depends on {@link Particle#getDataType()}
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ Subject: [PATCH] Location.toBlockLocation/toCenterLocation()
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
index e71beb48f2e35d97b9d5bf8dbf5ddbc0673565fe..5a219f132747eb62204e98de4cb850748a43c9b4 100644
index 251d26e6870490abd3e915c5e7c06ce1075a24ab..24a872dfc8cf1f4a567b6ebd5a5e742593616ede 100644
--- a/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
+
+ // 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)
+ */
Expand All @@ -37,7 +37,8 @@ index e71beb48f2e35d97b9d5bf8dbf5ddbc0673565fe..5a219f132747eb62204e98de4cb85074
+ centerLoc.setZ(getBlockZ() + 0.5);
+ return centerLoc;
+ }
+ // Paper end
+ // Paper end - expand Location API
+
@Override
public boolean equals(Object obj) {
if (obj == null) {
117 changes: 50 additions & 67 deletions patches/api/0112-Add-getNearbyXXX-methods-to-Location.patch

Large diffs are not rendered by default.

32 changes: 16 additions & 16 deletions patches/api/0115-Expand-Explosions-API.patch
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Subject: [PATCH] Expand Explosions API
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
index 556e4524c30f8c7faeb591e272546c78090170fc..e8067e91dea3c5f8654c65ea5ec4d3db36d85a6c 100644
index 3161eae2fa5f03b7d3a5e9945ab659c15cf568c6..af737017ee397f80c44ee02c6cc60cefa07f59c1 100644
--- a/src/main/java/org/bukkit/Location.java
+++ b/src/main/java/org/bukkit/Location.java
@@ -7,6 +7,7 @@ import java.util.HashMap;
Expand All @@ -17,14 +17,14 @@ index 556e4524c30f8c7faeb591e272546c78090170fc..e8067e91dea3c5f8654c65ea5ec4d3db
import org.bukkit.util.NumberConversions;
import org.bukkit.util.Vector;
import org.jetbrains.annotations.NotNull;
@@ -568,6 +569,89 @@ public class Location implements Cloneable, ConfigurationSerializable, io.paperm
return centerLoc;
@@ -569,6 +570,89 @@ public class Location implements Cloneable, ConfigurationSerializable, io.paperm
}
// 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
Expand All @@ -37,11 +37,11 @@ index 556e4524c30f8c7faeb591e272546c78090170fc..e8067e91dea3c5f8654c65ea5ec4d3db
+ /**
+ * 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) {
Expand All @@ -53,8 +53,8 @@ index 556e4524c30f8c7faeb591e272546c78090170fc..e8067e91dea3c5f8654c65ea5ec4d3db
+ * 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) {
Expand All @@ -63,7 +63,7 @@ index 556e4524c30f8c7faeb591e272546c78090170fc..e8067e91dea3c5f8654c65ea5ec4d3db
+
+ /**
+ * 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
Expand All @@ -77,12 +77,12 @@ index 556e4524c30f8c7faeb591e272546c78090170fc..e8067e91dea3c5f8654c65ea5ec4d3db
+ /**
+ * 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) {
Expand All @@ -95,23 +95,23 @@ index 556e4524c30f8c7faeb591e272546c78090170fc..e8067e91dea3c5f8654c65ea5ec4d3db
+ *
+ * @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) {
+ return this.getWorld().createExplosion(source, this, power, setFire, breakBlocks);
+ }
+ // 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 d02b6743e4401004e75501e99b717b58e5acc5ae..de896af6006f791625bb388b105983fb64489071 100644
index 93c46d40efd73293d84c7eaadf4e360cc3706e2a..cd946f2de8a09fdb6ff9b256ca7eba64e6ed9aab 100644
--- a/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);

Expand Down
4 changes: 2 additions & 2 deletions patches/api/0119-Add-World.getEntity-UUID-API.patch
Original file line number Diff line number Diff line change
Expand Up @@ -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
index 266ed71b79d32f9b812be322563c247051ccd9d0..ffe6c8be86fc93d39e256a89e5016e3025afbe5c 100644
index c0e45f4c964ae262a894d92cff8f0750660cd41d..17b9e695a3f2eab94714b2124c657ee4d8b5ef51 100644
--- a/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
public Collection<Entity> getNearbyEntities(@NotNull Location location, double x, double y, double z);

Expand Down
19 changes: 12 additions & 7 deletions patches/api/0129-Expand-Location-Manipulation-API.patch
Original file line number Diff line number Diff line change
Expand Up @@ -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);

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
+++ 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

// 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
Expand All @@ -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
+ *
+ * <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
Expand All @@ -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
+ *
+ * <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
Expand All @@ -60,7 +64,8 @@ index b7ff09ffdd3aecc1843d175bc76fe5fae1f48dde..aa6821aa33d3c579a139bd7c0378253c
+ 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)
*/
Original file line number Diff line number Diff line change
Expand Up @@ -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
index 766d643f0fe79660942fdad25e39e488e9379419..4418c41f75e9a190dd77abdd6048b0a4fb2a57ed 100644
index 766d643f0fe79660942fdad25e39e488e9379419..eca55d8d3464f0e13a3b7984f74559ccda87edba 100644
--- a/src/main/java/org/bukkit/Chunk.java
+++ b/src/main/java/org/bukkit/Chunk.java
@@ -122,7 +122,30 @@ public interface Chunk extends PersistentDataHolder {
Expand Down Expand Up @@ -35,7 +35,7 @@ index 766d643f0fe79660942fdad25e39e488e9379419..4418c41f75e9a190dd77abdd6048b0a4
+ * @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

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Y range: [0, 1023]
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
index aa6821aa33d3c579a139bd7c0378253c43b3754a..6e6e65c40813ccce618fa7a3df2c0030aa0a3bbe 100644
index 189c2159941712a6f22bb5aaf1e8ca80b4eb54f6..09d1f9f909c971d6a785e9f98278f8c55cd44637 100644
--- a/src/main/java/org/bukkit/Location.java
+++ b/src/main/java/org/bukkit/Location.java
@@ -15,7 +15,6 @@ import org.jetbrains.annotations.Nullable;
Expand All @@ -29,7 +29,7 @@ index aa6821aa33d3c579a139bd7c0378253c43b3754a..6e6e65c40813ccce618fa7a3df2c0030
import java.util.function.Predicate;
import org.bukkit.entity.Entity;
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());
return blockLoc;
}
Expand All @@ -50,7 +50,7 @@ index aa6821aa33d3c579a139bd7c0378253c43b3754a..6e6e65c40813ccce618fa7a3df2c0030
* @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
index 315ecb5dc0f33edfef893ead1297c8165d292250..ad5afa7a05636cee82b517c673d281f0f4e38644 100644
index f21d3ab534a64a5445975968b63fc78d7dc2fa72..fef21d398d9c9349e10e59b62cbbe28e9538482d 100644
--- a/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
Expand Down
13 changes: 8 additions & 5 deletions patches/api/0141-isChunkGenerated-API.patch
Original file line number Diff line number Diff line change
Expand Up @@ -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
index 6e6e65c40813ccce618fa7a3df2c0030aa0a3bbe..8508aa2c6fb7c9f41f3d185f5228c86dd3b8b627 100644
index 09d1f9f909c971d6a785e9f98278f8c55cd44637..7fea9af96c97d9f60af6fe30fed1ec05d05a1a25 100644
--- a/src/main/java/org/bukkit/Location.java
+++ b/src/main/java/org/bukkit/Location.java
@@ -3,6 +3,7 @@ package org.bukkit;
Expand All @@ -16,10 +16,11 @@ index 6e6e65c40813ccce618fa7a3df2c0030aa0a3bbe..8508aa2c6fb7c9f41f3d185f5228c86d
import java.util.HashMap;
import java.util.Map;
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

// Paper start
+ // Paper start - isGenerated API
+ /**
+ * Checks if a {@link Chunk} has been generated at this location.
+ *
Expand All @@ -30,11 +31,13 @@ index 6e6e65c40813ccce618fa7a3df2c0030aa0a3bbe..8508aa2c6fb7c9f41f3d185f5228c86d
+ 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 ad5afa7a05636cee82b517c673d281f0f4e38644..880ff5ee1237096ac2da115b665dc663c677e57b 100644
index fef21d398d9c9349e10e59b62cbbe28e9538482d..213ec372ab639179da65e67a1326c1e08bfbc943 100644
--- a/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
Expand Down
Loading