diff --git a/Server/src/main/java/core/game/node/entity/Entity.java b/Server/src/main/java/core/game/node/entity/Entity.java index a0f07e7df..af22dead8 100644 --- a/Server/src/main/java/core/game/node/entity/Entity.java +++ b/Server/src/main/java/core/game/node/entity/Entity.java @@ -728,7 +728,7 @@ public abstract class Entity extends Node { * @param key The attribute name. */ public void incrementAttribute(String key, int amount) { - attributes.setAttribute(key, attributes.getAttribute(key.replace("/save:",""), 0) + amount); + attributes.setAttribute(key, attributes.getAttribute(key, 0) + amount); } /** diff --git a/Server/src/main/kotlin/rs09/game/VarpManager.kt b/Server/src/main/kotlin/rs09/game/VarpManager.kt index 3bdc7c7e9..982254b7d 100644 --- a/Server/src/main/kotlin/rs09/game/VarpManager.kt +++ b/Server/src/main/kotlin/rs09/game/VarpManager.kt @@ -4,6 +4,7 @@ import core.cache.def.impl.VarbitDefinition import core.game.node.entity.player.Player import org.json.simple.JSONArray import org.json.simple.JSONObject +import rs09.game.node.entity.skill.farming.FarmingPatch /** * Manages the collection of a player's varps. @@ -74,9 +75,13 @@ class VarpManager(val player: Player) { } fun parse(data: JSONArray){ + val patch_varps = FarmingPatch.values().map { it.varpIndex }.toIntArray() + val bin_varps = FarmingPatch.values().map { it.varpIndex }.toIntArray() for(varpobj in data){ val vobj = varpobj as JSONObject val index = vobj["index"].toString().toInt() + if(patch_varps.contains(index)) continue + if(bin_varps.contains(index)) continue val varp = get(index) val bits = vobj["bitArray"] as JSONArray for(vbit in bits){ diff --git a/Server/src/main/kotlin/rs09/game/content/jobs/JobManager.kt b/Server/src/main/kotlin/rs09/game/content/jobs/JobManager.kt index a576457da..4ff12bd64 100644 --- a/Server/src/main/kotlin/rs09/game/content/jobs/JobManager.kt +++ b/Server/src/main/kotlin/rs09/game/content/jobs/JobManager.kt @@ -7,6 +7,7 @@ import core.game.node.entity.player.Player import core.game.node.item.GroundItemManager import core.game.node.item.Item import rs09.game.system.SystemLogger +import java.util.concurrent.TimeUnit object JobManager { @JvmStatic @@ -51,6 +52,11 @@ object JobManager { val amt = player.getAttribute("jobs:original_amount",0) val type = player.getAttribute("jobs:type",0) val jobId = player.getAttribute("jobs:id",0) + val dailyDone = player.getAttribute("jobs:dailyAmt",0) + if(dailyDone == 3){ + player.dialogueInterpreter.sendDialogue("You can only complete 3 jobs per day.") + return + } if(type == 0){ val it = Item(GatheringJobs.values()[jobId].itemId) var amount = player.inventory.getAmount(it) @@ -82,5 +88,9 @@ object JobManager { player.removeAttribute("jobs:amount") player.removeAttribute("jobs:original_amount") player.removeAttribute("jobs:type") + player.incrementAttribute("/save:jobs:dailyAmt",1) + if(player.getAttribute("jobs:dailyAmt",0) == 3){ + player.setAttribute("/save:jobs:reset_time",System.currentTimeMillis() + TimeUnit.HOURS.toMillis(24)) + } } } \ No newline at end of file diff --git a/Server/src/main/kotlin/rs09/game/content/jobs/WorkForInteractionListener.kt b/Server/src/main/kotlin/rs09/game/content/jobs/WorkForInteractionListener.kt index 755f286a1..034803b21 100644 --- a/Server/src/main/kotlin/rs09/game/content/jobs/WorkForInteractionListener.kt +++ b/Server/src/main/kotlin/rs09/game/content/jobs/WorkForInteractionListener.kt @@ -57,6 +57,10 @@ class WorkForInteractionListener : InteractionListener() { var amount = 0 var jobId = 0 + if(player.getAttribute("jobs:reset_time",0L) < System.currentTimeMillis()){ + player.setAttribute("/save:jobs:dailyAmt",0) + } + if(player.getAttribute("jobs:id",-1) != -1){ JobManager.rewardPlayer(player,node.asNpc()) return@on true diff --git a/Server/src/main/kotlin/rs09/game/node/entity/player/info/login/PlayerSaveParser.kt b/Server/src/main/kotlin/rs09/game/node/entity/player/info/login/PlayerSaveParser.kt index b36e1b0e9..c2b865534 100644 --- a/Server/src/main/kotlin/rs09/game/node/entity/player/info/login/PlayerSaveParser.kt +++ b/Server/src/main/kotlin/rs09/game/node/entity/player/info/login/PlayerSaveParser.kt @@ -15,6 +15,7 @@ import org.json.simple.JSONArray import org.json.simple.JSONObject import org.json.simple.parser.JSONParser import rs09.ServerConstants +import rs09.game.node.entity.skill.farming.FarmingPatch import rs09.game.system.SystemLogger import rs09.game.world.GameWorld import java.io.FileReader @@ -31,6 +32,9 @@ class PlayerSaveParser(val player: Player) { var saveFile: JSONObject? = null var read = true + val patch_varps = FarmingPatch.values().map { it.varpIndex }.toIntArray() + val bin_varps = FarmingPatch.values().map { it.varpIndex }.toIntArray() + init { reader ?: SystemLogger.logWarn("Couldn't find save file for ${player.name}, or save is corrupted.").also { read = false } @@ -246,6 +250,8 @@ class PlayerSaveParser(val player: Player) { val c = config as JSONObject val index = (c.get("index") as String).toInt() if(index == 1048) continue + if(patch_varps.contains(index)) continue + if(bin_varps.contains(index)) continue val value = (c.get("value") as String).toInt() player.configManager.savedConfigurations[index] = value }