Repository reorganisation
Unified kotlin and java into just src/main Unified the rs09 and core packages Took all content out of the core package, and placed it into the new content package Reorganised all source code relating to content to be easier to find and explore
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
package content.global.skill.farming
|
||||
|
||||
import core.cache.def.impl.SceneryDefinition
|
||||
import core.game.interaction.OptionHandler
|
||||
import core.game.node.Node
|
||||
import core.game.node.entity.player.Player
|
||||
import core.game.node.entity.skill.Skills
|
||||
import core.tools.SystemLogger
|
||||
import core.plugin.Initializable
|
||||
import core.plugin.Plugin
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
@Initializable
|
||||
class HealthChecker : OptionHandler(){
|
||||
override fun newInstance(arg: Any?): Plugin<Any> {
|
||||
SceneryDefinition.setOptionHandler("check-health",this)
|
||||
return this
|
||||
}
|
||||
|
||||
override fun handle(player: Player?, node: Node?, option: String?): Boolean {
|
||||
player ?: return false
|
||||
node ?: return false
|
||||
val fPatch = FarmingPatch.forObject(node.asScenery())
|
||||
fPatch ?: return false
|
||||
val patch = fPatch.getPatchFor(player)
|
||||
val type = patch.patch.type
|
||||
|
||||
if(type != PatchType.BUSH && type != PatchType.FRUIT_TREE && type != PatchType.TREE && type != PatchType.CACTUS){
|
||||
player.sendMessage("This shouldn't be happening. Please report this.")
|
||||
return true
|
||||
}
|
||||
|
||||
if(!patch.isCheckHealth) return true
|
||||
|
||||
player.skills.addExperience(Skills.FARMING,patch.plantable?.checkHealthXP ?: 0.0)
|
||||
patch.isCheckHealth = false
|
||||
when(type){
|
||||
PatchType.TREE -> patch.setCurrentState(patch.getCurrentState() + 1)
|
||||
PatchType.FRUIT_TREE -> patch.setCurrentState(patch.getCurrentState() - 14)
|
||||
PatchType.BUSH -> patch.setCurrentState(patch.plantable!!.value + patch.plantable!!.stages + 4)
|
||||
PatchType.CACTUS -> patch.setCurrentState(patch.plantable!!.value + patch.plantable!!.stages + 3)
|
||||
else -> SystemLogger.logErr(this::class.java,"Unreachable patch type from when(type) switch in HealthChecker.kt line 36")
|
||||
}
|
||||
|
||||
if(type == PatchType.FRUIT_TREE){
|
||||
patch.nextGrowth = TimeUnit.MINUTES.toMillis(45)
|
||||
}
|
||||
|
||||
patch.update()
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user