Browse Source

Methods moved to new handler

combat-2
MagicBot 8 months ago
parent
commit
dc366068a9
  1. 2
      src/engine/gameManager/BuildingManager.java
  2. 28
      src/engine/gameManager/ItemManager.java
  3. 27
      src/engine/objects/Item.java

2
src/engine/gameManager/BuildingManager.java

@ -213,7 +213,7 @@ public enum BuildingManager { @@ -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);

28
src/engine/gameManager/ItemManager.java

@ -2,6 +2,7 @@ package engine.gameManager; @@ -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 { @@ -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;
}
}

27
src/engine/objects/Item.java

@ -370,33 +370,6 @@ public class Item extends AbstractWorldObject { @@ -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)

Loading…
Cancel
Save