// Path: src/main/java/com/gamingmesh/jobs/util/UUIDFetcher.java
// public class UUIDFetcher implements Callable<Map<String, UUID>> {
//     private static final double PROFILES_PER_REQUEST = 100;
//     private static final String PROFILE_URL = "https://api.mojang.com/profiles/minecraft";
//     private final JSONParser jsonParser = new JSONParser();
//     private final List<String> names;
//     private final boolean rateLimiting;
// 
//     public UUIDFetcher(List<String> names, boolean rateLimiting) {
//         this.names = ImmutableList.copyOf(names);
//         this.rateLimiting = rateLimiting;
//     }
// 
//     public UUIDFetcher(List<String> names) {
//         this(names, true);
//     }
// 
//     public Map<String, UUID> call() throws Exception {
//         Map<String, UUID> uuidMap = new HashMap<String, UUID>();
//         int requests = (int) Math.ceil(names.size() / PROFILES_PER_REQUEST);
//         for (int i = 0; i < requests; i++) {
//             HttpURLConnection connection = createConnection();
//             String body = JSONArray.toJSONString(names.subList(i * 100, Math.min((i + 1) * 100, names.size())));
//             writeBody(connection, body);
//             JSONArray array = (JSONArray) jsonParser.parse(new InputStreamReader(connection.getInputStream()));
//             for (Object profile : array) {
//                 JSONObject jsonProfile = (JSONObject) profile;
//                 String id = (String) jsonProfile.get("id");
//                 String name = (String) jsonProfile.get("name");
//                 UUID uuid = UUIDFetcher.getUUID(id);
//                 uuidMap.put(name, uuid);
//             }
//             if (rateLimiting && i != requests - 1) {
//                 Thread.sleep(100L);
//             }
//         }
//         return uuidMap;
//     }
// 
//     private static void writeBody(HttpURLConnection connection, String body) throws Exception {
//         OutputStream stream = connection.getOutputStream();
//         stream.write(body.getBytes());
//         stream.flush();
//         stream.close();
//     }
// 
//     private static HttpURLConnection createConnection() throws Exception {
//         URL url = new URL(PROFILE_URL);
//         HttpURLConnection connection = (HttpURLConnection) url.openConnection();
//         connection.setRequestMethod("POST");
//         connection.setRequestProperty("Content-Type", "application/json");
//         connection.setUseCaches(false);
//         connection.setDoInput(true);
//         connection.setDoOutput(true);
//         return connection;
//     }
// 
//     private static UUID getUUID(String id) {
//         return UUID.fromString(id.substring(0, 8) + "-" + id.substring(8, 12) + "-" + id.substring(12, 16) + "-" + id.substring(16, 20) + "-" +id.substring(20, 32));
//     }
// 
//     public static byte[] toBytes(UUID uuid) {
//         ByteBuffer byteBuffer = ByteBuffer.wrap(new byte[16]);
//         byteBuffer.putLong(uuid.getMostSignificantBits());
//         byteBuffer.putLong(uuid.getLeastSignificantBits());
//         return byteBuffer.array();
//     }
// 
//     public static UUID fromBytes(byte[] array) {
//         if (array.length != 16) {
//             throw new IllegalArgumentException("Illegal byte array length: " + array.length);
//         }
//         ByteBuffer byteBuffer = ByteBuffer.wrap(array);
//         long mostSignificant = byteBuffer.getLong();
//         long leastSignificant = byteBuffer.getLong();
//         return new UUID(mostSignificant, leastSignificant);
//     }
// 
//     public static UUID getUUIDOf(String name) throws Exception {
//         return new UUIDFetcher(Arrays.asList(name)).call().get(name);
//     }
// }
// 
// Path: src/main/java/com/gamingmesh/jobs/util/UUIDUtil.java
// public class UUIDUtil {
//     public static byte[] toBytes(UUID uuid) {
//         ByteBuffer bb = ByteBuffer.allocate(16);
//         bb.putLong(uuid.getMostSignificantBits());
//         bb.putLong(uuid.getLeastSignificantBits());
//         return bb.array();
//     }
// 
//     public static UUID fromBytes(byte[] array) {
//         ByteBuffer bb = ByteBuffer.wrap(array);
//         long most = bb.getLong();
//         long least = bb.getLong();
//         return new UUID(most, least);
//     }
// }


