Class McbsEditorFileTab
java.lang.Object
com.thecsdev.betterstats.api.mcbs.controller.tab.McbsEditorTab
com.thecsdev.betterstats.api.mcbs.controller.tab.McbsEditorFileTab
This
Class serves as the controller component in the MVC architecture.
Its job is to represent a "tab" in a given McbsEditor, that manages
interactions and operations related to a specific McbsFile instance.-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final McbsEditorFileTab"Special"McbsEditorTabinstance, specifically for interfacing withLocalPlayerStatsProviderdata. -
Constructor Summary
ConstructorsConstructorDescriptionMcbsEditorFileTab(@NotNull McbsFile mcbsFile) McbsEditorFileTab(@NotNull Path path) -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanTo prevent theMcbsEditors from opening duplicate tabs, it is essential to override this method along withMcbsEditorTab.hashCode()to enforce non-fungibility.final @NotNull StatsViewReturns theStatsViewinstance that is currently selected for thisMcbsEditorFileTab.final @NotNull net.minecraft.network.chat.ComponentThis method provides the display name that will be shown in the user interface for this particular tab within anMcbsEditor.getGoals()final @NotNull McbsFileReturns the raw unfilteredMcbsFileinstance this MVC controller controls.final StatsView.FiltersReturns theStatsView.Filtersinstance that is used for thisMcbsEditorFileTab.final @NotNull com.thecsdev.commonmc.api.stats.IStatsProvidergetStats()final inthashCode()To prevent theMcbsEditors from opening duplicate tabs, it is essential to override this method along withMcbsEditorTab.equals(Object)to enforce non-fungibility.final voidfinal voidloadStatsFrom(@NotNull com.thecsdev.commonmc.api.stats.IStatsProvider statsProvider) Loads theMcbsStatsdata from the specifiedIStatsProviderinto thisMcbsEditorFileTab'sMcbsFileinstance.final voidPuts anMcbsGoalintoMcbsFile.getGoals().final voidfinal booleanremoveGoal(@NotNull McbsGoal goal) final booleanremoveGoal(@NotNull net.minecraft.resources.Identifier id) final voidSaves theMcbsFiledata of thisMcbsEditorFileTabto the specified file.final voidsetCurrentView(@NotNull StatsView view) Sets theStatsViewinstance that is currently selected for thisMcbsEditorFileTab.Methods inherited from class McbsEditorTab
addEditCount, getEditCount
-
Field Details
-
LOCALPLAYER
"Special"McbsEditorTabinstance, specifically for interfacing withLocalPlayerStatsProviderdata.
-
-
Constructor Details
-
McbsEditorFileTab
- Throws:
NullPointerException
-
McbsEditorFileTab
- Throws:
NullPointerExceptionIOException
-
-
Method Details
-
hashCode
public final int hashCode()Description copied from class:McbsEditorTabTo prevent theMcbsEditors from opening duplicate tabs, it is essential to override this method along withMcbsEditorTab.equals(Object)to enforce non-fungibility.- Specified by:
hashCodein classMcbsEditorTab- See Also:
-
equals
Description copied from class:McbsEditorTabTo prevent theMcbsEditors from opening duplicate tabs, it is essential to override this method along withMcbsEditorTab.hashCode()to enforce non-fungibility.- Specified by:
equalsin classMcbsEditorTab- See Also:
-
getDisplayName
@NotNull public final @NotNull net.minecraft.network.chat.Component getDisplayName()Description copied from class:McbsEditorTabThis method provides the display name that will be shown in the user interface for this particular tab within anMcbsEditor.- Specified by:
getDisplayNamein classMcbsEditorTab
-
getMcbsFile
Returns the raw unfilteredMcbsFileinstance this MVC controller controls.It is generally recommended not to manually write data in there such that it bypasses this controller. Use this for read-only operations only.
If you really must write, call
McbsEditorTab.addEditCount()afterward. -
getStats
@NotNull public final @NotNull com.thecsdev.commonmc.api.stats.IStatsProvider getStats()Returns anIStatsProviderview of theMcbsStatsinstance thisMcbsEditorFileTabis managing.Important API note:
Intended to be read-only! Attempts to set stat values may and willthrow! -
getGoals
Returns aMapview of theMcbsGoalinstances thisMcbsEditorFileTabis managing.Important API note:
Intended to be read-only! Attempts to modify the map (e.g. adding/removing goals) willthrow! -
getCurrentView
Returns theStatsViewinstance that is currently selected for thisMcbsEditorFileTab. -
setCurrentView
Sets theStatsViewinstance that is currently selected for thisMcbsEditorFileTab.- Parameters:
view- TheStatsViewto be set as current.- Throws:
NullPointerException- If an argument isnull.
-
getStatFilters
Returns theStatsView.Filtersinstance that is used for thisMcbsEditorFileTab. These filters tellStatsViews which stats are to be shown on screen. -
putGoal
Puts anMcbsGoalintoMcbsFile.getGoals().- Parameters:
goal- TheMcbsGoalto add.- Throws:
NullPointerException- If the argument isnull.
-
putGoal
public final void putGoal(@NotNull @NotNull net.minecraft.resources.Identifier id, @NotNull @NotNull McbsGoal goal) throws NullPointerException - Parameters:
id- TheIdentifierkey to associate with the goal.goal- TheMcbsGoalto add.- Throws:
NullPointerException- If an argument isnull.
-
removeGoal
- Parameters:
goal- TheMcbsGoalto remove.- Returns:
trueif the goal was removed, orfalseif theMcbsFiledid not contain the specified goal.- Throws:
NullPointerException- If the argument isnull.
-
removeGoal
public final boolean removeGoal(@NotNull @NotNull net.minecraft.resources.Identifier id) throws NullPointerException - Parameters:
id- TheIdentifierkey of theMcbsGoalto remove.- Returns:
trueif the goal was removed, orfalseif theMcbsFiledid not contain a goal with the specified id.- Throws:
NullPointerException- If the argument isnull.
-
saveAs
public final void saveAs(@NotNull @NotNull Path file) throws NullPointerException, IllegalArgumentException, IOException Saves theMcbsFiledata of thisMcbsEditorFileTabto the specified file.- Parameters:
file- The file to save the data to.- Throws:
NullPointerException- If the argument isnull.IllegalArgumentException- If theFile's extension-name is unsupported.IOException- If an I/O error occurs duringFilewriting.- API Note:
- Supports
.jsonand.nbtFiles only.
-
loadFrom
public final void loadFrom(@NotNull @NotNull Path file) throws NullPointerException, IllegalArgumentException, IOException Loads theMcbsFiledata from the specified file into thisMcbsEditorFileTab'sMcbsFileinstance.This overrides existing
McbsFiledata!- Parameters:
file- The file to load the data from.- Throws:
NullPointerException- If an argument isnull.IllegalArgumentException- If theFile's extension-name is unsupported.IOException- If an I/O error occurs duringFilereading.- API Note:
- Supports
.jsonand.nbtFiles only.
-
loadStatsFrom
public final void loadStatsFrom(@NotNull @NotNull com.thecsdev.commonmc.api.stats.IStatsProvider statsProvider) throws NullPointerException Loads theMcbsStatsdata from the specifiedIStatsProviderinto thisMcbsEditorFileTab'sMcbsFileinstance.Specifically, calls
McbsStats.clearAndAddAll(IStatsProvider).This overrides existing
McbsStatsdata!- Parameters:
statsProvider- TheIStatsProviderto load the data from.- Throws:
NullPointerException- If an argument isnull.
-