1
0
mirror of https://github.com/Zrips/Jobs.git synced 2024-11-29 05:55:27 +01:00

Added cost for skipping quests

This commit is contained in:
montlikadani 2019-11-09 19:50:09 +01:00
parent 389424fbb8
commit cdd95e2a9b
5 changed files with 28 additions and 2 deletions

View File

@ -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

View File

@ -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;
}
}

View File

@ -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);

View File

@ -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]"));

View File

@ -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