A simple "Why ACF" guide page
- Lingua principale
- Java
- Stelle
- 628
- Fork
- 150
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
We need a page on the wiki that takes the selling points of ACF (ie in the README) and breaks it down into simple wordings on the basics of ACF.
Something that is easier for less experienced people to consume and see what ACF provides for them.
Example chat form CodeVision:
```
[12:49 PM] FunkyMoneyMan: whats so good about ACF compared to public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args)
[12:50 PM] Aikar:
ACF is an extremely powerful command framework that takes nearly every concept of boilerplate code commonly found in command handlers, and abstracts them away behind annotations.
ACF redefines how you build your command handlers, allowing things such as Dependency Injection, Validation, Tab Completion, Help Documentation, Syntax Advice, and Stateful Conditions to all be behind Annotations that you place on methods.
Clean up your command handlers and unleash rich command experiences that would be too burdensome to pull off manually.
[12:51 PM] FunkyMoneyMan: idk what Dependency Injection, Validation is
[12:53 PM] Aikar:
@CommandAlias("empire|e")
@Subcommand("roles|role|r")
public class EmpireRoleManagementCommand extends EmpireBaseCommand {
@Subcommand("assign|ass|a")
@CommandCompletion("@empires @empiremembers @empireroles")
@Description("Assigns a player a new role. Does not remove previous roles")
public void onRoleAssign(Player player, @Flags("perm=ADMIN") Empire empire, EmpireMember member, EmpireRole role) {
empire.assignRole(player, member, role);
}
}
This code powers the command /e roles assign EMC PlayerName Officer
[12:53 PM] Aikar: the EMC is fed to Empire argument, and automatically grabs the Empire object that is represented by"EMC" (guild/clan tag)
[12:53 PM] Aikar: Empire == guilds/clans
[12:53 PM] FunkyMoneyMan: im guessing empire is ur plugin
[12:53 PM] Aikar: yes
[12:54 PM] Aikar: EmpireMember then is fed PlayerName, automatically getting their membership object of the Empire specified in empire
[12:54 PM] Aikar: then EmpireRole automatically gets a role object specified by Officer
[12:54 PM] Aikar: say I ttyped an invalid empire name? or didnt pass in any of them
[12:54 PM] Aikar: notice how im not validating anything
[12:54 PM] Aikar: all the validation is handled by ACF and the Context system
[12:55 PM] FunkyMoneyMan: hmm :/
[12:55 PM] Aikar: you never need to write "is this value a number? convert to number or show error" ever again
[12:55 PM] FunkyMoneyMan: im trying to like figure this out
[12:55 PM] Aikar: there is a bit of a learning curve yeah, but its hugely powerful
[12:55 PM] FunkyMoneyMan: hopfully this is a good anology but it's like a spanish 4 student talking to a spanish 1 student in spanish. you can pick up very little but it's still very hard
[12:56 PM] Aikar: i know, im still learning how to phrase things simpler >_>
[12:56 PM] Aikar: you can keep your usage simple to start, using Strings etc
[12:56 PM] Aikar: then work your way up for more advanced stuff
[12:56 PM] FunkyMoneyMan: yea :/
[12:56 PM] Aikar:
@CommandAlias("rareitem|ritem")
@CommandCompletion("@rareitems")
public static void doRareItems(Player player, String rareItems, @Default("1") Integer count) {
[12:57 PM] Aikar: for example thats my command for something like /give
[12:57 PM] Aikar: i type /rareitem itemname 32
[12:57 PM] FunkyMoneyMan: so basically instead of doing if(cmd == "empire" || "e") you just do @CommandAlias("empire|e")
[12:57 PM] Aikar: and itll give me 32 of them
[12:57 PM] Aikar: correct
[12:57 PM] Aikar: it lets you create hundreds of aliases
[12:57 PM] Aikar: allow your command to work in all kinds of formations
[12:57 PM] FunkyMoneyMan: oh thats awesome
[12:58 PM] Aikar: ie /empire roles assign is same as /e r a and /e role ass
[12:58 PM] FunkyMoneyMan: :open_mouth:
[12:58 PM] Aikar: ACF calculates every permutation based on the piped values and it figures out how to map what was typed to execute the correct method
[12:58 PM] FunkyMoneyMan: yea you can't do that with my method easily
[12:59 PM] Aikar: to do this in 'plain' handlers is A LOT of boilerplate
[12:59 PM] Aikar: so much it makes it not worth it
[12:59 PM] FunkyMoneyMan: hmmmmmmmmmmm
```
Guida per i contributori
Apri la guida per i contributori
Valutazione
Questa issue non è ancora stata valutata.