mirror of
https://gitlab.com/2009scape/2009scape.git
synced 2025-12-12 17:40:17 -07:00
Added exclusions for old farming varps + daily job limit
This commit is contained in:
parent
68195eaeb7
commit
b83dd22f2e
5 changed files with 26 additions and 1 deletions
|
|
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -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){
|
||||
|
|
|
|||
|
|
@ -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))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue