Further modernise and remove legacy item classes

This commit is contained in:
Matthew Miller
2018-06-17 17:50:04 +10:00
parent c43109bde5
commit e2608bc0c9
35 changed files with 392 additions and 1045 deletions

View File

@ -0,0 +1,25 @@
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* Copyright (C) WorldEdit team and contributors
*
* 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
* (at your option) any later version.
*
* 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.
*
* 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/>.
*/
package com.sk89q.worldedit.util;
public enum HandSide {
MAIN_HAND,
OFF_HAND
}

View File

@ -33,6 +33,7 @@ import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Properties;
import java.util.Set;
@ -73,7 +74,7 @@ public class PropertiesConfiguration extends LocalConfiguration {
loadExtra();
profile = getBool("profile", profile);
disallowedBlocks = getIntSet("disallowed-blocks", defaultDisallowedBlocks);
disallowedBlocks = getStringSet("disallowed-blocks", defaultDisallowedBlocks);
defaultChangeLimit = getInt("default-max-changed-blocks", defaultChangeLimit);
maxChangeLimit = getInt("max-changed-blocks", maxChangeLimit);
defaultMaxPolygonalPoints = getInt("default-max-polygon-points", defaultMaxPolygonalPoints);
@ -88,14 +89,14 @@ public class PropertiesConfiguration extends LocalConfiguration {
logFile = getString("log-file", logFile);
logFormat = getString("log-format", logFormat);
registerHelp = getBool("register-help", registerHelp);
wandItem = getInt("wand-item", wandItem);
wandItem = getString("wand-item", wandItem);
superPickaxeDrop = getBool("super-pickaxe-drop-items", superPickaxeDrop);
superPickaxeManyDrop = getBool("super-pickaxe-many-drop-items", superPickaxeManyDrop);
noDoubleSlash = getBool("no-double-slash", noDoubleSlash);
useInventory = getBool("use-inventory", useInventory);
useInventoryOverride = getBool("use-inventory-override", useInventoryOverride);
useInventoryCreativeOverride = getBool("use-inventory-creative-override", useInventoryCreativeOverride);
navigationWand = getInt("nav-wand-item", navigationWand);
navigationWand = getString("nav-wand-item", navigationWand);
navigationWandMaxDistance = getInt("nav-wand-distance", navigationWandMaxDistance);
navigationUseGlass = getBool("nav-use-glass", navigationUseGlass);
scriptTimeout = getInt("scripting-timeout", scriptTimeout);
@ -238,4 +239,30 @@ public class PropertiesConfiguration extends LocalConfiguration {
}
}
/**
* Get a String set.
*
* @param key the key
* @param def the default value
* @return the value
*/
protected Set<String> getStringSet(String key, String[] def) {
String val = properties.getProperty(key);
if (val == null) {
properties.setProperty(key, StringUtil.joinString(def, ",", 0));
return new HashSet<>(Arrays.asList(def));
} else {
Set<String> set = new HashSet<>();
String[] parts = val.split(",");
for (String part : parts) {
try {
String v = part.trim();
set.add(v);
} catch (NumberFormatException ignored) {
}
}
return set;
}
}
}

View File

@ -19,6 +19,7 @@
package com.sk89q.worldedit.util;
import com.google.common.collect.Lists;
import com.sk89q.util.yaml.YAMLProcessor;
import com.sk89q.worldedit.LocalConfiguration;
import com.sk89q.worldedit.LocalSession;
@ -53,7 +54,7 @@ public class YAMLConfiguration extends LocalConfiguration {
}
profile = config.getBoolean("debug", profile);
wandItem = config.getInt("wand-item", wandItem);
wandItem = config.getString("wand-item", wandItem);
defaultChangeLimit = Math.max(-1, config.getInt(
"limits.max-blocks-changed.default", defaultChangeLimit));
@ -76,7 +77,7 @@ public class YAMLConfiguration extends LocalConfiguration {
butcherDefaultRadius = Math.max(-1, config.getInt("limits.butcher-radius.default", butcherDefaultRadius));
butcherMaxRadius = Math.max(-1, config.getInt("limits.butcher-radius.maximum", butcherMaxRadius));
disallowedBlocks = new HashSet<>(config.getIntList("limits.disallowed-blocks", null));
disallowedBlocks = new HashSet<>(config.getStringList("limits.disallowed-blocks", Lists.newArrayList(defaultDisallowedBlocks)));
allowedDataCycleBlocks = new HashSet<>(config.getIntList("limits.allowed-data-cycle-blocks", null));
registerHelp = config.getBoolean("register-help", true);
@ -97,7 +98,7 @@ public class YAMLConfiguration extends LocalConfiguration {
useInventoryCreativeOverride = config.getBoolean("use-inventory.creative-mode-overrides",
useInventoryCreativeOverride);
navigationWand = config.getInt("navigation-wand.item", navigationWand);
navigationWand = config.getString("navigation-wand.item", navigationWand);
navigationWandMaxDistance = config.getInt("navigation-wand.max-distance", navigationWandMaxDistance);
navigationUseGlass = config.getBoolean("navigation.use-glass", navigationUseGlass);