diff options
| author | LMBishop <13875753+LMBishop@users.noreply.github.com> | 2021-03-03 15:51:32 +0000 |
|---|---|---|
| committer | LMBishop <13875753+LMBishop@users.noreply.github.com> | 2021-03-03 15:51:32 +0000 |
| commit | b851c0fcfc97754a7f1cfb3afa6177a0f9157f95 (patch) | |
| tree | a14f9d40d1cbada3aa56c92119158a0d656a6cff /src/main | |
| parent | 3a454e2597263bac73ac31d250347f7a356fd69f (diff) | |
Add quest tracking command & relicensed under GPLv3
- The GPLv3 license is to comply with Spigot's GPL license.
Diffstat (limited to 'src/main')
| -rw-r--r-- | src/main/java/com/leonardobishop/quests/commands/CommandQuests.java | 31 | ||||
| -rw-r--r-- | src/main/java/com/leonardobishop/quests/player/questprogressfile/QuestProgressFile.java | 3 |
2 files changed, 11 insertions, 23 deletions
diff --git a/src/main/java/com/leonardobishop/quests/commands/CommandQuests.java b/src/main/java/com/leonardobishop/quests/commands/CommandQuests.java index 4df5cd7d..00b7640e 100644 --- a/src/main/java/com/leonardobishop/quests/commands/CommandQuests.java +++ b/src/main/java/com/leonardobishop/quests/commands/CommandQuests.java @@ -370,30 +370,19 @@ public class CommandQuests implements TabExecutor { if (args.length >= 3) { Quest quest = plugin.getQuestManager().getQuestById(args[1]); QPlayer qPlayer = plugin.getPlayerManager().getPlayer(player.getUniqueId()); - + if (qPlayer == null) { + sender.sendMessage(ChatColor.RED + "Your quest progress file has not been loaded yet."); + return true; + } + if (quest == null) { + sender.sendMessage(Messages.COMMAND_QUEST_GENERAL_DOESNTEXIST.getMessage().replace("{quest}", args[1])); + } if (args[2].equalsIgnoreCase("s") || args[2].equalsIgnoreCase("start")) { - if (quest == null) { - sender.sendMessage(Messages.COMMAND_QUEST_START_DOESNTEXIST.getMessage().replace("{quest}", args[1])); - } else { - if (qPlayer == null) { - // shit + fan - sender.sendMessage(ChatColor.RED + "Your quest progress file has not been loaded yet."); //lazy? :) - } else { - qPlayer.getQuestProgressFile().startQuest(quest); - } - } + qPlayer.getQuestProgressFile().startQuest(quest); } else if (args[2].equalsIgnoreCase("c") || args[2].equalsIgnoreCase("cancel")) { - if (qPlayer == null) { - sender.sendMessage(ChatColor.RED + "Your quest progress file has not been loaded yet."); //lazy x2? ;) - } else { - qPlayer.getQuestProgressFile().cancelQuest(quest); - } + qPlayer.getQuestProgressFile().cancelQuest(quest); } else if (args[2].equalsIgnoreCase("t") || args[2].equalsIgnoreCase("track")) { - if (qPlayer == null) { - sender.sendMessage(ChatColor.RED + "Your quest progress file has not been loaded yet."); //lazy x2? ;) - } else { - qPlayer.getQuestProgressFile().trackQuest(quest); - } + qPlayer.getQuestProgressFile().trackQuest(quest); } else { sender.sendMessage(Messages.COMMAND_SUB_DOESNTEXIST.getMessage().replace("{sub}", args[2])); } diff --git a/src/main/java/com/leonardobishop/quests/player/questprogressfile/QuestProgressFile.java b/src/main/java/com/leonardobishop/quests/player/questprogressfile/QuestProgressFile.java index e7a77853..5af227f5 100644 --- a/src/main/java/com/leonardobishop/quests/player/questprogressfile/QuestProgressFile.java +++ b/src/main/java/com/leonardobishop/quests/player/questprogressfile/QuestProgressFile.java @@ -95,12 +95,11 @@ public class QuestProgressFile { /** * Attempt to track a quest for the player. This will also play all effects (such as titles, messages etc.) * - * Warning: will fail if the player is not online. + * Warning: {@link PlayerStopTrackQuestEvent} is not fired if the player is not online * * @param quest the quest to track */ public void trackQuest(Quest quest) { - //TODO change how this works Player player = Bukkit.getPlayer(playerUUID); if (quest == null) { playerPreferences.setTrackedQuestId(null); |
