package com.bebehp.mc.eewreciever.ping;

import java.util.List;

import com.bebehp.mc.eewreciever.ConfigurationHandler;
import com.bebehp.mc.eewreciever.EEWRecieverMod;
import com.bebehp.mc.eewreciever.p2pquake.P2PQuake;
import com.bebehp.mc.eewreciever.twitter.TweetQuake;

import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.TickEvent.ServerTickEvent;

public class QuakeMain {

	final IQuake p2pQuake = new P2PQuake();
	final IQuake tweetQuake = new TweetQuake();

	long lasttime;
	@SubscribeEvent
	public void onServerTick(final ServerTickEvent event) {
		try {
			final List<AbstractQuakeNode> p2pQuakeNode = this.p2pQuake.getQuakeUpdate();
			if(ConfigurationHandler.p2pQuakeEnable) checkUpdate(p2pQuakeNode);

			final List<AbstractQuakeNode> tweetQuakeNode = this.tweetQuake.getQuakeUpdate();
			if(ConfigurationHandler.twitterEnable) checkUpdate(tweetQuakeNode);
		} catch (final QuakeException e) {
			EEWRecieverMod.logger.error(e);
		}
	}

	public void checkUpdate(final List<AbstractQuakeNode> update)
	{
		for (final AbstractQuakeNode up : update)
		{
			if (ConfigurationHandler.debugMode || up.training)
			{
				EEWRecieverMod.sendServerChat(up.toString());
			} else {
				if (ConfigurationHandler.forceLevel || up.isAlarm())
				{
					EEWRecieverMod.sendServerChat(up.toString());
				}
			}
		}
	}
}

@@ -518,16 +518,17 @@
 sttime;%0A
+%0A
 %09@Subscr
@@ -678,32 +678,33 @@
 eUpdate();%0A%09%09%09if
+ 
 (ConfigurationHa
@@ -720,25 +720,29 @@
 QuakeEnable)
- 
+%0A%09%09%09%09
 checkUpdate(
@@ -846,16 +846,17 @@
 );%0A%09%09%09if
+ 
 (Configu
@@ -883,17 +883,21 @@
 rEnable)
- 
+%0A%09%09%09%09
 checkUpd
@@ -1059,18 +1059,17 @@
  update)
-%0A%09
+ 
 %7B%0A%09%09for 
@@ -1105,19 +1105,17 @@
  update)
-%0A%09%09
+ 
 %7B%0A%09%09%09if 
@@ -1149,28 +1149,10 @@
 Mode
+)
  
-%7C%7C up.training)%0A%09%09%09
 %7B%0A%09%09
@@ -1209,22 +1209,16 @@
 %09%7D else 
-%7B%0A%09%09%09%09
 if (Conf
@@ -1265,16 +1265,11 @@
 m())
-%0A%09%09%09%09
+ 
 %7B%0A
-%09
 %09%09%09%09
@@ -1318,14 +1318,8 @@
 ));%0A
-%09%09%09%09%7D%0A
 %09%09%09%7D

Fix debug mode