forked from MagicBane/Server
Begin constructor refactor
This commit is contained in:
@@ -61,9 +61,9 @@ public class dbItemHandler extends dbHandlerBase {
|
|||||||
PreparedStatement preparedStatement = connection.prepareStatement("CALL `item_CREATE`(?, ?, ?, ?, ?, ?, ?, ?, ?,?);")) {
|
PreparedStatement preparedStatement = connection.prepareStatement("CALL `item_CREATE`(?, ?, ?, ?, ?, ?, ?, ?, ?,?);")) {
|
||||||
|
|
||||||
preparedStatement.setInt(1, toAdd.getOwnerID());
|
preparedStatement.setInt(1, toAdd.getOwnerID());
|
||||||
preparedStatement.setInt(2, toAdd.getItemBaseID());
|
preparedStatement.setInt(2, toAdd.getTemplsteID());
|
||||||
preparedStatement.setInt(3, toAdd.getChargesRemaining());
|
preparedStatement.setInt(3, (byte) toAdd.chargesRemaining);
|
||||||
preparedStatement.setInt(4, toAdd.getDurabilityCurrent());
|
preparedStatement.setInt(4, (short) toAdd.durabilityCurrent);
|
||||||
preparedStatement.setInt(5, toAdd.getDurabilityMax());
|
preparedStatement.setInt(5, toAdd.getDurabilityMax());
|
||||||
|
|
||||||
if (toAdd.getNumOfItems() < 1)
|
if (toAdd.getNumOfItems() < 1)
|
||||||
@@ -392,7 +392,7 @@ public class dbItemHandler extends dbHandlerBase {
|
|||||||
|
|
||||||
preparedStatement.setInt(1, value);
|
preparedStatement.setInt(1, value);
|
||||||
preparedStatement.setLong(2, item.getObjectUUID());
|
preparedStatement.setLong(2, item.getObjectUUID());
|
||||||
preparedStatement.setInt(3, item.getDurabilityCurrent());
|
preparedStatement.setInt(3, (short) item.durabilityCurrent);
|
||||||
|
|
||||||
return (preparedStatement.executeUpdate() > 0);
|
return (preparedStatement.executeUpdate() > 0);
|
||||||
|
|
||||||
@@ -461,7 +461,7 @@ public class dbItemHandler extends dbHandlerBase {
|
|||||||
try (Connection connection = DbManager.getConnection();
|
try (Connection connection = DbManager.getConnection();
|
||||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_item` SET `item_chargesRemaining` = ? WHERE `UID` = ?")) {
|
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_item` SET `item_chargesRemaining` = ? WHERE `UID` = ?")) {
|
||||||
|
|
||||||
preparedStatement.setInt(1, item.getChargesRemaining());
|
preparedStatement.setInt(1, (byte) item.chargesRemaining);
|
||||||
preparedStatement.setLong(2, item.getObjectUUID());
|
preparedStatement.setLong(2, item.getObjectUUID());
|
||||||
|
|
||||||
return (preparedStatement.executeUpdate() > 0);
|
return (preparedStatement.executeUpdate() > 0);
|
||||||
|
|||||||
@@ -506,14 +506,14 @@ public class InfoCmd extends AbstractDevCmd {
|
|||||||
case MobLoot:
|
case MobLoot:
|
||||||
Item item = (Item) target;
|
Item item = (Item) target;
|
||||||
ItemBase itemBase = item.getItemBase();
|
ItemBase itemBase = item.getItemBase();
|
||||||
ItemTemplate template = ItemTemplate.itemTemplates.get(item.getItemBaseID());
|
ItemTemplate template = ItemTemplate.itemTemplates.get(item.getTemplsteID());
|
||||||
output += StringUtils.addWS("ItemBase: " + itemBase.getUUID(), 20);
|
output += StringUtils.addWS("ItemBase: " + itemBase.getUUID(), 20);
|
||||||
output += "Weight: " + itemBase.getWeight();
|
output += "Weight: " + itemBase.getWeight();
|
||||||
output += newline;
|
output += newline;
|
||||||
DecimalFormat df = new DecimalFormat("###,###,###,###,##0");
|
DecimalFormat df = new DecimalFormat("###,###,###,###,##0");
|
||||||
output += StringUtils.addWS("Qty: "
|
output += StringUtils.addWS("Qty: "
|
||||||
+ df.format(item.getNumOfItems()), 20);
|
+ df.format(item.getNumOfItems()), 20);
|
||||||
output += "Charges: " + item.getChargesRemaining()
|
output += "Charges: " + (byte) item.chargesRemaining
|
||||||
+ '/' + item.getChargesMax();
|
+ '/' + item.getChargesMax();
|
||||||
output += newline;
|
output += newline;
|
||||||
output += "Name: " + template.item_base_name;
|
output += "Name: " + template.item_base_name;
|
||||||
|
|||||||
@@ -37,9 +37,10 @@ public class MakeItemCmd extends AbstractDevCmd {
|
|||||||
if (ibID == 7)
|
if (ibID == 7)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
ItemBase ib = ItemBase.getItemBase(ibID);
|
ItemTemplate template = ItemTemplate.itemTemplates.get(ibID);
|
||||||
|
|
||||||
|
int weight = template.item_wt;
|
||||||
|
|
||||||
short weight = ib.getWeight();
|
|
||||||
if (!pc.getCharItemManager().hasRoomInventory(weight)) {
|
if (!pc.getCharItemManager().hasRoomInventory(weight)) {
|
||||||
throwbackError(pc, "Not enough room in inventory for any more of this item");
|
throwbackError(pc, "Not enough room in inventory for any more of this item");
|
||||||
|
|
||||||
@@ -48,10 +49,10 @@ public class MakeItemCmd extends AbstractDevCmd {
|
|||||||
}
|
}
|
||||||
|
|
||||||
boolean worked = false;
|
boolean worked = false;
|
||||||
Item item = new Item(ib, pc.getObjectUUID(),
|
Item item = new Item(template.template_id);
|
||||||
OwnerType.PlayerCharacter, (byte) 0, (byte) 0, (short) ib.getDurability(), (short) ib.getDurability(),
|
item.ownerID = pc.getObjectUUID();
|
||||||
true, false, ItemContainerType.INVENTORY, (byte) 0,
|
item.ownerType = OwnerType.PlayerCharacter;
|
||||||
new ArrayList<>(), "");
|
item.containerType = ItemContainerType.INVENTORY;
|
||||||
|
|
||||||
item.setNumOfItems(Warehouse.getMaxResources().get(ibID));
|
item.setNumOfItems(Warehouse.getMaxResources().get(ibID));
|
||||||
|
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ public class PrintBankCmd extends AbstractDevCmd {
|
|||||||
throwbackInfo(pc, "Bank for " + type + ' ' + name + " (" + tar.getObjectUUID() + ')');
|
throwbackInfo(pc, "Bank for " + type + ' ' + name + " (" + tar.getObjectUUID() + ')');
|
||||||
|
|
||||||
for (Item item : list) {
|
for (Item item : list) {
|
||||||
ItemTemplate template = ItemTemplate.itemTemplates.get(item.getItemBaseID());
|
ItemTemplate template = ItemTemplate.itemTemplates.get(item.getTemplsteID());
|
||||||
throwbackInfo(pc, " " + template.item_base_name + ", count: " + item.getNumOfItems());
|
throwbackInfo(pc, " " + template.item_base_name + ", count: " + item.getNumOfItems());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ public class PrintBonusesCmd extends AbstractDevCmd {
|
|||||||
if (target instanceof Item) {
|
if (target instanceof Item) {
|
||||||
type = "Item";
|
type = "Item";
|
||||||
tar = (Item) target;
|
tar = (Item) target;
|
||||||
ItemTemplate template = ItemTemplate.itemTemplates.get(((Item) tar).getItemBaseID());
|
ItemTemplate template = ItemTemplate.itemTemplates.get(((Item) tar).getTemplsteID());
|
||||||
name = template.item_base_name;
|
name = template.item_base_name;
|
||||||
} else if (target instanceof AbstractCharacter) {
|
} else if (target instanceof AbstractCharacter) {
|
||||||
tar = (AbstractCharacter) target;
|
tar = (AbstractCharacter) target;
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ public class PrintEquipCmd extends AbstractDevCmd {
|
|||||||
throwbackInfo(pc, "Equip for " + type + ' ' + name + " (" + tar.getObjectUUID() + ')');
|
throwbackInfo(pc, "Equip for " + type + ' ' + name + " (" + tar.getObjectUUID() + ')');
|
||||||
for (Integer slot : list.keySet()) {
|
for (Integer slot : list.keySet()) {
|
||||||
Item item = list.get(slot);
|
Item item = list.get(slot);
|
||||||
ItemTemplate template = ItemTemplate.itemTemplates.get(item.getItemBaseID());
|
ItemTemplate template = ItemTemplate.itemTemplates.get(item.getTemplsteID());
|
||||||
throwbackInfo(pc, " " + template.item_base_name + ", slot: " + slot);
|
throwbackInfo(pc, " " + template.item_base_name + ", slot: " + slot);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -79,10 +79,10 @@ public class PrintInventoryCmd extends AbstractDevCmd {
|
|||||||
String chargeInfo = "";
|
String chargeInfo = "";
|
||||||
byte chargeMax = item.getChargesMax();
|
byte chargeMax = item.getChargesMax();
|
||||||
if (chargeMax > 0) {
|
if (chargeMax > 0) {
|
||||||
byte charges = item.getChargesRemaining();
|
byte charges = (byte) item.chargesRemaining;
|
||||||
chargeInfo = " charges: " + charges + '/' + chargeMax;
|
chargeInfo = " charges: " + charges + '/' + chargeMax;
|
||||||
}
|
}
|
||||||
ItemTemplate template = ItemTemplate.itemTemplates.get(item.getItemBaseID());
|
ItemTemplate template = ItemTemplate.itemTemplates.get(item.getTemplsteID());
|
||||||
throwbackInfo(pc, " " + template.item_base_name + ", count: " + item.getNumOfItems() + chargeInfo);
|
throwbackInfo(pc, " " + template.item_base_name + ", count: " + item.getNumOfItems() + chargeInfo);
|
||||||
} else
|
} else
|
||||||
goldCount += item.getNumOfItems();
|
goldCount += item.getNumOfItems();
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ public class PrintVaultCmd extends AbstractDevCmd {
|
|||||||
ArrayList<Item> list = cim.getVault();
|
ArrayList<Item> list = cim.getVault();
|
||||||
throwbackInfo(pc, "Vault for " + type + ' ' + name + " (" + tar.getObjectUUID() + ')');
|
throwbackInfo(pc, "Vault for " + type + ' ' + name + " (" + tar.getObjectUUID() + ')');
|
||||||
for (Item item : list) {
|
for (Item item : list) {
|
||||||
ItemTemplate template = ItemTemplate.itemTemplates.get(item.getItemBaseID());
|
ItemTemplate template = ItemTemplate.itemTemplates.get(item.getTemplsteID());
|
||||||
throwbackInfo(pc, " " + template.item_base_name + ", count: " + item.getNumOfItems());
|
throwbackInfo(pc, " " + template.item_base_name + ", count: " + item.getNumOfItems());
|
||||||
}
|
}
|
||||||
Item gold = cim.getGoldVault();
|
Item gold = cim.getGoldVault();
|
||||||
|
|||||||
@@ -572,8 +572,8 @@ public enum BuildingManager {
|
|||||||
|
|
||||||
String pirateName = NPCManager.getPirateName(contract.getMobbaseID());
|
String pirateName = NPCManager.getPirateName(contract.getMobbaseID());
|
||||||
|
|
||||||
if (item.getChargesRemaining() > 0)
|
if ((byte) item.chargesRemaining > 0)
|
||||||
rank = item.getChargesRemaining() * 10;
|
rank = (byte) item.chargesRemaining * 10;
|
||||||
else
|
else
|
||||||
rank = 10;
|
rank = 10;
|
||||||
|
|
||||||
|
|||||||
@@ -612,7 +612,7 @@ public enum ChatManager {
|
|||||||
name = amount + " gold ";
|
name = amount + " gold ";
|
||||||
else {
|
else {
|
||||||
String vowels = "aeiou";
|
String vowels = "aeiou";
|
||||||
ItemTemplate template = ItemTemplate.itemTemplates.get(item.getItemBaseID());
|
ItemTemplate template = ItemTemplate.itemTemplates.get(item.getTemplsteID());
|
||||||
String iName = template.item_base_name;
|
String iName = template.item_base_name;
|
||||||
if (iName.length() > 0)
|
if (iName.length() > 0)
|
||||||
if (vowels.indexOf(iName.substring(0, 1).toLowerCase()) >= 0)
|
if (vowels.indexOf(iName.substring(0, 1).toLowerCase()) >= 0)
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ public enum LootManager {
|
|||||||
if (ib == null)
|
if (ib == null)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
ItemTemplate template = ItemTemplate.itemTemplates.get(it.getItemBaseID());
|
ItemTemplate template = ItemTemplate.itemTemplates.get(it.getTemplsteID());
|
||||||
|
|
||||||
if (ib.isDiscRune() || template.item_base_name.toLowerCase().contains("of the gods")) {
|
if (ib.isDiscRune() || template.item_base_name.toLowerCase().contains("of the gods")) {
|
||||||
ChatSystemMsg chatMsg = new ChatSystemMsg(null, mob.getName() + " in " + mob.getParentZone().zoneName + " has found the " + template.item_base_name + ". Are you tough enough to take it?");
|
ChatSystemMsg chatMsg = new ChatSystemMsg(null, mob.getName() + " in " + mob.getParentZone().zoneName + " has found the " + template.item_base_name + ". Are you tough enough to take it?");
|
||||||
@@ -354,7 +354,7 @@ public enum LootManager {
|
|||||||
|
|
||||||
if (ml != null && dropCount < 1) {
|
if (ml != null && dropCount < 1) {
|
||||||
ml.setIsID(true);
|
ml.setIsID(true);
|
||||||
ml.setDurabilityCurrent((short) (ml.getDurabilityCurrent() - ThreadLocalRandom.current().nextInt(5) + 1));
|
ml.setDurabilityCurrent((short) ((short) ml.durabilityCurrent - ThreadLocalRandom.current().nextInt(5) + 1));
|
||||||
mob.getCharItemManager().addItemToInventory(ml);
|
mob.getCharItemManager().addItemToInventory(ml);
|
||||||
dropCount = 1;
|
dropCount = 1;
|
||||||
//break; // Exit on first successful roll.
|
//break; // Exit on first successful roll.
|
||||||
@@ -383,8 +383,8 @@ public enum LootManager {
|
|||||||
|
|
||||||
int tableID = 0;
|
int tableID = 0;
|
||||||
|
|
||||||
if (_bootySetMap.get(gift.getItemBaseID()) != null)
|
if (_bootySetMap.get(gift.getTemplsteID()) != null)
|
||||||
tableID = _bootySetMap.get(gift.getItemBaseID()).get(ThreadLocalRandom.current().nextInt(_bootySetMap.get(gift.getItemBaseID()).size())).genTable;
|
tableID = _bootySetMap.get(gift.getTemplsteID()).get(ThreadLocalRandom.current().nextInt(_bootySetMap.get(gift.getTemplsteID()).size())).genTable;
|
||||||
|
|
||||||
if (tableID == 0)
|
if (tableID == 0)
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -1245,7 +1245,7 @@ public class ClientMessagePump implements NetMsgHandler {
|
|||||||
cost = sell.getBaseValue();
|
cost = sell.getBaseValue();
|
||||||
|
|
||||||
//apply damaged value reduction
|
//apply damaged value reduction
|
||||||
float durabilityCurrent = sell.getDurabilityCurrent();
|
float durabilityCurrent = (short) sell.durabilityCurrent;
|
||||||
float durabilityMax = sell.getDurabilityMax();
|
float durabilityMax = sell.getDurabilityMax();
|
||||||
float damagedModifier = durabilityCurrent / durabilityMax;
|
float damagedModifier = durabilityCurrent / durabilityMax;
|
||||||
cost *= damagedModifier;
|
cost *= damagedModifier;
|
||||||
@@ -1639,7 +1639,7 @@ public class ClientMessagePump implements NetMsgHandler {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
//make sure item is damaged and not destroyed
|
//make sure item is damaged and not destroyed
|
||||||
short dur = toRepair.getDurabilityCurrent();
|
short dur = (short) toRepair.durabilityCurrent;
|
||||||
short max = toRepair.getDurabilityMax();
|
short max = toRepair.getDurabilityMax();
|
||||||
//account for durability modifications
|
//account for durability modifications
|
||||||
float durMod = toRepair.getBonusPercent(ModType.Durability, SourceType.NONE);
|
float durMod = toRepair.getBonusPercent(ModType.Durability, SourceType.NONE);
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ public class GuildCreationFinalizeHandler extends AbstractClientMsgHandler {
|
|||||||
|
|
||||||
charter = msg.getCharter();
|
charter = msg.getCharter();
|
||||||
|
|
||||||
if (charter == null || charter.getOwnerType() != OwnerType.PlayerCharacter || charter.getOwnerID() != player.getObjectUUID()) {
|
if (charter == null || charter.ownerType != OwnerType.PlayerCharacter || charter.getOwnerID() != player.getObjectUUID()) {
|
||||||
ErrorPopupMsg.sendErrorPopup(player, GuildManager.NO_CHARTER_FOUND);
|
ErrorPopupMsg.sendErrorPopup(player, GuildManager.NO_CHARTER_FOUND);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -493,7 +493,7 @@ public class ObjectActionMsgHandler extends AbstractClientMsgHandler {
|
|||||||
removeRune(player, origin, comps.get(1).intValue());
|
removeRune(player, origin, comps.get(1).intValue());
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
} else if (item.getChargesRemaining() > 0) {
|
} else if ((byte) item.chargesRemaining > 0) {
|
||||||
ArrayList<Long> tarList = msg.getTargetCompID();
|
ArrayList<Long> tarList = msg.getTargetCompID();
|
||||||
AbstractWorldObject target = player;
|
AbstractWorldObject target = player;
|
||||||
if (tarList.size() > 1) {
|
if (tarList.size() > 1) {
|
||||||
|
|||||||
@@ -284,7 +284,7 @@ public class ItemProductionMsg extends ClientNetMsg {
|
|||||||
writer.putInt(this.itemUUID);
|
writer.putInt(this.itemUUID);
|
||||||
writer.putInt(0); //items left to produce?
|
writer.putInt(0); //items left to produce?
|
||||||
if (toRoll != null) {
|
if (toRoll != null) {
|
||||||
writer.putInt(toRoll.getItemBaseID());
|
writer.putInt(toRoll.getTemplsteID());
|
||||||
writer.putInt(toRoll.getValue());
|
writer.putInt(toRoll.getValue());
|
||||||
} else {
|
} else {
|
||||||
writer.putInt(0);
|
writer.putInt(0);
|
||||||
@@ -301,7 +301,7 @@ public class ItemProductionMsg extends ClientNetMsg {
|
|||||||
|
|
||||||
timeLeft /= 1000;
|
timeLeft /= 1000;
|
||||||
writer.putInt((int) timeLeft);
|
writer.putInt((int) timeLeft);
|
||||||
writer.putInt(vendor.getRollingTimeInSeconds(toRoll.getItemBaseID()));
|
writer.putInt(vendor.getRollingTimeInSeconds(toRoll.getTemplsteID()));
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -449,15 +449,15 @@ public class ManageNPCMsg extends ClientNetMsg {
|
|||||||
writer.putInt(i.getObjectUUID());
|
writer.putInt(i.getObjectUUID());
|
||||||
|
|
||||||
writer.putInt(0);
|
writer.putInt(0);
|
||||||
writer.putInt(i.getItemBaseID());
|
writer.putInt(i.getTemplsteID());
|
||||||
writer.putInt(ib.getBaseValue());
|
writer.putInt(ib.getBaseValue());
|
||||||
|
|
||||||
long timeLife = i.getDateToUpgrade() - System.currentTimeMillis();
|
long timeLife = i.getDateToUpgrade() - System.currentTimeMillis();
|
||||||
|
|
||||||
timeLife /= 1000;
|
timeLife /= 1000;
|
||||||
writer.putInt((int) timeLife);
|
writer.putInt((int) timeLife);
|
||||||
writer.putInt(npc.getRollingTimeInSeconds(i.getItemBaseID()));
|
writer.putInt(npc.getRollingTimeInSeconds(i.getTemplsteID()));
|
||||||
writer.putInt(1);
|
writer.putInt(1);
|
||||||
|
|
||||||
if (i.isComplete())
|
if (i.isComplete())
|
||||||
writer.put((byte) 1);
|
writer.put((byte) 1);
|
||||||
|
|||||||
@@ -12,7 +12,10 @@ package engine.objects;
|
|||||||
import engine.Enum;
|
import engine.Enum;
|
||||||
import engine.Enum.GameObjectType;
|
import engine.Enum.GameObjectType;
|
||||||
import engine.Enum.ItemType;
|
import engine.Enum.ItemType;
|
||||||
import engine.gameManager.*;
|
import engine.gameManager.BuildingManager;
|
||||||
|
import engine.gameManager.ChatManager;
|
||||||
|
import engine.gameManager.ConfigManager;
|
||||||
|
import engine.gameManager.DbManager;
|
||||||
import engine.math.Vector3fImmutable;
|
import engine.math.Vector3fImmutable;
|
||||||
import engine.net.Dispatch;
|
import engine.net.Dispatch;
|
||||||
import engine.net.DispatchMessage;
|
import engine.net.DispatchMessage;
|
||||||
@@ -931,7 +934,7 @@ public class CharacterItemManager {
|
|||||||
|
|
||||||
public synchronized boolean consume(Item i) {
|
public synchronized boolean consume(Item i) {
|
||||||
i.decrementChargesRemaining();
|
i.decrementChargesRemaining();
|
||||||
if (i.getChargesRemaining() > 0)
|
if ((byte) i.chargesRemaining > 0)
|
||||||
return true;
|
return true;
|
||||||
return junk(i, true);
|
return junk(i, true);
|
||||||
}
|
}
|
||||||
@@ -2089,7 +2092,7 @@ public class CharacterItemManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasRoomInventory(short weight) {
|
public boolean hasRoomInventory(int weight) {
|
||||||
if (this.absCharacter == null)
|
if (this.absCharacter == null)
|
||||||
return false;
|
return false;
|
||||||
if (this.absCharacter.getObjectType() == GameObjectType.PlayerCharacter) {
|
if (this.absCharacter.getObjectType() == GameObjectType.PlayerCharacter) {
|
||||||
@@ -2447,7 +2450,7 @@ public class CharacterItemManager {
|
|||||||
if (!item.isCanDestroy())
|
if (!item.isCanDestroy())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int dur = (int) item.getDurabilityCurrent();
|
int dur = (int) (short) item.durabilityCurrent;
|
||||||
if (dur - amount <= 0) {
|
if (dur - amount <= 0) {
|
||||||
//destroy the item
|
//destroy the item
|
||||||
junk(item);
|
junk(item);
|
||||||
|
|||||||
@@ -45,18 +45,18 @@ public class Item extends AbstractWorldObject {
|
|||||||
private final ArrayList<String> effectNames = new ArrayList<>();
|
private final ArrayList<String> effectNames = new ArrayList<>();
|
||||||
public Enum.ItemContainerType containerType;
|
public Enum.ItemContainerType containerType;
|
||||||
public ReentrantLock lootLock = new ReentrantLock();
|
public ReentrantLock lootLock = new ReentrantLock();
|
||||||
private int ownerID; //may be character, account, npc, mob
|
public int ownerID; //may be character, account, npc, mob
|
||||||
private int flags; //1 = isIDed
|
private int flags; //1 = isIDed
|
||||||
private int numberOfItems;
|
private int numberOfItems;
|
||||||
private short durabilityCurrent;
|
public float durabilityCurrent;
|
||||||
private byte chargesRemaining;
|
public int chargesRemaining;
|
||||||
private byte equipSlot;
|
private byte equipSlot;
|
||||||
private boolean canDestroy;
|
private boolean canDestroy;
|
||||||
private boolean rentable;
|
private boolean rentable;
|
||||||
private boolean isRandom = false;
|
private boolean isRandom = false;
|
||||||
private int value;
|
private int value;
|
||||||
private OwnerType ownerType;
|
public OwnerType ownerType;
|
||||||
private int itemBaseID;
|
public int templsteID;
|
||||||
private AbstractWorldObject lastOwner;
|
private AbstractWorldObject lastOwner;
|
||||||
private ArrayList<EnchantmentBase> enchants = new ArrayList<>();
|
private ArrayList<EnchantmentBase> enchants = new ArrayList<>();
|
||||||
private long dateToUpgrade;
|
private long dateToUpgrade;
|
||||||
@@ -72,7 +72,11 @@ public class Item extends AbstractWorldObject {
|
|||||||
public Item(int templateID) {
|
public Item(int templateID) {
|
||||||
super();
|
super();
|
||||||
this.template = ItemTemplate.itemTemplates.get(templateID);
|
this.template = ItemTemplate.itemTemplates.get(templateID);
|
||||||
|
this.chargesRemaining = this.template.item_initial_charges;
|
||||||
|
this.durabilityCurrent = this.template.combat_health_full;
|
||||||
|
|
||||||
|
loadEnchantments();
|
||||||
|
bakeInStats();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Item(ItemBase itemBase, int ownerID,
|
public Item(ItemBase itemBase, int ownerID,
|
||||||
@@ -81,7 +85,7 @@ public class Item extends AbstractWorldObject {
|
|||||||
boolean rentable, Enum.ItemContainerType containerType, byte equipSlot,
|
boolean rentable, Enum.ItemContainerType containerType, byte equipSlot,
|
||||||
ArrayList<EnchantmentBase> enchants, String name) {
|
ArrayList<EnchantmentBase> enchants, String name) {
|
||||||
super();
|
super();
|
||||||
this.itemBaseID = itemBase.getUUID();
|
this.templsteID = itemBase.getUUID();
|
||||||
this.ownerID = ownerID;
|
this.ownerID = ownerID;
|
||||||
this.ownerType = ownerType;
|
this.ownerType = ownerType;
|
||||||
|
|
||||||
@@ -119,7 +123,7 @@ public class Item extends AbstractWorldObject {
|
|||||||
ArrayList<EnchantmentBase> enchants, int newUUID) {
|
ArrayList<EnchantmentBase> enchants, int newUUID) {
|
||||||
|
|
||||||
super(newUUID);
|
super(newUUID);
|
||||||
this.itemBaseID = itemBase.getUUID();
|
this.templsteID = itemBase.getUUID();
|
||||||
this.ownerID = ownerID;
|
this.ownerID = ownerID;
|
||||||
this.ownerType = ownerType;
|
this.ownerType = ownerType;
|
||||||
this.customName = "";
|
this.customName = "";
|
||||||
@@ -146,7 +150,7 @@ public class Item extends AbstractWorldObject {
|
|||||||
public Item(ResultSet rs) throws SQLException {
|
public Item(ResultSet rs) throws SQLException {
|
||||||
super(rs);
|
super(rs);
|
||||||
|
|
||||||
this.itemBaseID = rs.getInt("item_itemBaseID");
|
this.templsteID = rs.getInt("item_itemBaseID");
|
||||||
|
|
||||||
// Set container enumeration
|
// Set container enumeration
|
||||||
|
|
||||||
@@ -784,11 +788,11 @@ public class Item extends AbstractWorldObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ItemBase getItemBase() {
|
public ItemBase getItemBase() {
|
||||||
return ItemBase.getItemBase(itemBaseID);
|
return ItemBase.getItemBase(templsteID);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getItemBaseID() {
|
public int getTemplsteID() {
|
||||||
return this.itemBaseID;
|
return this.templsteID;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getOwnerID() {
|
public int getOwnerID() {
|
||||||
@@ -800,10 +804,6 @@ public class Item extends AbstractWorldObject {
|
|||||||
this.ownerID = ownerID;
|
this.ownerID = ownerID;
|
||||||
}
|
}
|
||||||
|
|
||||||
public OwnerType getOwnerType() {
|
|
||||||
return ownerType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public AbstractGameObject getOwner() {
|
public AbstractGameObject getOwner() {
|
||||||
if (this.ownerType == OwnerType.Npc)
|
if (this.ownerType == OwnerType.Npc)
|
||||||
return NPC.getFromCache(this.ownerID);
|
return NPC.getFromCache(this.ownerID);
|
||||||
@@ -850,15 +850,7 @@ public class Item extends AbstractWorldObject {
|
|||||||
return chargesMax;
|
return chargesMax;
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte getChargesRemaining() {
|
public void setDurabilityCurrent(float value) {
|
||||||
return chargesRemaining;
|
|
||||||
}
|
|
||||||
|
|
||||||
public short getDurabilityCurrent() {
|
|
||||||
return durabilityCurrent;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDurabilityCurrent(short value) {
|
|
||||||
this.durabilityCurrent = value;
|
this.durabilityCurrent = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1194,7 +1186,7 @@ public class Item extends AbstractWorldObject {
|
|||||||
if (this.customName.isEmpty() == false)
|
if (this.customName.isEmpty() == false)
|
||||||
return this.customName;
|
return this.customName;
|
||||||
|
|
||||||
ItemTemplate template = ItemTemplate.itemTemplates.get(this.getItemBaseID());
|
ItemTemplate template = ItemTemplate.itemTemplates.get(this.getTemplsteID());
|
||||||
return template.item_base_name;
|
return template.item_base_name;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -189,7 +189,7 @@ public class ItemFactory {
|
|||||||
time *= MBServerStatics.ONE_MINUTE;
|
time *= MBServerStatics.ONE_MINUTE;
|
||||||
|
|
||||||
if (ml.getItemBase().getUUID() > 910010 && ml.getItemBase().getUUID() < 910019) {
|
if (ml.getItemBase().getUUID() > 910010 && ml.getItemBase().getUUID() < 910019) {
|
||||||
rank = ml.getItemBaseID() - 910010;
|
rank = ml.getTemplsteID() - 910010;
|
||||||
time = rank * 60 * 60 * 3 * 1000;
|
time = rank * 60 * 60 * 3 * 1000;
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -210,8 +210,8 @@ public class ItemFactory {
|
|||||||
|
|
||||||
if (pc != null)
|
if (pc != null)
|
||||||
playerID = pc.getObjectUUID();
|
playerID = pc.getObjectUUID();
|
||||||
DbManager.NPCQueries.ADD_TO_PRODUCTION_LIST(ml.getObjectUUID(), npc.getObjectUUID(), ml.getItemBaseID(), dateTime, "", "", "", false, playerID);
|
DbManager.NPCQueries.ADD_TO_PRODUCTION_LIST(ml.getObjectUUID(), npc.getObjectUUID(), ml.getTemplsteID(), dateTime, "", "", "", false, playerID);
|
||||||
ProducedItem pi = new ProducedItem(ml.getObjectUUID(), npc.getObjectUUID(), ml.getItemBaseID(), dateTime, false, "", "", "", playerID);
|
ProducedItem pi = new ProducedItem(ml.getObjectUUID(), npc.getObjectUUID(), ml.getTemplsteID(), dateTime, false, "", "", "", playerID);
|
||||||
pi.setProducedItemID(ml.getObjectUUID());
|
pi.setProducedItemID(ml.getObjectUUID());
|
||||||
pi.setAmount(itemsToRoll);
|
pi.setAmount(itemsToRoll);
|
||||||
pi.setRandom(false);
|
pi.setRandom(false);
|
||||||
@@ -606,7 +606,7 @@ public class ItemFactory {
|
|||||||
time *= MBServerStatics.ONE_MINUTE;
|
time *= MBServerStatics.ONE_MINUTE;
|
||||||
|
|
||||||
if (ml.getItemBase().getUUID() > 910010 && ml.getItemBase().getUUID() < 910019) {
|
if (ml.getItemBase().getUUID() > 910010 && ml.getItemBase().getUUID() < 910019) {
|
||||||
rank = ml.getItemBaseID() - 910010;
|
rank = ml.getTemplsteID() - 910010;
|
||||||
time = rank * 60 * 60 * 3 * 1000;
|
time = rank * 60 * 60 * 3 * 1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -627,8 +627,8 @@ public class ItemFactory {
|
|||||||
if (pc != null)
|
if (pc != null)
|
||||||
playerID = pc.getObjectUUID();
|
playerID = pc.getObjectUUID();
|
||||||
|
|
||||||
DbManager.NPCQueries.ADD_TO_PRODUCTION_LIST(ml.getObjectUUID(), npc.getObjectUUID(), ml.getItemBaseID(), dateTime, prefixString, suffixString, ml.getCustomName(), false, playerID);
|
DbManager.NPCQueries.ADD_TO_PRODUCTION_LIST(ml.getObjectUUID(), npc.getObjectUUID(), ml.getTemplsteID(), dateTime, prefixString, suffixString, ml.getCustomName(), false, playerID);
|
||||||
ProducedItem pi = new ProducedItem(npc.getRolling().size(), npc.getObjectUUID(), ml.getItemBaseID(), dateTime, false, prefixString, suffixString, ml.getCustomName(), playerID);
|
ProducedItem pi = new ProducedItem(npc.getRolling().size(), npc.getObjectUUID(), ml.getTemplsteID(), dateTime, false, prefixString, suffixString, ml.getCustomName(), playerID);
|
||||||
pi.setProducedItemID(ml.getObjectUUID());
|
pi.setProducedItemID(ml.getObjectUUID());
|
||||||
pi.setAmount(itemsToRoll);
|
pi.setAmount(itemsToRoll);
|
||||||
|
|
||||||
@@ -745,7 +745,7 @@ public class ItemFactory {
|
|||||||
time *= MBServerStatics.ONE_MINUTE;
|
time *= MBServerStatics.ONE_MINUTE;
|
||||||
|
|
||||||
if (toRoll.getItemBase().getUUID() > 910010 && toRoll.getItemBase().getUUID() < 910019) {
|
if (toRoll.getItemBase().getUUID() > 910010 && toRoll.getItemBase().getUUID() < 910019) {
|
||||||
rank = toRoll.getItemBaseID() - 910010;
|
rank = toRoll.getTemplsteID() - 910010;
|
||||||
time = rank * 60 * 60 * 3 * 1000;
|
time = rank * 60 * 60 * 3 * 1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -765,9 +765,9 @@ public class ItemFactory {
|
|||||||
if (playerCharacter != null)
|
if (playerCharacter != null)
|
||||||
playerID = playerCharacter.getObjectUUID();
|
playerID = playerCharacter.getObjectUUID();
|
||||||
|
|
||||||
DbManager.NPCQueries.ADD_TO_PRODUCTION_LIST(toRoll.getObjectUUID(), vendor.getObjectUUID(), toRoll.getItemBaseID(), dateTime, prefix, suffix, toRoll.getCustomName(), true, playerID);
|
DbManager.NPCQueries.ADD_TO_PRODUCTION_LIST(toRoll.getObjectUUID(), vendor.getObjectUUID(), toRoll.getTemplsteID(), dateTime, prefix, suffix, toRoll.getCustomName(), true, playerID);
|
||||||
|
|
||||||
ProducedItem pi = new ProducedItem(toRoll.getObjectUUID(), vendor.getObjectUUID(), toRoll.getItemBaseID(), dateTime, true, prefix, suffix, toRoll.getCustomName(), playerID);
|
ProducedItem pi = new ProducedItem(toRoll.getObjectUUID(), vendor.getObjectUUID(), toRoll.getTemplsteID(), dateTime, true, prefix, suffix, toRoll.getCustomName(), playerID);
|
||||||
pi.setProducedItemID(toRoll.getObjectUUID());
|
pi.setProducedItemID(toRoll.getObjectUUID());
|
||||||
pi.setAmount(itemsToRoll);
|
pi.setAmount(itemsToRoll);
|
||||||
ItemQueue produced = ItemQueue.borrow(pi, (long) (time * Float.parseFloat(ConfigManager.MB_PRODUCTION_RATE.getValue())));
|
ItemQueue produced = ItemQueue.borrow(pi, (long) (time * Float.parseFloat(ConfigManager.MB_PRODUCTION_RATE.getValue())));
|
||||||
|
|||||||
@@ -344,7 +344,7 @@ public class Warehouse extends AbstractWorldObject {
|
|||||||
if (resource.getItemBase().getType().equals(Enum.ItemType.GOLD))
|
if (resource.getItemBase().getType().equals(Enum.ItemType.GOLD))
|
||||||
resourceType = Resource.GOLD;
|
resourceType = Resource.GOLD;
|
||||||
else
|
else
|
||||||
resourceType = Resource.valueOf(ItemTemplate.itemTemplates.get(resource.getItemBaseID()).item_base_name.toUpperCase());
|
resourceType = Resource.valueOf(ItemTemplate.itemTemplates.get(resource.getTemplsteID()).item_base_name.toUpperCase());
|
||||||
|
|
||||||
if (transaction)
|
if (transaction)
|
||||||
AddTransactionToWarehouse(warehouse, pc.getObjectType(), pc.getObjectUUID(), Enum.TransactionType.DEPOSIT, resourceType, amount);
|
AddTransactionToWarehouse(warehouse, pc.getObjectType(), pc.getObjectUUID(), Enum.TransactionType.DEPOSIT, resourceType, amount);
|
||||||
|
|||||||
Reference in New Issue
Block a user