mirror of
https://github.com/PikaMug/Quests.git
synced 2024-11-12 13:43:57 +01:00
NEW date/time Planner section, part 6, #93
This commit is contained in:
parent
b178734233
commit
ff900f5f87
@ -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;
|
||||
|
@ -49,7 +49,7 @@ public class Quest {
|
||||
public String region = null;
|
||||
public ItemStack guiDisplay = null;
|
||||
public int parties = 0;
|
||||
LinkedList<Stage> orderedStages = new LinkedList<Stage>();
|
||||
public LinkedList<Stage> orderedStages = new LinkedList<Stage>();
|
||||
NPC npcStart;
|
||||
Location blockStart;
|
||||
Quests plugin;
|
||||
|
@ -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("<quest>", ChatColor.AQUA + q.name + ChatColor.YELLOW);
|
||||
early = early.replaceAll("<time>", ChatColor.DARK_PURPLE
|
||||
+ Quests.getTime(nextStart - System.currentTimeMillis()) + ChatColor.YELLOW);
|
||||
player.sendMessage(ChatColor.YELLOW + early);
|
||||
return;
|
||||
}
|
||||
//TODO - can this ever happen?
|
||||
if (System.currentTimeMillis() > nextEnd) {
|
||||
if (System.currentTimeMillis() > end) {
|
||||
String late = Lang.get("plnTooLate");
|
||||
late = late.replaceAll("<quest>", ChatColor.AQUA + q.name + ChatColor.RED);
|
||||
late = late.replaceAll("<time>", ChatColor.DARK_PURPLE
|
||||
+ Quests.getTime(System.currentTimeMillis() - end) + ChatColor.RED);
|
||||
player.sendMessage(ChatColor.RED + late);
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (q.startPlanner != null) {
|
||||
if (System.currentTimeMillis() < start) {
|
||||
String early = Lang.get("plnTooEarly");
|
||||
early = early.replaceAll("<quest>", ChatColor.AQUA + q.name + ChatColor.YELLOW);
|
||||
early = early.replaceAll("<time>", ChatColor.DARK_PURPLE
|
||||
+ Quests.getTime(start - System.currentTimeMillis()) + ChatColor.YELLOW);
|
||||
player.sendMessage(ChatColor.YELLOW + early);
|
||||
return;
|
||||
}
|
||||
}
|
||||
//TODO - should this even be reported?
|
||||
if (q.endPlanner != null) {
|
||||
if (System.currentTimeMillis() > end) {
|
||||
String late = Lang.get("plnTooLate");
|
||||
late = late.replaceAll("<quest>", ChatColor.AQUA + q.name + ChatColor.RED);
|
||||
late = late.replaceAll("<time>", ChatColor.DARK_PURPLE
|
||||
+ Quests.getTime(System.currentTimeMillis() - end) + ChatColor.RED);
|
||||
player.sendMessage(ChatColor.RED + late);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (q.testRequirements(player) == true || override) {
|
||||
addEmptiesFor(q, 0);
|
||||
currentQuests.put(q, 0);
|
||||
|
@ -51,14 +51,14 @@ public class PlannerPrompt extends FixedSetPrompt {
|
||||
+ ChatColor.GRAY + "(" + Lang.get("noneSet") + ")\n";
|
||||
} else {
|
||||
text += ChatColor.BLUE + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("plnStart") + "\n";
|
||||
text += " - " + getDate((String) context.getSessionData(CK.PLN_START_DATE)) + "\n";
|
||||
text += " - " + getPrettyDate((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") + "\n";
|
||||
text += " - " + getDate((String) context.getSessionData(CK.PLN_END_DATE)) + "\n";
|
||||
text += " - " + getPrettyDate((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") + " "
|
||||
@ -164,7 +164,7 @@ public class PlannerPrompt extends FixedSetPrompt {
|
||||
}
|
||||
}
|
||||
|
||||
private String getDate(String formattedDate) {
|
||||
private String getPrettyDate(String formattedDate) {
|
||||
Calendar cal = Calendar.getInstance();
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
|
||||
SimpleDateFormat timeFormat = new SimpleDateFormat("hh:mm:ss");
|
||||
|
@ -510,6 +510,8 @@ plnStartPrompt: "Enter amount of time (in seconds), 0 to clear the start date or
|
||||
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"
|
||||
plnTooEarly: "<quest> will be active in <time>."
|
||||
plnTooLate: "<quest> was last active <time> ago."
|
||||
rewSetMoney: "Set money reward"
|
||||
rewSetQuestPoints: "Set Quest Points reward"
|
||||
rewSetItems: "Set item rewards"
|
||||
|
Loading…
Reference in New Issue
Block a user