From f435d871ddd95325a1cc164fceeaa4ea836d77ec Mon Sep 17 00:00:00 2001 From: PikaMug <2267126+PikaMug@users.noreply.github.com> Date: Sun, 29 Nov 2020 23:17:59 -0500 Subject: [PATCH] Populate last known name on Quester instantiation, fixes #1479 --- main/src/main/java/me/blackvein/quests/Quester.java | 5 +++++ main/src/main/java/me/blackvein/quests/Quests.java | 3 +-- .../main/java/me/blackvein/quests/listeners/CmdExecutor.java | 3 +-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/main/src/main/java/me/blackvein/quests/Quester.java b/main/src/main/java/me/blackvein/quests/Quester.java index 2f78f0d8d..115c1875b 100644 --- a/main/src/main/java/me/blackvein/quests/Quester.java +++ b/main/src/main/java/me/blackvein/quests/Quester.java @@ -228,6 +228,10 @@ public class Quester implements Comparable { } }; + /** + * @deprecated Use {@link #Quester(Quests, UUID)} + */ + @Deprecated public Quester(final Quests plugin) { this.plugin = plugin; } @@ -235,6 +239,7 @@ public class Quester implements Comparable { public Quester(final Quests plugin, final UUID uuid) { this.plugin = plugin; this.id = uuid; + this.lastKnownName = Bukkit.getOfflinePlayer(uuid).getName(); } @Override diff --git a/main/src/main/java/me/blackvein/quests/Quests.java b/main/src/main/java/me/blackvein/quests/Quests.java index 4e685d6ee..9ef63be60 100644 --- a/main/src/main/java/me/blackvein/quests/Quests.java +++ b/main/src/main/java/me/blackvein/quests/Quests.java @@ -509,8 +509,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener Quester quester = getQuester(player.getUniqueId()); if (quester == null) { // Must be new player - quester = new Quester(Quests.this); - quester.setUUID(player.getUniqueId()); + quester = new Quester(Quests.this, player.getUniqueId()); if (quester.saveData()) { getLogger().info("Created new data for player " + player.getName()); } else { diff --git a/main/src/main/java/me/blackvein/quests/listeners/CmdExecutor.java b/main/src/main/java/me/blackvein/quests/listeners/CmdExecutor.java index a49503122..fd7a5824c 100644 --- a/main/src/main/java/me/blackvein/quests/listeners/CmdExecutor.java +++ b/main/src/main/java/me/blackvein/quests/listeners/CmdExecutor.java @@ -1399,8 +1399,7 @@ public class CmdExecutor implements CommandExecutor { } catch (final Exception e) { plugin.getLogger().info("Data file does not exist for " + id.toString()); } - quester = new Quester(plugin); - quester.setUUID(id); + quester = new Quester(plugin, id); quester.saveData(); final ConcurrentSkipListSet temp2 = (ConcurrentSkipListSet) plugin.getOfflineQuesters(); temp2.add(quester);