Refactor to remove abstraction.
This commit is contained in:
@@ -89,18 +89,19 @@ public class dbItemHandler extends dbHandlerBase {
|
|||||||
|
|
||||||
public String GET_OWNER(int ownerID) {
|
public String GET_OWNER(int ownerID) {
|
||||||
|
|
||||||
String ownerType = "";
|
String ownerType;
|
||||||
|
|
||||||
try (Connection connection = DbManager.getConnection();
|
try (Connection connection = DbManager.getConnection();
|
||||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT `type` FROM `object` WHERE `UID`=?")) {
|
PreparedStatement preparedStatement = connection.prepareStatement("SELECT `type` FROM `object` WHERE `UID`=?")) {
|
||||||
|
|
||||||
preparedStatement.setInt(1, ownerID);
|
preparedStatement.setInt(1, ownerID);
|
||||||
|
|
||||||
ResultSet rs = preparedStatement.executeQuery();
|
ResultSet rs = preparedStatement.executeQuery();
|
||||||
|
|
||||||
ownerType = rs.getString("type");
|
ownerType = rs.getString("type");
|
||||||
|
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
Logger.error(e);
|
Logger.error(e);
|
||||||
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
return ownerType;
|
return ownerType;
|
||||||
@@ -112,6 +113,7 @@ public class dbItemHandler extends dbHandlerBase {
|
|||||||
|
|
||||||
AbstractCharacter ac1 = man1.getOwner();
|
AbstractCharacter ac1 = man1.getOwner();
|
||||||
AbstractCharacter ac2 = man2.getOwner();
|
AbstractCharacter ac2 = man2.getOwner();
|
||||||
|
boolean worked = false;
|
||||||
|
|
||||||
if (ac1 == null || ac2 == null || inventoryGold1 == null || inventoryGold2 == null)
|
if (ac1 == null || ac2 == null || inventoryGold1 == null || inventoryGold2 == null)
|
||||||
return false;
|
return false;
|
||||||
@@ -130,12 +132,14 @@ public class dbItemHandler extends dbHandlerBase {
|
|||||||
|
|
||||||
ResultSet rs = preparedStatement.executeQuery();
|
ResultSet rs = preparedStatement.executeQuery();
|
||||||
|
|
||||||
return rs.getBoolean("result");
|
if (rs.next())
|
||||||
|
worked = rs.getBoolean("result");
|
||||||
|
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
Logger.error(e);
|
Logger.error(e);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
return worked;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String formatTradeString(HashSet<Integer> list) {
|
private static String formatTradeString(HashSet<Integer> list) {
|
||||||
@@ -159,139 +163,254 @@ public class dbItemHandler extends dbHandlerBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ArrayList<Item> GET_EQUIPPED_ITEMS(final int targetId) {
|
public ArrayList<Item> GET_EQUIPPED_ITEMS(final int targetId) {
|
||||||
prepareCallable("SELECT `obj_item`.*, `object`.`parent`, `object`.`type` FROM `object` INNER JOIN `obj_item` ON `object`.`UID` = `obj_item`.`UID` WHERE `object`.`parent`=? && `obj_item`.`item_container`='equip';");
|
|
||||||
setLong(1, (long) targetId);
|
ArrayList<Item> itemList;
|
||||||
return getObjectList();
|
|
||||||
|
try (Connection connection = DbManager.getConnection();
|
||||||
|
PreparedStatement preparedStatement = connection.prepareStatement("SELECT `obj_item`.*, `object`.`parent`, `object`.`type` FROM `object` INNER JOIN `obj_item` ON `object`.`UID` = `obj_item`.`UID` WHERE `object`.`parent`=? && `obj_item`.`item_container`='equip';")) {
|
||||||
|
|
||||||
|
preparedStatement.setLong(1, (long) targetId);
|
||||||
|
ResultSet rs = preparedStatement.executeQuery();
|
||||||
|
|
||||||
|
itemList = getObjectsFromRs(rs, 50);
|
||||||
|
|
||||||
|
} catch (SQLException e) {
|
||||||
|
Logger.error(e);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return itemList;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Item GET_ITEM(final int id) {
|
public Item GET_ITEM(final int itemUUID) {
|
||||||
|
|
||||||
|
Item item;
|
||||||
|
|
||||||
prepareCallable("SELECT `obj_item`.*, `object`.`parent`, `object`.`type` FROM `object` INNER JOIN `obj_item` ON `object`.`UID` = `obj_item`.`UID` WHERE `object`.`UID`=?;");
|
try (Connection connection = DbManager.getConnection();
|
||||||
setLong(1, (long) id);
|
PreparedStatement preparedStatement = connection.prepareStatement("SELECT `obj_item`.*, `object`.`parent`, `object`.`type` FROM `object` INNER JOIN `obj_item` ON `object`.`UID` = `obj_item`.`UID` WHERE `object`.`UID`=?;")) {
|
||||||
return (Item) getObjectSingle(id);
|
|
||||||
|
preparedStatement.setLong(1, itemUUID);
|
||||||
|
ResultSet rs = preparedStatement.executeQuery();
|
||||||
|
|
||||||
|
item = (Item) getObjectFromRs(rs);
|
||||||
|
|
||||||
|
} catch (SQLException e) {
|
||||||
|
Logger.error(e);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArrayList<Item> GET_ITEMS_FOR_ACCOUNT(final int accountId) {
|
public ArrayList<Item> GET_ITEMS_FOR_ACCOUNT(final int accountId) {
|
||||||
prepareCallable("SELECT `obj_item`.*, `object`.`parent`, `object`.`type` FROM `object` INNER JOIN `obj_item` ON `object`.`UID` = `obj_item`.`UID` WHERE `object`.`parent`=?;");
|
|
||||||
setLong(1, (long) accountId);
|
ArrayList<Item> itemList;
|
||||||
return getObjectList();
|
|
||||||
|
try (Connection connection = DbManager.getConnection();
|
||||||
|
PreparedStatement preparedStatement = connection.prepareStatement("SELECT `obj_item`.*, `object`.`parent`, `object`.`type` FROM `object` INNER JOIN `obj_item` ON `object`.`UID` = `obj_item`.`UID` WHERE `object`.`parent`=?;")) {
|
||||||
|
|
||||||
|
preparedStatement.setLong(1, (long) accountId);
|
||||||
|
ResultSet rs = preparedStatement.executeQuery();
|
||||||
|
|
||||||
|
itemList = getObjectsFromRs(rs, 100);
|
||||||
|
|
||||||
|
} catch (SQLException e) {
|
||||||
|
Logger.error(e);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return itemList;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArrayList<Item> GET_ITEMS_FOR_NPC(final int npcId) {
|
public ArrayList<Item> GET_ITEMS_FOR_NPC(final int npcId) {
|
||||||
prepareCallable("SELECT `obj_item`.*, `object`.`parent`, `object`.`type` FROM `object` INNER JOIN `obj_item` ON `object`.`UID` = `obj_item`.`UID` WHERE `object`.`parent`=?");
|
|
||||||
setLong(1, (long) npcId);
|
ArrayList<Item> itemList;
|
||||||
return getObjectList();
|
|
||||||
|
try (Connection connection = DbManager.getConnection();
|
||||||
|
PreparedStatement preparedStatement = connection.prepareStatement("SELECT `obj_item`.*, `object`.`parent`, `object`.`type` FROM `object` INNER JOIN `obj_item` ON `object`.`UID` = `obj_item`.`UID` WHERE `object`.`parent`=?;")) {
|
||||||
|
|
||||||
|
preparedStatement.setLong(1, npcId);
|
||||||
|
ResultSet rs = preparedStatement.executeQuery();
|
||||||
|
|
||||||
|
itemList = getObjectsFromRs(rs, 20);
|
||||||
|
|
||||||
|
} catch (SQLException e) {
|
||||||
|
Logger.error(e);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return itemList;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArrayList<Item> GET_ITEMS_FOR_PC(final int id) {
|
public ArrayList<Item> GET_ITEMS_FOR_PC(final int id) {
|
||||||
prepareCallable("SELECT `obj_item`.*, `object`.`parent`, `object`.`type` FROM `object` INNER JOIN `obj_item` ON `object`.`UID` = `obj_item`.`UID` WHERE `object`.`parent`=?");
|
|
||||||
setLong(1, (long) id);
|
ArrayList<Item> itemList;
|
||||||
return getLargeObjectList();
|
|
||||||
|
try (Connection connection = DbManager.getConnection();
|
||||||
|
PreparedStatement preparedStatement = connection.prepareStatement("SELECT `obj_item`.*, `object`.`parent`, `object`.`type` FROM `object` INNER JOIN `obj_item` ON `object`.`UID` = `obj_item`.`UID` WHERE `object`.`parent`=?")) {
|
||||||
|
|
||||||
|
preparedStatement.setLong(1, (long) id);
|
||||||
|
ResultSet rs = preparedStatement.executeQuery();
|
||||||
|
|
||||||
|
itemList = getObjectsFromRs(rs, 100);
|
||||||
|
|
||||||
|
} catch (SQLException e) {
|
||||||
|
Logger.error(e);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return itemList;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean MOVE_GOLD(final Item from, final Item to, final int amt) {
|
public boolean MOVE_GOLD(final Item from, final Item to, final int amt) {
|
||||||
int newFromAmt = from.getNumOfItems() - amt;
|
|
||||||
int newToAmt = to.getNumOfItems() + amt;
|
try (Connection connection = DbManager.getConnection();
|
||||||
prepareCallable("UPDATE `obj_item` SET `item_numberOfItems` = CASE WHEN `UID`=? THEN ? WHEN `UID`=? THEN ? END WHERE `UID` IN (?, ?);");
|
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_item` SET `item_numberOfItems` = CASE WHEN `UID`=? THEN ? WHEN `UID`=? THEN ? END WHERE `UID` IN (?, ?);")) {
|
||||||
setLong(1, (long) from.getObjectUUID());
|
|
||||||
setInt(2, newFromAmt);
|
int newFromAmt = from.getNumOfItems() - amt;
|
||||||
setLong(3, (long) to.getObjectUUID());
|
int newToAmt = to.getNumOfItems() + amt;
|
||||||
setInt(4, newToAmt);
|
|
||||||
setLong(5, (long) from.getObjectUUID());
|
preparedStatement.setLong(1, (long) from.getObjectUUID());
|
||||||
setLong(6, (long) to.getObjectUUID());
|
preparedStatement.setInt(2, newFromAmt);
|
||||||
return (executeUpdate() != 0);
|
preparedStatement.setLong(3, (long) to.getObjectUUID());
|
||||||
|
preparedStatement.setInt(4, newToAmt);
|
||||||
|
preparedStatement.setLong(5, (long) from.getObjectUUID());
|
||||||
|
preparedStatement.setLong(6, (long) to.getObjectUUID());
|
||||||
|
|
||||||
|
return (preparedStatement.executeUpdate() > 0);
|
||||||
|
|
||||||
|
} catch (SQLException e) {
|
||||||
|
Logger.error(e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean ORPHAN_INVENTORY(final HashSet<Item> inventory) {
|
public boolean ORPHAN_INVENTORY(final HashSet<Item> inventory) {
|
||||||
|
|
||||||
boolean worked = true;
|
boolean worked = true;
|
||||||
|
|
||||||
for (Item item : inventory) {
|
for (Item item : inventory) {
|
||||||
|
|
||||||
if (item.getItemBase().getType().equals(ItemType.GOLD))
|
if (item.getItemBase().getType().equals(ItemType.GOLD))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
prepareCallable("UPDATE `obj_item` LEFT JOIN `object` ON `object`.`UID` = `obj_item`.`UID` SET `object`.`parent`=NULL, `obj_item`.`item_container`='none' WHERE `object`.`UID`=?;");
|
try (Connection connection = DbManager.getConnection();
|
||||||
setLong(1, (long) item.getObjectUUID());
|
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_item` LEFT JOIN `object` ON `object`.`UID` = `obj_item`.`UID` SET `object`.`parent`=NULL, `obj_item`.`item_container`='none' WHERE `object`.`UID`=?;")) {
|
||||||
if (executeUpdate() == 0)
|
|
||||||
worked = false;
|
preparedStatement.setLong(1, (long) item.getObjectUUID());
|
||||||
else
|
worked = (preparedStatement.executeUpdate() > 0);
|
||||||
item.zeroItem();
|
|
||||||
|
if (worked)
|
||||||
|
item.zeroItem();
|
||||||
|
|
||||||
|
} catch (SQLException e) {
|
||||||
|
Logger.error(e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return worked;
|
return worked;
|
||||||
}
|
}
|
||||||
|
|
||||||
public HashSet<Integer> GET_ITEMS_FOR_VENDOR(final int vendorID) {
|
public HashSet<Integer> GET_ITEMS_FOR_VENDOR(final int vendorID) {
|
||||||
prepareCallable("SELECT ID FROM static_itembase WHERE vendorType = ?");
|
|
||||||
setInt(1, vendorID);
|
|
||||||
return getIntegerList(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
public String SET_PROPERTY(final Item i, String name, Object new_value) {
|
HashSet<Integer> itemSet = new HashSet<>();
|
||||||
prepareCallable("CALL item_SETPROP(?,?,?)");
|
|
||||||
setLong(1, (long) i.getObjectUUID());
|
|
||||||
setString(2, name);
|
|
||||||
setString(3, String.valueOf(new_value));
|
|
||||||
return getResult();
|
|
||||||
}
|
|
||||||
|
|
||||||
public String SET_PROPERTY(final Item i, String name, Object new_value, Object old_value) {
|
try (Connection connection = DbManager.getConnection();
|
||||||
prepareCallable("CALL item_GETSETPROP(?,?,?,?)");
|
PreparedStatement preparedStatement = connection.prepareStatement("SELECT ID FROM static_itembase WHERE vendorType = ?")) {
|
||||||
setLong(1, (long) i.getObjectUUID());
|
|
||||||
setString(2, name);
|
preparedStatement.setInt(1, vendorID);
|
||||||
setString(3, String.valueOf(new_value));
|
|
||||||
setString(4, String.valueOf(old_value));
|
ResultSet rs = preparedStatement.executeQuery();
|
||||||
return getResult();
|
|
||||||
|
while (rs.next())
|
||||||
|
itemSet.add(rs.getInt(1));
|
||||||
|
|
||||||
|
} catch (SQLException e) {
|
||||||
|
Logger.error(e);
|
||||||
|
return itemSet;
|
||||||
|
}
|
||||||
|
|
||||||
|
return itemSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Used to transfer a single item between owners or equip or vault or bank or inventory
|
//Used to transfer a single item between owners or equip or vault or bank or inventory
|
||||||
public boolean UPDATE_OWNER(final Item item, int newOwnerID, boolean ownerNPC, boolean ownerPlayer,
|
public boolean UPDATE_OWNER(final Item item, int newOwnerID, boolean ownerNPC, boolean ownerPlayer,
|
||||||
boolean ownerAccount, ItemContainerType containerType, int slot) {
|
boolean ownerAccount, ItemContainerType containerType, int slot) {
|
||||||
|
|
||||||
prepareCallable("CALL `item_TRANSFER_OWNER`(?, ?, ?, ? )");
|
boolean worked = false;
|
||||||
setLong(1, (long) item.getObjectUUID());
|
|
||||||
if (newOwnerID != 0)
|
try (Connection connection = DbManager.getConnection();
|
||||||
setLong(2, (long) newOwnerID);
|
PreparedStatement preparedStatement = connection.prepareStatement("CALL `item_TRANSFER_OWNER`(?, ?, ?, ? )")) {
|
||||||
else
|
|
||||||
setNULL(2, java.sql.Types.BIGINT);
|
preparedStatement.setLong(1, item.getObjectUUID());
|
||||||
|
|
||||||
switch (containerType) {
|
if (newOwnerID != 0)
|
||||||
case INVENTORY:
|
preparedStatement.setLong(2, newOwnerID);
|
||||||
setString(3, "inventory");
|
else
|
||||||
break;
|
preparedStatement.setNull(2, java.sql.Types.BIGINT);
|
||||||
case EQUIPPED:
|
|
||||||
setString(3, "equip");
|
switch (containerType) {
|
||||||
break;
|
case INVENTORY:
|
||||||
case BANK:
|
preparedStatement.setString(3, "inventory");
|
||||||
setString(3, "bank");
|
break;
|
||||||
break;
|
case EQUIPPED:
|
||||||
case VAULT:
|
preparedStatement.setString(3, "equip");
|
||||||
setString(3, "vault");
|
break;
|
||||||
break;
|
case BANK:
|
||||||
case FORGE:
|
preparedStatement.setString(3, "bank");
|
||||||
setString(3, "forge");
|
break;
|
||||||
break;
|
case VAULT:
|
||||||
default:
|
preparedStatement.setString(3, "vault");
|
||||||
setString(3, "none"); //Shouldn't be here
|
break;
|
||||||
break;
|
case FORGE:
|
||||||
|
preparedStatement.setString(3, "forge");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
preparedStatement.setString(3, "none"); //Shouldn't be here
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
preparedStatement.setInt(4, slot);
|
||||||
|
ResultSet rs = preparedStatement.executeQuery();
|
||||||
|
|
||||||
|
if (rs.next())
|
||||||
|
worked = rs.getBoolean("result");
|
||||||
|
|
||||||
|
} catch (SQLException e) {
|
||||||
|
Logger.error(e);
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
setInt(4, slot);
|
return worked;
|
||||||
return worked();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean SET_DURABILITY(final Item item, int value) {
|
public boolean SET_DURABILITY(final Item item, int value) {
|
||||||
prepareCallable("UPDATE `obj_item` SET `item_durabilityCurrent`=? WHERE `UID`=? AND `item_durabilityCurrent`=?");
|
|
||||||
setInt(1, value);
|
|
||||||
setLong(2, (long) item.getObjectUUID());
|
|
||||||
setInt(3, (int) item.getDurabilityCurrent());
|
|
||||||
return (executeUpdate() != 0);
|
|
||||||
|
|
||||||
|
try (Connection connection = DbManager.getConnection();
|
||||||
|
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_item` SET `item_durabilityCurrent`=? WHERE `UID`=? AND `item_durabilityCurrent`=?")) {
|
||||||
|
|
||||||
|
preparedStatement.setInt(1, value);
|
||||||
|
preparedStatement.setLong(2, (long) item.getObjectUUID());
|
||||||
|
preparedStatement.setInt(3, (int) item.getDurabilityCurrent());
|
||||||
|
|
||||||
|
return (preparedStatement.executeUpdate() > 0);
|
||||||
|
|
||||||
|
} catch (SQLException e) {
|
||||||
|
Logger.error(e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean UPDATE_FORGE_TO_INVENTORY(final Item item) {
|
public boolean UPDATE_FORGE_TO_INVENTORY(final Item item) {
|
||||||
prepareCallable("UPDATE `obj_item` SET `item_container` = ? WHERE `UID` = ? AND `item_container` = 'forge';");
|
|
||||||
setString(1, "inventory");
|
try (Connection connection = DbManager.getConnection();
|
||||||
setLong(2, (long) item.getObjectUUID());
|
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_item` SET `item_container` = ? WHERE `UID` = ? AND `item_container` = 'forge';")) {
|
||||||
return (executeUpdate() != 0);
|
|
||||||
|
preparedStatement.setString(1, "inventory");
|
||||||
|
preparedStatement.setLong(2, (long) item.getObjectUUID());
|
||||||
|
|
||||||
|
return (preparedStatement.executeUpdate() > 0);
|
||||||
|
|
||||||
|
} catch (SQLException e) {
|
||||||
|
Logger.error(e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -313,43 +432,88 @@ public class dbItemHandler extends dbHandlerBase {
|
|||||||
*/
|
*/
|
||||||
public boolean UPDATE_GOLD(final Item item, int newValue, int oldValue) {
|
public boolean UPDATE_GOLD(final Item item, int newValue, int oldValue) {
|
||||||
|
|
||||||
if (item.getItemBase().getType().equals(ItemType.GOLD) == false)
|
if (!item.getItemBase().getType().equals(ItemType.GOLD))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
prepareCallable("UPDATE `obj_item` SET `item_numberOfItems`=? WHERE `UID`=?");
|
try (Connection connection = DbManager.getConnection();
|
||||||
setInt(1, newValue);
|
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_item` SET `item_numberOfItems`=? WHERE `UID`=?")) {
|
||||||
setLong(2, (long) item.getObjectUUID());
|
|
||||||
return (executeUpdate() != 0);
|
preparedStatement.setInt(1, newValue);
|
||||||
|
preparedStatement.setLong(2, (long) item.getObjectUUID());
|
||||||
|
|
||||||
|
return (preparedStatement.executeUpdate() > 0);
|
||||||
|
|
||||||
|
} catch (SQLException e) {
|
||||||
|
Logger.error(e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean UPDATE_REMAINING_CHARGES(final Item item) {
|
public boolean UPDATE_REMAINING_CHARGES(final Item item) {
|
||||||
prepareCallable("UPDATE `obj_item` SET `item_chargesRemaining` = ? WHERE `UID` = ?");
|
|
||||||
setInt(1, item.getChargesRemaining());
|
try (Connection connection = DbManager.getConnection();
|
||||||
setLong(2, (long) item.getObjectUUID());
|
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_item` SET `item_chargesRemaining` = ? WHERE `UID` = ?")) {
|
||||||
return (executeUpdate() != 0);
|
|
||||||
|
preparedStatement.setInt(1, item.getChargesRemaining());
|
||||||
|
preparedStatement.setLong(2, (long) item.getObjectUUID());
|
||||||
|
|
||||||
|
return (preparedStatement.executeUpdate() > 0);
|
||||||
|
|
||||||
|
} catch (SQLException e) {
|
||||||
|
Logger.error(e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is necessary because default number of items is 1.
|
// This is necessary because default number of items is 1.
|
||||||
// When we create gold, we want it to start at 0 quantity.
|
// When we create gold, we want it to start at 0 quantity.
|
||||||
|
|
||||||
public boolean ZERO_ITEM_STACK(Item item) {
|
public boolean ZERO_ITEM_STACK(Item item) {
|
||||||
prepareCallable("UPDATE `obj_item` SET `item_numberOfItems`=0 WHERE `UID` = ?");
|
|
||||||
setLong(1, (long) item.getObjectUUID());
|
try (Connection connection = DbManager.getConnection();
|
||||||
return (executeUpdate() != 0);
|
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_item` SET `item_numberOfItems`=0 WHERE `UID` = ?")) {
|
||||||
|
|
||||||
|
preparedStatement.setLong(1, (long) item.getObjectUUID());
|
||||||
|
|
||||||
|
return (preparedStatement.executeUpdate() > 0);
|
||||||
|
|
||||||
|
} catch (SQLException e) {
|
||||||
|
Logger.error(e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean UPDATE_FLAGS(Item item) {
|
public boolean UPDATE_FLAGS(Item item) {
|
||||||
prepareCallable("UPDATE `obj_item` SET `item_flags`=? WHERE `UID` = ?");
|
|
||||||
setInt(1, item.getFlags());
|
try (Connection connection = DbManager.getConnection();
|
||||||
setLong(2, (long) item.getObjectUUID());
|
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_item` SET `item_flags`=? WHERE `UID` = ?")) {
|
||||||
return (executeUpdate() != 0);
|
|
||||||
|
preparedStatement.setInt(1, item.getFlags());
|
||||||
|
preparedStatement.setLong(2, (long) item.getObjectUUID());
|
||||||
|
|
||||||
|
return (preparedStatement.executeUpdate() > 0);
|
||||||
|
|
||||||
|
} catch (SQLException e) {
|
||||||
|
Logger.error(e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean UPDATE_VALUE(Item item,int value) {
|
public boolean UPDATE_VALUE(Item item,int value) {
|
||||||
prepareCallable("UPDATE `obj_item` SET `item_value`=? WHERE `UID` = ?");
|
|
||||||
setInt(1, value);
|
|
||||||
setLong(2, (long) item.getObjectUUID());
|
|
||||||
return (executeUpdate() != 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
try (Connection connection = DbManager.getConnection();
|
||||||
|
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_item` SET `item_value`=? WHERE `UID` = ?")) {
|
||||||
|
|
||||||
|
preparedStatement.setInt(1, value);
|
||||||
|
preparedStatement.setLong(2, (long) item.getObjectUUID());
|
||||||
|
|
||||||
|
return (preparedStatement.executeUpdate() > 0);
|
||||||
|
|
||||||
|
} catch (SQLException e) {
|
||||||
|
Logger.error(e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user