Skip to content

Commit 0cb1d8f

Browse files
author
david
committed
added more docs
1 parent 6599fd9 commit 0cb1d8f

File tree

5 files changed

+69
-8
lines changed

5 files changed

+69
-8
lines changed

src/main/java/net/onelitefeather/bettergopaint/brush/BrushSettings.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,17 @@
2222
import net.onelitefeather.bettergopaint.objects.other.SurfaceMode;
2323
import org.bukkit.Axis;
2424
import org.bukkit.Material;
25-
import org.bukkit.inventory.meta.ItemMeta;
2625
import org.jetbrains.annotations.ApiStatus;
2726
import org.jetbrains.annotations.NotNull;
2827

29-
import java.util.Arrays;
3028
import java.util.List;
31-
import java.util.Objects;
32-
import java.util.Optional;
3329
import java.util.Random;
3430

31+
/**
32+
* The BrushSettings interface defines the configuration settings for a brush. It provides methods to retrieve information
33+
* about the brush's axis, brush type, list of blocks, mask material, enabled status, surface mode, angle-height
34+
* difference, angle distance, chance, falloff strength, fracture distance, mixing strength, size and thickness.
35+
*/
3536
public interface BrushSettings {
3637

3738
/**

src/main/java/net/onelitefeather/bettergopaint/brush/PlayerBrush.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@
4949
import java.util.Random;
5050
import java.util.stream.Collectors;
5151

52+
/**
53+
* The PlayerBrush class represents the brush settings of a player.
54+
*/
5255
public final class PlayerBrush implements BrushSettings {
5356

5457
private final @NotNull PlayerBrushManager brushManager;

src/main/java/net/onelitefeather/bettergopaint/brush/PlayerBrushManager.java

Lines changed: 44 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@
4141
import java.util.UUID;
4242
import java.util.stream.Collectors;
4343

44+
/**
45+
* The PlayerBrushManager class manages the brush selection for each player.
46+
*/
4447
public 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();

src/main/java/net/onelitefeather/bettergopaint/utils/ConnectedBlocks.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,14 @@ public class ConnectedBlocks {
4141
BlockFace.DOWN,
4242
};
4343

44+
/**
45+
* Returns a stream of connected blocks starting from a given location, based on a list of blocks.
46+
* Only blocks of the same type as the start block are considered.
47+
*
48+
* @param loc the starting location
49+
* @param blocks the list of blocks to check for connectivity
50+
* @return a stream of connected blocks
51+
*/
4452
public static Stream<Block> getConnectedBlocks(Location loc, List<Block> blocks) {
4553
Block startBlock = loc.getBlock();
4654
Set<Block> connected = new HashSet<>();

src/main/java/net/onelitefeather/bettergopaint/utils/Sphere.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,15 @@
2929

3030
public class Sphere {
3131

32+
/**
33+
* Returns a stream of blocks within a specified radius from a given middle point.
34+
*
35+
* @param middlePoint The middle point from which to calculate the radius.
36+
* @param radius The radius value.
37+
* @param axis The axis along which to calculate the radius (optional).
38+
* @param air Whether air blocks should be included.
39+
* @return A stream of blocks within the specified radius.
40+
*/
3241
public static Stream<Block> getBlocksInRadius(Location middlePoint, int radius, @Nullable Axis axis, boolean air) {
3342
List<Block> blocks = new ArrayList<>();
3443
Location loc1 = middlePoint.clone().add(-radius / 2d, -radius / 2d, -radius / 2d).getBlock().getLocation();

0 commit comments

Comments
 (0)