Revert name changes

This commit is contained in:
CranberrySoup 2024-06-20 19:37:55 +02:00
parent c38bc8aabf
commit 1ed94c5a92
2 changed files with 8 additions and 7 deletions

View file

@ -34,7 +34,7 @@ abstract class Plugin {
*/ */
fun registerMainAPI(element: MainAPI) { fun registerMainAPI(element: MainAPI) {
Log.i(PLUGIN_TAG, "Adding ${element.name} (${element.mainUrl}) MainAPI") Log.i(PLUGIN_TAG, "Adding ${element.name} (${element.mainUrl}) MainAPI")
element.sourcePlugin = this.__filepath element.sourcePlugin = this.__filename
// Race condition causing which would case duplicates if not for distinctBy // Race condition causing which would case duplicates if not for distinctBy
synchronized(APIHolder.allProviders) { synchronized(APIHolder.allProviders) {
APIHolder.allProviders.add(element) APIHolder.allProviders.add(element)
@ -48,7 +48,7 @@ abstract class Plugin {
*/ */
fun registerExtractorAPI(element: ExtractorApi) { fun registerExtractorAPI(element: ExtractorApi) {
Log.i(PLUGIN_TAG, "Adding ${element.name} (${element.mainUrl}) ExtractorApi") Log.i(PLUGIN_TAG, "Adding ${element.name} (${element.mainUrl}) ExtractorApi")
element.sourcePlugin = this.__filepath element.sourcePlugin = this.__filename
extractorApis.add(element) extractorApis.add(element)
} }
@ -67,7 +67,8 @@ abstract class Plugin {
* This will contain your resources if you specified requiresResources in gradle * This will contain your resources if you specified requiresResources in gradle
*/ */
var resources: Resources? = null var resources: Resources? = null
var __filepath: String? = null /** Full file path to the plugin. */
var __filename: String? = null
/** /**
* This will add a button in the settings allowing you to add custom settings * This will add a button in the settings allowing you to add custom settings

View file

@ -517,7 +517,7 @@ object PluginManager {
return true return true
} }
pluginInstance.__filepath = file.absolutePath pluginInstance.__filename = file.absolutePath
if (manifest.requiresResources) { if (manifest.requiresResources) {
Log.d(TAG, "Loading resources for ${data.internalName}") Log.d(TAG, "Loading resources for ${data.internalName}")
// based on https://stackoverflow.com/questions/7483568/dynamic-resource-loading-from-other-apk // based on https://stackoverflow.com/questions/7483568/dynamic-resource-loading-from-other-apk
@ -566,14 +566,14 @@ object PluginManager {
// remove all registered apis // remove all registered apis
synchronized(APIHolder.apis) { synchronized(APIHolder.apis) {
APIHolder.apis.filter { api -> api.sourcePlugin == plugin.__filepath }.forEach { APIHolder.apis.filter { api -> api.sourcePlugin == plugin.__filename }.forEach {
removePluginMapping(it) removePluginMapping(it)
} }
} }
synchronized(APIHolder.allProviders) { synchronized(APIHolder.allProviders) {
APIHolder.allProviders.removeIf { provider: MainAPI -> provider.sourcePlugin == plugin.__filepath } APIHolder.allProviders.removeIf { provider: MainAPI -> provider.sourcePlugin == plugin.__filename }
} }
extractorApis.removeIf { provider: ExtractorApi -> provider.sourcePlugin == plugin.__filepath } extractorApis.removeIf { provider: ExtractorApi -> provider.sourcePlugin == plugin.__filename }
classLoaders.values.removeIf { v -> v == plugin } classLoaders.values.removeIf { v -> v == plugin }