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

This commit is contained in:
Jake Potrebic 2023-11-25 15:03:02 -08:00 committed by GitHub
parent f9938d3949
commit b37bbcfd98
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
21 changed files with 240 additions and 277 deletions

View file

@ -5,7 +5,7 @@ Subject: [PATCH] Ability to get Tile Entities from a chunk without snapshots
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftChunk.java b/src/main/java/org/bukkit/craftbukkit/CraftChunk.java
index df02963faaf8f514f4175d394e67d2df10c8a3ea..593cfd68dc0f3679c684b6a1d2036419d4f3bc0c 100644
index df02963faaf8f514f4175d394e67d2df10c8a3ea..545b14f02ac72dda30891d681eba585d19fd5e1d 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftChunk.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftChunk.java
@@ -127,6 +127,13 @@ public class CraftChunk implements Chunk {
@ -35,7 +35,7 @@ index df02963faaf8f514f4175d394e67d2df10c8a3ea..593cfd68dc0f3679c684b6a1d2036419
+ }
+
+ @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

View file

@ -5,7 +5,7 @@ Subject: [PATCH] Add a consumer parameter to ProjectileSource#launchProjectile
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
index 03b1b9d8bf7b12343564ff6eb4fb865e4626b1e4..b31356c042b5262ccb47fe1ec56bed0791e84262 100644
index 0faed04c7794dd4fd758a151d15ad5956e4f4907..c9396a55fddba47124ad5aebe7f816d99a03659c 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
@@ -509,8 +509,15 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
@ -20,7 +20,7 @@ index 03b1b9d8bf7b12343564ff6eb4fb865e4626b1e4..b31356c042b5262ccb47fe1ec56bed07
+
+ @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");
@ -38,7 +38,7 @@ index 03b1b9d8bf7b12343564ff6eb4fb865e4626b1e4..b31356c042b5262ccb47fe1ec56bed07
world.addFreshEntity(launch);
return (T) launch.getBukkitEntity();
diff --git a/src/main/java/org/bukkit/craftbukkit/projectiles/CraftBlockProjectileSource.java b/src/main/java/org/bukkit/craftbukkit/projectiles/CraftBlockProjectileSource.java
index 7f9a716ea65f98d1c8487438949f1d5bc8becc4a..f880b0def6ee12d1e88a732ade348ac062f8ab69 100644
index 7f9a716ea65f98d1c8487438949f1d5bc8becc4a..ab684fc1b09d4eade7dd11a95065e72b842a3667 100644
--- a/src/main/java/org/bukkit/craftbukkit/projectiles/CraftBlockProjectileSource.java
+++ b/src/main/java/org/bukkit/craftbukkit/projectiles/CraftBlockProjectileSource.java
@@ -56,6 +56,13 @@ public class CraftBlockProjectileSource implements BlockProjectileSource {
@ -50,7 +50,7 @@ index 7f9a716ea65f98d1c8487438949f1d5bc8becc4a..f880b0def6ee12d1e88a732ade348ac0
+ }
+
+ @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()