Add nullability for LivingEntity methods (#1668)

This commit is contained in:
emortaldev 2023-01-08 03:10:53 +00:00 committed by GitHub
parent aa621021e2
commit 84846f663b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -422,8 +422,7 @@ public class LivingEntity extends Entity implements EquipmentHandler {
*
* @return the last damage source, null if not any
*/
@Nullable
public DamageType getLastDamageSource() {
public @Nullable DamageType getLastDamageSource() {
return lastDamageSource;
}
@ -626,7 +625,7 @@ public class LivingEntity extends Entity implements EquipmentHandler {
*
* @param team The new team
*/
public void setTeam(Team team) {
public void setTeam(@Nullable Team team) {
if (this.team == team) return;
String member = this instanceof Player player ? player.getUsername() : uuid.toString();
if (this.team != null) {
@ -643,7 +642,7 @@ public class LivingEntity extends Entity implements EquipmentHandler {
*
* @return the {@link Team}
*/
public Team getTeam() {
public @Nullable Team getTeam() {
return team;
}
@ -653,7 +652,7 @@ public class LivingEntity extends Entity implements EquipmentHandler {
* @param maxDistance The max distance to scan before returning null
* @return The block position targeted by this entity, null if non are found
*/
public Point getTargetBlockPosition(int maxDistance) {
public @Nullable Point getTargetBlockPosition(int maxDistance) {
Iterator<Point> it = new BlockIterator(this, maxDistance);
while (it.hasNext()) {
final Point position = it.next();
@ -667,7 +666,7 @@ public class LivingEntity extends Entity implements EquipmentHandler {
*
* @return null if meta of this entity does not inherit {@link LivingEntityMeta}, casted value otherwise.
*/
public LivingEntityMeta getLivingEntityMeta() {
public @Nullable LivingEntityMeta getLivingEntityMeta() {
if (this.entityMeta instanceof LivingEntityMeta) {
return (LivingEntityMeta) this.entityMeta;
}