Skip to content

Commit

Permalink
Restore ktlint
Browse files Browse the repository at this point in the history
  • Loading branch information
andyksaw committed May 12, 2024
1 parent 75502f4 commit e5a8fd5
Show file tree
Hide file tree
Showing 110 changed files with 2,047 additions and 1,728 deletions.
6 changes: 3 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,8 @@ version = sharedVersion
plugins {
kotlin("jvm") version "1.9.22"

id("org.jlleitschuh.gradle.ktlint") version "12.1.1"
id("org.jetbrains.kotlin.plugin.serialization") version "1.6.10"
// id("org.jetbrains.kotlin.kapt") version "1.6.10"
// id("org.jlleitschuh.gradle.ktlint") version "10.2.1"
// id("org.jlleitschuh.gradle.ktlint-idea") version "10.2.1"
id("co.uzzu.dotenv.gradle") version "4.0.0"
}

Expand All @@ -25,6 +23,8 @@ subprojects {
version = sharedVersion

apply(plugin = "org.jetbrains.kotlin.jvm")
apply(plugin = "org.jlleitschuh.gradle.ktlint")
apply(plugin = "org.jetbrains.kotlin.plugin.serialization")

dependencies {
// Kotlin
Expand Down
8 changes: 5 additions & 3 deletions pcbridge-spigot/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar

val generatedResourcesDir = "${layout.buildDirectory}/generated-resources"

plugins {
id("com.github.johnrengelman.shadow") version "8.1.1"
}
Expand Down Expand Up @@ -57,7 +55,7 @@ sourceSets {
kotlin {
// TODO: is this still needed?
// Bundle generated resources with the output jar
output.dir(generatedResourcesDir)
output.dir("${layout.buildDirectory}/generated-resources")
}
}
}
Expand All @@ -69,6 +67,10 @@ tasks {
}

tasks.withType<ShadowJar> {
// Outputs the JAR to a location specified in the .env file if present.
//
// For faster testing with a Minecraft server, since we can output directly
// to the "plugins" folder
destinationDirectory.set(File(
env.fetchOrNull("BUILD_OUTPUT_DIR") ?: "build/release"
))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,13 @@ import com.projectcitybuild.pcbridge.core.config.Config
import com.projectcitybuild.pcbridge.core.config.JsonStorage
import com.projectcitybuild.pcbridge.core.database.DatabaseSession
import com.projectcitybuild.pcbridge.core.database.DatabaseSource
import com.projectcitybuild.pcbridge.core.datetime.DateTimeFormatter
import com.projectcitybuild.pcbridge.core.datetime.LocalizedTime
import com.projectcitybuild.pcbridge.core.errors.SentryReporter
import com.projectcitybuild.pcbridge.core.permissions.Permissions
import com.projectcitybuild.pcbridge.core.permissions.adapters.LuckPermsPermissions
import com.projectcitybuild.pcbridge.core.state.Store
import com.projectcitybuild.pcbridge.data.PluginConfig
import com.projectcitybuild.pcbridge.features.announcements.listeners.AnnouncementEnableListener
import com.projectcitybuild.pcbridge.features.announcements.repositories.AnnouncementRepository
import com.projectcitybuild.pcbridge.features.bans.actions.AuthoriseConnection
Expand All @@ -27,6 +30,7 @@ import com.projectcitybuild.pcbridge.features.bans.listeners.AuthorizeConnection
import com.projectcitybuild.pcbridge.features.bans.repositories.AggregateRepository
import com.projectcitybuild.pcbridge.features.bans.repositories.IPBanRepository
import com.projectcitybuild.pcbridge.features.bans.repositories.PlayerBanRepository
import com.projectcitybuild.pcbridge.features.bans.repositories.PlayerUUIDRepository
import com.projectcitybuild.pcbridge.features.chat.ChatBadgeFormatter
import com.projectcitybuild.pcbridge.features.chat.ChatGroupFormatter
import com.projectcitybuild.pcbridge.features.chat.listeners.EmojiChatListener
Expand All @@ -42,6 +46,7 @@ import com.projectcitybuild.pcbridge.features.joinmessages.listeners.AnnounceJoi
import com.projectcitybuild.pcbridge.features.joinmessages.listeners.AnnounceQuitListener
import com.projectcitybuild.pcbridge.features.joinmessages.listeners.FirstTimeJoinListener
import com.projectcitybuild.pcbridge.features.joinmessages.listeners.ServerOverviewJoinListener
import com.projectcitybuild.pcbridge.features.joinmessages.repositories.PlayerConfigRepository
import com.projectcitybuild.pcbridge.features.mute.commands.MuteCommand
import com.projectcitybuild.pcbridge.features.mute.commands.UnmuteCommand
import com.projectcitybuild.pcbridge.features.mute.listeners.MuteChatListener
Expand All @@ -56,24 +61,19 @@ import com.projectcitybuild.pcbridge.features.sync.listener.SyncRankOnJoinListen
import com.projectcitybuild.pcbridge.features.sync.repositories.SyncRepository
import com.projectcitybuild.pcbridge.features.telemetry.listeners.TelemetryPlayerConnectListener
import com.projectcitybuild.pcbridge.features.telemetry.repositories.TelemetryRepository
import com.projectcitybuild.pcbridge.features.warps.repositories.WarpRepository
import com.projectcitybuild.pcbridge.features.warps.Warp
import com.projectcitybuild.pcbridge.features.utilities.commands.PCBridgeCommand
import com.projectcitybuild.pcbridge.features.warnings.actions.GetUnacknowledgedWarnings
import com.projectcitybuild.pcbridge.features.warnings.commands.WarningAcknowledgeCommand
import com.projectcitybuild.pcbridge.features.warnings.listeners.NotifyWarningsOnJoinListener
import com.projectcitybuild.pcbridge.features.warnings.repositories.PlayerWarningRepository
import com.projectcitybuild.pcbridge.features.warps.Warp
import com.projectcitybuild.pcbridge.features.warps.commands.WarpCommand
import com.projectcitybuild.pcbridge.features.warps.commands.WarpsCommand
import com.projectcitybuild.pcbridge.features.warps.repositories.WarpRepository
import com.projectcitybuild.pcbridge.http.HttpService
import com.projectcitybuild.pcbridge.integrations.DynmapIntegration
import com.projectcitybuild.pcbridge.integrations.EssentialsIntegration
import com.projectcitybuild.pcbridge.integrations.LuckPermsIntegration
import com.projectcitybuild.pcbridge.core.datetime.DateTimeFormatter
import com.projectcitybuild.pcbridge.core.datetime.LocalizedTime
import com.projectcitybuild.pcbridge.data.PluginConfig
import com.projectcitybuild.pcbridge.http.HttpService
import com.projectcitybuild.pcbridge.features.bans.repositories.PlayerUUIDRepository
import com.projectcitybuild.pcbridge.features.joinmessages.repositories.PlayerConfigRepository
import com.projectcitybuild.pcbridge.features.warnings.actions.GetUnacknowledgedWarnings
import com.projectcitybuild.pcbridge.features.warnings.commands.WarningAcknowledgeCommand
import com.projectcitybuild.pcbridge.features.warnings.listeners.NotifyWarningsOnJoinListener
import com.projectcitybuild.pcbridge.features.warnings.repositories.PlayerWarningRepository
import com.projectcitybuild.pcbridge.support.spigot.SpigotCommandRegistry
import com.projectcitybuild.pcbridge.support.spigot.SpigotListenerRegistry
import com.projectcitybuild.pcbridge.support.spigot.SpigotNamespace
Expand All @@ -95,27 +95,28 @@ import java.util.Locale
import java.util.UUID
import kotlin.time.Duration.Companion.minutes

fun pluginModule(_plugin: JavaPlugin) = module {
spigot(_plugin)
core()
http()
integrations()

// Features
announcements()
bans()
chat()
joinMessages()
invisFrames()
mute()
nightVision()
staffChat()
sync()
telemetry()
utilities()
warps()
warnings()
}
fun pluginModule(_plugin: JavaPlugin) =
module {
spigot(_plugin)
core()
http()
integrations()

// Features
announcements()
bans()
chat()
joinMessages()
invisFrames()
mute()
nightVision()
staffChat()
sync()
telemetry()
utilities()
warps()
warnings()
}

private fun Module.spigot(plugin: JavaPlugin) {
single { plugin }
Expand Down Expand Up @@ -161,12 +162,14 @@ private fun Module.spigot(plugin: JavaPlugin) {
private fun Module.core() {
single {
Config(
jsonStorage = JsonStorage(
file = get<JavaPlugin>()
.dataFolder
.resolve("config.json"),
typeToken = object : TypeToken<PluginConfig>(){},
)
jsonStorage =
JsonStorage(
file =
get<JavaPlugin>()
.dataFolder
.resolve("config.json"),
typeToken = object : TypeToken<PluginConfig>() {},
),
)
}

Expand Down Expand Up @@ -200,20 +203,22 @@ private fun Module.core() {
val zoneId = ZoneId.of(config.localization.timeZone)

LocalizedTime(
clock = Clock.system(zoneId)
clock = Clock.system(zoneId),
)
}

factory {
val config = get<Config>().get()

DateTimeFormatter(
locale = Locale.forLanguageTag(
config.localization.locale,
),
timezone = ZoneId.of(
config.localization.timeZone
),
locale =
Locale.forLanguageTag(
config.localization.locale,
),
timezone =
ZoneId.of(
config.localization.timeZone,
),
)
}

Expand Down Expand Up @@ -277,9 +282,10 @@ private fun Module.warps() {
single {
WarpRepository(
db = get(),
cache = Cache.Builder<String, Warp>()
.expireAfterWrite(30.minutes)
.build(),
cache =
Cache.Builder<String, Warp>()
.expireAfterWrite(30.minutes)
.build(),
)
}

Expand Down Expand Up @@ -354,61 +360,66 @@ private fun Module.bans() {
factory {
PlayerUUIDRepository(
server = get(),
httpService = get<HttpService>().playerUuid
httpService = get<HttpService>().playerUuid,
)
}

factory {
IPBanRepository(
httpService = get<HttpService>().ipBan
httpService = get<HttpService>().ipBan,
)
}

factory {
BanCommand(
banUUID = BanUUID(
playerBanRepository = get(),
playerUUIDRepository = get(),
server = get(),
),
banUUID =
BanUUID(
playerBanRepository = get(),
playerUUIDRepository = get(),
server = get(),
),
server = get(),
)
}

factory {
BanIPCommand(
banIP = BanIP(
ipBanRepository = get(),
server = get(),
),
banIP =
BanIP(
ipBanRepository = get(),
server = get(),
),
server = get(),
)
}

factory {
UnbanCommand(
unbanUUID = UnbanUUID(
playerBanRepository = get(),
playerUUIDRepository = get(),
)
unbanUUID =
UnbanUUID(
playerBanRepository = get(),
playerUUIDRepository = get(),
),
)
}

factory {
UnbanIPCommand(
unbanIP = UnbanIP(
ipBanRepository = get(),
)
unbanIP =
UnbanIP(
ipBanRepository = get(),
),
)
}

factory {
CheckBanCommand(
checkUUIDBan = CheckUUIDBan(
dateTimeFormatter = get(),
playerUUIDRepository = get(),
playerBanRepository = get(),
)
checkUUIDBan =
CheckUUIDBan(
dateTimeFormatter = get(),
playerUUIDRepository = get(),
playerBanRepository = get(),
),
)
}

Expand Down Expand Up @@ -436,20 +447,20 @@ private fun Module.mute() {
factory {
MuteCommand(
server = get(),
mutedPlayers = get(named("mute_cache"))
mutedPlayers = get(named("mute_cache")),
)
}

factory {
UnmuteCommand(
server = get(),
mutedPlayers = get(named("mute_cache"))
mutedPlayers = get(named("mute_cache")),
)
}

factory {
MuteChatListener(
mutedPlayers = get(named("mute_cache"))
mutedPlayers = get(named("mute_cache")),
)
}
}
Expand Down Expand Up @@ -592,7 +603,6 @@ private fun Module.sync() {
)
}


factory {
SyncCommand(
generateAccountVerificationURL = get(),
Expand Down Expand Up @@ -641,10 +651,11 @@ private fun Module.warnings() {

factory {
NotifyWarningsOnJoinListener(
getUnacknowledgedWarnings = GetUnacknowledgedWarnings(
dateTimeFormatter = get(),
warningRepository = get(),
)
getUnacknowledgedWarnings =
GetUnacknowledgedWarnings(
dateTimeFormatter = get(),
warningRepository = get(),
),
)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ class Permissions private constructor() {
const val COMMAND_WARPS_USE = "pcbridge.warp.use"
const val COMMAND_UTILITIES = "pcbridge.utilities"
}
}
}
Loading

0 comments on commit e5a8fd5

Please sign in to comment.