Supply external conversation hooks, part 23

This commit is contained in:
PikaMug 2020-04-19 04:20:21 -04:00
parent f05d1256f9
commit f42d092627
6 changed files with 892 additions and 541 deletions

View File

@ -173,7 +173,6 @@ public class ItemStackPrompt extends FixedSetPrompt {
cc.setSessionData("tempMeta", map);
}
}
player.sendMessage(ChatColor.GREEN + Lang.get("itemCreateLoaded"));
return new ItemStackPrompt(oldPrompt);
}
} else if (input.equalsIgnoreCase("1")) {

View File

@ -44,7 +44,7 @@ public class OverridePrompt extends QuestsEditorStringPrompt {
@Override
public String getQueryText(ConversationContext context) {
return null;
return promptText;
}
@Override
@ -52,7 +52,7 @@ public class OverridePrompt extends QuestsEditorStringPrompt {
QuestsEditorPostOpenStringPromptEvent event = new QuestsEditorPostOpenStringPromptEvent(context, this);
context.getPlugin().getServer().getPluginManager().callEvent(event);
String text = ChatColor.YELLOW + promptText + "\n";;
String text = ChatColor.YELLOW + getQueryText(context) + "\n";
return text;
}

View File

@ -117,8 +117,7 @@ public class QuestMainPrompt extends QuestsEditorNumericPrompt {
return ChatColor.YELLOW + Lang.get("questEditorFinishMessage");
}
case 4:
if (context.getSessionData(CK.Q_START_NPC) == null && plugin.getDependencies().getCitizens()
!= null) {
if (context.getSessionData(CK.Q_START_NPC) == null && plugin.getDependencies().getCitizens() != null) {
return ChatColor.YELLOW + Lang.get("questEditorNPCStart");
} else if (plugin.getDependencies().getCitizens() != null) {
return ChatColor.YELLOW + Lang.get("questEditorNPCStart");

View File

@ -38,7 +38,7 @@ public class DateTimePrompt extends QuestsEditorNumericPrompt {
source = origin;
}
private final int size = 9;
private final int size = 10;
public int getSize() {
return size;
@ -53,36 +53,14 @@ public class DateTimePrompt extends QuestsEditorNumericPrompt {
Calendar cal = Calendar.getInstance();
SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
SimpleDateFormat timeFormat = new SimpleDateFormat("HH:mm:ss");
if (context.getSessionData("tempDay") == null) {
context.setSessionData("tempDay", cal.get(Calendar.DAY_OF_MONTH));
}
if (context.getSessionData("tempMonth") == null) {
context.setSessionData("tempMonth", cal.get(Calendar.MONTH));
}
if (context.getSessionData("tempYear") == null) {
context.setSessionData("tempYear", cal.get(Calendar.YEAR));
}
if (context.getSessionData("tempHour") == null) {
context.setSessionData("tempHour", cal.get(Calendar.HOUR_OF_DAY));
}
if (context.getSessionData("tempMinute") == null) {
context.setSessionData("tempMinute", cal.get(Calendar.MINUTE));
}
if (context.getSessionData("tempSecond") == null) {
context.setSessionData("tempSecond", cal.get(Calendar.SECOND));
}
cal.set((Integer) context.getSessionData("tempYear"), (Integer) context.getSessionData("tempMonth"),
(Integer) context.getSessionData("tempDay"), (Integer) context.getSessionData("tempHour"),
(Integer) context.getSessionData("tempMinute"), (Integer) context.getSessionData("tempSecond"));
dateData += ChatColor.DARK_AQUA + dateFormat.format(cal.getTime()) + " ";
dateData += ChatColor.AQUA + timeFormat.format(cal.getTime()) + " ";
if (context.getSessionData("tempZone") == null) {
context.setSessionData("tempZone", cal.getTimeZone().getID());
}
TimeZone tz = TimeZone.getTimeZone((String) context.getSessionData("tempZone"));
cal.setTimeZone(tz);
cal.setTimeZone(TimeZone.getTimeZone((String) context.getSessionData("tempZone")));
String[] iso = Lang.getISO().split("-");
Locale loc = new Locale(iso[0], iso[1]);
Double hour = (double) (cal.getTimeZone().getRawOffset() / 60 / 60 / 1000);
@ -96,25 +74,29 @@ public class DateTimePrompt extends QuestsEditorNumericPrompt {
public ChatColor getNumberColor(ConversationContext context, int number) {
switch (number) {
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
case 7:
return ChatColor.BLUE;
case 8:
return ChatColor.RED;
case 9:
return ChatColor.GREEN;
default:
return null;
case 0:
return ChatColor.YELLOW;
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
case 7:
return ChatColor.BLUE;
case 8:
return ChatColor.RED;
case 9:
return ChatColor.GREEN;
default:
return null;
}
}
public String getSelectionText(ConversationContext context, int number) {
switch(number) {
case 0:
return ChatColor.GOLD + Lang.get("dateCreateLoadTime");
case 1:
return ChatColor.YELLOW + Lang.get("timeDay");
case 2:
@ -140,6 +122,8 @@ public class DateTimePrompt extends QuestsEditorNumericPrompt {
public String getAdditionalText(ConversationContext context, int number) {
switch(number) {
case 0:
return "";
case 1:
if (context.getSessionData("tempDay") != null) {
return ChatColor.GRAY + "(" + ChatColor.AQUA + context.getSessionData("tempDay")
@ -189,8 +173,14 @@ public class DateTimePrompt extends QuestsEditorNumericPrompt {
QuestsEditorPostOpenNumericPromptEvent event = new QuestsEditorPostOpenNumericPromptEvent(context, this);
context.getPlugin().getServer().getPluginManager().callEvent(event);
String text = ChatColor.AQUA + getTitle(context) + "\n" + getDataText(context) + "\n";
for (int i = 1; i <= size; i++) {
String text = ChatColor.AQUA + getTitle(context) + "\n";
if (context.getSessionData("tempDay") != null && context.getSessionData("tempMonth") != null
&& context.getSessionData("tempYear") != null && context.getSessionData("tempHour") != null
&& context.getSessionData("tempMinute") != null && context.getSessionData("tempSecond") != null
&& context.getSessionData("tempZone") != null) {
text += getDataText(context) + "\n";
}
for (int i = 0; i <= size - 1; i++) {
text += getNumberColor(context, i) + "" + ChatColor.BOLD + i + ChatColor.RESET + " - "
+ getSelectionText(context, i) + " " + getAdditionalText(context, i) + "\n";
}
@ -200,6 +190,16 @@ public class DateTimePrompt extends QuestsEditorNumericPrompt {
@Override
protected Prompt acceptValidatedInput(ConversationContext context, Number input) {
switch(input.intValue()) {
case 0:
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("tempHour", cal.get(Calendar.HOUR_OF_DAY));
context.setSessionData("tempMinute", cal.get(Calendar.MINUTE));
context.setSessionData("tempSecond", cal.get(Calendar.SECOND));
context.setSessionData("tempZone", cal.getTimeZone().getID());
return new DateTimePrompt(context, oldPrompt, source);
case 1:
return new DayPrompt();
case 2:
@ -224,23 +224,43 @@ public class DateTimePrompt extends QuestsEditorNumericPrompt {
context.setSessionData("tempZone", null);
return oldPrompt;
case 9:
int day = (Integer) context.getSessionData("tempDay");
int month = (Integer) context.getSessionData("tempMonth");
int year = (Integer) context.getSessionData("tempYear");
int hour = (Integer) context.getSessionData("tempHour");
int minute = (Integer) context.getSessionData("tempMinute");
int second = (Integer) context.getSessionData("tempSecond");
String zone = (String) context.getSessionData("tempZone");
String date = day + ":" + month + ":" + year + ":"
+ hour + ":" + minute + ":" + second + ":" + zone;
if (source != null) {
if (source.equals("start")) {
context.setSessionData(CK.PLN_START_DATE, date);
} else if (source.equals("end")) {
context.setSessionData(CK.PLN_END_DATE, date);
if (context.getSessionData("tempDay") != null && context.getSessionData("tempMonth") != null
&& context.getSessionData("tempYear") != null && context.getSessionData("tempHour") != null
&& context.getSessionData("tempMinute") != null && context.getSessionData("tempSecond") != null
&& context.getSessionData("tempZone") != null) {
int day = (Integer) context.getSessionData("tempDay");
int month = (Integer) context.getSessionData("tempMonth");
int year = (Integer) context.getSessionData("tempYear");
int hour = (Integer) context.getSessionData("tempHour");
int minute = (Integer) context.getSessionData("tempMinute");
int second = (Integer) context.getSessionData("tempSecond");
String zone = (String) context.getSessionData("tempZone");
String date = day + ":" + month + ":" + year + ":"
+ hour + ":" + minute + ":" + second + ":" + zone;
if (source != null) {
if (source.equals("start")) {
context.setSessionData(CK.PLN_START_DATE, date);
} else if (source.equals("end")) {
context.setSessionData(CK.PLN_END_DATE, date);
}
}
context.setSessionData("tempDay", null);
context.setSessionData("tempMonth", null);
context.setSessionData("tempYear", null);
context.setSessionData("tempHour", null);
context.setSessionData("tempMinute", null);
context.setSessionData("tempSecond", null);
context.setSessionData("tempZone", null);
return oldPrompt;
} else if (context.getSessionData("tempDay") != null || context.getSessionData("tempMonth") != null
|| context.getSessionData("tempYear") != null || context.getSessionData("tempHour") != null
|| context.getSessionData("tempMinute") != null || context.getSessionData("tempSecond") != null
|| context.getSessionData("tempZone") != null) {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("listsNotSameSize"));
return new DateTimePrompt(context, oldPrompt, source);
} else {
return oldPrompt;
}
return oldPrompt;
default:
return new DateTimePrompt(context, oldPrompt, source);
}

View File

@ -243,7 +243,6 @@ stageEditorNoDenizen: "Denizen is not installed!"
stageEditorPositiveAmount: "You must enter a positive number!"
stageEditorNotListofNumbers: "is not a list of numbers!"
stageEditorNoDelaySet: "You must set a delay first!"
stageEditorNoBlockNames: "You must set block names first!"
stageEditorNoEnchantments: "You must set enchantments first!"
stageEditorNoItems: "You must add items first!"
stageEditorNoDeliveryMessage: "You must set at least one delivery message!"
@ -508,7 +507,6 @@ itemCreateEnterEnch: "Enter an enchantment name, <clear>, <cancel>"
itemCreateEnterLevel: "Enter a level (number) for <enchantment>"
itemCreateEnterDisplay: "Enter item display name, <clear>, <cancel>"
itemCreateEnterLore: "Enter item lore, <semicolon>, <clear>, <cancel>"
itemCreateLoaded: "Item loaded."
itemCreateNoItem: "No item in hand!"
itemCreateNoName: "You must set a name first!"
itemCreateInvalidName: "Invalid item name!"
@ -517,6 +515,7 @@ itemCreateInvalidEnch: "Invalid enchantment name!"
itemCreateInvalidInput: "Invalid input!"
itemCreateNoNameAmount: "You must set a name and amount first!"
itemCreateCriticalError: "A critical error has occurred."
dateCreateLoadTime: "Load current time"
dateCreateEnterDay: "Enter a day (max. 31), <cancel>"
dateCreateEnterMonth: "Enter a month (max. 12), <cancel>"
dateCreateEnterYear: "Enter a year (max. 9999), <cancel>"