/*
 * Copyright 2014 Alexander Chauncey
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.censoredsoftware.infractions.bukkit.legacy;

import com.censoredsoftware.infractions.bukkit.Infraction;
import com.censoredsoftware.infractions.bukkit.Infractions;
import com.censoredsoftware.infractions.bukkit.dossier.Dossier;
import com.censoredsoftware.infractions.bukkit.legacy.data.ServerData;
import com.censoredsoftware.infractions.bukkit.legacy.util.MiscUtil;
import com.censoredsoftware.infractions.bukkit.legacy.util.SettingUtil;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;

import java.util.Set;

public class PlayerListener implements Listener
{
	@EventHandler
	public void onPlayerJoin(PlayerJoinEvent e)
	{
		// sync to master file
		final Player p = e.getPlayer();
		Dossier dossier = Infractions.getCompleteDossier(p);
		if(SettingUtil.getSettingBoolean("motd"))
		{
			// TODO Consolidate this into some sort of useful notification system.
			p.sendMessage("This server is policed with infractions.");
		}
		if(p.hasPermission("infractions.ignore"))
		{

			Set<Infraction> infractions = dossier.getInfractions();
			if(!infractions.isEmpty())
				for(Infraction infraction : infractions)
					dossier.acquit(infraction);
			return;
		}
		if(ServerData.exists(p.getName(), "NEWINFRACTION"))
		{
			if((Boolean) ServerData.get(p.getName(), "NEWINFRACTION"))
			{
				p.sendMessage(ChatColor.RED + "You have a new infraction!" + ChatColor.WHITE + " Use " + ChatColor.YELLOW + "/history" + ChatColor.WHITE + " for more information.");
				ServerData.remove(p.getName(), "NEWINFRACTION");
			}
		}
		if(ServerData.exists(p.getName(), "NEWVIRTUE"))
		{
			if((Boolean) ServerData.get(p.getName(), "NEWVIRTUE"))
			{
				p.sendMessage(ChatColor.RED + "You have a new virtue!" + ChatColor.WHITE + " Use " + ChatColor.YELLOW + "/history" + ChatColor.WHITE + " for more information.");
				ServerData.remove(p.getName(), "NEWVIRTUE");
			}
		}

		ServerData.put(p.getName(), "LASTLOGINTIME", System.currentTimeMillis());
		MiscUtil.checkScore(p);
	}
}

@@ -656,67 +656,8 @@
 y;%0A%0A
-import com.censoredsoftware.infractions.bukkit.Infraction;%0A
 impo
@@ -712,16 +712,16 @@
 ctions;%0A
+
 import c
@@ -1175,31 +1175,8 @@
 t;%0A%0A
-import java.util.Set;%0A%0A
 publ
@@ -1520,16 +1520,16 @@
 system.%0A
+
 %09%09%09p.sen
@@ -1590,239 +1590,8 @@
 %09%09%7D%0A
-%09%09if(p.hasPermission(%22infractions.ignore%22))%0A%09%09%7B%0A%0A%09%09%09Set%3CInfraction%3E infractions = dossier.getInfractions();%0A%09%09%09if(!infractions.isEmpty())%0A%09%09%09%09for(Infraction infraction : infractions)%0A%09%09%09%09%09dossier.acquit(infraction);%0A%09%09%09return;%0A%09%09%7D%0A
 %09%09if

Remove harmful code.