-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fa42469
commit 8f9d6d0
Showing
18 changed files
with
153 additions
and
147 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
12 changes: 12 additions & 0 deletions
12
.../db-rating/src/main/kotlin/ru/astrainteractive/astrarating/db/rating/di/DBRatingModule.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 |
---|---|---|
@@ -1,17 +1,29 @@ | ||
package ru.astrainteractive.astrarating.db.rating.di | ||
|
||
import org.jetbrains.exposed.sql.Database | ||
import ru.astrainteractive.astralibs.lifecycle.Lifecycle | ||
import ru.astrainteractive.astrarating.db.rating.di.factory.RatingDatabaseFactory | ||
import ru.astrainteractive.astrarating.db.rating.model.DBConnection | ||
import ru.astrainteractive.klibs.kdi.Single | ||
import ru.astrainteractive.klibs.kdi.getValue | ||
|
||
interface DBRatingModule { | ||
val lifecycle: Lifecycle | ||
val database: Database | ||
|
||
class Default(connection: DBConnection) : DBRatingModule { | ||
override val database: Database by Single { | ||
RatingDatabaseFactory(connection).create() | ||
} | ||
override val lifecycle: Lifecycle by lazy { | ||
Lifecycle.Lambda( | ||
onEnable = { | ||
database.connector.invoke().connection | ||
}, | ||
onDisable = { | ||
database.connector.invoke().close() | ||
} | ||
) | ||
} | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
...i/src/main/kotlin/ru/astrainteractive/astrarating/integration/papi/RatingPAPILifecycle.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 |
---|---|---|
@@ -1,19 +1,30 @@ | ||
package ru.astrainteractive.astrarating.integration.papi | ||
|
||
import org.bukkit.Bukkit | ||
import ru.astrainteractive.astralibs.lifecycle.Lifecycle | ||
import ru.astrainteractive.astrarating.integration.papi.di.PapiDependencies | ||
|
||
internal class RatingPAPILifecycle(dependencies: PapiDependencies) : Lifecycle { | ||
private val expansion = RatingPAPIExpansion(dependencies) | ||
private val isPapiExists: Boolean | ||
get() = Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null | ||
|
||
override fun onEnable() { | ||
if (!isPapiExists) return | ||
if (expansion.isRegistered) { | ||
expansion.unregister() | ||
} | ||
expansion.register() | ||
} | ||
|
||
override fun onReload() { | ||
if (!isPapiExists) return | ||
onDisable() | ||
onEnable() | ||
} | ||
|
||
override fun onDisable() { | ||
if (!isPapiExists) return | ||
expansion.unregister() | ||
} | ||
} |
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
9 changes: 9 additions & 0 deletions
9
spigot/src/main/kotlin/ru/astrainteractive/astrarating/command/di/CommandsModule.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 |
---|---|---|
@@ -1,15 +1,24 @@ | ||
package ru.astrainteractive.astrarating.command.di | ||
|
||
import CommandManager | ||
import ru.astrainteractive.astralibs.lifecycle.Lifecycle | ||
import ru.astrainteractive.astrarating.di.RootModule | ||
|
||
interface CommandsModule { | ||
val lifecycle: Lifecycle | ||
val commandManager: CommandManager | ||
|
||
class Default(rootModule: RootModule) : CommandsModule { | ||
override val commandManager: CommandManager by lazy { | ||
val dependencies = CommandsDependencies.Default(rootModule) | ||
CommandManager(dependencies) | ||
} | ||
override val lifecycle: Lifecycle by lazy { | ||
Lifecycle.Lambda( | ||
onEnable = { | ||
commandManager | ||
} | ||
) | ||
} | ||
} | ||
} |
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
Oops, something went wrong.