Skip to content

Commit

Permalink
feat: disallow changing wiki URL after it has been set
Browse files Browse the repository at this point in the history
  • Loading branch information
ybw0014 committed Oct 16, 2024
1 parent 357ea18 commit e11f430
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,12 @@ default boolean hasDependency(@Nonnull String dependency) {
}

/**
* This method returns the wiki URL for all the items this {@link SlimefunAddon}.
* The "%item%" placeholder will be replaced with the SlimefunItem's ID.
* This method returns the wiki URL template for all the items this {@link SlimefunAddon}.
* The "%item%" placeholder will be replaced with the SlimefunItem's ID by default.
*
* @return The wiki URL for this {@link SlimefunAddon}.
* @return The wiki URL template for this {@link SlimefunAddon}.
*/
default @Nonnull String getWikiURL() {
default @Nonnull String getWikiUrlTemplate() {
return "";
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -907,7 +907,7 @@ public final void addOfficialWikipage(@Nonnull String page) {
public final void addWikiPage(@Nonnull String page) {
Preconditions.checkArgument(page != null, "Wiki page cannot be null.");
Preconditions.checkState(getState() != ItemState.UNREGISTERED, "Wiki page can only be added after item has been registered.");
addCustomWikiPage(getAddon().getWikiURL().replace("%item%", page));
addCustomWikiPage(getAddon().getWikiUrlTemplate().replace("%item%", page));
}

/**
Expand All @@ -918,6 +918,7 @@ public final void addWikiPage(@Nonnull String page) {
*/
public final void addCustomWikiPage(@Nonnull String url) {
Preconditions.checkArgument(url != null, "Wiki page cannot be null.");
Preconditions.checkState(wikiURL.isEmpty(), "Wiki page cannot be modified after it has been set.");
wikiURL = Optional.of(url);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ public String getBugTrackerURL() {
}

@Override
public @Nonnull String getWikiURL() {
public @Nonnull String getWikiUrlTemplate() {
return "https://github.com/Slimefun/Slimefun4/wiki/%item%";
}

Expand Down

0 comments on commit e11f430

Please sign in to comment.