Search in sources :

Example 26 with NBTTagCompound

use of net.minecraft.server.v1_13_R2.NBTTagCompound in project MyPet by xXKeyleXx.

the class ItemStackComparator method compareTagData.

public static boolean compareTagData(ItemStack i1, ItemStack i2) {
    if (i1 == null || i2 == null) {
        return false;
    }
    if (i1.hasItemMeta() && i2.hasItemMeta()) {
        NBTTagCompound tag1 = CraftItemStack.asNMSCopy(i1).getTag();
        NBTTagCompound tag2 = CraftItemStack.asNMSCopy(i2).getTag();
        if (tag1 != null) {
            if (tag1.equals(tag2)) {
                return true;
            } else {
                i1 = CraftItemStack.asBukkitCopy(CraftItemStack.asNMSCopy(i1));
                tag1 = CraftItemStack.asNMSCopy(i1).getTag();
                return tag1.equals(tag2);
            }
        }
        return false;
    }
    return i1.hasItemMeta() == i2.hasItemMeta();
}
Also used : NBTTagCompound(net.minecraft.server.v1_16_R3.NBTTagCompound)

Example 27 with NBTTagCompound

use of net.minecraft.server.v1_13_R2.NBTTagCompound in project MyMaid2 by jaoafa.

the class Jail method JailAdd.

/**
 * Jailに理由つきでプレイヤーを追加
 * @param cmd コマンド情報
 * @param player オフラインのプレイヤー
 * @param banned_by 追加したプレイヤー
 * @param reason 理由
 * @return 実行できたかどうか
 * @author mine_book000
 * @throws SQLException
 * @throws NullPointerException
 * @throws ClassNotFoundException
 * @throws EscapeJailException
 */
