/gist:2a185a41dcddfb9abb67 Secret
dispatcher.registerCommand( | |
literal("scoreboard").then( | |
literal("players").then( | |
literal("reset").then( | |
argument("players", players()).then( | |
optional("objective", objective()) | |
).executes(SOME_COMMAND) | |
) | |
).then( | |
literal("list").then( | |
argument("players", players()) | |
).executes(SOME_COMMAND) | |
) | |
).then( | |
literal("objectives").then( | |
literal("list").executes(SOME_COMMAND) | |
).then( | |
literal("setdisplay").then( | |
argument("slot", enumValues(ScoreboardSlotTypes.class)).then( | |
argument("objective", objective()) | |
).executes(SOME_COMMAND) | |
) | |
) | |
) | |
); |
Literally madness.
This is epic! :)
for the error handeling: can't you have this throw an error but have MC catch it and print it out?
Why don't you put all command definitions in extra json or XML files which get then parsed?
I agree: Java is too verbose for DSLs. Why not an XML/JSON/YAML dialect that gets parsed or ran a codegen on?
Wow that looks pretty neat
This is a joke right? that looks like the most awful spagetti-code.
@p000ison Yap seems like a joke. Cant understand what he want here.
- Why would it be a joke? It looks pretty good to me, not at all spaghetti-like.
- This could potentially be far more powerful than a JSON file, simply because a JSON file can't contain code. Though I imagine parsing a JSON file using this wouldn't be particularly difficult.
Should implement the bukkit server commands like backup etc into it before worrying about a gui
@CelticMinstrel Aaand, you're sure it's still pretty readable when there are maybe 20 options and another 30 arguments? There are already pretty decent libraries out there http://args4j.kohsuke.org/
Just hopin this command system is totally optional you you can use whatever implementation you like....
Why do you have this marked "Secret" if you're posting it on Twitter? Why not let people find it from here too? You could put a comment or something explaining the context.
Oh the horror… Why don't you just use LUA for user-created stuff, like lots of other mature projects does? Instead of this… this… spaghetti.
This is madness!