Player Stock is now cleared from the general store at an interval defined by world.playerstock_clear_mins (defaults to 180 minutes)
Player Stock can now be recirculated back onto the GE as bot offers when cleared if world.playerstock_bot_offers is true (defaults to true)
This commit is contained in:
@@ -284,5 +284,11 @@ class ServerConstants {
|
|||||||
|
|
||||||
@JvmField
|
@JvmField
|
||||||
var IRONMAN_ICONS = false
|
var IRONMAN_ICONS = false
|
||||||
|
|
||||||
|
@JvmField
|
||||||
|
var PLAYER_STOCK_CLEAR_INTERVAL = 1
|
||||||
|
|
||||||
|
@JvmField
|
||||||
|
var PLAYER_STOCK_RECIRCULATE = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,9 +16,9 @@ import core.game.interaction.IntType
|
|||||||
import core.game.interaction.InterfaceListener
|
import core.game.interaction.InterfaceListener
|
||||||
import core.tools.SystemLogger
|
import core.tools.SystemLogger
|
||||||
import core.game.system.command.Privilege
|
import core.game.system.command.Privilege
|
||||||
import core.tools.END_DIALOGUE
|
|
||||||
import core.tools.Log
|
|
||||||
import java.io.FileReader
|
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.
|
* 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 personalizedShops = "world.personalized_shops"
|
||||||
@JvmStatic val shopsById = HashMap<Int, Shop>()
|
@JvmStatic val shopsById = HashMap<Int, Shop>()
|
||||||
@JvmStatic val shopsByNpc = HashMap<Int, Shop>()
|
@JvmStatic val shopsByNpc = HashMap<Int, Shop>()
|
||||||
|
private var lastPlayerStockClear = 0
|
||||||
|
|
||||||
@JvmStatic fun openId(player: Player, id: Int)
|
@JvmStatic fun openId(player: Player, id: Int)
|
||||||
{
|
{
|
||||||
@@ -109,6 +110,16 @@ class Shops : StartupListener, TickListener, InteractionListener, InterfaceListe
|
|||||||
|
|
||||||
override fun tick() {
|
override fun tick() {
|
||||||
shopsById.values.forEach(Shop::restock)
|
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() {
|
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)
|
player.packetDispatch.sendRunScript(25, "vg", arg1, 92) //Run CS2 script 25, with args 868? and 92(our container id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -152,6 +152,8 @@ object ServerConfigParser {
|
|||||||
ServerConstants.ENABLE_GLOBALCHAT = data.getBoolean("world.enable_globalchat", true)
|
ServerConstants.ENABLE_GLOBALCHAT = data.getBoolean("world.enable_globalchat", true)
|
||||||
ServerConstants.MAX_PATHFIND_DISTANCE = data.getLong("server.max_pathfind_dist", 25L).toInt()
|
ServerConstants.MAX_PATHFIND_DISTANCE = data.getLong("server.max_pathfind_dist", 25L).toInt()
|
||||||
ServerConstants.IRONMAN_ICONS = data.getBoolean("world.ironman_icons", false)
|
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()
|
val logLevel = data.getString("server.log_level", "VERBOSE").uppercase()
|
||||||
ServerConstants.LOG_LEVEL = parseEnumEntry<LogLevel>(logLevel) ?: LogLevel.VERBOSE
|
ServerConstants.LOG_LEVEL = parseEnumEntry<LogLevel>(logLevel) ?: LogLevel.VERBOSE
|
||||||
|
|||||||
Reference in New Issue
Block a user