public static boolean JailAdd(OfflinePlayer player, CommandSender banned_by, String reason) throws ClassNotFoundException, NullPointerException, SQLException, EscapeJailException {
    if (player == null) {
        banned_by.sendMessage("[JAIL] " + ChatColor.GREEN + "指定されたプレイヤーは見つかりません。");
        try {
            throw new java.lang.NullPointerException("JailAdd OfflinePlayer is null...!");
        } catch (java.lang.NullPointerException e) {
            BugReporter(e);
        }
        return false;
    }
    if (banned_by instanceof Player) {
        Player banned_by_player = (Player) banned_by;
        Pointjao pointjao = new Pointjao(banned_by_player);
        if (!pointjao.has(REQUIRED_jao)) {
            // 所持していない
            banned_by.sendMessage("[JAIL] " + ChatColor.GREEN + "あなたはJailするためのjaoポイントが足りません。");
            return true;
        }
    }
    if (Jail.contains(player.getUniqueId().toString())) {
        // 既に牢獄にいるので無理
        banned_by.sendMessage("[JAIL] " + ChatColor.GREEN + "指定されたプレイヤーはすでに牢獄にいるため追加できません。");
        return false;
    }
    // Item Check
    if (player.isOnline()) {
        Boolean EscapeFlag = false;
        Player target = player.getPlayer();
        PlayerInventory inv = target.getInventory();
        for (int n = 0; n < inv.getSize(); n++) {
            ItemStack is = inv.getItem(n);
            if (is == null) {
                continue;
            }
            if (is.getType() == Material.AIR) {
                continue;
            }
            net.minecraft.server.v1_12_R1.ItemStack nms = CraftItemStack.asNMSCopy(is);
            NBTTagCompound nbttag = nms.getTag();
            if (nbttag == null) {
                continue;
            }
            String id = nbttag.getString("MyMaid_EscapeJailID");
            if (id == null) {
                continue;
            } else if (id.equals("")) {
                continue;
            }
            PreparedStatement statement = MySQL.getNewPreparedStatement("SELECT * FROM uniqueitem WHERE id = ? AND type = ?");
            statement.setString(1, id);
            statement.setString(2, "MyMaid_EscapeJailID");
            ResultSet res = statement.executeQuery();
            if (res.next()) {
                // ある
                if (res.getBoolean("used")) {
                    // 使ってる
                    nbttag.remove("MyMaid_EscapeJailID");
                    nms.setTag(nbttag);
                    is = CraftItemStack.asBukkitCopy(nms);
                    ItemMeta meta = is.getItemMeta();
                    meta.setDisplayName(meta.getDisplayName() + ChatColor.RED + " [使用済]");
                    is.setItemMeta(meta);
                    inv.setItem(n, is);
                    continue;
                }
            } else {
                // ない
                nbttag.remove("MyMaid_EscapeJailID");
                nms.setTag(nbttag);
                is = CraftItemStack.asBukkitCopy(nms);
                ItemMeta meta = is.getItemMeta();
                meta.setDisplayName(meta.getDisplayName() + ChatColor.RED + " [無効]");
                is.setItemMeta(meta);
                inv.setItem(n, is);
                continue;
            }
            // 使ってない
            PreparedStatement statement_disable = MySQL.getNewPreparedStatement("UPDATE uniqueitem SET used = ? WHERE id = ? AND type = ?");
            statement_disable.setBoolean(1, true);
            statement_disable.setString(2, id);
            statement_disable.setString(3, "MyMaid_EscapeJailID");
            statement_disable.executeUpdate();
            nbttag.remove("MyMaid_EscapeJailID");
            nms.setTag(nbttag);
            is = CraftItemStack.asBukkitCopy(nms);
            ItemMeta meta = is.getItemMeta();
            meta.setDisplayName(meta.getDisplayName() + ChatColor.RED + " [使用済]");
            is.setItemMeta(meta);
            inv.setItem(n, is);
            EscapeFlag = true;
            break;
        }
        target.updateInventory();
        if (EscapeFlag) {
            if (banned_by instanceof Player) {
                Player banned_by_player = (Player) banned_by;
                Pointjao pointjao = new Pointjao(banned_by_player);
                pointjao.use(REQUIRED_jao, player.getName() + "をJailに追加しようとしたため。(理由: " + reason + " | EscapeJailによって失敗)");
            }
            throw new EscapeJailException();
        }
    }
    Jail.add(player.getUniqueId().toString());
    // 設置破壊不可
    block.put(player.getUniqueId().toString(), false);
    // 範囲外移動
    area.put(player.getUniqueId().toString(), false);
    // まだ遺言を残してない
    lasttext.put(player.getUniqueId().toString(), false);
    SimpleDateFormat allsdf = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
    try {
        PreparedStatement statement = MySQL.getNewPreparedStatement("INSERT INTO jail (player, uuid, banned_by, reason, date) VALUES (?, ?, ?, ?, ?)");
        statement.setString(1, player.getName());
        statement.setString(2, player.getUniqueId().toString());
        statement.setString(3, banned_by.getName());
        statement.setString(4, reason);
        statement.setString(5, allsdf.format(new Date()));
        statement.executeUpdate();
    } catch (SQLException | ClassNotFoundException e) {
        BugReporter(e);
    }
    try {
        PreparedStatement statement = MySQL.getNewPreparedStatement("INSERT INTO banlist (player, uuid, type, bannedby, reason, time) VALUES (?, ?, ?, ?, ?, ?)");
        statement.setString(1, player.getName());
        statement.setString(2, player.getUniqueId().toString());
        statement.setString(3, "jail");
        statement.setString(4, banned_by.getName());
        statement.setString(5, reason);
        statement.setString(6, allsdf.format(new Date()));
        statement.executeUpdate();
    } catch (SQLException | ClassNotFoundException e) {
        BugReporter(e);
    }
    Bukkit.broadcastMessage("[JAIL] " + ChatColor.GREEN + "プレイヤー:「" + player.getName() + "」を「" + reason + "」という理由で牢獄リストに追加しました。");
    DiscordSend("223582668132974594", "***Jail[追加]***: プレイヤー「" + player.getName() + "」が「" + banned_by.getName() + "」によって「" + reason + "」という理由でJailリストに追加されました。");
    if (banned_by instanceof Player) {
        Player banned_by_player = (Player) banned_by;
        Pointjao pointjao = new Pointjao(banned_by_player);
        pointjao.use(REQUIRED_jao, player.getName() + "をJailに追加したため。(理由: " + reason + ")");
    }
    JailBackupSaveTxt(player.getName(), JailType.ADD, banned_by.getName(), reason);
    return true;
}
Also used : Player(org.bukkit.entity.Player) OfflinePlayer(org.bukkit.OfflinePlayer) SQLException(java.sql.SQLException) NBTTagCompound(net.minecraft.server.v1_12_R1.NBTTagCompound) PreparedStatement(java.sql.PreparedStatement) PlayerInventory(org.bukkit.inventory.PlayerInventory) Date(java.util.Date) ResultSet(java.sql.ResultSet) CraftItemStack(org.bukkit.craftbukkit.v1_12_R1.inventory.CraftItemStack) ItemStack(org.bukkit.inventory.ItemStack) SimpleDateFormat(java.text.SimpleDateFormat) ItemMeta(org.bukkit.inventory.meta.ItemMeta)

