From b63c54b657f8211e289349edc6c6b873067ec2af Mon Sep 17 00:00:00 2001 From: Leijurv Date: Thu, 19 Sep 2019 14:09:09 -0700 Subject: [PATCH] remove isNull and nonNull --- src/api/java/baritone/api/utils/BlockOptionalMeta.java | 4 +--- .../baritone/api/utils/command/BaritoneChatControl.java | 7 ++----- .../api/utils/command/argparser/ArgParserManager.java | 6 ++---- .../api/utils/command/datatypes/EntityClassById.java | 4 +--- .../api/utils/command/datatypes/PlayerByUsername.java | 4 +--- .../api/utils/command/datatypes/RelativeBlockPos.java | 4 +--- .../baritone/api/utils/command/datatypes/RelativeGoal.java | 4 +--- .../api/utils/command/execution/CommandExecution.java | 4 +--- .../api/utils/command/helpers/pagination/Paginator.java | 7 +++---- .../baritone/api/utils/command/manager/CommandManager.java | 5 ++--- .../java/baritone/launch/mixins/MixinTabCompleter.java | 4 +--- src/main/java/baritone/cache/WorldScanner.java | 4 +--- .../java/baritone/utils/command/defaults/ComeCommand.java | 3 +-- .../baritone/utils/command/defaults/FollowCommand.java | 6 ++---- .../java/baritone/utils/command/defaults/GoalCommand.java | 6 ++---- .../java/baritone/utils/command/defaults/HelpCommand.java | 3 +-- .../baritone/utils/command/defaults/InvertCommand.java | 3 +-- .../java/baritone/utils/command/defaults/PathCommand.java | 5 ++--- .../java/baritone/utils/command/defaults/ProcCommand.java | 3 +-- .../java/baritone/utils/command/defaults/SetCommand.java | 6 ++---- .../baritone/utils/command/defaults/VersionCommand.java | 3 +-- 21 files changed, 30 insertions(+), 65 deletions(-) diff --git a/src/api/java/baritone/api/utils/BlockOptionalMeta.java b/src/api/java/baritone/api/utils/BlockOptionalMeta.java index 7effe4bd..c65b6d3d 100644 --- a/src/api/java/baritone/api/utils/BlockOptionalMeta.java +++ b/src/api/java/baritone/api/utils/BlockOptionalMeta.java @@ -35,8 +35,6 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.stream.Collectors; -import static java.util.Objects.isNull; - public final class BlockOptionalMeta { private final Block block; @@ -50,7 +48,7 @@ public final class BlockOptionalMeta { public BlockOptionalMeta(@Nonnull Block block, @Nullable Integer meta) { this.block = block; - this.noMeta = isNull(meta); + this.noMeta = meta == null; this.meta = noMeta ? 0 : meta; this.blockstates = getStates(block, meta); this.stateHashes = getStateHashes(blockstates); diff --git a/src/api/java/baritone/api/utils/command/BaritoneChatControl.java b/src/api/java/baritone/api/utils/command/BaritoneChatControl.java index d7b07872..0c6fc5fd 100644 --- a/src/api/java/baritone/api/utils/command/BaritoneChatControl.java +++ b/src/api/java/baritone/api/utils/command/BaritoneChatControl.java @@ -47,9 +47,6 @@ import java.util.Locale; import java.util.UUID; import java.util.stream.Stream; -import static java.util.Objects.isNull; -import static java.util.Objects.nonNull; - public class BaritoneChatControl implements Helper, AbstractGameEventListener { public final IBaritone baritone; @@ -139,7 +136,7 @@ public class BaritoneChatControl implements Helper, AbstractGameEventListener { } } CommandExecution execution = CommandExecution.from(pair); - if (isNull(execution)) { + if (execution == null) { return false; } logRanCommand(command, rest); @@ -178,7 +175,7 @@ public class BaritoneChatControl implements Helper, AbstractGameEventListener { .stream(); } Settings.Setting setting = settings.byLowerName.get(argc.getString().toLowerCase(Locale.US)); - if (nonNull(setting)) { + if (setting != null) { if (setting.getValueClass() == Boolean.class) { TabCompleteHelper helper = new TabCompleteHelper(); if ((Boolean) setting.value) { diff --git a/src/api/java/baritone/api/utils/command/argparser/ArgParserManager.java b/src/api/java/baritone/api/utils/command/argparser/ArgParserManager.java index 8d8d160b..a87a8925 100644 --- a/src/api/java/baritone/api/utils/command/argparser/ArgParserManager.java +++ b/src/api/java/baritone/api/utils/command/argparser/ArgParserManager.java @@ -22,8 +22,6 @@ import baritone.api.utils.command.exception.CommandInvalidTypeException; import baritone.api.utils.command.exception.CommandNoParserForTypeException; import baritone.api.utils.command.registry.Registry; -import static java.util.Objects.isNull; - public class ArgParserManager { public static final Registry REGISTRY = new Registry<>(); @@ -74,7 +72,7 @@ public class ArgParserManager { */ public static T parseStateless(Class klass, CommandArgument arg) { ArgParser.Stateless parser = getParserStateless(klass); - if (isNull(parser)) { + if (parser == null) { throw new CommandNoParserForTypeException(klass); } try { @@ -97,7 +95,7 @@ public class ArgParserManager { */ public static T parseStated(Class klass, Class stateKlass, CommandArgument arg, S state) { ArgParser.Stated parser = getParserStated(klass, stateKlass); - if (isNull(parser)) { + if (parser == null) { throw new CommandNoParserForTypeException(klass); } try { diff --git a/src/api/java/baritone/api/utils/command/datatypes/EntityClassById.java b/src/api/java/baritone/api/utils/command/datatypes/EntityClassById.java index a6dcad75..45546119 100644 --- a/src/api/java/baritone/api/utils/command/datatypes/EntityClassById.java +++ b/src/api/java/baritone/api/utils/command/datatypes/EntityClassById.java @@ -25,8 +25,6 @@ import net.minecraft.util.ResourceLocation; import java.util.stream.Stream; -import static java.util.Objects.isNull; - public class EntityClassById implements IDatatypeFor> { public final Class entity; @@ -37,7 +35,7 @@ public class EntityClassById implements IDatatypeFor> { public EntityClassById(ArgConsumer consumer) { 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"); } } diff --git a/src/api/java/baritone/api/utils/command/datatypes/PlayerByUsername.java b/src/api/java/baritone/api/utils/command/datatypes/PlayerByUsername.java index d8406606..5cf25066 100644 --- a/src/api/java/baritone/api/utils/command/datatypes/PlayerByUsername.java +++ b/src/api/java/baritone/api/utils/command/datatypes/PlayerByUsername.java @@ -25,8 +25,6 @@ import net.minecraft.entity.player.EntityPlayer; import java.util.List; import java.util.stream.Stream; -import static java.util.Objects.isNull; - public class PlayerByUsername implements IDatatypeFor { private final List players = @@ -44,7 +42,7 @@ public class PlayerByUsername implements IDatatypeFor { .filter(s -> s.getName().equalsIgnoreCase(username)) .findFirst() .orElse(null); - if (isNull(player)) { + if (player == null) { throw new IllegalArgumentException("no player found by that username"); } } diff --git a/src/api/java/baritone/api/utils/command/datatypes/RelativeBlockPos.java b/src/api/java/baritone/api/utils/command/datatypes/RelativeBlockPos.java index b69fe003..610b8d5f 100644 --- a/src/api/java/baritone/api/utils/command/datatypes/RelativeBlockPos.java +++ b/src/api/java/baritone/api/utils/command/datatypes/RelativeBlockPos.java @@ -22,8 +22,6 @@ import baritone.api.utils.command.helpers.arguments.ArgConsumer; import java.util.stream.Stream; -import static java.util.Objects.isNull; - public class RelativeBlockPos implements IDatatypePost { final RelativeCoordinate x; @@ -55,7 +53,7 @@ public class RelativeBlockPos implements IDatatypePost tabComplete(ArgConsumer consumer) { if (consumer.has() && !consumer.has(4)) { while (consumer.has(2)) { - if (isNull(consumer.peekDatatypeOrNull(RelativeCoordinate.class))) { + if (consumer.peekDatatypeOrNull(RelativeCoordinate.class) == null) { break; } consumer.get(); diff --git a/src/api/java/baritone/api/utils/command/datatypes/RelativeGoal.java b/src/api/java/baritone/api/utils/command/datatypes/RelativeGoal.java index 6abb88b7..d3aad7b9 100644 --- a/src/api/java/baritone/api/utils/command/datatypes/RelativeGoal.java +++ b/src/api/java/baritone/api/utils/command/datatypes/RelativeGoal.java @@ -28,8 +28,6 @@ import java.util.ArrayList; import java.util.List; import java.util.stream.Stream; -import static java.util.Objects.nonNull; - public class RelativeGoal implements IDatatypePost { final RelativeCoordinate[] coords; @@ -41,7 +39,7 @@ public class RelativeGoal implements IDatatypePost { public RelativeGoal(ArgConsumer consumer) { List coordsList = new ArrayList<>(); 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)); } } diff --git a/src/api/java/baritone/api/utils/command/execution/CommandExecution.java b/src/api/java/baritone/api/utils/command/execution/CommandExecution.java index 26716b87..b82926e4 100644 --- a/src/api/java/baritone/api/utils/command/execution/CommandExecution.java +++ b/src/api/java/baritone/api/utils/command/execution/CommandExecution.java @@ -30,8 +30,6 @@ import com.mojang.realmsclient.util.Pair; import java.util.List; import java.util.stream.Stream; -import static java.util.Objects.isNull; - public class CommandExecution { /** @@ -88,7 +86,7 @@ public class CommandExecution { public static CommandExecution from(String label, ArgConsumer args) { Command command = CommandManager.getCommand(label); - if (isNull(command)) { + if (command == null) { return null; } return new CommandExecution( diff --git a/src/api/java/baritone/api/utils/command/helpers/pagination/Paginator.java b/src/api/java/baritone/api/utils/command/helpers/pagination/Paginator.java index 3904408f..05016d63 100644 --- a/src/api/java/baritone/api/utils/command/helpers/pagination/Paginator.java +++ b/src/api/java/baritone/api/utils/command/helpers/pagination/Paginator.java @@ -30,7 +30,6 @@ import java.util.List; import java.util.function.Function; import static java.util.Arrays.asList; -import static java.util.Objects.nonNull; public class Paginator implements Helper { @@ -73,8 +72,8 @@ public class Paginator implements Helper { logDirect("--", TextFormatting.DARK_GRAY); } } - boolean hasPrevPage = nonNull(commandPrefix) && validPage(page - 1); - boolean hasNextPage = nonNull(commandPrefix) && validPage(page + 1); + boolean hasPrevPage = commandPrefix != null && validPage(page - 1); + boolean hasNextPage = commandPrefix != null && validPage(page + 1); ITextComponent prevPageComponent = new TextComponentString("<<"); if (hasPrevPage) { prevPageComponent.getStyle() @@ -133,7 +132,7 @@ public class Paginator implements Helper { } } pagi.skipPages(page - pagi.page); - if (nonNull(pre)) { + if (pre != null) { pre.run(); } pagi.display(transform, commandPrefix); diff --git a/src/api/java/baritone/api/utils/command/manager/CommandManager.java b/src/api/java/baritone/api/utils/command/manager/CommandManager.java index ad90131b..8203ce45 100644 --- a/src/api/java/baritone/api/utils/command/manager/CommandManager.java +++ b/src/api/java/baritone/api/utils/command/manager/CommandManager.java @@ -29,7 +29,6 @@ import java.util.Locale; import java.util.stream.Stream; import static java.util.Objects.isNull; -import static java.util.Objects.nonNull; public class CommandManager { @@ -54,10 +53,10 @@ public class CommandManager { public static boolean execute(String string) { CommandExecution execution = CommandExecution.from(string); - if (nonNull(execution)) { + if (execution != null) { execution.execute(); } - return nonNull(execution); + return execution != null; } public static Stream tabComplete(CommandExecution execution) { diff --git a/src/launch/java/baritone/launch/mixins/MixinTabCompleter.java b/src/launch/java/baritone/launch/mixins/MixinTabCompleter.java index 7de73ead..cdbae3b4 100644 --- a/src/launch/java/baritone/launch/mixins/MixinTabCompleter.java +++ b/src/launch/java/baritone/launch/mixins/MixinTabCompleter.java @@ -31,8 +31,6 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import static java.util.Objects.isNull; - @Mixin(TabCompleter.class) public abstract class MixinTabCompleter implements ITabCompleter { @@ -105,7 +103,7 @@ public abstract class MixinTabCompleter implements ITabCompleter { public boolean onGuiChatSetCompletions(String[] newCompl) { IBaritone baritone = BaritoneAPI.getProvider().getPrimaryBaritone(); - if (isNull(baritone)) { + if (baritone == null) { return false; } diff --git a/src/main/java/baritone/cache/WorldScanner.java b/src/main/java/baritone/cache/WorldScanner.java index de9e6fe9..d31c17ab 100644 --- a/src/main/java/baritone/cache/WorldScanner.java +++ b/src/main/java/baritone/cache/WorldScanner.java @@ -34,8 +34,6 @@ import net.minecraft.world.chunk.storage.ExtendedBlockStorage; import java.util.*; import java.util.stream.IntStream; -import static java.util.Objects.nonNull; - public enum WorldScanner implements IWorldScanner { INSTANCE; @@ -162,7 +160,7 @@ public enum WorldScanner implements IWorldScanner { for (int z = playerChunkZ - 40; z <= playerChunkZ + 40; z++) { Chunk chunk = chunkProvider.getLoadedChunk(x, z); - if (nonNull(chunk) && !chunk.isEmpty()) { + if (chunk != null && !chunk.isEmpty()) { queued++; cachedWorld.queueForPacking(chunk); } diff --git a/src/main/java/baritone/utils/command/defaults/ComeCommand.java b/src/main/java/baritone/utils/command/defaults/ComeCommand.java index 857d8d01..e6b1431a 100644 --- a/src/main/java/baritone/utils/command/defaults/ComeCommand.java +++ b/src/main/java/baritone/utils/command/defaults/ComeCommand.java @@ -30,7 +30,6 @@ import java.util.List; import java.util.stream.Stream; import static java.util.Arrays.asList; -import static java.util.Objects.isNull; public class ComeCommand extends Command { @@ -42,7 +41,7 @@ public class ComeCommand extends Command { protected void executed(String label, ArgConsumer args, Settings settings) { args.requireMax(0); Entity entity = mc.getRenderViewEntity(); - if (isNull(entity)) { + if (entity == null) { throw new CommandInvalidStateException("render view entity is null"); } baritone.getCustomGoalProcess().setGoalAndPath(new GoalBlock(new BlockPos(entity))); diff --git a/src/main/java/baritone/utils/command/defaults/FollowCommand.java b/src/main/java/baritone/utils/command/defaults/FollowCommand.java index 9502b6af..5424fd14 100644 --- a/src/main/java/baritone/utils/command/defaults/FollowCommand.java +++ b/src/main/java/baritone/utils/command/defaults/FollowCommand.java @@ -40,8 +40,6 @@ import java.util.function.Predicate; import java.util.stream.Stream; import static java.util.Arrays.asList; -import static java.util.Objects.isNull; -import static java.util.Objects.nonNull; public class FollowCommand extends Command { @@ -78,7 +76,7 @@ public class FollowCommand extends Command { : 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))); } else { logDirect("Following these types of entities:"); @@ -112,7 +110,7 @@ public class FollowCommand extends Command { return Stream.empty(); } while (args.has(2)) { - if (isNull(args.peekDatatypeOrNull(followType))) { + if (args.peekDatatypeOrNull(followType) == null) { return Stream.empty(); } args.get(); diff --git a/src/main/java/baritone/utils/command/defaults/GoalCommand.java b/src/main/java/baritone/utils/command/defaults/GoalCommand.java index a62355c3..c793182a 100644 --- a/src/main/java/baritone/utils/command/defaults/GoalCommand.java +++ b/src/main/java/baritone/utils/command/defaults/GoalCommand.java @@ -32,8 +32,6 @@ import java.util.List; import java.util.stream.Stream; import static java.util.Arrays.asList; -import static java.util.Objects.isNull; -import static java.util.Objects.nonNull; public class GoalCommand extends Command { @@ -46,7 +44,7 @@ public class GoalCommand extends Command { ICustomGoalProcess goalProcess = baritone.getCustomGoalProcess(); if (args.has() && asList("reset", "clear", "none").contains(args.peekString())) { args.requireMax(1); - if (nonNull(goalProcess.getGoal())) { + if (goalProcess.getGoal() != null) { goalProcess.setGoal(null); logDirect("Cleared goal"); } else { @@ -69,7 +67,7 @@ public class GoalCommand extends Command { } else { if (args.hasAtMost(3)) { while (args.has(2)) { - if (isNull(args.peekDatatypeOrNull(RelativeCoordinate.class))) { + if (args.peekDatatypeOrNull(RelativeCoordinate.class) == null) { break; } args.get(); diff --git a/src/main/java/baritone/utils/command/defaults/HelpCommand.java b/src/main/java/baritone/utils/command/defaults/HelpCommand.java index 289e709e..b41e5d28 100644 --- a/src/main/java/baritone/utils/command/defaults/HelpCommand.java +++ b/src/main/java/baritone/utils/command/defaults/HelpCommand.java @@ -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.manager.CommandManager.getCommand; import static java.util.Arrays.asList; -import static java.util.Objects.isNull; public class HelpCommand extends Command { @@ -83,7 +82,7 @@ public class HelpCommand extends Command { } else { String commandName = args.getString().toLowerCase(); Command command = getCommand(commandName); - if (isNull(command)) { + if (command == null) { throw new CommandNotFoundException(commandName); } logDirect(String.format("%s - %s", String.join(" / ", command.names), command.getShortDesc())); diff --git a/src/main/java/baritone/utils/command/defaults/InvertCommand.java b/src/main/java/baritone/utils/command/defaults/InvertCommand.java index 368bdc4e..e7c8ef8f 100644 --- a/src/main/java/baritone/utils/command/defaults/InvertCommand.java +++ b/src/main/java/baritone/utils/command/defaults/InvertCommand.java @@ -30,7 +30,6 @@ import java.util.List; import java.util.stream.Stream; import static java.util.Arrays.asList; -import static java.util.Objects.isNull; public class InvertCommand extends Command { @@ -43,7 +42,7 @@ public class InvertCommand extends Command { args.requireMax(0); ICustomGoalProcess customGoalProcess = baritone.getCustomGoalProcess(); Goal goal; - if (isNull(goal = customGoalProcess.getGoal())) { + if ((goal = customGoalProcess.getGoal()) == null) { throw new CommandInvalidStateException("No goal"); } if (goal instanceof GoalInverted) { diff --git a/src/main/java/baritone/utils/command/defaults/PathCommand.java b/src/main/java/baritone/utils/command/defaults/PathCommand.java index 3a0fc5d4..5f3c06bc 100644 --- a/src/main/java/baritone/utils/command/defaults/PathCommand.java +++ b/src/main/java/baritone/utils/command/defaults/PathCommand.java @@ -33,7 +33,6 @@ import java.util.List; import java.util.stream.Stream; import static java.util.Arrays.asList; -import static java.util.Objects.isNull; public class PathCommand extends Command { @@ -48,7 +47,7 @@ public class PathCommand extends Command { if (args.has()) { args.requireMax(3); 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"); } args.requireMax(0); @@ -61,7 +60,7 @@ public class PathCommand extends Command { protected Stream tabCompleted(String label, ArgConsumer args, Settings settings) { if (args.has() && !args.has(4)) { while (args.has(2)) { - if (isNull(args.peekDatatypeOrNull(RelativeCoordinate.class))) { + if (args.peekDatatypeOrNull(RelativeCoordinate.class) == null) { break; } args.get(); diff --git a/src/main/java/baritone/utils/command/defaults/ProcCommand.java b/src/main/java/baritone/utils/command/defaults/ProcCommand.java index 03e069d0..33a29362 100644 --- a/src/main/java/baritone/utils/command/defaults/ProcCommand.java +++ b/src/main/java/baritone/utils/command/defaults/ProcCommand.java @@ -30,7 +30,6 @@ import java.util.List; import java.util.stream.Stream; import static java.util.Arrays.asList; -import static java.util.Objects.isNull; public class ProcCommand extends Command { @@ -43,7 +42,7 @@ public class ProcCommand extends Command { args.requireMax(0); IPathingControlManager pathingControlManager = baritone.getPathingControlManager(); IBaritoneProcess process = pathingControlManager.mostRecentInControl().orElse(null); - if (isNull(process)) { + if (process == null) { throw new CommandInvalidStateException("No process in control"); } logDirect(String.format( diff --git a/src/main/java/baritone/utils/command/defaults/SetCommand.java b/src/main/java/baritone/utils/command/defaults/SetCommand.java index 96130414..4c93f77a 100644 --- a/src/main/java/baritone/utils/command/defaults/SetCommand.java +++ b/src/main/java/baritone/utils/command/defaults/SetCommand.java @@ -40,8 +40,6 @@ import static baritone.api.utils.SettingsUtil.settingTypeToString; import static baritone.api.utils.SettingsUtil.settingValueToString; import static baritone.api.utils.command.BaritoneChatControl.FORCE_COMMAND_PREFIX; 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; public class SetCommand extends Command { @@ -126,7 +124,7 @@ public class SetCommand extends Command { .filter(s -> s.getName().equalsIgnoreCase(settingName)) .findFirst() .orElse(null); - if (isNull(setting)) { + if (setting == null) { throw new CommandInvalidTypeException(args.consumed(), "a valid setting"); } if (!doingSomething && !args.has()) { @@ -204,7 +202,7 @@ public class SetCommand extends Command { .stream(); } Settings.Setting setting = settings.byLowerName.get(arg.toLowerCase(Locale.US)); - if (nonNull(setting)) { + if (setting != null) { if (setting.getType() == Boolean.class) { TabCompleteHelper helper = new TabCompleteHelper(); if ((Boolean) setting.value) { diff --git a/src/main/java/baritone/utils/command/defaults/VersionCommand.java b/src/main/java/baritone/utils/command/defaults/VersionCommand.java index f795315d..ef07b688 100644 --- a/src/main/java/baritone/utils/command/defaults/VersionCommand.java +++ b/src/main/java/baritone/utils/command/defaults/VersionCommand.java @@ -27,7 +27,6 @@ import java.util.List; import java.util.stream.Stream; import static java.util.Arrays.asList; -import static java.util.Objects.isNull; public class VersionCommand extends Command { @@ -39,7 +38,7 @@ public class VersionCommand extends Command { protected void executed(String label, ArgConsumer args, Settings settings) { args.requireMax(0); String version = getClass().getPackage().getImplementationVersion(); - if (isNull(version)) { + if (version == null) { throw new CommandInvalidStateException("Null version (this is normal in a dev environment)"); } else { logDirect(String.format("You are running Baritone v%s", version));