diff --git a/src/main/java/baritone/command/defaults/FollowCommand.java b/src/main/java/baritone/command/defaults/FollowCommand.java index a3df5387f..a6e7cc5b2 100644 --- a/src/main/java/baritone/command/defaults/FollowCommand.java +++ b/src/main/java/baritone/command/defaults/FollowCommand.java @@ -24,6 +24,7 @@ import baritone.api.command.argument.IArgConsumer; import baritone.api.command.datatypes.EntityClassById; import baritone.api.command.datatypes.IDatatypeFor; import baritone.api.command.datatypes.NearbyPlayer; +import baritone.api.command.exception.CommandErrorMessageException; import baritone.api.command.exception.CommandException; import baritone.api.command.helpers.TabCompleteHelper; import net.minecraft.entity.Entity; @@ -60,7 +61,7 @@ public class FollowCommand extends Command { if (gotten instanceof Class) { //noinspection unchecked classes.add((Class) gotten); - } else { + } else if (gotten != null) { entities.add((Entity) gotten); } } @@ -73,12 +74,14 @@ public class FollowCommand extends Command { if (group != null) { logDirect(String.format("Following all %s", group.name().toLowerCase(Locale.US))); } else { - logDirect("Following these types of entities:"); if (classes.isEmpty()) { + if (entities.isEmpty()) throw new NoEntitiesException(); + logDirect("Following these entities:"); entities.stream() .map(Entity::toString) .forEach(this::logDirect); } else { + logDirect("Following these types of entities:"); classes.stream() .map(EntityList::getKey) .map(Objects::requireNonNull) @@ -155,4 +158,12 @@ public class FollowCommand extends Command { this.datatype = datatype; } } + + public static class NoEntitiesException extends CommandErrorMessageException { + + protected NoEntitiesException() { + super("No valid entities in range!"); + } + + } }