Example 28 with NBTTagCompound

use of net.minecraft.server.v1_13_R2.NBTTagCompound in project MyMaid2 by jaoafa.

the class Jail method JailAdd.

/**
 * Jailにプレイヤーを追加
 * @param cmd コマンド情報
 * @param player オフラインのプレイヤー
 * @param banned_by 追加したプレイヤー
 * @return 実行できたかどうか
 * @author mine_book000
 * @throws SQLException
 * @throws NullPointerException
 * @throws ClassNotFoundException
 * @throws EscapeJailException
 */
@Deprecated
public static boolean JailAdd(OfflinePlayer player, CommandSender banned_by) throws ClassNotFoundException, NullPointerException, SQLException, EscapeJailException {
    if (player == null) {
        banned_by.sendMessage("[JAIL] " + ChatColor.GREEN + "指定されたプレイヤーは見つかりません。");
        try {
            throw new java.lang.NullPointerException("JailAdd OfflinePlayer is null...!");
        } catch (java.lang.NullPointerException e) {
            BugReporter(e);
        }
        return false;
    }
    if (banned_by instanceof Player) {
        Player banned_by_player = (Player) banned_by;
        Pointjao pointjao = new Pointjao(banned_by_player);
        if (!pointjao.has(REQUIRED_jao)) {
            // 所持していない
            banned_by.sendMessage("[JAIL] " + ChatColor.GREEN + "あなたはJailするためのjaoポイントが足りません。");
            return true;
        }
    }
    if (Jail.contains(player.getUniqueId().toString())) {
        // 既に牢獄にいるので無理
        banned_by.sendMessage("[JAIL] " + ChatColor.GREEN + "指定されたプレイヤーはすでに牢獄にいるため追加できません。");
        return false;
    }
    // Item Check
    if (player.isOnline()) {
        Boolean EscapeFlag = false;
        Player target = player.getPlayer();
        PlayerInventory inv = target.getInventory();
        for (int n = 0; n < inv.getSize(); n++) {
            ItemStack is = inv.getItem(n);
            if (is == null) {
                continue;
            }
            if (is.getType() == Material.AIR) {
                continue;
            }
            net.minecraft.server.v1_12_R1.ItemStack nms = CraftItemStack.asNMSCopy(is);
            NBTTagCompound nbttag = nms.getTag();
            if (nbttag == null) {
                continue;
            }
            String id = nbttag.getString("MyMaid_EscapeJailID");
            if (id == null) {
                continue;
            } else if (id.equals("")) {
                continue;
            }
            PreparedStatement statement = MySQL.getNewPreparedStatement("SELECT * FROM uniqueitem WHERE id = ? AND type = ?");
            statement.setString(1, id);
            statement.setString(2, "MyMaid_EscapeJailID");
            ResultSet res = statement.executeQuery();
            if (res.next()) {
                // ある
                if (res.getBoolean("used")) {
                    // 使ってる
                    nbttag.remove("MyMaid_EscapeJailID");
                    nms.setTag(nbttag);
                    is = CraftItemStack.asBukkitCopy(nms);
                    ItemMeta meta = is.getItemMeta();
                    meta.setDisplayName(meta.getDisplayName() + ChatColor.RED + " [使用済]");
                    is.setItemMeta(meta);
                    inv.setItem(n, is);
                    continue;
                }
            } else {
                // ない
                nbttag.remove("MyMaid_EscapeJailID");
                nms.setTag(nbttag);
                is = CraftItemStack.asBukkitCopy(nms);
                ItemMeta meta = is.getItemMeta();
                meta.setDisplayName(meta.getDisplayName() + ChatColor.RED + " [無効]");
                is.setItemMeta(meta);
                inv.setItem(n, is);
                continue;
            }
            // 使ってない
            PreparedStatement statement_disable = MySQL.getNewPreparedStatement("UPDATE uniqueitem SET used = ? WHERE id = ? AND type = ?");
            statement_disable.setBoolean(1, true);
            statement_disable.setString(2, id);
            statement_disable.setString(3, "MyMaid_EscapeJailID");
            statement_disable.executeUpdate();
            nbttag.remove("MyMaid_EscapeJailID");
            nms.setTag(nbttag);
            is = CraftItemStack.asBukkitCopy(nms);
            ItemMeta meta = is.getItemMeta();
            meta.setDisplayName(meta.getDisplayName() + ChatColor.RED + " [使用済]");
            is.setItemMeta(meta);
            inv.setItem(n, is);
            EscapeFlag = true;
            break;
        }
        target.updateInventory();
        if (EscapeFlag) {
            if (banned_by instanceof Player) {
                Player banned_by_player = (Player) banned_by;
                Pointjao pointjao = new Pointjao(banned_by_player);
                pointjao.use(REQUIRED_jao, player.getName() + "をJailに追加しようとしたため。(EscapeJailによって失敗)");
            }
            throw new EscapeJailException();
        }
    }
    Jail.add(player.getUniqueId().toString());
    // 設置破壊不可
    block.put(player.getUniqueId().toString(), false);
    // 範囲外移動
    area.put(player.getUniqueId().toString(), false);
    // まだ遺言を残してない
    lasttext.put(player.getUniqueId().toString(), false);
    // データベース登録なし
    Bukkit.broadcastMessage("[JAIL] " + ChatColor.GREEN + "プレイヤー:「" + player.getName() + "」を牢獄リストに追加しました。");
    DiscordSend("223582668132974594", "***Jail[追加]***: プレイヤー「" + player.getName() + "」が「" + banned_by.getName() + "」によってJailリストに追加されました。");
    if (banned_by instanceof Player) {
        Player banned_by_player = (Player) banned_by;
        Pointjao pointjao = new Pointjao(banned_by_player);
        pointjao.use(REQUIRED_jao, player.getName() + "をJailに追加したため。");
    }
    JailBackupSaveTxt(player.getName(), JailType.ADD, banned_by.getName(), "");
    return true;
}
Also used : Player(org.bukkit.entity.Player) OfflinePlayer(org.bukkit.OfflinePlayer) NBTTagCompound(net.minecraft.server.v1_12_R1.NBTTagCompound) PreparedStatement(java.sql.PreparedStatement) PlayerInventory(org.bukkit.inventory.PlayerInventory) ResultSet(java.sql.ResultSet) CraftItemStack(org.bukkit.craftbukkit.v1_12_R1.inventory.CraftItemStack) ItemStack(org.bukkit.inventory.ItemStack) ItemMeta(org.bukkit.inventory.meta.ItemMeta)

