mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-04 23:47:59 +01:00
Lambda cleanup
This commit is contained in:
parent
f7d30feb7f
commit
19e3bee23c
@ -823,6 +823,10 @@ public class Entity implements Viewable, Tickable, TagHandler, PermissionHandler
|
|||||||
this.gravityAcceleration = gravityAcceleration;
|
this.gravityAcceleration = gravityAcceleration;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public double getDistance(@NotNull Point point) {
|
||||||
|
return getPosition().distance(point);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the distance between two entities.
|
* Gets the distance between two entities.
|
||||||
*
|
*
|
||||||
@ -830,7 +834,7 @@ public class Entity implements Viewable, Tickable, TagHandler, PermissionHandler
|
|||||||
* @return the distance between this and {@code entity}
|
* @return the distance between this and {@code entity}
|
||||||
*/
|
*/
|
||||||
public double getDistance(@NotNull Entity entity) {
|
public double getDistance(@NotNull Entity entity) {
|
||||||
return getPosition().distance(entity.getPosition());
|
return getDistance(entity.getPosition());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -149,10 +149,9 @@ public class EntityFinder {
|
|||||||
if (distance != null) {
|
if (distance != null) {
|
||||||
final int minDistance = distance.getMinimum();
|
final int minDistance = distance.getMinimum();
|
||||||
final int maxDistance = distance.getMaximum();
|
final int maxDistance = distance.getMaximum();
|
||||||
result = result.stream().filter(entity -> {
|
result = result.stream()
|
||||||
final int distance = (int) entity.getPosition().distance(pos);
|
.filter(entity -> MathUtils.isBetween(entity.getDistance(pos), minDistance, maxDistance))
|
||||||
return MathUtils.isBetween(distance, minDistance, maxDistance);
|
.collect(Collectors.toList());
|
||||||
}).collect(Collectors.toList());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Diff X/Y/Z
|
// Diff X/Y/Z
|
||||||
@ -180,46 +179,42 @@ public class EntityFinder {
|
|||||||
|
|
||||||
// Entity type
|
// Entity type
|
||||||
if (!entityTypes.isEmpty()) {
|
if (!entityTypes.isEmpty()) {
|
||||||
result = result.stream().filter(entity ->
|
result = result.stream()
|
||||||
filterToggleableMap(entity.getEntityType(), entityTypes))
|
.filter(entity -> filterToggleableMap(entity.getEntityType(), entityTypes))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
// GameMode
|
// GameMode
|
||||||
if (!gameModes.isEmpty()) {
|
if (!gameModes.isEmpty()) {
|
||||||
result = result.stream().filter(entity -> {
|
result = result.stream()
|
||||||
if (!(entity instanceof Player))
|
.filter(Player.class::isInstance)
|
||||||
return false;
|
.filter(entity -> filterToggleableMap(((Player) entity).getGameMode(), gameModes))
|
||||||
return filterToggleableMap(((Player) entity).getGameMode(), gameModes);
|
.collect(Collectors.toList());
|
||||||
}).collect(Collectors.toList());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Level
|
// Level
|
||||||
if (level != null) {
|
if (level != null) {
|
||||||
final int minLevel = level.getMinimum();
|
final int minLevel = level.getMinimum();
|
||||||
final int maxLevel = level.getMaximum();
|
final int maxLevel = level.getMaximum();
|
||||||
result = result.stream().filter(entity -> {
|
result = result.stream()
|
||||||
if (!(entity instanceof Player))
|
.filter(Player.class::isInstance)
|
||||||
return false;
|
.filter(entity -> MathUtils.isBetween(((Player) entity).getLevel(), minLevel, maxLevel))
|
||||||
|
.collect(Collectors.toList());
|
||||||
final int level = ((Player) entity).getLevel();
|
|
||||||
return MathUtils.isBetween(level, minLevel, maxLevel);
|
|
||||||
}).collect(Collectors.toList());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Name
|
// Name
|
||||||
if (!names.isEmpty()) {
|
if (!names.isEmpty()) {
|
||||||
result = result.stream().filter(entity -> {
|
result = result.stream()
|
||||||
if (!(entity instanceof Player))
|
.filter(Player.class::isInstance)
|
||||||
return false;
|
.filter(entity -> filterToggleableMap(((Player) entity).getUsername(), names))
|
||||||
return filterToggleableMap(((Player) entity).getUsername(), names);
|
.collect(Collectors.toList());
|
||||||
}).collect(Collectors.toList());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// UUID
|
// UUID
|
||||||
if (!uuids.isEmpty()) {
|
if (!uuids.isEmpty()) {
|
||||||
result = result.stream().filter(entity ->
|
result = result.stream()
|
||||||
filterToggleableMap(entity.getUuid(), uuids)).collect(Collectors.toList());
|
.filter(entity -> filterToggleableMap(entity.getUuid(), uuids))
|
||||||
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user