Comments (6)
I think this'd be super cool -- I'd had some similar thoughts, but they'd involved doing codegen to write out the builder logic to register commands rather than depending on some intermediate format.
The struggle I ran into was how to handle extracting parameters from custom argument types -- there might be some manual work needed? or a service registry that's AP-specific.
from cloud.
I think this'd be super cool -- I'd had some similar thoughts, but they'd involved doing codegen to write out the builder logic to register commands rather than depending on some intermediate format.
what similar thoughts? also, I wanted to explicitly avoid codegen bc codegen feels kinda icky to me when it could just be a file with the information that gets parsed, instead
The struggle I ran into was how to handle extracting parameters from custom argument types -- there might be some manual work needed? or a service registry that's AP-specific.
personally, for this I was thinking "if the argument cannot be extracted, just serialize it as a string and then it'll get extracted at runtime lol"
from cloud.
and is much more convenient than having to manually list all the classes with commands.
This can already be avoided by using the command containers. Other than being a fun experiment, I am not sure what this unlocks that isn't already possible.
simply serialize a json array of class names to run reflection on at runtime
"simply serialize a json array" is not a thing in Java. Neither cloud-core
nor cloud-annotations
has a dependency on a JSON serializer
but they'd involved doing codegen to write out the builder logic to register commands rather than depending on some intermediate format.
This is something I've been thinking about as well. EngineHub has had success with this way of creating commands, and I'm not at all opposed to the idea of generating command builders.
The struggle I ran into was how to handle extracting parameters from custom argument types -- there might be some manual work needed? or a service registry that's AP-specific.
cloud-core
already allows you to create command components from the parsed type rather than a specific parser, as long as the command builder is "attached" to the command manager. The part that is tricky is the customization of command components using annotations, which should be a less significant problem to deal with. cloud-annotations
uses annotation mappers to map the annotations to parser parameters, which are then passed to the parser registry. The issue that we'd need to solve here is how we'd do these mappings during AP.
from cloud.
and is much more convenient than having to manually list all the classes with commands.
This can already be avoided by using the command containers. Other than being a fun experiment, I am not sure what this unlocks that isn't already possible.
yeah I didn't realize the command containers already existed. though, from what I am aware, the command containers still need to do runtime reflection to get methods, method parameter types, etc.
it would be cool if this could be moved to compile-time
also, one part of this would be supporting the command containers in kotlin's KSP.
simply serialize a json array of class names to run reflection on at runtime
"simply serialize a json array" is not a thing in Java. Neither
cloud-core
norcloud-annotations
has a dependency on a JSON serializer
yeah, it'd be a separate module. I said json bc it's a common format, but it could always just be smth custom
but they'd involved doing codegen to write out the builder logic to register commands rather than depending on some intermediate format.
This is something I've been thinking about as well. EngineHub has had success with this way of creating commands, and I'm not at all opposed to the idea of generating command builders.
doing codegen could always be viable as well. I just would prefer to avoid codegen if possible though lol
The struggle I ran into was how to handle extracting parameters from custom argument types -- there might be some manual work needed? or a service registry that's AP-specific.
cloud-core
already allows you to create command components from the parsed type rather than a specific parser, as long as the command builder is "attached" to the command manager. The part that is tricky is the customization of command components using annotations, which should be a less significant problem to deal with.cloud-annotations
uses annotation mappers to map the annotations to parser parameters, which are then passed to the parser registry. The issue that we'd need to solve here is how we'd do these mappings during AP.
maybe there'd be some way to run the compiled annotation mappers at compile time? idk.
from cloud.
Honestly JavaPoet makes codegen super fun and easy, and it's kinda the standard for Java APs these days
from cloud.
Honestly JavaPoet makes codegen super fun and easy, and it's kinda the standard for Java APs these days
yeah, I just feel that a custom serialized format would be "easier"
because, there's not really any need to codegen what can be put in a file to be read at runtime, as no client code will ever be interacting directly with this. it'd just be something like invoking AnnotationProcessorCommandLoader.load()
or smth, idk
then, it'd either load the fileformat and parse it then loop over it, or load a fileformat with a list of class names and then run a function on those classes.
effectively the same thing.
from cloud.
Related Issues (20)
- CloudBrigadierManager brigadierSourceMapper maybe is null HOT 2
- Please fix the documentation for minecraft users HOT 3
- Support senderType in CommandBeans
- Allow registration method chaining with ParameterInjectorRegistry
- Add `handler` overloads for future-producing command execution handlers
- Annotated default-returning methods HOT 2
- Allow customizing the appearance of enums HOT 1
- Number suggestions don't suggest anything until input is provided with positive minimum values
- Optional arguments doesn't work on v2 HOT 1
- Issue with String Suggestions in CommandComponent.Builder#suggestionProvider HOT 2
- Add specific overloads for CloudKey<Void> HOT 1
- ArgumentPair should support TypeToken HOT 1
- Missing method generic type in kotlin extensions.
- Support suspending parsers.
- Suspending functions with relocated cloud. HOT 2
- Support kotlin default arguments for non coroutines methods HOT 1
- ClassCastException when using dynamic default value and sender type
- Exception handler is not properly handling ParserExceptions HOT 1
- Paper 1.20.6 Support HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cloud.