mirror of
https://github.com/PikaMug/Quests.git
synced 2024-11-24 19:46:34 +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 int time;
|
||||||
private boolean last;
|
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.quester = quester;
|
||||||
this.quest = quest;
|
this.quest = quest;
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
|
@ -49,7 +49,7 @@ public class Quest {
|
|||||||
public String region = null;
|
public String region = null;
|
||||||
public ItemStack guiDisplay = null;
|
public ItemStack guiDisplay = null;
|
||||||
public int parties = 0;
|
public int parties = 0;
|
||||||
LinkedList<Stage> orderedStages = new LinkedList<Stage>();
|
public LinkedList<Stage> orderedStages = new LinkedList<Stage>();
|
||||||
NPC npcStart;
|
NPC npcStart;
|
||||||
Location blockStart;
|
Location blockStart;
|
||||||
Quests plugin;
|
Quests plugin;
|
||||||
|
@ -15,6 +15,7 @@ package me.blackvein.quests;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Calendar;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
@ -311,6 +312,73 @@ public class Quester {
|
|||||||
|
|
||||||
public void takeQuest(Quest q, boolean override) {
|
public void takeQuest(Quest q, boolean override) {
|
||||||
Player player = getPlayer();
|
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) {
|
if (q.testRequirements(player) == true || override) {
|
||||||
addEmptiesFor(q, 0);
|
addEmptiesFor(q, 0);
|
||||||
currentQuests.put(q, 0);
|
currentQuests.put(q, 0);
|
||||||
|
@ -51,14 +51,14 @@ public class PlannerPrompt extends FixedSetPrompt {
|
|||||||
+ ChatColor.GRAY + "(" + Lang.get("noneSet") + ")\n";
|
+ ChatColor.GRAY + "(" + Lang.get("noneSet") + ")\n";
|
||||||
} else {
|
} else {
|
||||||
text += ChatColor.BLUE + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("plnStart") + "\n";
|
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) {
|
if (context.getSessionData(CK.PLN_END_DATE) == null) {
|
||||||
text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("plnEnd") + " "
|
text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("plnEnd") + " "
|
||||||
+ ChatColor.GRAY + "(" + Lang.get("noneSet") + ")\n";
|
+ ChatColor.GRAY + "(" + Lang.get("noneSet") + ")\n";
|
||||||
} else {
|
} else {
|
||||||
text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("plnEnd") + "\n";
|
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) {
|
if (context.getSessionData(CK.PLN_REPEAT_CYCLE) == null) {
|
||||||
text += ChatColor.BLUE + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("plnRepeat") + " "
|
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();
|
Calendar cal = Calendar.getInstance();
|
||||||
SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
|
SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
|
||||||
SimpleDateFormat timeFormat = new SimpleDateFormat("hh:mm:ss");
|
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"
|
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"
|
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"
|
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"
|
rewSetMoney: "Set money reward"
|
||||||
rewSetQuestPoints: "Set Quest Points reward"
|
rewSetQuestPoints: "Set Quest Points reward"
|
||||||
rewSetItems: "Set item rewards"
|
rewSetItems: "Set item rewards"
|
||||||
|
Loading…
Reference in New Issue
Block a user