From ff900f5f87b0b081685813ba14fce4beb619ef6a Mon Sep 17 00:00:00 2001 From: HappyPikachu Date: Sun, 1 Apr 2018 00:24:17 -0400 Subject: [PATCH] NEW date/time Planner section, part 6, #93 --- .../me/blackvein/quests/ObjectiveTimer.java | 2 +- src/main/java/me/blackvein/quests/Quest.java | 2 +- .../java/me/blackvein/quests/Quester.java | 68 +++++++++++++++++++ .../quests/prompts/PlannerPrompt.java | 6 +- src/main/resources/strings.yml | 2 + 5 files changed, 75 insertions(+), 5 deletions(-) diff --git a/src/main/java/me/blackvein/quests/ObjectiveTimer.java b/src/main/java/me/blackvein/quests/ObjectiveTimer.java index 200f54568..168b0906f 100644 --- a/src/main/java/me/blackvein/quests/ObjectiveTimer.java +++ b/src/main/java/me/blackvein/quests/ObjectiveTimer.java @@ -24,7 +24,7 @@ public class ObjectiveTimer extends BukkitRunnable { private int time; private boolean last; - ObjectiveTimer(Quests plugin, Quester quester, Quest quest, int time, boolean last) { + public ObjectiveTimer(Quests plugin, Quester quester, Quest quest, int time, boolean last) { this.quester = quester; this.quest = quest; this.plugin = plugin; diff --git a/src/main/java/me/blackvein/quests/Quest.java b/src/main/java/me/blackvein/quests/Quest.java index f03d43413..54ede5da7 100644 --- a/src/main/java/me/blackvein/quests/Quest.java +++ b/src/main/java/me/blackvein/quests/Quest.java @@ -49,7 +49,7 @@ public class Quest { public String region = null; public ItemStack guiDisplay = null; public int parties = 0; - LinkedList orderedStages = new LinkedList(); + public LinkedList orderedStages = new LinkedList(); NPC npcStart; Location blockStart; Quests plugin; diff --git a/src/main/java/me/blackvein/quests/Quester.java b/src/main/java/me/blackvein/quests/Quester.java index 2c4ac14e5..aae7885f4 100644 --- a/src/main/java/me/blackvein/quests/Quester.java +++ b/src/main/java/me/blackvein/quests/Quester.java @@ -15,6 +15,7 @@ package me.blackvein.quests; import java.io.File; import java.io.IOException; import java.util.ArrayList; +import java.util.Calendar; import java.util.Collection; import java.util.HashMap; import java.util.LinkedList; @@ -311,6 +312,73 @@ public class Quester { public void takeQuest(Quest q, boolean override) { Player player = getPlayer(); + long start = -1; + long end = -1; + if (q.startPlanner != null) { + Calendar cal = Calendar.getInstance(); + String[] s = q.startPlanner.split(":"); + cal.set(Integer.valueOf(s[2]), Integer.valueOf(s[1]), Integer.valueOf(s[0]), + Integer.valueOf(s[3]), Integer.valueOf(s[4]), Integer.valueOf(s[5])); + start = cal.getTimeInMillis(); + } + if (q.endPlanner != null) { + Calendar cal = Calendar.getInstance(); + String[] s = q.endPlanner.split(":"); + cal.set(Integer.valueOf(s[2]), Integer.valueOf(s[1]), Integer.valueOf(s[0]), + Integer.valueOf(s[3]), Integer.valueOf(s[4]), Integer.valueOf(s[5])); + end = cal.getTimeInMillis(); + } + if (start > -1 && end > -1) { + if (q.repeatPlanner > -1) { + long questLength = end - start; + long nextStart = start; + while (System.currentTimeMillis() >= nextStart) { + nextStart += questLength + q.repeatPlanner; + } + long nextEnd = nextStart + questLength; + if (System.currentTimeMillis() < nextStart) { + String early = Lang.get("plnTooEarly"); + early = early.replaceAll("", ChatColor.AQUA + q.name + ChatColor.YELLOW); + early = early.replaceAll("