Use nonNull rather than !isNull

Dieser Commit ist enthalten in:
Matthew Miller 2019-02-16 19:58:06 +10:00
Ursprung db1315e043
Commit 3683a0438a

Datei anzeigen

@ -1,180 +1,179 @@
/* /*
* WorldEdit, a Minecraft world manipulation toolkit * WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com> * Copyright (C) sk89q <http://www.sk89q.com>
* Copyright (C) WorldEdit team and contributors * Copyright (C) WorldEdit team and contributors
* *
* This program is free software: you can redistribute it and/or modify it * This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the * under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or * Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, but WITHOUT * This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details. * for more details.
* *
* You should have received a copy of the GNU Lesser General Public License * You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package com.sk89q.worldedit; package com.sk89q.worldedit;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.sk89q.worldedit.util.logging.LogFormat; import com.sk89q.worldedit.util.logging.LogFormat;
import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockType;
import com.sk89q.worldedit.world.block.BlockTypes; import com.sk89q.worldedit.world.block.BlockTypes;
import com.sk89q.worldedit.world.registry.LegacyMapper; import com.sk89q.worldedit.world.registry.LegacyMapper;
import com.sk89q.worldedit.world.snapshot.SnapshotRepository; import com.sk89q.worldedit.world.snapshot.SnapshotRepository;
import java.io.File; import java.io.File;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
import java.util.Set; import java.util.Set;
import java.util.function.IntFunction;
/**
/** * Represents WorldEdit's configuration.
* Represents WorldEdit's configuration. */
*/ public abstract class LocalConfiguration {
public abstract class LocalConfiguration {
public boolean profile = false;
public boolean profile = false; public boolean traceUnflushedSessions = false;
public boolean traceUnflushedSessions = false; public Set<String> disallowedBlocks = new HashSet<>();
public Set<String> disallowedBlocks = new HashSet<>(); public int defaultChangeLimit = -1;
public int defaultChangeLimit = -1; public int maxChangeLimit = -1;
public int maxChangeLimit = -1; public int defaultMaxPolygonalPoints = -1;
public int defaultMaxPolygonalPoints = -1; public int maxPolygonalPoints = 20;
public int maxPolygonalPoints = 20; public int defaultMaxPolyhedronPoints = -1;
public int defaultMaxPolyhedronPoints = -1; public int maxPolyhedronPoints = 20;
public int maxPolyhedronPoints = 20; public String shellSaveType = "";
public String shellSaveType = ""; public SnapshotRepository snapshotRepo = null;
public SnapshotRepository snapshotRepo = null; public int maxRadius = -1;
public int maxRadius = -1; public int maxSuperPickaxeSize = 5;
public int maxSuperPickaxeSize = 5; public int maxBrushRadius = 6;
public int maxBrushRadius = 6; public boolean logCommands = false;
public boolean logCommands = false; public String logFile = "";
public String logFile = ""; public String logFormat = LogFormat.DEFAULT_FORMAT;
public String logFormat = LogFormat.DEFAULT_FORMAT; public boolean registerHelp = true; // what is the point of this, it's not even used
public boolean registerHelp = true; // what is the point of this, it's not even used public String wandItem = "minecraft:wooden_axe";
public String wandItem = "minecraft:wooden_axe"; public boolean superPickaxeDrop = true;
public boolean superPickaxeDrop = true; public boolean superPickaxeManyDrop = true;
public boolean superPickaxeManyDrop = true; public boolean noDoubleSlash = false;
public boolean noDoubleSlash = false; public boolean useInventory = false;
public boolean useInventory = false; public boolean useInventoryOverride = false;
public boolean useInventoryOverride = false; public boolean useInventoryCreativeOverride = false;
public boolean useInventoryCreativeOverride = false; public boolean navigationUseGlass = true;
public boolean navigationUseGlass = true; public String navigationWand = "minecraft:compass";
public String navigationWand = "minecraft:compass"; public int navigationWandMaxDistance = 50;
public int navigationWandMaxDistance = 50; public int scriptTimeout = 3000;
public int scriptTimeout = 3000; public int calculationTimeout = 100;
public int calculationTimeout = 100; public Set<String> allowedDataCycleBlocks = new HashSet<>();
public Set<String> allowedDataCycleBlocks = new HashSet<>(); public String saveDir = "schematics";
public String saveDir = "schematics"; public String scriptsDir = "craftscripts";
public String scriptsDir = "craftscripts"; public boolean showHelpInfo = true;
public boolean showHelpInfo = true; public int butcherDefaultRadius = -1;
public int butcherDefaultRadius = -1; public int butcherMaxRadius = -1;
public int butcherMaxRadius = -1; public boolean allowSymlinks = false;
public boolean allowSymlinks = false; public boolean serverSideCUI = true;
public boolean serverSideCUI = true;
protected String[] getDefaultDisallowedBlocks() {
protected String[] getDefaultDisallowedBlocks() { List<BlockType> blockTypes = Lists.newArrayList(
List<BlockType> blockTypes = Lists.newArrayList( BlockTypes.OAK_SAPLING,
BlockTypes.OAK_SAPLING, BlockTypes.JUNGLE_SAPLING,
BlockTypes.JUNGLE_SAPLING, BlockTypes.DARK_OAK_SAPLING,
BlockTypes.DARK_OAK_SAPLING, BlockTypes.SPRUCE_SAPLING,
BlockTypes.SPRUCE_SAPLING, BlockTypes.BIRCH_SAPLING,
BlockTypes.BIRCH_SAPLING, BlockTypes.ACACIA_SAPLING,
BlockTypes.ACACIA_SAPLING, BlockTypes.BLACK_BED,
BlockTypes.BLACK_BED, BlockTypes.BLUE_BED,
BlockTypes.BLUE_BED, BlockTypes.BROWN_BED,
BlockTypes.BROWN_BED, BlockTypes.CYAN_BED,
BlockTypes.CYAN_BED, BlockTypes.GRAY_BED,
BlockTypes.GRAY_BED, BlockTypes.GREEN_BED,
BlockTypes.GREEN_BED, BlockTypes.LIGHT_BLUE_BED,
BlockTypes.LIGHT_BLUE_BED, BlockTypes.LIGHT_GRAY_BED,
BlockTypes.LIGHT_GRAY_BED, BlockTypes.LIME_BED,
BlockTypes.LIME_BED, BlockTypes.MAGENTA_BED,
BlockTypes.MAGENTA_BED, BlockTypes.ORANGE_BED,
BlockTypes.ORANGE_BED, BlockTypes.PINK_BED,
BlockTypes.PINK_BED, BlockTypes.PURPLE_BED,
BlockTypes.PURPLE_BED, BlockTypes.RED_BED,
BlockTypes.RED_BED, BlockTypes.WHITE_BED,
BlockTypes.WHITE_BED, BlockTypes.YELLOW_BED,
BlockTypes.YELLOW_BED, BlockTypes.POWERED_RAIL,
BlockTypes.POWERED_RAIL, BlockTypes.DETECTOR_RAIL,
BlockTypes.DETECTOR_RAIL, BlockTypes.GRASS,
BlockTypes.GRASS, BlockTypes.DEAD_BUSH,
BlockTypes.DEAD_BUSH, BlockTypes.MOVING_PISTON,
BlockTypes.MOVING_PISTON, BlockTypes.PISTON_HEAD,
BlockTypes.PISTON_HEAD, BlockTypes.SUNFLOWER,
BlockTypes.SUNFLOWER, BlockTypes.ROSE_BUSH,
BlockTypes.ROSE_BUSH, BlockTypes.DANDELION,
BlockTypes.DANDELION, BlockTypes.POPPY,
BlockTypes.POPPY, BlockTypes.BROWN_MUSHROOM,
BlockTypes.BROWN_MUSHROOM, BlockTypes.RED_MUSHROOM,
BlockTypes.RED_MUSHROOM, BlockTypes.TNT,
BlockTypes.TNT, BlockTypes.TORCH,
BlockTypes.TORCH, BlockTypes.FIRE,
BlockTypes.FIRE, BlockTypes.REDSTONE_WIRE,
BlockTypes.REDSTONE_WIRE, BlockTypes.WHEAT,
BlockTypes.WHEAT, BlockTypes.POTATOES,
BlockTypes.POTATOES, BlockTypes.CARROTS,
BlockTypes.CARROTS, BlockTypes.MELON_STEM,
BlockTypes.MELON_STEM, BlockTypes.PUMPKIN_STEM,
BlockTypes.PUMPKIN_STEM, BlockTypes.BEETROOTS,
BlockTypes.BEETROOTS, BlockTypes.RAIL,
BlockTypes.RAIL, BlockTypes.LEVER,
BlockTypes.LEVER, BlockTypes.REDSTONE_TORCH,
BlockTypes.REDSTONE_TORCH, BlockTypes.REDSTONE_WALL_TORCH,
BlockTypes.REDSTONE_WALL_TORCH, BlockTypes.REPEATER,
BlockTypes.REPEATER, BlockTypes.COMPARATOR,
BlockTypes.COMPARATOR, BlockTypes.STONE_BUTTON,
BlockTypes.STONE_BUTTON, BlockTypes.BIRCH_BUTTON,
BlockTypes.BIRCH_BUTTON, BlockTypes.ACACIA_BUTTON,
BlockTypes.ACACIA_BUTTON, BlockTypes.DARK_OAK_BUTTON,
BlockTypes.DARK_OAK_BUTTON, BlockTypes.JUNGLE_BUTTON,
BlockTypes.JUNGLE_BUTTON, BlockTypes.OAK_BUTTON,
BlockTypes.OAK_BUTTON, BlockTypes.SPRUCE_BUTTON,
BlockTypes.SPRUCE_BUTTON, BlockTypes.CACTUS,
BlockTypes.CACTUS, BlockTypes.SUGAR_CANE,
BlockTypes.SUGAR_CANE, // ores and stuff
// ores and stuff BlockTypes.BEDROCK
BlockTypes.BEDROCK );
); return blockTypes.stream().filter(Objects::nonNull).map(BlockType::getId).toArray(String[]::new);
return blockTypes.stream().filter(type -> !Objects.isNull(type)).map(BlockType::getId).toArray(String[]::new); }
}
/**
/** * Load the configuration.
* Load the configuration. */
*/ public abstract void load();
public abstract void load();
/**
/** * Get the working directory to work from.
* Get the working directory to work from. *
* * @return a working directory
* @return a working directory */
*/ public File getWorkingDirectory() {
public File getWorkingDirectory() { return new File(".");
return new File("."); }
}
public String convertLegacyItem(String legacy) {
public String convertLegacyItem(String legacy) { String item = legacy;
String item = legacy; try {
try { String[] splitter = item.split(":", 2);
String[] splitter = item.split(":", 2); int id = 0;
int id = 0; byte data = 0;
byte data = 0; if (splitter.length == 1) {
if (splitter.length == 1) { id = Integer.parseInt(item);
id = Integer.parseInt(item); } else {
} else { id = Integer.parseInt(splitter[0]);
id = Integer.parseInt(splitter[0]); data = Byte.parseByte(splitter[1]);
data = Byte.parseByte(splitter[1]); }
} item = LegacyMapper.getInstance().getItemFromLegacy(id, data).getId();
item = LegacyMapper.getInstance().getItemFromLegacy(id, data).getId(); } catch (Throwable e) {
} catch (Throwable e) { }
}
return item;
return item; }
}
}
}