Skip to content

Commit 97d489d

Browse files
committed
Remove unnecessary usage of JetBrains annotations
1 parent 01b95ce commit 97d489d

28 files changed

+162
-140
lines changed

src/main/java/net/onelitefeather/bettergopaint/BetterGoPaint.java

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,14 @@
4949

5050
public class BetterGoPaint extends JavaPlugin implements Listener {
5151

52-
public static final @NotNull String PAPER_DOCS = "https://jd.papermc.io/paper/1.20.6/org/bukkit/Material.html#enum-constant-summary";
52+
public static final String PAPER_DOCS = "https://jd.papermc.io/paper/1.20.6/org/bukkit/Material.html#enum-constant-summary";
53+
public static final String USE_PERMISSION = "bettergopaint.use";
54+
public static final String ADMIN_PERMISSION = "bettergopaint.admin";
55+
public static final String RELOAD_PERMISSION = "bettergopaint.command.admin.reload";
56+
public static final String WORLD_BYPASS_PERMISSION = "bettergopaint.world.bypass";
5357

54-
public static final @NotNull String USE_PERMISSION = "bettergopaint.use";
55-
public static final @NotNull String ADMIN_PERMISSION = "bettergopaint.admin";
56-
public static final @NotNull String RELOAD_PERMISSION = "bettergopaint.command.admin.reload";
57-
public static final @NotNull String WORLD_BYPASS_PERMISSION = "bettergopaint.world.bypass";
58-
59-
private final @NotNull PlayerBrushManager brushManager = new PlayerBrushManager();
60-
private final @NotNull Metrics metrics = new Metrics(this, 18734);
58+
private final PlayerBrushManager brushManager = new PlayerBrushManager();
59+
private final Metrics metrics = new Metrics(this, 18734);
6160

6261
@Override
6362
public void onLoad() {
@@ -82,7 +81,7 @@ public void onEnable() {
8281

8382
reloadConfig();
8483

85-
Material brush = Settings.settings().GENERIC.DEFAULT_BRUSH;
84+
Material brush = Settings.settings().generic.DEFAULT_BRUSH;
8685
if (!brush.isItem()) {
8786
getComponentLogger().error("{} is not a valid default brush, it has to be an item", brush.name());
8887
getComponentLogger().error("For more information visit {}", PAPER_DOCS);
@@ -141,8 +140,8 @@ private boolean hasOriginalGoPaint() {
141140
}
142141
return new AnnotationParser<>(commandManager, CommandSender.class);
143142

144-
} catch (Exception e) {
145-
getLogger().log(Level.SEVERE, "Cannot init command manager");
143+
} catch (Exception exception) {
144+
getLogger().log(Level.SEVERE, "Cannot init command manager", exception);
146145
return null;
147146
}
148147
}

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public record ExportedPlayerBrush(
5151
double angleHeightDifference
5252
) implements BrushSettings {
5353

54-
private static final @NotNull Random RANDOM = new SecureRandom();
54+
private static final Random RANDOM = new SecureRandom();
5555

5656
public ExportedPlayerBrush(@NotNull Builder builder) {
5757
this(
@@ -91,19 +91,19 @@ public boolean maskEnabled() {
9191
return RANDOM;
9292
}
9393

94-
public static Builder builder(Brush brush) {
94+
public static Builder builder(@NotNull Brush brush) {
9595
return new Builder(brush);
9696
}
9797

9898
public static final class Builder {
9999

100-
private final @NotNull Brush brush;
100+
private final Brush brush;
101101

102-
private @NotNull List<Material> blocks = Collections.emptyList();
103-
private @NotNull Axis axis = Settings.settings().GENERIC.DEFAULT_AXIS;
104-
private @NotNull SurfaceMode surfaceMode = SurfaceMode.DISABLED;
102+
private List<Material> blocks = Collections.emptyList();
103+
private Axis axis = Settings.settings().generic.DEFAULT_AXIS;
104+
private SurfaceMode surfaceMode = SurfaceMode.DISABLED;
105105

106-
private @Nullable Material mask;
106+
private Material mask;
107107

108108
private int size;
109109
private int chance;

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

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@
5454
*/
5555
public final class PlayerBrush implements BrushSettings {
5656

57-
private final @NotNull PlayerBrushManager brushManager;
58-
private final @NotNull Random random = new SecureRandom();
57+
private final PlayerBrushManager brushManager;
58+
private final Random random = new SecureRandom();
5959

6060
private boolean maskEnabled;
6161
private boolean enabled;
@@ -67,31 +67,31 @@ public final class PlayerBrush implements BrushSettings {
6767
private int falloffStrength;
6868
private int mixingStrength;
6969
private double angleHeightDifference;
70-
private @NotNull Axis axis;
71-
private @NotNull SurfaceMode surfaceMode;
70+
private Axis axis;
71+
private SurfaceMode surfaceMode;
7272

73-
private @NotNull Brush brush;
74-
private @NotNull Material mask;
75-
private final @NotNull List<Material> blocks = new ArrayList<>();
73+
private Brush brush;
74+
private Material mask;
75+
private final List<Material> blocks = new ArrayList<>();
7676

77-
private final @NotNull Inventory gui;
77+
private final Inventory gui;
7878

7979
public PlayerBrush(@NotNull PlayerBrushManager brushManager) {
8080
this.brushManager = brushManager;
8181

82-
surfaceMode = Settings.settings().GENERIC.SURFACE_MODE;
83-
maskEnabled = Settings.settings().GENERIC.MASK_ENABLED;
84-
enabled = Settings.settings().GENERIC.ENABLED_BY_DEFAULT;
85-
chance = Settings.settings().GENERIC.DEFAULT_CHANCE;
86-
thickness = Settings.settings().THICKNESS.DEFAULT_THICKNESS;
87-
fractureDistance = Settings.settings().FRACTURE.DEFAULT_FRACTURE_DISTANCE;
88-
angleDistance = Settings.settings().ANGLE.DEFAULT_ANGLE_DISTANCE;
89-
angleHeightDifference = Settings.settings().ANGLE.DEFAULT_ANGLE_HEIGHT_DIFFERENCE;
90-
falloffStrength = Settings.settings().GENERIC.DEFAULT_FALLOFF_STRENGTH;
91-
mixingStrength = Settings.settings().GENERIC.DEFAULT_MIXING_STRENGTH;
92-
axis = Settings.settings().GENERIC.DEFAULT_AXIS;
93-
size = Settings.settings().GENERIC.DEFAULT_SIZE;
94-
mask = Settings.settings().GENERIC.DEFAULT_MASK;
82+
surfaceMode = Settings.settings().generic.SURFACE_MODE;
83+
maskEnabled = Settings.settings().generic.MASK_ENABLED;
84+
enabled = Settings.settings().generic.ENABLED_BY_DEFAULT;
85+
chance = Settings.settings().generic.DEFAULT_CHANCE;
86+
thickness = Settings.settings().thickness.DEFAULT_THICKNESS;
87+
fractureDistance = Settings.settings().fracture.DEFAULT_FRACTURE_DISTANCE;
88+
angleDistance = Settings.settings().angle.DEFAULT_ANGLE_DISTANCE;
89+
angleHeightDifference = Settings.settings().angle.DEFAULT_ANGLE_HEIGHT_DIFFERENCE;
90+
falloffStrength = Settings.settings().generic.DEFAULT_FALLOFF_STRENGTH;
91+
mixingStrength = Settings.settings().generic.DEFAULT_MIXING_STRENGTH;
92+
axis = Settings.settings().generic.DEFAULT_AXIS;
93+
size = Settings.settings().generic.DEFAULT_SIZE;
94+
mask = Settings.settings().generic.DEFAULT_MASK;
9595
brush = brushManager.cycleForward(null);
9696
blocks.add(Material.STONE);
9797
gui = GUI.create(this);
@@ -170,7 +170,7 @@ public int chance() {
170170
}
171171

172172
@Override
173-
public SurfaceMode surfaceMode() {
173+
public @NotNull SurfaceMode surfaceMode() {
174174
return surfaceMode;
175175
}
176176

@@ -248,10 +248,10 @@ public void cycleBrushBackwards() {
248248
}
249249

250250
public void setSize(int size) {
251-
if (size <= Settings.settings().GENERIC.MAX_SIZE && size > 0) {
251+
if (size <= Settings.settings().generic.MAX_SIZE && size > 0) {
252252
this.size = size;
253-
} else if (size > Settings.settings().GENERIC.MAX_SIZE) {
254-
this.size = Settings.settings().GENERIC.MAX_SIZE;
253+
} else if (size > Settings.settings().generic.MAX_SIZE) {
254+
this.size = Settings.settings().generic.MAX_SIZE;
255255
} else {
256256
this.size = 1;
257257
}
@@ -264,13 +264,13 @@ public Inventory getInventory() {
264264

265265
public void increaseBrushSize(boolean x10) {
266266
if (x10) {
267-
if (size + 10 <= Settings.settings().GENERIC.MAX_SIZE) {
267+
if (size + 10 <= Settings.settings().generic.MAX_SIZE) {
268268
size += 10;
269269
} else {
270-
size = Settings.settings().GENERIC.MAX_SIZE;
270+
size = Settings.settings().generic.MAX_SIZE;
271271
}
272272
} else {
273-
if (size < Settings.settings().GENERIC.MAX_SIZE) {
273+
if (size < Settings.settings().generic.MAX_SIZE) {
274274
size += 1;
275275
}
276276
}
@@ -312,7 +312,7 @@ public void decreaseChance() {
312312
}
313313

314314
public void increaseThickness() {
315-
if (thickness < Settings.settings().THICKNESS.MAX_THICKNESS) {
315+
if (thickness < Settings.settings().thickness.MAX_THICKNESS) {
316316
thickness += 1;
317317
}
318318
updateInventory();
@@ -326,7 +326,7 @@ public void decreaseThickness() {
326326
}
327327

328328
public void increaseAngleDistance() {
329-
if (angleDistance < Settings.settings().ANGLE.MAX_ANGLE_DISTANCE) {
329+
if (angleDistance < Settings.settings().angle.MAX_ANGLE_DISTANCE) {
330330
angleDistance += 1;
331331
}
332332
updateInventory();
@@ -340,7 +340,7 @@ public void decreaseAngleDistance() {
340340
}
341341

342342
public void increaseFractureDistance() {
343-
if (this.fractureDistance < Settings.settings().FRACTURE.MAX_FRACTURE_DISTANCE) {
343+
if (this.fractureDistance < Settings.settings().fracture.MAX_FRACTURE_DISTANCE) {
344344
this.fractureDistance += 1;
345345
}
346346
updateInventory();
@@ -359,8 +359,8 @@ public void increaseAngleHeightDifference(boolean d15) {
359359
} else {
360360
angleHeightDifference += 5.0;
361361
}
362-
if (angleHeightDifference > Settings.settings().ANGLE.MAX_ANGLE_HEIGHT_DIFFERENCE) {
363-
angleHeightDifference = Settings.settings().ANGLE.MAX_ANGLE_HEIGHT_DIFFERENCE;
362+
if (angleHeightDifference > Settings.settings().angle.MAX_ANGLE_HEIGHT_DIFFERENCE) {
363+
angleHeightDifference = Settings.settings().angle.MAX_ANGLE_HEIGHT_DIFFERENCE;
364364
}
365365
updateInventory();
366366
}
@@ -371,8 +371,8 @@ public void decreaseAngleHeightDifference(boolean d15) {
371371
} else {
372372
angleHeightDifference -= 5.0;
373373
}
374-
if (angleHeightDifference < Settings.settings().ANGLE.MIN_ANGLE_HEIGHT_DIFFERENCE) {
375-
angleHeightDifference = Settings.settings().ANGLE.MIN_ANGLE_HEIGHT_DIFFERENCE;
374+
if (angleHeightDifference < Settings.settings().angle.MIN_ANGLE_HEIGHT_DIFFERENCE) {
375+
angleHeightDifference = Settings.settings().angle.MIN_ANGLE_HEIGHT_DIFFERENCE;
376376
}
377377
updateInventory();
378378
}

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

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
*/
1919
package net.onelitefeather.bettergopaint.brush;
2020

21-
import com.google.common.collect.ImmutableList;
2221
import net.onelitefeather.bettergopaint.objects.brush.AngleBrush;
2322
import net.onelitefeather.bettergopaint.objects.brush.Brush;
2423
import net.onelitefeather.bettergopaint.objects.brush.BucketBrush;
@@ -46,20 +45,25 @@
4645
*/
4746
public class PlayerBrushManager {
4847

49-
private final @NotNull HashMap<UUID, PlayerBrush> playerBrushes = new HashMap<>();
50-
private final @NotNull List<Brush> brushes = ImmutableList.of(
51-
new SphereBrush(),
52-
new SprayBrush(),
53-
new SplatterBrush(),
54-
new DiscBrush(),
55-
new BucketBrush(),
56-
new AngleBrush(),
57-
new OverlayBrush(),
58-
new UnderlayBrush(),
59-
new FractureBrush(),
60-
new GradientBrush(),
61-
new PaintBrush()
62-
);
48+
private final HashMap<UUID, PlayerBrush> playerBrushes;
49+
private final List<Brush> brushes;
50+
51+
public PlayerBrushManager() {
52+
this.playerBrushes = new HashMap<>();
53+
this.brushes = List.of(
54+
new SphereBrush(),
55+
new SprayBrush(),
56+
new SplatterBrush(),
57+
new DiscBrush(),
58+
new BucketBrush(),
59+
new AngleBrush(),
60+
new OverlayBrush(),
61+
new UnderlayBrush(),
62+
new FractureBrush(),
63+
new GradientBrush(),
64+
new PaintBrush()
65+
);
66+
}
6367

6468
/**
6569
* Retrieves the brush for the given player.
@@ -151,5 +155,4 @@ public void removeBrush(@NotNull Player player) {
151155
}
152156
return brushes.getLast();
153157
}
154-
155158
}

src/main/java/net/onelitefeather/bettergopaint/command/GoPaintCommand.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public boolean execute(
4949
return false;
5050
}
5151
PlayerBrush pb = plugin.getBrushManager().getBrush(p);
52-
String prefix = Settings.settings().GENERIC.PREFIX;
52+
String prefix = Settings.settings().generic.PREFIX;
5353
if (!p.hasPermission(BetterGoPaint.USE_PERMISSION)) {
5454
p.sendRichMessage(prefix + "<red>You are lacking the permission bettergopaint.use");
5555
return true;

src/main/java/net/onelitefeather/bettergopaint/listeners/ConnectListener.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,18 @@
2323
import org.bukkit.event.EventPriority;
2424
import org.bukkit.event.Listener;
2525
import org.bukkit.event.player.PlayerQuitEvent;
26+
import org.jetbrains.annotations.NotNull;
2627

2728
public class ConnectListener implements Listener {
2829

2930
private final PlayerBrushManager brushManager;
3031

31-
public ConnectListener(PlayerBrushManager brushManager) {
32+
public ConnectListener(@NotNull PlayerBrushManager brushManager) {
3233
this.brushManager = brushManager;
3334
}
3435

3536
@EventHandler(priority = EventPriority.LOWEST)
36-
public void onQuit(PlayerQuitEvent event) {
37+
public void onQuit(@NotNull PlayerQuitEvent event) {
3738
brushManager.removeBrush(event.getPlayer());
3839
}
39-
4040
}

src/main/java/net/onelitefeather/bettergopaint/listeners/InteractListener.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public void onClick(PlayerInteractEvent event) {
6161
return;
6262
}
6363

64-
if (event.getAction().isLeftClick() && item.getType() == Settings.settings().GENERIC.DEFAULT_BRUSH) {
64+
if (event.getAction().isLeftClick() && item.getType() == Settings.settings().generic.DEFAULT_BRUSH) {
6565
PlayerBrush brush = plugin.getBrushManager().getBrush(player);
6666
player.openInventory(brush.getInventory());
6767
event.setCancelled(true);
@@ -85,9 +85,9 @@ public void onClick(PlayerInteractEvent event) {
8585
return;
8686
}
8787

88-
final boolean hasNotWorldBaypassPermission = !player.hasPermission(BetterGoPaint.WORLD_BYPASS_PERMISSION);
88+
final boolean hasNotWorldByePassPermission = !player.hasPermission(BetterGoPaint.WORLD_BYPASS_PERMISSION);
8989

90-
if (hasNotWorldBaypassPermission && Settings.settings().GENERIC.DISABLED_WORLDS
90+
if (hasNotWorldByePassPermission && Settings.settings().generic.DISABLED_WORLDS
9191
.contains(location.getWorld().getName())) {
9292
return;
9393
}
@@ -102,7 +102,7 @@ public void onClick(PlayerInteractEvent event) {
102102

103103
//noinspection removal
104104
brushSettings = brush.map(current -> ExportedPlayerBrush.parse(current, itemMeta)).orElse(null);
105-
} else if (item.getType().equals(Settings.settings().GENERIC.DEFAULT_BRUSH)) {
105+
} else if (item.getType().equals(Settings.settings().generic.DEFAULT_BRUSH)) {
106106
brushSettings = plugin.getBrushManager().getBrush(player);
107107
} else {
108108
return;
@@ -118,7 +118,7 @@ public void onClick(PlayerInteractEvent event) {
118118
);
119119
} else {
120120
player.sendRichMessage(
121-
Settings.settings().GENERIC.PREFIX + "<red>Your brush is disabled, left click to enable the brush."
121+
Settings.settings().generic.PREFIX + "<red>Your brush is disabled, left click to enable the brush."
122122
);
123123
}
124124
}

src/main/java/net/onelitefeather/bettergopaint/listeners/InventoryListener.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public void menuClick(InventoryClickEvent event) {
6969
if (event.getRawSlot() == 10 || event.getRawSlot() == 1 || event.getRawSlot() == 19) {
7070
if (event.getClick().equals(ClickType.LEFT)) {
7171
if (!event.getCursor().getType().isBlock()) {
72-
if (!event.getCursor().getType().equals(Settings.settings().GENERIC.DEFAULT_BRUSH)) {
72+
if (!event.getCursor().getType().equals(Settings.settings().generic.DEFAULT_BRUSH)) {
7373
playerBrush.export(event.getCursor());
7474
}
7575
}

src/main/java/net/onelitefeather/bettergopaint/objects/brush/AngleBrush.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@
3030

3131
public class AngleBrush extends Brush {
3232

33-
private static final @NotNull String DESCRIPTION = "Only works on cliffs";
34-
private static final @NotNull String HEAD = "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNmRlNDQ4ZjBkYmU3NmJiOGE4MzJjOGYzYjJhMDNkMzViZDRlMjc4NWZhNWU4Mjk4YzI2MTU1MDNmNDdmZmEyIn19fQ==";
35-
private static final @NotNull String NAME = "Angle Brush";
33+
private static final String NAME = "Angle Brush";
34+
private static final String DESCRIPTION = "Only works on cliffs";
35+
private static final String HEAD = "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNmRlNDQ4ZjBkYmU3NmJiOGE4MzJjOGYzYjJhMDNkMzViZDRlMjc4NWZhNWU4Mjk4YzI2MTU1MDNmNDdmZmEyIn19fQ==";
3636

3737
public AngleBrush() {
3838
super(NAME, DESCRIPTION, HEAD);

src/main/java/net/onelitefeather/bettergopaint/objects/brush/Brush.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@
3737

3838
public abstract class Brush {
3939

40-
private final @NotNull String name, description, head;
40+
private final String name;
41+
private final String description;
42+
private final String head;
4143

4244
protected Brush(@NotNull String name, @NotNull String description, @NotNull String head) {
4345
this.description = description;
@@ -111,7 +113,7 @@ protected void setBlock(
111113
* @param player The player performing the edit.
112114
* @param edit A Consumer functional interface that defines the actions to be taken within the edit session.
113115
*/
114-
protected void performEdit(Player player, Consumer<EditSession> edit) {
116+
protected void performEdit(@NotNull Player player, @NotNull Consumer<EditSession> edit) {
115117
BukkitPlayer wrapped = BukkitAdapter.adapt(player);
116118
LocalSession localSession = WorldEdit.getInstance().getSessionManager().get(wrapped);
117119
try (EditSession editsession = localSession.createEditSession(wrapped)) {

0 commit comments

Comments
 (0)