Makes it possible to get the current value from /dedit

Finally gets rid of the redundancy when checking if a record has been beaten
Adds tab-completions for arenas and properties to the edit command
Adds an ArenaEditableProperty enum to keep track of editable arena properties
This commit is contained in:
2023-03-29 11:37:26 +02:00
parent 34989e6673
commit ca5b0fcbca
5 changed files with 188 additions and 59 deletions

View File

@ -2,6 +2,7 @@ package net.knarcraft.dropper.command;
import net.knarcraft.dropper.Dropper;
import net.knarcraft.dropper.arena.DropperArena;
import net.knarcraft.dropper.property.ArenaEditableProperty;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
@ -31,9 +32,22 @@ public class EditArenaCommand implements CommandExecutor {
return false;
}
//TODO: If an arena name and a property is given, display the current value
//TODO: If an arena name, a property and a value is given, check if it's valid, and update the property
return false;
ArenaEditableProperty editableProperty = ArenaEditableProperty.getFromArgumentString(arguments[1]);
if (editableProperty == null) {
commandSender.sendMessage("Unknown property specified.");
return false;
}
String currentValueFormat = "Current value of %s is: %s";
if (arguments.length < 3) {
// Print the current value of the property
String value = editableProperty.getCurrentValueAsString(specifiedArena);
commandSender.sendMessage(String.format(currentValueFormat, editableProperty.getArgumentString(), value));
} else {
// TODO: Expect a new value for the option, which needs to be validated, and possibly set
}
return true;
}
}

View File

@ -1,11 +1,13 @@
package net.knarcraft.dropper.command;
import net.knarcraft.dropper.util.TabCompleteHelper;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
import java.util.List;
/**
@ -16,9 +18,16 @@ public class EditArenaTabCompleter implements TabCompleter {
@Override
public @Nullable List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command,
@NotNull String label, @NotNull String[] args) {
//TODO: Tab-complete existing arena names
//TODO: If an arena name is given, tab-complete change-able properties
return null;
if (args.length == 1) {
return TabCompleteHelper.getArenas();
} else if (args.length == 2) {
return TabCompleteHelper.getArenaProperties();
} else if (args.length == 3) {
//TODO: Tab-complete possible values for the given property
return null;
} else {
return new ArrayList<>();
}
}
}