public void run() {
System.out.println("INFO: Npc sleep timer started");
Random r = new Random();
NonPlayerChar n = null;
ServerMap m = null;
while(m_running) {
/*
* Loop through every map
*/
for(int x = 0; x < 100; x++) {
for(int y = 0; y < 100; y++) {
m = GameServer.getServiceManager().
getMovementService().getMapMatrix().getMapByRealPosition(x, y);
if(m != null) {
/*
* Loop through every npc on the map
* If they're sleeping, check if its time to wake them
*/
for(int i = 0; i < m.getNpcs().size(); i++) {
n = m.getNpcs().get(i);
if(n != null && !n.canBattle() &&
System.currentTimeMillis() - n.getLastBattleTime()
>= 300000 + r.nextInt(300000)) {
n.setLastBattleTime(0);
}