3
0
Mirror von https://github.com/IntellectualSites/FastAsyncWorldEdit.git synchronisiert 2024-11-09 13:00:05 +01:00

Parse instead of get block for masks

Dieser Commit ist enthalten in:
Jesse Boyd 2018-08-17 23:05:34 +10:00
Ursprung b8cc785717
Commit 44c5447edb
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 59F1DE6293AF6E1F
2 geänderte Dateien mit 8 neuen und 6 gelöschten Zeilen

Datei anzeigen

@ -3,6 +3,7 @@ package com.sk89q.worldedit.function.mask;
import com.boydti.fawe.object.collection.FastBitSet; import com.boydti.fawe.object.collection.FastBitSet;
import com.boydti.fawe.object.string.MutableCharSequence; import com.boydti.fawe.object.string.MutableCharSequence;
import com.boydti.fawe.util.StringMan; import com.boydti.fawe.util.StringMan;
import com.sk89q.worldedit.extension.input.InputParseException;
import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.registry.state.AbstractProperty; import com.sk89q.worldedit.registry.state.AbstractProperty;
import com.sk89q.worldedit.registry.state.Property; import com.sk89q.worldedit.registry.state.Property;
@ -66,7 +67,7 @@ public class BlockMaskBuilder {
} }
} }
public BlockMaskBuilder addRegex(String input) { public BlockMaskBuilder addRegex(String input) throws InputParseException {
if (input.charAt(input.length() - 1) == ']') { if (input.charAt(input.length() - 1) == ']') {
int propStart = StringMan.findMatchingBracket(input, input.length() - 1); int propStart = StringMan.findMatchingBracket(input, input.length() - 1);
if (propStart == -1) return this; if (propStart == -1) return this;
@ -78,7 +79,7 @@ public class BlockMaskBuilder {
BlockTypes type = null; BlockTypes type = null;
List<BlockTypes> blockTypeList = null; List<BlockTypes> blockTypeList = null;
if (StringMan.isAlphanumericUnd(charSequence)) { if (StringMan.isAlphanumericUnd(charSequence)) {
type = BlockTypes.get(charSequence); type = BlockTypes.parse(charSequence.toString());
add(type); add(type);
} else { } else {
String regex = charSequence.toString(); String regex = charSequence.toString();
@ -153,7 +154,7 @@ public class BlockMaskBuilder {
} }
} else { } else {
if (StringMan.isAlphanumericUnd(input)) { if (StringMan.isAlphanumericUnd(input)) {
add(BlockTypes.get(input)); add(BlockTypes.parse(input));
} else { } else {
for (BlockTypes myType : BlockTypes.values) { for (BlockTypes myType : BlockTypes.values) {
if (myType.getId().matches(input)) { if (myType.getId().matches(input)) {

Datei anzeigen

@ -25,6 +25,7 @@ import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.blocks.BlockMaterial; import com.sk89q.worldedit.blocks.BlockMaterial;
import com.sk89q.worldedit.extension.input.InputParseException;
import com.sk89q.worldedit.extension.platform.Capability; import com.sk89q.worldedit.extension.platform.Capability;
import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.function.mask.Mask; import com.sk89q.worldedit.function.mask.Mask;
@ -978,7 +979,7 @@ public enum BlockTypes implements BlockType {
} }
} }
public static BlockTypes parse(String input) { public static BlockTypes parse(String input) throws InputParseException {
input = input.toLowerCase(); input = input.toLowerCase();
if (!input.split("\\[", 2)[0].contains(":")) input = "minecraft:" + input; if (!input.split("\\[", 2)[0].contains(":")) input = "minecraft:" + input;
@ -987,10 +988,10 @@ public enum BlockTypes implements BlockType {
try { try {
BlockStateHolder block = LegacyMapper.getInstance().getBlockFromLegacy(input); BlockStateHolder block = LegacyMapper.getInstance().getBlockFromLegacy(input);
if (block != null) return (BlockTypes) block.getBlockType(); if (block != null) return block.getBlockType();
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
} catch (IndexOutOfBoundsException e) {} } catch (IndexOutOfBoundsException e) {}
return null; throw new InputParseException("Unkown block for " + input);
} }
private static BlockTypes register(final String id) { private static BlockTypes register(final String id) {