ConfigObjectImpl.java 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317
  1. /*
  2. * Roughly Enough Items by Danielshe.
  3. * Licensed under the MIT License.
  4. */
  5. package me.shedaniel.rei.impl;
  6. import me.shedaniel.rei.api.ConfigObject;
  7. import me.shedaniel.rei.gui.config.*;
  8. import me.zeroeightsix.fiber.exception.FiberException;
  9. import me.zeroeightsix.fiber.tree.ConfigNode;
  10. import me.zeroeightsix.fiber.tree.ConfigValue;
  11. import me.zeroeightsix.fiber.tree.Node;
  12. public class ConfigObjectImpl implements ConfigObject {
  13. public ConfigNode configNode = new ConfigNode();
  14. private Node general = configNode.fork("!general");
  15. private Node appearance = configNode.fork("appearance");
  16. private Node modules = configNode.fork("modules");
  17. private Node technical = configNode.fork("technical");
  18. private ConfigValue<Boolean> cheating = ConfigValue.builder(Boolean.class)
  19. .withParent(general)
  20. .withDefaultValue(false)
  21. .withComment("Declares whether cheating mode is on.")
  22. .withName("cheating")
  23. .build();
  24. private ConfigValue<ItemListOrderingConfig> itemListOrdering = ConfigValue.builder(ItemListOrderingConfig.class)
  25. .withParent(appearance)
  26. .withDefaultValue(ItemListOrderingConfig.REGISTRY_ASCENDING)
  27. .withComment("The ordering of the items on the item panel.")
  28. .withName("itemListOrdering")
  29. .build();
  30. private ConfigValue<Boolean> darkTheme = ConfigValue.builder(Boolean.class)
  31. .withParent(appearance)
  32. .withDefaultValue(false)
  33. .withComment("Declares the appearance of REI windows.")
  34. .withName("darkTheme")
  35. .build();
  36. private ConfigValue<RecipeScreenType> recipeScreenType = ConfigValue.builder(RecipeScreenType.class)
  37. .withParent(appearance)
  38. .withDefaultValue(RecipeScreenType.UNSET)
  39. .withComment("The ordering of the items on the item panel.")
  40. .withName("recipeScreenType")
  41. .build();
  42. private ConfigValue<Boolean> loadDefaultPlugin = ConfigValue.builder(Boolean.class)
  43. .withParent(technical)
  44. .withDefaultValue(true)
  45. .withComment("To disable REI's default plugin.\nDon't change this unless you understand what you are doing")
  46. .withName("loadDefaultPlugin")
  47. .build();
  48. private ConfigValue<SearchFieldLocation> sideSearchField = ConfigValue.builder(SearchFieldLocation.class)
  49. .withParent(appearance)
  50. .withDefaultValue(SearchFieldLocation.CENTER)
  51. .withComment("Declares the position of the search field.")
  52. .withName("searchFieldLocation")
  53. .build();
  54. private ConfigValue<Boolean> mirrorItemPanel = ConfigValue.builder(Boolean.class)
  55. .withParent(appearance)
  56. .withDefaultValue(false)
  57. .withComment("Declares the position of the item list panel.")
  58. .withName("mirrorItemPanel")
  59. .build();
  60. private ConfigValue<Boolean> enableCraftableOnlyButton = ConfigValue.builder(Boolean.class)
  61. .withParent(modules)
  62. .withDefaultValue(true)
  63. .withComment("Declares whether the craftable filter button is enabled.")
  64. .withName("enableCraftableOnlyButton")
  65. .build();
  66. private ConfigValue<String> gamemodeCommand = ConfigValue.builder(String.class)
  67. .withParent(technical)
  68. .withDefaultValue("/gamemode {gamemode}")
  69. .withComment("Declares the command used to change gamemode.")
  70. .withName("gamemodeCommand")
  71. .build();
  72. private ConfigValue<String> giveCommand = ConfigValue.builder(String.class)
  73. .withParent(technical)
  74. .withDefaultValue("/give {player_name} {item_identifier}{nbt} {count}")
  75. .withComment("Declares the command used in servers to cheat items.")
  76. .withName("giveCommand")
  77. .build();
  78. private ConfigValue<String> weatherCommand = ConfigValue.builder(String.class)
  79. .withParent(technical)
  80. .withDefaultValue("/weather {weather}")
  81. .withComment("Declares the command used to change weather.")
  82. .withName("weatherCommand")
  83. .build();
  84. private ConfigValue<Integer> maxRecipePerPage = ConfigValue.builder(Integer.class)
  85. .withParent(appearance)
  86. .withDefaultValue(3)
  87. .withComment("Declares the maximum amount of recipes displayed in a page if possible.")
  88. .withName("maxRecipePerPage")
  89. .constraints()
  90. .minNumerical(2)
  91. .maxNumerical(99)
  92. .finish()
  93. .build();
  94. private ConfigValue<Boolean> showUtilsButtons = ConfigValue.builder(Boolean.class)
  95. .withParent(modules)
  96. .withDefaultValue(false)
  97. .withComment("Declares whether the utils buttons are shown.")
  98. .withName("showUtilsButtons")
  99. .build();
  100. private ConfigValue<Boolean> disableRecipeBook = ConfigValue.builder(Boolean.class)
  101. .withParent(modules)
  102. .withDefaultValue(false)
  103. .withComment("Declares whether REI should remove the recipe book.")
  104. .withName("disableRecipeBook")
  105. .build();
  106. private ConfigValue<Boolean> clickableRecipeArrows = ConfigValue.builder(Boolean.class)
  107. .withParent(appearance)
  108. .withDefaultValue(true)
  109. .withName("clickableRecipeArrows")
  110. .build();
  111. private ConfigValue<ItemCheatingMode> itemCheatingMode = ConfigValue.builder(ItemCheatingMode.class)
  112. .withParent(appearance)
  113. .withDefaultValue(ItemCheatingMode.REI_LIKE)
  114. .withName("itemCheatingMode")
  115. .build();
  116. private ConfigValue<Boolean> lightGrayRecipeBorder = ConfigValue.builder(Boolean.class)
  117. .withParent(appearance)
  118. .withDefaultValue(false)
  119. .withComment("Declares the appearance of recipe's border.")
  120. .withName("lightGrayRecipeBorder")
  121. .build();
  122. private ConfigValue<Boolean> appendModNames = ConfigValue.builder(Boolean.class)
  123. .withParent(appearance)
  124. .withDefaultValue(false)
  125. .withComment("Declares whether REI should append mod names to item stacks.")
  126. .withName("appendModNames")
  127. .build();
  128. private ConfigValue<Boolean> villagerScreenPermanentScrollBar = ConfigValue.builder(Boolean.class)
  129. .withParent(appearance)
  130. .withDefaultValue(false)
  131. .withComment("Declares how the scrollbar in villager screen act.")
  132. .withName("villagerScreenPermanentScrollBar")
  133. .build();
  134. private ConfigValue<Boolean> registerRecipesInAnotherThread = ConfigValue.builder(Boolean.class)
  135. .withParent(technical)
  136. .withDefaultValue(true)
  137. .withName("registerRecipesInAnotherThread")
  138. .build();
  139. private ConfigValue<Boolean> scrollingEntryListWidget = ConfigValue.builder(Boolean.class)
  140. .withParent(appearance)
  141. .withDefaultValue(false)
  142. .withComment("Declares whether if entry list widget is scrolled.")
  143. .withName("scrollingEntryListWidget")
  144. .build();
  145. // private ConfigValue<RelativePoint> choosePageDialogPoint = ConfigValue.builder(RelativePoint.class)
  146. // .withParent(technical)
  147. // .withDefaultValue(new RelativePoint(.5, .5))
  148. // .withName("choosePageDialogPoint")
  149. // .build();
  150. public ConfigObjectImpl() throws FiberException {
  151. }
  152. @Override
  153. public ConfigNode getConfigNode() {
  154. return configNode;
  155. }
  156. @Override
  157. public boolean isCheating() {
  158. return cheating.getValue();
  159. }
  160. @Override
  161. public void setCheating(boolean cheating) {
  162. this.cheating.setValue(cheating);
  163. }
  164. @Override
  165. public ItemListOrdering getItemListOrdering() {
  166. return itemListOrdering.getValue().getOrdering();
  167. }
  168. @Override
  169. public boolean isItemListAscending() {
  170. return itemListOrdering.getValue().isAscending();
  171. }
  172. @Override
  173. public boolean isUsingDarkTheme() {
  174. return darkTheme.getValue().booleanValue();
  175. }
  176. @Override
  177. public boolean isEntryListWidgetScrolled() {
  178. return scrollingEntryListWidget.getValue().booleanValue();
  179. }
  180. @Override
  181. public boolean shouldAppendModNames() {
  182. return appendModNames.getValue().booleanValue();
  183. }
  184. @Override
  185. public RecipeScreenType getRecipeScreenType() {
  186. return recipeScreenType.getValue();
  187. }
  188. @Override
  189. public void setRecipeScreenType(RecipeScreenType recipeScreenType) {
  190. this.recipeScreenType.setValue(recipeScreenType);
  191. }
  192. @Override
  193. public boolean isLoadingDefaultPlugin() {
  194. return loadDefaultPlugin.getValue().booleanValue();
  195. }
  196. @Override
  197. public SearchFieldLocation getSearchFieldLocation() {
  198. return sideSearchField.getValue();
  199. }
  200. @Override
  201. public boolean isLeftHandSidePanel() {
  202. return mirrorItemPanel.getValue().booleanValue();
  203. }
  204. @Override
  205. public boolean isCraftableFilterEnabled() {
  206. return enableCraftableOnlyButton.getValue().booleanValue();
  207. }
  208. @Override
  209. public String getGamemodeCommand() {
  210. return gamemodeCommand.getValue();
  211. }
  212. @Override
  213. public String getGiveCommand() {
  214. return giveCommand.getValue();
  215. }
  216. @Override
  217. public String getWeatherCommand() {
  218. return weatherCommand.getValue();
  219. }
  220. @Override
  221. public int getMaxRecipePerPage() {
  222. return maxRecipePerPage.getValue().intValue();
  223. }
  224. @Override
  225. public boolean doesShowUtilsButtons() {
  226. return showUtilsButtons.getValue().booleanValue();
  227. }
  228. @Override
  229. public boolean doesDisableRecipeBook() {
  230. return disableRecipeBook.getValue().booleanValue();
  231. }
  232. @Override
  233. public boolean areClickableRecipeArrowsEnabled() {
  234. return clickableRecipeArrows.getValue().booleanValue();
  235. }
  236. @Override
  237. public ItemCheatingMode getItemCheatingMode() {
  238. return itemCheatingMode.getValue();
  239. }
  240. @Override
  241. public boolean isUsingLightGrayRecipeBorder() {
  242. return lightGrayRecipeBorder.getValue().booleanValue();
  243. }
  244. @Override
  245. public boolean doesVillagerScreenHavePermanentScrollBar() {
  246. return villagerScreenPermanentScrollBar.getValue().booleanValue();
  247. }
  248. @Override
  249. public boolean doesRegisterRecipesInAnotherThread() {
  250. return registerRecipesInAnotherThread.getValue().booleanValue();
  251. }
  252. @Override
  253. public RelativePoint getChoosePageDialogPoint() {
  254. // return choosePageDialogPoint.getValue();
  255. return new RelativePoint(.5, .5);
  256. }
  257. @Override
  258. public void setChoosePageDialogPoint(RelativePoint choosePageDialogPoint) {
  259. // this.choosePageDialogPoint.setValue(choosePageDialogPoint);
  260. }
  261. }