New problem: How to I set a market's demand for a commodity to zero? I tried the following in EconomyUpdateListener.commodityUpdated()
CommodityOnMarketAPI com = market.getCommodityData(commodityId);
String modId = market.getId();
market.getDemand(com.getDemandClass()).getDemand().modifyMult(modId, 0);
com.getDemand().getDemand().modifyMult(modId, 0);
but the market's industries still generate their usual demand.
Ah, yeah, you don't want to generally mess with that - this is only used for determining the player-facing prices of things. It operates in "cargo units", not "economy units", so just generally it's not what you're looking for.
CommodityOnMarketAPI.getMaxDemand() is what's used here, and that returns the maximum demand out of all the industries that have demand for the commodity.
So I think what would work is:
For each IndustryAPI, call getDemand(String commodityId); this returns a MutableCommodityQuantity.
This has a MutableStat quantity, which you could modifyMult(modId, 0). I *believe* this should work.
EDIT: Also, how often is EconomyUpdateListener.economyUpdated() called? I'm wondering if it's safe to use for a monthly upkeep-style cost or if I should use reportEconomyTick insead.
Yeah, you want to use EconomyTickListener. EconomyUpdateListener gets called any time the economy is synched up, such as say when the player visits a colony.