package at.junction.anathema;

import at.junction.api.bans.Ban;

import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.player.AsyncPlayerPreLoginEvent;



import java.util.List;


public class AnathemaListener implements Listener {
    private Anathema plugin;

    public AnathemaListener(Anathema plugin) {
        this.plugin = plugin;
   }
    
    @EventHandler(priority = EventPriority.HIGHEST)
    public void onAsyncPlayerPreLoginEvent(AsyncPlayerPreLoginEvent event) {
        try {
            List<Ban> bans = plugin.banAPI.getLocalBans(event.getName(), "true");
            if (bans.size() > 0){ //Player is banned
                event.disallow(AsyncPlayerPreLoginEvent.Result.KICK_BANNED, "You have been banned from this server.\nReason: " + bans.get(0).reason + "\n" + plugin.config.BANAPPEND);
                return;
            }
        } catch (Exception exception){
            event.disallow(AsyncPlayerPreLoginEvent.Result.KICK_OTHER, "BanAPI Caused an error. Please contact tech staff");
            plugin.getLogger().severe("E01: Failed to access ban api. Message: " + exception.getMessage());
            return;
        }
        try {
            plugin.altAPI.add(event.getName(), event.getAddress().getHostAddress());
        } catch (Exception exception){
            plugin.getLogger().severe("E02: Failed to log alt information. Message: " + exception.getMessage());
        }

    }
}

@@ -58,16 +58,112 @@
 s.Ban;%0A%0A
+import at.junction.api.bans.Note;%0Aimport org.bukkit.ChatColor;%0Aimport org.bukkit.entity.Player;%0A
 import o
@@ -322,16 +322,64 @@
 nEvent;%0A
+import org.bukkit.event.player.PlayerLoginEvent;
 %0A%0A%0Aimpor
@@ -1630,16 +1630,879 @@
      %7D%0A%0A
+    %7D%0A    @EventHandler(priority = EventPriority.HIGHEST)%0A    public void onPlayerLoginEvent(PlayerLoginEvent event)%7B%0A        try %7B%0A%0A            List%3CNote%3E notes = plugin.banAPI.getLocalNotes(event.getPlayer().getName(), %22true%22);%0A            if (notes.size() == 0) return;%0A            for (Note n : notes)%7B%0A                String message = String.format(%22%25s%5BANATHEMA-NOTES%5D%25s%25s has note %25s added by %25s%22, ChatColor.GREEN.toString(), ChatColor.RESET.toString(), event.getPlayer().getName(), n.note, n.issuer);%0A                for (Player player : plugin.getServer().getOnlinePlayers())%7B%0A                    if (player.hasPermission(%22junction.anathema.access%22))%7B%0A                        player.sendMessage(message);%0A                    %7D%0A                %7D%0A            %7D%0A        %7D catch (Exception e)%7B%0A            plugin.getLogger().severe(e.getMessage());%0A        %7D%0A
     %7D%0A%7D%0A

Add login notification of notes