Update to Minecraft 1.19

By: md_5 <git@md-5.net>
This commit is contained in:
Bukkit/Spigot
2022-06-08 02:00:00 +10:00
parent 9bfa9ca85b
commit ec575f5252
88 changed files with 1339 additions and 375 deletions

View File

@@ -1,7 +1,8 @@
package org.bukkit.conversations;
import org.apache.commons.lang.ArrayUtils;
import org.apache.commons.lang.BooleanUtils;
import com.google.common.collect.ImmutableSet;
import java.util.Locale;
import java.util.Set;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -11,21 +12,23 @@ import org.jetbrains.annotations.Nullable;
*/
public abstract class BooleanPrompt extends ValidatingPrompt {
private static final Set<String> TRUE_INPUTS = ImmutableSet.of("true", "on", "yes", "y", "1", "right", "correct", "valid");
private static final Set<String> FALSE_INPUTS = ImmutableSet.of("false", "off", "no", "n", "0", "wrong", "incorrect", "invalid");
private static final Set<String> VALID_INPUTS = ImmutableSet.<String>builder().addAll(TRUE_INPUTS).addAll(FALSE_INPUTS).build();
public BooleanPrompt() {
super();
}
@Override
protected boolean isInputValid(@NotNull ConversationContext context, @NotNull String input) {
String[] accepted = {/* Apache values: */ "true", "false", "on", "off", "yes", "no", /* Additional values: */ "y", "n", "1", "0", "right", "wrong", "correct", "incorrect", "valid", "invalid"};
return ArrayUtils.contains(accepted, input.toLowerCase());
return VALID_INPUTS.contains(input.toLowerCase(Locale.ROOT));
}
@Nullable
@Override
protected Prompt acceptValidatedInput(@NotNull ConversationContext context, @NotNull String input) {
if (input.equalsIgnoreCase("y") || input.equals("1") || input.equalsIgnoreCase("right") || input.equalsIgnoreCase("correct") || input.equalsIgnoreCase("valid")) input = "true";
return acceptValidatedInput(context, BooleanUtils.toBoolean(input));
return acceptValidatedInput(context, TRUE_INPUTS.contains(input.toLowerCase(Locale.ROOT)));
}
/**

View File

@@ -1,8 +1,8 @@
package org.bukkit.conversations;
import com.google.common.base.Joiner;
import java.util.Arrays;
import java.util.List;
import org.apache.commons.lang.StringUtils;
import org.jetbrains.annotations.NotNull;
/**
@@ -42,6 +42,6 @@ public abstract class FixedSetPrompt extends ValidatingPrompt {
*/
@NotNull
protected String formatFixedSet() {
return "[" + StringUtils.join(fixedSet, ", ") + "]";
return "[" + Joiner.on(", ").join(fixedSet) + "]";
}
}

View File

@@ -1,6 +1,6 @@
package org.bukkit.conversations;
import org.apache.commons.lang.math.NumberUtils;
import org.apache.commons.lang3.math.NumberUtils;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;