From dc366068a9169cb01fd6c4042857dfe7ef838e20 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Tue, 2 Apr 2024 12:00:59 -0400 Subject: [PATCH] Methods moved to new handler --- src/engine/gameManager/BuildingManager.java | 2 +- src/engine/gameManager/ItemManager.java | 28 +++++++++++++++++++++ src/engine/objects/Item.java | 27 -------------------- 3 files changed, 29 insertions(+), 28 deletions(-) diff --git a/src/engine/gameManager/BuildingManager.java b/src/engine/gameManager/BuildingManager.java index a45242e6..380c7d5d 100644 --- a/src/engine/gameManager/BuildingManager.java +++ b/src/engine/gameManager/BuildingManager.java @@ -213,7 +213,7 @@ public enum BuildingManager { if (!player.charItemManager.hasRoomInventory(template.item_wt)) return false; - if (!Item.MakeItemForPlayer(template.template_id, player, amount)) + if (!ItemManager.MakeItemForPlayer(template.template_id, player, amount)) return false; shrine.setFavors(0); diff --git a/src/engine/gameManager/ItemManager.java b/src/engine/gameManager/ItemManager.java index c105f05d..82431b83 100644 --- a/src/engine/gameManager/ItemManager.java +++ b/src/engine/gameManager/ItemManager.java @@ -2,6 +2,7 @@ package engine.gameManager; import engine.Enum; import engine.objects.*; +import org.pmw.tinylog.Logger; import java.util.EnumSet; import java.util.concurrent.ConcurrentHashMap; @@ -192,4 +193,31 @@ public enum ItemManager { return item.template.item_value != 0 || Kit.IsNoobGear(item.templateID); } + + public static boolean MakeItemForPlayer(int templateID, PlayerCharacter reciever, int amount) { + + boolean itemWorked = false; + + Item item = new Item(templateID); + + item.ownerID = reciever.getObjectUUID(); + item.ownerType = Enum.OwnerType.PlayerCharacter; + item.containerType = Enum.ItemContainerType.INVENTORY; + item.numberOfItems = amount; + + try { + item = DbManager.ItemQueries.PERSIST(item); + itemWorked = true; + } catch (Exception e) { + Logger.error(e); + } + + if (!itemWorked) + return false; + + reciever.charItemManager.addItemToInventory(item); + reciever.charItemManager.updateInventory(); + + return true; + } } diff --git a/src/engine/objects/Item.java b/src/engine/objects/Item.java index 5ecc4edf..4745dddf 100644 --- a/src/engine/objects/Item.java +++ b/src/engine/objects/Item.java @@ -370,33 +370,6 @@ public class Item extends AbstractWorldObject { } - public static boolean MakeItemForPlayer(int templateID, PlayerCharacter reciever, int amount) { - - boolean itemWorked = false; - - Item item = new Item(templateID); - - item.ownerID = reciever.getObjectUUID(); - item.ownerType = OwnerType.PlayerCharacter; - item.containerType = Enum.ItemContainerType.INVENTORY; - item.numberOfItems = amount; - - try { - item = DbManager.ItemQueries.PERSIST(item); - itemWorked = true; - } catch (Exception e) { - Logger.error(e); - } - - if (!itemWorked) - return false; - - reciever.charItemManager.addItemToInventory(item); - reciever.charItemManager.updateInventory(); - - return true; - } - public static Item deserializeFromClientMsg(ByteBufferReader reader, boolean includeSlot) { if (includeSlot)