remove isNull and nonNull
This commit is contained in:
@@ -35,8 +35,6 @@ import java.util.regex.Matcher;
|
|||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static java.util.Objects.isNull;
|
|
||||||
|
|
||||||
public final class BlockOptionalMeta {
|
public final class BlockOptionalMeta {
|
||||||
|
|
||||||
private final Block block;
|
private final Block block;
|
||||||
@@ -50,7 +48,7 @@ public final class BlockOptionalMeta {
|
|||||||
|
|
||||||
public BlockOptionalMeta(@Nonnull Block block, @Nullable Integer meta) {
|
public BlockOptionalMeta(@Nonnull Block block, @Nullable Integer meta) {
|
||||||
this.block = block;
|
this.block = block;
|
||||||
this.noMeta = isNull(meta);
|
this.noMeta = meta == null;
|
||||||
this.meta = noMeta ? 0 : meta;
|
this.meta = noMeta ? 0 : meta;
|
||||||
this.blockstates = getStates(block, meta);
|
this.blockstates = getStates(block, meta);
|
||||||
this.stateHashes = getStateHashes(blockstates);
|
this.stateHashes = getStateHashes(blockstates);
|
||||||
|
@@ -47,9 +47,6 @@ import java.util.Locale;
|
|||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import static java.util.Objects.isNull;
|
|
||||||
import static java.util.Objects.nonNull;
|
|
||||||
|
|
||||||
public class BaritoneChatControl implements Helper, AbstractGameEventListener {
|
public class BaritoneChatControl implements Helper, AbstractGameEventListener {
|
||||||
|
|
||||||
public final IBaritone baritone;
|
public final IBaritone baritone;
|
||||||
@@ -139,7 +136,7 @@ public class BaritoneChatControl implements Helper, AbstractGameEventListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
CommandExecution execution = CommandExecution.from(pair);
|
CommandExecution execution = CommandExecution.from(pair);
|
||||||
if (isNull(execution)) {
|
if (execution == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
logRanCommand(command, rest);
|
logRanCommand(command, rest);
|
||||||
@@ -178,7 +175,7 @@ public class BaritoneChatControl implements Helper, AbstractGameEventListener {
|
|||||||
.stream();
|
.stream();
|
||||||
}
|
}
|
||||||
Settings.Setting setting = settings.byLowerName.get(argc.getString().toLowerCase(Locale.US));
|
Settings.Setting setting = settings.byLowerName.get(argc.getString().toLowerCase(Locale.US));
|
||||||
if (nonNull(setting)) {
|
if (setting != null) {
|
||||||
if (setting.getValueClass() == Boolean.class) {
|
if (setting.getValueClass() == Boolean.class) {
|
||||||
TabCompleteHelper helper = new TabCompleteHelper();
|
TabCompleteHelper helper = new TabCompleteHelper();
|
||||||
if ((Boolean) setting.value) {
|
if ((Boolean) setting.value) {
|
||||||
|
@@ -22,8 +22,6 @@ import baritone.api.utils.command.exception.CommandInvalidTypeException;
|
|||||||
import baritone.api.utils.command.exception.CommandNoParserForTypeException;
|
import baritone.api.utils.command.exception.CommandNoParserForTypeException;
|
||||||
import baritone.api.utils.command.registry.Registry;
|
import baritone.api.utils.command.registry.Registry;
|
||||||
|
|
||||||
import static java.util.Objects.isNull;
|
|
||||||
|
|
||||||
public class ArgParserManager {
|
public class ArgParserManager {
|
||||||
|
|
||||||
public static final Registry<ArgParser> REGISTRY = new Registry<>();
|
public static final Registry<ArgParser> REGISTRY = new Registry<>();
|
||||||
@@ -74,7 +72,7 @@ public class ArgParserManager {
|
|||||||
*/
|
*/
|
||||||
public static <T> T parseStateless(Class<T> klass, CommandArgument arg) {
|
public static <T> T parseStateless(Class<T> klass, CommandArgument arg) {
|
||||||
ArgParser.Stateless<T> parser = getParserStateless(klass);
|
ArgParser.Stateless<T> parser = getParserStateless(klass);
|
||||||
if (isNull(parser)) {
|
if (parser == null) {
|
||||||
throw new CommandNoParserForTypeException(klass);
|
throw new CommandNoParserForTypeException(klass);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
@@ -97,7 +95,7 @@ public class ArgParserManager {
|
|||||||
*/
|
*/
|
||||||
public static <T, S> T parseStated(Class<T> klass, Class<S> stateKlass, CommandArgument arg, S state) {
|
public static <T, S> T parseStated(Class<T> klass, Class<S> stateKlass, CommandArgument arg, S state) {
|
||||||
ArgParser.Stated<T, S> parser = getParserStated(klass, stateKlass);
|
ArgParser.Stated<T, S> parser = getParserStated(klass, stateKlass);
|
||||||
if (isNull(parser)) {
|
if (parser == null) {
|
||||||
throw new CommandNoParserForTypeException(klass);
|
throw new CommandNoParserForTypeException(klass);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
@@ -25,8 +25,6 @@ import net.minecraft.util.ResourceLocation;
|
|||||||
|
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import static java.util.Objects.isNull;
|
|
||||||
|
|
||||||
public class EntityClassById implements IDatatypeFor<Class<? extends Entity>> {
|
public class EntityClassById implements IDatatypeFor<Class<? extends Entity>> {
|
||||||
|
|
||||||
public final Class<? extends Entity> entity;
|
public final Class<? extends Entity> entity;
|
||||||
@@ -37,7 +35,7 @@ public class EntityClassById implements IDatatypeFor<Class<? extends Entity>> {
|
|||||||
|
|
||||||
public EntityClassById(ArgConsumer consumer) {
|
public EntityClassById(ArgConsumer consumer) {
|
||||||
ResourceLocation id = new ResourceLocation(consumer.getString());
|
ResourceLocation id = new ResourceLocation(consumer.getString());
|
||||||
if (isNull(entity = EntityList.REGISTRY.getObject(id))) {
|
if ((entity = EntityList.REGISTRY.getObject(id)) == null) {
|
||||||
throw new IllegalArgumentException("no entity found by that id");
|
throw new IllegalArgumentException("no entity found by that id");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -25,8 +25,6 @@ import net.minecraft.entity.player.EntityPlayer;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import static java.util.Objects.isNull;
|
|
||||||
|
|
||||||
public class PlayerByUsername implements IDatatypeFor<EntityPlayer> {
|
public class PlayerByUsername implements IDatatypeFor<EntityPlayer> {
|
||||||
|
|
||||||
private final List<EntityPlayer> players =
|
private final List<EntityPlayer> players =
|
||||||
@@ -44,7 +42,7 @@ public class PlayerByUsername implements IDatatypeFor<EntityPlayer> {
|
|||||||
.filter(s -> s.getName().equalsIgnoreCase(username))
|
.filter(s -> s.getName().equalsIgnoreCase(username))
|
||||||
.findFirst()
|
.findFirst()
|
||||||
.orElse(null);
|
.orElse(null);
|
||||||
if (isNull(player)) {
|
if (player == null) {
|
||||||
throw new IllegalArgumentException("no player found by that username");
|
throw new IllegalArgumentException("no player found by that username");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -22,8 +22,6 @@ import baritone.api.utils.command.helpers.arguments.ArgConsumer;
|
|||||||
|
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import static java.util.Objects.isNull;
|
|
||||||
|
|
||||||
public class RelativeBlockPos implements IDatatypePost<BetterBlockPos, BetterBlockPos> {
|
public class RelativeBlockPos implements IDatatypePost<BetterBlockPos, BetterBlockPos> {
|
||||||
|
|
||||||
final RelativeCoordinate x;
|
final RelativeCoordinate x;
|
||||||
@@ -55,7 +53,7 @@ public class RelativeBlockPos implements IDatatypePost<BetterBlockPos, BetterBlo
|
|||||||
public Stream<String> tabComplete(ArgConsumer consumer) {
|
public Stream<String> tabComplete(ArgConsumer consumer) {
|
||||||
if (consumer.has() && !consumer.has(4)) {
|
if (consumer.has() && !consumer.has(4)) {
|
||||||
while (consumer.has(2)) {
|
while (consumer.has(2)) {
|
||||||
if (isNull(consumer.peekDatatypeOrNull(RelativeCoordinate.class))) {
|
if (consumer.peekDatatypeOrNull(RelativeCoordinate.class) == null) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
consumer.get();
|
consumer.get();
|
||||||
|
@@ -28,8 +28,6 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import static java.util.Objects.nonNull;
|
|
||||||
|
|
||||||
public class RelativeGoal implements IDatatypePost<Goal, BetterBlockPos> {
|
public class RelativeGoal implements IDatatypePost<Goal, BetterBlockPos> {
|
||||||
|
|
||||||
final RelativeCoordinate[] coords;
|
final RelativeCoordinate[] coords;
|
||||||
@@ -41,7 +39,7 @@ public class RelativeGoal implements IDatatypePost<Goal, BetterBlockPos> {
|
|||||||
public RelativeGoal(ArgConsumer consumer) {
|
public RelativeGoal(ArgConsumer consumer) {
|
||||||
List<RelativeCoordinate> coordsList = new ArrayList<>();
|
List<RelativeCoordinate> coordsList = new ArrayList<>();
|
||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
if (nonNull(consumer.peekDatatypeOrNull(RelativeCoordinate.class))) {
|
if (consumer.peekDatatypeOrNull(RelativeCoordinate.class) != null) {
|
||||||
coordsList.add(consumer.getDatatype(RelativeCoordinate.class));
|
coordsList.add(consumer.getDatatype(RelativeCoordinate.class));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -30,8 +30,6 @@ import com.mojang.realmsclient.util.Pair;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import static java.util.Objects.isNull;
|
|
||||||
|
|
||||||
public class CommandExecution {
|
public class CommandExecution {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -88,7 +86,7 @@ public class CommandExecution {
|
|||||||
|
|
||||||
public static CommandExecution from(String label, ArgConsumer args) {
|
public static CommandExecution from(String label, ArgConsumer args) {
|
||||||
Command command = CommandManager.getCommand(label);
|
Command command = CommandManager.getCommand(label);
|
||||||
if (isNull(command)) {
|
if (command == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return new CommandExecution(
|
return new CommandExecution(
|
||||||
|
@@ -30,7 +30,6 @@ import java.util.List;
|
|||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
|
||||||
import static java.util.Arrays.asList;
|
import static java.util.Arrays.asList;
|
||||||
import static java.util.Objects.nonNull;
|
|
||||||
|
|
||||||
public class Paginator<E> implements Helper {
|
public class Paginator<E> implements Helper {
|
||||||
|
|
||||||
@@ -73,8 +72,8 @@ public class Paginator<E> implements Helper {
|
|||||||
logDirect("--", TextFormatting.DARK_GRAY);
|
logDirect("--", TextFormatting.DARK_GRAY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
boolean hasPrevPage = nonNull(commandPrefix) && validPage(page - 1);
|
boolean hasPrevPage = commandPrefix != null && validPage(page - 1);
|
||||||
boolean hasNextPage = nonNull(commandPrefix) && validPage(page + 1);
|
boolean hasNextPage = commandPrefix != null && validPage(page + 1);
|
||||||
ITextComponent prevPageComponent = new TextComponentString("<<");
|
ITextComponent prevPageComponent = new TextComponentString("<<");
|
||||||
if (hasPrevPage) {
|
if (hasPrevPage) {
|
||||||
prevPageComponent.getStyle()
|
prevPageComponent.getStyle()
|
||||||
@@ -133,7 +132,7 @@ public class Paginator<E> implements Helper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
pagi.skipPages(page - pagi.page);
|
pagi.skipPages(page - pagi.page);
|
||||||
if (nonNull(pre)) {
|
if (pre != null) {
|
||||||
pre.run();
|
pre.run();
|
||||||
}
|
}
|
||||||
pagi.display(transform, commandPrefix);
|
pagi.display(transform, commandPrefix);
|
||||||
|
@@ -29,7 +29,6 @@ import java.util.Locale;
|
|||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import static java.util.Objects.isNull;
|
import static java.util.Objects.isNull;
|
||||||
import static java.util.Objects.nonNull;
|
|
||||||
|
|
||||||
public class CommandManager {
|
public class CommandManager {
|
||||||
|
|
||||||
@@ -54,10 +53,10 @@ public class CommandManager {
|
|||||||
|
|
||||||
public static boolean execute(String string) {
|
public static boolean execute(String string) {
|
||||||
CommandExecution execution = CommandExecution.from(string);
|
CommandExecution execution = CommandExecution.from(string);
|
||||||
if (nonNull(execution)) {
|
if (execution != null) {
|
||||||
execution.execute();
|
execution.execute();
|
||||||
}
|
}
|
||||||
return nonNull(execution);
|
return execution != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Stream<String> tabComplete(CommandExecution execution) {
|
public static Stream<String> tabComplete(CommandExecution execution) {
|
||||||
|
@@ -31,8 +31,6 @@ import org.spongepowered.asm.mixin.injection.At;
|
|||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
|
||||||
import static java.util.Objects.isNull;
|
|
||||||
|
|
||||||
@Mixin(TabCompleter.class)
|
@Mixin(TabCompleter.class)
|
||||||
public abstract class MixinTabCompleter implements ITabCompleter {
|
public abstract class MixinTabCompleter implements ITabCompleter {
|
||||||
|
|
||||||
@@ -105,7 +103,7 @@ public abstract class MixinTabCompleter implements ITabCompleter {
|
|||||||
public boolean onGuiChatSetCompletions(String[] newCompl) {
|
public boolean onGuiChatSetCompletions(String[] newCompl) {
|
||||||
IBaritone baritone = BaritoneAPI.getProvider().getPrimaryBaritone();
|
IBaritone baritone = BaritoneAPI.getProvider().getPrimaryBaritone();
|
||||||
|
|
||||||
if (isNull(baritone)) {
|
if (baritone == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -34,8 +34,6 @@ import net.minecraft.world.chunk.storage.ExtendedBlockStorage;
|
|||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.IntStream;
|
import java.util.stream.IntStream;
|
||||||
|
|
||||||
import static java.util.Objects.nonNull;
|
|
||||||
|
|
||||||
public enum WorldScanner implements IWorldScanner {
|
public enum WorldScanner implements IWorldScanner {
|
||||||
|
|
||||||
INSTANCE;
|
INSTANCE;
|
||||||
@@ -162,7 +160,7 @@ public enum WorldScanner implements IWorldScanner {
|
|||||||
for (int z = playerChunkZ - 40; z <= playerChunkZ + 40; z++) {
|
for (int z = playerChunkZ - 40; z <= playerChunkZ + 40; z++) {
|
||||||
Chunk chunk = chunkProvider.getLoadedChunk(x, z);
|
Chunk chunk = chunkProvider.getLoadedChunk(x, z);
|
||||||
|
|
||||||
if (nonNull(chunk) && !chunk.isEmpty()) {
|
if (chunk != null && !chunk.isEmpty()) {
|
||||||
queued++;
|
queued++;
|
||||||
cachedWorld.queueForPacking(chunk);
|
cachedWorld.queueForPacking(chunk);
|
||||||
}
|
}
|
||||||
|
@@ -30,7 +30,6 @@ import java.util.List;
|
|||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import static java.util.Arrays.asList;
|
import static java.util.Arrays.asList;
|
||||||
import static java.util.Objects.isNull;
|
|
||||||
|
|
||||||
public class ComeCommand extends Command {
|
public class ComeCommand extends Command {
|
||||||
|
|
||||||
@@ -42,7 +41,7 @@ public class ComeCommand extends Command {
|
|||||||
protected void executed(String label, ArgConsumer args, Settings settings) {
|
protected void executed(String label, ArgConsumer args, Settings settings) {
|
||||||
args.requireMax(0);
|
args.requireMax(0);
|
||||||
Entity entity = mc.getRenderViewEntity();
|
Entity entity = mc.getRenderViewEntity();
|
||||||
if (isNull(entity)) {
|
if (entity == null) {
|
||||||
throw new CommandInvalidStateException("render view entity is null");
|
throw new CommandInvalidStateException("render view entity is null");
|
||||||
}
|
}
|
||||||
baritone.getCustomGoalProcess().setGoalAndPath(new GoalBlock(new BlockPos(entity)));
|
baritone.getCustomGoalProcess().setGoalAndPath(new GoalBlock(new BlockPos(entity)));
|
||||||
|
@@ -40,8 +40,6 @@ import java.util.function.Predicate;
|
|||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import static java.util.Arrays.asList;
|
import static java.util.Arrays.asList;
|
||||||
import static java.util.Objects.isNull;
|
|
||||||
import static java.util.Objects.nonNull;
|
|
||||||
|
|
||||||
public class FollowCommand extends Command {
|
public class FollowCommand extends Command {
|
||||||
|
|
||||||
@@ -78,7 +76,7 @@ public class FollowCommand extends Command {
|
|||||||
: e -> classes.stream().anyMatch(c -> c.isInstance(e))
|
: e -> classes.stream().anyMatch(c -> c.isInstance(e))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (nonNull(group)) {
|
if (group != null) {
|
||||||
logDirect(String.format("Following all %s", group.name().toLowerCase(Locale.US)));
|
logDirect(String.format("Following all %s", group.name().toLowerCase(Locale.US)));
|
||||||
} else {
|
} else {
|
||||||
logDirect("Following these types of entities:");
|
logDirect("Following these types of entities:");
|
||||||
@@ -112,7 +110,7 @@ public class FollowCommand extends Command {
|
|||||||
return Stream.empty();
|
return Stream.empty();
|
||||||
}
|
}
|
||||||
while (args.has(2)) {
|
while (args.has(2)) {
|
||||||
if (isNull(args.peekDatatypeOrNull(followType))) {
|
if (args.peekDatatypeOrNull(followType) == null) {
|
||||||
return Stream.empty();
|
return Stream.empty();
|
||||||
}
|
}
|
||||||
args.get();
|
args.get();
|
||||||
|
@@ -32,8 +32,6 @@ import java.util.List;
|
|||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import static java.util.Arrays.asList;
|
import static java.util.Arrays.asList;
|
||||||
import static java.util.Objects.isNull;
|
|
||||||
import static java.util.Objects.nonNull;
|
|
||||||
|
|
||||||
public class GoalCommand extends Command {
|
public class GoalCommand extends Command {
|
||||||
|
|
||||||
@@ -46,7 +44,7 @@ public class GoalCommand extends Command {
|
|||||||
ICustomGoalProcess goalProcess = baritone.getCustomGoalProcess();
|
ICustomGoalProcess goalProcess = baritone.getCustomGoalProcess();
|
||||||
if (args.has() && asList("reset", "clear", "none").contains(args.peekString())) {
|
if (args.has() && asList("reset", "clear", "none").contains(args.peekString())) {
|
||||||
args.requireMax(1);
|
args.requireMax(1);
|
||||||
if (nonNull(goalProcess.getGoal())) {
|
if (goalProcess.getGoal() != null) {
|
||||||
goalProcess.setGoal(null);
|
goalProcess.setGoal(null);
|
||||||
logDirect("Cleared goal");
|
logDirect("Cleared goal");
|
||||||
} else {
|
} else {
|
||||||
@@ -69,7 +67,7 @@ public class GoalCommand extends Command {
|
|||||||
} else {
|
} else {
|
||||||
if (args.hasAtMost(3)) {
|
if (args.hasAtMost(3)) {
|
||||||
while (args.has(2)) {
|
while (args.has(2)) {
|
||||||
if (isNull(args.peekDatatypeOrNull(RelativeCoordinate.class))) {
|
if (args.peekDatatypeOrNull(RelativeCoordinate.class) == null) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
args.get();
|
args.get();
|
||||||
|
@@ -38,7 +38,6 @@ import java.util.stream.Stream;
|
|||||||
import static baritone.api.utils.command.BaritoneChatControl.FORCE_COMMAND_PREFIX;
|
import static baritone.api.utils.command.BaritoneChatControl.FORCE_COMMAND_PREFIX;
|
||||||
import static baritone.api.utils.command.manager.CommandManager.getCommand;
|
import static baritone.api.utils.command.manager.CommandManager.getCommand;
|
||||||
import static java.util.Arrays.asList;
|
import static java.util.Arrays.asList;
|
||||||
import static java.util.Objects.isNull;
|
|
||||||
|
|
||||||
public class HelpCommand extends Command {
|
public class HelpCommand extends Command {
|
||||||
|
|
||||||
@@ -83,7 +82,7 @@ public class HelpCommand extends Command {
|
|||||||
} else {
|
} else {
|
||||||
String commandName = args.getString().toLowerCase();
|
String commandName = args.getString().toLowerCase();
|
||||||
Command command = getCommand(commandName);
|
Command command = getCommand(commandName);
|
||||||
if (isNull(command)) {
|
if (command == null) {
|
||||||
throw new CommandNotFoundException(commandName);
|
throw new CommandNotFoundException(commandName);
|
||||||
}
|
}
|
||||||
logDirect(String.format("%s - %s", String.join(" / ", command.names), command.getShortDesc()));
|
logDirect(String.format("%s - %s", String.join(" / ", command.names), command.getShortDesc()));
|
||||||
|
@@ -30,7 +30,6 @@ import java.util.List;
|
|||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import static java.util.Arrays.asList;
|
import static java.util.Arrays.asList;
|
||||||
import static java.util.Objects.isNull;
|
|
||||||
|
|
||||||
public class InvertCommand extends Command {
|
public class InvertCommand extends Command {
|
||||||
|
|
||||||
@@ -43,7 +42,7 @@ public class InvertCommand extends Command {
|
|||||||
args.requireMax(0);
|
args.requireMax(0);
|
||||||
ICustomGoalProcess customGoalProcess = baritone.getCustomGoalProcess();
|
ICustomGoalProcess customGoalProcess = baritone.getCustomGoalProcess();
|
||||||
Goal goal;
|
Goal goal;
|
||||||
if (isNull(goal = customGoalProcess.getGoal())) {
|
if ((goal = customGoalProcess.getGoal()) == null) {
|
||||||
throw new CommandInvalidStateException("No goal");
|
throw new CommandInvalidStateException("No goal");
|
||||||
}
|
}
|
||||||
if (goal instanceof GoalInverted) {
|
if (goal instanceof GoalInverted) {
|
||||||
|
@@ -33,7 +33,6 @@ import java.util.List;
|
|||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import static java.util.Arrays.asList;
|
import static java.util.Arrays.asList;
|
||||||
import static java.util.Objects.isNull;
|
|
||||||
|
|
||||||
public class PathCommand extends Command {
|
public class PathCommand extends Command {
|
||||||
|
|
||||||
@@ -48,7 +47,7 @@ public class PathCommand extends Command {
|
|||||||
if (args.has()) {
|
if (args.has()) {
|
||||||
args.requireMax(3);
|
args.requireMax(3);
|
||||||
goal = args.getDatatype(RelativeGoal.class).apply(ctx.playerFeet());
|
goal = args.getDatatype(RelativeGoal.class).apply(ctx.playerFeet());
|
||||||
} else if (isNull(goal = customGoalProcess.getGoal())) {
|
} else if ((goal = customGoalProcess.getGoal()) == null) {
|
||||||
throw new CommandInvalidStateException("No goal");
|
throw new CommandInvalidStateException("No goal");
|
||||||
}
|
}
|
||||||
args.requireMax(0);
|
args.requireMax(0);
|
||||||
@@ -61,7 +60,7 @@ public class PathCommand extends Command {
|
|||||||
protected Stream<String> tabCompleted(String label, ArgConsumer args, Settings settings) {
|
protected Stream<String> tabCompleted(String label, ArgConsumer args, Settings settings) {
|
||||||
if (args.has() && !args.has(4)) {
|
if (args.has() && !args.has(4)) {
|
||||||
while (args.has(2)) {
|
while (args.has(2)) {
|
||||||
if (isNull(args.peekDatatypeOrNull(RelativeCoordinate.class))) {
|
if (args.peekDatatypeOrNull(RelativeCoordinate.class) == null) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
args.get();
|
args.get();
|
||||||
|
@@ -30,7 +30,6 @@ import java.util.List;
|
|||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import static java.util.Arrays.asList;
|
import static java.util.Arrays.asList;
|
||||||
import static java.util.Objects.isNull;
|
|
||||||
|
|
||||||
public class ProcCommand extends Command {
|
public class ProcCommand extends Command {
|
||||||
|
|
||||||
@@ -43,7 +42,7 @@ public class ProcCommand extends Command {
|
|||||||
args.requireMax(0);
|
args.requireMax(0);
|
||||||
IPathingControlManager pathingControlManager = baritone.getPathingControlManager();
|
IPathingControlManager pathingControlManager = baritone.getPathingControlManager();
|
||||||
IBaritoneProcess process = pathingControlManager.mostRecentInControl().orElse(null);
|
IBaritoneProcess process = pathingControlManager.mostRecentInControl().orElse(null);
|
||||||
if (isNull(process)) {
|
if (process == null) {
|
||||||
throw new CommandInvalidStateException("No process in control");
|
throw new CommandInvalidStateException("No process in control");
|
||||||
}
|
}
|
||||||
logDirect(String.format(
|
logDirect(String.format(
|
||||||
|
@@ -40,8 +40,6 @@ import static baritone.api.utils.SettingsUtil.settingTypeToString;
|
|||||||
import static baritone.api.utils.SettingsUtil.settingValueToString;
|
import static baritone.api.utils.SettingsUtil.settingValueToString;
|
||||||
import static baritone.api.utils.command.BaritoneChatControl.FORCE_COMMAND_PREFIX;
|
import static baritone.api.utils.command.BaritoneChatControl.FORCE_COMMAND_PREFIX;
|
||||||
import static java.util.Arrays.asList;
|
import static java.util.Arrays.asList;
|
||||||
import static java.util.Objects.isNull;
|
|
||||||
import static java.util.Objects.nonNull;
|
|
||||||
import static java.util.stream.Stream.of;
|
import static java.util.stream.Stream.of;
|
||||||
|
|
||||||
public class SetCommand extends Command {
|
public class SetCommand extends Command {
|
||||||
@@ -126,7 +124,7 @@ public class SetCommand extends Command {
|
|||||||
.filter(s -> s.getName().equalsIgnoreCase(settingName))
|
.filter(s -> s.getName().equalsIgnoreCase(settingName))
|
||||||
.findFirst()
|
.findFirst()
|
||||||
.orElse(null);
|
.orElse(null);
|
||||||
if (isNull(setting)) {
|
if (setting == null) {
|
||||||
throw new CommandInvalidTypeException(args.consumed(), "a valid setting");
|
throw new CommandInvalidTypeException(args.consumed(), "a valid setting");
|
||||||
}
|
}
|
||||||
if (!doingSomething && !args.has()) {
|
if (!doingSomething && !args.has()) {
|
||||||
@@ -204,7 +202,7 @@ public class SetCommand extends Command {
|
|||||||
.stream();
|
.stream();
|
||||||
}
|
}
|
||||||
Settings.Setting setting = settings.byLowerName.get(arg.toLowerCase(Locale.US));
|
Settings.Setting setting = settings.byLowerName.get(arg.toLowerCase(Locale.US));
|
||||||
if (nonNull(setting)) {
|
if (setting != null) {
|
||||||
if (setting.getType() == Boolean.class) {
|
if (setting.getType() == Boolean.class) {
|
||||||
TabCompleteHelper helper = new TabCompleteHelper();
|
TabCompleteHelper helper = new TabCompleteHelper();
|
||||||
if ((Boolean) setting.value) {
|
if ((Boolean) setting.value) {
|
||||||
|
@@ -27,7 +27,6 @@ import java.util.List;
|
|||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import static java.util.Arrays.asList;
|
import static java.util.Arrays.asList;
|
||||||
import static java.util.Objects.isNull;
|
|
||||||
|
|
||||||
public class VersionCommand extends Command {
|
public class VersionCommand extends Command {
|
||||||
|
|
||||||
@@ -39,7 +38,7 @@ public class VersionCommand extends Command {
|
|||||||
protected void executed(String label, ArgConsumer args, Settings settings) {
|
protected void executed(String label, ArgConsumer args, Settings settings) {
|
||||||
args.requireMax(0);
|
args.requireMax(0);
|
||||||
String version = getClass().getPackage().getImplementationVersion();
|
String version = getClass().getPackage().getImplementationVersion();
|
||||||
if (isNull(version)) {
|
if (version == null) {
|
||||||
throw new CommandInvalidStateException("Null version (this is normal in a dev environment)");
|
throw new CommandInvalidStateException("Null version (this is normal in a dev environment)");
|
||||||
} else {
|
} else {
|
||||||
logDirect(String.format("You are running Baritone v%s", version));
|
logDirect(String.format("You are running Baritone v%s", version));
|
||||||
|
Reference in New Issue
Block a user