Skip to content

Commit

Permalink
style(velocity): opt-in to experimental apis, use direct access, prop…
Browse files Browse the repository at this point in the history
…erly typecast
  • Loading branch information
bigspeedfpv committed Sep 24, 2024
1 parent 6bf81f8 commit 98714e8
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import com.velocitypowered.api.event.EventHandler
import com.velocitypowered.api.event.EventTask
import com.velocitypowered.api.plugin.PluginContainer
import kotlinx.coroutines.CoroutineStart
import kotlinx.coroutines.ExperimentalCoroutinesApi
import java.lang.reflect.Method
import kotlin.coroutines.Continuation

Expand All @@ -26,6 +27,7 @@ class EventServiceImpl(
registerInternally(listener, onlyRegisterSuspend)
}

@OptIn(ExperimentalCoroutinesApi::class)
private fun registerInternally(listener: Any, onlyRegisterSuspend: Boolean) {
val eventManager = suspendingPluginContainer.server.eventManager

Expand Down Expand Up @@ -120,15 +122,15 @@ class EventServiceImpl(
if (errors != null) {
suspendingPluginContainer.logger.info(
"Invalid listener method {} in {}: {}",
method.getName(),
method.getDeclaringClass().getName(),
method.name,
method.declaringClass.getName(),
errors
)
continue
}

val untargetedHandler = loadingCacheClassGetMethod.invoke(unTargetedMethodHandlers, method)
val handler = buildHandlerMethod.invoke(untargetedHandler, listener) as EventHandler<Any>
val handler = buildHandlerMethod.invoke(untargetedHandler, listener) as EventHandler<*>
val handlerRegistration =
handlerRegistrationClassConstructor.newInstance(
pluginContainer,
Expand Down

0 comments on commit 98714e8

Please sign in to comment.