use of mc.dragons.core.gameobject.quest.Quest in project DragonsOnline by UniverseCraft.
the class QuestDialogueCommands method questChoice.
/* 0=<questName>, 1=<response text> */
private void questChoice(CommandSender sender, String[] args) {
if (args.length < 2) {
return;
}
User user = user(sender);
String questName = args[0];
String response = StringUtil.concatArgs(args, 1);
user.debug("Selected quest choice " + response + " for quest " + questName);
// get the current quest action they're on
Quest quest = questLoader.getQuestByName(questName);
// invalid quest name
if (quest == null)
return;
QuestStep progress = user.getQuestProgress().get(quest);
// user has not begun quest
if (progress == null)
return;
int actionIndex = user.getQuestActionIndex(quest) - 1;
QuestAction action = progress.getActions().get(actionIndex);
// not a stage where the user needs to input anything
if (action.getActionType() != QuestAction.QuestActionType.CHOICES)
return;
// possible responses are mapped to a new quest stage
Integer stage = action.getChoices().get(response);
if (stage == null) {
return;
}
sender.sendMessage(ChatColor.GRAY + "[1/1] " + ChatColor.DARK_GREEN + "You: " + ChatColor.GREEN + response);
user.setQuestPaused(quest, false);
user.updateQuestProgress(quest, quest.getSteps().get(stage), false);
}
use of mc.dragons.core.gameobject.quest.Quest in project DragonsOnline by UniverseCraft.
the class StuckQuestCommand method selectQuest.
private void selectQuest(CommandSender sender) {
User user = user(sender);
boolean any = false;
for (Entry<Quest, QuestStep> entry : user.getQuestProgress().entrySet()) {
if (entry.getValue().getStepName().equalsIgnoreCase("Complete"))
continue;
any = true;
}
if (!any) {
sender.sendMessage(ChatColor.RED + "You don't have any active quests!");
return;
}
sender.sendMessage(" ");
sender.sendMessage(ChatColor.YELLOW + "" + ChatColor.BOLD + "Please confirm the quest you are having issues with:");
for (Entry<Quest, QuestStep> entry : user.getQuestProgress().entrySet()) {
if (entry.getValue().getStepName().equalsIgnoreCase("Complete"))
continue;
sender.spigot().sendMessage(StringUtil.clickableHoverableText(ChatColor.GRAY + " • " + ChatColor.GREEN + entry.getKey().getQuestName(), "/stuckquest " + entry.getKey().getName(), ChatColor.GRAY + "Quest: " + ChatColor.RESET + entry.getKey().getQuestName()));
}
sender.sendMessage(" ");
sender.sendMessage(ChatColor.GRAY + "Click on one of the quests above to continue with the report.");
sender.sendMessage(" ");
}
use of mc.dragons.core.gameobject.quest.Quest in project DragonsOnline by UniverseCraft.
the class QuestCommand method displayQuest.
private void displayQuest(CommandSender sender, String[] args) {
Quest quest = lookupQuest(sender, args[0]);
if (quest == null)
return;
sender.sendMessage(ChatColor.GREEN + "=== Quest: " + quest.getName() + " ===");
sender.sendMessage(ChatColor.GRAY + "Database identifier: " + ChatColor.GREEN + quest.getIdentifier().toString());
if (quest.isLocked()) {
sender.sendMessage(ChatColor.RED + "Currently locked to players");
}
sender.sendMessage(ChatColor.GRAY + "Full name: " + ChatColor.GREEN + quest.getQuestName());
sender.sendMessage(ChatColor.GRAY + "Level min: " + ChatColor.GREEN + quest.getLevelMin());
sender.sendMessage(ChatColor.GRAY + "# Stages: " + ChatColor.GREEN + quest.getSteps().size());
sender.spigot().sendMessage(StringUtil.clickableHoverableText(ChatColor.GRAY + "[Test Quest] ", "/testquest " + quest.getName(), true, "Click to test quest"), ObjectMetadataCommand.getClickableMetadataLink(GameObjectType.QUEST, quest.getUUID()));
if (!quest.isValid()) {
sender.sendMessage(ChatColor.RED + "Warning: Invalid or incomplete quest! To be valid, the final stage must be named \"Complete\", have trigger type INSTANT, and have no actions.");
}
}
use of mc.dragons.core.gameobject.quest.Quest in project DragonsOnline by UniverseCraft.
the class QuestCommand method insertAction.
private void insertAction(CommandSender sender, String[] args) {
Quest quest = lookupQuest(sender, args[0]);
Integer stepNo = parseInt(sender, args[2]);
Integer actionNo = parseInt(sender, args[5]);
if (quest == null || stepNo == null || actionNo == null)
return;
QuestStep step = quest.getSteps().get(stepNo);
QuestAction action = makeAction(quest, sender, Arrays.copyOfRange(args, 6, args.length));
step.insertAction(action, actionNo);
Document base = Document.parse(quest.getData().toJson());
sender.sendMessage(ChatColor.GREEN + "Inserted new action to quest stage successfully.");
AUDIT_LOG.saveEntry(quest, user(sender), base, "Inserted action before " + args[5] + " to stage " + args[2]);
}
use of mc.dragons.core.gameobject.quest.Quest in project DragonsOnline by UniverseCraft.
the class QuestCommand method updateLevelMin.
private void updateLevelMin(CommandSender sender, String[] args) {
Quest quest = lookupQuest(sender, args[0]);
if (quest == null)
return;
Document base = Document.parse(quest.getData().toJson());
quest.setLevelMin(Integer.valueOf(args[2]));
sender.sendMessage(ChatColor.GREEN + "Updated quest level min successfully.");
AUDIT_LOG.saveEntry(quest, user(sender), base, "Set level min to " + args[2]);
}
Aggregations