Year to date format is generally better understood

This commit is contained in:
PikaMug 2021-02-11 02:43:16 -05:00
parent 56887451ad
commit e57a9c3626

View File

@ -111,11 +111,11 @@ public class DateTimePrompt extends QuestsEditorNumericPrompt {
case 0: case 0:
return ChatColor.GOLD + Lang.get("dateCreateLoadTime"); return ChatColor.GOLD + Lang.get("dateCreateLoadTime");
case 1: case 1:
return ChatColor.YELLOW + Lang.get("timeDay"); return ChatColor.YELLOW + Lang.get("timeYear");
case 2: case 2:
return ChatColor.YELLOW + Lang.get("timeMonth"); return ChatColor.YELLOW + Lang.get("timeMonth");
case 3: case 3:
return ChatColor.YELLOW + Lang.get("timeYear"); return ChatColor.YELLOW + Lang.get("timeDay");
case 4: case 4:
return ChatColor.YELLOW + Lang.get("timeHour"); return ChatColor.YELLOW + Lang.get("timeHour");
case 5: case 5:
@ -139,8 +139,8 @@ public class DateTimePrompt extends QuestsEditorNumericPrompt {
case 0: case 0:
return ""; return "";
case 1: case 1:
if (context.getSessionData("tempDay") != null) { if (context.getSessionData("tempYear") != null) {
return ChatColor.GRAY + "(" + ChatColor.AQUA + context.getSessionData("tempDay") return ChatColor.GRAY + "(" + ChatColor.AQUA + context.getSessionData("tempYear")
+ ChatColor.GRAY + ")"; + ChatColor.GRAY + ")";
} }
case 2: case 2:
@ -149,8 +149,8 @@ public class DateTimePrompt extends QuestsEditorNumericPrompt {
+ ((Integer) context.getSessionData("tempMonth") + 1) + ChatColor.GRAY + ")"; + ((Integer) context.getSessionData("tempMonth") + 1) + ChatColor.GRAY + ")";
} }
case 3: case 3:
if (context.getSessionData("tempYear") != null) { if (context.getSessionData("tempDay") != null) {
return ChatColor.GRAY + "(" + ChatColor.AQUA + context.getSessionData("tempYear") return ChatColor.GRAY + "(" + ChatColor.AQUA + context.getSessionData("tempDay")
+ ChatColor.GRAY + ")"; + ChatColor.GRAY + ")";
} }
case 4: case 4:
@ -188,8 +188,8 @@ public class DateTimePrompt extends QuestsEditorNumericPrompt {
context.getPlugin().getServer().getPluginManager().callEvent(event); context.getPlugin().getServer().getPluginManager().callEvent(event);
String text = ChatColor.AQUA + getTitle(context) + "\n"; String text = ChatColor.AQUA + getTitle(context) + "\n";
if (context.getSessionData("tempDay") != null && context.getSessionData("tempMonth") != null if (context.getSessionData("tempYear") != null && context.getSessionData("tempMonth") != null
&& context.getSessionData("tempYear") != null && context.getSessionData("tempHour") != null && context.getSessionData("tempDay") != null && context.getSessionData("tempHour") != null
&& context.getSessionData("tempMinute") != null && context.getSessionData("tempSecond") != null && context.getSessionData("tempMinute") != null && context.getSessionData("tempSecond") != null
&& context.getSessionData("tempZone") != null) { && context.getSessionData("tempZone") != null) {
text += getDataText(context); text += getDataText(context);
@ -206,20 +206,20 @@ public class DateTimePrompt extends QuestsEditorNumericPrompt {
switch(input.intValue()) { switch(input.intValue()) {
case 0: case 0:
final Calendar cal = Calendar.getInstance(); final Calendar cal = Calendar.getInstance();
context.setSessionData("tempDay", cal.get(Calendar.DAY_OF_MONTH));
context.setSessionData("tempMonth", cal.get(Calendar.MONTH));
context.setSessionData("tempYear", cal.get(Calendar.YEAR)); context.setSessionData("tempYear", cal.get(Calendar.YEAR));
context.setSessionData("tempMonth", cal.get(Calendar.MONTH));
context.setSessionData("tempDay", cal.get(Calendar.DAY_OF_MONTH));
context.setSessionData("tempHour", cal.get(Calendar.HOUR_OF_DAY)); context.setSessionData("tempHour", cal.get(Calendar.HOUR_OF_DAY));
context.setSessionData("tempMinute", cal.get(Calendar.MINUTE)); context.setSessionData("tempMinute", cal.get(Calendar.MINUTE));
context.setSessionData("tempSecond", cal.get(Calendar.SECOND)); context.setSessionData("tempSecond", cal.get(Calendar.SECOND));
context.setSessionData("tempZone", cal.getTimeZone().getID()); context.setSessionData("tempZone", cal.getTimeZone().getID());
return new DateTimePrompt(context, oldPrompt, source); return new DateTimePrompt(context, oldPrompt, source);
case 1: case 1:
return new DayPrompt(context); return new YearPrompt(context);
case 2: case 2:
return new MonthPrompt(context); return new MonthPrompt(context);
case 3: case 3:
return new YearPrompt(context); return new DayPrompt(context);
case 4: case 4:
return new HourPrompt(context); return new HourPrompt(context);
case 5: case 5:
@ -229,22 +229,22 @@ public class DateTimePrompt extends QuestsEditorNumericPrompt {
case 7: case 7:
return new OffsetPrompt(context); return new OffsetPrompt(context);
case 8: case 8:
context.setSessionData("tempDay", null);
context.setSessionData("tempMonth", null);
context.setSessionData("tempYear", null); context.setSessionData("tempYear", null);
context.setSessionData("tempMonth", null);
context.setSessionData("tempDay", null);
context.setSessionData("tempHour", null); context.setSessionData("tempHour", null);
context.setSessionData("tempMinute", null); context.setSessionData("tempMinute", null);
context.setSessionData("tempSecond", null); context.setSessionData("tempSecond", null);
context.setSessionData("tempZone", null); context.setSessionData("tempZone", null);
return oldPrompt; return oldPrompt;
case 9: case 9:
if (context.getSessionData("tempDay") != null && context.getSessionData("tempMonth") != null if (context.getSessionData("tempYear") != null && context.getSessionData("tempMonth") != null
&& context.getSessionData("tempYear") != null && context.getSessionData("tempHour") != null && context.getSessionData("tempDay") != null && context.getSessionData("tempHour") != null
&& context.getSessionData("tempMinute") != null && context.getSessionData("tempSecond") != null && context.getSessionData("tempMinute") != null && context.getSessionData("tempSecond") != null
&& context.getSessionData("tempZone") != null) { && context.getSessionData("tempZone") != null) {
final int day = (Integer) context.getSessionData("tempDay");
final int month = (Integer) context.getSessionData("tempMonth");
final int year = (Integer) context.getSessionData("tempYear"); final int year = (Integer) context.getSessionData("tempYear");
final int month = (Integer) context.getSessionData("tempMonth");
final int day = (Integer) context.getSessionData("tempDay");
final int hour = (Integer) context.getSessionData("tempHour"); final int hour = (Integer) context.getSessionData("tempHour");
final int minute = (Integer) context.getSessionData("tempMinute"); final int minute = (Integer) context.getSessionData("tempMinute");
final int second = (Integer) context.getSessionData("tempSecond"); final int second = (Integer) context.getSessionData("tempSecond");
@ -258,16 +258,16 @@ public class DateTimePrompt extends QuestsEditorNumericPrompt {
context.setSessionData(CK.PLN_END_DATE, date); context.setSessionData(CK.PLN_END_DATE, date);
} }
} }
context.setSessionData("tempDay", null);
context.setSessionData("tempMonth", null);
context.setSessionData("tempYear", null); context.setSessionData("tempYear", null);
context.setSessionData("tempMonth", null);
context.setSessionData("tempDay", null);
context.setSessionData("tempHour", null); context.setSessionData("tempHour", null);
context.setSessionData("tempMinute", null); context.setSessionData("tempMinute", null);
context.setSessionData("tempSecond", null); context.setSessionData("tempSecond", null);
context.setSessionData("tempZone", null); context.setSessionData("tempZone", null);
return oldPrompt; return oldPrompt;
} else if (context.getSessionData("tempDay") != null || context.getSessionData("tempMonth") != null } else if (context.getSessionData("tempYear") != null || context.getSessionData("tempMonth") != null
|| context.getSessionData("tempYear") != null || context.getSessionData("tempHour") != null || context.getSessionData("tempDay") != null || context.getSessionData("tempHour") != null
|| context.getSessionData("tempMinute") != null || context.getSessionData("tempSecond") != null || context.getSessionData("tempMinute") != null || context.getSessionData("tempSecond") != null
|| context.getSessionData("tempZone") != null) { || context.getSessionData("tempZone") != null) {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("listsNotSameSize")); context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("listsNotSameSize"));
@ -280,9 +280,9 @@ public class DateTimePrompt extends QuestsEditorNumericPrompt {
} }
} }
public class DayPrompt extends QuestsEditorStringPrompt { public class YearPrompt extends QuestsEditorStringPrompt {
public DayPrompt(final ConversationContext context) { public YearPrompt(final ConversationContext context) {
super(context); super(context);
} }
@ -293,7 +293,7 @@ public class DateTimePrompt extends QuestsEditorNumericPrompt {
@Override @Override
public String getQueryText(final ConversationContext context) { public String getQueryText(final ConversationContext context) {
return Lang.get("dateCreateEnterDay"); return Lang.get("dateCreateEnterYear");
} }
@Override @Override
@ -309,17 +309,17 @@ public class DateTimePrompt extends QuestsEditorNumericPrompt {
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) { if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) {
try { try {
final int amt = Integer.parseInt(input); final int amt = Integer.parseInt(input);
if (amt < 1 || amt > 31) { if (amt < 1000 || amt > 9999) {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("invalidRange") context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("invalidRange")
.replace("<least>", "1").replace("<greatest>", "31")); .replace("<least>", "1000").replace("<greatest>", "9999"));
return new DayPrompt(context); return new YearPrompt(context);
} else { } else {
context.setSessionData("tempDay", Integer.parseInt(input)); context.setSessionData("tempYear", Integer.parseInt(input));
return new DateTimePrompt(context, oldPrompt, source); return new DateTimePrompt(context, oldPrompt, source);
} }
} catch (final NumberFormatException e) { } catch (final NumberFormatException e) {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("itemCreateInvalidInput")); context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("itemCreateInvalidInput"));
return new DayPrompt(context); return new YearPrompt(context);
} }
} else { } else {
return new DateTimePrompt(context, oldPrompt, source); return new DateTimePrompt(context, oldPrompt, source);
@ -374,9 +374,9 @@ public class DateTimePrompt extends QuestsEditorNumericPrompt {
} }
} }
public class YearPrompt extends QuestsEditorStringPrompt { public class DayPrompt extends QuestsEditorStringPrompt {
public YearPrompt(final ConversationContext context) { public DayPrompt(final ConversationContext context) {
super(context); super(context);
} }
@ -387,7 +387,7 @@ public class DateTimePrompt extends QuestsEditorNumericPrompt {
@Override @Override
public String getQueryText(final ConversationContext context) { public String getQueryText(final ConversationContext context) {
return Lang.get("dateCreateEnterYear"); return Lang.get("dateCreateEnterDay");
} }
@Override @Override
@ -403,17 +403,17 @@ public class DateTimePrompt extends QuestsEditorNumericPrompt {
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) { if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) {
try { try {
final int amt = Integer.parseInt(input); final int amt = Integer.parseInt(input);
if (amt < 1000 || amt > 9999) { if (amt < 1 || amt > 31) {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("invalidRange") context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("invalidRange")
.replace("<least>", "1000").replace("<greatest>", "9999")); .replace("<least>", "1").replace("<greatest>", "31"));
return new YearPrompt(context); return new DayPrompt(context);
} else { } else {
context.setSessionData("tempYear", Integer.parseInt(input)); context.setSessionData("tempDay", Integer.parseInt(input));
return new DateTimePrompt(context, oldPrompt, source); return new DateTimePrompt(context, oldPrompt, source);
} }
} catch (final NumberFormatException e) { } catch (final NumberFormatException e) {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("itemCreateInvalidInput")); context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("itemCreateInvalidInput"));
return new YearPrompt(context); return new DayPrompt(context);
} }
} else { } else {
return new DateTimePrompt(context, oldPrompt, source); return new DateTimePrompt(context, oldPrompt, source);