Browse Source

items PERSIST work.

combat-2
MagicBot 9 months ago
parent
commit
ec90ef6174
  1. 2
      src/engine/db/handlers/dbItemHandler.java
  2. 4
      src/engine/devcmd/cmds/MakeItemCmd.java
  3. 2
      src/engine/gameManager/BuildingManager.java
  4. 2
      src/engine/net/client/handlers/OrderNPCMsgHandler.java
  5. 34
      src/engine/objects/Item.java
  6. 2
      src/engine/objects/ItemFactory.java
  7. 2
      src/engine/objects/Kit.java
  8. 4
      src/engine/objects/MobLoot.java
  9. 4
      src/engine/objects/PlayerCharacter.java
  10. 4
      src/engine/objects/Warehouse.java

2
src/engine/db/handlers/dbItemHandler.java

@ -55,7 +55,7 @@ public class dbItemHandler extends dbHandlerBase { @@ -55,7 +55,7 @@ public class dbItemHandler extends dbHandlerBase {
return ret;
}
public Item ADD_ITEM(Item toAdd) {
public Item PERSIST(Item toAdd) {
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("CALL `item_CREATE`(?, ?, ?, ?, ?, ?, ?, ?, ?,?);")) {

4
src/engine/devcmd/cmds/MakeItemCmd.java

@ -57,7 +57,7 @@ public class MakeItemCmd extends AbstractDevCmd { @@ -57,7 +57,7 @@ public class MakeItemCmd extends AbstractDevCmd {
item.setNumOfItems(Warehouse.getMaxResources().get(ibID));
try {
item = DbManager.ItemQueries.ADD_ITEM(item);
item = DbManager.ItemQueries.PERSIST(item);
worked = true;
} catch (Exception e) {
throwbackError(pc, "DB error 1: Unable to create item. " + e.getMessage());
@ -214,7 +214,7 @@ public class MakeItemCmd extends AbstractDevCmd { @@ -214,7 +214,7 @@ public class MakeItemCmd extends AbstractDevCmd {
item.setNumOfItems(numItems);
try {
item = DbManager.ItemQueries.ADD_ITEM(item);
item = DbManager.ItemQueries.PERSIST(item);
worked = true;
} catch (Exception e) {
throwbackError(pc, "DB error 1: Unable to create item. " + e.getMessage());

2
src/engine/gameManager/BuildingManager.java

@ -833,7 +833,7 @@ public enum BuildingManager { @@ -833,7 +833,7 @@ public enum BuildingManager {
item.containerType = Enum.ItemContainerType.INVENTORY;
try {
item = DbManager.ItemQueries.ADD_ITEM(item);
item = DbManager.ItemQueries.PERSIST(item);
itemWorked = true;
} catch (Exception e) {
Logger.error(e);

2
src/engine/net/client/handlers/OrderNPCMsgHandler.java

@ -73,7 +73,7 @@ public class OrderNPCMsgHandler extends AbstractClientMsgHandler { @@ -73,7 +73,7 @@ public class OrderNPCMsgHandler extends AbstractClientMsgHandler {
item.containerType = Enum.ItemContainerType.INVENTORY;
try {
item = DbManager.ItemQueries.ADD_ITEM(item);
item = DbManager.ItemQueries.PERSIST(item);
itemWorked = true;
} catch (Exception e) {
Logger.error(e);

34
src/engine/objects/Item.java

@ -52,7 +52,6 @@ public class Item extends AbstractWorldObject { @@ -52,7 +52,6 @@ public class Item extends AbstractWorldObject {
public int chargesRemaining;
private byte equipSlot;
private boolean canDestroy;
private boolean rentable;
private boolean isRandom = false;
private int value;
public OwnerType ownerType;
@ -101,7 +100,6 @@ public class Item extends AbstractWorldObject { @@ -101,7 +100,6 @@ public class Item extends AbstractWorldObject {
this.durabilityCurrent = (short) itemBase.getDurability();
this.containerType = containerType;
this.canDestroy = canDestroy;
this.rentable = rentable;
this.equipSlot = equipSlot;
this.enchants = enchants;
this.flags = 1;
@ -134,7 +132,6 @@ public class Item extends AbstractWorldObject { @@ -134,7 +132,6 @@ public class Item extends AbstractWorldObject {
this.durabilityMax = (short) itemBase.getDurability();
this.durabilityCurrent = (short) itemBase.getDurability();
this.canDestroy = canDestroy;
this.rentable = rentable;
this.equipSlot = equipSlot;
this.enchants = enchants;
this.flags = 1;
@ -433,7 +430,7 @@ public class Item extends AbstractWorldObject { @@ -433,7 +430,7 @@ public class Item extends AbstractWorldObject {
item.containerType = Enum.ItemContainerType.INVENTORY;
try {
item = DbManager.ItemQueries.ADD_ITEM(item);
item = DbManager.ItemQueries.PERSIST(item);
itemWorked = true;
} catch (Exception e) {
Logger.error(e);
@ -604,7 +601,7 @@ public class Item extends AbstractWorldObject { @@ -604,7 +601,7 @@ public class Item extends AbstractWorldObject {
true, false, Enum.ItemContainerType.INVENTORY, (byte) 0,
new ArrayList<>(), "");
try {
item = DbManager.ItemQueries.ADD_ITEM(temp);
item = DbManager.ItemQueries.PERSIST(temp);
} catch (Exception e) {
Logger.error(e);
}
@ -624,7 +621,7 @@ public class Item extends AbstractWorldObject { @@ -624,7 +621,7 @@ public class Item extends AbstractWorldObject {
true, false, Enum.ItemContainerType.BANK, (byte) 0,
new ArrayList<>(), "");
try {
item = DbManager.ItemQueries.ADD_ITEM(temp);
item = DbManager.ItemQueries.PERSIST(temp);
} catch (Exception e) {
}
return item;
@ -642,7 +639,7 @@ public class Item extends AbstractWorldObject { @@ -642,7 +639,7 @@ public class Item extends AbstractWorldObject {
true, false, Enum.ItemContainerType.INVENTORY, (byte) 0,
new ArrayList<>(), "");
try {
item = DbManager.ItemQueries.ADD_ITEM(temp);
item = DbManager.ItemQueries.PERSIST(temp);
} catch (Exception e) {
Logger.error(e);
}
@ -681,7 +678,7 @@ public class Item extends AbstractWorldObject { @@ -681,7 +678,7 @@ public class Item extends AbstractWorldObject {
if (persist) {
try {
newGold = DbManager.ItemQueries.ADD_ITEM(newGold);
newGold = DbManager.ItemQueries.PERSIST(newGold);
if (newGold != null) {
synchronized (newGold) {
newGold.numberOfItems = 0;
@ -742,7 +739,7 @@ public class Item extends AbstractWorldObject { @@ -742,7 +739,7 @@ public class Item extends AbstractWorldObject {
if (persist) {
try {
newGold = DbManager.ItemQueries.ADD_ITEM(newGold);
newGold = DbManager.ItemQueries.PERSIST(newGold);
if (newGold != null) {
synchronized (newGold) {
newGold.numberOfItems = 0;
@ -834,18 +831,6 @@ public class Item extends AbstractWorldObject { @@ -834,18 +831,6 @@ public class Item extends AbstractWorldObject {
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() {
return chargesMax;
}
@ -862,17 +847,10 @@ public class Item extends AbstractWorldObject { @@ -862,17 +847,10 @@ public class Item extends AbstractWorldObject {
return canDestroy;
}
public boolean isRentable() {
return rentable;
}
public byte getEquipSlot() {
return equipSlot;
}
public ArrayList<EnchantmentBase> getEnchants() {
return enchants;
}
public int getNumOfItems() {
return this.numberOfItems;

2
src/engine/objects/ItemFactory.java

@ -61,7 +61,7 @@ public class ItemFactory { @@ -61,7 +61,7 @@ public class ItemFactory {
(short) 1, (short) 1, true, false, ItemContainerType.INVENTORY, (byte) 0,
new ArrayList<>(), "");
try {
item = DbManager.ItemQueries.ADD_ITEM(item);
item = DbManager.ItemQueries.PERSIST(item);
worked = true;
} catch (Exception e) {
Logger.error(e);

2
src/engine/objects/Kit.java

@ -120,7 +120,7 @@ public class Kit extends AbstractGameObject { @@ -120,7 +120,7 @@ public class Kit extends AbstractGameObject {
new ArrayList<>(), "");
try {
temp = DbManager.ItemQueries.ADD_ITEM(temp);
temp = DbManager.ItemQueries.PERSIST(temp);
} catch (Exception e) {
Logger.error(e);
}

4
src/engine/objects/MobLoot.java

@ -149,7 +149,7 @@ public final class MobLoot extends Item { @@ -149,7 +149,7 @@ public final class MobLoot extends Item {
item.setNumOfItems(this.getNumOfItems());
try {
item = DbManager.ItemQueries.ADD_ITEM(item);
item = DbManager.ItemQueries.PERSIST(item);
} catch (Exception e) {
Logger.error("e");
return null;
@ -187,7 +187,7 @@ public final class MobLoot extends Item { @@ -187,7 +187,7 @@ public final class MobLoot extends Item {
item.setNumOfItems(this.getNumOfItems());
try {
item = DbManager.ItemQueries.ADD_ITEM(item);
item = DbManager.ItemQueries.PERSIST(item);
} catch (Exception e) {
Logger.error(e);
return null;

4
src/engine/objects/PlayerCharacter.java

@ -1198,7 +1198,7 @@ public class PlayerCharacter extends AbstractCharacter { @@ -1198,7 +1198,7 @@ public class PlayerCharacter extends AbstractCharacter {
Item hair;
try {
hair = DbManager.ItemQueries.ADD_ITEM(tempHair);
hair = DbManager.ItemQueries.PERSIST(tempHair);
} catch (Exception e) {
hair = null;
}
@ -1218,7 +1218,7 @@ public class PlayerCharacter extends AbstractCharacter { @@ -1218,7 +1218,7 @@ public class PlayerCharacter extends AbstractCharacter {
(byte) MBServerStatics.SLOT_BEARDSTYLE, new ArrayList<>(), "");
Item beard;
try {
beard = DbManager.ItemQueries.ADD_ITEM(tempBeard);
beard = DbManager.ItemQueries.PERSIST(tempBeard);
} catch (Exception e) {
beard = null;
}

4
src/engine/objects/Warehouse.java

@ -760,7 +760,7 @@ public class Warehouse extends AbstractWorldObject { @@ -760,7 +760,7 @@ public class Warehouse extends AbstractWorldObject {
item.containerType = Enum.ItemContainerType.INVENTORY;
try {
item = DbManager.ItemQueries.ADD_ITEM(item);
item = DbManager.ItemQueries.PERSIST(item);
itemWorked = true;
} catch (Exception e) {
Logger.error(e);
@ -836,7 +836,7 @@ public class Warehouse extends AbstractWorldObject { @@ -836,7 +836,7 @@ public class Warehouse extends AbstractWorldObject {
item.containerType = Enum.ItemContainerType.INVENTORY;
try {
item = DbManager.ItemQueries.ADD_ITEM(item);
item = DbManager.ItemQueries.PERSIST(item);
itemWorked = true;
} catch (Exception e) {
Logger.error(e);

Loading…
Cancel
Save