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