ConfigEntry.java 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. package me.lortseam.completeconfig.api;
  2. import me.lortseam.completeconfig.data.EnumEntry;
  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. * Applied to declare that a field should be resolved as config entry.
  9. */
  10. @Target(ElementType.FIELD)
  11. @Retention(RetentionPolicy.RUNTIME)
  12. public @interface ConfigEntry {
  13. /**
  14. * Specifies the ID of this entry. If empty, the field name will be used by default.
  15. *
  16. * @return the ID
  17. */
  18. String value() default "";
  19. /**
  20. * Specifies a comment to describe the purpose of this entry. The comment will only be visible in the config
  21. * save file.
  22. *
  23. * <p>If blank, no comment will be applied to the entry.
  24. *
  25. * @return a comment
  26. */
  27. String comment() default "";
  28. /**
  29. * Specifies a custom translation key for this entry. If empty, the default key for this entry will be used.
  30. *
  31. * @return a custom translation key
  32. */
  33. String translationKey() default "";
  34. /**
  35. * Specifies one or more custom translation keys for this entry's tooltip, declared line by line. If empty, the
  36. * default single-line or multi-line keys will be used, depending on which are defined in the language file(s).
  37. *
  38. * @return an array of custom tooltip translation keys
  39. */
  40. String[] tooltipTranslationKeys() default {};
  41. /**
  42. * Specifies whether the field should always get updated, regardless of the number of listeners.
  43. *
  44. * <p>If at least one listener exists in the field's class, by default, the field will not get modified when the
  45. * config is saved. Instead, all listeners will be called. Set this to true to disable that behaviour.
  46. *
  47. * @return true if the field should always get updated, else false
  48. */
  49. boolean forceUpdate() default false;
  50. /**
  51. * Specifies whether the game needs to be restarted after modifying the entry.
  52. *
  53. * @return whether the game needs to be restarted after modifying the entry
  54. */
  55. boolean requiresRestart() default false;
  56. /**
  57. * Applied to an entry of type Boolean.
  58. */
  59. @Target(ElementType.FIELD)
  60. @Retention(RetentionPolicy.RUNTIME)
  61. @interface Boolean {
  62. /**
  63. * A custom translation key for the value {@code true}. If empty, the default key will be used.
  64. *
  65. * @return a custom translation key
  66. */
  67. String trueTranslationKey() default "";
  68. /**
  69. * A custom translation key for the value {@code false}. If empty, the default key will be used.
  70. *
  71. * @return a custom translation key
  72. */
  73. String falseTranslationKey() default "";
  74. }
  75. /**
  76. * Applies bounds to an entry of type Integer.
  77. */
  78. @Target(ElementType.FIELD)
  79. @Retention(RetentionPolicy.RUNTIME)
  80. @interface BoundedInteger {
  81. /**
  82. * The minimum bound.
  83. *
  84. * @return the minimum bound
  85. */
  86. int min() default java.lang.Integer.MIN_VALUE;
  87. /**
  88. * The maximum bound.
  89. *
  90. * @return the maximum bound
  91. */
  92. int max() default java.lang.Integer.MAX_VALUE;
  93. /**
  94. * Specifies whether the entry should be rendered as slider.
  95. *
  96. * @return whether the entry should be rendered as slider
  97. */
  98. boolean slider() default true;
  99. }
  100. /**
  101. * Applies bounds to an entry of type Long.
  102. */
  103. @Target(ElementType.FIELD)
  104. @Retention(RetentionPolicy.RUNTIME)
  105. @interface BoundedLong {
  106. /**
  107. * The minimum bound.
  108. *
  109. * @return the minimum bound
  110. */
  111. long min() default java.lang.Long.MIN_VALUE;
  112. /**
  113. * The maximum bound.
  114. *
  115. * @return the maximum bound
  116. */
  117. long max() default java.lang.Long.MAX_VALUE;
  118. /**
  119. * Specifies whether the entry should be rendered as slider.
  120. *
  121. * @return whether the entry should be rendered as slider
  122. */
  123. boolean slider() default true;
  124. }
  125. /**
  126. * Applies bounds to an entry of type Float.
  127. */
  128. @Target(ElementType.FIELD)
  129. @Retention(RetentionPolicy.RUNTIME)
  130. @interface BoundedFloat {
  131. /**
  132. * The minimum bound.
  133. *
  134. * @return the minimum bound
  135. */
  136. float min() default -java.lang.Float.MAX_VALUE;
  137. /**
  138. * The maximum bound.
  139. *
  140. * @return the maximum bound
  141. */
  142. float max() default java.lang.Float.MAX_VALUE;
  143. }
  144. /**
  145. * Applies bounds to an entry of type Double.
  146. */
  147. @Target(ElementType.FIELD)
  148. @Retention(RetentionPolicy.RUNTIME)
  149. @interface BoundedDouble {
  150. /**
  151. * The minimum bound.
  152. *
  153. * @return the minimum bound
  154. */
  155. double min() default -java.lang.Double.MAX_VALUE;
  156. /**
  157. * The maximum bound.
  158. *
  159. * @return the maximum bound
  160. */
  161. double max() default java.lang.Double.MAX_VALUE;
  162. }
  163. /**
  164. * Applied to an entry of type Enum.
  165. *
  166. * <p>This annotation is optional.
  167. */
  168. @Target(ElementType.FIELD)
  169. @Retention(RetentionPolicy.RUNTIME)
  170. @interface Enum {
  171. /**
  172. * Specifies how the entry should be rendered.
  173. *
  174. * @return the desired display type
  175. */
  176. EnumEntry.DisplayType displayType() default EnumEntry.DisplayType.BUTTON;
  177. }
  178. /**
  179. * Applied to an entry which represents a color.
  180. */
  181. @Target(ElementType.FIELD)
  182. @Retention(RetentionPolicy.RUNTIME)
  183. @interface Color {
  184. /**
  185. * Specifies whether the color has an alpha value.
  186. *
  187. * @return whether the color has an alpha value
  188. */
  189. boolean alphaMode();
  190. }
  191. }