import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Map;
import java.util.UUID;
import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.util.UUIDFetcher;
import com.gamingmesh.jobs.util.UUIDUtil;
            prest.setString(2, getPrefix()+"jobs");
            ResultSet res = prest.executeQuery();
            if (res.next()) {
                rows = res.getInt(1);
            }
        } finally {
            if (prest != null) {
                try {
                    prest.close();
                } catch (SQLException e) {}
            }
        }

        PreparedStatement pst1 = null;
        PreparedStatement pst2 = null;
        try {
            if (rows == 0) {
                executeSQL("CREATE TABLE `" + getPrefix() + "jobs` (`id` int NOT NULL AUTO_INCREMENT PRIMARY KEY, `player_uuid` binary(16) NOT NULL, `username` varchar(20), `job` varchar(20), `experience` int, `level` int);");
            } else {
                Jobs.getPluginLogger().info("Converting existing usernames to Mojang UUIDs.  This could take a long time!");
                
                executeSQL("ALTER TABLE `" + getPrefix() + "jobs` ADD COLUMN `id` int NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST;");
                executeSQL("ALTER TABLE `" + getPrefix() + "jobs` ADD COLUMN `player_uuid` binary(16) DEFAULT NULL AFTER `id`;");
                
                pst1 = conn.prepareStatement("SELECT DISTINCT `username` FROM `" + getPrefix() + "jobs` WHERE `player_uuid` IS NULL;");
                ResultSet rs = pst1.executeQuery();
                ArrayList<String> usernames = new ArrayList<String>();
                while (rs.next()) {
                    usernames.add(rs.getString(1));
                }
// Path: src/main/java/com/gamingmesh/jobs/util/UUIDFetcher.java
// public class UUIDFetcher implements Callable<Map<String, UUID>> {
//     private static final double PROFILES_PER_REQUEST = 100;
//     private static final String PROFILE_URL = "https://api.mojang.com/profiles/minecraft";
//     private final JSONParser jsonParser = new JSONParser();
//     private final List<String> names;
//     private final boolean rateLimiting;
// 
//     public UUIDFetcher(List<String> names, boolean rateLimiting) {
//         this.names = ImmutableList.copyOf(names);
//         this.rateLimiting = rateLimiting;
//     }
// 
//     public UUIDFetcher(List<String> names) {
//         this(names, true);
//     }
// 
//     public Map<String, UUID> call() throws Exception {
//         Map<String, UUID> uuidMap = new HashMap<String, UUID>();
//         int requests = (int) Math.ceil(names.size() / PROFILES_PER_REQUEST);
//         for (int i = 0; i < requests; i++) {
//             HttpURLConnection connection = createConnection();
//             String body = JSONArray.toJSONString(names.subList(i * 100, Math.min((i + 1) * 100, names.size())));
//             writeBody(connection, body);
//             JSONArray array = (JSONArray) jsonParser.parse(new InputStreamReader(connection.getInputStream()));
//             for (Object profile : array) {
//                 JSONObject jsonProfile = (JSONObject) profile;
//                 String id = (String) jsonProfile.get("id");
//                 String name = (String) jsonProfile.get("name");
//                 UUID uuid = UUIDFetcher.getUUID(id);
//                 uuidMap.put(name, uuid);
//             }
//             if (rateLimiting && i != requests - 1) {
//                 Thread.sleep(100L);
//             }
//         }
//         return uuidMap;
//     }
// 
//     private static void writeBody(HttpURLConnection connection, String body) throws Exception {
//         OutputStream stream = connection.getOutputStream();
//         stream.write(body.getBytes());
//         stream.flush();
//         stream.close();
//     }
// 
//     private static HttpURLConnection createConnection() throws Exception {
//         URL url = new URL(PROFILE_URL);
//         HttpURLConnection connection = (HttpURLConnection) url.openConnection();
//         connection.setRequestMethod("POST");
//         connection.setRequestProperty("Content-Type", "application/json");
//         connection.setUseCaches(false);
//         connection.setDoInput(true);
//         connection.setDoOutput(true);
//         return connection;
//     }
// 
//     private static UUID getUUID(String id) {
//         return UUID.fromString(id.substring(0, 8) + "-" + id.substring(8, 12) + "-" + id.substring(12, 16) + "-" + id.substring(16, 20) + "-" +id.substring(20, 32));
//     }
// 
//     public static byte[] toBytes(UUID uuid) {
//         ByteBuffer byteBuffer = ByteBuffer.wrap(new byte[16]);
//         byteBuffer.putLong(uuid.getMostSignificantBits());
//         byteBuffer.putLong(uuid.getLeastSignificantBits());
//         return byteBuffer.array();
//     }
// 
//     public static UUID fromBytes(byte[] array) {
//         if (array.length != 16) {
//             throw new IllegalArgumentException("Illegal byte array length: " + array.length);
//         }
//         ByteBuffer byteBuffer = ByteBuffer.wrap(array);
//         long mostSignificant = byteBuffer.getLong();
//         long leastSignificant = byteBuffer.getLong();
//         return new UUID(mostSignificant, leastSignificant);
//     }
// 
//     public static UUID getUUIDOf(String name) throws Exception {
//         return new UUIDFetcher(Arrays.asList(name)).call().get(name);
//     }
// }
// 
// Path: src/main/java/com/gamingmesh/jobs/util/UUIDUtil.java
// public class UUIDUtil {
//     public static byte[] toBytes(UUID uuid) {
//         ByteBuffer bb = ByteBuffer.allocate(16);
//         bb.putLong(uuid.getMostSignificantBits());
//         bb.putLong(uuid.getLeastSignificantBits());
//         return bb.array();
//     }
// 
//     public static UUID fromBytes(byte[] array) {
//         ByteBuffer bb = ByteBuffer.wrap(array);
//         long most = bb.getLong();
//         long least = bb.getLong();
//         return new UUID(most, least);
//     }
// }


// Path: src/main/java/com/gamingmesh/jobs/dao/JobsDAOMySQL.java
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Map;
import java.util.UUID;
import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.util.UUIDFetcher;
import com.gamingmesh.jobs.util.UUIDUtil;

            prest.setString(2, getPrefix()+"jobs");
            ResultSet res = prest.executeQuery();
            if (res.next()) {
                rows = res.getInt(1);
            }
        } finally {
            if (prest != null) {
                try {
                    prest.close();
                } catch (SQLException e) {}
            }
        }

        PreparedStatement pst1 = null;
        PreparedStatement pst2 = null;
        try {
            if (rows == 0) {
                executeSQL("CREATE TABLE `" + getPrefix() + "jobs` (`id` int NOT NULL AUTO_INCREMENT PRIMARY KEY, `player_uuid` binary(16) NOT NULL, `username` varchar(20), `job` varchar(20), `experience` int, `level` int);");
            } else {
                Jobs.getPluginLogger().info("Converting existing usernames to Mojang UUIDs.  This could take a long time!");
                
                executeSQL("ALTER TABLE `" + getPrefix() + "jobs` ADD COLUMN `id` int NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST;");
                executeSQL("ALTER TABLE `" + getPrefix() + "jobs` ADD COLUMN `player_uuid` binary(16) DEFAULT NULL AFTER `id`;");
                
                pst1 = conn.prepareStatement("SELECT DISTINCT `username` FROM `" + getPrefix() + "jobs` WHERE `player_uuid` IS NULL;");
                ResultSet rs = pst1.executeQuery();
                ArrayList<String> usernames = new ArrayList<String>();
                while (rs.next()) {
                    usernames.add(rs.getString(1));
                }
                UUIDFetcher uuidFetcher = new UUIDFetcher(usernames);