Skip to content

Commit

Permalink
Add ProtocolLib support and fix paper tab completer registration
Browse files Browse the repository at this point in the history
  • Loading branch information
vjh0107 committed Jan 24, 2024
1 parent 817ef8c commit 99e9e50
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 11 deletions.
3 changes: 3 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ val subProjectPlugins = listOf(
)

subprojects {
group = extra["project.group"].toString()
version = extra["project.version"].toString()

subProjectPlugins.forEach {
pluginManager.apply(it.get().pluginId)
}
Expand Down
3 changes: 2 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
kotlin.code.style=official

project.group=kr.summitsystems
project.version=0.0.8-beta3
project.version=0.0.8-beta4
project.name=spring-bukkit
project.url=https://github.com/summit-systems/spring-bukkit
project.url.scm=https://github.com/summit-systems/spring-bukkit.git
Expand All @@ -18,6 +18,7 @@ [email protected]
# Spigot
spigot.version=1.20.2-R0.1-SNAPSHOT
mock.bukkit.version=3.58.0
protocollib.version=5.1.0

# Jakarta EE
jakarta.annotation.version=2.1.1
Expand Down
2 changes: 2 additions & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ dependencyResolutionManagement {
repositories {
mavenCentral()
maven("https://repo.papermc.io/repository/maven-public/")
maven("https://repo.dmulloy2.net/repository/public/")
}

versionCatalogs {
Expand All @@ -39,6 +40,7 @@ dependencyResolutionManagement {
library("spigot", "org.spigotmc:spigot-api:${extra["spigot.version"]}")
library("paper", "io.papermc.paper:paper-api:${extra["spigot.version"]}")
library("mockbukkit", "com.github.seeseemelk:MockBukkit-v1.20:${extra["mock.bukkit.version"]}")
library("protocollib", "com.comphenix.protocol:ProtocolLib:${extra["protocollib.version"]}")

library("kotlin-stdlib", "org.jetbrains.kotlin:kotlin-stdlib-jdk8:${extra["kotlin.version"]}")
library("kotlin-reflect", "org.jetbrains.kotlin:kotlin-reflect:${extra["kotlin.version"]}")
Expand Down
1 change: 1 addition & 0 deletions spring-bukkit-support/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
dependencies {
compileOnly(libs.spigot)
compileOnly(libs.paper)
implementation(libs.protocollib)

api(projects.core)
implementation(projects.command)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package kr.summitsystems.springbukkit.support.paper

import kr.summitsystems.springbukkit.command.CommandTabCompletionProvider
import org.springframework.beans.factory.config.BeanDefinition
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass
import org.springframework.context.annotation.*

@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
@Configuration
class PaperConfiguration {
@ConditionalOnClass(name = ["com.destroystokyo.paper.event.server.AsyncTabCompleteEvent"])
@Bean
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
fun paperTabCompleter(commandTabCompletionProvider: CommandTabCompletionProvider): PaperTabCompleter {
return PaperTabCompleter(commandTabCompletionProvider)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,7 @@ package kr.summitsystems.springbukkit.support.paper
import com.destroystokyo.paper.event.server.AsyncTabCompleteEvent
import kr.summitsystems.springbukkit.command.CommandTabCompletionProvider
import org.bukkit.event.EventHandler
import org.springframework.beans.factory.config.BeanDefinition
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass
import org.springframework.context.annotation.Role
import org.springframework.context.annotation.Scope
import org.springframework.context.annotation.ScopedProxyMode
import org.springframework.stereotype.Component

@ConditionalOnClass(name = ["com.destroystokyo.paper.event.server.AsyncTabCompleteEvent"])
@Scope(proxyMode = ScopedProxyMode.DEFAULT)
@Component
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
class PaperTabCompleter(
private val commandTabCompletionProvider: CommandTabCompletionProvider
) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package kr.summitsystems.springbukkit.support.protocollib

import com.comphenix.protocol.ProtocolLibrary
import com.comphenix.protocol.ProtocolManager
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration

@Configuration
class ProtocolLibConfiguration {
@ConditionalOnClass(name = ["com.comphenix.protocol.ProtocolManager"])
@Bean
fun protocolManager(): ProtocolManager {
return ProtocolLibrary.getProtocolManager()
}
}

0 comments on commit 99e9e50

Please sign in to comment.