All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.lop.devtools.monstera.files.animcontroller.AnimControllerVariables.kt Maven / Gradle / Ivy

Go to download

A library and environment designed to streamline the development of Minecraft addons.

There is a newer version: 0.4.5
Show newest version
package com.lop.devtools.monstera.files.animcontroller

import com.lop.devtools.monstera.addon.api.MonsteraFile
import com.lop.devtools.monstera.addon.api.MonsteraUnsafeMap
import com.lop.devtools.monstera.addon.molang.Molang
import com.lop.devtools.monstera.addon.molang.Variable

class AnimControllerVariables: MonsteraFile {
    override val unsafe = Unsafe()

    inner class Unsafe: MonsteraUnsafeMap {
        val general = mutableMapOf()

        override fun getData() = general

        fun getAsList(): List {
            return general.map { (k, v) -> "$k=$v;" }
        }
    }

    fun set(name: String, value: String) {
        val variable = if (name.startsWith("variable.") || name.startsWith("temp.") || name.startsWith("v.")) {
            name
        } else {
            "variable.$name"
        }
        unsafe.general[variable] = value
    }

    fun set(name: String, exp: Molang) {
        set(name, exp.toString())
    }

    fun set(value: Variable) {
        val (k, v) = value.data.dropLastWhile { it == ';' }.split("=")
        unsafe.general[k] = v
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy