From c3d48ff36e0c1883221c48a559a805a0357c64d2 Mon Sep 17 00:00:00 2001 From: Ceikry Date: Tue, 6 Jun 2023 00:19:18 +0000 Subject: [PATCH] Added configurable limit for GE bot offers, now set by world.botstock_limit config (defaults to 5000) --- Server/src/main/core/ServerConstants.kt | 3 +++ Server/src/main/core/game/ge/GrandExchangeOffer.kt | 7 +++++-- .../src/main/core/game/system/config/ServerConfigParser.kt | 1 + 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/Server/src/main/core/ServerConstants.kt b/Server/src/main/core/ServerConstants.kt index 318cf364c..0f3826ec1 100644 --- a/Server/src/main/core/ServerConstants.kt +++ b/Server/src/main/core/ServerConstants.kt @@ -290,5 +290,8 @@ class ServerConstants { @JvmField var PLAYER_STOCK_RECIRCULATE = true + + @JvmField + var BOTSTOCK_LIMIT = 5000 } } diff --git a/Server/src/main/core/game/ge/GrandExchangeOffer.kt b/Server/src/main/core/game/ge/GrandExchangeOffer.kt index 3a7522919..919427567 100644 --- a/Server/src/main/core/game/ge/GrandExchangeOffer.kt +++ b/Server/src/main/core/game/ge/GrandExchangeOffer.kt @@ -11,7 +11,9 @@ import core.net.packet.out.ContainerPacket import core.net.packet.out.GrandExchangePacket import core.integrations.discord.Discord import core.game.world.repository.Repository +import kotlin.math.min import java.sql.ResultSet +import core.ServerConstants /** @@ -22,7 +24,6 @@ import java.sql.ResultSet class GrandExchangeOffer() { var itemID = 0 - var amount = 0 var completedAmount = 0 var offeredValue = 0 var index = 0 @@ -37,6 +38,8 @@ class GrandExchangeOffer() { var isLimitation = false var isBot = false + var amount: Int = 0 + get() = if (isBot) min(field, ServerConstants.BOTSTOCK_LIMIT) else field /** * Gets the total amount of money entered. * @return The total value. @@ -49,7 +52,7 @@ class GrandExchangeOffer() { * @return The amount. */ val amountLeft: Int - get() = amount - completedAmount + get() = if (isBot) min(ServerConstants.BOTSTOCK_LIMIT, amount - completedAmount) else amount - completedAmount /** * Checks if this offer is still active for dispatching. diff --git a/Server/src/main/core/game/system/config/ServerConfigParser.kt b/Server/src/main/core/game/system/config/ServerConfigParser.kt index f12d7065e..1ca8e70de 100644 --- a/Server/src/main/core/game/system/config/ServerConfigParser.kt +++ b/Server/src/main/core/game/system/config/ServerConfigParser.kt @@ -154,6 +154,7 @@ object ServerConfigParser { 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) + ServerConstants.BOTSTOCK_LIMIT = data.getLong("world.botstock_limit", 5000L).toInt() val logLevel = data.getString("server.log_level", "VERBOSE").uppercase() ServerConstants.LOG_LEVEL = parseEnumEntry(logLevel) ?: LogLevel.VERBOSE