Buenas noches, estoy probando un código para enviar el mensaje! Jugadores automático con intervalo de tiempo. Exem: 30 en 30 minutos para enviar el mensaje en el reproductor
Alguien podría escribirlo? No sé mucho de Java, y yo creo que es algo fácil.
No tienes permiso para ver los enlaces. Para poder verlos
Registrate o Conectate.Buenas noches, estoy probando un código para enviar el mensaje! Jugadores automático con intervalo de tiempo. Exem: 30 en 30 minutos para enviar el mensaje en el reproductor
Alguien podría escribirlo? No sé mucho de Java, y yo creo que es algo fácil.
Usa este ejemplo ^^
/*
* 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 custom.events.AutoEvent;
import java.util.concurrent.ScheduledFuture;
import org.l2jdevs.gameserver.ThreadPoolManager;
import org.l2jdevs.gameserver.model.actor.instance.L2PcInstance;
import org.l2jdevs.gameserver.util.Broadcast;
/**
* Auto Event Example
* @author Swarlog
*/
public final class AutoEvent extends Event
{
// Config
public static final int TIME_START = 60; // minutes
public static final int TIME_OF_EVENT = 10; // minutes
public static final int TIME_RESTART = 120; // minutes
private static boolean EVENT_ACTIVE = false;
// Task, auto event
private ScheduledFuture<?> _eventTask = null;
private AutoEvent()
{
super(AutoEvent.class.getSimpleName(), "custom/events");
// Task
_eventTask = ThreadPoolManager.getInstance().scheduleGeneral(() -> eventStart(null), TIME_START * 60 * 1000);
}
@Override
public boolean eventBypass(L2PcInstance activeChar, String bypass)
{
return false;
}
@Override
public boolean eventStart(L2PcInstance eventMaker)
{
if (EVENT_ACTIVE)
{
return false;
}
if (_eventTask != null)
{
_eventTask.cancel(false);
}
// State
EVENT_ACTIVE = true;
// Message
Broadcast.toAllOnlinePlayers("Auto Event ON!");
// Task
_eventTask = ThreadPoolManager.getInstance().scheduleGeneral(() -> eventStop(null), TIME_OF_EVENT * 60 * 1000);
return true;
}
@Override
public boolean eventStop()
{
if (!EVENT_ACTIVE)
{
return false;
}
if (_eventTask != null)
{
_eventTask.cancel(true);
_eventTask = null;
}
// State
EVENT_ACTIVE = false;
// Task
_eventTask = ThreadPoolManager.getInstance().scheduleGeneral(() -> eventStart(null), TIME_RESTART * 60 * 1000);
Broadcast.toAllOnlinePlayers("Auto Event OFF!");
return true;
}
public static void main(String[] args)
{
new AutoEvent();
}
}
Muchas gracias No tienes permiso para ver los enlaces. Para poder verlos
Registrate o
Conectate. voy a adaptarlo a L2JFrozen (interlude)