geforkt von Mirrors/FastAsyncWorldEdit
Fix tab complete error for single property states
Dieser Commit ist enthalten in:
Ursprung
48bc4015c2
Commit
290f047f6a
@ -11,6 +11,7 @@ import java.util.Arrays;
|
|||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
@ -52,6 +53,14 @@ public class SuggestInputParseException extends InputParseException {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static SuggestInputParseException of(String input, List<Object> values) {
|
||||||
|
throw new SuggestInputParseException("No value: " + input, input, () ->
|
||||||
|
values.stream()
|
||||||
|
.map(v -> v.toString())
|
||||||
|
.filter(v -> v.startsWith(input))
|
||||||
|
.collect(Collectors.toList()));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized Throwable getCause() {
|
public synchronized Throwable getCause() {
|
||||||
return cause.getCause();
|
return cause.getCause();
|
||||||
|
@ -48,7 +48,14 @@ public class BooleanProperty extends AbstractProperty<Boolean> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getIndexFor(CharSequence string) throws IllegalArgumentException {
|
public int getIndexFor(CharSequence string) throws IllegalArgumentException {
|
||||||
return string.charAt(0) == 't' ? defaultIndex : 1 - defaultIndex;
|
switch (string.charAt(0)) {
|
||||||
|
case 't':
|
||||||
|
return defaultIndex;
|
||||||
|
case 'f':
|
||||||
|
return 1 - defaultIndex;
|
||||||
|
default:
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
|
@ -145,8 +145,10 @@ public class BlockState implements BlockStateHolder<BlockState>, FawePattern {
|
|||||||
String name = property.getName();
|
String name = property.getName();
|
||||||
|
|
||||||
charSequence.setSubstring(propStrStart + name.length() + 2, state.length() - 1);
|
charSequence.setSubstring(propStrStart + name.length() + 2, state.length() - 1);
|
||||||
|
int index = charSequence.length() <= 0 ? -1 : property.getIndexFor(charSequence);
|
||||||
return type.withPropertyId(property.getIndexFor(charSequence));
|
if (index != -1) {
|
||||||
|
return type.withPropertyId(index);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
int stateId;
|
int stateId;
|
||||||
if (defaultState != null) {
|
if (defaultState != null) {
|
||||||
@ -167,13 +169,7 @@ public class BlockState implements BlockStateHolder<BlockState>, FawePattern {
|
|||||||
if (property != null) {
|
if (property != null) {
|
||||||
int index = property.getIndexFor(charSequence);
|
int index = property.getIndexFor(charSequence);
|
||||||
if (index == -1) {
|
if (index == -1) {
|
||||||
String input = charSequence.toString();
|
throw SuggestInputParseException.of(charSequence.toString(), property.getValues());
|
||||||
List<Object> values = property.getValues();
|
|
||||||
throw new SuggestInputParseException("No value: " + input + " for " + type, input, () ->
|
|
||||||
values.stream()
|
|
||||||
.map(v -> v.toString())
|
|
||||||
.filter(v -> v.startsWith(input))
|
|
||||||
.collect(Collectors.toList()));
|
|
||||||
}
|
}
|
||||||
stateId = property.modifyIndex(stateId, index);
|
stateId = property.modifyIndex(stateId, index);
|
||||||
} else {
|
} else {
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren