From a078973df21f019f81d0f22d8579663a4751d03a Mon Sep 17 00:00:00 2001 From: PikaMug <2267126+PikaMug@users.noreply.github.com> Date: Thu, 23 Sep 2021 23:22:12 -0400 Subject: [PATCH] Always continue kill objective checks --- .../quests/listeners/PlayerListener.java | 12 +++++++---- .../implementation/sql/SqlStorage.java | 21 +++++++++---------- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/main/src/main/java/me/blackvein/quests/listeners/PlayerListener.java b/main/src/main/java/me/blackvein/quests/listeners/PlayerListener.java index f8ca10b87..70b332dd9 100644 --- a/main/src/main/java/me/blackvein/quests/listeners/PlayerListener.java +++ b/main/src/main/java/me/blackvein/quests/listeners/PlayerListener.java @@ -677,9 +677,11 @@ public class PlayerListener implements Listener { if (!quester.meetsCondition(quest, true)) { continue; } + if (!quester.getCurrentQuests().containsKey(quest)) { + continue; + } - if (quester.getCurrentQuests().containsKey(quest) - && quester.getCurrentStage(quest).containsObjective(type)) { + if (quester.getCurrentStage(quest).containsObjective(type)) { quester.killMob(quest, target.getLocation(), target.getType()); } @@ -779,9 +781,11 @@ public class PlayerListener implements Listener { if (!quester.meetsCondition(quest, true)) { continue; } + if (!quester.getCurrentQuests().containsKey(quest)) { + continue; + } - if (quester.getCurrentQuests().containsKey(quest) - && quester.getCurrentStage(quest).containsObjective(type)) { + if (quester.getCurrentStage(quest).containsObjective(type)) { quester.killPlayer(quest, (Player)target); } diff --git a/main/src/main/java/me/blackvein/quests/storage/implementation/sql/SqlStorage.java b/main/src/main/java/me/blackvein/quests/storage/implementation/sql/SqlStorage.java index 87bafcacd..22a48f053 100644 --- a/main/src/main/java/me/blackvein/quests/storage/implementation/sql/SqlStorage.java +++ b/main/src/main/java/me/blackvein/quests/storage/implementation/sql/SqlStorage.java @@ -425,7 +425,7 @@ public class SqlStorage implements StorageImplementation { } public ConcurrentHashMap getQuesterCurrentQuests(final UUID uniqueId) throws Exception { - final ConcurrentHashMap currentQuests = new ConcurrentHashMap(); + final ConcurrentHashMap currentQuests = new ConcurrentHashMap<>(); try (Connection c = connectionFactory.getConnection()) { try (PreparedStatement ps = c.prepareStatement(statementProcessor.apply(PLAYER_CURRENT_QUESTS_SELECT_BY_UUID))) { ps.setString(1, uniqueId.toString()); @@ -442,10 +442,9 @@ public class SqlStorage implements StorageImplementation { return currentQuests; } - @SuppressWarnings("unchecked") public ConcurrentHashMap getQuesterQuestData(final UUID uniqueId) throws Exception { final Quester quester = plugin.getQuester(uniqueId); - final ConcurrentHashMap questData = new ConcurrentHashMap(); + final ConcurrentHashMap questData = new ConcurrentHashMap<>(); try (Connection c = connectionFactory.getConnection()) { try (PreparedStatement ps = c.prepareStatement(statementProcessor.apply(PLAYER_QUEST_DATA_SELECT_BY_UUID))) { ps.setString(1, uniqueId.toString()); @@ -499,7 +498,7 @@ public class SqlStorage implements StorageImplementation { } public ConcurrentSkipListSet getQuesterCompletedQuests(final UUID uniqueId) throws Exception { - final ConcurrentSkipListSet completedQuests = new ConcurrentSkipListSet(); + final ConcurrentSkipListSet completedQuests = new ConcurrentSkipListSet<>(); try (Connection c = connectionFactory.getConnection()) { try (PreparedStatement ps = c.prepareStatement(statementProcessor.apply(PLAYER_COMPLETED_QUESTS_SELECT_BY_UUID))) { ps.setString(1, uniqueId.toString()); @@ -517,7 +516,7 @@ public class SqlStorage implements StorageImplementation { } public ConcurrentHashMap getQuesterCompletedTimes(final UUID uniqueId) throws Exception { - final ConcurrentHashMap completedTimes = new ConcurrentHashMap(); + final ConcurrentHashMap completedTimes = new ConcurrentHashMap<>(); try (Connection c = connectionFactory.getConnection()) { try (PreparedStatement ps = c.prepareStatement(statementProcessor.apply(PLAYER_REDOABLE_QUESTS_SELECT_BY_UUID))) { ps.setString(1, uniqueId.toString()); @@ -535,7 +534,7 @@ public class SqlStorage implements StorageImplementation { } public ConcurrentHashMap getQuesterAmountsCompleted(final UUID uniqueId) throws Exception { - final ConcurrentHashMap amountsCompleted = new ConcurrentHashMap(); + final ConcurrentHashMap amountsCompleted = new ConcurrentHashMap<>(); try (Connection c = connectionFactory.getConnection()) { try (PreparedStatement ps = c.prepareStatement(statementProcessor.apply(PLAYER_REDOABLE_QUESTS_SELECT_BY_UUID))) { ps.setString(1, uniqueId.toString()); @@ -554,12 +553,12 @@ public class SqlStorage implements StorageImplementation { @Override public Collection getSavedUniqueIds() throws Exception { - final Collection ids = new ConcurrentSkipListSet(); + final Collection ids = new ConcurrentSkipListSet<>(); try (Connection c = connectionFactory.getConnection()) { try (PreparedStatement ps = c.prepareStatement(statementProcessor.apply(PLAYER_SELECT_UUID))) { try (ResultSet rs = ps.executeQuery()) { while (rs.next()) { - UUID id = null; + UUID id; try { id = UUID.fromString(rs.getString("uuid")); } catch (final IllegalArgumentException e) { @@ -584,7 +583,7 @@ public class SqlStorage implements StorageImplementation { } public LinkedList deserializeIntProgress(String string) { - LinkedList list = new LinkedList(); + LinkedList list = new LinkedList<>(); if (string != null) { string = string.replace("{", "").replace("}", ""); for (String section : string.split(",")) { @@ -595,7 +594,7 @@ public class SqlStorage implements StorageImplementation { } public LinkedList deserializeBooleanProgress(String string) { - LinkedList list = new LinkedList(); + LinkedList list = new LinkedList<>(); if (string != null) { string = string.replace("{", "").replace("}", ""); for (String section : string.split(",")) { @@ -616,7 +615,7 @@ public class SqlStorage implements StorageImplementation { } public LinkedList deserializeItemStackProgress(String string, LinkedList objective) { - LinkedList list = new LinkedList(); + LinkedList list = new LinkedList<>(); if (string != null) { string = string.replace("{", "").replace("}", ""); int index = 0;