mirror of
https://github.com/PikaMug/Quests.git
synced 2024-11-22 10:36:09 +01:00
Tab complete applicable quests only
This commit is contained in:
parent
684a3ebbdb
commit
2d3592a89c
@ -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
|
||||
|
@ -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,9 +115,21 @@ public class QuestadminFinishCommand extends QuestsSubCommand {
|
||||
return null; // Shows online players
|
||||
} else if (args.length == 3) {
|
||||
final List<String> results = new ArrayList<>();
|
||||
for (final IQuest quest : plugin.getLoadedQuests()) {
|
||||
if (quest.getName().toLowerCase().startsWith(args[2].toLowerCase())) {
|
||||
results.add(ChatColor.stripColor(quest.getName()));
|
||||
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;
|
||||
|
@ -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,9 +115,21 @@ public class QuestadminNextstageCommand extends QuestsSubCommand {
|
||||
return null; // Shows online players
|
||||
} else if (args.length == 3) {
|
||||
final List<String> results = new ArrayList<>();
|
||||
for (final IQuest quest : plugin.getLoadedQuests()) {
|
||||
if (quest.getName().toLowerCase().startsWith(args[2].toLowerCase())) {
|
||||
results.add(ChatColor.stripColor(quest.getName()));
|
||||
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;
|
||||
|
@ -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,9 +110,21 @@ public class QuestadminQuitCommand extends QuestsSubCommand {
|
||||
return null; // Shows online players
|
||||
} else if (args.length == 3) {
|
||||
final List<String> results = new ArrayList<>();
|
||||
for (final IQuest quest : plugin.getLoadedQuests()) {
|
||||
if (quest.getName().toLowerCase().startsWith(args[2].toLowerCase())) {
|
||||
results.add(ChatColor.stripColor(quest.getName()));
|
||||
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;
|
||||
|
@ -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,9 +108,21 @@ public class QuestadminRemoveCommand extends QuestsSubCommand {
|
||||
return null; // Shows online players
|
||||
} else if (args.length == 3) {
|
||||
final List<String> results = new ArrayList<>();
|
||||
for (final IQuest quest : plugin.getLoadedQuests()) {
|
||||
if (quest.getName().toLowerCase().startsWith(args[2].toLowerCase())) {
|
||||
results.add(ChatColor.stripColor(quest.getName()));
|
||||
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;
|
||||
|
@ -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<>();
|
||||
for (final IQuest quest : plugin.getLoadedQuests()) {
|
||||
if (quest.getName().toLowerCase().startsWith(args[2].toLowerCase())) {
|
||||
results.add(quest.getName());
|
||||
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;
|
||||
|
@ -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,9 +101,20 @@ public class QuestsQuitCommand extends QuestsSubCommand {
|
||||
public List<String> tabComplete(CommandSender commandSender, String[] args) {
|
||||
if (args.length == 2) {
|
||||
final List<String> results = new ArrayList<>();
|
||||
for (final IQuest quest : plugin.getLoadedQuests()) {
|
||||
if (quest.getName().toLowerCase().startsWith(args[1].toLowerCase())) {
|
||||
results.add(ChatColor.stripColor(quest.getName()));
|
||||
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;
|
||||
|
Loading…
Reference in New Issue
Block a user