mirror of
https://github.com/PikaMug/Quests.git
synced 2024-12-29 12:37:36 +01:00
NEW date/time Planner section, part 2, #93
This commit is contained in:
parent
41c2103d3e
commit
b7143785ed
@ -69,6 +69,11 @@ public class Quest {
|
||||
Map<String, Map<String, Object>> customRequirements = new HashMap<String, Map<String, Object>>();
|
||||
Map<String, Map<String, Object>> customRewards = new HashMap<String, Map<String, Object>>();
|
||||
public String failRequirements = null;
|
||||
//Planner
|
||||
public long startPlanner = -1;
|
||||
public long endPlanner = -1;
|
||||
public long repeatPlanner = -1;
|
||||
public long cooldownPlanner = -1;
|
||||
// Rewards
|
||||
int moneyReward = 0;
|
||||
int questPoints = 0;
|
||||
@ -81,11 +86,6 @@ public class Quest {
|
||||
List<String> heroesClasses = new LinkedList<String>();
|
||||
List<Double> heroesAmounts = new LinkedList<Double>();
|
||||
List<String> phatLootRewards = new LinkedList<String>();
|
||||
//Planner
|
||||
public long startPlanner = -1;
|
||||
public long endPlanner = -1;
|
||||
public long repeatPlanner = -1;
|
||||
public long cooldownPlanner = -1;
|
||||
|
||||
public Stage getStage(int index) {
|
||||
try {
|
||||
|
@ -232,7 +232,7 @@ public class QuestFactory implements ConversationAbandonedListener {
|
||||
} else {
|
||||
return new CreateMenuPrompt();
|
||||
}
|
||||
} else if (input.equalsIgnoreCase("8")) {
|
||||
} else if (input.equalsIgnoreCase("9")) {
|
||||
return new RequirementsPrompt(plugin, QuestFactory.this);
|
||||
} else if (input.equalsIgnoreCase("10")) {
|
||||
return new PlannerPrompt(plugin, QuestFactory.this);
|
||||
|
@ -6,6 +6,7 @@ import org.bukkit.ChatColor;
|
||||
import org.bukkit.conversations.ConversationContext;
|
||||
import org.bukkit.conversations.FixedSetPrompt;
|
||||
import org.bukkit.conversations.Prompt;
|
||||
import org.bukkit.conversations.StringPrompt;
|
||||
|
||||
public class DateTimePrompt extends FixedSetPrompt {
|
||||
|
||||
@ -34,11 +35,38 @@ public class DateTimePrompt extends FixedSetPrompt {
|
||||
@Override
|
||||
protected Prompt acceptValidatedInput(ConversationContext cc, String input) {
|
||||
if (input.equalsIgnoreCase("1")) {
|
||||
//return new DayPrompt();
|
||||
return new DayPrompt();
|
||||
} else if (input.equalsIgnoreCase("2")) {
|
||||
//return new MonthPrompt();
|
||||
return new MonthPrompt();
|
||||
} else if (input.equalsIgnoreCase("3")) {
|
||||
//return new YearPrompt();
|
||||
return new YearPrompt();
|
||||
} else if (input.equalsIgnoreCase("4")) {
|
||||
return new HourPrompt();
|
||||
} else if (input.equalsIgnoreCase("5")) {
|
||||
return new MinutePrompt();
|
||||
} else if (input.equalsIgnoreCase("6")) {
|
||||
return new SecondPrompt();
|
||||
} else if (input.equalsIgnoreCase("7")) {
|
||||
return new ZonePrompt();
|
||||
} else if (input.equalsIgnoreCase("8")) {
|
||||
cc.setSessionData("tempDay", null);
|
||||
cc.setSessionData("tempMonth", null);
|
||||
cc.setSessionData("tempYear", null);
|
||||
cc.setSessionData("tempHour", null);
|
||||
cc.setSessionData("tempMinute", null);
|
||||
cc.setSessionData("tempSecond", null);
|
||||
cc.setSessionData("tempZone", null);
|
||||
} else if (input.equalsIgnoreCase("9")) {
|
||||
int day = (Integer) cc.getSessionData("tempDay");
|
||||
int month = (Integer) cc.getSessionData("tempMonth");
|
||||
int year = (Integer) cc.getSessionData("tempYear");
|
||||
int hour = (Integer) cc.getSessionData("tempHour");
|
||||
int minute = (Integer) cc.getSessionData("tempMinute");
|
||||
int second = (Integer) cc.getSessionData("tempSecond");
|
||||
int zone = (Integer) cc.getSessionData("tempZone");
|
||||
String date = day + ":" + month + ":" + year + ":"
|
||||
+ hour + ":" + minute + ":" + second + ":" + zone;
|
||||
cc.setSessionData("tempDate", date);
|
||||
}
|
||||
try {
|
||||
return oldPrompt;
|
||||
@ -47,4 +75,207 @@ public class DateTimePrompt extends FixedSetPrompt {
|
||||
return Prompt.END_OF_CONVERSATION;
|
||||
}
|
||||
}
|
||||
|
||||
private class DayPrompt extends StringPrompt {
|
||||
|
||||
@Override
|
||||
public String getPromptText(ConversationContext cc) {
|
||||
return ChatColor.YELLOW + Lang.get("dateCreateEnterDay");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Prompt acceptInput(ConversationContext cc, String input) {
|
||||
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) {
|
||||
try {
|
||||
int amt = Integer.parseInt(input);
|
||||
if (amt < 1 || amt > 31) {
|
||||
cc.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("dateCreateInvalidDay"));
|
||||
return new DayPrompt();
|
||||
} else {
|
||||
cc.setSessionData("tempDay", Integer.parseInt(input));
|
||||
return new ItemStackPrompt(oldPrompt);
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
cc.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("itemCreateInvalidInput"));
|
||||
return new DayPrompt();
|
||||
}
|
||||
} else {
|
||||
return new DateTimePrompt(oldPrompt);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class MonthPrompt extends StringPrompt {
|
||||
|
||||
@Override
|
||||
public String getPromptText(ConversationContext cc) {
|
||||
return ChatColor.YELLOW + Lang.get("dateCreateEnterMonth");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Prompt acceptInput(ConversationContext cc, String input) {
|
||||
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) {
|
||||
try {
|
||||
int amt = Integer.parseInt(input);
|
||||
if (amt < 1 || amt > 12) {
|
||||
cc.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("dateCreateInvalidMonth"));
|
||||
return new MonthPrompt();
|
||||
} else {
|
||||
cc.setSessionData("tempMonth", Integer.parseInt(input));
|
||||
return new DateTimePrompt(oldPrompt);
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
cc.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("itemCreateInvalidInput"));
|
||||
return new MonthPrompt();
|
||||
}
|
||||
} else {
|
||||
return new DateTimePrompt(oldPrompt);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class YearPrompt extends StringPrompt {
|
||||
|
||||
@Override
|
||||
public String getPromptText(ConversationContext cc) {
|
||||
return ChatColor.YELLOW + Lang.get("dateCreateEnterYear");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Prompt acceptInput(ConversationContext cc, String input) {
|
||||
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) {
|
||||
try {
|
||||
int amt = Integer.parseInt(input);
|
||||
if (amt < 1000 || amt > 9999) {
|
||||
cc.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("dateCreateInvalidYear"));
|
||||
return new YearPrompt();
|
||||
} else {
|
||||
cc.setSessionData("tempYear", Integer.parseInt(input));
|
||||
return new DateTimePrompt(oldPrompt);
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
cc.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("itemCreateInvalidInput"));
|
||||
return new YearPrompt();
|
||||
}
|
||||
} else {
|
||||
return new DateTimePrompt(oldPrompt);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class HourPrompt extends StringPrompt {
|
||||
|
||||
@Override
|
||||
public String getPromptText(ConversationContext cc) {
|
||||
return ChatColor.YELLOW + Lang.get("dateCreateEnterHour");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Prompt acceptInput(ConversationContext cc, String input) {
|
||||
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) {
|
||||
try {
|
||||
int amt = Integer.parseInt(input);
|
||||
if (amt < 0 || amt > 23) {
|
||||
cc.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("dateCreateInvalidHour"));
|
||||
return new HourPrompt();
|
||||
} else {
|
||||
cc.setSessionData("tempHour", Integer.parseInt(input));
|
||||
return new DateTimePrompt(oldPrompt);
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
cc.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("itemCreateInvalidInput"));
|
||||
return new HourPrompt();
|
||||
}
|
||||
} else {
|
||||
return new DateTimePrompt(oldPrompt);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class MinutePrompt extends StringPrompt {
|
||||
|
||||
@Override
|
||||
public String getPromptText(ConversationContext cc) {
|
||||
return ChatColor.YELLOW + Lang.get("dateCreateEnterMinute");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Prompt acceptInput(ConversationContext cc, String input) {
|
||||
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) {
|
||||
try {
|
||||
int amt = Integer.parseInt(input);
|
||||
if (amt < 0 || amt > 59) {
|
||||
cc.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("dateCreateInvalidMinute"));
|
||||
return new MinutePrompt();
|
||||
} else {
|
||||
cc.setSessionData("tempMinute", Integer.parseInt(input));
|
||||
return new DateTimePrompt(oldPrompt);
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
cc.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("itemCreateInvalidInput"));
|
||||
return new MinutePrompt();
|
||||
}
|
||||
} else {
|
||||
return new DateTimePrompt(oldPrompt);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class SecondPrompt extends StringPrompt {
|
||||
|
||||
@Override
|
||||
public String getPromptText(ConversationContext cc) {
|
||||
return ChatColor.YELLOW + Lang.get("dateCreateEnterSecond");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Prompt acceptInput(ConversationContext cc, String input) {
|
||||
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) {
|
||||
try {
|
||||
int amt = Integer.parseInt(input);
|
||||
if (amt < 0 || amt > 59) {
|
||||
cc.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("dateCreateInvalidSecond"));
|
||||
return new SecondPrompt();
|
||||
} else {
|
||||
cc.setSessionData("tempSecond", Integer.parseInt(input));
|
||||
return new DateTimePrompt(oldPrompt);
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
cc.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("itemCreateInvalidInput"));
|
||||
return new SecondPrompt();
|
||||
}
|
||||
} else {
|
||||
return new DateTimePrompt(oldPrompt);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class ZonePrompt extends StringPrompt {
|
||||
|
||||
@Override
|
||||
public String getPromptText(ConversationContext cc) {
|
||||
return ChatColor.YELLOW + Lang.get("dateCreateEnterZone");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Prompt acceptInput(ConversationContext cc, String input) {
|
||||
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) {
|
||||
try {
|
||||
int amt = Integer.parseInt(input.replaceAll("UTC", ""));
|
||||
if (amt < -12 || amt > 14) {
|
||||
cc.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("dateCreateInvalidZone"));
|
||||
return new ZonePrompt();
|
||||
} else {
|
||||
cc.setSessionData("tempZone", Integer.parseInt(input));
|
||||
return new DateTimePrompt(oldPrompt);
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
cc.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("itemCreateInvalidInput"));
|
||||
return new ZonePrompt();
|
||||
}
|
||||
} else {
|
||||
return new DateTimePrompt(oldPrompt);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -43,12 +43,12 @@ public class PlannerPrompt extends FixedSetPrompt {
|
||||
if (context.getSessionData(CK.PLN_START_DATE) == null) {
|
||||
text += ChatColor.BLUE + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("plnStart") + " " + ChatColor.GRAY + "(" + Lang.get("noneSet") + ")\n";
|
||||
} else {
|
||||
text += ChatColor.BLUE + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("plnStart") + " (" + Quests.getTime((Long) context.getSessionData(CK.PLN_START_DATE)) + ")\n";
|
||||
text += ChatColor.BLUE + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("plnStart") + " (" + getDate((String) context.getSessionData(CK.PLN_START_DATE)) + ")\n";
|
||||
}
|
||||
if (context.getSessionData(CK.PLN_END_DATE) == null) {
|
||||
text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("plnEnd") + " " + ChatColor.GRAY + "(" + Lang.get("noneSet") + ")\n";
|
||||
} else {
|
||||
text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("plnEnd") + " (" + Quests.getTime((Long) context.getSessionData(CK.PLN_END_DATE)) + ")\n";
|
||||
text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("plnEnd") + " (" + getDate((String) context.getSessionData(CK.PLN_END_DATE)) + ")\n";
|
||||
}
|
||||
if (context.getSessionData(CK.PLN_REPEAT_CYCLE) == null) {
|
||||
text += ChatColor.BLUE + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("plnRepeat") + " " + ChatColor.GRAY + "(" + Lang.get("noneSet") + ")\n";
|
||||
@ -215,4 +215,24 @@ public class PlannerPrompt extends FixedSetPrompt {
|
||||
return new PlannerPrompt(quests, factory);
|
||||
}
|
||||
}
|
||||
|
||||
private String getDate(String formattedDate) {
|
||||
String[] date = formattedDate.split(":");
|
||||
String day = date[0];
|
||||
String month = date[1];
|
||||
String year = date[2];
|
||||
String hour = date[3];
|
||||
String minute = date[4];
|
||||
String second = date[5];
|
||||
String zone = date[6];
|
||||
String output = day + "-" + month + "-" + year + " "
|
||||
+ hour + ":" + minute + ":" + second + " UTC";
|
||||
if (Integer.parseInt(date[6]) < 0) {
|
||||
output += "-";
|
||||
} else {
|
||||
output += "+";
|
||||
}
|
||||
output += zone;
|
||||
return output;
|
||||
}
|
||||
}
|
||||
|
@ -64,9 +64,9 @@ questEditorBlockStart: "Set Block start"
|
||||
questEditorInitialEvent: "Set initial Event"
|
||||
questEditorSetGUI: "Set GUI Item display"
|
||||
questEditorReqs: "Edit Requirements"
|
||||
questEditorPln: "Edit Planner"
|
||||
questEditorStages: "Edit Stages"
|
||||
questEditorRews: "Edit Rewards"
|
||||
questEditorPln: "Edit Planner"
|
||||
questEditorEnterQuestName: "Enter Quest name (<cancel>)"
|
||||
questEditorEditEnterQuestName: "Enter Quest name to edit (<cancel>)"
|
||||
questEditorEnterAskMessage: "Enter ask message (<cancel>)"
|
||||
@ -512,6 +512,14 @@ reqMustAddItem: "You must add at least one item first!"
|
||||
reqNoMessage: "You must set a fail requirements message!"
|
||||
reqNoMcMMO: "mcMMO not installed"
|
||||
reqNoHeroes: "Heroes not installed"
|
||||
plnStart: "Set start date"
|
||||
plnEnd: "Set end date"
|
||||
plnRepeat: "Set repeat cycle"
|
||||
plnCooldown: "Set player cooldown"
|
||||
plnStartPrompt: "Enter amount of time (in seconds), 0 to clear the start date or -1 to cancel"
|
||||
plnEndPrompt: "Enter amount of time (in seconds), 0 to clear the end date or -1 to cancel"
|
||||
plnRepeatPrompt: "Enter amount of time (in seconds), 0 to clear the repeat or -1 to cancel"
|
||||
plnCooldownPrompt: "Enter amount of time (in seconds), 0 to clear the cooldown or -1 to cancel"
|
||||
rewSetMoney: "Set money reward"
|
||||
rewSetQuestPoints: "Set Quest Points reward"
|
||||
rewSetItems: "Set item rewards"
|
||||
@ -552,14 +560,6 @@ rewCustomAlreadyAdded: "That custom reward has already been added!"
|
||||
rewCustomNotFound: "Custom reward module not found."
|
||||
rewCustomCleared: "Custom rewards cleared."
|
||||
rewNoPhat: "PhatLoots not installed"
|
||||
plnStart: "Set start date"
|
||||
plnEnd: "Set end date"
|
||||
plnRepeat: "Set repeat cycle"
|
||||
plnCooldown: "Set player cooldown"
|
||||
plnStartPrompt: "Enter amount of time (in seconds), 0 to clear the start date or -1 to cancel"
|
||||
plnEndPrompt: "Enter amount of time (in seconds), 0 to clear the end date or -1 to cancel"
|
||||
plnRepeatPrompt: "Enter amount of time (in seconds), 0 to clear the repeat or -1 to cancel"
|
||||
plnCooldownPrompt: "Enter amount of time (in seconds), 0 to clear the cooldown or -1 to cancel"
|
||||
itemCreateLoadHand: "Load item in hand"
|
||||
itemCreateSetName: "Set name"
|
||||
itemCreateSetAmount: "Set amount"
|
||||
@ -578,7 +578,7 @@ itemCreateLoaded: "Item loaded."
|
||||
itemCreateNoItem: "No item in hand!"
|
||||
itemCreateNoName: "You must set a name first!"
|
||||
itemCreateInvalidName: "Invalid item name!"
|
||||
itemCreateInvalidAmount: "Amount must be between 1-64!"
|
||||
itemCreateInvalidAmount: "Amount must be between 1 and 64!"
|
||||
itemCreateInvalidDurab: "Invalid item durability!"
|
||||
itemCreateInvalidEnch: "Invalid enchantment name!"
|
||||
itemCreateInvalidLevel: "Level must be greater than 0!"
|
||||
@ -586,6 +586,21 @@ itemCreateInvalidInput: "Invalid input!"
|
||||
itemCreateNotNumber: "Input was not a number!"
|
||||
itemCreateNoNameAmount: "You must set a name and amount first!"
|
||||
itemCreateCriticalError: "A critical error has occurred."
|
||||
dateCreateEnterDay: "Enter a day (max. 31), <cancel>"
|
||||
dateCreateInvalidDay: "Day must be between 1 and 31!"
|
||||
dateCreateEnterMonth: "Enter a month (max. 12), <cancel>"
|
||||
dateCreateInvalidMonth: "Day must be between 1 and 12!"
|
||||
dateCreateEnterYear: "Enter a year (max. 9999), <cancel>"
|
||||
dateCreateInvalidYear: "Year must be between 1000 and 9999!"
|
||||
dateCreateEnterHour: "Enter an hour (max. 23), <cancel>"
|
||||
dateCreateInvalidHour: "Hour must be between 0 and 23!"
|
||||
dateCreateEnterMinute: "Enter a minute (max. 59), <cancel>"
|
||||
dateCreateInvalidMinute: "Minute must be between 0 and 59!"
|
||||
dateCreateEnterSecond: "Enter a second (max. 59), <cancel>"
|
||||
dateCreateInvalidSecond: "Second must be between 0 and 59!"
|
||||
dateCreateEnterZone: "Enter a UTC time zone (max. 14), <cancel>"
|
||||
dateCreateInvalidZone: "Zone must be between -12 and 14!"
|
||||
dateCreateNoYearAmount: "You must set a year first!"
|
||||
questTitle: "-- <quest> --"
|
||||
questObjectivesTitle: "---(<quest>)---"
|
||||
questCompleteTitle: '**QUEST COMPLETE: <quest>**'
|
||||
|
Loading…
Reference in New Issue
Block a user