Example 29 with NBTTagCompound

use of net.minecraft.server.v1_13_R2.NBTTagCompound in project MyMaid2 by jaoafa.

the class Jail method JailAdd.

/**
 * Jailにプレイヤーを追加
 * @param cmd コマンド情報
 * @param player プレイヤー
 * @param banned_by 追加したプレイヤー
 * @return 実行できたかどうか
 * @author mine_book000
 * @throws SQLException
 * @throws NullPointerException
 * @throws ClassNotFoundException
 * @throws EscapeJailException
 */
@Deprecated
public static boolean JailAdd(Player player, CommandSender banned_by) throws ClassNotFoundException, NullPointerException, SQLException, EscapeJailException {
    if (player == null) {
        banned_by.sendMessage("[JAIL] " + ChatColor.GREEN + "指定されたプレイヤーは見つかりません。");
        try {
            throw new java.lang.NullPointerException("JailAdd Player is null...!");
        } catch (java.lang.NullPointerException e) {
            BugReporter(e);
        }
        return false;
    }
    if (banned_by instanceof Player) {
        Player banned_by_player = (Player) banned_by;
        Pointjao pointjao = new Pointjao(banned_by_player);
        if (!pointjao.has(REQUIRED_jao)) {
            // 所持していない
            banned_by.sendMessage("[JAIL] " + ChatColor.GREEN + "あなたはJailするためのjaoポイントが足りません。");
            return true;
        }
    }
    if (Jail.contains(player.getUniqueId().toString())) {
        // 既に牢獄にいるので無理
        banned_by.sendMessage("[JAIL] " + ChatColor.GREEN + "指定されたプレイヤーはすでに牢獄にいるため追加できません。");
        return false;
    }
    // Item Check
    if (player.isOnline()) {
        Boolean EscapeFlag = false;
        Player target = player.getPlayer();
        PlayerInventory inv = target.getInventory();
        for (int n = 0; n < inv.getSize(); n++) {
            ItemStack is = inv.getItem(n);
            if (is == null) {
                continue;
            }
            if (is.getType() == Material.AIR) {
                continue;
            }
            net.minecraft.server.v1_12_R1.ItemStack nms = CraftItemStack.asNMSCopy(is);
            NBTTagCompound nbttag = nms.getTag();
            if (nbttag == null) {
                continue;
            }
            String id = nbttag.getString("MyMaid_EscapeJailID");
            if (id == null) {
                continue;
            } else if (id.equals("")) {
                continue;
            }
            PreparedStatement statement = MySQL.getNewPreparedStatement("SELECT * FROM uniqueitem WHERE id = ? AND type = ?");
            statement.setString(1, id);
            statement.setString(2, "MyMaid_EscapeJailID");
            ResultSet res = statement.executeQuery();
            if (res.next()) {
                // ある
                if (res.getBoolean("used")) {
                    // 使ってる
                    nbttag.remove("MyMaid_EscapeJailID");
                    nms.setTag(nbttag);
                    is = CraftItemStack.asBukkitCopy(nms);
                    ItemMeta meta = is.getItemMeta();
                    meta.setDisplayName(meta.getDisplayName() + ChatColor.RED + " [使用済]");
                    is.setItemMeta(meta);
                    inv.setItem(n, is);
                    continue;
                }
            } else {
                // ない
                nbttag.remove("MyMaid_EscapeJailID");
                nms.setTag(nbttag);
                is = CraftItemStack.asBukkitCopy(nms);
                ItemMeta meta = is.getItemMeta();
                meta.setDisplayName(meta.getDisplayName() + ChatColor.RED + " [無効]");
                is.setItemMeta(meta);
                inv.setItem(n, is);
                continue;
            }
            // 使ってない
            PreparedStatement statement_disable = MySQL.getNewPreparedStatement("UPDATE uniqueitem SET used = ? WHERE id = ? AND type = ?");
            statement_disable.setBoolean(1, true);
            statement_disable.setString(2, id);
            statement_disable.setString(3, "MyMaid_EscapeJailID");
            statement_disable.executeUpdate();
            nbttag.remove("MyMaid_EscapeJailID");
            nms.setTag(nbttag);
            is = CraftItemStack.asBukkitCopy(nms);
            ItemMeta meta = is.getItemMeta();
            meta.setDisplayName(meta.getDisplayName() + ChatColor.RED + " [使用済]");
            is.setItemMeta(meta);
            inv.setItem(n, is);
            EscapeFlag = true;
            break;
        }
        target.updateInventory();
        if (EscapeFlag) {
            if (banned_by instanceof Player) {
                Player banned_by_player = (Player) banned_by;
                Pointjao pointjao = new Pointjao(banned_by_player);
                pointjao.use(REQUIRED_jao, player.getName() + "をJailに追加しようとしたため。(EscapeJailによって失敗)");
            }
            throw new EscapeJailException();
        }
    }
    Jail.add(player.getUniqueId().toString());
    // 設置破壊不可
    block.put(player.getUniqueId().toString(), false);
    // 範囲外移動
    area.put(player.getUniqueId().toString(), false);
    // まだ遺言を残してない
    lasttext.put(player.getUniqueId().toString(), false);
    if (player.getGameMode() == GameMode.SPECTATOR)
        player.setGameMode(GameMode.CREATIVE);
    World Jao_Afa = Bukkit.getServer().getWorld("Jao_Afa");
    Location minami = new Location(Jao_Afa, 2856, 69, 2888);
    // テレポート
    player.teleport(minami);
    SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
    player.sendMessage(ChatColor.GRAY + "[" + sdf.format(new Date()) + "]" + ChatColor.GOLD + "■jaotan" + ChatColor.WHITE + ": " + "やあ。" + player.getName() + "クン。どうも君はなにかをして南の楽園に来てしまったみたいなんだ");
    player.sendMessage(ChatColor.GRAY + "[" + sdf.format(new Date()) + "]" + ChatColor.GOLD + "■jaotan" + ChatColor.WHITE + ": " + "なにをしてしまったのは知らないけどなにかをしたからここに来たんだと思うんだ。");
    player.sendMessage(ChatColor.GRAY + "[" + sdf.format(new Date()) + "]" + ChatColor.GOLD + "■jaotan" + ChatColor.WHITE + ": " + "ちょっとやったことを反省してみるのもいいかもしれないね");
    player.sendMessage(ChatColor.GRAY + "[" + sdf.format(new Date()) + "]" + ChatColor.GOLD + "■jaotan" + ChatColor.WHITE + ": " + "あ、そうだ、今の君に人権はないよ。");
    player.sendMessage(ChatColor.GRAY + "[" + sdf.format(new Date()) + "]" + ChatColor.GOLD + "■jaotan" + ChatColor.WHITE + ": " + "あと、「/testment <LastText>」で遺言を残せるよ!");
    // データベース登録なし
    Bukkit.broadcastMessage("[JAIL] " + ChatColor.GREEN + "プレイヤー:「" + player.getName() + "」を牢獄リストに追加しました。");
    DiscordSend("223582668132974594", "***Jail[追加]***: プレイヤー「" + player.getName() + "」が「" + banned_by.getName() + "」によってJailリストに追加されました。");
    if (banned_by instanceof Player) {
        Player banned_by_player = (Player) banned_by;
        Pointjao pointjao = new Pointjao(banned_by_player);
        pointjao.use(REQUIRED_jao, player.getName() + "をJailに追加したため。");
    }
    JailBackupSaveTxt(player.getName(), JailType.ADD, banned_by.getName(), "");
    return true;
}
Also used : Player(org.bukkit.entity.Player) OfflinePlayer(org.bukkit.OfflinePlayer) NBTTagCompound(net.minecraft.server.v1_12_R1.NBTTagCompound) PreparedStatement(java.sql.PreparedStatement) PlayerInventory(org.bukkit.inventory.PlayerInventory) World(org.bukkit.World) Date(java.util.Date) ResultSet(java.sql.ResultSet) CraftItemStack(org.bukkit.craftbukkit.v1_12_R1.inventory.CraftItemStack) ItemStack(org.bukkit.inventory.ItemStack) SimpleDateFormat(java.text.SimpleDateFormat) ItemMeta(org.bukkit.inventory.meta.ItemMeta) Location(org.bukkit.Location)

