4141import java .util .UUID ;
4242import java .util .stream .Collectors ;
4343
44+ /**
45+ * The PlayerBrushManager class manages the brush selection for each player.
46+ */
4447public class PlayerBrushManager {
4548
4649 private final @ NotNull HashMap <UUID , PlayerBrush > playerBrushes = new HashMap <>();
@@ -58,12 +61,23 @@ public class PlayerBrushManager {
5861 new PaintBrush ()
5962 );
6063
61- public PlayerBrush getBrush (@ NotNull Player player ) {
64+ /**
65+ * Retrieves the brush for the given player.
66+ *
67+ * @param player The player for which to retrieve the brush.
68+ * @return The brush for the specified player.
69+ */
6270 public @ NotNull PlayerBrush getBrush (@ NotNull Player player ) {
6371 return playerBrushes .computeIfAbsent (player .getUniqueId (), ignored -> new PlayerBrush (this ));
6472 }
6573
66- public String getBrushLore (@ NotNull Brush brush ) {
74+ /**
75+ * Retrieves the lore for a specific brush. Each brush name is preceded by a color code
76+ * indicating whether it is the currently selected brush or not.
77+ *
78+ * @param brush The brush for which to retrieve the lore.
79+ * @return The lore for the specified brush.
80+ */
6781 public @ NotNull String getBrushLore (@ NotNull Brush brush ) {
6882 return brushes .stream ().map (current -> {
6983 if (current .equals (brush )) {
@@ -74,21 +88,42 @@ public String getBrushLore(@NotNull Brush brush) {
7488 }).collect (Collectors .joining ());
7589 }
7690
91+ /**
92+ * Retrieves the brush handler for the given name.
93+ *
94+ * @param name The name of the brush to look for.
95+ * @return An optional containing the brush handler, or empty if not found.
96+ */
7797 public @ NotNull Optional <Brush > getBrushHandler (String name ) {
7898 return brushes .stream ()
7999 .filter (brush -> brush .getName ().contains (name ))
80100 .findAny ();
81101 }
82102
103+ /**
104+ * Retrieves the list of available brushes.
105+ *
106+ * @return The list of available brushes.
107+ */
83108 public @ NotNull List <Brush > getBrushes () {
84109 return brushes ;
85110 }
86111
112+ /**
113+ * Removes the player from the {@link #playerBrushes} map.
114+ *
115+ * @param player The player who should be removed.
116+ */
87117 public void removeBrush (@ NotNull Player player ) {
88118 playerBrushes .remove (player .getUniqueId ());
89119 }
90120
91- public Brush cycleForward (@ Nullable Brush brush ) {
121+ /**
122+ * Retrieves the next brush in the list of available brushes.
123+ *
124+ * @param brush The current brush, if null returns the first brush in the list.
125+ * @return The next brush in the list, or the first brush if the current brush is null.
126+ */
92127 public @ NotNull Brush cycleForward (@ Nullable Brush brush ) {
93128 if (brush == null ) {
94129 return brushes .getFirst ();
@@ -100,7 +135,12 @@ public Brush cycleForward(@Nullable Brush brush) {
100135 return brushes .getFirst ();
101136 }
102137
103- public Brush cycleBack (@ Nullable Brush brush ) {
138+ /**
139+ * Retrieves the previous brush in the list of available brushes.
140+ *
141+ * @param brush The current brush.
142+ * @return The previous brush in the list, or the first brush if the current brush is null.
143+ */
104144 public @ NotNull Brush cycleBack (@ Nullable Brush brush ) {
105145 if (brush == null ) {
106146 return brushes .getFirst ();
0 commit comments