#1297: Change Consumer and Predicates to super
This commit is contained in:
parent
864f616da6
commit
d433f086d5
@ -334,7 +334,7 @@ public abstract class CraftRegionAccessor implements RegionAccessor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean generateTree(Location location, Random random, TreeType treeType, Consumer<BlockState> consumer) {
|
||||
public boolean generateTree(Location location, Random random, TreeType treeType, Consumer<? super BlockState> consumer) {
|
||||
return generateTree(location, random, treeType, (consumer == null) ? null : (block) -> {
|
||||
consumer.accept(block);
|
||||
return true;
|
||||
@ -342,7 +342,7 @@ public abstract class CraftRegionAccessor implements RegionAccessor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean generateTree(Location location, Random random, TreeType treeType, Predicate<BlockState> predicate) {
|
||||
public boolean generateTree(Location location, Random random, TreeType treeType, Predicate<? super BlockState> predicate) {
|
||||
BlockPosition pos = CraftLocation.toBlockPosition(location);
|
||||
BlockStateListPopulator populator = new BlockStateListPopulator(getHandle());
|
||||
boolean result = generateTree(populator, getHandle().getMinecraftWorld().getChunkSource().getGenerator(), pos, new RandomSourceWrapper(random), treeType);
|
||||
@ -534,20 +534,20 @@ public abstract class CraftRegionAccessor implements RegionAccessor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends Entity> T spawn(Location location, Class<T> clazz, Consumer<T> function) throws IllegalArgumentException {
|
||||
public <T extends Entity> T spawn(Location location, Class<T> clazz, Consumer<? super T> function) throws IllegalArgumentException {
|
||||
return spawn(location, clazz, function, CreatureSpawnEvent.SpawnReason.CUSTOM);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends Entity> T spawn(Location location, Class<T> clazz, boolean randomizeData, Consumer<T> function) throws IllegalArgumentException {
|
||||
public <T extends Entity> T spawn(Location location, Class<T> clazz, boolean randomizeData, Consumer<? super T> function) throws IllegalArgumentException {
|
||||
return spawn(location, clazz, function, CreatureSpawnEvent.SpawnReason.CUSTOM, randomizeData);
|
||||
}
|
||||
|
||||
public <T extends Entity> T spawn(Location location, Class<T> clazz, Consumer<T> function, CreatureSpawnEvent.SpawnReason reason) throws IllegalArgumentException {
|
||||
public <T extends Entity> T spawn(Location location, Class<T> clazz, Consumer<? super T> function, CreatureSpawnEvent.SpawnReason reason) throws IllegalArgumentException {
|
||||
return spawn(location, clazz, function, reason, true);
|
||||
}
|
||||
|
||||
public <T extends Entity> T spawn(Location location, Class<T> clazz, Consumer<T> function, CreatureSpawnEvent.SpawnReason reason, boolean randomizeData) throws IllegalArgumentException {
|
||||
public <T extends Entity> T spawn(Location location, Class<T> clazz, Consumer<? super T> function, CreatureSpawnEvent.SpawnReason reason, boolean randomizeData) throws IllegalArgumentException {
|
||||
net.minecraft.world.entity.Entity entity = createEntity(location, clazz, randomizeData);
|
||||
|
||||
return addEntity(entity, reason, function, randomizeData);
|
||||
@ -559,7 +559,7 @@ public abstract class CraftRegionAccessor implements RegionAccessor {
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T extends Entity> T addEntity(net.minecraft.world.entity.Entity entity, CreatureSpawnEvent.SpawnReason reason, Consumer<T> function, boolean randomizeData) throws IllegalArgumentException {
|
||||
public <T extends Entity> T addEntity(net.minecraft.world.entity.Entity entity, CreatureSpawnEvent.SpawnReason reason, Consumer<? super T> function, boolean randomizeData) throws IllegalArgumentException {
|
||||
Preconditions.checkArgument(entity != null, "Cannot spawn null entity");
|
||||
|
||||
if (randomizeData && entity instanceof EntityInsentient) {
|
||||
|
@ -2284,7 +2284,7 @@ public final class CraftServer implements Server {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockData createBlockData(org.bukkit.Material material, Consumer<BlockData> consumer) {
|
||||
public BlockData createBlockData(org.bukkit.Material material, Consumer<? super BlockData> consumer) {
|
||||
BlockData data = createBlockData(material);
|
||||
|
||||
if (consumer != null) {
|
||||
|
@ -484,7 +484,7 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.bukkit.entity.Item dropItem(Location loc, ItemStack item, Consumer<org.bukkit.entity.Item> function) {
|
||||
public org.bukkit.entity.Item dropItem(Location loc, ItemStack item, Consumer<? super org.bukkit.entity.Item> function) {
|
||||
Preconditions.checkArgument(loc != null, "Location cannot be null");
|
||||
Preconditions.checkArgument(item != null, "ItemStack cannot be null");
|
||||
|
||||
@ -504,7 +504,7 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.bukkit.entity.Item dropItemNaturally(Location loc, ItemStack item, Consumer<org.bukkit.entity.Item> function) {
|
||||
public org.bukkit.entity.Item dropItemNaturally(Location loc, ItemStack item, Consumer<? super org.bukkit.entity.Item> function) {
|
||||
Preconditions.checkArgument(loc != null, "Location cannot be null");
|
||||
Preconditions.checkArgument(item != null, "ItemStack cannot be null");
|
||||
|
||||
@ -826,7 +826,7 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Entity> getNearbyEntities(Location location, double x, double y, double z, Predicate<Entity> filter) {
|
||||
public Collection<Entity> getNearbyEntities(Location location, double x, double y, double z, Predicate<? super Entity> filter) {
|
||||
Preconditions.checkArgument(location != null, "Location cannot be null");
|
||||
Preconditions.checkArgument(this.equals(location.getWorld()), "Location cannot be in a different world");
|
||||
|
||||
@ -840,7 +840,7 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Entity> getNearbyEntities(BoundingBox boundingBox, Predicate<Entity> filter) {
|
||||
public Collection<Entity> getNearbyEntities(BoundingBox boundingBox, Predicate<? super Entity> filter) {
|
||||
Preconditions.checkArgument(boundingBox != null, "BoundingBox cannot be null");
|
||||
|
||||
AxisAlignedBB bb = new AxisAlignedBB(boundingBox.getMinX(), boundingBox.getMinY(), boundingBox.getMinZ(), boundingBox.getMaxX(), boundingBox.getMaxY(), boundingBox.getMaxZ());
|
||||
@ -868,12 +868,12 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
||||
}
|
||||
|
||||
@Override
|
||||
public RayTraceResult rayTraceEntities(Location start, Vector direction, double maxDistance, Predicate<Entity> filter) {
|
||||
public RayTraceResult rayTraceEntities(Location start, Vector direction, double maxDistance, Predicate<? super Entity> filter) {
|
||||
return this.rayTraceEntities(start, direction, maxDistance, 0.0D, filter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RayTraceResult rayTraceEntities(Location start, Vector direction, double maxDistance, double raySize, Predicate<Entity> filter) {
|
||||
public RayTraceResult rayTraceEntities(Location start, Vector direction, double maxDistance, double raySize, Predicate<? super Entity> filter) {
|
||||
Preconditions.checkArgument(start != null, "Location start cannot be null");
|
||||
Preconditions.checkArgument(this.equals(start.getWorld()), "Location start cannot be in a different world");
|
||||
start.checkFinite();
|
||||
@ -949,7 +949,7 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
||||
}
|
||||
|
||||
@Override
|
||||
public RayTraceResult rayTrace(Location start, Vector direction, double maxDistance, FluidCollisionMode fluidCollisionMode, boolean ignorePassableBlocks, double raySize, Predicate<Entity> filter) {
|
||||
public RayTraceResult rayTrace(Location start, Vector direction, double maxDistance, FluidCollisionMode fluidCollisionMode, boolean ignorePassableBlocks, double raySize, Predicate<? super Entity> filter) {
|
||||
RayTraceResult blockHit = this.rayTraceBlocks(start, direction, maxDistance, fluidCollisionMode, ignorePassableBlocks);
|
||||
Vector startVec = null;
|
||||
double blockHitDistance = maxDistance;
|
||||
|
@ -228,7 +228,7 @@ public class CraftLimitedRegion extends CraftRegionAccessor implements LimitedRe
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean generateTree(Location location, Random random, TreeType treeType, Consumer<BlockState> consumer) {
|
||||
public boolean generateTree(Location location, Random random, TreeType treeType, Consumer<? super BlockState> consumer) {
|
||||
Preconditions.checkArgument(isInRegion(location), "Coordinates %s, %s, %s are not in the region", location.getBlockX(), location.getBlockY(), location.getBlockZ());
|
||||
return super.generateTree(location, random, treeType, consumer);
|
||||
}
|
||||
@ -241,7 +241,7 @@ public class CraftLimitedRegion extends CraftRegionAccessor implements LimitedRe
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends Entity> T spawn(Location location, Class<T> clazz, Consumer<T> function, CreatureSpawnEvent.SpawnReason reason) throws IllegalArgumentException {
|
||||
public <T extends Entity> T spawn(Location location, Class<T> clazz, Consumer<? super T> function, CreatureSpawnEvent.SpawnReason reason) throws IllegalArgumentException {
|
||||
Preconditions.checkArgument(isInRegion(location), "Coordinates %s, %s, %s are not in the region", location.getBlockX(), location.getBlockY(), location.getBlockZ());
|
||||
return super.spawn(location, clazz, function, reason);
|
||||
}
|
||||
|
@ -121,7 +121,7 @@ public class CraftScheduler implements BukkitScheduler {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runTask(Plugin plugin, Consumer<BukkitTask> task) throws IllegalArgumentException {
|
||||
public void runTask(Plugin plugin, Consumer<? super BukkitTask> task) throws IllegalArgumentException {
|
||||
runTaskLater(plugin, task, 0L);
|
||||
}
|
||||
|
||||
@ -137,7 +137,7 @@ public class CraftScheduler implements BukkitScheduler {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runTaskAsynchronously(Plugin plugin, Consumer<BukkitTask> task) throws IllegalArgumentException {
|
||||
public void runTaskAsynchronously(Plugin plugin, Consumer<? super BukkitTask> task) throws IllegalArgumentException {
|
||||
runTaskLaterAsynchronously(plugin, task, 0L);
|
||||
}
|
||||
|
||||
@ -152,7 +152,7 @@ public class CraftScheduler implements BukkitScheduler {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runTaskLater(Plugin plugin, Consumer<BukkitTask> task, long delay) throws IllegalArgumentException {
|
||||
public void runTaskLater(Plugin plugin, Consumer<? super BukkitTask> task, long delay) throws IllegalArgumentException {
|
||||
runTaskTimer(plugin, task, delay, CraftTask.NO_REPEATING);
|
||||
}
|
||||
|
||||
@ -168,12 +168,12 @@ public class CraftScheduler implements BukkitScheduler {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runTaskLaterAsynchronously(Plugin plugin, Consumer<BukkitTask> task, long delay) throws IllegalArgumentException {
|
||||
public void runTaskLaterAsynchronously(Plugin plugin, Consumer<? super BukkitTask> task, long delay) throws IllegalArgumentException {
|
||||
runTaskTimerAsynchronously(plugin, task, delay, CraftTask.NO_REPEATING);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runTaskTimerAsynchronously(Plugin plugin, Consumer<BukkitTask> task, long delay, long period) throws IllegalArgumentException {
|
||||
public void runTaskTimerAsynchronously(Plugin plugin, Consumer<? super BukkitTask> task, long delay, long period) throws IllegalArgumentException {
|
||||
runTaskTimerAsynchronously(plugin, (Object) task, delay, CraftTask.NO_REPEATING);
|
||||
}
|
||||
|
||||
@ -188,7 +188,7 @@ public class CraftScheduler implements BukkitScheduler {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runTaskTimer(Plugin plugin, Consumer<BukkitTask> task, long delay, long period) throws IllegalArgumentException {
|
||||
public void runTaskTimer(Plugin plugin, Consumer<? super BukkitTask> task, long delay, long period) throws IllegalArgumentException {
|
||||
runTaskTimer(plugin, (Object) task, delay, period);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user