diff options
| author | LMBishop <13875753+LMBishop@users.noreply.github.com> | 2019-09-02 20:13:10 +0100 |
|---|---|---|
| committer | LMBishop <13875753+LMBishop@users.noreply.github.com> | 2019-09-02 20:13:10 +0100 |
| commit | 05b6f210c822cee5eee31f5958ed57e4c249136d (patch) | |
| tree | 8e533a8540e9fb70582a7c2582e3e0d197980990 /src | |
| parent | 6c4c3d3811bead8a5e4b0dbdf3cb74a4c5a7f01b (diff) | |
Start strings on quests
- Sends the player a custom string when the quest is started
Diffstat (limited to 'src')
4 files changed, 30 insertions, 21 deletions
diff --git a/src/main/java/com/leonardobishop/quests/QuestsConfigLoader.java b/src/main/java/com/leonardobishop/quests/QuestsConfigLoader.java index 2880dc99..96cff812 100644 --- a/src/main/java/com/leonardobishop/quests/QuestsConfigLoader.java +++ b/src/main/java/com/leonardobishop/quests/QuestsConfigLoader.java @@ -77,6 +77,7 @@ public class QuestsConfigLoader { List<String> rewards = config.getStringList("rewards"); List<String> requirements = config.getStringList("options.requires"); List<String> rewardString = config.getStringList("rewardstring"); + List<String> startString = config.getStringList("startstring"); boolean repeatable = config.getBoolean("options.repeatable", false); boolean cooldown = config.getBoolean("options.cooldown.enabled", false); boolean permissionRequired = config.getBoolean("options.permission-required", false); @@ -84,25 +85,17 @@ public class QuestsConfigLoader { int sortOrder = config.getInt("options.sort-order", 1); String category = config.getString("options.category"); - if (rewardString == null) { - rewardString = new ArrayList<>(); - } - if (requirements == null) { - requirements = new ArrayList<>(); - } - if (rewards == null) { - rewards = new ArrayList<>(); - } - if (category == null) { - category = ""; - } - + if (rewardString == null) rewardString = new ArrayList<>(); + if (startString == null) startString = new ArrayList<>(); + if (requirements == null) requirements = new ArrayList<>(); + if (rewards == null) rewards = new ArrayList<>(); + if (category == null) category = ""; Quest quest; if (category.equals("")) { - quest = new Quest(id, displayItem, rewards, requirements, repeatable, cooldown, cooldownTime, permissionRequired, rewardString, sortOrder); + quest = new Quest(id, displayItem, rewards, requirements, repeatable, cooldown, cooldownTime, permissionRequired, rewardString, startString, sortOrder); } else { - quest = new Quest(id, displayItem, rewards, requirements, repeatable, cooldown, cooldownTime, permissionRequired, rewardString, category, sortOrder); + quest = new Quest(id, displayItem, rewards, requirements, repeatable, cooldown, cooldownTime, permissionRequired, rewardString, startString, category, sortOrder); Category c = plugin.getQuestManager().getCategoryById(category); if (c != null) { c.registerQuestId(id); 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 6396bc13..42251f27 100644 --- a/src/main/java/com/leonardobishop/quests/player/questprogressfile/QuestProgressFile.java +++ b/src/main/java/com/leonardobishop/quests/player/questprogressfile/QuestProgressFile.java @@ -164,6 +164,9 @@ public class QuestProgressFile { .getDisplayNameStripped()), Messages.TITLE_QUEST_START_SUBTITLE.getMessage().replace("{quest}", quest .getDisplayNameStripped())); } + for (String s : quest.getStartString()) { + player.sendMessage(ChatColor.translateAlternateColorCodes('&', s)); + } } } return code; diff --git a/src/main/java/com/leonardobishop/quests/quests/Quest.java b/src/main/java/com/leonardobishop/quests/quests/Quest.java index 3f1ddd9b..a54a06bd 100644 --- a/src/main/java/com/leonardobishop/quests/quests/Quest.java +++ b/src/main/java/com/leonardobishop/quests/quests/Quest.java @@ -14,6 +14,7 @@ public class Quest implements Comparable<Quest> { private List<String> rewards; private List<String> requirements; private List<String> rewardString; + private List<String> startString; private boolean repeatable; private boolean cooldownEnabled; private int cooldown; @@ -22,12 +23,12 @@ public class Quest implements Comparable<Quest> { private String categoryid; - public Quest(String id, QItemStack displayItem, List<String> rewards, List<String> requirements, boolean repeatable, boolean cooldownEnabled, int cooldown, boolean permissionRequired, List<String> rewardString, String categoryid, int sortOrder) { - this(id, displayItem, rewards, requirements, repeatable, cooldownEnabled, cooldown, permissionRequired, rewardString, sortOrder); + public Quest(String id, QItemStack displayItem, List<String> rewards, List<String> requirements, boolean repeatable, boolean cooldownEnabled, int cooldown, boolean permissionRequired, List<String> rewardString, List<String> startString, String categoryid, int sortOrder) { + this(id, displayItem, rewards, requirements, repeatable, cooldownEnabled, cooldown, permissionRequired, rewardString, startString, sortOrder); this.categoryid = categoryid; } - public Quest(String id, QItemStack displayItem, List<String> rewards, List<String> requirements, boolean repeatable, boolean cooldownEnabled, int cooldown, boolean permissionRequired, List<String> rewardString, int sortOrder) { + public Quest(String id, QItemStack displayItem, List<String> rewards, List<String> requirements, boolean repeatable, boolean cooldownEnabled, int cooldown, boolean permissionRequired, List<String> rewardString, List<String> startString, int sortOrder) { this.id = id; this.displayItem = displayItem; this.rewards = rewards; @@ -37,6 +38,7 @@ public class Quest implements Comparable<Quest> { this.cooldown = cooldown; this.permissionRequired = permissionRequired; this.rewardString = rewardString; + this.startString = startString; this.sortOrder = sortOrder; } @@ -71,6 +73,10 @@ public class Quest implements Comparable<Quest> { return rewardString; } + public List<String> getStartString() { + return startString; + } + public String getId() { return id; } diff --git a/src/main/resources/quests/example4.yml b/src/main/resources/quests/example4.yml index f8ee7d69..28734ae7 100644 --- a/src/main/resources/quests/example4.yml +++ b/src/main/resources/quests/example4.yml @@ -1,5 +1,5 @@ # This is a quest which requires the previous quest to be complete to start. -# Unlike the previous quests, this quest has a reward string. +# Unlike the previous quests, this quest has a reward string and a start string. tasks: mobkilling: @@ -18,17 +18,24 @@ display: - "" - "&7Rewards:" - "&7 - $50 added to your in-game balance." + - "&7 - 1 diamond ." lore-started: - "" - "&7Your current progression:" - "&7 - {mobkilling:progress}/3 mobs killed." type: "STRING" +# Here you can list messages which will be sent to the player (if they are online) upon the quest starting. +startstring: + - "&7Upon completion of this quest, you will be rewarded with" + - " &8* &c$50" + - " &8* &c1 diamonds" rewards: - "eco give {player} 50" + - "give {player} diamond 1" # Here you can list messages which will be sent to the player (if they are online) upon completion. rewardstring: - - " &8* &c$10 &7was added to your in-game balance." - - " &8* &c30 diamonds &7was added to your inventory." + - " &8* &c$1000 &7was added to your in-game balance." + - " &8* &c1 diamond &7was added to your inventory." options: category: "examples" requires: |
