fix: Crashing when launching without jade
This commit is contained in:
@@ -163,7 +163,7 @@ fun createIsolatedSourceSet(name: String, path: String = "compat/$name", isEnabl
|
|||||||
extendsFrom(getByName(mainSS.annotationProcessorConfigurationName))
|
extendsFrom(getByName(mainSS.annotationProcessorConfigurationName))
|
||||||
}
|
}
|
||||||
(mainSS.runtimeOnlyConfigurationName) {
|
(mainSS.runtimeOnlyConfigurationName) {
|
||||||
extendsFrom(getByName(ss.runtimeClasspathConfigurationName))
|
// extendsFrom(getByName(ss.runtimeClasspathConfigurationName))
|
||||||
}
|
}
|
||||||
("ksp$upperName") {
|
("ksp$upperName") {
|
||||||
extendsFrom(ksp.get())
|
extendsFrom(ksp.get())
|
||||||
|
|||||||
@@ -34,86 +34,91 @@ import moe.nea.firmament.features.world.Waypoints
|
|||||||
import moe.nea.firmament.util.data.DataHolder
|
import moe.nea.firmament.util.data.DataHolder
|
||||||
|
|
||||||
object FeatureManager : DataHolder<FeatureManager.Config>(serializer(), "features", ::Config) {
|
object FeatureManager : DataHolder<FeatureManager.Config>(serializer(), "features", ::Config) {
|
||||||
@Serializable
|
@Serializable
|
||||||
data class Config(
|
data class Config(
|
||||||
val enabledFeatures: MutableMap<String, Boolean> = mutableMapOf()
|
val enabledFeatures: MutableMap<String, Boolean> = mutableMapOf()
|
||||||
)
|
)
|
||||||
|
|
||||||
private val features = mutableMapOf<String, FirmamentFeature>()
|
private val features = mutableMapOf<String, FirmamentFeature>()
|
||||||
|
|
||||||
val allFeatures: Collection<FirmamentFeature> get() = features.values
|
val allFeatures: Collection<FirmamentFeature> get() = features.values
|
||||||
|
|
||||||
private var hasAutoloaded = false
|
private var hasAutoloaded = false
|
||||||
|
|
||||||
fun autoload() {
|
fun autoload() {
|
||||||
synchronized(this) {
|
synchronized(this) {
|
||||||
if (hasAutoloaded) return
|
if (hasAutoloaded) return
|
||||||
loadFeature(MinorTrolling)
|
loadFeature(MinorTrolling)
|
||||||
loadFeature(FairySouls)
|
loadFeature(FairySouls)
|
||||||
loadFeature(AutoCompletions)
|
loadFeature(AutoCompletions)
|
||||||
// TODO: loadFeature(FishingWarning)
|
// TODO: loadFeature(FishingWarning)
|
||||||
loadFeature(SlotLocking)
|
loadFeature(SlotLocking)
|
||||||
loadFeature(StorageOverlay)
|
loadFeature(StorageOverlay)
|
||||||
loadFeature(PristineProfitTracker)
|
loadFeature(PristineProfitTracker)
|
||||||
loadFeature(CraftingOverlay)
|
loadFeature(CraftingOverlay)
|
||||||
loadFeature(PowerUserTools)
|
loadFeature(PowerUserTools)
|
||||||
loadFeature(Waypoints)
|
loadFeature(Waypoints)
|
||||||
loadFeature(ChatLinks)
|
loadFeature(ChatLinks)
|
||||||
loadFeature(InventoryButtons)
|
loadFeature(InventoryButtons)
|
||||||
loadFeature(CompatibliltyFeatures)
|
loadFeature(CompatibliltyFeatures)
|
||||||
loadFeature(AnniversaryFeatures)
|
loadFeature(AnniversaryFeatures)
|
||||||
loadFeature(QuickCommands)
|
loadFeature(QuickCommands)
|
||||||
loadFeature(PetFeatures)
|
loadFeature(PetFeatures)
|
||||||
loadFeature(SaveCursorPosition)
|
loadFeature(SaveCursorPosition)
|
||||||
loadFeature(PriceData)
|
loadFeature(PriceData)
|
||||||
loadFeature(Fixes)
|
loadFeature(Fixes)
|
||||||
loadFeature(DianaWaypoints)
|
loadFeature(DianaWaypoints)
|
||||||
loadFeature(ItemRarityCosmetics)
|
loadFeature(ItemRarityCosmetics)
|
||||||
loadFeature(PickaxeAbility)
|
loadFeature(PickaxeAbility)
|
||||||
loadFeature(CarnivalFeatures)
|
loadFeature(CarnivalFeatures)
|
||||||
if (Firmament.DEBUG) {
|
if (Firmament.DEBUG) {
|
||||||
loadFeature(DeveloperFeatures)
|
loadFeature(DeveloperFeatures)
|
||||||
loadFeature(DebugView)
|
loadFeature(DebugView)
|
||||||
}
|
}
|
||||||
allFeatures.forEach { it.config }
|
allFeatures.forEach { it.config }
|
||||||
FeaturesInitializedEvent.publish(FeaturesInitializedEvent(allFeatures.toList()))
|
FeaturesInitializedEvent.publish(FeaturesInitializedEvent(allFeatures.toList()))
|
||||||
hasAutoloaded = true
|
hasAutoloaded = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun subscribeEvents() {
|
fun subscribeEvents() {
|
||||||
SubscriptionList.allLists.forEach {
|
SubscriptionList.allLists.forEach { list ->
|
||||||
it.provideSubscriptions {
|
runCatching {
|
||||||
it.owner.javaClass.classes.forEach {
|
list.provideSubscriptions {
|
||||||
runCatching { it.getDeclaredField("INSTANCE").get(null) }
|
it.owner.javaClass.classes.forEach {
|
||||||
|
runCatching { it.getDeclaredField("INSTANCE").get(null) }
|
||||||
|
}
|
||||||
|
subscribeSingleEvent(it)
|
||||||
}
|
}
|
||||||
subscribeSingleEvent(it)
|
}.getOrElse {
|
||||||
}
|
// TODO: allow annotating source sets to specifically opt out of loading for mods, maybe automatically
|
||||||
}
|
Firmament.logger.info("Ignoring events from $list, likely due to a missing compat mod.", it)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun <T : FirmamentEvent> subscribeSingleEvent(it: Subscription<T>) {
|
private fun <T : FirmamentEvent> subscribeSingleEvent(it: Subscription<T>) {
|
||||||
it.eventBus.subscribe(false, "${it.owner.javaClass.simpleName}:${it.methodName}", it.invoke)
|
it.eventBus.subscribe(false, "${it.owner.javaClass.simpleName}:${it.methodName}", it.invoke)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun loadFeature(feature: FirmamentFeature) {
|
fun loadFeature(feature: FirmamentFeature) {
|
||||||
synchronized(features) {
|
synchronized(features) {
|
||||||
if (feature.identifier in features) {
|
if (feature.identifier in features) {
|
||||||
Firmament.logger.error("Double registering feature ${feature.identifier}. Ignoring second instance $feature")
|
Firmament.logger.error("Double registering feature ${feature.identifier}. Ignoring second instance $feature")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
features[feature.identifier] = feature
|
features[feature.identifier] = feature
|
||||||
feature.onLoad()
|
feature.onLoad()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun isEnabled(identifier: String): Boolean? =
|
fun isEnabled(identifier: String): Boolean? =
|
||||||
data.enabledFeatures[identifier]
|
data.enabledFeatures[identifier]
|
||||||
|
|
||||||
|
|
||||||
fun setEnabled(identifier: String, value: Boolean) {
|
fun setEnabled(identifier: String, value: Boolean) {
|
||||||
data.enabledFeatures[identifier] = value
|
data.enabledFeatures[identifier] = value
|
||||||
markDirty()
|
markDirty()
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user