|
|
@ -9,10 +9,13 @@ |
|
|
|
|
|
|
|
|
|
|
|
package engine.db.handlers; |
|
|
|
package engine.db.handlers; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import engine.gameManager.DbManager; |
|
|
|
import engine.objects.BootySetEntry; |
|
|
|
import engine.objects.BootySetEntry; |
|
|
|
import engine.objects.ItemBase; |
|
|
|
import engine.objects.ItemBase; |
|
|
|
import org.pmw.tinylog.Logger; |
|
|
|
import org.pmw.tinylog.Logger; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.sql.Connection; |
|
|
|
|
|
|
|
import java.sql.PreparedStatement; |
|
|
|
import java.sql.ResultSet; |
|
|
|
import java.sql.ResultSet; |
|
|
|
import java.sql.SQLException; |
|
|
|
import java.sql.SQLException; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.ArrayList; |
|
|
@ -26,23 +29,20 @@ public class dbItemBaseHandler extends dbHandlerBase { |
|
|
|
|
|
|
|
|
|
|
|
public void LOAD_BAKEDINSTATS(ItemBase itemBase) { |
|
|
|
public void LOAD_BAKEDINSTATS(ItemBase itemBase) { |
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
try (Connection connection = DbManager.getConnection(); |
|
|
|
prepareCallable("SELECT * FROM `static_item_bakedinstat` WHERE `itemID` = ?"); |
|
|
|
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `static_item_bakedinstat` WHERE `itemID` = ?")) { |
|
|
|
setInt(1, itemBase.getUUID()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ResultSet rs = executeQuery(); |
|
|
|
preparedStatement.setInt(1, itemBase.getUUID()); |
|
|
|
|
|
|
|
ResultSet rs = preparedStatement.executeQuery(); |
|
|
|
|
|
|
|
|
|
|
|
while (rs.next()) { |
|
|
|
while (rs.next()) { |
|
|
|
|
|
|
|
|
|
|
|
if (rs.getBoolean("fromUse")) |
|
|
|
if (rs.getBoolean("fromUse")) |
|
|
|
itemBase.getUsedStats().put(rs.getInt("token"), rs.getInt("numTrains")); |
|
|
|
itemBase.getUsedStats().put(rs.getInt("token"), rs.getInt("numTrains")); |
|
|
|
else |
|
|
|
else |
|
|
|
itemBase.getBakedInStats().put(rs.getInt("token"), rs.getInt("numTrains")); |
|
|
|
itemBase.getBakedInStats().put(rs.getInt("token"), rs.getInt("numTrains")); |
|
|
|
} |
|
|
|
} |
|
|
|
} catch (SQLException e) { |
|
|
|
} catch (SQLException e) { |
|
|
|
Logger.error( e.toString()); |
|
|
|
Logger.error(e); |
|
|
|
} finally { |
|
|
|
|
|
|
|
closeCallable(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -50,27 +50,24 @@ public class dbItemBaseHandler extends dbHandlerBase { |
|
|
|
|
|
|
|
|
|
|
|
ArrayList<Integer> tempList = new ArrayList<>(); |
|
|
|
ArrayList<Integer> tempList = new ArrayList<>(); |
|
|
|
ArrayList<Integer> tempListOff = new ArrayList<>(); |
|
|
|
ArrayList<Integer> tempListOff = new ArrayList<>(); |
|
|
|
try { |
|
|
|
|
|
|
|
prepareCallable("SELECT * FROM `static_itembase_animations` WHERE `itemBaseUUID` = ?"); |
|
|
|
|
|
|
|
setInt(1, itemBase.getUUID()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ResultSet rs = executeQuery(); |
|
|
|
try (Connection connection = DbManager.getConnection(); |
|
|
|
|
|
|
|
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `static_itembase_animations` WHERE `itemBaseUUID` = ?")) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
preparedStatement.setInt(1, itemBase.getUUID()); |
|
|
|
|
|
|
|
ResultSet rs = preparedStatement.executeQuery(); |
|
|
|
|
|
|
|
|
|
|
|
while (rs.next()) { |
|
|
|
while (rs.next()) { |
|
|
|
int animation = rs.getInt("animation"); |
|
|
|
int animation = rs.getInt("animation"); |
|
|
|
|
|
|
|
|
|
|
|
boolean rightHand = rs.getBoolean("rightHand"); |
|
|
|
boolean rightHand = rs.getBoolean("rightHand"); |
|
|
|
|
|
|
|
|
|
|
|
if (rightHand) |
|
|
|
if (rightHand) |
|
|
|
tempList.add(animation); |
|
|
|
tempList.add(animation); |
|
|
|
else |
|
|
|
else |
|
|
|
tempListOff.add(animation); |
|
|
|
tempListOff.add(animation); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} catch (SQLException e) { |
|
|
|
} catch (SQLException e) { |
|
|
|
Logger.error( e.toString()); |
|
|
|
Logger.error(e); |
|
|
|
} finally { |
|
|
|
|
|
|
|
closeCallable(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
itemBase.setAnimations(tempList); |
|
|
|
itemBase.setAnimations(tempList); |
|
|
@ -80,31 +77,24 @@ public class dbItemBaseHandler extends dbHandlerBase { |
|
|
|
public void LOAD_ALL_ITEMBASES() { |
|
|
|
public void LOAD_ALL_ITEMBASES() { |
|
|
|
|
|
|
|
|
|
|
|
ItemBase itemBase; |
|
|
|
ItemBase itemBase; |
|
|
|
|
|
|
|
|
|
|
|
int recordsRead = 0; |
|
|
|
int recordsRead = 0; |
|
|
|
|
|
|
|
|
|
|
|
prepareCallable("SELECT * FROM static_itembase"); |
|
|
|
try (Connection connection = DbManager.getConnection(); |
|
|
|
|
|
|
|
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM static_itembase")) { |
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
ResultSet rs = preparedStatement.executeQuery(); |
|
|
|
ResultSet rs = executeQuery(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
while (rs.next()) { |
|
|
|
while (rs.next()) { |
|
|
|
|
|
|
|
|
|
|
|
recordsRead++; |
|
|
|
recordsRead++; |
|
|
|
itemBase = new ItemBase(rs); |
|
|
|
itemBase = new ItemBase(rs); |
|
|
|
|
|
|
|
|
|
|
|
// Add ItemBase to internal cache
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ItemBase.addToCache(itemBase); |
|
|
|
ItemBase.addToCache(itemBase); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Logger.info( "read: " + recordsRead + "cached: " + ItemBase.getUUIDCache().size()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (SQLException e) { |
|
|
|
} catch (SQLException e) { |
|
|
|
Logger.error( e.toString()); |
|
|
|
Logger.error(e); |
|
|
|
} finally { |
|
|
|
|
|
|
|
closeCallable(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Logger.info("read: " + recordsRead + "cached: " + ItemBase.getUUIDCache().size()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public HashMap<Integer, ArrayList<Integer>> LOAD_RUNES_FOR_NPC_AND_MOBS() { |
|
|
|
public HashMap<Integer, ArrayList<Integer>> LOAD_RUNES_FOR_NPC_AND_MOBS() { |
|
|
@ -114,10 +104,10 @@ public class dbItemBaseHandler extends dbHandlerBase { |
|
|
|
int runeBaseID; |
|
|
|
int runeBaseID; |
|
|
|
int recordsRead = 0; |
|
|
|
int recordsRead = 0; |
|
|
|
|
|
|
|
|
|
|
|
prepareCallable("SELECT * FROM static_npc_runeSet"); |
|
|
|
try (Connection connection = DbManager.getConnection(); |
|
|
|
|
|
|
|
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM static_npc_runeSet")) { |
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
ResultSet rs = preparedStatement.executeQuery(); |
|
|
|
ResultSet rs = executeQuery(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
while (rs.next()) { |
|
|
|
while (rs.next()) { |
|
|
|
|
|
|
|
|
|
|
@ -130,21 +120,19 @@ public class dbItemBaseHandler extends dbHandlerBase { |
|
|
|
ArrayList<Integer> runeList = new ArrayList<>(); |
|
|
|
ArrayList<Integer> runeList = new ArrayList<>(); |
|
|
|
runeList.add(runeBaseID); |
|
|
|
runeList.add(runeBaseID); |
|
|
|
runeSets.put(runeSetID, runeList); |
|
|
|
runeSets.put(runeSetID, runeList); |
|
|
|
} |
|
|
|
} else { |
|
|
|
else{ |
|
|
|
|
|
|
|
ArrayList<Integer> runeList = runeSets.get(runeSetID); |
|
|
|
ArrayList<Integer> runeList = runeSets.get(runeSetID); |
|
|
|
runeList.add(runeSetID); |
|
|
|
runeList.add(runeSetID); |
|
|
|
runeSets.put(runeSetID, runeList); |
|
|
|
runeSets.put(runeSetID, runeList); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Logger.info("read: " + recordsRead + " cached: " + runeSets.size()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (SQLException e) { |
|
|
|
} catch (SQLException e) { |
|
|
|
Logger.error( e.toString()); |
|
|
|
Logger.error(e); |
|
|
|
} finally { |
|
|
|
return runeSets; |
|
|
|
closeCallable(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Logger.info("read: " + recordsRead + " cached: " + runeSets.size()); |
|
|
|
return runeSets; |
|
|
|
return runeSets; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -153,13 +141,12 @@ public class dbItemBaseHandler extends dbHandlerBase { |
|
|
|
HashMap<Integer, ArrayList<BootySetEntry>> bootySets = new HashMap<>(); |
|
|
|
HashMap<Integer, ArrayList<BootySetEntry>> bootySets = new HashMap<>(); |
|
|
|
BootySetEntry bootySetEntry; |
|
|
|
BootySetEntry bootySetEntry; |
|
|
|
int bootySetID; |
|
|
|
int bootySetID; |
|
|
|
|
|
|
|
|
|
|
|
int recordsRead = 0; |
|
|
|
int recordsRead = 0; |
|
|
|
|
|
|
|
|
|
|
|
prepareCallable("SELECT * FROM static_npc_bootySet"); |
|
|
|
try (Connection connection = DbManager.getConnection(); |
|
|
|
|
|
|
|
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM static_npc_bootySet")) { |
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
ResultSet rs = preparedStatement.executeQuery(); |
|
|
|
ResultSet rs = executeQuery(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
while (rs.next()) { |
|
|
|
while (rs.next()) { |
|
|
|
|
|
|
|
|
|
|
@ -172,21 +159,18 @@ public class dbItemBaseHandler extends dbHandlerBase { |
|
|
|
ArrayList<BootySetEntry> bootyList = new ArrayList<>(); |
|
|
|
ArrayList<BootySetEntry> bootyList = new ArrayList<>(); |
|
|
|
bootyList.add(bootySetEntry); |
|
|
|
bootyList.add(bootySetEntry); |
|
|
|
bootySets.put(bootySetID, bootyList); |
|
|
|
bootySets.put(bootySetID, bootyList); |
|
|
|
} |
|
|
|
} else { |
|
|
|
else{ |
|
|
|
|
|
|
|
ArrayList<BootySetEntry> bootyList = bootySets.get(bootySetID); |
|
|
|
ArrayList<BootySetEntry> bootyList = bootySets.get(bootySetID); |
|
|
|
bootyList.add(bootySetEntry); |
|
|
|
bootyList.add(bootySetEntry); |
|
|
|
bootySets.put(bootySetID, bootyList); |
|
|
|
bootySets.put(bootySetID, bootyList); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Logger.info("read: " + recordsRead + " cached: " + bootySets.size()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (SQLException e) { |
|
|
|
} catch (SQLException e) { |
|
|
|
Logger.error( e.toString()); |
|
|
|
Logger.error(e); |
|
|
|
} finally { |
|
|
|
return bootySets; |
|
|
|
closeCallable(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Logger.info("read: " + recordsRead + " cached: " + bootySets.size()); |
|
|
|
return bootySets; |
|
|
|
return bootySets; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|