Skip to content

Commit

Permalink
feat: remove for-removal deprecated fields
Browse files Browse the repository at this point in the history
  • Loading branch information
ShindouMihou committed Sep 28, 2023
1 parent 9fef208 commit 9f69cf5
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 130 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import pw.mihou.nexus.core.reflective.NexusReflection
import pw.mihou.nexus.features.command.interceptors.annotations.Name
import pw.mihou.nexus.features.command.interceptors.core.NexusCommandInterceptorCore
import pw.mihou.nexus.features.command.interceptors.facades.NexusAfterware
import pw.mihou.nexus.features.command.interceptors.facades.NexusInterceptorRepository
import pw.mihou.nexus.features.command.interceptors.facades.NexusMiddleware

object NexusCommandInterceptors {
Expand Down Expand Up @@ -49,18 +48,13 @@ object NexusCommandInterceptors {
}

/**
* Adds the provided repository to the registry. Any [NexusInterceptorRepository] will be handled like
* how it is done in the older versions, but any other classes will be loaded via reflection through the
* newer mechanism.
* Adds the provided repository to the registry. In this new mechanism, we load all the [NexusAfterware] and
* [NexusMiddleware] variables in the class into the registry with a name based on their field name or the name
* provided using [Name] annotation.
*
* @param repository the repository to add.
*/
fun add(repository: Any) {
if (repository is NexusInterceptorRepository) {
interceptors.addRepository(repository)
return
}

NexusReflection.accumulate(repository) { field ->
if (field.type != NexusMiddleware::class.java && field.type != NexusAfterware::class.java) return@accumulate
val name =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package pw.mihou.nexus.features.command.interceptors.core

import pw.mihou.nexus.features.command.interceptors.facades.NexusAfterware
import pw.mihou.nexus.features.command.interceptors.facades.NexusCommandInterceptor
import pw.mihou.nexus.features.command.interceptors.facades.NexusInterceptorRepository
import pw.mihou.nexus.features.command.interceptors.facades.NexusMiddleware
import pw.mihou.nexus.Nexus
import pw.mihou.nexus.features.command.core.NexusMiddlewareEventCore
Expand Down Expand Up @@ -35,15 +34,6 @@ internal object NexusCommandInterceptorCore {
interceptors[name] = afterware
}

/**
* Adds one repository of command interceptors to [Nexus].
* @param repository the repository to add.
*/
@JvmStatic
fun addRepository(repository: NexusInterceptorRepository) {
repository.define()
}

@JvmStatic
fun has(name: String) = interceptors.containsKey(name)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,75 +1,3 @@
package pw.mihou.nexus.features.command.interceptors.facades;

import pw.mihou.nexus.Nexus;
import pw.mihou.nexus.core.assignment.NexusUuidAssigner;
import pw.mihou.nexus.features.command.interceptors.core.NexusCommandInterceptorCore;

public interface NexusCommandInterceptor {

/**
* Creates an anonymous middleware where the name of the middleware is generated randomly
* by the framework at runtime.
*
* @param middleware The middleware functionality.
* @return The name of the middleware to generated.
* @see Nexus#getInterceptors
*/
@Deprecated(forRemoval = true)
static String middleware(NexusMiddleware middleware) {
return Nexus.getInterceptors().middleware(middleware);
}

/**
* Creates an anonymous afterware where the name of the middleware is generated randomly
* by the framework at runtime.
*
* @param afterware The afterware functionality.
* @return The name of the afterware to generated.
* @see Nexus#getInterceptors
*/
@Deprecated(forRemoval = true)
static String afterware(NexusAfterware afterware) {
return Nexus.getInterceptors().afterware(afterware);

}

/**
* Adds the middleware into the command interceptor storage.
*
* @param name The name of the middleware to add.
* @param middleware The middleware functionality.
* @return The name of the middleware for quick-use.
* @see Nexus#getInterceptors
*/
@Deprecated(forRemoval = true)
static String addMiddleware(String name, NexusMiddleware middleware) {
return Nexus.getInterceptors().middleware(name, middleware);
}

/**
* Adds the afterware into the command interceptor storage.
*
* @param name The name of the afterware to add.
* @param afterware The afterware functionality.
* @return The name of the afterware for quick-use.
* @see Nexus#getInterceptors
*/
@Deprecated(forRemoval = true)
static String addAfterware(String name, NexusAfterware afterware) {
return Nexus.getInterceptors().afterware(name, afterware);

}

/**
* Adds a repository of command interceptors to the command interceptor
* storage.
*
* @param repository The repository to add.
* @see Nexus#getInterceptors
*/
@Deprecated(forRemoval = true)
static void addRepository(NexusInterceptorRepository repository) {
Nexus.getInterceptors().add(repository);
}

}
public interface NexusCommandInterceptor {}

This file was deleted.

0 comments on commit 9f69cf5

Please sign in to comment.