API Design v2 #1

3 years ago

Avatar of xTrollxDudex
xTrollxDudex, Admin
Offline

I will be breaking from server development and look to improve the API tomorrow. The API is how users will most likely interact with the TridentSDK project, and greatly lacks both the codebase, tools, and promises made early on. I will be aiming to redesign how the user writes plugins and make it easier, cleaner, and more unique. Remeber, TridentSDK is a fresh, new API. Bukkit was very good at designing an API that lasted, but it seems a bit out of date and unorganized. I want to make it different and put in some flair, already beginning with removing the get prefix from getters. Maybe some functional programming here and there to keep up with the development of Java.

 

I'd love to hear feedback on how to improve the API, criticism (I'm over with the evilmidget thing, thanks guys), praise, anything. But I'd much rather have some criticism than praise. Again, thank you for your continued support of TridentSDK.

0

API Design v2 #2

3 years ago

Avatar of xTrollxDudex
xTrollxDudex, Admin
Offline

Alright, kickstarted it off today with a total rewrite of CommandHandler, which is now called CmdRegistrar. Instead of doing all your checks in the method body, you customize when the method is called depending on what executed it, permissions, and aliases. How about a Javadocs for awesomeness: http://tridentsdk.github.io/javadocs/net/tridentsdk/plugin/cmd/CmdRegistrar.html?

 

With one static import, here is your new registration code:

bindAll("eat", "reload").to(CmdExecutor.class)
.withAliases("consume", "munch").permit("perm.eat").forOnly(CONSOLE, BLOCKS).and() .withAliases("reloadAll").permit("perm.reload").forOnly(CONSOLE).complete(); 

 

You can also register the entire class with each method, configurable with or without the @Cmd annotation handle a new command. The method name is the command to be executed, and keyword commands can have a $ to prevent that.

searchAndBind(CommandHandler.class, true);

Will bind all methods with @Cmd to its own command. There are different methods to bind your provided commands to the class too! In fact, you don't even need to configure. Just bind(...).to(...) and your parameters in @Cmd will handle it for you!

Last edit by xTrollxDudex, 3 years ago
0

API Design v2 #3

3 years ago

Avatar of xTrollxDudex
xTrollxDudex, Admin
Offline

Concept for the API: https://gist.github.com/AgentTroll/b3acff5718c0ce1ebad8

I wouldn't say this has the full support of the entire team...

Last edit by xTrollxDudex, 3 years ago
0

API Design v2 #4

3 years ago

Avatar of xTrollxDudex
xTrollxDudex, Admin
Offline

Not pushing today, changes are not ready. I'm keeping it local because the existing CmdRegistrar needs a refactor to work with the registry.

0

API Design v2 #5

3 years ago

Avatar of xTrollxDudex
xTrollxDudex, Admin
Offline

Time to work a little bit on the world generation API. What would everyone like to see in their plugins to generates fancy worlds?

0

API Design v2 #6

3 years ago

Avatar of Luke__
Luke__, Member
Offline

Couple of things I want to point out:

Messy, try to keep it cleaner and simplier. Also ofc it will run fast, it has nothing to do yet, no tick tasks. RAM usage, even worse than spigot, it ended up using 400mb+ ram while spigot only takes up 200mb of ram? Chunk class memory-optimiziation. Analyzed head dump and found this: 

TrindentWorld#ChunkHandler is using up 257MB, while net.minecraft.server.v1_8_R3.World#Chunk uses up only 95mb

Yes I do know that now your main goal is to make everything work. But don't make the same mistake bukkit did, write it good from the start. Or suffer 2 years of rewriting.

0

API Design v2 #7

3 years ago

Avatar of xTrollxDudex
xTrollxDudex, Admin
Offline

I'm not sure what you're comparing here. The ChunkHandler stores all of the chunks and you're making a comparison to NMS Chunk, which is a single chunk.

 

I'm not saying you're wrong, just confused on what you're trying to say here. Can you further elaborate on the "messy" aspect? The ideas were never implemented because the API is a lower priority, again, because we're trying to get everything to work (again, like you said).

 

Thanks for the feedback.

0

API Design v2 #8

3 years ago

Avatar of sothatsit
sothatsit, Member
Offline

Keep it segmented. I hate API's with random methods which you have to search up the javadocs to find out what they do. For example, your visit(BindView) method. 

 

Also, i like the use of repeated functions on one line, but keep different objects seperate. I find the and() really messy. I would much prefer something like:

CmdRegistrar.bind("eat").to(CmdExecutor.class)
   .aliases("consume", "munch")
   .permit("perm.eat")
   .forOnly(CommandTarget.CONSOLE, CommandTarget.BLOCKS).complete();
CmdRegistrar.bind("reload").to(CmdExecutor.class)
   .aliases("reloadAll")
   .permit("perm.reload")
   .forOnly(CONSOLE).complete(); 

 

Also, if you are removing the get (i prefer using get, but without it doesn't really bother me), then also remove the other verbs before your other methods to keep it consistent. Like "setName(String)" -> "name(String)" and "withAliases()" -> "aliases()".

 

Those are my opinions.

Last edit by sothatsit, 3 years ago
0

API Design v2 #9

3 years ago

Avatar of sidboy55555
sidboy55555, Member
Offline

Ok, I don't know anyting about scripting etc. But it look likes xtrollxdudex is coding everyting and others are complaining, I mean its a git project jou guys can script on it too.

0

API Design v2 #10

3 years ago

Avatar of xTrollxDudex
xTrollxDudex, Admin
Offline

Hi sidboy55555, I like your enthusiasm, but there's a difference between complaining and constructive criticism, fortunatelysmiley

 

For example, in OP, I mentioned:

I'd love to hear feedback on how to improve the API, criticism [...]

It means it's ok to 'complain', as long as it helps improve what I'm working on.

 

As another example, here is what complaining looks like:

OMG WHEN R U RELEASINGG>>>>??????!!!!!!
why are u so slow
fix everything in server plzzzss

 

Sothatsit is giving constructive criticism, which usually looks like this:

I like [...] about [...], but I think it could be improved, such as by doing [...]
In my opinion, [...] isn't very well designed, it should be changed by [...]
Honestly, [...] was a poor idea because [...]. Possibly replace it with [...] or remove it, and offer [...]

 

Finally, I don't mind being the lone man still thinking about it. People have lives too :p 

0
Copyright © 2018 TridentSDK
Made by Vilsol