diff --git a/build.gradle.kts b/build.gradle.kts index c5c8df17..43e8cd4d 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,7 +1,7 @@ plugins { alias(libs.plugins.gradle.neoforgegradle) apply false alias(libs.plugins.klibs.gradle.detekt) apply false - alias(libs.plugins.klibs.gradle.dokka.root) +// alias(libs.plugins.klibs.gradle.dokka.root) alias(libs.plugins.klibs.gradle.java.version) apply false alias(libs.plugins.klibs.gradle.publication) apply false alias(libs.plugins.klibs.gradle.rootinfo) apply false diff --git a/core-forge/build.gradle.kts b/core-forge/build.gradle.kts index fa261539..775d8485 100644 --- a/core-forge/build.gradle.kts +++ b/core-forge/build.gradle.kts @@ -29,6 +29,8 @@ dependencies { implementation(projects.command) implementation(projects.core) + api(projects.coreMinecraft) + testImplementation(libs.kotlin.serialization.kaml) testImplementation(libs.tests.kotlin.test) } diff --git a/core-forge/src/main/kotlin/ru/astrainteractive/astralibs/command/brigadier/command/ForgeCommandExt.kt b/core-forge/src/main/kotlin/ru/astrainteractive/astralibs/command/brigadier/command/ForgeCommandExt.kt deleted file mode 100644 index 8008c9a2..00000000 --- a/core-forge/src/main/kotlin/ru/astrainteractive/astralibs/command/brigadier/command/ForgeCommandExt.kt +++ /dev/null @@ -1,160 +0,0 @@ -@file:Suppress("TooManyFunctions") - -package ru.astrainteractive.astralibs.command.brigadier.command - -import com.mojang.brigadier.Command -import com.mojang.brigadier.arguments.ArgumentType -import com.mojang.brigadier.builder.LiteralArgumentBuilder -import com.mojang.brigadier.builder.RequiredArgumentBuilder -import com.mojang.brigadier.context.CommandContext -import net.minecraft.commands.CommandSourceStack -import net.minecraft.commands.Commands -import net.minecraft.server.MinecraftServer -import net.minecraft.server.dedicated.DedicatedServer -import net.minecraft.server.level.ServerPlayer -import net.minecraft.server.rcon.RconConsoleSource -import ru.astrainteractive.astralibs.command.api.argumenttype.ArgumentConverter -import ru.astrainteractive.astralibs.command.api.exception.ArgumentConverterException -import ru.astrainteractive.astralibs.command.api.exception.CommandException -import ru.astrainteractive.astralibs.command.api.exception.NoPermissionException -import ru.astrainteractive.astralibs.command.api.exception.NotPlayerExecutorException -import ru.astrainteractive.astralibs.server.permission.Permission -import ru.astrainteractive.astralibs.server.util.asPermissible - -fun command( - alias: String, - block: LiteralArgumentBuilder.() -> Unit -): LiteralArgumentBuilder { - val literal = Commands.literal(alias) - literal.block() - return literal -} - -fun LiteralArgumentBuilder.literal( - alias: String, - block: LiteralArgumentBuilder.() -> Unit -) { - val literal = Commands.literal(alias) - literal.block() - this.then(literal) -} - -data class BrigadierArgument( - val alias: String, - val type: ArgumentType, - val clazz: Class -) - -inline fun LiteralArgumentBuilder.argument( - alias: String, - type: ArgumentType, - noinline block: RequiredArgumentBuilder.(BrigadierArgument) -> Unit -) = argument( - alias = alias, - type = type, - clazz = T::class.java, - block = block -) - -fun LiteralArgumentBuilder.argument( - alias: String, - type: ArgumentType, - clazz: Class, - block: RequiredArgumentBuilder.(BrigadierArgument) -> Unit -) { - val argument = Commands.argument(alias, type) - val brigadierArgument = BrigadierArgument( - alias = alias, - type = type, - clazz = clazz - ) - argument.block(brigadierArgument) - this.then(argument) -} - -inline fun RequiredArgumentBuilder.argument( - alias: String, - type: ArgumentType, - noinline block: RequiredArgumentBuilder.(BrigadierArgument) -> Unit -) = argument( - alias = alias, - type = type, - clazz = T::class.java, - block = block -) - -fun RequiredArgumentBuilder.argument( - alias: String, - type: ArgumentType, - clazz: Class, - block: RequiredArgumentBuilder.(BrigadierArgument) -> Unit -) { - val argument = Commands.argument(alias, type) - val brigadierArgument = BrigadierArgument( - alias = alias, - type = type, - clazz = clazz - ) - argument.block(brigadierArgument) - this.then(argument) -} - -fun RequiredArgumentBuilder.runs( - onFailure: (CommandContext, Throwable) -> Unit = { _, _ -> }, - block: (RequiredArgumentBuilder.(CommandContext) -> Unit) -) { - executes { ctx -> - runCatching { block.invoke(this, ctx) } - .onFailure { onFailure.invoke(ctx, it) } - Command.SINGLE_SUCCESS - } -} - -fun LiteralArgumentBuilder.runs( - onFailure: (CommandContext, Throwable) -> Unit = { _, _ -> }, - block: LiteralArgumentBuilder.(CommandContext) -> Unit -) { - executes { ctx -> - runCatching { block.invoke(this, ctx) } - .onFailure { onFailure.invoke(ctx, it) } - Command.SINGLE_SUCCESS - } -} - -fun RequiredArgumentBuilder.hints(block: (CommandContext) -> List) { - suggests { context, builder -> - block.invoke(context).forEach(builder::suggest) - builder.buildFuture() - } -} - -@Throws(NoPermissionException::class) -fun CommandContext.requirePermission(permission: Permission) { - if (source.source is RconConsoleSource) return - if (source.source is DedicatedServer) return - if (source.source is MinecraftServer) return - val serverPlayer = source.entity as? ServerPlayer ?: run { - throw CommandException("$source.source; is not a player!") - } - val hasPermission = serverPlayer.asPermissible().hasPermission(permission) - if (!hasPermission) throw NoPermissionException(permission) -} - -@Throws(NotPlayerExecutorException::class) -fun CommandContext.requirePlayer(): ServerPlayer { - return this.source.player ?: throw NotPlayerExecutorException() -} - -@Throws(IllegalArgumentException::class) -fun CommandContext.requireArgument(bArgument: BrigadierArgument): T { - return getArgument(bArgument.alias, bArgument.clazz) -} - -@Throws(ArgumentConverterException::class) -fun CommandContext.requireArgument( - bArgument: BrigadierArgument, - converter: ArgumentConverter -): T { - val string = getArgument(bArgument.alias, bArgument.clazz) - return converter.transform(string) -} diff --git a/core-forge/src/main/kotlin/ru/astrainteractive/astralibs/command/brigadier/command/ForgeMultiplatformCommands.kt b/core-forge/src/main/kotlin/ru/astrainteractive/astralibs/command/brigadier/command/ForgeMultiplatformCommands.kt deleted file mode 100644 index b1787229..00000000 --- a/core-forge/src/main/kotlin/ru/astrainteractive/astralibs/command/brigadier/command/ForgeMultiplatformCommands.kt +++ /dev/null @@ -1,53 +0,0 @@ -package ru.astrainteractive.astralibs.command.brigadier.command - -import com.mojang.brigadier.arguments.ArgumentType -import com.mojang.brigadier.builder.LiteralArgumentBuilder -import com.mojang.brigadier.builder.RequiredArgumentBuilder -import com.mojang.brigadier.context.CommandContext -import net.minecraft.commands.CommandSourceStack -import net.minecraft.commands.Commands -import net.minecraft.server.MinecraftServer -import net.minecraft.server.dedicated.DedicatedServer -import net.minecraft.server.level.ServerPlayer -import net.minecraft.server.rcon.RconConsoleSource -import ru.astrainteractive.astralibs.command.api.brigadier.command.MultiplatformCommands -import ru.astrainteractive.astralibs.command.api.brigadier.sender.KCommandSender -import ru.astrainteractive.astralibs.command.api.brigadier.sender.KPlayerKCommandSender -import ru.astrainteractive.astralibs.command.brigadier.sender.ForgeRconKCommandSender -import ru.astrainteractive.astralibs.command.brigadier.sender.ForgeServerKCommandSender -import ru.astrainteractive.astralibs.server.util.asOnlineMinecraftPlayer - -@Suppress("UNCHECKED_CAST") -class ForgeMultiplatformCommands : MultiplatformCommands { - override fun literal(literal: String): LiteralArgumentBuilder { - return Commands.literal(literal) as LiteralArgumentBuilder - } - - override fun argument( - name: String, - argumentType: ArgumentType - ): RequiredArgumentBuilder { - return Commands.argument(name, argumentType) as RequiredArgumentBuilder - } - - override fun getSender(context: CommandContext<*>): KCommandSender { - val commandSourceStack = context.source as CommandSourceStack - - return when (val source = commandSourceStack.source) { - is ServerPlayer -> { - KPlayerKCommandSender(source.asOnlineMinecraftPlayer()) - } - - is RconConsoleSource -> { - ForgeRconKCommandSender(source) - } - - is DedicatedServer, - is MinecraftServer -> { - ForgeServerKCommandSender(source) - } - - else -> error("Could not wrap sender ${commandSourceStack.source.javaClass}") - } - } -} diff --git a/core-forge/src/main/kotlin/ru/astrainteractive/astralibs/command/brigadier/sender/ForgeServerKCommandSender.kt b/core-forge/src/main/kotlin/ru/astrainteractive/astralibs/command/brigadier/sender/ForgeServerKCommandSender.kt deleted file mode 100644 index 18664933..00000000 --- a/core-forge/src/main/kotlin/ru/astrainteractive/astralibs/command/brigadier/sender/ForgeServerKCommandSender.kt +++ /dev/null @@ -1,17 +0,0 @@ -package ru.astrainteractive.astralibs.command.brigadier.sender - -import net.minecraft.server.MinecraftServer -import ru.astrainteractive.astralibs.command.api.brigadier.sender.ConsoleKCommandSender -import ru.astrainteractive.astralibs.server.KAudience -import ru.astrainteractive.astralibs.server.KCommandDispatcher -import ru.astrainteractive.astralibs.server.permission.ConsoleKPermissible -import ru.astrainteractive.astralibs.server.permission.KPermissible -import ru.astrainteractive.astralibs.server.util.asKAudience -import ru.astrainteractive.astralibs.server.util.asKCommandDispatcher - -class ForgeServerKCommandSender( - sender: MinecraftServer -) : ConsoleKCommandSender, - KPermissible by ConsoleKPermissible, - KAudience by sender.asKAudience(), - KCommandDispatcher by sender.asKCommandDispatcher() diff --git a/core-forge/src/main/kotlin/ru/astrainteractive/astralibs/command/registrar/ForgeCommandRegistrarContext.kt b/core-forge/src/main/kotlin/ru/astrainteractive/astralibs/command/registrar/ForgeCommandRegistrarContext.kt deleted file mode 100644 index 21f736b8..00000000 --- a/core-forge/src/main/kotlin/ru/astrainteractive/astralibs/command/registrar/ForgeCommandRegistrarContext.kt +++ /dev/null @@ -1,31 +0,0 @@ -package ru.astrainteractive.astralibs.command.registrar - -import com.mojang.brigadier.builder.LiteralArgumentBuilder -import kotlinx.coroutines.CoroutineScope -import kotlinx.coroutines.flow.SharingStarted -import kotlinx.coroutines.flow.filterNotNull -import kotlinx.coroutines.flow.launchIn -import kotlinx.coroutines.flow.mapNotNull -import kotlinx.coroutines.flow.onEach -import kotlinx.coroutines.flow.stateIn -import net.minecraft.commands.CommandSourceStack -import net.minecraftforge.event.RegisterCommandsEvent -import net.minecraftforge.eventbus.api.EventPriority -import ru.astrainteractive.astralibs.command.api.registrar.CommandRegistrarContext -import ru.astrainteractive.astralibs.event.flowEvent - -class ForgeCommandRegistrarContext( - private val mainScope: CoroutineScope -) : CommandRegistrarContext { - private val registerCommandsEvent = flowEvent(EventPriority.HIGHEST) - .filterNotNull() - .stateIn(mainScope, SharingStarted.Eagerly, null) - - override fun registerWhenReady(node: LiteralArgumentBuilder<*>) { - node as LiteralArgumentBuilder - registerCommandsEvent - .mapNotNull { registerCommandsEvent -> registerCommandsEvent?.dispatcher } - .onEach { commandDispatcher -> commandDispatcher.register(node) } - .launchIn(mainScope) - } -} diff --git a/core-forge/src/main/kotlin/ru/astrainteractive/astralibs/coroutines/ForgeDispatchers.kt b/core-forge/src/main/kotlin/ru/astrainteractive/astralibs/coroutines/ForgeDispatchers.kt deleted file mode 100644 index c7ca223b..00000000 --- a/core-forge/src/main/kotlin/ru/astrainteractive/astralibs/coroutines/ForgeDispatchers.kt +++ /dev/null @@ -1,18 +0,0 @@ -package ru.astrainteractive.astralibs.coroutines - -import kotlinx.coroutines.CoroutineDispatcher -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.MainCoroutineDispatcher -import ru.astrainteractive.klibs.mikro.core.dispatchers.KotlinDispatchers - -class ForgeDispatchers : KotlinDispatchers { - override val Main: MainCoroutineDispatcher by lazy { - ForgeMainDispatcher() - } - override val IO: CoroutineDispatcher - get() = Dispatchers.IO - override val Default: CoroutineDispatcher - get() = Dispatchers.Default - override val Unconfined: CoroutineDispatcher - get() = Dispatchers.Unconfined -} diff --git a/core-forge/src/main/kotlin/ru/astrainteractive/astralibs/coroutines/ForgeMainDispatcher.kt b/core-forge/src/main/kotlin/ru/astrainteractive/astralibs/coroutines/ForgeMainDispatcher.kt deleted file mode 100644 index 94900c95..00000000 --- a/core-forge/src/main/kotlin/ru/astrainteractive/astralibs/coroutines/ForgeMainDispatcher.kt +++ /dev/null @@ -1,35 +0,0 @@ -package ru.astrainteractive.astralibs.coroutines - -import kotlinx.coroutines.MainCoroutineDispatcher -import net.minecraft.client.Minecraft -import net.minecraftforge.api.distmarker.Dist -import net.minecraftforge.fml.loading.FMLEnvironment -import ru.astrainteractive.astralibs.server.util.ForgeUtil -import java.util.concurrent.Executor -import kotlin.coroutines.CoroutineContext - -class ForgeMainDispatcher : MainCoroutineDispatcher() { - override val immediate: MainCoroutineDispatcher - get() = this - private val executor = when (FMLEnvironment.dist) { - Dist.CLIENT -> Minecraft.getInstance() - Dist.DEDICATED_SERVER -> Executor { block -> - ForgeUtil.requireServer().executeBlocking(block) - } - } - - override fun isDispatchNeeded(context: CoroutineContext): Boolean { - return true - } - - override fun dispatch(context: CoroutineContext, block: Runnable) { - val coroutineTimings = context[CoroutineTimings.Key] - - if (coroutineTimings == null) { - executor.execute(block) - } else { - coroutineTimings.queue.add(block) - executor.execute(coroutineTimings) - } - } -} diff --git a/core-forge/src/main/kotlin/ru/astrainteractive/astralibs/lifecycle/ForgeLifecycleServer.kt b/core-forge/src/main/kotlin/ru/astrainteractive/astralibs/lifecycle/ForgeLifecycleServer.kt index d3fa77b2..f37b768d 100644 --- a/core-forge/src/main/kotlin/ru/astrainteractive/astralibs/lifecycle/ForgeLifecycleServer.kt +++ b/core-forge/src/main/kotlin/ru/astrainteractive/astralibs/lifecycle/ForgeLifecycleServer.kt @@ -11,13 +11,14 @@ import net.minecraftforge.event.server.ServerStartedEvent import net.minecraftforge.event.server.ServerStoppingEvent import net.minecraftforge.eventbus.api.EventPriority import ru.astrainteractive.astralibs.event.flowEvent -import ru.astrainteractive.astralibs.server.util.ForgeUtil +import ru.astrainteractive.astralibs.server.util.MinecraftUtil import ru.astrainteractive.klibs.mikro.core.logging.Logger abstract class ForgeLifecycleServer : Lifecycle, Logger { private val unconfinedScope = CoroutineScope(SupervisorJob() + Dispatchers.Unconfined) val serverStartedEvent = flowEvent(EventPriority.HIGHEST) + .onEach { event -> MinecraftUtil.setServer(event.server) } .onEach { onEnable() } .catch { throwable -> error(throwable) { "#serverStartedEvent ${throwable.localizedMessage}" } @@ -31,8 +32,4 @@ abstract class ForgeLifecycleServer : Lifecycle, Logger { error(throwable) { "#serverStartedEvent ${throwable.localizedMessage}" } } .launchIn(unconfinedScope) - - init { - ForgeUtil.bootstrap() - } } diff --git a/core-forge/src/main/kotlin/ru/astrainteractive/astralibs/server/util/ForgeUtil.kt b/core-forge/src/main/kotlin/ru/astrainteractive/astralibs/server/util/ForgeUtil.kt deleted file mode 100644 index 65653b0d..00000000 --- a/core-forge/src/main/kotlin/ru/astrainteractive/astralibs/server/util/ForgeUtil.kt +++ /dev/null @@ -1,88 +0,0 @@ -package ru.astrainteractive.astralibs.server.util - -import com.mojang.authlib.GameProfile -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.flow.SharingStarted -import kotlinx.coroutines.flow.filterNotNull -import kotlinx.coroutines.flow.first -import kotlinx.coroutines.flow.flowOn -import kotlinx.coroutines.flow.map -import kotlinx.coroutines.flow.stateIn -import net.minecraft.server.MinecraftServer -import net.minecraft.server.level.ServerPlayer -import net.minecraft.world.level.Level -import net.minecraftforge.event.server.ServerStartedEvent -import net.minecraftforge.fml.loading.FMLLoader -import net.minecraftforge.server.ServerLifecycleHooks -import ru.astrainteractive.astralibs.event.flowEvent -import ru.astrainteractive.klibs.mikro.core.logging.JUtiltLogger -import ru.astrainteractive.klibs.mikro.core.logging.Logger -import java.util.UUID - -/** - * Don't forget to instantiate [ForgeUtil] on init at loader - */ -object ForgeUtil : Logger by JUtiltLogger("AstraLibs-ForgeUtil") { - private val serverFlow = flowEvent() - .map { event -> event.server } - .flowOn(Dispatchers.Unconfined) - .stateIn(GlobalScope, SharingStarted.Eagerly, null) - - val serverOrNull: MinecraftServer? - get() = ServerLifecycleHooks.getCurrentServer() - - suspend fun awaitServer(): MinecraftServer { - return serverFlow.filterNotNull().first() - } - - fun requireServer(): MinecraftServer { - return ServerLifecycleHooks - .getCurrentServer() - ?: error("Server is not available") - } - - fun bootstrap() = Unit -} - -fun ForgeUtil.isModLoaded(modId: String): Boolean { - return FMLLoader.getLoadingModList().getModFileById(modId) != null -} - -fun ForgeUtil.getDefaultWorldName(): String? { - return serverOrNull - ?.getLevel(Level.OVERWORLD) - ?.level - ?.dimension() - ?.location() - ?.path -} - -fun ForgeUtil.getPlayerGameProfile(uuid: UUID): GameProfile? { - return serverOrNull?.profileCache?.get(uuid)?.orElse(null) -} - -fun ForgeUtil.getPlayerGameProfile(name: String): GameProfile? { - return serverOrNull?.profileCache?.get(name)?.orElse(null) -} - -fun ForgeUtil.getOnlinePlayers(): List { - return serverOrNull - ?.playerList - ?.players - ?.toList() - .orEmpty() - .filterNotNull() -} - -fun ForgeUtil.getOnlinePlayer(uuid: UUID): ServerPlayer? { - return serverOrNull?.playerList?.getPlayer(uuid) -} - -fun ForgeUtil.getOnlinePlayer(name: String): ServerPlayer? { - return serverOrNull?.playerList?.getPlayerByName(name) -} - -fun ForgeUtil.getNextTickTime(): Double { - return serverOrNull?.nextTickTime?.toDouble() ?: 0.0 -} diff --git a/core-forge/src/main/kotlin/ru/astrainteractive/astralibs/server/util/PermissibleExt.kt b/core-forge/src/main/kotlin/ru/astrainteractive/astralibs/server/util/PermissibleExt.kt deleted file mode 100644 index a0cc4ded..00000000 --- a/core-forge/src/main/kotlin/ru/astrainteractive/astralibs/server/util/PermissibleExt.kt +++ /dev/null @@ -1,13 +0,0 @@ -package ru.astrainteractive.astralibs.server.util - -import net.minecraft.world.entity.player.Player -import ru.astrainteractive.astralibs.server.permission.KPermissible -import ru.astrainteractive.astralibs.server.permission.LuckPermsKPermissible - -fun Player.asPermissible(): KPermissible { - return if (ForgeUtil.isModLoaded("luckperms")) { - LuckPermsKPermissible(this.uuid) - } else { - error("No permission provider loaded!") - } -} diff --git a/core-forge/src/main/kotlin/ru/astrainteractive/astralibs/server/util/TeleportableExt.kt b/core-forge/src/main/kotlin/ru/astrainteractive/astralibs/server/util/TeleportableExt.kt deleted file mode 100644 index 47dd3f93..00000000 --- a/core-forge/src/main/kotlin/ru/astrainteractive/astralibs/server/util/TeleportableExt.kt +++ /dev/null @@ -1,22 +0,0 @@ -package ru.astrainteractive.astralibs.server.util - -import net.minecraft.server.level.ServerPlayer -import net.minecraft.world.level.storage.ServerLevelData -import ru.astrainteractive.astralibs.server.Teleportable - -fun ServerPlayer.asTeleportable() = Teleportable { location -> - val player = this - - val level = player.server - ?.allLevels - ?.firstOrNull { (it.level.levelData as ServerLevelData).levelName == location.worldName } - ?: return@Teleportable - player.teleportTo( - level, - location.x, - location.y, - location.z, - 0f, - 0f - ) -} diff --git a/core-fabric/build.gradle.kts b/core-minecraft/build.gradle.kts similarity index 70% rename from core-fabric/build.gradle.kts rename to core-minecraft/build.gradle.kts index af6da13e..f058ab5b 100644 --- a/core-fabric/build.gradle.kts +++ b/core-minecraft/build.gradle.kts @@ -1,18 +1,16 @@ -import ru.astrainteractive.gradleplugin.property.util.requireJinfo - plugins { alias(libs.plugins.gradle.fabric.loom) id("org.jetbrains.kotlin.jvm") id("org.jetbrains.kotlin.plugin.serialization") id("ru.astrainteractive.gradleplugin.java.version") + id("ru.astrainteractive.gradleplugin.detekt") + id("ru.astrainteractive.gradleplugin.publication") id("ru.astrainteractive.gradleplugin.rootinfo") } + dependencies { - minecraft(libs.minecraft.fabric.mojang.get()) + minecraft(libs.minecraft.fabric.mojang) mappings(loom.officialMojangMappings()) - modImplementation(libs.minecraft.fabric.kotlin.get()) - modImplementation(libs.minecraft.fabric.loader.get()) - modImplementation(libs.minecraft.fabric.api.get()) } dependencies { compileOnly(libs.klibs.mikro.core) @@ -31,8 +29,6 @@ dependencies { testImplementation(libs.tests.kotlin.test) } -java.toolchain.languageVersion = JavaLanguageVersion.of(requireJinfo.jtarget.majorVersion) - configurations.runtimeElements { setExtendsFrom(emptySet()) } diff --git a/core-fabric/gradle.properties b/core-minecraft/gradle.properties similarity index 50% rename from core-fabric/gradle.properties rename to core-minecraft/gradle.properties index d431dff9..9c2df928 100644 --- a/core-fabric/gradle.properties +++ b/core-minecraft/gradle.properties @@ -1 +1,2 @@ makeevrserg.java.source=21 +fabric.loom.dontRemap=true diff --git a/core-neoforge/src/main/kotlin/ru/astrainteractive/astralibs/command/brigadier/command/NeoForgeCommandExt.kt b/core-minecraft/src/main/kotlin/ru/astrainteractive/astralibs/command/brigadier/command/MinecraftCommandExt.kt similarity index 94% rename from core-neoforge/src/main/kotlin/ru/astrainteractive/astralibs/command/brigadier/command/NeoForgeCommandExt.kt rename to core-minecraft/src/main/kotlin/ru/astrainteractive/astralibs/command/brigadier/command/MinecraftCommandExt.kt index 8008c9a2..456bd740 100644 --- a/core-neoforge/src/main/kotlin/ru/astrainteractive/astralibs/command/brigadier/command/NeoForgeCommandExt.kt +++ b/core-minecraft/src/main/kotlin/ru/astrainteractive/astralibs/command/brigadier/command/MinecraftCommandExt.kt @@ -20,6 +20,7 @@ import ru.astrainteractive.astralibs.command.api.exception.NoPermissionException import ru.astrainteractive.astralibs.command.api.exception.NotPlayerExecutorException import ru.astrainteractive.astralibs.server.permission.Permission import ru.astrainteractive.astralibs.server.util.asPermissible +import ru.astrainteractive.astralibs.util.publicSource fun command( alias: String, @@ -130,11 +131,12 @@ fun RequiredArgumentBuilder.hints(block: (CommandContext< @Throws(NoPermissionException::class) fun CommandContext.requirePermission(permission: Permission) { - if (source.source is RconConsoleSource) return - if (source.source is DedicatedServer) return - if (source.source is MinecraftServer) return - val serverPlayer = source.entity as? ServerPlayer ?: run { - throw CommandException("$source.source; is not a player!") + val source = source.publicSource + if (source is RconConsoleSource) return + if (source is DedicatedServer) return + if (source is MinecraftServer) return + val serverPlayer = source as? ServerPlayer ?: run { + throw CommandException("$source; is not a player!") } val hasPermission = serverPlayer.asPermissible().hasPermission(permission) if (!hasPermission) throw NoPermissionException(permission) diff --git a/core-neoforge/src/main/kotlin/ru/astrainteractive/astralibs/command/brigadier/command/NeoForgeMultiplatformCommands.kt b/core-minecraft/src/main/kotlin/ru/astrainteractive/astralibs/command/brigadier/command/MinecraftMultiplatformCommands.kt similarity index 76% rename from core-neoforge/src/main/kotlin/ru/astrainteractive/astralibs/command/brigadier/command/NeoForgeMultiplatformCommands.kt rename to core-minecraft/src/main/kotlin/ru/astrainteractive/astralibs/command/brigadier/command/MinecraftMultiplatformCommands.kt index c1cece70..47384215 100644 --- a/core-neoforge/src/main/kotlin/ru/astrainteractive/astralibs/command/brigadier/command/NeoForgeMultiplatformCommands.kt +++ b/core-minecraft/src/main/kotlin/ru/astrainteractive/astralibs/command/brigadier/command/MinecraftMultiplatformCommands.kt @@ -13,12 +13,13 @@ import net.minecraft.server.rcon.RconConsoleSource import ru.astrainteractive.astralibs.command.api.brigadier.command.MultiplatformCommands import ru.astrainteractive.astralibs.command.api.brigadier.sender.KCommandSender import ru.astrainteractive.astralibs.command.api.brigadier.sender.KPlayerKCommandSender -import ru.astrainteractive.astralibs.command.brigadier.sender.NeoForgeRconKCommandSender -import ru.astrainteractive.astralibs.command.brigadier.sender.NeoForgeServerKCommandSender +import ru.astrainteractive.astralibs.command.brigadier.sender.MinecraftRconKCommandSender +import ru.astrainteractive.astralibs.command.brigadier.sender.MinecraftServerKCommandSender import ru.astrainteractive.astralibs.server.util.asOnlineMinecraftPlayer +import ru.astrainteractive.astralibs.util.publicSource @Suppress("UNCHECKED_CAST") -class NeoForgeMultiplatformCommands : MultiplatformCommands { +class MinecraftMultiplatformCommands : MultiplatformCommands { override fun literal(literal: String): LiteralArgumentBuilder { return Commands.literal(literal) as LiteralArgumentBuilder } @@ -32,22 +33,21 @@ class NeoForgeMultiplatformCommands : MultiplatformCommands { override fun getSender(context: CommandContext<*>): KCommandSender { val commandSourceStack = context.source as CommandSourceStack - - return when (val source = commandSourceStack.source) { + return when (val source = commandSourceStack.publicSource) { is ServerPlayer -> { KPlayerKCommandSender(source.asOnlineMinecraftPlayer()) } is RconConsoleSource -> { - NeoForgeRconKCommandSender(source) + MinecraftRconKCommandSender(source) } is DedicatedServer, is MinecraftServer -> { - NeoForgeServerKCommandSender(source) + MinecraftServerKCommandSender(source) } - else -> error("Could not wrap sender ${commandSourceStack.source.javaClass}") + else -> error("Could not wrap sender ${source.javaClass}") } } } diff --git a/core-forge/src/main/kotlin/ru/astrainteractive/astralibs/command/brigadier/sender/ForgeRconKCommandSender.kt b/core-minecraft/src/main/kotlin/ru/astrainteractive/astralibs/command/brigadier/sender/MinecraftRconKCommandSender.kt similarity index 95% rename from core-forge/src/main/kotlin/ru/astrainteractive/astralibs/command/brigadier/sender/ForgeRconKCommandSender.kt rename to core-minecraft/src/main/kotlin/ru/astrainteractive/astralibs/command/brigadier/sender/MinecraftRconKCommandSender.kt index 36cd2291..d925122c 100644 --- a/core-forge/src/main/kotlin/ru/astrainteractive/astralibs/command/brigadier/sender/ForgeRconKCommandSender.kt +++ b/core-minecraft/src/main/kotlin/ru/astrainteractive/astralibs/command/brigadier/sender/MinecraftRconKCommandSender.kt @@ -9,7 +9,7 @@ import ru.astrainteractive.astralibs.server.permission.KPermissible import ru.astrainteractive.astralibs.server.util.asKAudience import ru.astrainteractive.astralibs.server.util.asKCommandDispatcher -class ForgeRconKCommandSender( +class MinecraftRconKCommandSender( sender: RconConsoleSource ) : ConsoleKCommandSender, KPermissible by ConsoleKPermissible, diff --git a/core-neoforge/src/main/kotlin/ru/astrainteractive/astralibs/command/brigadier/sender/NeoForgeServerKCommandSender.kt b/core-minecraft/src/main/kotlin/ru/astrainteractive/astralibs/command/brigadier/sender/MinecraftServerKCommandSender.kt similarity index 95% rename from core-neoforge/src/main/kotlin/ru/astrainteractive/astralibs/command/brigadier/sender/NeoForgeServerKCommandSender.kt rename to core-minecraft/src/main/kotlin/ru/astrainteractive/astralibs/command/brigadier/sender/MinecraftServerKCommandSender.kt index 613c135f..1c2f538b 100644 --- a/core-neoforge/src/main/kotlin/ru/astrainteractive/astralibs/command/brigadier/sender/NeoForgeServerKCommandSender.kt +++ b/core-minecraft/src/main/kotlin/ru/astrainteractive/astralibs/command/brigadier/sender/MinecraftServerKCommandSender.kt @@ -9,7 +9,7 @@ import ru.astrainteractive.astralibs.server.permission.KPermissible import ru.astrainteractive.astralibs.server.util.asKAudience import ru.astrainteractive.astralibs.server.util.asKCommandDispatcher -class NeoForgeServerKCommandSender( +class MinecraftServerKCommandSender( sender: MinecraftServer ) : ConsoleKCommandSender, KPermissible by ConsoleKPermissible, diff --git a/core-neoforge/src/main/kotlin/ru/astrainteractive/astralibs/coroutines/NeoForgeDispatchers.kt b/core-minecraft/src/main/kotlin/ru/astrainteractive/astralibs/coroutines/MinecraftDispatchers.kt similarity index 87% rename from core-neoforge/src/main/kotlin/ru/astrainteractive/astralibs/coroutines/NeoForgeDispatchers.kt rename to core-minecraft/src/main/kotlin/ru/astrainteractive/astralibs/coroutines/MinecraftDispatchers.kt index cbf64957..1e707f22 100644 --- a/core-neoforge/src/main/kotlin/ru/astrainteractive/astralibs/coroutines/NeoForgeDispatchers.kt +++ b/core-minecraft/src/main/kotlin/ru/astrainteractive/astralibs/coroutines/MinecraftDispatchers.kt @@ -5,9 +5,9 @@ import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.MainCoroutineDispatcher import ru.astrainteractive.klibs.mikro.core.dispatchers.KotlinDispatchers -class NeoForgeDispatchers : KotlinDispatchers { +class MinecraftDispatchers : KotlinDispatchers { override val Main: MainCoroutineDispatcher by lazy { - NeoForgeMainDispatcher() + MinecraftMainDispatcher() } override val IO: CoroutineDispatcher get() = Dispatchers.IO diff --git a/core-neoforge/src/main/kotlin/ru/astrainteractive/astralibs/coroutines/NeoForgeMainDispatcher.kt b/core-minecraft/src/main/kotlin/ru/astrainteractive/astralibs/coroutines/MinecraftMainDispatcher.kt similarity index 56% rename from core-neoforge/src/main/kotlin/ru/astrainteractive/astralibs/coroutines/NeoForgeMainDispatcher.kt rename to core-minecraft/src/main/kotlin/ru/astrainteractive/astralibs/coroutines/MinecraftMainDispatcher.kt index 5639b954..e4842a03 100644 --- a/core-neoforge/src/main/kotlin/ru/astrainteractive/astralibs/coroutines/NeoForgeMainDispatcher.kt +++ b/core-minecraft/src/main/kotlin/ru/astrainteractive/astralibs/coroutines/MinecraftMainDispatcher.kt @@ -1,30 +1,22 @@ package ru.astrainteractive.astralibs.coroutines import kotlinx.coroutines.MainCoroutineDispatcher -import net.minecraft.client.Minecraft -import net.neoforged.api.distmarker.Dist -import net.neoforged.fml.loading.FMLEnvironment -import ru.astrainteractive.astralibs.server.util.NeoForgeUtil +import ru.astrainteractive.astralibs.server.util.MinecraftUtil import java.util.concurrent.Executor import kotlin.coroutines.CoroutineContext -class NeoForgeMainDispatcher : MainCoroutineDispatcher() { +class MinecraftMainDispatcher : MainCoroutineDispatcher() { override val immediate: MainCoroutineDispatcher get() = this - private val executor = when (FMLEnvironment.dist) { - Dist.CLIENT -> Minecraft.getInstance() - Dist.DEDICATED_SERVER -> Executor { block -> - NeoForgeUtil.requireServer().executeBlocking(block) - } - } - override fun isDispatchNeeded(context: CoroutineContext): Boolean { - return true + private val executor = Executor { block -> + MinecraftUtil.requireServer().executeBlocking(block) } + override fun isDispatchNeeded(context: CoroutineContext): Boolean = true + override fun dispatch(context: CoroutineContext, block: Runnable) { val coroutineTimings = context[CoroutineTimings.Key] - if (coroutineTimings == null) { executor.execute(block) } else { diff --git a/core-forge/src/main/kotlin/ru/astrainteractive/astralibs/server/bridge/ForgePlatformServer.kt b/core-minecraft/src/main/kotlin/ru/astrainteractive/astralibs/server/bridge/MinecraftPlatformServer.kt similarity index 68% rename from core-forge/src/main/kotlin/ru/astrainteractive/astralibs/server/bridge/ForgePlatformServer.kt rename to core-minecraft/src/main/kotlin/ru/astrainteractive/astralibs/server/bridge/MinecraftPlatformServer.kt index 1ac7a7cd..843878bd 100644 --- a/core-forge/src/main/kotlin/ru/astrainteractive/astralibs/server/bridge/ForgePlatformServer.kt +++ b/core-minecraft/src/main/kotlin/ru/astrainteractive/astralibs/server/bridge/MinecraftPlatformServer.kt @@ -2,7 +2,7 @@ package ru.astrainteractive.astralibs.server.bridge import ru.astrainteractive.astralibs.server.player.KPlayer import ru.astrainteractive.astralibs.server.player.OnlineKPlayer -import ru.astrainteractive.astralibs.server.util.ForgeUtil +import ru.astrainteractive.astralibs.server.util.MinecraftUtil import ru.astrainteractive.astralibs.server.util.asOfflineMinecraftPlayer import ru.astrainteractive.astralibs.server.util.asOnlineMinecraftPlayer import ru.astrainteractive.astralibs.server.util.getOnlinePlayer @@ -10,26 +10,26 @@ import ru.astrainteractive.astralibs.server.util.getOnlinePlayers import ru.astrainteractive.astralibs.server.util.getPlayerGameProfile import java.util.UUID -object ForgePlatformServer : PlatformServer { +object MinecraftPlatformServer : PlatformServer { override fun getOnlinePlayers(): List { - return ForgeUtil + return MinecraftUtil .getOnlinePlayers() .map { serverPlayer -> serverPlayer.asOnlineMinecraftPlayer() } } override fun findOnlinePlayer(uuid: UUID): OnlineKPlayer? { - return ForgeUtil.getOnlinePlayer(uuid)?.asOnlineMinecraftPlayer() + return MinecraftUtil.getOnlinePlayer(uuid)?.asOnlineMinecraftPlayer() } override fun findOfflinePlayer(uuid: UUID): KPlayer? { - return ForgeUtil.getPlayerGameProfile(uuid)?.asOfflineMinecraftPlayer() + return MinecraftUtil.getPlayerGameProfile(uuid)?.asOfflineMinecraftPlayer() } override fun findOnlinePlayer(name: String): OnlineKPlayer? { - return ForgeUtil.getOnlinePlayer(name)?.asOnlineMinecraftPlayer() + return MinecraftUtil.getOnlinePlayer(name)?.asOnlineMinecraftPlayer() } override fun findOfflinePlayer(name: String): KPlayer? { - return ForgeUtil.getPlayerGameProfile(name)?.asOfflineMinecraftPlayer() + return MinecraftUtil.getPlayerGameProfile(name)?.asOfflineMinecraftPlayer() } } diff --git a/core-forge/src/main/kotlin/ru/astrainteractive/astralibs/server/player/ForgeKPlayer.kt b/core-minecraft/src/main/kotlin/ru/astrainteractive/astralibs/server/player/MinecraftKPlayer.kt similarity index 76% rename from core-forge/src/main/kotlin/ru/astrainteractive/astralibs/server/player/ForgeKPlayer.kt rename to core-minecraft/src/main/kotlin/ru/astrainteractive/astralibs/server/player/MinecraftKPlayer.kt index 710457ac..5852807b 100644 --- a/core-forge/src/main/kotlin/ru/astrainteractive/astralibs/server/player/ForgeKPlayer.kt +++ b/core-minecraft/src/main/kotlin/ru/astrainteractive/astralibs/server/player/MinecraftKPlayer.kt @@ -2,12 +2,12 @@ package ru.astrainteractive.astralibs.server.player import com.mojang.authlib.GameProfile import net.minecraft.world.level.storage.LevelResource -import net.minecraftforge.server.ServerLifecycleHooks import ru.astrainteractive.astralibs.server.annotation.InternalPlatformApi +import ru.astrainteractive.astralibs.server.util.MinecraftUtil import java.util.UUID @OptIn(InternalPlatformApi::class) -class ForgeKPlayer(val instance: GameProfile) : KPlayer { +class MinecraftKPlayer(val instance: GameProfile) : KPlayer { override val uuid: UUID get() = instance.id @@ -15,7 +15,7 @@ class ForgeKPlayer(val instance: GameProfile) : KPlayer { get() = instance.name override fun hasPlayedBefore(): Boolean { - val playerDataDir = ServerLifecycleHooks.getCurrentServer() + val playerDataDir = MinecraftUtil.serverOrNull ?.getWorldPath(LevelResource.PLAYER_DATA_DIR) ?.toFile() return playerDataDir?.resolve("$uuid.dat")?.exists() == true diff --git a/core-forge/src/main/kotlin/ru/astrainteractive/astralibs/server/player/ForgeOnlineKPlayer.kt b/core-minecraft/src/main/kotlin/ru/astrainteractive/astralibs/server/player/MinecraftOnlineKPlayer.kt similarity index 87% rename from core-forge/src/main/kotlin/ru/astrainteractive/astralibs/server/player/ForgeOnlineKPlayer.kt rename to core-minecraft/src/main/kotlin/ru/astrainteractive/astralibs/server/player/MinecraftOnlineKPlayer.kt index 52079e60..3fdda652 100644 --- a/core-forge/src/main/kotlin/ru/astrainteractive/astralibs/server/player/ForgeOnlineKPlayer.kt +++ b/core-minecraft/src/main/kotlin/ru/astrainteractive/astralibs/server/player/MinecraftOnlineKPlayer.kt @@ -13,12 +13,13 @@ import ru.astrainteractive.astralibs.server.util.asLocatable import ru.astrainteractive.astralibs.server.util.asPermissible import ru.astrainteractive.astralibs.server.util.asTeleportable import ru.astrainteractive.astralibs.server.util.toPlain +import ru.astrainteractive.astralibs.util.publicServer import ru.astrainteractive.klibs.mikro.core.util.cast import java.net.InetSocketAddress import java.util.* @OptIn(InternalPlatformApi::class) -class ForgeOnlineKPlayer(val instance: ServerPlayer) : +class MinecraftOnlineKPlayer(val instance: ServerPlayer) : OnlineKPlayer, KAudience by instance.asKAudience(), Locatable by instance.asLocatable(), @@ -31,9 +32,10 @@ class ForgeOnlineKPlayer(val instance: ServerPlayer) : get() = instance.name.toPlain() override fun hasPlayedBefore(): Boolean { - return instance.server.playerList - .load(instance) - ?.isEmpty != true + return instance.publicServer + ?.playerList + ?.load(instance) + ?.isEmpty == true } override val address: InetSocketAddress diff --git a/core-forge/src/main/kotlin/ru/astrainteractive/astralibs/server/util/AudienceExt.kt b/core-minecraft/src/main/kotlin/ru/astrainteractive/astralibs/server/util/AudienceExt.kt similarity index 92% rename from core-forge/src/main/kotlin/ru/astrainteractive/astralibs/server/util/AudienceExt.kt rename to core-minecraft/src/main/kotlin/ru/astrainteractive/astralibs/server/util/AudienceExt.kt index f1d523df..e93475ec 100644 --- a/core-forge/src/main/kotlin/ru/astrainteractive/astralibs/server/util/AudienceExt.kt +++ b/core-minecraft/src/main/kotlin/ru/astrainteractive/astralibs/server/util/AudienceExt.kt @@ -7,7 +7,7 @@ import net.minecraft.world.entity.player.Player import ru.astrainteractive.astralibs.server.KAudience fun Player.asKAudience() = KAudience { component -> - this.sendSystemMessage(component.toNative()) + displayClientMessage(component.toNative(), false) } fun CommandSourceStack.asKAudience() = KAudience { component -> diff --git a/core-forge/src/main/kotlin/ru/astrainteractive/astralibs/server/util/CommandDispatcherExt.kt b/core-minecraft/src/main/kotlin/ru/astrainteractive/astralibs/server/util/CommandDispatcherExt.kt similarity index 78% rename from core-forge/src/main/kotlin/ru/astrainteractive/astralibs/server/util/CommandDispatcherExt.kt rename to core-minecraft/src/main/kotlin/ru/astrainteractive/astralibs/server/util/CommandDispatcherExt.kt index 1cd750b6..755f99fa 100644 --- a/core-forge/src/main/kotlin/ru/astrainteractive/astralibs/server/util/CommandDispatcherExt.kt +++ b/core-minecraft/src/main/kotlin/ru/astrainteractive/astralibs/server/util/CommandDispatcherExt.kt @@ -3,9 +3,8 @@ package ru.astrainteractive.astralibs.server.util import net.minecraft.server.MinecraftServer import net.minecraft.server.level.ServerPlayer import net.minecraft.server.rcon.RconConsoleSource -import net.minecraftforge.server.ServerLifecycleHooks -import ru.astrainteractive.astralibs.command.brigadier.command.command import ru.astrainteractive.astralibs.server.KCommandDispatcher +import ru.astrainteractive.astralibs.util.publicServer fun MinecraftServer.asKCommandDispatcher() = KCommandDispatcher { command -> this.commands.performPrefixedCommand( @@ -15,7 +14,7 @@ fun MinecraftServer.asKCommandDispatcher() = KCommandDispatcher { command -> } fun RconConsoleSource.asKCommandDispatcher() = KCommandDispatcher { command -> - ServerLifecycleHooks.getCurrentServer() + MinecraftUtil.serverOrNull ?.commands ?.performPrefixedCommand( this.createCommandSourceStack(), @@ -24,7 +23,7 @@ fun RconConsoleSource.asKCommandDispatcher() = KCommandDispatcher { command -> } fun ServerPlayer.asKCommandDispatcher() = KCommandDispatcher { command -> - this.server.commands.performPrefixedCommand( + publicServer?.commands?.performPrefixedCommand( this.createCommandSourceStack(), command ) diff --git a/core-forge/src/main/kotlin/ru/astrainteractive/astralibs/server/util/LocatableExt.kt b/core-minecraft/src/main/kotlin/ru/astrainteractive/astralibs/server/util/LocatableExt.kt similarity index 100% rename from core-forge/src/main/kotlin/ru/astrainteractive/astralibs/server/util/LocatableExt.kt rename to core-minecraft/src/main/kotlin/ru/astrainteractive/astralibs/server/util/LocatableExt.kt diff --git a/core-minecraft/src/main/kotlin/ru/astrainteractive/astralibs/server/util/MinecraftUtil.kt b/core-minecraft/src/main/kotlin/ru/astrainteractive/astralibs/server/util/MinecraftUtil.kt new file mode 100644 index 00000000..6e76a4bb --- /dev/null +++ b/core-minecraft/src/main/kotlin/ru/astrainteractive/astralibs/server/util/MinecraftUtil.kt @@ -0,0 +1,65 @@ +package ru.astrainteractive.astralibs.server.util + +import com.mojang.authlib.GameProfile +import net.minecraft.server.MinecraftServer +import net.minecraft.server.level.ServerPlayer +import net.minecraft.world.level.Level +import java.lang.ref.WeakReference +import java.util.UUID +import java.util.concurrent.locks.ReentrantLock +import kotlin.concurrent.withLock + +object MinecraftUtil { + private val lock = ReentrantLock() + private var _server: WeakReference? = null + + val serverOrNull: MinecraftServer? + get() = lock.withLock { _server?.get() } + + fun setServer(server: MinecraftServer?) { + lock.withLock { _server = WeakReference(server) } + } + + fun requireServer(): MinecraftServer { + return lock + .withLock { _server?.get() } + ?: error("Server is not available") + } +} + +fun MinecraftUtil.getDefaultWorldName(): String? { + return serverOrNull + ?.getLevel(Level.OVERWORLD) + ?.dimension() + ?.location() + ?.path +} + +fun MinecraftUtil.getPlayerGameProfile(uuid: UUID): GameProfile? { + return serverOrNull?.profileCache?.get(uuid)?.orElse(null) +} + +fun MinecraftUtil.getPlayerGameProfile(name: String): GameProfile? { + return serverOrNull?.profileCache?.get(name)?.orElse(null) +} + +fun MinecraftUtil.getOnlinePlayers(): List { + return serverOrNull + ?.playerList + ?.players + ?.toList() + .orEmpty() + .filterNotNull() +} + +fun MinecraftUtil.getOnlinePlayer(uuid: UUID): ServerPlayer? { + return serverOrNull?.playerList?.getPlayer(uuid) +} + +fun MinecraftUtil.getOnlinePlayer(name: String): ServerPlayer? { + return serverOrNull?.playerList?.getPlayerByName(name) +} + +fun MinecraftUtil.getNextTickTime(): Double { + return serverOrNull?.nextTickTime?.toDouble() ?: 0.0 +} diff --git a/core-forge/src/main/kotlin/ru/astrainteractive/astralibs/server/util/NativeComponentExt.kt b/core-minecraft/src/main/kotlin/ru/astrainteractive/astralibs/server/util/NativeComponentExt.kt similarity index 100% rename from core-forge/src/main/kotlin/ru/astrainteractive/astralibs/server/util/NativeComponentExt.kt rename to core-minecraft/src/main/kotlin/ru/astrainteractive/astralibs/server/util/NativeComponentExt.kt diff --git a/core-neoforge/src/main/kotlin/ru/astrainteractive/astralibs/server/util/PermissibleExt.kt b/core-minecraft/src/main/kotlin/ru/astrainteractive/astralibs/server/util/PermissibleExt.kt similarity index 70% rename from core-neoforge/src/main/kotlin/ru/astrainteractive/astralibs/server/util/PermissibleExt.kt rename to core-minecraft/src/main/kotlin/ru/astrainteractive/astralibs/server/util/PermissibleExt.kt index f8f618f2..65e5d81e 100644 --- a/core-neoforge/src/main/kotlin/ru/astrainteractive/astralibs/server/util/PermissibleExt.kt +++ b/core-minecraft/src/main/kotlin/ru/astrainteractive/astralibs/server/util/PermissibleExt.kt @@ -4,8 +4,12 @@ import net.minecraft.world.entity.player.Player import ru.astrainteractive.astralibs.server.permission.KPermissible import ru.astrainteractive.astralibs.server.permission.LuckPermsKPermissible +private val isLuckPermsLoaded: Boolean by lazy { + runCatching { Class.forName("net.luckperms.api.LuckPerms") }.isSuccess +} + fun Player.asPermissible(): KPermissible { - return if (NeoForgeUtil.isModLoaded("luckperms")) { + return if (isLuckPermsLoaded) { LuckPermsKPermissible(this.uuid) } else { error("No permission provider loaded!") diff --git a/core-forge/src/main/kotlin/ru/astrainteractive/astralibs/server/util/PlayerExt.kt b/core-minecraft/src/main/kotlin/ru/astrainteractive/astralibs/server/util/PlayerExt.kt similarity index 63% rename from core-forge/src/main/kotlin/ru/astrainteractive/astralibs/server/util/PlayerExt.kt rename to core-minecraft/src/main/kotlin/ru/astrainteractive/astralibs/server/util/PlayerExt.kt index 114aee07..975d19e9 100644 --- a/core-forge/src/main/kotlin/ru/astrainteractive/astralibs/server/util/PlayerExt.kt +++ b/core-minecraft/src/main/kotlin/ru/astrainteractive/astralibs/server/util/PlayerExt.kt @@ -2,15 +2,15 @@ package ru.astrainteractive.astralibs.server.util import com.mojang.authlib.GameProfile import net.minecraft.server.level.ServerPlayer -import ru.astrainteractive.astralibs.server.player.ForgeKPlayer -import ru.astrainteractive.astralibs.server.player.ForgeOnlineKPlayer import ru.astrainteractive.astralibs.server.player.KPlayer +import ru.astrainteractive.astralibs.server.player.MinecraftKPlayer +import ru.astrainteractive.astralibs.server.player.MinecraftOnlineKPlayer import ru.astrainteractive.astralibs.server.player.OnlineKPlayer fun ServerPlayer.asOnlineMinecraftPlayer(): OnlineKPlayer { - return ForgeOnlineKPlayer(this) + return MinecraftOnlineKPlayer(this) } fun GameProfile.asOfflineMinecraftPlayer(): KPlayer { - return ForgeKPlayer(this) + return MinecraftKPlayer(this) } diff --git a/core-neoforge/src/main/kotlin/ru/astrainteractive/astralibs/server/util/TeleportableExt.kt b/core-minecraft/src/main/kotlin/ru/astrainteractive/astralibs/server/util/TeleportableExt.kt similarity index 60% rename from core-neoforge/src/main/kotlin/ru/astrainteractive/astralibs/server/util/TeleportableExt.kt rename to core-minecraft/src/main/kotlin/ru/astrainteractive/astralibs/server/util/TeleportableExt.kt index 47dd3f93..8e053ee8 100644 --- a/core-neoforge/src/main/kotlin/ru/astrainteractive/astralibs/server/util/TeleportableExt.kt +++ b/core-minecraft/src/main/kotlin/ru/astrainteractive/astralibs/server/util/TeleportableExt.kt @@ -3,13 +3,17 @@ package ru.astrainteractive.astralibs.server.util import net.minecraft.server.level.ServerPlayer import net.minecraft.world.level.storage.ServerLevelData import ru.astrainteractive.astralibs.server.Teleportable +import ru.astrainteractive.astralibs.util.publicServer +import ru.astrainteractive.klibs.mikro.core.util.tryCast fun ServerPlayer.asTeleportable() = Teleportable { location -> val player = this - val level = player.server + val level = player.publicServer ?.allLevels - ?.firstOrNull { (it.level.levelData as ServerLevelData).levelName == location.worldName } + ?.firstOrNull { serverLevel -> + serverLevel.level.levelData.tryCast()?.levelName == location.worldName + } ?: return@Teleportable player.teleportTo( level, @@ -17,6 +21,6 @@ fun ServerPlayer.asTeleportable() = Teleportable { location -> location.y, location.z, 0f, - 0f + 0f, ) } diff --git a/core-minecraft/src/main/kotlin/ru/astrainteractive/astralibs/util/MinecraftExt.kt b/core-minecraft/src/main/kotlin/ru/astrainteractive/astralibs/util/MinecraftExt.kt new file mode 100644 index 00000000..c15aedfe --- /dev/null +++ b/core-minecraft/src/main/kotlin/ru/astrainteractive/astralibs/util/MinecraftExt.kt @@ -0,0 +1,12 @@ +package ru.astrainteractive.astralibs.util + +import net.minecraft.commands.CommandSource +import net.minecraft.commands.CommandSourceStack +import net.minecraft.server.MinecraftServer +import net.minecraft.server.level.ServerPlayer + +internal val CommandSourceStack.publicSource: CommandSource + get() = this.privateField(fieldName = "source") + +internal val ServerPlayer.publicServer: MinecraftServer? + get() = this.privateField(fieldName = "server", onError = { null }) diff --git a/core-minecraft/src/main/kotlin/ru/astrainteractive/astralibs/util/ReflectionExt.kt b/core-minecraft/src/main/kotlin/ru/astrainteractive/astralibs/util/ReflectionExt.kt new file mode 100644 index 00000000..7fdd4815 --- /dev/null +++ b/core-minecraft/src/main/kotlin/ru/astrainteractive/astralibs/util/ReflectionExt.kt @@ -0,0 +1,13 @@ +package ru.astrainteractive.astralibs.util + +@Suppress("UNCHECKED_CAST") +internal inline fun Any.privateField( + fieldName: String, + onError: (Throwable) -> T = { t -> error(t) } +): T = try { + val field = this::class.java.getDeclaredField(fieldName) + field.isAccessible = true + field.get(this) as T +} catch (e: Throwable) { + onError.invoke(e) +} diff --git a/core-neoforge/build.gradle.kts b/core-neoforge/build.gradle.kts index 304bd9d9..3d0240e1 100644 --- a/core-neoforge/build.gradle.kts +++ b/core-neoforge/build.gradle.kts @@ -23,6 +23,8 @@ dependencies { implementation(projects.command) implementation(projects.core) + api(projects.coreMinecraft) + testImplementation(libs.kotlin.serialization.kaml) testImplementation(libs.tests.kotlin.test) } diff --git a/core-neoforge/src/main/kotlin/ru/astrainteractive/astralibs/command/brigadier/sender/NeoForgeRconKCommandSender.kt b/core-neoforge/src/main/kotlin/ru/astrainteractive/astralibs/command/brigadier/sender/NeoForgeRconKCommandSender.kt deleted file mode 100644 index b0c339fc..00000000 --- a/core-neoforge/src/main/kotlin/ru/astrainteractive/astralibs/command/brigadier/sender/NeoForgeRconKCommandSender.kt +++ /dev/null @@ -1,17 +0,0 @@ -package ru.astrainteractive.astralibs.command.brigadier.sender - -import net.minecraft.server.rcon.RconConsoleSource -import ru.astrainteractive.astralibs.command.api.brigadier.sender.ConsoleKCommandSender -import ru.astrainteractive.astralibs.server.KAudience -import ru.astrainteractive.astralibs.server.KCommandDispatcher -import ru.astrainteractive.astralibs.server.permission.ConsoleKPermissible -import ru.astrainteractive.astralibs.server.permission.KPermissible -import ru.astrainteractive.astralibs.server.util.asKAudience -import ru.astrainteractive.astralibs.server.util.asKCommandDispatcher - -class NeoForgeRconKCommandSender( - sender: RconConsoleSource -) : ConsoleKCommandSender, - KPermissible by ConsoleKPermissible, - KAudience by sender.asKAudience(), - KCommandDispatcher by sender.asKCommandDispatcher() diff --git a/core-neoforge/src/main/kotlin/ru/astrainteractive/astralibs/lifecycle/ForgeLifecycleServer.kt b/core-neoforge/src/main/kotlin/ru/astrainteractive/astralibs/lifecycle/ForgeLifecycleServer.kt index 2cdf3cdd..f3cea6ad 100644 --- a/core-neoforge/src/main/kotlin/ru/astrainteractive/astralibs/lifecycle/ForgeLifecycleServer.kt +++ b/core-neoforge/src/main/kotlin/ru/astrainteractive/astralibs/lifecycle/ForgeLifecycleServer.kt @@ -11,13 +11,14 @@ import net.neoforged.bus.api.EventPriority import net.neoforged.neoforge.event.server.ServerStartedEvent import net.neoforged.neoforge.event.server.ServerStoppingEvent import ru.astrainteractive.astralibs.event.flowEvent -import ru.astrainteractive.astralibs.server.util.NeoForgeUtil +import ru.astrainteractive.astralibs.server.util.MinecraftUtil import ru.astrainteractive.klibs.mikro.core.logging.Logger abstract class ForgeLifecycleServer : Lifecycle, Logger { private val unconfinedScope = CoroutineScope(SupervisorJob() + Dispatchers.Unconfined) val serverStartedEvent = flowEvent(EventPriority.HIGHEST) + .onEach { event -> MinecraftUtil.setServer(event.server) } .onEach { onEnable() } .catch { throwable -> error(throwable) { "#serverStartedEvent ${throwable.localizedMessage}" } @@ -31,8 +32,4 @@ abstract class ForgeLifecycleServer : Lifecycle, Logger { error(throwable) { "#serverStartedEvent ${throwable.localizedMessage}" } } .launchIn(unconfinedScope) - - init { - NeoForgeUtil.bootstrap() - } } diff --git a/core-neoforge/src/main/kotlin/ru/astrainteractive/astralibs/server/bridge/NeoForgePlatformServer.kt b/core-neoforge/src/main/kotlin/ru/astrainteractive/astralibs/server/bridge/NeoForgePlatformServer.kt deleted file mode 100644 index 168e7e72..00000000 --- a/core-neoforge/src/main/kotlin/ru/astrainteractive/astralibs/server/bridge/NeoForgePlatformServer.kt +++ /dev/null @@ -1,35 +0,0 @@ -package ru.astrainteractive.astralibs.server.bridge - -import ru.astrainteractive.astralibs.server.player.KPlayer -import ru.astrainteractive.astralibs.server.player.OnlineKPlayer -import ru.astrainteractive.astralibs.server.util.NeoForgeUtil -import ru.astrainteractive.astralibs.server.util.asOfflineMinecraftPlayer -import ru.astrainteractive.astralibs.server.util.asOnlineMinecraftPlayer -import ru.astrainteractive.astralibs.server.util.getOnlinePlayer -import ru.astrainteractive.astralibs.server.util.getOnlinePlayers -import ru.astrainteractive.astralibs.server.util.getPlayerGameProfile -import java.util.UUID - -object NeoForgePlatformServer : PlatformServer { - override fun getOnlinePlayers(): List { - return NeoForgeUtil - .getOnlinePlayers() - .map { serverPlayer -> serverPlayer.asOnlineMinecraftPlayer() } - } - - override fun findOnlinePlayer(uuid: UUID): OnlineKPlayer? { - return NeoForgeUtil.getOnlinePlayer(uuid)?.asOnlineMinecraftPlayer() - } - - override fun findOfflinePlayer(uuid: UUID): KPlayer? { - return NeoForgeUtil.getPlayerGameProfile(uuid)?.asOfflineMinecraftPlayer() - } - - override fun findOnlinePlayer(name: String): OnlineKPlayer? { - return NeoForgeUtil.getOnlinePlayer(name)?.asOnlineMinecraftPlayer() - } - - override fun findOfflinePlayer(name: String): KPlayer? { - return NeoForgeUtil.getPlayerGameProfile(name)?.asOfflineMinecraftPlayer() - } -} diff --git a/core-neoforge/src/main/kotlin/ru/astrainteractive/astralibs/server/player/NeoForgeKPlayer.kt b/core-neoforge/src/main/kotlin/ru/astrainteractive/astralibs/server/player/NeoForgeKPlayer.kt deleted file mode 100644 index e51a3304..00000000 --- a/core-neoforge/src/main/kotlin/ru/astrainteractive/astralibs/server/player/NeoForgeKPlayer.kt +++ /dev/null @@ -1,23 +0,0 @@ -package ru.astrainteractive.astralibs.server.player - -import com.mojang.authlib.GameProfile -import net.minecraft.world.level.storage.LevelResource -import net.neoforged.neoforge.server.ServerLifecycleHooks -import ru.astrainteractive.astralibs.server.annotation.InternalPlatformApi -import java.util.UUID - -@OptIn(InternalPlatformApi::class) -class NeoForgeKPlayer(val instance: GameProfile) : KPlayer { - override val uuid: UUID - get() = instance.id - - override val name: String? - get() = instance.name - - override fun hasPlayedBefore(): Boolean { - val playerDataDir = ServerLifecycleHooks.getCurrentServer() - ?.getWorldPath(LevelResource.PLAYER_DATA_DIR) - ?.toFile() - return playerDataDir?.resolve("$uuid.dat")?.exists() == true - } -} diff --git a/core-neoforge/src/main/kotlin/ru/astrainteractive/astralibs/server/player/NeoForgeOnlineKPlayer.kt b/core-neoforge/src/main/kotlin/ru/astrainteractive/astralibs/server/player/NeoForgeOnlineKPlayer.kt deleted file mode 100644 index d4b434ed..00000000 --- a/core-neoforge/src/main/kotlin/ru/astrainteractive/astralibs/server/player/NeoForgeOnlineKPlayer.kt +++ /dev/null @@ -1,43 +0,0 @@ -package ru.astrainteractive.astralibs.server.player - -import net.minecraft.server.level.ServerPlayer -import ru.astrainteractive.astralibs.server.KAudience -import ru.astrainteractive.astralibs.server.KCommandDispatcher -import ru.astrainteractive.astralibs.server.Locatable -import ru.astrainteractive.astralibs.server.Teleportable -import ru.astrainteractive.astralibs.server.annotation.InternalPlatformApi -import ru.astrainteractive.astralibs.server.permission.KPermissible -import ru.astrainteractive.astralibs.server.util.asKAudience -import ru.astrainteractive.astralibs.server.util.asKCommandDispatcher -import ru.astrainteractive.astralibs.server.util.asLocatable -import ru.astrainteractive.astralibs.server.util.asPermissible -import ru.astrainteractive.astralibs.server.util.asTeleportable -import ru.astrainteractive.astralibs.server.util.toPlain -import ru.astrainteractive.klibs.mikro.core.util.cast -import java.net.InetSocketAddress -import java.util.* - -@OptIn(InternalPlatformApi::class) -class NeoForgeOnlineKPlayer(val instance: ServerPlayer) : - OnlineKPlayer, - KAudience by instance.asKAudience(), - Locatable by instance.asLocatable(), - Teleportable by instance.asTeleportable(), - KPermissible by instance.asPermissible(), - KCommandDispatcher by instance.asKCommandDispatcher() { - override val uuid: UUID - get() = instance.uuid - override val name: String - get() = instance.name.toPlain() - - override fun hasPlayedBefore(): Boolean { - return instance.server.playerList - .load(instance) - .isPresent - } - - override val address: InetSocketAddress - get() = instance.connection - .remoteAddress - .cast() -} diff --git a/core-neoforge/src/main/kotlin/ru/astrainteractive/astralibs/server/util/AudienceExt.kt b/core-neoforge/src/main/kotlin/ru/astrainteractive/astralibs/server/util/AudienceExt.kt deleted file mode 100644 index f1d523df..00000000 --- a/core-neoforge/src/main/kotlin/ru/astrainteractive/astralibs/server/util/AudienceExt.kt +++ /dev/null @@ -1,23 +0,0 @@ -package ru.astrainteractive.astralibs.server.util - -import net.minecraft.commands.CommandSourceStack -import net.minecraft.server.MinecraftServer -import net.minecraft.server.rcon.RconConsoleSource -import net.minecraft.world.entity.player.Player -import ru.astrainteractive.astralibs.server.KAudience - -fun Player.asKAudience() = KAudience { component -> - this.sendSystemMessage(component.toNative()) -} - -fun CommandSourceStack.asKAudience() = KAudience { component -> - this.sendSystemMessage(component.toNative()) -} - -fun MinecraftServer.asKAudience() = KAudience { component -> - sendSystemMessage(component.toNative()) -} - -fun RconConsoleSource.asKAudience() = KAudience { component -> - sendSystemMessage(component.toNative()) -} diff --git a/core-neoforge/src/main/kotlin/ru/astrainteractive/astralibs/server/util/CommandDispatcherExt.kt b/core-neoforge/src/main/kotlin/ru/astrainteractive/astralibs/server/util/CommandDispatcherExt.kt deleted file mode 100644 index 9a584b9e..00000000 --- a/core-neoforge/src/main/kotlin/ru/astrainteractive/astralibs/server/util/CommandDispatcherExt.kt +++ /dev/null @@ -1,31 +0,0 @@ -package ru.astrainteractive.astralibs.server.util - -import net.minecraft.server.MinecraftServer -import net.minecraft.server.level.ServerPlayer -import net.minecraft.server.rcon.RconConsoleSource -import net.neoforged.neoforge.server.ServerLifecycleHooks -import ru.astrainteractive.astralibs.command.brigadier.command.command -import ru.astrainteractive.astralibs.server.KCommandDispatcher - -fun MinecraftServer.asKCommandDispatcher() = KCommandDispatcher { command -> - this.commands.performPrefixedCommand( - this.createCommandSourceStack(), - command - ) -} - -fun RconConsoleSource.asKCommandDispatcher() = KCommandDispatcher { command -> - ServerLifecycleHooks.getCurrentServer() - ?.commands - ?.performPrefixedCommand( - this.createCommandSourceStack(), - command - ) -} - -fun ServerPlayer.asKCommandDispatcher() = KCommandDispatcher { command -> - this.server.commands.performPrefixedCommand( - this.createCommandSourceStack(), - command - ) -} diff --git a/core-neoforge/src/main/kotlin/ru/astrainteractive/astralibs/server/util/LocatableExt.kt b/core-neoforge/src/main/kotlin/ru/astrainteractive/astralibs/server/util/LocatableExt.kt deleted file mode 100644 index 242ce45f..00000000 --- a/core-neoforge/src/main/kotlin/ru/astrainteractive/astralibs/server/util/LocatableExt.kt +++ /dev/null @@ -1,15 +0,0 @@ -package ru.astrainteractive.astralibs.server.util - -import net.minecraft.world.entity.Entity -import net.minecraft.world.level.storage.ServerLevelData -import ru.astrainteractive.astralibs.server.Locatable -import ru.astrainteractive.astralibs.server.location.KLocation - -fun Entity.asLocatable() = Locatable { - KLocation( - x = this.x, - y = this.y, - z = this.z, - worldName = (level().levelData as ServerLevelData).levelName - ) -} diff --git a/core-neoforge/src/main/kotlin/ru/astrainteractive/astralibs/server/util/NativeComponentExt.kt b/core-neoforge/src/main/kotlin/ru/astrainteractive/astralibs/server/util/NativeComponentExt.kt deleted file mode 100644 index bad6086e..00000000 --- a/core-neoforge/src/main/kotlin/ru/astrainteractive/astralibs/server/util/NativeComponentExt.kt +++ /dev/null @@ -1,31 +0,0 @@ -package ru.astrainteractive.astralibs.server.util - -import net.minecraft.network.chat.Component -import net.minecraft.network.chat.Component.Serializer -import ru.astrainteractive.astralibs.kyori.KyoriComponentSerializer - -fun net.kyori.adventure.text.Component.toNative(): Component { - val json = KyoriComponentSerializer.Json - val jsonComponent = json.serializer.serialize(this) - - return Serializer.fromJson( - jsonComponent, - NeoForgeUtil.requireServer().registryAccess() - ) ?: Component.empty() -} - -fun Component.toKyori(): net.kyori.adventure.text.Component { - val json = Serializer.toJson( - this, - NeoForgeUtil.requireServer().registryAccess() - ) - return KyoriComponentSerializer.Json.serializer.deserialize(json) -} - -fun net.kyori.adventure.text.Component.toPlain(): String { - return KyoriComponentSerializer.Plain.serializer.serialize(this) -} - -fun Component.toPlain(): String { - return toKyori().toPlain() -} diff --git a/core-neoforge/src/main/kotlin/ru/astrainteractive/astralibs/server/util/NeoForgeUtil.kt b/core-neoforge/src/main/kotlin/ru/astrainteractive/astralibs/server/util/NeoForgeUtil.kt deleted file mode 100644 index 95e6ba9d..00000000 --- a/core-neoforge/src/main/kotlin/ru/astrainteractive/astralibs/server/util/NeoForgeUtil.kt +++ /dev/null @@ -1,88 +0,0 @@ -package ru.astrainteractive.astralibs.server.util - -import com.mojang.authlib.GameProfile -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.flow.SharingStarted -import kotlinx.coroutines.flow.filterNotNull -import kotlinx.coroutines.flow.first -import kotlinx.coroutines.flow.flowOn -import kotlinx.coroutines.flow.map -import kotlinx.coroutines.flow.stateIn -import net.minecraft.server.MinecraftServer -import net.minecraft.server.level.ServerPlayer -import net.minecraft.world.level.Level -import net.neoforged.fml.loading.FMLLoader -import net.neoforged.neoforge.event.server.ServerStartedEvent -import net.neoforged.neoforge.server.ServerLifecycleHooks -import ru.astrainteractive.astralibs.event.flowEvent -import ru.astrainteractive.klibs.mikro.core.logging.JUtiltLogger -import ru.astrainteractive.klibs.mikro.core.logging.Logger -import java.util.UUID - -/** - * Don't forget to instantiate [NeoForgeUtil] on init at loader - */ -object NeoForgeUtil : Logger by JUtiltLogger("AstraLibs-ForgeUtil") { - private val serverFlow = flowEvent() - .map { event -> event.server } - .flowOn(Dispatchers.Unconfined) - .stateIn(GlobalScope, SharingStarted.Eagerly, null) - - val serverOrNull: MinecraftServer? - get() = ServerLifecycleHooks.getCurrentServer() - - suspend fun awaitServer(): MinecraftServer { - return serverFlow.filterNotNull().first() - } - - fun requireServer(): MinecraftServer { - return ServerLifecycleHooks - .getCurrentServer() - ?: error("Server is not available") - } - - fun bootstrap() = Unit -} - -fun NeoForgeUtil.isModLoaded(modId: String): Boolean { - return FMLLoader.getLoadingModList().getModFileById(modId) != null -} - -fun NeoForgeUtil.getDefaultWorldName(): String? { - return serverOrNull - ?.getLevel(Level.OVERWORLD) - ?.level - ?.dimension() - ?.location() - ?.path -} - -fun NeoForgeUtil.getPlayerGameProfile(uuid: UUID): GameProfile? { - return serverOrNull?.profileCache?.get(uuid)?.orElse(null) -} - -fun NeoForgeUtil.getPlayerGameProfile(name: String): GameProfile? { - return serverOrNull?.profileCache?.get(name)?.orElse(null) -} - -fun NeoForgeUtil.getOnlinePlayers(): List { - return serverOrNull - ?.playerList - ?.players - ?.toList() - .orEmpty() - .filterNotNull() -} - -fun NeoForgeUtil.getOnlinePlayer(uuid: UUID): ServerPlayer? { - return serverOrNull?.playerList?.getPlayer(uuid) -} - -fun NeoForgeUtil.getOnlinePlayer(name: String): ServerPlayer? { - return serverOrNull?.playerList?.getPlayerByName(name) -} - -fun NeoForgeUtil.getNextTickTime(): Double { - return serverOrNull?.nextTickTime?.toDouble() ?: 0.0 -} diff --git a/core-neoforge/src/main/kotlin/ru/astrainteractive/astralibs/server/util/PlayerExt.kt b/core-neoforge/src/main/kotlin/ru/astrainteractive/astralibs/server/util/PlayerExt.kt deleted file mode 100644 index 2e199424..00000000 --- a/core-neoforge/src/main/kotlin/ru/astrainteractive/astralibs/server/util/PlayerExt.kt +++ /dev/null @@ -1,16 +0,0 @@ -package ru.astrainteractive.astralibs.server.util - -import com.mojang.authlib.GameProfile -import net.minecraft.server.level.ServerPlayer -import ru.astrainteractive.astralibs.server.player.KPlayer -import ru.astrainteractive.astralibs.server.player.NeoForgeKPlayer -import ru.astrainteractive.astralibs.server.player.NeoForgeOnlineKPlayer -import ru.astrainteractive.astralibs.server.player.OnlineKPlayer - -fun ServerPlayer.asOnlineMinecraftPlayer(): OnlineKPlayer { - return NeoForgeOnlineKPlayer(this) -} - -fun GameProfile.asOfflineMinecraftPlayer(): KPlayer { - return NeoForgeKPlayer(this) -} diff --git a/gradle.properties b/gradle.properties index d4da4091..eb30fbc7 100644 --- a/gradle.properties +++ b/gradle.properties @@ -9,7 +9,7 @@ klibs.java.ktarget=21 # Project klibs.project.name=AstraLibs klibs.project.group=ru.astrainteractive.astralibs -klibs.project.version.string=3.39.1 +klibs.project.version.string=3.40.0 klibs.project.description=Core utilities for spigot development klibs.project.developers=makeevrserg|Makeev Roman|makeevrserg@gmail.com klibs.project.url=https://empireprojekt.ru diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 63cb6e06..fe03d5ac 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -42,7 +42,7 @@ minecraft-kyori = "5.0.1" minecraft-luckperms = "5.5" minecraft-mcprotocollib = "1.21.7-SNAPSHOT" minecraft-mockbukkit = "4.108.0" -minecraft-mojang-version = "1.21.11" +minecraft-mojang-version = "1.20.1" minecraft-neoforged-bus = "8.0.2" minecraft-neoforgegradle = "7.1.20" minecraft-forgegradle = "7.0.25" diff --git a/settings.gradle.kts b/settings.gradle.kts index 2e26b71a..0532c4ca 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -56,7 +56,7 @@ include(":core") include(":core-bukkit") include(":core-neoforge") include(":core-forge") -include(":core-fabric") +include(":core-minecraft") include(":menu-bukkit") include(":command") include(":command-bukkit")