Skip to content

Commit

Permalink
[ci-skip] Chore: Changes
Browse files Browse the repository at this point in the history
  • Loading branch information
byPixelTV committed Oct 4, 2024
1 parent e19b4c9 commit e084fa7
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 34 deletions.
6 changes: 0 additions & 6 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ dependencies {
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.9.0")

compileOnly("com.velocitypowered:velocity-api:3.3.0-SNAPSHOT")
annotationProcessor("com.velocitypowered:velocity-api:3.3.0-SNAPSHOT")

// Jedis and SnakeYAML
implementation("redis.clients:jedis:5.2.0")
Expand Down Expand Up @@ -77,11 +76,6 @@ tasks {
build {
dependsOn(shadowJar)
}

compileKotlin {
compilerOptions {
}
}
}

tasks.withType<JavaCompile> {
Expand Down
30 changes: 11 additions & 19 deletions src/main/kotlin/de/bypixeltv/redivelocity/RediVelocity.kt
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
package de.bypixeltv.redivelocity

import com.velocitypowered.api.event.Subscribe
import com.velocitypowered.api.event.proxy.ProxyInitializeEvent
import com.velocitypowered.api.event.proxy.ProxyShutdownEvent
import com.velocitypowered.api.proxy.ProxyServer
import de.bypixeltv.redivelocity.commands.RediVelocityCommand
import de.bypixeltv.redivelocity.config.ConfigLoader
Expand All @@ -17,6 +14,7 @@ import eu.cloudnetservice.ext.platforminject.api.stereotype.Dependency
import eu.cloudnetservice.ext.platforminject.api.stereotype.PlatformPlugin
import eu.cloudnetservice.wrapper.holder.ServiceInfoHolder
import jakarta.inject.Inject
import jakarta.inject.Named
import jakarta.inject.Provider
import jakarta.inject.Singleton
import net.kyori.adventure.text.minimessage.MiniMessage
Expand All @@ -32,20 +30,20 @@ import net.kyori.adventure.text.minimessage.MiniMessage
)
class RediVelocity @Inject constructor(
private val proxy: ProxyServer,
@Named("plugin") private val pluginInstance: Any,
private val proxyIdGenerator: ProxyIdGenerator,
private val updateManager: UpdateManager,
private val rediVelocityCommandProvider: Provider<RediVelocityCommand>,
private val serviceInfoHolder: ServiceInfoHolder
) : PlatformEntrypoint {

private val miniMessages: MiniMessage = MiniMessage.miniMessage()

init {
CommandAPI.onLoad(CommandAPIVelocityConfig(proxy, this).silentLogs(true).verboseOutput(true))
sendLogs("RediVelocity plugin loaded")
proxy.eventManager.register(this, this) // Register the event listener
}

private val miniMessages = MiniMessage.miniMessage()

private val configLoader: ConfigLoader = ConfigLoader("plugins/redivelocity/config.yml").apply { load() }
private val config = configLoader.config
private var jsonFormat: String = config?.jsonFormat.toString()
Expand All @@ -68,9 +66,7 @@ class RediVelocity @Inject constructor(
this.proxy.consoleCommandSource.sendMessage(miniMessages.deserialize("<grey>[<aqua>RediVelocity</aqua>]</grey> <red>$message</red>"))
}

@Suppress("UNUSED")
@Subscribe
fun onProxyInitialization(event: ProxyInitializeEvent) {
override fun onLoad() {
sendLogs("Proxy initialization started")
// Load config and create RedisController
configLoader.load()
Expand All @@ -79,7 +75,6 @@ class RediVelocity @Inject constructor(

redisController = RedisController(this, config!!)
CommandAPI.onEnable()
event.toString()

// Generate new proxy id
proxyId = if (config.cloudnet.enabled) {
Expand Down Expand Up @@ -109,25 +104,22 @@ class RediVelocity @Inject constructor(
updateManager.checkForUpdate()

// Register listeners
proxy.eventManager.register(this, ServerSwitchListener(this, config))
proxy.eventManager.register(this, PostLoginListener(this, config))
proxy.eventManager.register(this, DisconnectListener(this, config))
proxy.eventManager.register(this, ResourcePackListeners(proxy, config))
proxy.eventManager.register(this.pluginInstance, ServerSwitchListener(this, config))
proxy.eventManager.register(this.pluginInstance, PostLoginListener(this, config))
proxy.eventManager.register(this.pluginInstance, DisconnectListener(this, config))
proxy.eventManager.register(this.pluginInstance, ResourcePackListeners(proxy, config))

if (config.playerCountSync) {
proxy.eventManager.register(this, ProxyPingListener(this))
proxy.eventManager.register(this.pluginInstance, ProxyPingListener(this))
}

// Register commands
rediVelocityCommandProvider.get().register()
sendLogs("Proxy initialization completed")
}

@Suppress("UNUSED")
@Subscribe
fun onProxyShutdown(event: ProxyShutdownEvent) {
override fun onDisable() {
sendLogs("Proxy shutdown started")
event.toString()
redisController.removeFromListByValue("rv-proxies", proxyId)
redisController.deleteHashField("rv-proxy-players", proxyId)
redisController.deleteHash("rv-players-name")
Expand Down
9 changes: 0 additions & 9 deletions src/main/resources/velocity-plugin.json

This file was deleted.

0 comments on commit e084fa7

Please sign in to comment.