From 637ac02ee2fd09e45ce85621cc2ef441c66e2aeb Mon Sep 17 00:00:00 2001 From: PikaMug <2267126+PikaMug@users.noreply.github.com> Date: Thu, 24 Mar 2022 01:28:51 -0400 Subject: [PATCH] Remove color on quest tab complete, fixes #1907 --- .../main/java/me/blackvein/quests/Quests.java | 29 +++++++++++++++++++ .../subcommands/QuestadminFinishCommand.java | 2 +- .../subcommands/QuestadminGiveCommand.java | 2 +- .../QuestadminNextstageCommand.java | 2 +- .../subcommands/QuestadminQuitCommand.java | 2 +- .../subcommands/QuestadminRemoveCommand.java | 2 +- .../quests/subcommands/QuestsQuitCommand.java | 2 +- .../quests/subcommands/QuestsTakeCommand.java | 2 +- 8 files changed, 36 insertions(+), 7 deletions(-) diff --git a/core/src/main/java/me/blackvein/quests/Quests.java b/core/src/main/java/me/blackvein/quests/Quests.java index 2998a602d..788adf776 100644 --- a/core/src/main/java/me/blackvein/quests/Quests.java +++ b/core/src/main/java/me/blackvein/quests/Quests.java @@ -4332,6 +4332,14 @@ public class Quests extends JavaPlugin implements QuestsAPI { return q; } } + for (final IQuest iq : quests) { + // For tab completion + final Quest q = (Quest) iq; + if (ChatColor.stripColor(q.getName()).equals(ChatColor.stripColor(ChatColor + .translateAlternateColorCodes('&', name)))) { + return q; + } + } return null; } @@ -4360,6 +4368,13 @@ public class Quests extends JavaPlugin implements QuestsAPI { return q; } } + for (final IQuest q : quests) { + // For tab completion + if (ChatColor.stripColor(q.getName()).equals(ChatColor.stripColor(ChatColor + .translateAlternateColorCodes('&', name)))) { + return q; + } + } return null; } @@ -4388,6 +4403,13 @@ public class Quests extends JavaPlugin implements QuestsAPI { return a; } } + for (final IAction a : actions) { + // For tab completion + if (ChatColor.stripColor(a.getName()).equals(ChatColor.stripColor(ChatColor. + translateAlternateColorCodes('&', name)))) { + return a; + } + } return null; } @@ -4416,6 +4438,13 @@ public class Quests extends JavaPlugin implements QuestsAPI { return c; } } + for (final ICondition c : conditions) { + // For tab completion + if (ChatColor.stripColor(c.getName()).equals(ChatColor.stripColor(ChatColor + .translateAlternateColorCodes('&', name)))) { + return c; + } + } return null; } diff --git a/core/src/main/java/me/blackvein/quests/commands/questadmin/subcommands/QuestadminFinishCommand.java b/core/src/main/java/me/blackvein/quests/commands/questadmin/subcommands/QuestadminFinishCommand.java index 16dd54a30..cfbc333d3 100644 --- a/core/src/main/java/me/blackvein/quests/commands/questadmin/subcommands/QuestadminFinishCommand.java +++ b/core/src/main/java/me/blackvein/quests/commands/questadmin/subcommands/QuestadminFinishCommand.java @@ -116,7 +116,7 @@ public class QuestadminFinishCommand extends QuestsSubCommand { final List results = new ArrayList<>(); 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; diff --git a/core/src/main/java/me/blackvein/quests/commands/questadmin/subcommands/QuestadminGiveCommand.java b/core/src/main/java/me/blackvein/quests/commands/questadmin/subcommands/QuestadminGiveCommand.java index c8831dfdd..a243f2739 100644 --- a/core/src/main/java/me/blackvein/quests/commands/questadmin/subcommands/QuestadminGiveCommand.java +++ b/core/src/main/java/me/blackvein/quests/commands/questadmin/subcommands/QuestadminGiveCommand.java @@ -135,7 +135,7 @@ public class QuestadminGiveCommand extends QuestsSubCommand { final List results = new ArrayList<>(); 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; diff --git a/core/src/main/java/me/blackvein/quests/commands/questadmin/subcommands/QuestadminNextstageCommand.java b/core/src/main/java/me/blackvein/quests/commands/questadmin/subcommands/QuestadminNextstageCommand.java index b4f6a3ca3..dbf0b02f9 100644 --- a/core/src/main/java/me/blackvein/quests/commands/questadmin/subcommands/QuestadminNextstageCommand.java +++ b/core/src/main/java/me/blackvein/quests/commands/questadmin/subcommands/QuestadminNextstageCommand.java @@ -116,7 +116,7 @@ public class QuestadminNextstageCommand extends QuestsSubCommand { final List results = new ArrayList<>(); 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; diff --git a/core/src/main/java/me/blackvein/quests/commands/questadmin/subcommands/QuestadminQuitCommand.java b/core/src/main/java/me/blackvein/quests/commands/questadmin/subcommands/QuestadminQuitCommand.java index 7f2f682ef..ad09a508d 100644 --- a/core/src/main/java/me/blackvein/quests/commands/questadmin/subcommands/QuestadminQuitCommand.java +++ b/core/src/main/java/me/blackvein/quests/commands/questadmin/subcommands/QuestadminQuitCommand.java @@ -111,7 +111,7 @@ public class QuestadminQuitCommand extends QuestsSubCommand { final List results = new ArrayList<>(); 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; diff --git a/core/src/main/java/me/blackvein/quests/commands/questadmin/subcommands/QuestadminRemoveCommand.java b/core/src/main/java/me/blackvein/quests/commands/questadmin/subcommands/QuestadminRemoveCommand.java index 7a9de27ee..2b7ec4bc8 100644 --- a/core/src/main/java/me/blackvein/quests/commands/questadmin/subcommands/QuestadminRemoveCommand.java +++ b/core/src/main/java/me/blackvein/quests/commands/questadmin/subcommands/QuestadminRemoveCommand.java @@ -108,7 +108,7 @@ public class QuestadminRemoveCommand extends QuestsSubCommand { final List results = new ArrayList<>(); 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; diff --git a/core/src/main/java/me/blackvein/quests/commands/quests/subcommands/QuestsQuitCommand.java b/core/src/main/java/me/blackvein/quests/commands/quests/subcommands/QuestsQuitCommand.java index ae519be95..b76cd21e3 100644 --- a/core/src/main/java/me/blackvein/quests/commands/quests/subcommands/QuestsQuitCommand.java +++ b/core/src/main/java/me/blackvein/quests/commands/quests/subcommands/QuestsQuitCommand.java @@ -102,7 +102,7 @@ public class QuestsQuitCommand extends QuestsSubCommand { final List results = new ArrayList<>(); for (final IQuest quest : plugin.getLoadedQuests()) { if (quest.getName().toLowerCase().startsWith(args[1].toLowerCase())) { - results.add(quest.getName()); + results.add(ChatColor.stripColor(quest.getName())); } } return results; diff --git a/core/src/main/java/me/blackvein/quests/commands/quests/subcommands/QuestsTakeCommand.java b/core/src/main/java/me/blackvein/quests/commands/quests/subcommands/QuestsTakeCommand.java index eac581084..9b19cedfe 100644 --- a/core/src/main/java/me/blackvein/quests/commands/quests/subcommands/QuestsTakeCommand.java +++ b/core/src/main/java/me/blackvein/quests/commands/quests/subcommands/QuestsTakeCommand.java @@ -102,7 +102,7 @@ public class QuestsTakeCommand extends QuestsSubCommand { final List results = new ArrayList<>(); for (final IQuest quest : plugin.getLoadedQuests()) { if (quest.getName().toLowerCase().startsWith(args[1].toLowerCase())) { - results.add(quest.getName()); + results.add(ChatColor.stripColor(quest.getName())); } } return results;