Mirror von
https://github.com/IntellectualSites/FastAsyncWorldEdit.git
synchronisiert 2024-12-26 02:50:06 +01:00
Add suggestions for items.
Dieser Commit ist enthalten in:
Ursprung
5e857b3547
Commit
27b58f4e85
@ -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<BaseItem> {
|
||||
|
||||
@Override
|
||||
public Stream<String> 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<BaseItem> {
|
||||
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]));
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren