Throw invalid kit message on invalid delay

This commit is contained in:
Necrodoom 2013-04-30 20:03:54 +03:00 committed by KHobbits
parent 479dad9966
commit a65d0db57d

View File

@ -59,7 +59,16 @@ public class Kit
final Calendar time = new GregorianCalendar();
// Take the current time, and remove the delay from it.
final double delay = els.containsKey("delay") ? ((Number)els.get("delay")).doubleValue() : 0.0d;
double delay = 0;
try
{
// Also make sure delay is valid
delay = els.containsKey("delay") ? ((Number)els.get("delay")).doubleValue() : 0.0d;
}
catch (Exception e)
{
throw new Exception(_("kitError2"));
}
final Calendar earliestTime = new GregorianCalendar();
earliestTime.add(Calendar.SECOND, -(int)delay);
earliestTime.add(Calendar.MILLISECOND, -(int)((delay * 1000.0) % 1000.0));