Add text input option allowing empty text (#9058)

* feat: Add option allowing empty text input

* feat: Implement https://github.com/Anuken/Arc/pull/155

* chore: Add missing null checks in Menus
This commit is contained in:
Phinner
2023-09-15 23:11:22 +02:00
committed by GitHub
parent 9aa87f0f33
commit cbc3721e50
3 changed files with 24 additions and 7 deletions

View File

@@ -31,6 +31,7 @@ public class Menus{
@Remote(variants = Variant.both)
public static void menu(int menuId, String title, String message, String[][] options){
if(title == null) title = "";
if(message == null) message = "";
if(options == null) options = new String[0][0];
ui.showMenu(title, message, options, (option) -> Call.menuChoose(player, menuId, option));
@@ -39,6 +40,7 @@ public class Menus{
@Remote(variants = Variant.both)
public static void followUpMenu(int menuId, String title, String message, String[][] options){
if(title == null) title = "";
if(message == null) message = "";
if(options == null) options = new String[0][0];
ui.showFollowUpMenu(menuId, title, message, options, (option) -> Call.menuChoose(player, menuId, option));
@@ -61,9 +63,16 @@ public class Menus{
@Remote(variants = Variant.both)
public static void textInput(int textInputId, String title, String message, int textLength, String def, boolean numeric){
if(title == null) title = "";
textInput(textInputId, title, message, textLength, def, numeric, false);
}
ui.showTextInput(title, message, textLength, def, numeric, (text) -> {
@Remote(variants = Variant.both)
public static void textInput(int textInputId, String title, String message, int textLength, String def, boolean numeric, boolean allowEmpty){
if(title == null) title = "";
if(message == null) message = "";
if(def == null) def = "";
ui.showTextInput(title, message, textLength, def, numeric, allowEmpty, (text) -> {
Call.textInputResult(player, textInputId, text);
}, () -> {
Call.textInputResult(player, textInputId, null);