Hello would like help to leave the registration time every minute.
package net.sf.l2j.gameserver.model.entity.capturetheflag;import java.util.Calendar;import java.util.concurrent.ScheduledFuture;import java.util.logging.Logger;import net.sf.l2j.Config;import net.sf.l2j.commons.concurrent.ThreadPool;import net.sf.l2j.gameserver.util.Broadcast;/**
* @author FBIagent
*/publicclassCTFManager{protectedstatic final Logger _log =Logger.getLogger(CTFManager.class.getName());/** Task for event cycles<br> */privateCTFStartTask _task;/**
* New instance only by getInstance()<br>
*/publicCTFManager(){if(Config.CTF_EVENT_ENABLED){CTFEvent.init();this.scheduleEventStart();
_log.info("CTFEventEngine: Started.");}else{
_log.info("CTFEventEngine: Disabled.");}}/**
* Initialize new/Returns the one and only instance<br><br>
*
* @return CTFManager<br>
*/publicstaticCTFManager getInstance(){returnSingletonHolder._instance;}/**
* Starts CTFStartTask
*/publicvoid scheduleEventStart(){try{Calendar currentTime =Calendar.getInstance();Calendar nextStartTime = null;Calendar testStartTime = null;for(String timeOfDay :Config.CTF_EVENT_INTERVAL){// Creating a Calendar object from the specified interval value
testStartTime =Calendar.getInstance();
testStartTime.setLenient(true);String[] splitTimeOfDay = timeOfDay.split(":");
testStartTime.set(Calendar.HOUR_OF_DAY,Integer.parseInt(splitTimeOfDay[0]));
testStartTime.set(Calendar.MINUTE,Integer.parseInt(splitTimeOfDay[1]));// If the date is in the past, make it the next day (Example: Checking for "1:00", when the time is 23:57.)if(testStartTime.getTimeInMillis()< currentTime.getTimeInMillis()){
testStartTime.add(Calendar.DAY_OF_MONTH,1);}// Check for the test date to be the minimum (smallest in the specified list)if(nextStartTime == null || testStartTime.getTimeInMillis()< nextStartTime.getTimeInMillis()){
nextStartTime = testStartTime;}}if(nextStartTime != null){
_task =newCTFStartTask(nextStartTime.getTimeInMillis());ThreadPool.execute(_task);}}catch(Exception e){
_log.warning("CTFEventEngine[CTFManager.scheduleEventStart()]: Error figuring out a start time. Check CTFEventInterval in config file.");}}/**
* Method to start participation
*/publicvoid startReg(){if(!CTFEvent.startParticipation()){Broadcast.announceToOnlinePlayers("CTF Event: Event was cancelled.");
_log.warning("CTFEventEngine[CTFManager.run()]: Error spawning event npc for participation.");this.scheduleEventStart();}else{Broadcast.announceToOnlinePlayers("CTF Event: Registration opened for "+Config.CTF_EVENT_PARTICIPATION_TIME +" minute(s).",true);Broadcast.announceToOnlinePlayers("CTF Event: Joinable in "+Config.CTF_JOIN_LOCATION +".");if(Config.CTF_VOICED_COMMAND)Broadcast.announceToOnlinePlayers("CTF Event : Commands .ctfjoin .ctfleave .ctfinfo!");// schedule registration end
_task.setStartTime(System.currentTimeMillis()+60000L*Config.CTF_EVENT_PARTICIPATION_TIME);ThreadPool.execute(_task);}}/**
* Method to start the fight
*/publicvoid startEvent(){if(!CTFEvent.startFight()){Broadcast.announceToOnlinePlayers("CTF Event: Event cancelled due to lack of Participation.");
_log.info("CTFEventEngine[CTFManager.run()]: Lack of registration, abort event.");this.scheduleEventStart();}else{CTFEvent.sysMsgToAllParticipants("CTF Event: Teleporting participants to an arena in "+Config.CTF_EVENT_START_LEAVE_TELEPORT_DELAY +" second(s).");
_task.setStartTime(System.currentTimeMillis()+60000L*Config.CTF_EVENT_RUNNING_TIME);ThreadPool.execute(_task);}}/**
* Method to end the event and reward
*/publicvoid endEvent(){Broadcast.announceToOnlinePlayers(CTFEvent.calculateRewards());CTFEvent.sysMsgToAllParticipants("CTF Event: Teleporting back to the registration npc in "+Config.CTF_EVENT_START_LEAVE_TELEPORT_DELAY +" second(s).");CTFEvent.stopFight();this.scheduleEventStart();}publicvoid skipDelay(){if(_task.nextRun.cancel(false)){
_task.setStartTime(System.currentTimeMillis());ThreadPool.execute(_task);}}/**
* Class for CTF cycles
*/classCTFStartTask implements Runnable{privatelong _startTime;publicScheduledFuture<?> nextRun;publicCTFStartTask(long startTime){
_startTime = startTime;}publicvoid setStartTime(long startTime){
_startTime = startTime;}/**
* @see java.lang.Runnable#run()
*/@Overridepublicvoid run(){int delay =(int)Math.round((_startTime -System.currentTimeMillis())/1000.0);if(delay >0){this.announce(delay);}int nextMsg =0;if(delay >3600){
nextMsg = delay -3600;}elseif(delay >1800){
nextMsg = delay -1800;}elseif(delay >900){
nextMsg = delay -900;}elseif(delay >600){
nextMsg = delay -600;}elseif(delay >300){
nextMsg = delay -300;}elseif(delay >60){
nextMsg = delay -60;}elseif(delay >5){
nextMsg = delay -5;}elseif(delay >0){
nextMsg = delay;}else{// startif(CTFEvent.isInactive()){CTFManager.this.startReg();}elseif(CTFEvent.isParticipating()){CTFManager.this.startEvent();}else{CTFManager.this.endEvent();}}if(delay >0){
nextRun =ThreadPool.schedule(this, nextMsg *1000);}}privatevoid announce(long time){if(time >=3600&& time %3600==0){if(CTFEvent.isParticipating()){Broadcast.announceToOnlinePlayers("CTF Event: "+(time /60/60)+" hour(s) until registration is closed!");}elseif(CTFEvent.isStarted()){CTFEvent.sysMsgToAllParticipants("CTF Event: "+(time /60/60)+" hour(s) until event is finished!");}}elseif(time >=60){if(CTFEvent.isParticipating()){Broadcast.announceToOnlinePlayers("CTF Event: "+(time /60)+" minute(s) until registration is closed!");}elseif(CTFEvent.isStarted()){CTFEvent.sysMsgToAllParticipants("CTF Event: "+(time /60)+" minute(s) until the event is finished!");}}else{if(CTFEvent.isParticipating()){Broadcast.announceToOnlinePlayers("CTF Event: "+ time +" second(s) until registration is closed!");}elseif(CTFEvent.isStarted()){CTFEvent.sysMsgToAllParticipants("CTF Event: "+ time +" second(s) until the event is finished!");}}}}privatestaticclassSingletonHolder{protectedstatic final CTFManager _instance =newCTFManager();}}
You can post now and register later.
If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.
I don't understand why you are so offended and aggressive, who allowed you to disrespect me or call me in any way? Did I insulted you? You act like a angry kid, grow up boy.
@Maxtor@Celestino
The administrators of this forum can access everything I've sent...
Your move won't work on me. Hahahaha!
Getting into the parameters and editing the HTMLs of websites and claiming it's real used to be really cool among true friends.
@jtos So, is this also true? 🤣😂🤣😂🤣😂🤣
Your joke still hasn't been better than mine. Hahahah!
Question
l2jkain
Hello would like help to leave the registration time every minute.
0 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.