forked from MagicBane/Server
items PERSIST work.
This commit is contained in:
@@ -55,7 +55,7 @@ public class dbItemHandler extends dbHandlerBase {
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Item ADD_ITEM(Item toAdd) {
|
public Item PERSIST(Item toAdd) {
|
||||||
|
|
||||||
try (Connection connection = DbManager.getConnection();
|
try (Connection connection = DbManager.getConnection();
|
||||||
PreparedStatement preparedStatement = connection.prepareStatement("CALL `item_CREATE`(?, ?, ?, ?, ?, ?, ?, ?, ?,?);")) {
|
PreparedStatement preparedStatement = connection.prepareStatement("CALL `item_CREATE`(?, ?, ?, ?, ?, ?, ?, ?, ?,?);")) {
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ public class MakeItemCmd extends AbstractDevCmd {
|
|||||||
item.setNumOfItems(Warehouse.getMaxResources().get(ibID));
|
item.setNumOfItems(Warehouse.getMaxResources().get(ibID));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
item = DbManager.ItemQueries.ADD_ITEM(item);
|
item = DbManager.ItemQueries.PERSIST(item);
|
||||||
worked = true;
|
worked = true;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throwbackError(pc, "DB error 1: Unable to create item. " + e.getMessage());
|
throwbackError(pc, "DB error 1: Unable to create item. " + e.getMessage());
|
||||||
@@ -214,7 +214,7 @@ public class MakeItemCmd extends AbstractDevCmd {
|
|||||||
item.setNumOfItems(numItems);
|
item.setNumOfItems(numItems);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
item = DbManager.ItemQueries.ADD_ITEM(item);
|
item = DbManager.ItemQueries.PERSIST(item);
|
||||||
worked = true;
|
worked = true;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throwbackError(pc, "DB error 1: Unable to create item. " + e.getMessage());
|
throwbackError(pc, "DB error 1: Unable to create item. " + e.getMessage());
|
||||||
|
|||||||
@@ -833,7 +833,7 @@ public enum BuildingManager {
|
|||||||
item.containerType = Enum.ItemContainerType.INVENTORY;
|
item.containerType = Enum.ItemContainerType.INVENTORY;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
item = DbManager.ItemQueries.ADD_ITEM(item);
|
item = DbManager.ItemQueries.PERSIST(item);
|
||||||
itemWorked = true;
|
itemWorked = true;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Logger.error(e);
|
Logger.error(e);
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ public class OrderNPCMsgHandler extends AbstractClientMsgHandler {
|
|||||||
item.containerType = Enum.ItemContainerType.INVENTORY;
|
item.containerType = Enum.ItemContainerType.INVENTORY;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
item = DbManager.ItemQueries.ADD_ITEM(item);
|
item = DbManager.ItemQueries.PERSIST(item);
|
||||||
itemWorked = true;
|
itemWorked = true;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Logger.error(e);
|
Logger.error(e);
|
||||||
|
|||||||
@@ -52,7 +52,6 @@ public class Item extends AbstractWorldObject {
|
|||||||
public int chargesRemaining;
|
public int chargesRemaining;
|
||||||
private byte equipSlot;
|
private byte equipSlot;
|
||||||
private boolean canDestroy;
|
private boolean canDestroy;
|
||||||
private boolean rentable;
|
|
||||||
private boolean isRandom = false;
|
private boolean isRandom = false;
|
||||||
private int value;
|
private int value;
|
||||||
public OwnerType ownerType;
|
public OwnerType ownerType;
|
||||||
@@ -101,7 +100,6 @@ public class Item extends AbstractWorldObject {
|
|||||||
this.durabilityCurrent = (short) itemBase.getDurability();
|
this.durabilityCurrent = (short) itemBase.getDurability();
|
||||||
this.containerType = containerType;
|
this.containerType = containerType;
|
||||||
this.canDestroy = canDestroy;
|
this.canDestroy = canDestroy;
|
||||||
this.rentable = rentable;
|
|
||||||
this.equipSlot = equipSlot;
|
this.equipSlot = equipSlot;
|
||||||
this.enchants = enchants;
|
this.enchants = enchants;
|
||||||
this.flags = 1;
|
this.flags = 1;
|
||||||
@@ -134,7 +132,6 @@ public class Item extends AbstractWorldObject {
|
|||||||
this.durabilityMax = (short) itemBase.getDurability();
|
this.durabilityMax = (short) itemBase.getDurability();
|
||||||
this.durabilityCurrent = (short) itemBase.getDurability();
|
this.durabilityCurrent = (short) itemBase.getDurability();
|
||||||
this.canDestroy = canDestroy;
|
this.canDestroy = canDestroy;
|
||||||
this.rentable = rentable;
|
|
||||||
this.equipSlot = equipSlot;
|
this.equipSlot = equipSlot;
|
||||||
this.enchants = enchants;
|
this.enchants = enchants;
|
||||||
this.flags = 1;
|
this.flags = 1;
|
||||||
@@ -433,7 +430,7 @@ public class Item extends AbstractWorldObject {
|
|||||||
item.containerType = Enum.ItemContainerType.INVENTORY;
|
item.containerType = Enum.ItemContainerType.INVENTORY;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
item = DbManager.ItemQueries.ADD_ITEM(item);
|
item = DbManager.ItemQueries.PERSIST(item);
|
||||||
itemWorked = true;
|
itemWorked = true;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Logger.error(e);
|
Logger.error(e);
|
||||||
@@ -604,7 +601,7 @@ public class Item extends AbstractWorldObject {
|
|||||||
true, false, Enum.ItemContainerType.INVENTORY, (byte) 0,
|
true, false, Enum.ItemContainerType.INVENTORY, (byte) 0,
|
||||||
new ArrayList<>(), "");
|
new ArrayList<>(), "");
|
||||||
try {
|
try {
|
||||||
item = DbManager.ItemQueries.ADD_ITEM(temp);
|
item = DbManager.ItemQueries.PERSIST(temp);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Logger.error(e);
|
Logger.error(e);
|
||||||
}
|
}
|
||||||
@@ -624,7 +621,7 @@ public class Item extends AbstractWorldObject {
|
|||||||
true, false, Enum.ItemContainerType.BANK, (byte) 0,
|
true, false, Enum.ItemContainerType.BANK, (byte) 0,
|
||||||
new ArrayList<>(), "");
|
new ArrayList<>(), "");
|
||||||
try {
|
try {
|
||||||
item = DbManager.ItemQueries.ADD_ITEM(temp);
|
item = DbManager.ItemQueries.PERSIST(temp);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
}
|
}
|
||||||
return item;
|
return item;
|
||||||
@@ -642,7 +639,7 @@ public class Item extends AbstractWorldObject {
|
|||||||
true, false, Enum.ItemContainerType.INVENTORY, (byte) 0,
|
true, false, Enum.ItemContainerType.INVENTORY, (byte) 0,
|
||||||
new ArrayList<>(), "");
|
new ArrayList<>(), "");
|
||||||
try {
|
try {
|
||||||
item = DbManager.ItemQueries.ADD_ITEM(temp);
|
item = DbManager.ItemQueries.PERSIST(temp);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Logger.error(e);
|
Logger.error(e);
|
||||||
}
|
}
|
||||||
@@ -681,7 +678,7 @@ public class Item extends AbstractWorldObject {
|
|||||||
|
|
||||||
if (persist) {
|
if (persist) {
|
||||||
try {
|
try {
|
||||||
newGold = DbManager.ItemQueries.ADD_ITEM(newGold);
|
newGold = DbManager.ItemQueries.PERSIST(newGold);
|
||||||
if (newGold != null) {
|
if (newGold != null) {
|
||||||
synchronized (newGold) {
|
synchronized (newGold) {
|
||||||
newGold.numberOfItems = 0;
|
newGold.numberOfItems = 0;
|
||||||
@@ -742,7 +739,7 @@ public class Item extends AbstractWorldObject {
|
|||||||
|
|
||||||
if (persist) {
|
if (persist) {
|
||||||
try {
|
try {
|
||||||
newGold = DbManager.ItemQueries.ADD_ITEM(newGold);
|
newGold = DbManager.ItemQueries.PERSIST(newGold);
|
||||||
if (newGold != null) {
|
if (newGold != null) {
|
||||||
synchronized (newGold) {
|
synchronized (newGold) {
|
||||||
newGold.numberOfItems = 0;
|
newGold.numberOfItems = 0;
|
||||||
@@ -834,18 +831,6 @@ public class Item extends AbstractWorldObject {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isOwnerNPC() {
|
|
||||||
return (ownerType == OwnerType.Npc);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isOwnerCharacter() {
|
|
||||||
return (ownerType == OwnerType.PlayerCharacter);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isOwnerAccount() {
|
|
||||||
return (ownerType == OwnerType.Account);
|
|
||||||
}
|
|
||||||
|
|
||||||
public byte getChargesMax() {
|
public byte getChargesMax() {
|
||||||
return chargesMax;
|
return chargesMax;
|
||||||
}
|
}
|
||||||
@@ -862,17 +847,10 @@ public class Item extends AbstractWorldObject {
|
|||||||
return canDestroy;
|
return canDestroy;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isRentable() {
|
|
||||||
return rentable;
|
|
||||||
}
|
|
||||||
|
|
||||||
public byte getEquipSlot() {
|
public byte getEquipSlot() {
|
||||||
return equipSlot;
|
return equipSlot;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArrayList<EnchantmentBase> getEnchants() {
|
|
||||||
return enchants;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getNumOfItems() {
|
public int getNumOfItems() {
|
||||||
return this.numberOfItems;
|
return this.numberOfItems;
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ public class ItemFactory {
|
|||||||
(short) 1, (short) 1, true, false, ItemContainerType.INVENTORY, (byte) 0,
|
(short) 1, (short) 1, true, false, ItemContainerType.INVENTORY, (byte) 0,
|
||||||
new ArrayList<>(), "");
|
new ArrayList<>(), "");
|
||||||
try {
|
try {
|
||||||
item = DbManager.ItemQueries.ADD_ITEM(item);
|
item = DbManager.ItemQueries.PERSIST(item);
|
||||||
worked = true;
|
worked = true;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Logger.error(e);
|
Logger.error(e);
|
||||||
|
|||||||
@@ -120,7 +120,7 @@ public class Kit extends AbstractGameObject {
|
|||||||
new ArrayList<>(), "");
|
new ArrayList<>(), "");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
temp = DbManager.ItemQueries.ADD_ITEM(temp);
|
temp = DbManager.ItemQueries.PERSIST(temp);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Logger.error(e);
|
Logger.error(e);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -149,7 +149,7 @@ public final class MobLoot extends Item {
|
|||||||
item.setNumOfItems(this.getNumOfItems());
|
item.setNumOfItems(this.getNumOfItems());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
item = DbManager.ItemQueries.ADD_ITEM(item);
|
item = DbManager.ItemQueries.PERSIST(item);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Logger.error("e");
|
Logger.error("e");
|
||||||
return null;
|
return null;
|
||||||
@@ -187,7 +187,7 @@ public final class MobLoot extends Item {
|
|||||||
item.setNumOfItems(this.getNumOfItems());
|
item.setNumOfItems(this.getNumOfItems());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
item = DbManager.ItemQueries.ADD_ITEM(item);
|
item = DbManager.ItemQueries.PERSIST(item);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Logger.error(e);
|
Logger.error(e);
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -1198,7 +1198,7 @@ public class PlayerCharacter extends AbstractCharacter {
|
|||||||
Item hair;
|
Item hair;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
hair = DbManager.ItemQueries.ADD_ITEM(tempHair);
|
hair = DbManager.ItemQueries.PERSIST(tempHair);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
hair = null;
|
hair = null;
|
||||||
}
|
}
|
||||||
@@ -1218,7 +1218,7 @@ public class PlayerCharacter extends AbstractCharacter {
|
|||||||
(byte) MBServerStatics.SLOT_BEARDSTYLE, new ArrayList<>(), "");
|
(byte) MBServerStatics.SLOT_BEARDSTYLE, new ArrayList<>(), "");
|
||||||
Item beard;
|
Item beard;
|
||||||
try {
|
try {
|
||||||
beard = DbManager.ItemQueries.ADD_ITEM(tempBeard);
|
beard = DbManager.ItemQueries.PERSIST(tempBeard);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
beard = null;
|
beard = null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -760,7 +760,7 @@ public class Warehouse extends AbstractWorldObject {
|
|||||||
item.containerType = Enum.ItemContainerType.INVENTORY;
|
item.containerType = Enum.ItemContainerType.INVENTORY;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
item = DbManager.ItemQueries.ADD_ITEM(item);
|
item = DbManager.ItemQueries.PERSIST(item);
|
||||||
itemWorked = true;
|
itemWorked = true;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Logger.error(e);
|
Logger.error(e);
|
||||||
@@ -836,7 +836,7 @@ public class Warehouse extends AbstractWorldObject {
|
|||||||
item.containerType = Enum.ItemContainerType.INVENTORY;
|
item.containerType = Enum.ItemContainerType.INVENTORY;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
item = DbManager.ItemQueries.ADD_ITEM(item);
|
item = DbManager.ItemQueries.PERSIST(item);
|
||||||
itemWorked = true;
|
itemWorked = true;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Logger.error(e);
|
Logger.error(e);
|
||||||
|
|||||||
Reference in New Issue
Block a user