package l2p.gameserver.enums;
import l2p.commons.time.cron.SchedulingPattern;
import l2p.gameserver.network.components.SystemMsg;
public enum ReuseType
{
NORMAL(SystemMsg.THERE_ARE_S2_SECONDS_REMAINING_IN_S1S_REUSE_TIME, SystemMsg.THERE_ARE_S2_MINUTES_S3_SECONDS_REMAINING_IN_S1S_REUSE_TIME, SystemMsg.THERE_ARE_S2_HOURS_S3_MINUTES_AND_S4_SECONDS_REMAINING_IN_S1S_REUSE_TIME)
{
@Override
public long next(long reuseDelay)
{
return System.currentTimeMillis() + reuseDelay;
}
@Override
public long next()
{
return next(0);
}
},
EVERY_DAY_AT_6_30(SystemMsg.THERE_ARE_S2_SECONDS_REMAINING_FOR_S1S_REUSE_TIME, SystemMsg.THERE_ARE_S2_MINUTES_S3_SECONDS_REMAINING_FOR_S1S_REUSE_TIME, SystemMsg.THERE_ARE_S2_HOURS_S3_MINUTES_S4_SECONDS_REMAINING_FOR_S1S_REUSE_TIME)
{
private final SchedulingPattern _pattern = new SchedulingPattern("30 6 * * *");
@Override
public long next(long reuseDelay)
{
return _pattern.next(System.currentTimeMillis());
}
@Override
public long next()
{
return next(24 * 60 * 60 * 1000L);
}
},
DAILY(SystemMsg.THERE_ARE_S2_SECONDS_REMAINING_IN_S1S_REUSE_TIME, SystemMsg.THERE_ARE_S2_MINUTES_S3_SECONDS_REMAINING_IN_S1S_REUSE_TIME, SystemMsg.THERE_ARE_S2_HOURS_S3_MINUTES_AND_S4_SECONDS_REMAINING_IN_S1S_REUSE_TIME)
{
private final SchedulingPattern _pattern = new SchedulingPattern("0 0 * * *");
@Override
public long next(long reuseDelay)
{
return _pattern.next(System.currentTimeMillis());
}
@Override
public long next()
{
return next(24 * 60 * 60 * 1000L);
}
},
TWICE_A_DAY(SystemMsg.THERE_ARE_S2_SECONDS_REMAINING_IN_S1S_REUSE_TIME, SystemMsg.THERE_ARE_S2_MINUTES_S3_SECONDS_REMAINING_IN_S1S_REUSE_TIME, SystemMsg.THERE_ARE_S2_HOURS_S3_MINUTES_AND_S4_SECONDS_REMAINING_IN_S1S_REUSE_TIME)
{
private final SchedulingPattern _pattern = new SchedulingPattern("30 6 * * *|30 18 * * *");
@Override
public long next(long reuseDelay)
{
return _pattern.next(System.currentTimeMillis());
}
@Override
public long next()
{
return next(12 * 60 * 60 * 1000L);
}
},
EVERY_HOUR(SystemMsg.THERE_ARE_S2_SECONDS_REMAINING_IN_S1S_REUSE_TIME, SystemMsg.THERE_ARE_S2_MINUTES_S3_SECONDS_REMAINING_IN_S1S_REUSE_TIME, SystemMsg.THERE_ARE_S2_HOURS_S3_MINUTES_AND_S4_SECONDS_REMAINING_IN_S1S_REUSE_TIME)
{
private final SchedulingPattern _pattern = new SchedulingPattern("0 * * * *");
@Override
public long next(long reuseDelay)
{
return _pattern.next(System.currentTimeMillis());
}
@Override
public long next()
{
return next(60 * 60 * 1000L);
}
};
private SystemMsg[] _messages;
private ReuseType(SystemMsg... messages)
{
_messages = messages;
}
public abstract long next();
public abstract long next(long reuseDelay);
public SystemMsg[] getMessages()
{
return _messages;
}
}