Skip to content

Instantly share code, notes, and snippets.

@Dinnerbone
Created September 29, 2014 11:21
Show Gist options
  • Star 15 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save Dinnerbone/2a185a41dcddfb9abb67 to your computer and use it in GitHub Desktop.
Save Dinnerbone/2a185a41dcddfb9abb67 to your computer and use it in GitHub Desktop.
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)
)
)
)
);
@bitbrain
Copy link

This is madness!

@BlackBeltPanda
Copy link

Literally madness.

@witchica
Copy link

This is epic! :)

@AEnterprise
Copy link

for the error handeling: can't you have this throw an error but have MC catch it and print it out?

@voidc
Copy link

voidc commented Sep 29, 2014

Why don't you put all command definitions in extra json or XML files which get then parsed?

@flying-sheep
Copy link

I agree: Java is too verbose for DSLs. Why not an XML/JSON/YAML dialect that gets parsed or ran a codegen on?

@jacklin213
Copy link

Wow that looks pretty neat

@maxammann
Copy link

This is a joke right? that looks like the most awful spagetti-code.

@Drehverschluss
Copy link

@p000ison Yap seems like a joke. Cant understand what he want here.

@CelticMinstrel
Copy link

  1. Why would it be a joke? It looks pretty good to me, not at all spaghetti-like.
  2. 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.

@scruff-01
Copy link

Should implement the bukkit server commands like backup etc into it before worrying about a gui

@maxammann
Copy link

@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....

@flarn2006
Copy link

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.

@alfuken
Copy link

alfuken commented Dec 2, 2014

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment