Tab complete applicable quests only

This commit is contained in:
PikaMug 2022-04-27 05:24:27 -04:00
parent 684a3ebbdb
commit 2d3592a89c
7 changed files with 99 additions and 20 deletions

View File

@ -1595,7 +1595,7 @@ public class Quests extends JavaPlugin implements QuestsAPI {
}
/**
* Show the player a list of their quests
* Show the player a list of their available quests
*
* @param quester Quester to show the list
* @param page Page to display, with 7 quests per page

View File

@ -12,6 +12,7 @@
package me.blackvein.quests.commands.questadmin.subcommands;
import me.blackvein.quests.Quester;
import me.blackvein.quests.Quests;
import me.blackvein.quests.commands.QuestsSubCommand;
import me.blackvein.quests.player.IQuester;
@ -114,11 +115,23 @@ public class QuestadminFinishCommand extends QuestsSubCommand {
return null; // Shows online players
} else if (args.length == 3) {
final List<String> results = new ArrayList<>();
final Player player = Bukkit.getPlayer(args[1]);
if (player != null) {
final Quester quester = plugin.getQuester(player.getUniqueId());
if (quester != null) {
for (final IQuest quest : quester.getCurrentQuests().keySet()) {
if (quest.getName().toLowerCase().startsWith(args[2].toLowerCase())) {
results.add(ChatColor.stripColor(quest.getName()));
}
}
}
} else {
for (final IQuest quest : plugin.getLoadedQuests()) {
if (quest.getName().toLowerCase().startsWith(args[2].toLowerCase())) {
results.add(ChatColor.stripColor(quest.getName()));
}
}
}
return results;
}
return Collections.emptyList();

View File

@ -12,6 +12,7 @@
package me.blackvein.quests.commands.questadmin.subcommands;
import me.blackvein.quests.Quester;
import me.blackvein.quests.Quests;
import me.blackvein.quests.commands.QuestsSubCommand;
import me.blackvein.quests.player.IQuester;
@ -114,11 +115,23 @@ public class QuestadminNextstageCommand extends QuestsSubCommand {
return null; // Shows online players
} else if (args.length == 3) {
final List<String> results = new ArrayList<>();
final Player player = Bukkit.getPlayer(args[1]);
if (player != null) {
final Quester quester = plugin.getQuester(player.getUniqueId());
if (quester != null) {
for (final IQuest quest : quester.getCurrentQuests().keySet()) {
if (quest.getName().toLowerCase().startsWith(args[2].toLowerCase())) {
results.add(ChatColor.stripColor(quest.getName()));
}
}
}
} else {
for (final IQuest quest : plugin.getLoadedQuests()) {
if (quest.getName().toLowerCase().startsWith(args[2].toLowerCase())) {
results.add(ChatColor.stripColor(quest.getName()));
}
}
}
return results;
}
return Collections.emptyList();

View File

@ -12,6 +12,7 @@
package me.blackvein.quests.commands.questadmin.subcommands;
import me.blackvein.quests.Quester;
import me.blackvein.quests.Quests;
import me.blackvein.quests.commands.QuestsSubCommand;
import me.blackvein.quests.player.IQuester;
@ -109,11 +110,23 @@ public class QuestadminQuitCommand extends QuestsSubCommand {
return null; // Shows online players
} else if (args.length == 3) {
final List<String> results = new ArrayList<>();
final Player player = Bukkit.getPlayer(args[1]);
if (player != null) {
final Quester quester = plugin.getQuester(player.getUniqueId());
if (quester != null) {
for (final IQuest quest : quester.getCurrentQuests().keySet()) {
if (quest.getName().toLowerCase().startsWith(args[2].toLowerCase())) {
results.add(ChatColor.stripColor(quest.getName()));
}
}
}
} else {
for (final IQuest quest : plugin.getLoadedQuests()) {
if (quest.getName().toLowerCase().startsWith(args[2].toLowerCase())) {
results.add(ChatColor.stripColor(quest.getName()));
}
}
}
return results;
}
return Collections.emptyList();

View File

@ -12,6 +12,7 @@
package me.blackvein.quests.commands.questadmin.subcommands;
import me.blackvein.quests.Quester;
import me.blackvein.quests.Quests;
import me.blackvein.quests.commands.QuestsSubCommand;
import me.blackvein.quests.player.IQuester;
@ -21,6 +22,7 @@ import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.OfflinePlayer;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.Collections;
@ -89,7 +91,7 @@ public class QuestadminRemoveCommand extends QuestsSubCommand {
} else {
msg = msg.replace("<player>", ChatColor.GREEN + args[1] + ChatColor.GOLD);
}
msg = msg.replace("<quest>", ChatColor.DARK_PURPLE + toRemove.getName() + ChatColor.AQUA);
msg = msg.replace("<quest>", ChatColor.DARK_PURPLE + toRemove.getName() + ChatColor.GOLD);
cs.sendMessage(ChatColor.GOLD + msg);
cs.sendMessage(ChatColor.DARK_PURPLE + " UUID: " + ChatColor.DARK_AQUA + quester.getUUID().toString());
quester.hardRemove(toRemove);
@ -106,11 +108,23 @@ public class QuestadminRemoveCommand extends QuestsSubCommand {
return null; // Shows online players
} else if (args.length == 3) {
final List<String> results = new ArrayList<>();
final Player player = Bukkit.getPlayer(args[1]);
if (player != null) {
final Quester quester = plugin.getQuester(player.getUniqueId());
if (quester != null) {
for (final IQuest quest : quester.getCompletedQuests()) {
if (quest.getName().toLowerCase().startsWith(args[2].toLowerCase())) {
results.add(ChatColor.stripColor(quest.getName()));
}
}
}
} else {
for (final IQuest quest : plugin.getLoadedQuests()) {
if (quest.getName().toLowerCase().startsWith(args[2].toLowerCase())) {
results.add(ChatColor.stripColor(quest.getName()));
}
}
}
return results;
}
return Collections.emptyList();

View File

@ -13,6 +13,7 @@
package me.blackvein.quests.commands.questadmin.subcommands;
import me.blackvein.quests.Quest;
import me.blackvein.quests.Quester;
import me.blackvein.quests.Quests;
import me.blackvein.quests.commands.QuestsSubCommand;
import me.blackvein.quests.player.IQuester;
@ -22,6 +23,7 @@ import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.OfflinePlayer;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.Collections;
@ -134,9 +136,21 @@ public class QuestadminSetstageCommand extends QuestsSubCommand {
return null; // Shows online players
} else if (args.length == 3) {
final List<String> results = new ArrayList<>();
final Player player = Bukkit.getPlayer(args[1]);
if (player != null) {
final Quester quester = plugin.getQuester(player.getUniqueId());
if (quester != null) {
for (final IQuest quest : quester.getCurrentQuests().keySet()) {
if (quest.getName().toLowerCase().startsWith(args[2].toLowerCase())) {
results.add(ChatColor.stripColor(quest.getName()));
}
}
}
} else {
for (final IQuest quest : plugin.getLoadedQuests()) {
if (quest.getName().toLowerCase().startsWith(args[2].toLowerCase())) {
results.add(quest.getName());
results.add(ChatColor.stripColor(quest.getName()));
}
}
}
return results;

View File

@ -12,6 +12,7 @@
package me.blackvein.quests.commands.quests.subcommands;
import me.blackvein.quests.Quester;
import me.blackvein.quests.Quests;
import me.blackvein.quests.commands.QuestsSubCommand;
import me.blackvein.quests.player.IQuester;
@ -100,11 +101,22 @@ public class QuestsQuitCommand extends QuestsSubCommand {
public List<String> tabComplete(CommandSender commandSender, String[] args) {
if (args.length == 2) {
final List<String> results = new ArrayList<>();
if (commandSender instanceof Player) {
final Quester quester = plugin.getQuester(((Player) commandSender).getUniqueId());
if (quester != null) {
for (final IQuest quest : quester.getCurrentQuests().keySet()) {
if (quest.getName().toLowerCase().startsWith(args[1].toLowerCase())) {
results.add(ChatColor.stripColor(quest.getName()));
}
}
}
} else {
for (final IQuest quest : plugin.getLoadedQuests()) {
if (quest.getName().toLowerCase().startsWith(args[1].toLowerCase())) {
results.add(ChatColor.stripColor(quest.getName()));
}
}
}
return results;
}
return Collections.emptyList();