Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.foxtrot.utils.tools;
- import java.io.IOException;
- import java.sql.Connection;
- import java.sql.DriverManager;
- import java.sql.PreparedStatement;
- import java.sql.SQLException;
- import com.foxtrot.cache.Cache;
- import com.foxtrot.utils.Utils;
- import com.foxtrot.utils.tools.ItemBonuses;
- /**
- * @author Frosty Teh Snowman
- *
- * Unpacks the Item Bonuses that are packed into the bonuses.ib file.
- */
- public class ItemBonusesLoader {
- public static final void main(String[] args) {
- System.out.println("Loader Started.");
- try {
- Cache.init();
- System.out.println("Cache Initiated.");
- } catch (IOException e) {
- System.out.println("Exception in initializing cache.");
- }
- ItemBonuses.init();
- System.out.println("Item Bonuses Initiated.");
- try {
- try (Connection conn = DriverManager.getConnection("jdbc:mysql://Localhost:3306/Q718?useServerPrepStmts=false&rewriteBatchedStatements=true", "root", "")) {
- try (PreparedStatement preparedStmt = conn.prepareStatement("INSERT INTO item_bonuses (itemId, Astab, Aslash, Acrush, Amagic, Arange, Dstab, Dslash, Dcrush, Dmagic, Drange, Dsummoning, AbsorbMelee, AbsorbMagic, AbsorbRange, Strength, RStrength, PRayer, MagicDamage)" +
- "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)")) {
- for (int itemId = 0; itemId < Utils.getItemDefinitionsSize(); itemId++)
- // int itemId = 6585; //testing loading single item
- {
- System.out.println("Getting Values for item " + itemId);
- int[] bonuses = ItemBonuses.getItemBonuses(itemId);
- preparedStmt.setInt(1, itemId);
- preparedStmt.setInt(2, bonuses[0]);
- preparedStmt.setInt(3, bonuses[1]);
- preparedStmt.setInt(4, bonuses[2]);
- preparedStmt.setInt(5, bonuses[3]);
- preparedStmt.setInt(6, bonuses[4]);
- preparedStmt.setInt(7, bonuses[5]);
- preparedStmt.setInt(8, bonuses[6]);
- preparedStmt.setInt(9, bonuses[7]);
- preparedStmt.setInt(10, bonuses[8]);
- preparedStmt.setInt(11, bonuses[9]);
- preparedStmt.setInt(12, bonuses[10]);
- preparedStmt.setInt(13, bonuses[11]);
- preparedStmt.setInt(14, bonuses[12]);
- preparedStmt.setInt(15, bonuses[13]);
- preparedStmt.setInt(16, bonuses[14]);
- preparedStmt.setInt(17, bonuses[15]);
- preparedStmt.setInt(18, bonuses[16]);
- preparedStmt.setInt(19, bonuses[17]);
- preparedStmt.addBatch();
- }
- System.out.println("executing query");
- preparedStmt.executeBatch();
- System.out.println("finished unpacking");
- }
- }
- }
- catch (NullPointerException npe) {
- System.err.println("Got an exception!");
- System.err.println(npe.getMessage());
- }catch (SQLException e)
- {
- System.err.println("Got an exception!");
- System.err.println(e.getMessage());
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement