3
0
Mirror von https://github.com/IntellectualSites/FastAsyncWorldEdit.git synchronisiert 2024-12-24 18:10:08 +01:00

Treat categories as empty when missing

Dieser Commit ist enthalten in:
Matthew Miller 2019-02-18 21:17:36 +10:00
Ursprung df5ef52d6c
Commit 5de8e0852c
4 geänderte Dateien mit 14 neuen und 13 gelöschten Zeilen

Datei anzeigen

@ -27,7 +27,6 @@ import com.sk89q.worldedit.function.mask.BlockCategoryMask;
import com.sk89q.worldedit.function.mask.Mask;
import com.sk89q.worldedit.internal.registry.InputParser;
import com.sk89q.worldedit.session.request.Request;
import com.sk89q.worldedit.world.block.BlockCategories;
import com.sk89q.worldedit.world.block.BlockCategory;
public class BlockCategoryMaskParser extends InputParser<Mask> {
@ -45,7 +44,7 @@ public class BlockCategoryMaskParser extends InputParser<Mask> {
Extent extent = Request.request().getEditSession();
// This means it's a tag mask.
BlockCategory category = BlockCategories.get(input.substring(2).toLowerCase());
BlockCategory category = BlockCategory.REGISTRY.get(input.substring(2).toLowerCase());
if (category == null) {
throw new InputParseException("Unrecognised tag '" + input.substring(2) + '\'');
} else {

Datei anzeigen

@ -26,9 +26,7 @@ import com.sk89q.worldedit.function.pattern.BlockPattern;
import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.function.pattern.RandomPattern;
import com.sk89q.worldedit.internal.registry.InputParser;
import com.sk89q.worldedit.world.block.BlockCategories;
import com.sk89q.worldedit.world.block.BlockCategory;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockType;
import java.util.List;
@ -58,7 +56,7 @@ public class BlockCategoryPatternParser extends InputParser<Pattern> {
anyState = true;
}
BlockCategory category = BlockCategories.get(tag);
BlockCategory category = BlockCategory.REGISTRY.get(tag);
if (category == null) {
throw new InputParseException("Unknown block tag: " + tag);
}

Datei anzeigen

@ -19,8 +19,6 @@
package com.sk89q.worldedit.world.block;
import javax.annotation.Nullable;
/**
* Stores a list of categories of Block Types.
*/
@ -62,7 +60,11 @@ public final class BlockCategories {
private BlockCategories() {
}
public static @Nullable BlockCategory get(final String id) {
return BlockCategory.REGISTRY.get(id);
private static BlockCategory get(final String id) {
BlockCategory blockCategory = BlockCategory.REGISTRY.get(id);
if (blockCategory == null) {
return new BlockCategory(id);
}
return blockCategory;
}
}

Datei anzeigen

@ -19,8 +19,6 @@
package com.sk89q.worldedit.world.item;
import javax.annotation.Nullable;
/**
* Stores a list of categories of Item Types.
*/
@ -60,7 +58,11 @@ public final class ItemCategories {
private ItemCategories() {
}
public static @Nullable ItemCategory get(final String id) {
return ItemCategory.REGISTRY.get(id);
private static ItemCategory get(final String id) {
ItemCategory itemCategory = ItemCategory.REGISTRY.get(id);
if (itemCategory == null) {
return new ItemCategory(id);
}
return itemCategory;
}
}