Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
root = true

[*]
insert_final_newline = true

[{*.kt,*.kts}]
ij_kotlin_code_style_defaults = KOTLIN_OFFICIAL

# Disable wildcard imports entirely
ij_kotlin_name_count_to_use_star_import = 2147483647
ij_kotlin_name_count_to_use_star_import_for_members = 2147483647
ij_kotlin_packages_to_use_import_on_demand = unset
56 changes: 32 additions & 24 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import xyz.jpenilla.runpaper.task.RunServerTask

/*
* WHCore - Core features for the WolvHaven server
* Copyright (C) 2023 Underscore11
Expand All @@ -19,48 +17,51 @@ import xyz.jpenilla.runpaper.task.RunServerTask
*/

plugins {
kotlin("jvm") version "1.8.0"
id("com.github.johnrengelman.shadow") version "7.0.0"
id("xyz.jpenilla.run-paper") version "1.0.7-SNAPSHOT"
id("org.jlleitschuh.gradle.ktlint") version "10.2.0"
id("net.minecrell.plugin-yml.bukkit") version "0.5.3"
kotlin("jvm") version "2.1.10"
id("com.gradleup.shadow") version "9.0.0-beta10"
id("xyz.jpenilla.run-paper") version "2.3.1"
id("org.jlleitschuh.gradle.ktlint") version "12.2.0"
id("net.minecrell.plugin-yml.bukkit") version "0.6.0"
}

group = "net.wolvhaven"
version = "1.1.0-SNAPSHOT"
version = "1.2.1-SNAPSHOT"

val ktReflect = "org.jetbrains.kotlin:kotlin-reflect:2.1.10"

dependencies {
compileOnly("io.papermc.paper:paper-api:1.18.2-R0.1-SNAPSHOT")
compileOnly("io.papermc.paper:paper-api:1.21.4-R0.1-SNAPSHOT")
compileOnly(ktReflect)

implementation("org.spongepowered:configurate-hocon:4.1.2")
implementation("org.jetbrains.kotlin:kotlin-reflect:1.8.20-RC")
implementation("cloud.commandframework:cloud-paper:1.8.3")
implementation("org.incendo:cloud-paper:2.0.0-beta.10")
implementation("org.incendo:cloud-kotlin-extensions:2.0.0")
implementation("org.incendo:cloud-annotations:2.0.0")
implementation("org.incendo:cloud-kotlin-coroutines-annotations:2.0.0")

compileOnly("net.luckperms:api:5.4")
compileOnly("com.github.mbax:VanishNoPacket:0cb428ff27")
compileOnly("me.clip:placeholderapi:2.10.9")
compileOnly("me.clip:placeholderapi:2.11.6")
compileOnly("net.ess3:EssentialsX:2.18.2")
compileOnly("com.sk89q.worldedit:worldedit-bukkit:7.2.6")
compileOnly("com.sk89q.worldedit:worldedit-bukkit:7.3.10")

// compileOnly("us.dynmap:DynmapCoreAPI:3.4")
// compileOnly("com.bergerkiller.bukkit:TrainCarts:1.19.4-v2-SNAPSHOT")
}

kotlin {
jvmToolchain(17)
}

configure<org.jlleitschuh.gradle.ktlint.KtlintExtension> {
disabledRules.add("no-wildcard-imports")
jvmToolchain(21)
}

tasks {
named<RunServerTask>("runServer") {
dependsOn(shadowJar)
minecraftVersion("1.18.2")
runServer {
minecraftVersion("1.21.4")
// jvmArgs("-DLog4jContextSelector=org.apache.logging.log4j.core.selector.ClassLoaderContextSelector") // https://github.com/PaperMC/Paper/issues/4155
jvmArgs("-Ddisable.watchdog=true")
}
ktlint {
}

build {
dependsOn(shadowJar)
}
Expand All @@ -71,22 +72,29 @@ tasks {
"org.spongepowered",
"org.jetbrains",
"org.intellij",
"kotlin",
"io.leangen",
"com.typesafe",
"cloud.commandframework"
"org.incendo",
).forEach {
relocate(it, "net.wolvhaven.core.relocated.$it")
}
exclude("kotlin")
}

compileKotlin {
compilerOptions {
freeCompilerArgs.add("-java-parameters")
}
}
}