Example 30 with NBTTagCompound

use of net.minecraft.server.v1_13_R2.NBTTagCompound in project MyMaid2 by jaoafa.

the class Event_Antijaoium method setjaoiumItemData.

private void setjaoiumItemData(Player player, ItemStack is) {
    if (ItemData.containsKey(player.getName()))
        return;
    YamlConfiguration yaml = new YamlConfiguration();
    yaml.set("data", is);
    StringBuilder builder = new StringBuilder();
    // "/give @p <アイテム> "
    builder.append("/give @p splash_potion ");
    // "/give @p <アイテム> [個数]"
    builder.append(is.getAmount());
    // "/give @p <アイテム> [個数] "
    builder.append(" ");
    // "/give @p <アイテム> [個数] [データ]"
    builder.append(is.getDurability());
    net.minecraft.server.v1_12_R1.ItemStack nmsItem = CraftItemStack.asNMSCopy(is);
    NBTTagCompound nbttag = nmsItem.getTag();
    if (nbttag != null) {
        // "/give @p <アイテム> [個数] [データ] "
        builder.append(" ");
        // "/give @p <アイテム> [個数] [データ] [データタグ]"
        builder.append(nbttag.toString());
    }
    String command = builder.toString();
    yaml.set("command", command);
    String code = yaml.saveToString();
    String name = "MyMaid2 Antijaoium jaoium ItemData & Command";
    try {
        PreparedStatement statement = MySQL.getNewPreparedStatement("INSERT INTO cmd (player, uuid, title, command) VALUES (?, ?, ?, ?);", Statement.RETURN_GENERATED_KEYS);
        statement.setString(1, player.getName());
        statement.setString(2, player.getUniqueId().toString());
        statement.setString(3, name);
        statement.setString(4, code);
        statement.executeUpdate();
        ResultSet res = statement.getGeneratedKeys();
        if (res == null || !res.next()) {
            throw new IllegalStateException();
        }
        int id = res.getInt(1);
        ItemData.put(player.getName(), "https://jaoafa.com/cmd/" + id);
    } catch (SQLException | ClassNotFoundException e) {
        ItemData.put(player.getName(), "null");
    }
}
Also used : SQLException(java.sql.SQLException) NBTTagCompound(net.minecraft.server.v1_12_R1.NBTTagCompound) PreparedStatement(java.sql.PreparedStatement) YamlConfiguration(org.bukkit.configuration.file.YamlConfiguration) ResultSet(java.sql.ResultSet)

