package me.games647.scoreboardstats.api;

import net.minecraft.server.v1_5_R2.Packet206SetScoreboardObjective;
import net.minecraft.server.v1_5_R2.Packet207SetScoreboardScore;
import net.minecraft.server.v1_5_R2.Packet208SetScoreboardDisplayObjective;
import net.minecraft.server.v1_5_R2.PlayerConnection;

public final class Score {

    private static final String TITLE = org.bukkit.ChatColor.translateAlternateColorCodes('&', "&a&lStats&f");

    public static void createScoreboard(final PlayerConnection con, final int value_kills, final int value_deaths) {

        final Packet206SetScoreboardObjective objective = new Packet206SetScoreboardObjective();
        objective.a = TITLE;
        objective.b = TITLE;
//        objective.c = 0; Integers have automatically zero as value

        final Packet208SetScoreboardDisplayObjective display = new Packet208SetScoreboardDisplayObjective();
        display.b = TITLE;
        display.a = 1;

        final Packet207SetScoreboardScore kills = new Packet207SetScoreboardScore();
        kills.a = "§9Kills     ";
        kills.b = TITLE;
        kills.c = value_kills;

        final Packet207SetScoreboardScore deaths = new Packet207SetScoreboardScore();
        deaths.a = "§9Deaths     ";
        deaths.b = TITLE;
        deaths.c = value_deaths;

        con.sendPacket(objective);
        con.sendPacket(display);
        con.sendPacket(kills);
        con.sendPacket(deaths);
    }

    public static void update(final PlayerConnection con, final boolean type, final int value) {
        final Packet207SetScoreboardScore packet = new Packet207SetScoreboardScore();

        packet.c = value;
        if (type) {
            packet.a = "§9Kills     ";
        } else {
            packet.a = "§9Deaths     ";
        }
        packet.b = TITLE;

        con.sendPacket(packet);
    }
}

@@ -439,35 +439,35 @@
 ts&f%22);%0A
-%0A
     p
-ublic
+rivate
  static 
 void cre
@@ -462,115 +462,116 @@
 tic 
-void createScoreboard(final PlayerConnection con, final int value_kills, final int value_deaths) %7B%0A%0A       
+final Packet206SetScoreboardObjective OBJECTIVE =  new Packet206SetScoreboardObjective();%0A    private static
  fin
@@ -573,33 +573,33 @@
 c final Packet20
-6
+8
 SetScoreboardObj
@@ -587,32 +587,39 @@
 208SetScoreboard
+Display
 Objective object
@@ -612,25 +612,23 @@
 jective 
-objective
+DISPLAY
  = new P
@@ -626,33 +626,33 @@
 Y = new Packet20
-6
+8
 SetScoreboardObj
@@ -640,32 +640,39 @@
 208SetScoreboard
+Display
 Objective();%0A   
@@ -672,29 +672,42 @@
 ();%0A    
-    objective
+static %7B%0A        OBJECTIVE
 .a = TIT
@@ -718,25 +718,25 @@
         
-objective
+OBJECTIVE
 .b = TIT
@@ -743,18 +743,16 @@
 LE;%0A
-//
         
 obje
@@ -751,226 +751,242 @@
     
-objective.c = 0; Integers have automatically zero as value%0A
+DISPLAY.b = TITLE;%0A        DISPLAY.a = 1;
 %0A    
+%7D%0A%0A
     
-final Packet208SetScoreboardDisplayObjective display = new Packet208SetScoreboardDisplayObjective();%0A        display.b = TITLE;%0A        display.a = 1;
+public static void createScoreboard(final PlayerConnection con, final int value_kills, final int value_deaths) %7B%0A//        objective.c = 0; Integers have automatically zero as value
 %0A%0A  
@@ -1364,25 +1364,25 @@
 dPacket(
-objective
+OBJECTIVE
 );%0A     
@@ -1403,15 +1403,15 @@
 ket(
-display
+DISPLAY
 );%0A 

Improve object an display packet