I would suggest creating themes as static elements of a utility class, as per the below example:
packagedev.sefiraat.slimetinker2.implementation;importio.github.sefiraat.sefilib.string.Theme;importnet.md_5.bungee.api.ChatColor;publicfinalclassTinkerThemes {privateTinkerThemes() {thrownewIllegalStateException("Utility class"); }publicstaticfinalTheme MAIN =newTheme(ChatColor.of("#8a0e0e"),"SlimeTinker2");publicstaticfinalTheme RESEARCH =newTheme(ChatColor.of("#a60e03"),"Research");publicstaticfinalTheme CRAFTING =newTheme(ChatColor.of("#dbcea9"),"Crafting Material");publicstaticfinalTheme RECIPE_TYPE =newTheme(ChatColor.of("#ffe89c"),"Recipe Type");publicstaticfinalTheme MACHINE =newTheme(ChatColor.of("#3295a8"),"Machine");publicstaticfinalTheme TOOL =newTheme(ChatColor.of("#3295a8"),"Tool");publicstaticfinalTheme PART =newTheme(ChatColor.of("#dbcea9"),"Part");publicstaticfinalTheme TRAIT =newTheme(ChatColor.of("#3295a8"),"Trait");publicstaticfinalTheme MATERIAL =newTheme(ChatColor.of("#dbcea9"),"Material");publicstaticfinalTheme ENCHANTMENT =newTheme(ChatColor.of("#ffe89c"),"Enchantment");publicstaticfinalTheme UPGRADE =newTheme(ChatColor.of("#ea201a"),"Upgrade");publicstaticfinalTheme ADDON =newTheme(ChatColor.of("#8a0e0e"),"Addon");}
The Theme class comes with some default themes that can be used for common purposes (and used by Theme for item generation and certain strings).
// Yellow theme used to denote a warning of some kindpublicstaticfinalTheme WARNING =newTheme(ChatColor.YELLOW,"Warning");// Red theme used to denote an error, misuse etc.publicstaticfinalTheme ERROR =newTheme(ChatColor.RED,"Error");// A plain white theme used for simple noticespublicstaticfinalTheme NOTICE =newTheme(ChatColor.WHITE,"Notice");// A passive light grey theme used for hints, sub-information and item lorepublicstaticfinalTheme PASSIVE =newTheme(ChatColor.GRAY);// A lime-green theme used to denote success and/or 'good' responsespublicstaticfinalTheme SUCCESS =newTheme(ChatColor.GREEN,"Success");// A bright yellow used for highlighting key word or where to clickpublicstaticfinalTheme CLICK_INFO =newTheme(ChatColor.of("#e4ed32"),"Click here");
ItemStacks
To create an ItemStack with the Theme applied. Simply use the static method Theme#themedItemStack() providing the Material, the Theme to be applied, the Item's name and a List<String> for the lore.
ItemStack itemStack =Theme.themedItemStack(Material.OAK_LOG,Themes.MATERIAL,"Testing Name",List.of("Hello there","This is some lore" ));
The resulting ItemStack will have the name you provided using the Theme's color. The lore lines will follow after a single line gap using a the default Theme#PASSIVE. After all of the lore lines, there will be one last gap followed by the Theme's lore line using Theme#CLICK_INFO
SlimefunItemStack
A SlimefunItemStack is created in almost the same way, requiring an additional argument for the SlimefunItem ID as well as the List<String> being replaced with a String Array/String var-args
SlimefunItemStack slimefunItemStack =Theme.themedSlimefunItemStack("ADDON_ITEM_ID",Material.OAK_LOG,Themes.MATERIAL,"Testing Name",newString[] {"Hello there","This is some lore" });
SlimefunItemStack slimefunItemStack =Theme.themedSlimefunItemStack("ADDON_ITEM_ID",Material.OAK_LOG,Themes.MATERIAL,"Testing Name","Hello there","This is some lore");
Themed Strings
The Theme class overrides .toString() to provide the theme's base color. This means at the most basic level, you can use your theme field directly within a string concatenation or other message formatter
You can use the .apply(Object) method which will directly return a String that is colored to match the theme. The static method Theme#applyThemeToString(Theme, String) does the same as .apply() but in a static context.
Player player =getPlayer();player.sendMessage(Themes.WARNING_THEME.apply("This is a warning message"));player.sendMessage(Theme.applyThemeToString(Themes.WARNING_THEME,"This is a warning mesage"));
You can use the .asTitle(Object, Object) method which will directly return a String that has the first object (as a string) in the themes color followed immedietly by a colon, a space then the second object as a string using the default Theme.PASSIVE. The static method Theme#applyThemeAsTitle(Theme, String, Object) does the same as .asTitle() but in a static context.
Player player =getPlayer();int numberOfItems =getNumberOfItems();String message =Theme.CLICK_INFO.asTitle("Total Items", numberOfItems);player.sendMessage(message);