MagicBot
8 months ago
5 changed files with 0 additions and 114 deletions
@ -1,51 +0,0 @@
@@ -1,51 +0,0 @@
|
||||
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||
// Magicbane Emulator Project © 2013 - 2022
|
||||
// www.magicbane.com
|
||||
|
||||
|
||||
package engine.db.handlers; |
||||
|
||||
import engine.gameManager.DbManager; |
||||
import engine.objects.ItemBase; |
||||
import org.pmw.tinylog.Logger; |
||||
|
||||
import java.sql.Connection; |
||||
import java.sql.PreparedStatement; |
||||
import java.sql.ResultSet; |
||||
import java.sql.SQLException; |
||||
|
||||
public class dbItemBaseHandler extends dbHandlerBase { |
||||
|
||||
public dbItemBaseHandler() { |
||||
|
||||
} |
||||
|
||||
public void LOAD_ALL_ITEMBASES() { |
||||
|
||||
ItemBase itemBase; |
||||
int recordsRead = 0; |
||||
|
||||
try (Connection connection = DbManager.getConnection(); |
||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM static_itembase")) { |
||||
|
||||
ResultSet rs = preparedStatement.executeQuery(); |
||||
|
||||
while (rs.next()) { |
||||
recordsRead++; |
||||
itemBase = new ItemBase(rs); |
||||
|
||||
ItemBase.addToCache(itemBase); |
||||
} |
||||
|
||||
} catch (SQLException e) { |
||||
Logger.error(e); |
||||
} |
||||
|
||||
Logger.info("read: " + recordsRead + " cached: " + ItemBase.getUUIDCache().size()); |
||||
} |
||||
|
||||
} |
@ -1,55 +0,0 @@
@@ -1,55 +0,0 @@
|
||||
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||
// Magicbane Emulator Project © 2013 - 2022
|
||||
// www.magicbane.com
|
||||
|
||||
|
||||
package engine.objects; |
||||
|
||||
import engine.gameManager.DbManager; |
||||
import org.pmw.tinylog.Logger; |
||||
|
||||
import java.sql.ResultSet; |
||||
import java.sql.SQLException; |
||||
import java.util.HashMap; |
||||
|
||||
public class ItemBase { |
||||
|
||||
public static ItemBase GOLD_ITEM_BASE = null; |
||||
public static HashMap<Integer, ItemBase> _itemBaseByUUID = new HashMap<>(); |
||||
|
||||
public final int uuid; |
||||
|
||||
public ItemBase(ResultSet rs) throws SQLException { |
||||
|
||||
this.uuid = rs.getInt("ID"); |
||||
|
||||
} |
||||
|
||||
public static void addToCache(ItemBase itemBase) { |
||||
|
||||
_itemBaseByUUID.put(itemBase.uuid, itemBase); |
||||
|
||||
ItemTemplate template = ItemTemplate.templates.get(itemBase.uuid); |
||||
|
||||
if (template == null) |
||||
Logger.error("Null template for: " + itemBase.uuid); |
||||
} |
||||
|
||||
public static HashMap<Integer, ItemBase> getUUIDCache() { |
||||
return _itemBaseByUUID; |
||||
} |
||||
|
||||
public static void loadAllItemBases() { |
||||
DbManager.ItemBaseQueries.LOAD_ALL_ITEMBASES(); |
||||
} |
||||
|
||||
|
||||
public final int getUUID() { |
||||
return uuid; |
||||
} |
||||
|
||||
} |
Loading…
Reference in new issue