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

fix: avoid recursive LegacyMapper initialization (#1922)

Dieser Commit ist enthalten in:
Hannes Greule 2022-08-27 16:48:54 +02:00 committet von GitHub
Ursprung dc2db5f07f
Commit a6a0b5eb66
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 4AEE18F83AFDEB23
2 geänderte Dateien mit 12 neuen und 7 gelöschten Zeilen

Datei anzeigen

@ -455,7 +455,7 @@ public class DefaultBlockParser extends InputParser<BaseBlock> {
state = item.getType().getBlockType().getDefaultState(); state = item.getType().getBlockType().getDefaultState();
nbt = item.getNbtData(); nbt = item.getNbtData();
} else { } else {
BlockType type = BlockTypes.parse(typeString.toLowerCase(Locale.ROOT)); BlockType type = BlockTypes.parse(typeString.toLowerCase(Locale.ROOT), context);
if (type != null) { if (type != null) {
state = type.getDefaultState(); state = type.getDefaultState();

Datei anzeigen

@ -23,6 +23,7 @@ import com.fastasyncworldedit.core.command.SuggestInputParseException;
import com.fastasyncworldedit.core.util.JoinedCharSequence; import com.fastasyncworldedit.core.util.JoinedCharSequence;
import com.fastasyncworldedit.core.util.StringMan; import com.fastasyncworldedit.core.util.StringMan;
import com.sk89q.worldedit.extension.input.InputParseException; import com.sk89q.worldedit.extension.input.InputParseException;
import com.sk89q.worldedit.extension.input.ParserContext;
import com.sk89q.worldedit.world.registry.LegacyMapper; import com.sk89q.worldedit.world.registry.LegacyMapper;
import javax.annotation.Nullable; import javax.annotation.Nullable;
@ -1948,6 +1949,9 @@ public final class BlockTypes {
*/ */
public static BlockType parse(final String type) throws InputParseException { public static BlockType parse(final String type) throws InputParseException {
return parse(type, new ParserContext());
}
public static BlockType parse(final String type, final ParserContext context) throws InputParseException {
final String inputLower = type.toLowerCase(Locale.ROOT); final String inputLower = type.toLowerCase(Locale.ROOT);
String input = inputLower; String input = inputLower;
@ -1958,7 +1962,7 @@ public final class BlockTypes {
if (result != null) { if (result != null) {
return result; return result;
} }
if (context.isTryingLegacy()) {
try { try {
BlockStateHolder<BlockState> block = LegacyMapper.getInstance().getBlockFromLegacy(input); BlockStateHolder<BlockState> block = LegacyMapper.getInstance().getBlockFromLegacy(input);
if (block != null) { if (block != null) {
@ -1966,6 +1970,7 @@ public final class BlockTypes {
} }
} catch (NumberFormatException | IndexOutOfBoundsException ignored) { } catch (NumberFormatException | IndexOutOfBoundsException ignored) {
} }
}
throw new SuggestInputParseException("Does not match a valid block type: " + inputLower, inputLower, () -> Stream.of( throw new SuggestInputParseException("Does not match a valid block type: " + inputLower, inputLower, () -> Stream.of(
BlockTypesCache.values) BlockTypesCache.values)