@ -83,6 +83,7 @@ public class ItemFactory { 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					        boolean  useWarehouse  =  false ;   
					 
					 
					 
					        boolean  useWarehouse  =  false ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					
 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					        ItemBase  ib  =  ItemBase . getItemBase ( itemID ) ;   
					 
					 
					 
					        ItemBase  ib  =  ItemBase . getItemBase ( itemID ) ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					        ItemTemplate  template  =  ItemTemplate . itemTemplates . get ( itemID ) ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					
 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					        if  ( ib  = =  null )   
					 
					 
					 
					        if  ( ib  = =  null )   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					            return  null ;   
					 
					 
					 
					            return  null ;   
				
			 
			
		
	
	
		
		
			
				
					
						
							
								 
							 
						
						
							
								 
							 
						
						
					 
					 
					@ -127,19 +128,19 @@ public class ItemFactory { 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					
 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                if  ( overdraft  >  0  & &  ! useWarehouse )  {   
					 
					 
					 
					                if  ( overdraft  >  0  & &  ! useWarehouse )  {   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                    if  ( pc  ! =  null )   
					 
					 
					 
					                    if  ( pc  ! =  null )   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                        ErrorPopupMsg . sendErrorMsg ( pc ,  "Not enough gold in building strongbox."  +  " "  +  ib . getName ( ) ) ;   
					 
					 
					 
					                        ErrorPopupMsg . sendErrorMsg ( pc ,  "Not enough gold in building strongbox."  +  " "  +  template . item_base_name ) ;   
				
			 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 
					 
					 
					                    return  null ;   
					 
					 
					 
					                    return  null ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                }   
					 
					 
					 
					                }   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					
 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                if  ( overdraft  >  0  & &  Warehouse . isResourceLocked ( cityWarehouse ,  ItemBase . GOLD_ITEM_BASE ) )  {   
					 
					 
					 
					                if  ( overdraft  >  0  & &  Warehouse . isResourceLocked ( cityWarehouse ,  ItemBase . GOLD_ITEM_BASE ) )  {   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                    if  ( pc  ! =  null )   
					 
					 
					 
					                    if  ( pc  ! =  null )   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                        ErrorPopupMsg . sendErrorMsg ( pc ,  "Warehouse gold is barred! Overdraft cannot be withdrawn from warehouse."  +  " "  +  ib . getName ( ) ) ;   
					 
					 
					 
					                        ErrorPopupMsg . sendErrorMsg ( pc ,  "Warehouse gold is barred! Overdraft cannot be withdrawn from warehouse."  +  " "  +  template . item_base_name ) ;   
				
			 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 
					 
					 
					                    return  null ;   
					 
					 
					 
					                    return  null ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                }   
					 
					 
					 
					                }   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					
 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                if  ( overdraft  >  resources . get ( ItemBase . GOLD_ITEM_BASE ) )  {   
					 
					 
					 
					                if  ( overdraft  >  resources . get ( ItemBase . GOLD_ITEM_BASE ) )  {   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                    if  ( pc  ! =  null )   
					 
					 
					 
					                    if  ( pc  ! =  null )   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                        ErrorPopupMsg . sendErrorMsg ( pc ,  "Not enough Gold in Warehouse for overdraft."  +  " "  +  ib . getName ( ) ) ;   
					 
					 
					 
					                        ErrorPopupMsg . sendErrorMsg ( pc ,  "Not enough Gold in Warehouse for overdraft."  +  " "  +  template . item_base_name ) ;   
				
			 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 
					 
					 
					                    return  null ;   
					 
					 
					 
					                    return  null ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                }   
					 
					 
					 
					                }   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					
 
					 
					 
					 
					
 
				
			 
			
		
	
	
		
		
			
				
					
						
						
						
							
								 
							 
						
					 
					 
					@ -156,11 +157,11 @@ public class ItemFactory { 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                    overdraft  + =  buildingWithdraw ;   
					 
					 
					 
					                    overdraft  + =  buildingWithdraw ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					
 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                    if  ( ! useWarehouse )  {   
					 
					 
					 
					                    if  ( ! useWarehouse )  {   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                        ErrorPopupMsg . sendErrorMsg ( pc ,  "Building does not have enough gold to produce this item."  +  ib . getName ( ) ) ;   
					 
					 
					 
					                        ErrorPopupMsg . sendErrorMsg ( pc ,  "Building does not have enough gold to produce this item."  +  template . item_base_name ) ;   
				
			 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 
					 
					 
					                        return  null ;   
					 
					 
					 
					                        return  null ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                    }  else  {   
					 
					 
					 
					                    }  else  {   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                        if  ( overdraft  >  resources . get ( ItemBase . GOLD_ITEM_BASE ) )  {   
					 
					 
					 
					                        if  ( overdraft  >  resources . get ( ItemBase . GOLD_ITEM_BASE ) )  {   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                            ErrorPopupMsg . sendErrorMsg ( pc ,  "Not enough Gold in Warehouse to produce this item."  +  ib . getName ( ) ) ;   
					 
					 
					 
					                            ErrorPopupMsg . sendErrorMsg ( pc ,  "Not enough Gold in Warehouse to produce this item."  +  template . item_base_name ) ;   
				
			 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 
					 
					 
					                            return  null ;   
					 
					 
					 
					                            return  null ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                        }   
					 
					 
					 
					                        }   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                    }   
					 
					 
					 
					                    }   
				
			 
			
		
	
	
		
		
			
				
					
						
						
						
							
								 
							 
						
					 
					 
					@ -169,7 +170,7 @@ public class ItemFactory { 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                if  ( overdraft  >  0 )   
					 
					 
					 
					                if  ( overdraft  >  0 )   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                    if  ( ! Warehouse . withdraw ( cityWarehouse ,  npc ,  ItemBase . GOLD_ITEM_BASE ,  overdraft ,  true ) )  {   
					 
					 
					 
					                    if  ( ! Warehouse . withdraw ( cityWarehouse ,  npc ,  ItemBase . GOLD_ITEM_BASE ,  overdraft ,  true ) )  {   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                        //ChatManager.chatGuildError(pc, "Failed to create Item");
   
					 
					 
					 
					                        //ChatManager.chatGuildError(pc, "Failed to create Item");
   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                        Logger . error ( "Warehouse With UID of "  +  cityWarehouse . UID  +  " Failed to Create Item."  +  ib . getName ( ) ) ;   
					 
					 
					 
					                        Logger . error ( "Warehouse With UID of "  +  cityWarehouse . UID  +  " Failed to Create Item."  +  template . item_base_name ) ;   
				
			 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 
					 
					 
					                        return  null ;   
					 
					 
					 
					                        return  null ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                    }   
					 
					 
					 
					                    }   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					
 
					 
					 
					 
					
 
				
			 
			
		
	
	
		
		
			
				
					
						
							
								 
							 
						
						
							
								 
							 
						
						
					 
					 
					@ -257,7 +258,7 @@ public class ItemFactory { 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					            if  ( galvorAmount  >  0  | |  wormwoodAmount  >  0 )   
					 
					 
					 
					            if  ( galvorAmount  >  0  | |  wormwoodAmount  >  0 )   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                if  ( ! useWarehouse )  {   
					 
					 
					 
					                if  ( ! useWarehouse )  {   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                    if  ( pc  ! =  null )   
					 
					 
					 
					                    if  ( pc  ! =  null )   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                        ErrorPopupMsg . sendErrorMsg ( pc ,  "This item requires resources to roll! Please make sure the forge is protected to access the warehouse."  +  ib . getName ( ) ) ;   
					 
					 
					 
					                        ErrorPopupMsg . sendErrorMsg ( pc ,  "This item requires resources to roll! Please make sure the forge is protected to access the warehouse."  +  template . item_base_name ) ;   
				
			 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 
					 
					 
					                    return  null ;   
					 
					 
					 
					                    return  null ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					
 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                }   
					 
					 
					 
					                }   
				
			 
			
		
	
	
		
		
			
				
					
						
						
						
							
								 
							 
						
					 
					 
					@ -265,13 +266,13 @@ public class ItemFactory { 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					            if  ( galvorAmount  >  0 )  {   
					 
					 
					 
					            if  ( galvorAmount  >  0 )  {   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                if  ( Warehouse . isResourceLocked ( cityWarehouse ,  galvor ) )  {   
					 
					 
					 
					                if  ( Warehouse . isResourceLocked ( cityWarehouse ,  galvor ) )  {   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                    if  ( pc  ! =  null )   
					 
					 
					 
					                    if  ( pc  ! =  null )   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                        ErrorPopupMsg . sendErrorMsg ( pc ,  "Galvor is locked."  +  ib . getName ( ) ) ;   
					 
					 
					 
					                        ErrorPopupMsg . sendErrorMsg ( pc ,  "Galvor is locked."  +  template . item_base_name ) ;   
				
			 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 
					 
					 
					                    return  null ;   
					 
					 
					 
					                    return  null ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                }   
					 
					 
					 
					                }   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					
 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                if  ( cityWarehouse . resources . get ( galvor )  <  galvorAmount )  {   
					 
					 
					 
					                if  ( cityWarehouse . resources . get ( galvor )  <  galvorAmount )  {   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                    if  ( pc  ! =  null )   
					 
					 
					 
					                    if  ( pc  ! =  null )   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                        ErrorPopupMsg . sendErrorMsg ( pc ,  "Not enough Galvor in warehouse to roll this item."  +  ib . getName ( ) ) ;   
					 
					 
					 
					                        ErrorPopupMsg . sendErrorMsg ( pc ,  "Not enough Galvor in warehouse to roll this item."  +  template . item_base_name ) ;   
				
			 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 
					 
					 
					                    return  null ;   
					 
					 
					 
					                    return  null ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                }   
					 
					 
					 
					                }   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					            }   
					 
					 
					 
					            }   
				
			 
			
		
	
	
		
		
			
				
					
						
						
						
							
								 
							 
						
					 
					 
					@ -279,13 +280,13 @@ public class ItemFactory { 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					            if  ( wormwoodAmount  >  0 )  {   
					 
					 
					 
					            if  ( wormwoodAmount  >  0 )  {   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                if  ( Warehouse . isResourceLocked ( cityWarehouse ,  wormwood ) )  {   
					 
					 
					 
					                if  ( Warehouse . isResourceLocked ( cityWarehouse ,  wormwood ) )  {   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                    if  ( pc  ! =  null )   
					 
					 
					 
					                    if  ( pc  ! =  null )   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                        ErrorPopupMsg . sendErrorMsg ( pc ,  "Wormwood is locked."  +  ib . getName ( ) ) ;   
					 
					 
					 
					                        ErrorPopupMsg . sendErrorMsg ( pc ,  "Wormwood is locked."  +  template . item_base_name ) ;   
				
			 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 
					 
					 
					                    return  null ;   
					 
					 
					 
					                    return  null ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                }   
					 
					 
					 
					                }   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					
 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                if  ( cityWarehouse . resources . get ( wormwood )  <  wormwoodAmount )  {   
					 
					 
					 
					                if  ( cityWarehouse . resources . get ( wormwood )  <  wormwoodAmount )  {   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                    if  ( pc  ! =  null )   
					 
					 
					 
					                    if  ( pc  ! =  null )   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                        ErrorPopupMsg . sendErrorMsg ( pc ,  "Not enough Wormwood in warehouse to roll this item."  +  ib . getName ( ) ) ;   
					 
					 
					 
					                        ErrorPopupMsg . sendErrorMsg ( pc ,  "Not enough Wormwood in warehouse to roll this item."  +  template . item_base_name ) ;   
				
			 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 
					 
					 
					                    return  null ;   
					 
					 
					 
					                    return  null ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                }   
					 
					 
					 
					                }   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					            }   
					 
					 
					 
					            }   
				
			 
			
		
	
	
		
		
			
				
					
						
						
						
							
								 
							 
						
					 
					 
					@ -296,7 +297,7 @@ public class ItemFactory { 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					
 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                if  ( ! useWarehouse )  {   
					 
					 
					 
					                if  ( ! useWarehouse )  {   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                    if  ( pc  ! =  null )   
					 
					 
					 
					                    if  ( pc  ! =  null )   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                        ErrorPopupMsg . sendErrorMsg ( pc ,  "Forge cannot access warehouse! Check to make sure forge is protected."  +  ib . getName ( ) ) ;   
					 
					 
					 
					                        ErrorPopupMsg . sendErrorMsg ( pc ,  "Forge cannot access warehouse! Check to make sure forge is protected."  +  template . item_base_name ) ;   
				
			 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 
					 
					 
					                    return  null ;   
					 
					 
					 
					                    return  null ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                }   
					 
					 
					 
					                }   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                prefix  =  PowersManager . getEffectByToken ( pToken ) ;   
					 
					 
					 
					                prefix  =  PowersManager . getEffectByToken ( pToken ) ;   
				
			 
			
		
	
	
		
		
			
				
					
						
						
						
							
								 
							 
						
					 
					 
					@ -316,19 +317,19 @@ public class ItemFactory { 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					
 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                if  ( overdraft  >  0  & &  ! useWarehouse )  {   
					 
					 
					 
					                if  ( overdraft  >  0  & &  ! useWarehouse )  {   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                    if  ( pc  ! =  null )   
					 
					 
					 
					                    if  ( pc  ! =  null )   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                        ErrorPopupMsg . sendErrorMsg ( pc ,  "Not enough gold in building strongbox."  +  ib . getName ( ) ) ;   
					 
					 
					 
					                        ErrorPopupMsg . sendErrorMsg ( pc ,  "Not enough gold in building strongbox."  +  template . item_base_name ) ;   
				
			 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 
					 
					 
					                    return  null ;   
					 
					 
					 
					                    return  null ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                }   
					 
					 
					 
					                }   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					
 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                if  ( overdraft  >  0  & &  Warehouse . isResourceLocked ( cityWarehouse ,  ItemBase . GOLD_ITEM_BASE ) )  {   
					 
					 
					 
					                if  ( overdraft  >  0  & &  Warehouse . isResourceLocked ( cityWarehouse ,  ItemBase . GOLD_ITEM_BASE ) )  {   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                    if  ( pc  ! =  null )   
					 
					 
					 
					                    if  ( pc  ! =  null )   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                        ErrorPopupMsg . sendErrorMsg ( pc ,  "Warehouse gold is barred! Overdraft cannot be withdrawn from warehouse."  +  ib . getName ( ) ) ;   
					 
					 
					 
					                        ErrorPopupMsg . sendErrorMsg ( pc ,  "Warehouse gold is barred! Overdraft cannot be withdrawn from warehouse."  +  template . item_base_name ) ;   
				
			 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 
					 
					 
					                    return  null ;   
					 
					 
					 
					                    return  null ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                }   
					 
					 
					 
					                }   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					
 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                if  ( overdraft  >  cityWarehouse . resources . get ( ItemBase . GOLD_ITEM_BASE ) )  {   
					 
					 
					 
					                if  ( overdraft  >  cityWarehouse . resources . get ( ItemBase . GOLD_ITEM_BASE ) )  {   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                    if  ( pc  ! =  null )   
					 
					 
					 
					                    if  ( pc  ! =  null )   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                        ErrorPopupMsg . sendErrorMsg ( pc ,  "Not enough Gold in Warehouse for overdraft."  +  ib . getName ( ) ) ;   
					 
					 
					 
					                        ErrorPopupMsg . sendErrorMsg ( pc ,  "Not enough Gold in Warehouse for overdraft."  +  template . item_base_name ) ;   
				
			 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 
					 
					 
					                    return  null ;   
					 
					 
					 
					                    return  null ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                }   
					 
					 
					 
					                }   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                prefixResourceCosts  =  prefix . getResourcesForEffect ( ) ;   
					 
					 
					 
					                prefixResourceCosts  =  prefix . getResourcesForEffect ( ) ;   
				
			 
			
		
	
	
		
		
			
				
					
						
						
						
							
								 
							 
						
					 
					 
					@ -349,7 +350,7 @@ public class ItemFactory { 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					
 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                if  ( ! useWarehouse )  {   
					 
					 
					 
					                if  ( ! useWarehouse )  {   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                    if  ( pc  ! =  null )   
					 
					 
					 
					                    if  ( pc  ! =  null )   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                        ErrorPopupMsg . sendErrorMsg ( pc ,  "Forge cannot access warehouse! Check to make sure forge is protected."  +  ib . getName ( ) ) ;   
					 
					 
					 
					                        ErrorPopupMsg . sendErrorMsg ( pc ,  "Forge cannot access warehouse! Check to make sure forge is protected."  +  template . item_base_name ) ;   
				
			 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 
					 
					 
					                    return  null ;   
					 
					 
					 
					                    return  null ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                }   
					 
					 
					 
					                }   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                suffix  =  PowersManager . getEffectByToken ( sToken ) ;   
					 
					 
					 
					                suffix  =  PowersManager . getEffectByToken ( sToken ) ;   
				
			 
			
		
	
	
		
		
			
				
					
						
						
						
							
								 
							 
						
					 
					 
					@ -370,19 +371,19 @@ public class ItemFactory { 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					
 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                if  ( overdraft  >  0  & &  ! useWarehouse )  {   
					 
					 
					 
					                if  ( overdraft  >  0  & &  ! useWarehouse )  {   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                    if  ( pc  ! =  null )   
					 
					 
					 
					                    if  ( pc  ! =  null )   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                        ErrorPopupMsg . sendErrorMsg ( pc ,  "Not enough gold in building strongbox."  +  ib . getName ( ) ) ;   
					 
					 
					 
					                        ErrorPopupMsg . sendErrorMsg ( pc ,  "Not enough gold in building strongbox."  +  template . item_base_name ) ;   
				
			 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 
					 
					 
					                    return  null ;   
					 
					 
					 
					                    return  null ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                }   
					 
					 
					 
					                }   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					
 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                if  ( overdraft  >  0  & &  Warehouse . isResourceLocked ( cityWarehouse ,  ItemBase . GOLD_ITEM_BASE ) )  {   
					 
					 
					 
					                if  ( overdraft  >  0  & &  Warehouse . isResourceLocked ( cityWarehouse ,  ItemBase . GOLD_ITEM_BASE ) )  {   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                    if  ( pc  ! =  null )   
					 
					 
					 
					                    if  ( pc  ! =  null )   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                        ErrorPopupMsg . sendErrorMsg ( pc ,  "Warehouse gold is barred! Overdraft cannot be withdrawn from warehouse."  +  ib . getName ( ) ) ;   
					 
					 
					 
					                        ErrorPopupMsg . sendErrorMsg ( pc ,  "Warehouse gold is barred! Overdraft cannot be withdrawn from warehouse."  +  template . item_base_name ) ;   
				
			 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 
					 
					 
					                    return  null ;   
					 
					 
					 
					                    return  null ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                }   
					 
					 
					 
					                }   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					
 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                if  ( overdraft  >  cityWarehouse . resources . get ( ItemBase . GOLD_ITEM_BASE ) )  {   
					 
					 
					 
					                if  ( overdraft  >  cityWarehouse . resources . get ( ItemBase . GOLD_ITEM_BASE ) )  {   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                    if  ( pc  ! =  null )   
					 
					 
					 
					                    if  ( pc  ! =  null )   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                        ErrorPopupMsg . sendErrorMsg ( pc ,  "Not enough Gold in Warehouse for overdraft."  +  ib . getName ( ) ) ;   
					 
					 
					 
					                        ErrorPopupMsg . sendErrorMsg ( pc ,  "Not enough Gold in Warehouse for overdraft."  +  template . item_base_name ) ;   
				
			 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 
					 
					 
					                    return  null ;   
					 
					 
					 
					                    return  null ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                }   
					 
					 
					 
					                }   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					
 
					 
					 
					 
					
 
				
			 
			
		
	
	
		
		
			
				
					
						
							
								 
							 
						
						
							
								 
							 
						
						
					 
					 
					@ -410,19 +411,19 @@ public class ItemFactory { 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					
 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					            if  ( overdraft  >  0  & &  ! useWarehouse )  {   
					 
					 
					 
					            if  ( overdraft  >  0  & &  ! useWarehouse )  {   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                if  ( pc  ! =  null )   
					 
					 
					 
					                if  ( pc  ! =  null )   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                    ErrorPopupMsg . sendErrorMsg ( pc ,  "Not enough gold in building strongbox."  +  ib . getName ( ) ) ;   
					 
					 
					 
					                    ErrorPopupMsg . sendErrorMsg ( pc ,  "Not enough gold in building strongbox."  +  template . item_base_name ) ;   
				
			 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 
					 
					 
					                return  null ;   
					 
					 
					 
					                return  null ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					            }   
					 
					 
					 
					            }   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					
 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					            if  ( overdraft  >  0  & &  useWarehouse  & &  Warehouse . isResourceLocked ( cityWarehouse ,  ItemBase . GOLD_ITEM_BASE ) )  {   
					 
					 
					 
					            if  ( overdraft  >  0  & &  useWarehouse  & &  Warehouse . isResourceLocked ( cityWarehouse ,  ItemBase . GOLD_ITEM_BASE ) )  {   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                if  ( pc  ! =  null )   
					 
					 
					 
					                if  ( pc  ! =  null )   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                    ErrorPopupMsg . sendErrorMsg ( pc ,  "Warehouse gold is barred! Overdraft cannot be withdrawn from warehouse."  +  ib . getName ( ) ) ;   
					 
					 
					 
					                    ErrorPopupMsg . sendErrorMsg ( pc ,  "Warehouse gold is barred! Overdraft cannot be withdrawn from warehouse."  +  template . item_base_name ) ;   
				
			 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 
					 
					 
					                return  null ;   
					 
					 
					 
					                return  null ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					            }   
					 
					 
					 
					            }   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					
 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					            if  ( useWarehouse  & &  overdraft  >  cityWarehouse . resources . get ( ItemBase . GOLD_ITEM_BASE ) )  {   
					 
					 
					 
					            if  ( useWarehouse  & &  overdraft  >  cityWarehouse . resources . get ( ItemBase . GOLD_ITEM_BASE ) )  {   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                if  ( pc  ! =  null )   
					 
					 
					 
					                if  ( pc  ! =  null )   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                    ErrorPopupMsg . sendErrorMsg ( pc ,  "Not enough Gold in Warehouse for overdraft."  +  ib . getName ( ) ) ;   
					 
					 
					 
					                    ErrorPopupMsg . sendErrorMsg ( pc ,  "Not enough Gold in Warehouse for overdraft."  +  template . item_base_name ) ;   
				
			 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 
					 
					 
					                return  null ;   
					 
					 
					 
					                return  null ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					            }   
					 
					 
					 
					            }   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					
 
					 
					 
					 
					
 
				
			 
			
		
	
	
		
		
			
				
					
						
						
						
							
								 
							 
						
					 
					 
					@ -437,11 +438,11 @@ public class ItemFactory { 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                overdraft  + =  buildingWithdraw ;   
					 
					 
					 
					                overdraft  + =  buildingWithdraw ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					
 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                if  ( ! useWarehouse )  {   
					 
					 
					 
					                if  ( ! useWarehouse )  {   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                    ErrorPopupMsg . sendErrorMsg ( pc ,  "Building does not have enough gold to produce this item."  +  ib . getName ( ) ) ;   
					 
					 
					 
					                    ErrorPopupMsg . sendErrorMsg ( pc ,  "Building does not have enough gold to produce this item."  +  template . item_base_name ) ;   
				
			 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 
					 
					 
					                    return  null ;   
					 
					 
					 
					                    return  null ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                }  else  {   
					 
					 
					 
					                }  else  {   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                    if  ( overdraft  >  cityWarehouse . resources . get ( ItemBase . GOLD_ITEM_BASE ) )  {   
					 
					 
					 
					                    if  ( overdraft  >  cityWarehouse . resources . get ( ItemBase . GOLD_ITEM_BASE ) )  {   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                        ErrorPopupMsg . sendErrorMsg ( pc ,  "Not enough Gold in Warehouse to produce this item."  +  ib . getName ( ) ) ;   
					 
					 
					 
					                        ErrorPopupMsg . sendErrorMsg ( pc ,  "Not enough Gold in Warehouse to produce this item."  +  template . item_base_name ) ;   
				
			 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 
					 
					 
					                        return  null ;   
					 
					 
					 
					                        return  null ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                    }   
					 
					 
					 
					                    }   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                }   
					 
					 
					 
					                }   
				
			 
			
		
	
	
		
		
			
				
					
						
						
						
							
								 
							 
						
					 
					 
					@ -450,7 +451,7 @@ public class ItemFactory { 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					            if  ( overdraft  >  0  & &  useWarehouse )   
					 
					 
					 
					            if  ( overdraft  >  0  & &  useWarehouse )   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                if  ( ! Warehouse . withdraw ( cityWarehouse ,  npc ,  ItemBase . GOLD_ITEM_BASE ,  overdraft ,  true ) )  {   
					 
					 
					 
					                if  ( ! Warehouse . withdraw ( cityWarehouse ,  npc ,  ItemBase . GOLD_ITEM_BASE ,  overdraft ,  true ) )  {   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                    //ChatManager.chatGuildError(pc, "Failed to create Item");
   
					 
					 
					 
					                    //ChatManager.chatGuildError(pc, "Failed to create Item");
   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                    Logger . error ( "Warehouse With UID of "  +  cityWarehouse . UID  +  " Failed to Create Item."  +  ib . getName ( ) ) ;   
					 
					 
					 
					                    Logger . error ( "Warehouse With UID of "  +  cityWarehouse . UID  +  " Failed to Create Item."  +  template . item_base_name ) ;   
				
			 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 
					 
					 
					                    return  null ;   
					 
					 
					 
					                    return  null ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                }   
					 
					 
					 
					                }   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					
 
					 
					 
					 
					
 
				
			 
			
		
	
	
		
		
			
				
					
						
						
						
							
								 
							 
						
					 
					 
					@ -458,7 +459,7 @@ public class ItemFactory { 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					            if  ( prefix  ! =  null )  {   
					 
					 
					 
					            if  ( prefix  ! =  null )  {   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					
 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                if  ( ! useWarehouse )  {   
					 
					 
					 
					                if  ( ! useWarehouse )  {   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                    ErrorPopupMsg . sendErrorMsg ( pc ,  "Cannot Resource Roll without access to the warehouse! Make sure the forge is currently protected."  +  ib . getName ( ) ) ;   
					 
					 
					 
					                    ErrorPopupMsg . sendErrorMsg ( pc ,  "Cannot Resource Roll without access to the warehouse! Make sure the forge is currently protected."  +  template . item_base_name ) ;   
				
			 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 
					 
					 
					                    return  null ;   
					 
					 
					 
					                    return  null ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                }   
					 
					 
					 
					                }   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					
 
					 
					 
					 
					
 
				
			 
			
		
	
	
		
		
			
				
					
						
						
						
							
								 
							 
						
					 
					 
					@ -478,7 +479,7 @@ public class ItemFactory { 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					
 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                    if  ( ! Warehouse . withdraw ( cityWarehouse ,  npc ,  ibResources ,  amount ,  true ) )  {   
					 
					 
					 
					                    if  ( ! Warehouse . withdraw ( cityWarehouse ,  npc ,  ibResources ,  amount ,  true ) )  {   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                        //ChatManager.chatGuildError(pc, "Failed to create Item");
   
					 
					 
					 
					                        //ChatManager.chatGuildError(pc, "Failed to create Item");
   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                        Logger . error ( "Warehouse With UID of "  +  cityWarehouse . UID  +  " Failed to Create Item."  +  ib . getName ( ) ) ;   
					 
					 
					 
					                        Logger . error ( "Warehouse With UID of "  +  cityWarehouse . UID  +  " Failed to Create Item."  +  template . item_base_name ) ;   
				
			 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 
					 
					 
					                        return  null ;   
					 
					 
					 
					                        return  null ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                    }   
					 
					 
					 
					                    }   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                }   
					 
					 
					 
					                }   
				
			 
			
		
	
	
		
		
			
				
					
						
						
						
							
								 
							 
						
					 
					 
					@ -490,7 +491,7 @@ public class ItemFactory { 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                    int  creationAmount  =  suffixResourceCosts . get ( ibResources ) ;   
					 
					 
					 
					                    int  creationAmount  =  suffixResourceCosts . get ( ibResources ) ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					
 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                    if  ( Warehouse . isResourceLocked ( cityWarehouse ,  ibResources )  = =  true )  {   
					 
					 
					 
					                    if  ( Warehouse . isResourceLocked ( cityWarehouse ,  ibResources )  = =  true )  {   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                        ChatManager . chatSystemError ( pc ,  ibResources . getName ( )  +  " is locked!"  +  ib . getName ( ) ) ;   
					 
					 
					 
					                        ChatManager . chatSystemError ( pc ,  ibResources . getName ( )  +  " is locked!"  +  template . item_base_name ) ;   
				
			 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 
					 
					 
					                        return  null ;   
					 
					 
					 
					                        return  null ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                    }   
					 
					 
					 
					                    }   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					
 
					 
					 
					 
					
 
				
			 
			
		
	
	
		
		
			
				
					
						
						
						
							
								 
							 
						
					 
					 
					@ -500,7 +501,7 @@ public class ItemFactory { 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                        amount  =  oldAmount ;   
					 
					 
					 
					                        amount  =  oldAmount ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                    if  ( ! Warehouse . withdraw ( cityWarehouse ,  npc ,  ibResources ,  amount ,  true ) )  {   
					 
					 
					 
					                    if  ( ! Warehouse . withdraw ( cityWarehouse ,  npc ,  ibResources ,  amount ,  true ) )  {   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                        //ChatManager.chatGuildError(pc, "Failed to create Item");
   
					 
					 
					 
					                        //ChatManager.chatGuildError(pc, "Failed to create Item");
   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                        Logger . error ( "Warehouse With UID of "  +  cityWarehouse . UID  +  " Failed to Create Item."  +  ib . getName ( ) ) ;   
					 
					 
					 
					                        Logger . error ( "Warehouse With UID of "  +  cityWarehouse . UID  +  " Failed to Create Item."  +  template . item_base_name ) ;   
				
			 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 
					 
					 
					                        return  null ;   
					 
					 
					 
					                        return  null ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                    }   
					 
					 
					 
					                    }   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                }   
					 
					 
					 
					                }   
				
			 
			
		
	
	
		
		
			
				
					
						
						
						
							
								 
							 
						
					 
					 
					@ -518,21 +519,21 @@ public class ItemFactory { 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                if  ( overdraft  >  0  & &  ! useWarehouse )  {   
					 
					 
					 
					                if  ( overdraft  >  0  & &  ! useWarehouse )  {   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					
 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                    if  ( pc  ! =  null )   
					 
					 
					 
					                    if  ( pc  ! =  null )   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                        ErrorPopupMsg . sendErrorMsg ( pc ,  "Not enough gold in building strongbox."  +  ib . getName ( ) ) ;   
					 
					 
					 
					                        ErrorPopupMsg . sendErrorMsg ( pc ,  "Not enough gold in building strongbox."  +  template . item_base_name ) ;   
				
			 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 
					 
					 
					                    return  null ;   
					 
					 
					 
					                    return  null ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                }   
					 
					 
					 
					                }   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					
 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                if  ( overdraft  >  0  & &  Warehouse . isResourceLocked ( cityWarehouse ,  ItemBase . GOLD_ITEM_BASE ) )  {   
					 
					 
					 
					                if  ( overdraft  >  0  & &  Warehouse . isResourceLocked ( cityWarehouse ,  ItemBase . GOLD_ITEM_BASE ) )  {   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					
 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                    if  ( pc  ! =  null )   
					 
					 
					 
					                    if  ( pc  ! =  null )   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                        ErrorPopupMsg . sendErrorMsg ( pc ,  "Warehouse gold is barred! Overdraft cannot be withdrawn from warehouse."  +  ib . getName ( ) ) ;   
					 
					 
					 
					                        ErrorPopupMsg . sendErrorMsg ( pc ,  "Warehouse gold is barred! Overdraft cannot be withdrawn from warehouse."  +  template . item_base_name ) ;   
				
			 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 
					 
					 
					                    return  null ;   
					 
					 
					 
					                    return  null ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                }   
					 
					 
					 
					                }   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					
 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                if  ( useWarehouse  & &  overdraft  >  cityWarehouse . resources . get ( ItemBase . GOLD_ITEM_BASE ) )  {   
					 
					 
					 
					                if  ( useWarehouse  & &  overdraft  >  cityWarehouse . resources . get ( ItemBase . GOLD_ITEM_BASE ) )  {   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					
 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                    if  ( pc  ! =  null )   
					 
					 
					 
					                    if  ( pc  ! =  null )   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                        ErrorPopupMsg . sendErrorMsg ( pc ,  "Not enough Gold in Warehouse for overdraft."  +  ib . getName ( ) ) ;   
					 
					 
					 
					                        ErrorPopupMsg . sendErrorMsg ( pc ,  "Not enough Gold in Warehouse for overdraft."  +  template . item_base_name ) ;   
				
			 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 
					 
					 
					                    return  null ;   
					 
					 
					 
					                    return  null ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                }   
					 
					 
					 
					                }   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					            }   
					 
					 
					 
					            }   
				
			 
			
		
	
	
		
		
			
				
					
						
						
						
							
								 
							 
						
					 
					 
					@ -541,11 +542,11 @@ public class ItemFactory { 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                overdraft  + =  buildingWithdraw ;   
					 
					 
					 
					                overdraft  + =  buildingWithdraw ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					
 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                if  ( ! useWarehouse )  {   
					 
					 
					 
					                if  ( ! useWarehouse )  {   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                    ErrorPopupMsg . sendErrorMsg ( pc ,  "Building does not have enough gold to produce this item."  +  ib . getName ( ) ) ;   
					 
					 
					 
					                    ErrorPopupMsg . sendErrorMsg ( pc ,  "Building does not have enough gold to produce this item."  +  template . item_base_name ) ;   
				
			 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 
					 
					 
					                    return  null ;   
					 
					 
					 
					                    return  null ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                }  else  {   
					 
					 
					 
					                }  else  {   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                    if  ( overdraft  >  cityWarehouse . resources . get ( ItemBase . GOLD_ITEM_BASE ) )  {   
					 
					 
					 
					                    if  ( overdraft  >  cityWarehouse . resources . get ( ItemBase . GOLD_ITEM_BASE ) )  {   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                        ErrorPopupMsg . sendErrorMsg ( pc ,  "Not enough Gold in Warehouse to produce this item."  +  ib . getName ( ) ) ;   
					 
					 
					 
					                        ErrorPopupMsg . sendErrorMsg ( pc ,  "Not enough Gold in Warehouse to produce this item."  +  template . item_base_name ) ;   
				
			 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 
					 
					 
					                        return  null ;   
					 
					 
					 
					                        return  null ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                    }   
					 
					 
					 
					                    }   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                }   
					 
					 
					 
					                }   
				
			 
			
		
	
	
		
		
			
				
					
						
						
						
							
								 
							 
						
					 
					 
					@ -554,7 +555,7 @@ public class ItemFactory { 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					            if  ( overdraft  >  0 )   
					 
					 
					 
					            if  ( overdraft  >  0 )   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                if  ( ! Warehouse . withdraw ( cityWarehouse ,  npc ,  ItemBase . GOLD_ITEM_BASE ,  overdraft ,  true ) )  {   
					 
					 
					 
					                if  ( ! Warehouse . withdraw ( cityWarehouse ,  npc ,  ItemBase . GOLD_ITEM_BASE ,  overdraft ,  true ) )  {   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                    //ChatManager.chatGuildError(pc, "Failed to create Item");
   
					 
					 
					 
					                    //ChatManager.chatGuildError(pc, "Failed to create Item");
   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                    Logger . error ( "Warehouse With UID of "  +  cityWarehouse . UID  +  " Failed to Create Item."  +  ib . getName ( ) ) ;   
					 
					 
					 
					                    Logger . error ( "Warehouse With UID of "  +  cityWarehouse . UID  +  " Failed to Create Item."  +  template . item_base_name ) ;   
				
			 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 
					 
					 
					                    return  null ;   
					 
					 
					 
					                    return  null ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                }   
					 
					 
					 
					                }   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					
 
					 
					 
					 
					
 
				
			 
			
		
	
	
		
		
			
				
					
						
						
						
							
								 
							 
						
					 
					 
					@ -562,7 +563,7 @@ public class ItemFactory { 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					
 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					            if  ( galvorAmount  >  0 )  {   
					 
					 
					 
					            if  ( galvorAmount  >  0 )  {   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                if  ( ! Warehouse . withdraw ( cityWarehouse ,  npc ,  galvor ,  galvorAmount ,  true ) )  {   
					 
					 
					 
					                if  ( ! Warehouse . withdraw ( cityWarehouse ,  npc ,  galvor ,  galvorAmount ,  true ) )  {   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                    ErrorPopupMsg . sendErrorMsg ( pc ,  "Failed to withdraw Galvor from warehouse!"  +  ib . getName ( ) ) ;   
					 
					 
					 
					                    ErrorPopupMsg . sendErrorMsg ( pc ,  "Failed to withdraw Galvor from warehouse!"  +  template . item_base_name ) ;   
				
			 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 
					 
					 
					                    Logger . error ( "Warehouse with UID of"  +  cityWarehouse . getObjectUUID ( )  +  "Failed to Withdrawl " ) ;   
					 
					 
					 
					                    Logger . error ( "Warehouse with UID of"  +  cityWarehouse . getObjectUUID ( )  +  "Failed to Withdrawl " ) ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                    return  null ;   
					 
					 
					 
					                    return  null ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                }   
					 
					 
					 
					                }   
				
			 
			
		
	
	
		
		
			
				
					
						
						
						
							
								 
							 
						
					 
					 
					@ -570,7 +571,7 @@ public class ItemFactory { 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					
 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					            if  ( wormwoodAmount  >  0 )  {   
					 
					 
					 
					            if  ( wormwoodAmount  >  0 )  {   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                if  ( ! Warehouse . withdraw ( cityWarehouse ,  npc ,  wormwood ,  wormwoodAmount ,  true ) )  {   
					 
					 
					 
					                if  ( ! Warehouse . withdraw ( cityWarehouse ,  npc ,  wormwood ,  wormwoodAmount ,  true ) )  {   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                    ErrorPopupMsg . sendErrorMsg ( pc ,  "Failed to withdraw Wormwood from warehouse!"  +  ib . getName ( ) ) ;   
					 
					 
					 
					                    ErrorPopupMsg . sendErrorMsg ( pc ,  "Failed to withdraw Wormwood from warehouse!"  +  template . item_base_name ) ;   
				
			 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 
					 
					 
					                    Logger . error ( "Warehouse with UID of"  +  cityWarehouse . getObjectUUID ( )  +  "Failed to Withdrawl " ) ;   
					 
					 
					 
					                    Logger . error ( "Warehouse with UID of"  +  cityWarehouse . getObjectUUID ( )  +  "Failed to Withdrawl " ) ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                    return  null ;   
					 
					 
					 
					                    return  null ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                }   
					 
					 
					 
					                }   
				
			 
			
		
	
	
		
		
			
				
					
						
							
								 
							 
						
						
							
								 
							 
						
						
					 
					 
					@ -657,6 +658,7 @@ public class ItemFactory { 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					        ModTableEntry  suffixEntry  =  null ;   
					 
					 
					 
					        ModTableEntry  suffixEntry  =  null ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					
 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					        ItemBase  ib  =  ItemBase . getItemBase ( itemBaseID ) ;   
					 
					 
					 
					        ItemBase  ib  =  ItemBase . getItemBase ( itemBaseID ) ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					        ItemTemplate  template  =  ItemTemplate . itemTemplates . get ( itemBaseID ) ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					
 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					        if  ( ib  = =  null )   
					 
					 
					 
					        if  ( ib  = =  null )   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					            return  null ;   
					 
					 
					 
					            return  null ;   
				
			 
			
		
	
	
		
		
			
				
					
						
							
								 
							 
						
						
							
								 
							 
						
						
					 
					 
					@ -689,7 +691,7 @@ public class ItemFactory { 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					        }   
					 
					 
					 
					        }   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					
 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					        if  ( prefixMod  = =  0  & &  suffixMod  = =  0 )  {   
					 
					 
					 
					        if  ( prefixMod  = =  0  & &  suffixMod  = =  0 )  {   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					            Logger . info ( "Failed to find modTables for item "  +  ib . getName ( ) ) ;   
					 
					 
					 
					            Logger . info ( "Failed to find modTables for item "  +  template . item_base_name ) ;   
				
			 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 
					 
					 
					            return  null ;   
					 
					 
					 
					            return  null ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					        }   
					 
					 
					 
					        }   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					
 
					 
					 
					 
					
 
				
			 
			
		
	
	
		
		
			
				
					
						
							
								 
							 
						
						
							
								 
							 
						
						
					 
					 
					@ -782,6 +784,7 @@ public class ItemFactory { 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					            return  null ;   
					 
					 
					 
					            return  null ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					
 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					        ItemBase  ib  =  ItemBase . getItemBase ( itemID ) ;   
					 
					 
					 
					        ItemBase  ib  =  ItemBase . getItemBase ( itemID ) ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					        ItemTemplate  template  =  ItemTemplate . itemTemplates . get ( itemID ) ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					
 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					        if  ( ib  = =  null )   
					 
					 
					 
					        if  ( ib  = =  null )   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					            return  null ;   
					 
					 
					 
					            return  null ;   
				
			 
			
		
	
	
		
		
			
				
					
						
							
								 
							 
						
						
							
								 
							 
						
						
					 
					 
					@ -853,24 +856,24 @@ public class ItemFactory { 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					
 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					            if  ( galvorAmount  >  0 )  {   
					 
					 
					 
					            if  ( galvorAmount  >  0 )  {   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                if  ( Warehouse . isResourceLocked ( cityWarehouse ,  galvor ) )  {   
					 
					 
					 
					                if  ( Warehouse . isResourceLocked ( cityWarehouse ,  galvor ) )  {   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                    ErrorPopupMsg . sendErrorMsg ( pc ,  "Galvor is locked."  +  ib . getName ( ) ) ;   
					 
					 
					 
					                    ErrorPopupMsg . sendErrorMsg ( pc ,  "Galvor is locked."  +  template . item_base_name ) ;   
				
			 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 
					 
					 
					                    return  null ;   
					 
					 
					 
					                    return  null ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                }   
					 
					 
					 
					                }   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					
 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                if  ( cityWarehouse . resources . get ( galvor )  <  galvorAmount )  {   
					 
					 
					 
					                if  ( cityWarehouse . resources . get ( galvor )  <  galvorAmount )  {   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                    ErrorPopupMsg . sendErrorMsg ( pc ,  "Not enough Galvor in warehouse to roll this item."  +  ib . getName ( ) ) ;   
					 
					 
					 
					                    ErrorPopupMsg . sendErrorMsg ( pc ,  "Not enough Galvor in warehouse to roll this item."  +  template . item_base_name ) ;   
				
			 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 
					 
					 
					                    return  null ;   
					 
					 
					 
					                    return  null ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                }   
					 
					 
					 
					                }   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					            }   
					 
					 
					 
					            }   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					
 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					            if  ( wormwoodAmount  >  0 )  {   
					 
					 
					 
					            if  ( wormwoodAmount  >  0 )  {   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                if  ( Warehouse . isResourceLocked ( cityWarehouse ,  wormwood ) )  {   
					 
					 
					 
					                if  ( Warehouse . isResourceLocked ( cityWarehouse ,  wormwood ) )  {   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                    ErrorPopupMsg . sendErrorMsg ( pc ,  "Galvor is locked."  +  ib . getName ( ) ) ;   
					 
					 
					 
					                    ErrorPopupMsg . sendErrorMsg ( pc ,  "Galvor is locked."  +  template . item_base_name ) ;   
				
			 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 
					 
					 
					                    return  null ;   
					 
					 
					 
					                    return  null ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                }   
					 
					 
					 
					                }   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					
 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                if  ( cityWarehouse . resources . get ( wormwood )  <  wormwoodAmount )  {   
					 
					 
					 
					                if  ( cityWarehouse . resources . get ( wormwood )  <  wormwoodAmount )  {   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                    ErrorPopupMsg . sendErrorMsg ( pc ,  "Not enough Galvor in warehouse to roll this item."  +  ib . getName ( ) ) ;   
					 
					 
					 
					                    ErrorPopupMsg . sendErrorMsg ( pc ,  "Not enough Galvor in warehouse to roll this item."  +  template . item_base_name ) ;   
				
			 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 
					 
					 
					                    return  null ;   
					 
					 
					 
					                    return  null ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                }   
					 
					 
					 
					                }   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					            }   
					 
					 
					 
					            }   
				
			 
			
		
	
	
		
		
			
				
					
						
							
								 
							 
						
						
							
								 
							 
						
						
					 
					 
					@ -904,18 +907,18 @@ public class ItemFactory { 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                int  overdraft  =  BuildingManager . GetOverdraft ( forge ,  costToCreate ) ;   
					 
					 
					 
					                int  overdraft  =  BuildingManager . GetOverdraft ( forge ,  costToCreate ) ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					
 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                if  ( overdraft  >  0  & &  ! useWarehouse )  {   
					 
					 
					 
					                if  ( overdraft  >  0  & &  ! useWarehouse )  {   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                    ErrorPopupMsg . sendErrorMsg ( pc ,  "Not enough gold in building strongbox."  +  ib . getName ( ) ) ;   
					 
					 
					 
					                    ErrorPopupMsg . sendErrorMsg ( pc ,  "Not enough gold in building strongbox."  +  template . item_base_name ) ;   
				
			 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 
					 
					 
					                    return  null ;   
					 
					 
					 
					                    return  null ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                }   
					 
					 
					 
					                }   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					
 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                if  ( useWarehouse  & &  overdraft  >  0  & &  Warehouse . isResourceLocked ( cityWarehouse ,  ItemBase . GOLD_ITEM_BASE ) )  {   
					 
					 
					 
					                if  ( useWarehouse  & &  overdraft  >  0  & &  Warehouse . isResourceLocked ( cityWarehouse ,  ItemBase . GOLD_ITEM_BASE ) )  {   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                    if  ( pc  ! =  null )   
					 
					 
					 
					                    if  ( pc  ! =  null )   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                        ErrorPopupMsg . sendErrorMsg ( pc ,  "Warehouse gold is barred! Overdraft cannot be withdrawn from warehouse."  +  ib . getName ( ) ) ;   
					 
					 
					 
					                        ErrorPopupMsg . sendErrorMsg ( pc ,  "Warehouse gold is barred! Overdraft cannot be withdrawn from warehouse."  +  template . item_base_name ) ;   
				
			 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 
					 
					 
					                    return  null ;   
					 
					 
					 
					                    return  null ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                }   
					 
					 
					 
					                }   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					
 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                if  ( useWarehouse  & &  overdraft  >  resources . get ( goldIB ) )  {   
					 
					 
					 
					                if  ( useWarehouse  & &  overdraft  >  resources . get ( goldIB ) )  {   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                    ErrorPopupMsg . sendErrorMsg ( pc ,  "Not enough Gold in Warehouse for overdraft."  +  ib . getName ( ) ) ;   
					 
					 
					 
					                    ErrorPopupMsg . sendErrorMsg ( pc ,  "Not enough Gold in Warehouse for overdraft."  +  template . item_base_name ) ;   
				
			 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 
					 
					 
					                    return  null ;   
					 
					 
					 
					                    return  null ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                }   
					 
					 
					 
					                }   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					
 
					 
					 
					 
					
 
				
			 
			
		
	
	
		
		
			
				
					
						
						
						
							
								 
							 
						
					 
					 
					@ -923,11 +926,11 @@ public class ItemFactory { 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                    overdraft  + =  buildingWithdraw ;   
					 
					 
					 
					                    overdraft  + =  buildingWithdraw ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					
 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                    if  ( ! useWarehouse )  {   
					 
					 
					 
					                    if  ( ! useWarehouse )  {   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                        ErrorPopupMsg . sendErrorMsg ( pc ,  "Building does not have enough gold to produce this item."  +  ib . getName ( ) ) ;   
					 
					 
					 
					                        ErrorPopupMsg . sendErrorMsg ( pc ,  "Building does not have enough gold to produce this item."  +  template . item_base_name ) ;   
				
			 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 
					 
					 
					                        return  null ;   
					 
					 
					 
					                        return  null ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                    }  else  {   
					 
					 
					 
					                    }  else  {   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                        if  ( overdraft  >  resources . get ( goldIB ) )  {   
					 
					 
					 
					                        if  ( overdraft  >  resources . get ( goldIB ) )  {   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                            ErrorPopupMsg . sendErrorMsg ( pc ,  "Not enough Gold in Warehouse to produce this item."  +  ib . getName ( ) ) ;   
					 
					 
					 
					                            ErrorPopupMsg . sendErrorMsg ( pc ,  "Not enough Gold in Warehouse to produce this item."  +  template . item_base_name ) ;   
				
			 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 
					 
					 
					                            return  null ;   
					 
					 
					 
					                            return  null ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                        }   
					 
					 
					 
					                        }   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                    }   
					 
					 
					 
					                    }   
				
			 
			
		
	
	
		
		
			
				
					
						
							
								 
							 
						
						
							
								 
							 
						
						
					 
					 
					@ -955,18 +958,18 @@ public class ItemFactory { 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                int  overdraft  =  BuildingManager . GetOverdraft ( forge ,  total ) ;   
					 
					 
					 
					                int  overdraft  =  BuildingManager . GetOverdraft ( forge ,  total ) ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					
 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                if  ( overdraft  >  0  & &  ! useWarehouse )  {   
					 
					 
					 
					                if  ( overdraft  >  0  & &  ! useWarehouse )  {   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                    ErrorPopupMsg . sendErrorMsg ( pc ,  "Not enough gold in building strongbox."  +  ib . getName ( ) ) ;   
					 
					 
					 
					                    ErrorPopupMsg . sendErrorMsg ( pc ,  "Not enough gold in building strongbox."  +  template . item_base_name ) ;   
				
			 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 
					 
					 
					                    return  null ;   
					 
					 
					 
					                    return  null ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                }   
					 
					 
					 
					                }   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					
 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                if  ( useWarehouse  & &  overdraft  >  0  & &  Warehouse . isResourceLocked ( cityWarehouse ,  ItemBase . GOLD_ITEM_BASE ) )  {   
					 
					 
					 
					                if  ( useWarehouse  & &  overdraft  >  0  & &  Warehouse . isResourceLocked ( cityWarehouse ,  ItemBase . GOLD_ITEM_BASE ) )  {   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                    if  ( pc  ! =  null )   
					 
					 
					 
					                    if  ( pc  ! =  null )   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                        ErrorPopupMsg . sendErrorMsg ( pc ,  "Warehouse gold is barred! Overdraft cannot be withdrawn from warehouse."  +  ib . getName ( ) ) ;   
					 
					 
					 
					                        ErrorPopupMsg . sendErrorMsg ( pc ,  "Warehouse gold is barred! Overdraft cannot be withdrawn from warehouse."  +  template . item_base_name ) ;   
				
			 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 
					 
					 
					                    return  null ;   
					 
					 
					 
					                    return  null ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                }   
					 
					 
					 
					                }   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					
 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                if  ( useWarehouse  & &  overdraft  >  resources . get ( goldIB ) )  {   
					 
					 
					 
					                if  ( useWarehouse  & &  overdraft  >  resources . get ( goldIB ) )  {   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                    ErrorPopupMsg . sendErrorMsg ( pc ,  "Not enough Gold in Warehouse for overdraft."  +  ib . getName ( ) ) ;   
					 
					 
					 
					                    ErrorPopupMsg . sendErrorMsg ( pc ,  "Not enough Gold in Warehouse for overdraft."  +  template . item_base_name ) ;   
				
			 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 
					 
					 
					                    return  null ;   
					 
					 
					 
					                    return  null ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                }   
					 
					 
					 
					                }   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					
 
					 
					 
					 
					
 
				
			 
			
		
	
	
		
		
			
				
					
						
						
						
							
								 
							 
						
					 
					 
					@ -974,11 +977,11 @@ public class ItemFactory { 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                    overdraft  + =  buildingWithdraw ;   
					 
					 
					 
					                    overdraft  + =  buildingWithdraw ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					
 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                    if  ( ! useWarehouse )  {   
					 
					 
					 
					                    if  ( ! useWarehouse )  {   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                        ErrorPopupMsg . sendErrorMsg ( pc ,  "Building does not have enough gold to produce this item."  +  ib . getName ( ) ) ;   
					 
					 
					 
					                        ErrorPopupMsg . sendErrorMsg ( pc ,  "Building does not have enough gold to produce this item."  +  template . item_base_name ) ;   
				
			 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 
					 
					 
					                        return  null ;   
					 
					 
					 
					                        return  null ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                    }  else  {   
					 
					 
					 
					                    }  else  {   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                        if  ( overdraft  >  resources . get ( goldIB ) )  {   
					 
					 
					 
					                        if  ( overdraft  >  resources . get ( goldIB ) )  {   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                            ErrorPopupMsg . sendErrorMsg ( pc ,  "Not enough Gold in Warehouse to produce this item."  +  ib . getName ( ) ) ;   
					 
					 
					 
					                            ErrorPopupMsg . sendErrorMsg ( pc ,  "Not enough Gold in Warehouse to produce this item."  +  template . item_base_name ) ;   
				
			 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 
					 
					 
					                            return  null ;   
					 
					 
					 
					                            return  null ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                        }   
					 
					 
					 
					                        }   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                    }   
					 
					 
					 
					                    }   
				
			 
			
		
	
	
		
		
			
				
					
						
						
						
							
								 
							 
						
					 
					 
					@ -1003,7 +1006,7 @@ public class ItemFactory { 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					            if  ( galvorAmount  >  0  & &  useWarehouse )  {   
					 
					 
					 
					            if  ( galvorAmount  >  0  & &  useWarehouse )  {   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                //ChatManager.chatGuildInfo(pc, "Withdrawing " + galvorAmount + " galvor from warehouse");
   
					 
					 
					 
					                //ChatManager.chatGuildInfo(pc, "Withdrawing " + galvorAmount + " galvor from warehouse");
   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                if  ( ! Warehouse . withdraw ( cityWarehouse ,  npc ,  galvor ,  galvorAmount ,  true ) )  {   
					 
					 
					 
					                if  ( ! Warehouse . withdraw ( cityWarehouse ,  npc ,  galvor ,  galvorAmount ,  true ) )  {   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                    ErrorPopupMsg . sendErrorMsg ( pc ,  "Failed to withdraw Galvor from warehouse!"  +  ib . getName ( ) ) ;   
					 
					 
					 
					                    ErrorPopupMsg . sendErrorMsg ( pc ,  "Failed to withdraw Galvor from warehouse!"  +  template . item_base_name ) ;   
				
			 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 
					 
					 
					                    Logger . error ( "Warehouse with UID of"  +  cityWarehouse . getObjectUUID ( )  +  "Failed to Withdrawl " ) ;   
					 
					 
					 
					                    Logger . error ( "Warehouse with UID of"  +  cityWarehouse . getObjectUUID ( )  +  "Failed to Withdrawl " ) ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                    return  null ;   
					 
					 
					 
					                    return  null ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                }   
					 
					 
					 
					                }   
				
			 
			
		
	
	
		
		
			
				
					
						
						
						
							
								 
							 
						
					 
					 
					@ -1012,7 +1015,7 @@ public class ItemFactory { 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					            if  ( wormwoodAmount  >  0  & &  useWarehouse )  {   
					 
					 
					 
					            if  ( wormwoodAmount  >  0  & &  useWarehouse )  {   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                //ChatManager.chatGuildInfo(pc, "Withdrawing " + wormwoodAmount + " wormwood from warehouse");
   
					 
					 
					 
					                //ChatManager.chatGuildInfo(pc, "Withdrawing " + wormwoodAmount + " wormwood from warehouse");
   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                if  ( ! Warehouse . withdraw ( cityWarehouse ,  npc ,  wormwood ,  wormwoodAmount ,  true ) )  {   
					 
					 
					 
					                if  ( ! Warehouse . withdraw ( cityWarehouse ,  npc ,  wormwood ,  wormwoodAmount ,  true ) )  {   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                    ErrorPopupMsg . sendErrorMsg ( pc ,  "Failed to withdraw Wormwood from warehouse for "  +  ib . getName ( ) ) ;   
					 
					 
					 
					                    ErrorPopupMsg . sendErrorMsg ( pc ,  "Failed to withdraw Wormwood from warehouse for "  +  template . item_base_name ) ;   
				
			 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 
					 
					 
					                    Logger . error ( "Warehouse with UID of"  +  cityWarehouse . getObjectUUID ( )  +  "Failed to Withdrawl " ) ;   
					 
					 
					 
					                    Logger . error ( "Warehouse with UID of"  +  cityWarehouse . getObjectUUID ( )  +  "Failed to Withdrawl " ) ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					
 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                    return  null ;   
					 
					 
					 
					                    return  null ;