generated from Astra-Interactive/AstraTemplate
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add custom currency selection, fix paths for configs (#35)
- Loading branch information
1 parent
18c98de
commit edbde56
Showing
16 changed files
with
110 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ makeevrserg.java.ktarget=21 | |
# Project | ||
makeevrserg.project.name=AstraShop | ||
makeevrserg.project.group=ru.astrainteractive.astrashop | ||
makeevrserg.project.version.string=4.11.7 | ||
makeevrserg.project.version.string=4.12.0 | ||
makeevrserg.project.description=Shop plugin for EmpireSMP | ||
makeevrserg.project.developers=makeevrserg|Makeev Roman|[email protected] | ||
makeevrserg.project.url=https://empireprojekt.ru | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
...in/kotlin/ru/astrainteractive/astrashop/core/di/factory/CurrencyEconomyProviderFactory.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package ru.astrainteractive.astrashop.core.di.factory | ||
|
||
import net.milkbowl.vault.economy.Economy | ||
import org.bukkit.Bukkit | ||
import org.bukkit.plugin.java.JavaPlugin | ||
import ru.astrainteractive.astralibs.economy.EconomyProvider | ||
import ru.astrainteractive.astralibs.economy.EssentialsEconomyProvider | ||
import ru.astrainteractive.astralibs.economy.VaultEconomyProvider | ||
import ru.astrainteractive.astralibs.logging.JUtiltLogger | ||
import ru.astrainteractive.astralibs.logging.Logger | ||
|
||
interface CurrencyEconomyProviderFactory { | ||
fun findByCurrencyId(currencyId: String): EconomyProvider? | ||
fun findDefault(): EconomyProvider? | ||
} | ||
|
||
internal class CurrencyEconomyProviderFactoryImpl( | ||
private val plugin: JavaPlugin, | ||
) : CurrencyEconomyProviderFactory, | ||
Logger by JUtiltLogger("CurrencyEconomyProviderFactory") { | ||
override fun findByCurrencyId(currencyId: String): EconomyProvider? { | ||
val registrations = Bukkit.getServer().servicesManager.getRegistrations(Economy::class.java) | ||
info { "#findEconomyProviderByCurrency registrations: ${registrations.size}" } | ||
val specificEconomyProvider = registrations | ||
.firstOrNull { it.provider.currencyNameSingular() == currencyId } | ||
?.provider | ||
?.let(::VaultEconomyProvider) | ||
if (specificEconomyProvider == null) { | ||
error { "#economyProvider could not find economy with currency: $currencyId" } | ||
} | ||
return specificEconomyProvider | ||
} | ||
|
||
override fun findDefault(): EconomyProvider? { | ||
return kotlin.runCatching { | ||
VaultEconomyProvider(plugin) | ||
}.getOrNull() ?: kotlin.runCatching { | ||
if (!Bukkit.getServer().pluginManager.isPluginEnabled("Essentials")) { | ||
error("Essentials not enabled") | ||
} else { | ||
EssentialsEconomyProvider | ||
} | ||
}.getOrNull() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters