From d05dbef71dfa60e15aa2a01d102388f60235ac49 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 2 Mar 2024 10:52:20 -0500 Subject: [PATCH] More item refactor work. --- src/engine/objects/Item.java | 5 ++--- src/engine/objects/PlayerCharacter.java | 24 ++++++++++++++---------- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/src/engine/objects/Item.java b/src/engine/objects/Item.java index fd0e9e55..12a9d8c8 100644 --- a/src/engine/objects/Item.java +++ b/src/engine/objects/Item.java @@ -50,7 +50,7 @@ public class Item extends AbstractWorldObject { private int numberOfItems; public float durabilityCurrent; public int chargesRemaining; - private byte equipSlot; + public byte equipSlot; private boolean canDestroy; private boolean isRandom = false; private int value; @@ -627,11 +627,10 @@ public class Item extends AbstractWorldObject { if (persist) { try { newGold = DbManager.ItemQueries.PERSIST(newGold); - + DbManager.ItemQueries.ZERO_ITEM_STACK(newGold); } catch (Exception e) { Logger.error(e); } - DbManager.ItemQueries.ZERO_ITEM_STACK(newGold); } return newGold; diff --git a/src/engine/objects/PlayerCharacter.java b/src/engine/objects/PlayerCharacter.java index 0c7d722a..2f0da902 100644 --- a/src/engine/objects/PlayerCharacter.java +++ b/src/engine/objects/PlayerCharacter.java @@ -1190,15 +1190,17 @@ public class PlayerCharacter extends AbstractCharacter { } if (hairStyleID != 0) { + // Create Hair - Item tempHair = new Item(ItemBase.getItemBase(hairStyleID), playerCharacter.getObjectUUID(), OwnerType.PlayerCharacter, - (byte) 0, (byte) 0, (short) 1, (short) 1, false, false, ItemContainerType.EQUIPPED, - (byte) MBServerStatics.SLOT_HAIRSTYLE, new ArrayList<>(), ""); + Item hair = new Item(hairStyleID); + hair.ownerID = playerCharacter.getObjectUUID(); + hair.ownerType = OwnerType.PlayerCharacter; + hair.containerType = ItemContainerType.EQUIPPED; + hair.equipSlot = (byte) MBServerStatics.SLOT_HAIRSTYLE; - Item hair; try { - hair = DbManager.ItemQueries.PERSIST(tempHair); + hair = DbManager.ItemQueries.PERSIST(hair); } catch (Exception e) { hair = null; } @@ -1213,12 +1215,14 @@ public class PlayerCharacter extends AbstractCharacter { if (beardStyleID != 0) { // Create Beard - Item tempBeard = new Item(ItemBase.getItemBase(beardStyleID), playerCharacter.getObjectUUID(), OwnerType.PlayerCharacter, - (byte) 0, (byte) 0, (short) 1, (short) 1, false, false, ItemContainerType.EQUIPPED, - (byte) MBServerStatics.SLOT_BEARDSTYLE, new ArrayList<>(), ""); - Item beard; + Item beard = new Item(hairStyleID); + beard.ownerID = playerCharacter.getObjectUUID(); + beard.ownerType = OwnerType.PlayerCharacter; + beard.containerType = ItemContainerType.EQUIPPED; + beard.equipSlot = (byte) MBServerStatics.SLOT_BEARDSTYLE; + try { - beard = DbManager.ItemQueries.PERSIST(tempBeard); + beard = DbManager.ItemQueries.PERSIST(beard); } catch (Exception e) { beard = null; }