3
0
Mirror von https://github.com/IntellectualSites/FastAsyncWorldEdit.git synchronisiert 2024-12-26 11:00:04 +01:00

Add suggestions for items.

Dieser Commit ist enthalten in:
wizjany 2019-05-28 16:07:29 -04:00
Ursprung 5e857b3547
Commit 27b58f4e85

Datei anzeigen

@ -21,6 +21,7 @@ package com.sk89q.worldedit.extension.factory.parser;
import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.blocks.BaseItem; 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.InputParseException;
import com.sk89q.worldedit.extension.input.ParserContext; import com.sk89q.worldedit.extension.input.ParserContext;
import com.sk89q.worldedit.internal.registry.InputParser; import com.sk89q.worldedit.internal.registry.InputParser;
@ -39,11 +40,7 @@ public class DefaultItemParser extends InputParser<BaseItem> {
@Override @Override
public Stream<String> getSuggestions(String input) { public Stream<String> getSuggestions(String input) {
if (input.indexOf(':') == -1) { return SuggestionHelper.getNamespacedRegistrySuggestions(ItemType.REGISTRY, input);
input = "minecraft:" + input;
}
String key = input;
return ItemType.REGISTRY.keySet().stream().filter(s -> s.startsWith(key));
} }
@Override @Override
@ -54,7 +51,9 @@ public class DefaultItemParser extends InputParser<BaseItem> {
try { try {
String[] split = input.split(":"); String[] split = input.split(":");
ItemType type; 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])); type = LegacyMapper.getInstance().getItemFromLegacy(Integer.parseInt(split[0]));
} else { } else {
type = LegacyMapper.getInstance().getItemFromLegacy(Integer.parseInt(split[0]), Integer.parseInt(split[1])); type = LegacyMapper.getInstance().getItemFromLegacy(Integer.parseInt(split[0]), Integer.parseInt(split[1]));