package com.mcbans.firestar.mcbans.api;

import org.bukkit.Bukkit;
import org.bukkit.entity.Player;

import com.mcbans.firestar.mcbans.BanType;
import com.mcbans.firestar.mcbans.BukkitInterface;
import com.mcbans.firestar.mcbans.pluginInterface.Ban;

public class MCBansAPI {
    private final BukkitInterface plugin;

    public MCBansAPI(final BukkitInterface plugin) {
        this.plugin = plugin;
    }

    private void Ban(BanType type, String targetName, String senderName, String reason, String duration, String measure){
        // check null
        if (targetName == null || senderName == null){
            return;
        }

        String targetIP = "";
        if (type != BanType.UNBAN){
            final Player target = Bukkit.getPlayerExact(targetName);
            targetIP = (target != null) ? target.getAddress().getAddress().getHostAddress() : "";
        }

        Ban banControl = new Ban(plugin, type.getActionName(), targetName, targetIP, senderName, reason, duration, measure);
        Thread triggerThread = new Thread(banControl);
        triggerThread.start();
    }

    public void LocalBan(String targetName, String senderName, String reason){
        reason = (reason == null || reason == "") ? plugin.settings.getString("defaultLocal") : reason;
        this.Ban(BanType.LOCAL, targetName, senderName, reason, "", "");
    }

    public void GlobalBan(String targetName, String senderName, String reason){
        if (reason == null || reason == "") return;
        this.Ban(BanType.GLOBAL, targetName, senderName, reason, "", "");
    }

    public void TempBan(String targetName, String senderName, String reason, String duration, String measure){
        reason = (reason == null || reason == "") ? plugin.settings.getString("defaultTemp") : reason;
        duration = (duration == null) ? "" : duration;
        measure = (measure == null) ? "" : measure;
        this.Ban(BanType.TEMP, targetName, senderName, reason, duration, measure);
    }

    public void UnBan(String targetName, String senderName){
        this.Ban(BanType.UNBAN, targetName, senderName, "", "", "");
    }
}

@@ -250,16 +250,73 @@
 ce.Ban;%0D
+%0Aimport com.mcbans.firestar.mcbans.pluginInterface.Kick;%0D
 %0A%0D%0Apubli
@@ -492,17 +492,17 @@
 te void 
-B
+b
 an(BanTy
@@ -1200,17 +1200,17 @@
 ic void 
-L
+l
 ocalBan(
@@ -1374,33 +1374,33 @@
 ;%0D%0A        this.
-B
+b
 an(BanType.LOCAL
@@ -1468,17 +1468,17 @@
 ic void 
-G
+g
 lobalBan
@@ -1591,33 +1591,33 @@
 ;%0D%0A        this.
-B
+b
 an(BanType.GLOBA
@@ -1686,17 +1686,17 @@
 ic void 
-T
+t
 empBan(S
@@ -2000,33 +2000,33 @@
 ;%0D%0A        this.
-B
+b
 an(BanType.TEMP,
@@ -2104,17 +2104,17 @@
 ic void 
-U
+u
 nBan(Str
@@ -2163,17 +2163,17 @@
    this.
-B
+b
 an(BanTy
@@ -2226,12 +2226,403 @@
 %0D%0A    %7D%0D
+%0A%0D%0A    public void kick(String targetName, String senderName, String reason)%7B%0D%0A        reason = (reason == null %7C%7C reason == %22%22) ? plugin.settings.getString(%22defaultKick%22) : reason;%0D%0A%0D%0A        // Start%0D%0A        Kick kickPlayer = new Kick(plugin.settings, plugin, targetName, senderName, reason);%0D%0A        Thread triggerThread = new Thread(kickPlayer);%0D%0A        triggerThread.start();%0D%0A    %7D%0D
 %0A%7D%0D%0A

Change MCBansAPI