Skip to content

Commit f618f08

Browse files
chore: add Javadoc strings to all public methods
1 parent ade3215 commit f618f08

File tree

7 files changed

+58
-38
lines changed

7 files changed

+58
-38
lines changed

src/main/java/net/bridgesplash/sidebar/sidebar/SidebarManager.java

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,27 @@
22

33
import java.util.WeakHashMap;
44
import net.minestom.server.entity.Player;
5+
import org.jetbrains.annotations.Nullable;
56

67
/**
78
* Manages the sidebar instances.
89
*/
9-
public class SidebarManager {
10-
10+
public final class SidebarManager {
1111

1212
private final WeakHashMap<Player, CustomSidebar> sidebars = new WeakHashMap<>();
1313

14+
/**
15+
* Constructs a new SidebarManager.
16+
*/
17+
public SidebarManager() {
18+
}
19+
20+
/**
21+
* Adds a sidebar for the given player.
22+
*
23+
* @param player Player to add
24+
* @param sidebar Sidebar to register player with
25+
*/
1426
public void addSidebar(Player player, CustomSidebar sidebar) {
1527
sidebars.put(player, sidebar);
1628
sidebar.addViewer(player);
@@ -20,7 +32,6 @@ public void addSidebar(Player player, CustomSidebar sidebar) {
2032
* Removes the sidebar for the given player.
2133
*
2234
* @param player the player to remove the sidebar for.
23-
*
2435
*/
2536
public void removeSidebar(Player player) {
2637
CustomSidebar sidebar = sidebars.remove(player);
@@ -29,6 +40,13 @@ public void removeSidebar(Player player) {
2940
}
3041
}
3142

43+
/**
44+
* Gets the sidebar for the given player.
45+
*
46+
* @param player player to get sidebar for
47+
* @return CustomSidebar sidebar if it exists, null otherwise
48+
*/
49+
@Nullable
3250
public CustomSidebar getSidebar(Player player) {
3351
return sidebars.get(player);
3452
}

src/main/java/net/bridgesplash/sidebar/state/Hooks.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@
66
* Utility class providing hook-like functions for managing
77
* side effects in response to state changes.
88
*/
9-
public class Hooks {
9+
public final class Hooks {
10+
11+
private Hooks() {
12+
throw new IllegalStateException("Utility class");
13+
}
1014

1115
/**
1216
* Runs the given effect whenever any of the specified dependencies change.

src/main/java/net/bridgesplash/sidebar/state/Memos.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77
*/
88
public final class Memos {
99

10+
private Memos() {
11+
throw new IllegalStateException("Utility class");
12+
}
13+
1014
/**
1115
* Returns a memoized {@link State} whose value is recomputed whenever any dependency changes.
1216
*

src/main/java/net/bridgesplash/sidebar/state/State.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@ public void set(T newValue) {
5252
}
5353
}
5454

55+
/**
56+
* Utility method to update the current value, given the previous value.
57+
*
58+
* @param update Function that takes the previous value and returns the new value
59+
*/
5560
public void setPrev(Function<T, T> update) {
5661
set(update.apply(get()));
5762
}

src/main/java/net/bridgesplash/sidebar/state/StateManager.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import java.util.concurrent.ConcurrentHashMap;
44
import net.bridgesplash.sidebar.sidebar.CustomSidebar;
5+
import org.jetbrains.annotations.Nullable;
56

67
/**
78
* Manages the state instances.
@@ -12,14 +13,32 @@ public final class StateManager {
1213
private final ConcurrentHashMap<String, State<?>> states = new ConcurrentHashMap<>();
1314
private final CustomSidebar sidebar;
1415

16+
/**
17+
* Constructs a new StateManager for the given sidebar.
18+
*
19+
* @param sidebar A sidebar to connect the state to
20+
*/
1521
public StateManager(CustomSidebar sidebar) {
1622
this.sidebar = sidebar;
1723
}
1824

25+
/**
26+
* Gets the state for the given key.
27+
*
28+
* @param key The unique key for the state
29+
* @return The state if it exists, null otherwise
30+
*/
31+
@Nullable
1932
public State<?> getState(String key) {
2033
return states.get(key);
2134
}
2235

36+
/**
37+
* Adds a state to the manager.
38+
*
39+
* @param key The unique key for the state
40+
* @param state State of any type
41+
*/
2342
public void putState(String key, State<?> state) {
2443
states.put(key, state);
2544
}

src/main/java/net/bridgesplash/sidebar/state/types/CustomType.java

Lines changed: 0 additions & 34 deletions
This file was deleted.

src/main/java/net/bridgesplash/sidebar/utils/AdventureUtils.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
99
*/
1010
public final class AdventureUtils {
1111

12+
private AdventureUtils() {
13+
throw new IllegalStateException("Utility class");
14+
}
15+
1216
/**
1317
* Converts an object to a {@link Component} for rendering.
1418
* Supports String, primitives, Component, ComponentLike, and falls back to toString().

0 commit comments

Comments
 (0)