Uses KnarLib to get rid of duplicate code
This commit is contained in:
@ -2,7 +2,11 @@ package net.knarcraft.dynmapcitizens.handler.trait.quests;
|
||||
|
||||
import me.blackvein.quests.quests.IQuest;
|
||||
import me.blackvein.quests.quests.Planner;
|
||||
import net.knarcraft.dynmapcitizens.util.TimeFormatter;
|
||||
import net.knarcraft.knarlib.formatting.TimeFormatter;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* A class to generate a string containing all information about a quest's planner info
|
||||
@ -42,13 +46,13 @@ public class QuestPlannerInfoGenerator {
|
||||
//Quest only becomes available after the start date
|
||||
if (planner.hasStart()) {
|
||||
plannerInfo.append("<li>Quest available from ");
|
||||
plannerInfo.append(TimeFormatter.formatTimestamp(planner.getStartInMillis())).append("</li>");
|
||||
plannerInfo.append(formatTimestamp(planner.getStartInMillis())).append("</li>");
|
||||
}
|
||||
|
||||
//Quest is only available until the end date
|
||||
if (planner.hasEnd()) {
|
||||
plannerInfo.append("<li>Quest available until ");
|
||||
plannerInfo.append(TimeFormatter.formatTimestamp(planner.getEndInMillis())).append("</li>");
|
||||
plannerInfo.append(formatTimestamp(planner.getEndInMillis())).append("</li>");
|
||||
}
|
||||
|
||||
//Quest availability repeats
|
||||
@ -61,4 +65,16 @@ public class QuestPlannerInfoGenerator {
|
||||
return plannerInfo.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a datetime string for the given timestamp
|
||||
*
|
||||
* @param timestamp <p>A timestamp in milliseconds</p>
|
||||
* @return <p>A datetime string</p>
|
||||
*/
|
||||
private String formatTimestamp(long timestamp) {
|
||||
DateFormat format = new SimpleDateFormat("dd MM yyyy HH:mm:ss");
|
||||
Date date = new Date(timestamp);
|
||||
return format.format(date);
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user