forked from MagicBane/Server
More item refactor work.
This commit is contained in:
@@ -47,7 +47,7 @@ public class Item extends AbstractWorldObject {
|
||||
public ReentrantLock lootLock = new ReentrantLock();
|
||||
public int ownerID; //may be character, account, npc, mob
|
||||
private int flags; //1 = isIDed
|
||||
private int numberOfItems;
|
||||
public int numberOfItems;
|
||||
public float durabilityCurrent;
|
||||
public int chargesRemaining;
|
||||
public byte equipSlot;
|
||||
@@ -73,37 +73,8 @@ public class Item extends AbstractWorldObject {
|
||||
this.chargesRemaining = this.template.item_initial_charges;
|
||||
this.durabilityCurrent = this.template.combat_health_full;
|
||||
this.equipSlot = 0;
|
||||
loadEnchantments();
|
||||
bakeInStats();
|
||||
}
|
||||
|
||||
public Item(ItemBase itemBase, int ownerID,
|
||||
OwnerType ownerType, byte chargesMax, byte chargesRemaining,
|
||||
short durabilityCurrent, short durabilityMax, boolean canDestroy,
|
||||
boolean rentable, Enum.ItemContainerType containerType, byte equipSlot,
|
||||
String name) {
|
||||
super();
|
||||
this.templsteID = itemBase.getUUID();
|
||||
this.ownerID = ownerID;
|
||||
this.ownerType = ownerType;
|
||||
|
||||
if (itemBase.getType().getValue() == 20) {
|
||||
this.chargesMax = chargesMax;
|
||||
this.chargesRemaining = chargesRemaining;
|
||||
} else {
|
||||
this.chargesMax = (byte) itemBase.getNumCharges();
|
||||
this.chargesRemaining = (byte) itemBase.getNumCharges();
|
||||
}
|
||||
|
||||
this.durabilityMax = (short) itemBase.getDurability();
|
||||
this.durabilityCurrent = (short) itemBase.getDurability();
|
||||
this.containerType = containerType;
|
||||
this.canDestroy = canDestroy;
|
||||
this.equipSlot = equipSlot;
|
||||
this.flags = 1;
|
||||
this.value = this.magicValue;
|
||||
this.customName = name;
|
||||
|
||||
this.containerType = ItemContainerType.NONE;
|
||||
this.numberOfItems = 1;
|
||||
loadEnchantments();
|
||||
bakeInStats();
|
||||
}
|
||||
|
||||
@@ -25,7 +25,6 @@ import engine.server.MBServerStatics;
|
||||
import org.joda.time.DateTime;
|
||||
import org.pmw.tinylog.Logger;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
|
||||
@@ -57,9 +56,11 @@ public class ItemFactory {
|
||||
break;
|
||||
}
|
||||
|
||||
Item item = new Item(ib, pc.getObjectUUID(), OwnerType.PlayerCharacter, (byte) 0, (byte) 0,
|
||||
(short) 1, (short) 1, true, false, ItemContainerType.INVENTORY, (byte) 0,
|
||||
new ArrayList<>(), "");
|
||||
Item item = new Item(ib.getUUID());
|
||||
item.ownerID = pc.getObjectUUID();
|
||||
item.ownerType = OwnerType.PlayerCharacter;
|
||||
item.containerType = ItemContainerType.INVENTORY;
|
||||
|
||||
try {
|
||||
item = DbManager.ItemQueries.PERSIST(item);
|
||||
worked = true;
|
||||
|
||||
@@ -112,20 +112,20 @@ public class Kit extends AbstractGameObject {
|
||||
*/
|
||||
|
||||
private static boolean kitItemCreator(PlayerCharacter pc, int itemBase, int slot) {
|
||||
ItemBase i = ItemBase.getItemBase(itemBase);
|
||||
|
||||
Item temp = new Item(i, pc.getObjectUUID(),
|
||||
OwnerType.PlayerCharacter, (byte) 0, (byte) 0, (short) 0, (short) 0,
|
||||
false, false, ItemContainerType.EQUIPPED, (byte) slot,
|
||||
new ArrayList<>(), "");
|
||||
Item item = new Item(itemBase);
|
||||
item.ownerID = pc.getObjectUUID();
|
||||
item.ownerType = OwnerType.PlayerCharacter;
|
||||
item.containerType = ItemContainerType.EQUIPPED;
|
||||
item.equipSlot = (byte) slot;
|
||||
|
||||
try {
|
||||
temp = DbManager.ItemQueries.PERSIST(temp);
|
||||
item = DbManager.ItemQueries.PERSIST(item);
|
||||
} catch (Exception e) {
|
||||
Logger.error(e);
|
||||
}
|
||||
|
||||
if (temp == null) {
|
||||
if (item == null) {
|
||||
Logger.info("Ungoof this goof, something is wrong with our kit.");
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -753,11 +753,12 @@ public class Warehouse extends AbstractWorldObject {
|
||||
itemMan.updateInventory();
|
||||
} else {
|
||||
boolean itemWorked = false;
|
||||
Item item = new Item(ib, pc.getObjectUUID(), Enum.OwnerType.PlayerCharacter, (byte) 0, (byte) 0,
|
||||
(short) 1, (short) 1, true, false, Enum.ItemContainerType.INVENTORY, (byte) 0,
|
||||
new ArrayList<>(), "");
|
||||
item.setNumOfItems(amount);
|
||||
|
||||
Item item = new Item(ib.getUUID());
|
||||
item.ownerID = pc.getObjectUUID();
|
||||
item.ownerType = Enum.OwnerType.PlayerCharacter;
|
||||
item.containerType = Enum.ItemContainerType.INVENTORY;
|
||||
item.numberOfItems = amount;
|
||||
|
||||
try {
|
||||
item = DbManager.ItemQueries.PERSIST(item);
|
||||
@@ -829,11 +830,11 @@ public class Warehouse extends AbstractWorldObject {
|
||||
itemMan.updateInventory();
|
||||
} else {
|
||||
boolean itemWorked = false;
|
||||
Item item = new Item(ib, pc.getObjectUUID(), Enum.OwnerType.PlayerCharacter, (byte) 0, (byte) 0,
|
||||
(short) 1, (short) 1, true, false, Enum.ItemContainerType.INVENTORY, (byte) 0,
|
||||
new ArrayList<>(), "");
|
||||
item.setNumOfItems(amount);
|
||||
Item item = new Item(ib.getUUID());
|
||||
item.ownerID = pc.getObjectUUID();
|
||||
item.ownerType = Enum.OwnerType.PlayerCharacter;
|
||||
item.containerType = Enum.ItemContainerType.INVENTORY;
|
||||
item.numberOfItems = amount;
|
||||
|
||||
try {
|
||||
item = DbManager.ItemQueries.PERSIST(item);
|
||||
|
||||
Reference in New Issue
Block a user