From 27b58f4e850e6f1c15e18ff152746f4f5091c187 Mon Sep 17 00:00:00 2001 From: wizjany Date: Tue, 28 May 2019 16:07:29 -0400 Subject: [PATCH] Add suggestions for items. --- .../extension/factory/parser/DefaultItemParser.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 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 e325b24a1..450538f28 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 @@ -21,6 +21,7 @@ package com.sk89q.worldedit.extension.factory.parser; import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.blocks.BaseItem; +import com.sk89q.worldedit.command.util.SuggestionHelper; import com.sk89q.worldedit.extension.input.InputParseException; import com.sk89q.worldedit.extension.input.ParserContext; import com.sk89q.worldedit.internal.registry.InputParser; @@ -39,11 +40,7 @@ public class DefaultItemParser extends InputParser { @Override public Stream getSuggestions(String input) { - if (input.indexOf(':') == -1) { - input = "minecraft:" + input; - } - String key = input; - return ItemType.REGISTRY.keySet().stream().filter(s -> s.startsWith(key)); + return SuggestionHelper.getNamespacedRegistrySuggestions(ItemType.REGISTRY, input); } @Override @@ -54,7 +51,9 @@ public class DefaultItemParser extends InputParser { try { String[] split = input.split(":"); ItemType type; - if (split.length == 1) { + if (split.length == 0) { + throw new InputParseException("Invalid colon."); + } else if (split.length == 1) { type = LegacyMapper.getInstance().getItemFromLegacy(Integer.parseInt(split[0])); } else { type = LegacyMapper.getInstance().getItemFromLegacy(Integer.parseInt(split[0]), Integer.parseInt(split[1]));