From 6312bcecf699fc0fcb58dba4df9f6451c6c0df3b Mon Sep 17 00:00:00 2001 From: Matthew Miller Date: Sun, 23 Dec 2018 19:02:58 +1000 Subject: [PATCH] Fixed the item parser not using the ItemRegistry --- .../factory/parser/DefaultItemParser.java | 8 +++++--- .../world/registry/BundledItemRegistry.java | 12 ------------ .../worldedit/world/registry/ItemRegistry.java | 13 ------------- .../worldedit/forge/ForgeItemRegistry.java | 17 +---------------- 4 files changed, 6 insertions(+), 44 deletions(-) diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/DefaultItemParser.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/DefaultItemParser.java index f25bd86be..f6c396b93 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/DefaultItemParser.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/DefaultItemParser.java @@ -23,9 +23,9 @@ import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.blocks.BaseItem; import com.sk89q.worldedit.extension.input.InputParseException; import com.sk89q.worldedit.extension.input.ParserContext; -import com.sk89q.worldedit.extension.platform.Capability; import com.sk89q.worldedit.internal.registry.InputParser; import com.sk89q.worldedit.world.item.ItemType; +import com.sk89q.worldedit.world.item.ItemTypes; import com.sk89q.worldedit.world.registry.LegacyMapper; public class DefaultItemParser extends InputParser { @@ -53,8 +53,10 @@ public class DefaultItemParser extends InputParser { } if (item == null) { - item = WorldEdit.getInstance().getPlatformManager() - .queryCapability(Capability.GAME_HOOKS).getRegistries().getItemRegistry().createFromId(input.toLowerCase()); + ItemType type = ItemTypes.get(input.toLowerCase()); + if (type != null) { + item = new BaseItem(type); + } } if (item == null) { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/BundledItemRegistry.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/BundledItemRegistry.java index 11e723f21..31dc71e5d 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/BundledItemRegistry.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/BundledItemRegistry.java @@ -19,22 +19,10 @@ package com.sk89q.worldedit.world.registry; -import com.sk89q.worldedit.blocks.BaseItem; -import com.sk89q.worldedit.world.item.ItemType; -import com.sk89q.worldedit.world.item.ItemTypes; - -import javax.annotation.Nullable; - /** * A item registry that uses {@link BundledItemRegistry} to serve information * about items. */ public class BundledItemRegistry implements ItemRegistry { - @Nullable - @Override - public BaseItem createFromId(String id) { - ItemType itemType = ItemTypes.get(id); - return itemType == null ? null : new BaseItem(itemType); - } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/ItemRegistry.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/ItemRegistry.java index 749aa6a37..9d53db0c1 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/ItemRegistry.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/ItemRegistry.java @@ -19,19 +19,6 @@ package com.sk89q.worldedit.world.registry; -import com.sk89q.worldedit.blocks.BaseItem; - -import javax.annotation.Nullable; - public interface ItemRegistry { - /** - * Create a new item using its ID. - * - * @param id the id - * @return the item, which may be null if no item exists - */ - @Nullable - BaseItem createFromId(String id); - } diff --git a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeItemRegistry.java b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeItemRegistry.java index c87033075..49ae97cb0 100644 --- a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeItemRegistry.java +++ b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeItemRegistry.java @@ -19,23 +19,8 @@ package com.sk89q.worldedit.forge; -import com.sk89q.worldedit.blocks.BaseItem; -import com.sk89q.worldedit.world.item.ItemTypes; import com.sk89q.worldedit.world.registry.ItemRegistry; -import net.minecraft.item.Item; -import net.minecraft.util.ResourceLocation; - -import javax.annotation.Nullable; public class ForgeItemRegistry implements ItemRegistry { - @Nullable - @Override - public BaseItem createFromId(String id) { - Item match = Item.REGISTRY.getObject(new ResourceLocation(id)); - if (match != null) { - return new BaseItem(ItemTypes.get(id)); - } else { - return null; - } - } + }