Noticias:

Debes de estar registrado para poder ver el contenido indicado. Registrate o Conectate

Menú Principal

Scheduled Auto restart (Sacrifice)

Iniciado por Swarlog, Sep 01, 2022, 12:32 AM

Tema anterior - Siguiente tema

Swarlog

Esta clase lo que hace es un restart automático el Miércoles (WEDNESDAY) de cada semana a la hora que configures en la base de datos (ver script SQL más abajo), avisando primero a los jugadores online de que se ha iniciado el proceso hasta que se cumpla el tiempo, (en intervalos va avisando de que se está acabando el tiempo) y a los 10 minutos (600 segundos) el server reinicia.
/*
 * Copyright (C) 2004-2016 L2J DataPack
 *
 * This file is part of L2J DataPack.
 *
 * L2J DataPack is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * L2J DataPack is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 */
package cron;

import java.util.Calendar;

import com.l2jserver.gameserver.Shutdown;
import com.l2jserver.gameserver.util.Broadcast;

/**
 * @author Sacrifice
 */
public final class ScheduledAutoRestart
{
public static void main(String[] args)
{
Calendar now = Calendar.getInstance();
if ((now.get(Calendar.DAY_OF_WEEK) == Calendar.WEDNESDAY))
{
Broadcast.toAllOnlinePlayers("Scheduled reboot is starting...");
Shutdown.getInstance().autoRestart(600);
}
}
}
Para que se ejecute el script es necesario ejecutar este SQL para añadir la tarea. Antes, cambiar la hora si se desea ('10:00:00' por otra 'HH:MM:SS' la que deseemos y en formato de 24 horas).
INSERT INTO `global_tasks` VALUES ('201', 'script', 'TYPE_GLOBAL_TASK', '0', '1', '10:00:00', 'ScheduledAutoRestart.java');
Y reiniciar el server para que se actualice la nueva tarea, después se ejecutará por sí sola.