Class PreferencesSection
- Direct Known Subclasses:
BackupsSection,BedrockSection,BlocklySection,CodeStyleSection,GradleSection,HiddenSection,IDESection,ImageEditorSection,NotificationsSection,UISection
This class defines a section inside the PreferencesDialog. It groups all PreferencesEntry together both visually and innerly (when storing preferences).
For examples on how to create a new PreferencesSection and declare new PreferencesEntry inside the class, see built-in sections net.mcreator.preferences.data.
Java plugins need to initialize their section using ApplicationLoadedEvent.
Example:
public class MyPlugin extends JavaPlugin {
public MySection mySection;
public MyPlugin(Plugin plugin) {
addListener(ApplicationLoadedEvent.class, event -> {
mySection = new MySection("myIdentifier");
});
}
}
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal <T,S extends PreferencesEntry<T>>
SaddEntry(S entry) This method allows adding a newPreferencesEntryto thisPreferencesSection.final <T,S extends PreferencesEntry<T>>
SaddPluginEntry(String pluginPreferencesIdentifier, S entry) This method allows adding a newPreferencesEntryto thePreferencesSection.abstract Stringboolean
-
Constructor Details
-
PreferencesSection
-
-
Method Details
-
addEntry
This method allows adding a new
PreferencesEntryto thisPreferencesSection. Contrary toaddPluginEntry(String, PreferencesEntry), this method does not allow to specify a customidentifier, meaning the system will use the one provided by this section (preferencesIdentifier).For Java plugins: Use this method ONLY when making a custom
PreferencesSection. Do NOT use with a built-in section (seePreferencesData). CustomPreferencesEntrywill be added to thecoreidentifier group, leading to many problems for you and users.- Parameters:
entry- The newPreferencesEntryto add to this section- Returns:
- The provided
PreferencesEntryto register
-
addPluginEntry
public final <T,S extends PreferencesEntry<T>> S addPluginEntry(String pluginPreferencesIdentifier, S entry) This method allows adding a new
PreferencesEntryto thePreferencesSection. This method is designed so Java plugins can add a customPreferencesEntryto an already existingPreferencesSectioncreated by MCreator (seePreferencesData). While this method will work in all types of cases,addPluginEntry(String, PreferencesEntry)can be safely used when using a customPreferencesSection}.Example of a Java plugin:
public class MyPlugin extends JavaPlugin { public final BooleanEntry myEntry = new BooleanEntry("displayMCreator", true); public MyPlugin(Plugin plugin) { addListener(ApplicationLoadedEvent.class, event -> { PreferencesManager.PREFERENCES.ui.addJavaEntry("myIdentifier", myEntry); }); } }- Parameters:
pluginPreferencesIdentifier- A uniqueStringacting like a mod's id for this system. If you use this method with one of the built-in section (seePreferencesData), this parameter can NOT be"core"as the system use it for all built-in entries.entry- The newPreferencesEntryto add to this section- Returns:
- The provided
PreferencesEntryto register
-
isVisible
public boolean isVisible()- Returns:
- True
PreferencesDialogshould display thisPreferencesSection. Usually, this should always be true. This was implemented forHiddenSection.
-
getSectionKey
- Returns:
- The registry name of this specific section. It is used, among other things, for the localization's key of the
PreferencesEntryinside this section.
-