bukkit {
main = "net.wolvhaven.core.CorePluginBootstrap"
name = "WhCore"
version = project.version.toString()
apiVersion = "1.18"
apiVersion = "1.21"
author = "Underscore11"
website = "https://wolvhaven.net"
description = "Core functions for the WolvHaven server"
libraries = listOf(ktReflect, "org.jetbrains.kotlin:kotlin-stdlib:2.1.10")
}
22 changes: 2 additions & 20 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,23 +1,5 @@
#
# WHCore - Core features for the WolvHaven server
# Copyright (C) 2023 Underscore11
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#

distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
zipStorePath=wrapper/dists
16 changes: 16 additions & 0 deletions gradlew
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
#!/bin/sh

#
# Copyright © 2015-2021 the original authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

##############################################################################
#
# Gradle start up script for POSIX generated by Gradle.
Expand Down
7 changes: 0 additions & 7 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,3 @@ dependencyResolutionManagement {

repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
}

pluginManagement {
repositories {
gradlePluginPortal()
maven("https://repo.jpenilla.xyz/snapshots/") // for shadow snapshot
}
}
35 changes: 20 additions & 15 deletions src/main/kotlin/net/wolvhaven/core/CorePlugin.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,31 +18,36 @@

package net.wolvhaven.core

import cloud.commandframework.CommandManager
import cloud.commandframework.execution.CommandExecutionCoordinator
import cloud.commandframework.paper.PaperCommandManager
import net.wolvhaven.core.locale.Messages
import net.wolvhaven.core.modules.*
import org.bukkit.command.CommandSender
import net.wolvhaven.core.modules.WhModule
import net.wolvhaven.core.modules.WhModuleType
import org.bukkit.plugin.Plugin
import java.util.*
import org.incendo.cloud.CommandManager
import org.incendo.cloud.annotations.AnnotationParser
import org.incendo.cloud.execution.ExecutionCoordinator
import org.incendo.cloud.kotlin.coroutines.annotations.installCoroutineSupport
import org.incendo.cloud.paper.PaperCommandManager
import org.incendo.cloud.paper.util.sender.PaperSimpleSenderMapper
import org.incendo.cloud.paper.util.sender.Source
import java.util.EnumMap
import java.util.concurrent.Executors
import java.util.concurrent.ScheduledExecutorService

class CorePlugin(val bootstrap: CorePluginBootstrap) : Plugin by bootstrap {
val commandManager: CommandManager<CommandSender> = PaperCommandManager(
bootstrap,
CommandExecutionCoordinator.simpleCoordinator(),
{ it }, { it }
).also {
it.registerAsynchronousCompletions()
it.registerBrigadier()
it.setSetting(CommandManager.ManagerSettings.ALLOW_UNSAFE_REGISTRATION, true)
}
val executorService: ScheduledExecutorService = Executors.newSingleThreadScheduledExecutor()

val commandManager: CommandManager<Source> =
PaperCommandManager
.builder(PaperSimpleSenderMapper.simpleSenderMapper())
.executionCoordinator(ExecutionCoordinator.coordinatorFor(executorService))
.buildOnEnable(bootstrap)

val annotationParser = AnnotationParser(commandManager, Source::class.java).installCoroutineSupport()

val messages = Messages(this)

val modules: MutableMap<WhModuleType, WhModule> = EnumMap(WhModuleType::class.java)

init {
modules.putAll(WhModuleType.values().associateWith { it.creator(this) })
}
Expand Down
7 changes: 2 additions & 5 deletions src/main/kotlin/net/wolvhaven/core/CorePluginBootstrap.kt
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,13 @@ import org.bukkit.plugin.java.JavaPlugin
class CorePluginBootstrap : JavaPlugin() {
val plugin: CorePlugin get() = _plugin ?: throw IllegalStateException("Attempt to get plugin while disabled!")
private var _plugin: CorePlugin? = null

override fun onEnable() {
_plugin = CorePlugin(this)
}

override fun onDisable() {
plugin.disable()
_plugin = null
}

fun reload() {
isEnabled = false
isEnabled = true
}
}
12 changes: 7 additions & 5 deletions src/main/kotlin/net/wolvhaven/core/config/Config.kt
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,13 @@ class Config<T>(private val type: Class<T>, private val file: File) {
throw IllegalStateException("Config objects have to be annotated with ConfigSerializable!")
}

this.loader = HoconConfigurationLoader.builder()
.defaultOptions {
it.shouldCopyDefaults(true)
}.file(this.file)
.build()
this.loader =
HoconConfigurationLoader
.builder()
.defaultOptions {
it.shouldCopyDefaults(true)
}.file(this.file)
.build()
this.configNode = this.loader.load()
this.config = this.configNode.get(this.type) ?: throw IllegalStateException("Null Config")
}
Expand Down
Loading