nrubin29

CommandData

May 3rd, 2014
1,121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.77 KB | None | 0 0
  1. package me.pogostick29dev.economy29;
  2.  
  3. import java.lang.annotation.ElementType;
  4. import java.lang.annotation.Retention;
  5. import java.lang.annotation.RetentionPolicy;
  6. import java.lang.annotation.Target;
  7.  
  8. @Retention(RetentionPolicy.RUNTIME)
  9. @Target(ElementType.TYPE)
  10. public @interface CommandData {
  11.  
  12.     String getName();
  13.     String getDescription();
  14.     String getArgs();
  15. }
  16.  
  17. // Annotating a class with @CommandData:
  18. @CommandData(getName="Add", getDescription="Add money to balance.", getArgs="<player> <amount>")
  19.  
  20. // Getting information stored in @CommandData for a given class:
  21. for (EcoCommand c : cmds) {
  22.     CommandData data = c.getClass().getAnnotation(CommandData.class);
  23.     sender.sendMessage("/eco " + data.getName() + " " + data.getArgs() + " - " + data.getDescription());
  24. }
Advertisement
Add Comment
Please, Sign In to add comment