mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-12-23 09:47:38 +00:00
Add suggestions for items.
This commit is contained in:
parent
5e857b3547
commit
27b58f4e85
@ -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]));
|
||||||
|
Loading…
Reference in New Issue
Block a user