Aggregations

NBTTagCompound (net.minecraft.server.v1_12_R1.NBTTagCompound)69 ItemStack (org.bukkit.inventory.ItemStack)60 Map (java.util.Map)41 NBTTagCompound (net.minecraft.server.v1_16_R3.NBTTagCompound)39 NBTTagCompound (net.minecraft.server.v1_8_R3.NBTTagCompound)38 ArrayList (java.util.ArrayList)37 ItemMeta (org.bukkit.inventory.meta.ItemMeta)35 CraftItemStack (org.bukkit.craftbukkit.v1_12_R1.inventory.CraftItemStack)33 CompoundTag (com.wasteofplastic.org.jnbt.CompoundTag)30 ListTag (com.wasteofplastic.org.jnbt.ListTag)30 StringTag (com.wasteofplastic.org.jnbt.StringTag)30 Tag (com.wasteofplastic.org.jnbt.Tag)30 NBTTagCompound (net.minecraft.server.v1_16_R2.NBTTagCompound)24 Nullable (javax.annotation.Nullable)21 NBTTagCompound (net.minecraft.server.v1_9_R2.NBTTagCompound)21 NBTTagCompound (net.minecraft.server.v1_10_R1.NBTTagCompound)20 NBTTagCompound (net.minecraft.server.v1_11_R1.NBTTagCompound)20 CraftItemStack (org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack)20 NBTTagList (net.minecraft.server.v1_12_R1.NBTTagList)19 NBTTagCompound (net.minecraft.server.v1_15_R1.NBTTagCompound)18