I made this without Eclipse so I might have forgotten a thing or two but thats the basic.
/*
* This program 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.
*
* This program 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 com.l2jfree.gameserver;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.l2jfree.gameserver.model.L2World;
import com.l2jfree.gameserver.model.entity.events.CTF;
import com.l2jfree.gameserver.model.entity.events.TvT;
import com.l2jfree.tools.random.Rnd;
/**
* @author Horus
*
*/
public class EventManager
{
private static EventManager _instance;
private final static Log _log = LogFactory.getLog(EventManager.class.getName());
class StartEvent implements Runnable
{
public void run()
{
if(L2World.getInstance().getAllPlayers().size() >= 10)
{
int _chance = Rnd.get(0, 100);
if(_chance >= 0 && _chance <50)
{
TvT.loadData();
TvT.autoEvent();
}
else if(_chance >= 50 && _chance < 101)
{
CTF.loadData();
CTF.autoEvent();
}
}
else
_log.warn("Event Manager: Event Startup Failed due to lack of Players.");
}
}
public static EventManager getInstance()
{
if (_instance == null)
_instance = new EventManager();
return _instance;
}
private EventManager()
{
ThreadPoolManager.getInstance().scheduleGeneral(new StartEvent(), 16000);
}
}
About the NPC just make an NPC with the Type "L2EventManager"