diff --git a/Server/src/main/core/ServerConstants.kt b/Server/src/main/core/ServerConstants.kt index 277a4d108..318cf364c 100644 --- a/Server/src/main/core/ServerConstants.kt +++ b/Server/src/main/core/ServerConstants.kt @@ -284,5 +284,11 @@ class ServerConstants { @JvmField var IRONMAN_ICONS = false + + @JvmField + var PLAYER_STOCK_CLEAR_INTERVAL = 1 + + @JvmField + var PLAYER_STOCK_RECIRCULATE = true } } diff --git a/Server/src/main/core/game/shops/Shops.kt b/Server/src/main/core/game/shops/Shops.kt index 6114aeaa6..52a8de020 100644 --- a/Server/src/main/core/game/shops/Shops.kt +++ b/Server/src/main/core/game/shops/Shops.kt @@ -16,9 +16,9 @@ import core.game.interaction.IntType import core.game.interaction.InterfaceListener import core.tools.SystemLogger import core.game.system.command.Privilege -import core.tools.END_DIALOGUE -import core.tools.Log import java.io.FileReader +import core.tools.* +import core.game.ge.* /** * The "controller" class for shops. Handles opening shops from various NPC interactions and updating stock, etc. @@ -34,6 +34,7 @@ class Shops : StartupListener, TickListener, InteractionListener, InterfaceListe @JvmStatic val personalizedShops = "world.personalized_shops" @JvmStatic val shopsById = HashMap() @JvmStatic val shopsByNpc = HashMap() + private var lastPlayerStockClear = 0 @JvmStatic fun openId(player: Player, id: Int) { @@ -109,6 +110,16 @@ class Shops : StartupListener, TickListener, InteractionListener, InterfaceListe override fun tick() { shopsById.values.forEach(Shop::restock) + + val playerStockClearInterval = secondsToTicks(ServerConstants.PLAYER_STOCK_CLEAR_INTERVAL * 60) + if (getWorldTicks() % playerStockClearInterval == 0) { + val clearToGe = ServerConstants.PLAYER_STOCK_RECIRCULATE + if (clearToGe) { + for (item in Shop.generalPlayerStock.toArray().filter{it != null}) + GrandExchange.addBotOffer(item.id, item.amount) + } + Shop.generalPlayerStock.clear() + } } override fun defineListeners() { @@ -266,4 +277,4 @@ class Shops : StartupListener, TickListener, InteractionListener, InterfaceListe player.packetDispatch.sendRunScript(25, "vg", arg1, 92) //Run CS2 script 25, with args 868? and 92(our container id) } } -} \ No newline at end of file +} diff --git a/Server/src/main/core/game/system/config/ServerConfigParser.kt b/Server/src/main/core/game/system/config/ServerConfigParser.kt index 5dd559b87..f12d7065e 100644 --- a/Server/src/main/core/game/system/config/ServerConfigParser.kt +++ b/Server/src/main/core/game/system/config/ServerConfigParser.kt @@ -152,6 +152,8 @@ object ServerConfigParser { ServerConstants.ENABLE_GLOBALCHAT = data.getBoolean("world.enable_globalchat", true) ServerConstants.MAX_PATHFIND_DISTANCE = data.getLong("server.max_pathfind_dist", 25L).toInt() ServerConstants.IRONMAN_ICONS = data.getBoolean("world.ironman_icons", false) + ServerConstants.PLAYER_STOCK_CLEAR_INTERVAL = data.getLong("world.playerstock_clear_mins", 180L).toInt() + ServerConstants.PLAYER_STOCK_RECIRCULATE = data.getBoolean("world.playerstock_bot_offers", true) val logLevel = data.getString("server.log_level", "VERBOSE").uppercase() ServerConstants.LOG_LEVEL = parseEnumEntry(logLevel) ?: LogLevel.VERBOSE