diff --git a/Changelog.txt b/Changelog.txt index 7c6d680b..e662229f 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -1,5 +1,6 @@ # 4.15.0 - Fixed issue when the quest description only showed one lines of list. +- Added cost for skipping quests # 4.14.0 - Fixed %titlename% placeholder does not showed anything diff --git a/src/main/java/com/gamingmesh/jobs/commands/list/skipquest.java b/src/main/java/com/gamingmesh/jobs/commands/list/skipquest.java index da22740c..581ab324 100644 --- a/src/main/java/com/gamingmesh/jobs/commands/list/skipquest.java +++ b/src/main/java/com/gamingmesh/jobs/commands/list/skipquest.java @@ -13,6 +13,7 @@ import com.gamingmesh.jobs.container.Job; import com.gamingmesh.jobs.container.JobsPlayer; import com.gamingmesh.jobs.container.Quest; import com.gamingmesh.jobs.container.QuestProgression; +import com.gamingmesh.jobs.economy.BufferedEconomy; public class skipquest implements Cmd { @@ -77,10 +78,26 @@ public class skipquest implements Cmd { if (Jobs.getGCManager().getDailyQuestsSkips() <= jPlayer.getSkippedQuests()) return false; + double amount = Jobs.getGCManager().skipQuestCost; + BufferedEconomy econ = Jobs.getEconomy(); + if (amount > 0) { + if (!econ.getEconomy().hasMoney(jPlayer.getPlayer(), amount)) { + sender.sendMessage(Jobs.getLanguage().getMessage("economy.error.nomoney")); + return false; + } + + econ.getEconomy().withdrawPlayer(jPlayer.getPlayer(), amount); + } + jPlayer.replaceQuest(old); if (jPlayer.isOnline()) Bukkit.dispatchCommand(jPlayer.getPlayer(), "jobs quests"); + + if (amount > 0) { + sender.sendMessage(Jobs.getLanguage().getMessage("command.skipquest.output.questSkipForCost", "%amount%", amount)); + } + return true; } } diff --git a/src/main/java/com/gamingmesh/jobs/config/GeneralConfigManager.java b/src/main/java/com/gamingmesh/jobs/config/GeneralConfigManager.java index 7331ca09..c5db7154 100644 --- a/src/main/java/com/gamingmesh/jobs/config/GeneralConfigManager.java +++ b/src/main/java/com/gamingmesh/jobs/config/GeneralConfigManager.java @@ -78,6 +78,7 @@ public class GeneralConfigManager { private int ResetTimeHour; private int ResetTimeMinute; private int DailyQuestsSkips; + public double skipQuestCost; private ConfigReader c = null; // Limits @@ -526,8 +527,10 @@ public class GeneralConfigManager { "Any daily quests given before reset will be invalid and new ones will be given out"); ResetTimeHour = c.get("DailyQuests.ResetTime.Hour", 4); ResetTimeMinute = c.get("DailyQuests.ResetTime.Minute", 0); - c.addComment("DailyQuests.Skips", "Defines amount of skips player can do on a quest","This allows player to abandon current quest and get new one"); + c.addComment("DailyQuests.Skips", "Defines amount of skips player can do on a quest", "This allows player to abandon current quest and get new one"); DailyQuestsSkips = c.get("DailyQuests.Skips", 1); + c.addComment("DailyQuests.SkipQuestCost", "The cost of the quest skip (money).", "Default 0, disabling cost of skipping quest."); + skipQuestCost = c.get("DailyQuests.SkipQuestCost", 0d); c.addComment("ScheduleManager", "Enables the schedule manager to boost the server.", "By default this has been disabled for causing memory leak."); enableSchedule = c.get("ScheduleManager.Use", true); diff --git a/src/main/java/com/gamingmesh/jobs/config/LanguageManager.java b/src/main/java/com/gamingmesh/jobs/config/LanguageManager.java index 502dec33..7583eff8 100644 --- a/src/main/java/com/gamingmesh/jobs/config/LanguageManager.java +++ b/src/main/java/com/gamingmesh/jobs/config/LanguageManager.java @@ -507,7 +507,8 @@ public class LanguageManager { c.get("command.skipquest.help.info", "Skip defined quest and get new one"); c.get("command.skipquest.help.args", "[jobname] [questname] (playerName)"); - + c.get("command.skipquest.output.questSkipForCost", "&2You skipped the quest and paid:&e %amount%$"); + c.get("command.quests.help.info", "List available quests"); c.get("command.quests.help.args", "[playername]"); Jobs.getGCManager().getCommandArgs().put("quests", Arrays.asList("[playername]")); diff --git a/src/main/java/com/gamingmesh/jobs/economy/BufferedEconomy.java b/src/main/java/com/gamingmesh/jobs/economy/BufferedEconomy.java index 30b3e0b1..c89b7242 100644 --- a/src/main/java/com/gamingmesh/jobs/economy/BufferedEconomy.java +++ b/src/main/java/com/gamingmesh/jobs/economy/BufferedEconomy.java @@ -49,6 +49,10 @@ public class BufferedEconomy { this.economy = economy; } + public Economy getEconomy() { + return economy; + } + /** * Add payment to player's payment buffer * @param player - player to be paid