remove isNull and nonNull

This commit is contained in:
Leijurv 2019-09-19 14:09:09 -07:00
parent 3c914de690
commit b63c54b657
No known key found for this signature in database
GPG Key ID: 44A3EA646EADAC6A
21 changed files with 30 additions and 65 deletions

View File

@ -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);

View File

@ -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) {

View File

@ -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<ArgParser> REGISTRY = new Registry<>();
@ -74,7 +72,7 @@ public class ArgParserManager {
*/
public static <T> T parseStateless(Class<T> klass, CommandArgument arg) {
ArgParser.Stateless<T> parser = getParserStateless(klass);
if (isNull(parser)) {
if (parser == null) {
throw new CommandNoParserForTypeException(klass);
}
try {
@ -97,7 +95,7 @@ public class ArgParserManager {
*/
public static <T, S> T parseStated(Class<T> klass, Class<S> stateKlass, CommandArgument arg, S state) {
ArgParser.Stated<T, S> parser = getParserStated(klass, stateKlass);
if (isNull(parser)) {
if (parser == null) {
throw new CommandNoParserForTypeException(klass);
}
try {

View File

@ -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<Class<? extends Entity>> {
public final Class<? extends Entity> entity;
@ -37,7 +35,7 @@ public class EntityClassById implements IDatatypeFor<Class<? extends Entity>> {
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");
}
}

View File

@ -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<EntityPlayer> {
private final List<EntityPlayer> players =
@ -44,7 +42,7 @@ public class PlayerByUsername implements IDatatypeFor<EntityPlayer> {
.filter(s -> s.getName().equalsIgnoreCase(username))
.findFirst()
.orElse(null);
if (isNull(player)) {
if (player == null) {
throw new IllegalArgumentException("no player found by that username");
}
}

View File

@ -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<BetterBlockPos, BetterBlockPos> {
final RelativeCoordinate x;
@ -55,7 +53,7 @@ public class RelativeBlockPos implements IDatatypePost<BetterBlockPos, BetterBlo
public Stream<String> 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();

View File

@ -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<Goal, BetterBlockPos> {
final RelativeCoordinate[] coords;
@ -41,7 +39,7 @@ public class RelativeGoal implements IDatatypePost<Goal, BetterBlockPos> {
public RelativeGoal(ArgConsumer consumer) {
List<RelativeCoordinate> 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));
}
}

View File

@ -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(

View File

@ -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<E> implements Helper {
@ -73,8 +72,8 @@ public class Paginator<E> 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<E> implements Helper {
}
}
pagi.skipPages(page - pagi.page);
if (nonNull(pre)) {
if (pre != null) {
pre.run();
}
pagi.display(transform, commandPrefix);

View File

@ -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<String> tabComplete(CommandExecution execution) {

View File

@ -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;
}

View File

@ -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);
}

View File

@ -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)));

View File

@ -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();

View File

@ -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();

View File

@ -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()));

View File

@ -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) {

View File

@ -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<String> 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();

View File

@ -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(

View File

@ -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) {

View File

@ -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));