diff --git a/src/main/java/net/knarcraft/paidsigns/PaidSigns.java b/src/main/java/net/knarcraft/paidsigns/PaidSigns.java index 9f9b1e5..367eee1 100644 --- a/src/main/java/net/knarcraft/paidsigns/PaidSigns.java +++ b/src/main/java/net/knarcraft/paidsigns/PaidSigns.java @@ -5,6 +5,7 @@ import net.knarcraft.paidsigns.command.AddConditionCommand; import net.knarcraft.paidsigns.command.AddConditionTabCompleter; import net.knarcraft.paidsigns.command.AddTabCompleter; import net.knarcraft.paidsigns.command.ListCommand; +import net.knarcraft.paidsigns.command.ListTabCompleter; import net.knarcraft.paidsigns.command.ReloadTabCommand; import net.knarcraft.paidsigns.command.RemoveConditionCommand; import net.knarcraft.paidsigns.command.RemoveConditionTabCompleter; @@ -113,7 +114,7 @@ public final class PaidSigns extends JavaPlugin { PluginCommand listCommand = this.getCommand("listPaidSigns"); if (listCommand != null) { listCommand.setExecutor(new ListCommand()); - //TODO: Add tab completer + listCommand.setTabCompleter(new ListTabCompleter()); } PluginCommand addConditionCommand = this.getCommand("addPaidSignCondition"); diff --git a/src/main/java/net/knarcraft/paidsigns/command/AddCommand.java b/src/main/java/net/knarcraft/paidsigns/command/AddCommand.java index 91f9ed5..20f396f 100644 --- a/src/main/java/net/knarcraft/paidsigns/command/AddCommand.java +++ b/src/main/java/net/knarcraft/paidsigns/command/AddCommand.java @@ -25,7 +25,6 @@ public class AddCommand extends TokenizedCommand { if (args.length < 3) { return false; } - PaidSignManager manager = PaidSigns.getInstance().getSignManager(); String signName = arguments.get(0); double cost; @@ -45,6 +44,23 @@ public class AddCommand extends TokenizedCommand { ignoreColor = OptionState.fromString(arguments.get(4)); } + return createPaidSign(sender, signName, cost, permission, ignoreCase, ignoreColor); + } + + /** + * Creates a new paid sign with the given user input + * + * @param sender
The command sender that called the add command
+ * @param signNameThe name of the new paid sign
+ * @param costThe cost of the new paid sign
+ * @param permissionThe permission required for creating the sign represented by the paid sign
+ * @param ignoreCaseWhether to ignore case for the paid sign's conditions
+ * @param ignoreColorWhether to ignore color for the paid sign's conditions
+ * @returnTrue if the paid sign was successfully created and registered
+ */ + private boolean createPaidSign(CommandSender sender, String signName, double cost, String permission, + OptionState ignoreCase, OptionState ignoreColor) { + PaidSignManager manager = PaidSigns.getInstance().getSignManager(); try { PaidSign sign = new PaidSign(signName, cost, permission, ignoreCase, ignoreColor); if (manager.getPaidSign(signName) != null) { diff --git a/src/main/java/net/knarcraft/paidsigns/command/ListTabCompleter.java b/src/main/java/net/knarcraft/paidsigns/command/ListTabCompleter.java new file mode 100644 index 0000000..ca4628f --- /dev/null +++ b/src/main/java/net/knarcraft/paidsigns/command/ListTabCompleter.java @@ -0,0 +1,29 @@ +package net.knarcraft.paidsigns.command; + +import net.knarcraft.paidsigns.utility.TabCompleteHelper; +import org.bukkit.command.Command; +import org.bukkit.command.CommandSender; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.util.ArrayList; +import java.util.List; + +/** + * The tab completer for the list paid signs command + */ +public class ListTabCompleter extends TokenizedTabCompleter { + + @Nullable + @Override + public List