Skip to content

Commit db9c2d2

Browse files
committed
refactor: Replace JetBrains annotations with JSpecify annotations for nullability
1 parent 0de0e75 commit db9c2d2

File tree

33 files changed

+107
-114
lines changed

33 files changed

+107
-114
lines changed

buildSrc/src/main/kotlin/Versions.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ object Versions {
77
const val MULTIFICATION = "1.2.4"
88

99
const val JETBRAINS_ANNOTATIONS = "26.0.2-1"
10+
const val JSPECIFY = "1.0.0"
1011
const val PLACEHOLDER_API = "2.11.7"
1112
const val DYNMAP_API = "3.7-beta-6"
1213
const val LOMBOK = "1.18.42"

eternalcore-api/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ plugins {
77
dependencies {
88
compileOnly("org.spigotmc:spigot-api:${Versions.SPIGOT_API}")
99
api("org.jetbrains:annotations:${Versions.JETBRAINS_ANNOTATIONS}")
10+
api("org.jspecify:jspecify:${Versions.JSPECIFY}")
1011
}

eternalcore-api/src/main/java/com/eternalcode/core/feature/adminchat/AdminChatService.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
import java.util.Collection;
44
import java.util.UUID;
55
import org.bukkit.command.CommandSender;
6-
import org.jetbrains.annotations.NotNull;
76
import org.jetbrains.annotations.Unmodifiable;
7+
import org.jspecify.annotations.NonNull;
88

99
/**
1010
* Service responsible for managing admin chat functionality.
@@ -20,15 +20,15 @@ public interface AdminChatService {
2020
* @param playerUuid the UUID of the player to toggle admin chat for
2121
* @return {@code true} if persistent chat was enabled, {@code false} if it was disabled
2222
*/
23-
boolean toggleChat(@NotNull UUID playerUuid);
23+
boolean toggleChat(@NonNull UUID playerUuid);
2424

2525
/**
2626
* Checks if the persistent admin chat mode is enabled for the specified player.
2727
*
2828
* @param playerUuid the UUID of the player to check
2929
* @return {@code true} if persistent chat is enabled, {@code false} otherwise
3030
*/
31-
boolean hasEnabledChat(@NotNull UUID playerUuid);
31+
boolean hasEnabledChat(@NonNull UUID playerUuid);
3232

3333
/**
3434
* Retrieves all players who currently have persistent admin chat enabled.
@@ -39,7 +39,7 @@ public interface AdminChatService {
3939
*
4040
* @return an unmodifiable collection of player UUIDs with enabled admin chat
4141
*/
42-
@NotNull
42+
@NonNull
4343
@Unmodifiable
4444
Collection<UUID> getPlayersWithEnabledChat();
4545

@@ -52,27 +52,27 @@ public interface AdminChatService {
5252
* @param message the message content to send
5353
* @param sender the command sender who is sending the message
5454
*/
55-
void sendAdminChatMessage(@NotNull String message, @NotNull CommandSender sender);
55+
void sendAdminChatMessage(@NonNull String message, @NonNull CommandSender sender);
5656

5757
/**
5858
* Enables persistent admin chat for the specified player.
5959
*
6060
* @param playerUuid the UUID of the player
6161
*/
62-
void enableChat(@NotNull UUID playerUuid);
62+
void enableChat(@NonNull UUID playerUuid);
6363

6464
/**
6565
* Disables persistent admin chat for the specified player.
6666
*
6767
* @param playerUuid the UUID of the player
6868
*/
69-
void disableChat(@NotNull UUID playerUuid);
69+
void disableChat(@NonNull UUID playerUuid);
7070

7171
/**
7272
* Checks if the specified command sender has permission to see admin chat messages.
7373
*
7474
* @param sender the command sender to check
7575
* @return {@code true} if the sender can see admin chat messages, {@code false} otherwise
7676
*/
77-
boolean canSeeAdminChat(@NotNull CommandSender sender);
77+
boolean canSeeAdminChat(@NonNull CommandSender sender);
7878
}

eternalcore-api/src/main/java/com/eternalcode/core/feature/adminchat/event/AdminChatEvent.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import org.bukkit.event.Cancellable;
55
import org.bukkit.event.Event;
66
import org.bukkit.event.HandlerList;
7-
import org.jetbrains.annotations.NotNull;
7+
import org.jspecify.annotations.NonNull;
88

99
/**
1010
* Event called when an admin chat message is being sent.
@@ -21,7 +21,7 @@ public class AdminChatEvent extends Event implements Cancellable {
2121
private String content;
2222
private boolean cancelled;
2323

24-
public AdminChatEvent(@NotNull CommandSender sender, @NotNull String content) {
24+
public AdminChatEvent(@NonNull CommandSender sender, @NonNull String content) {
2525
super(false);
2626

2727
if (sender == null) {
@@ -36,22 +36,22 @@ public AdminChatEvent(@NotNull CommandSender sender, @NotNull String content) {
3636
this.cancelled = false;
3737
}
3838

39-
@NotNull
39+
@NonNull
4040
public static HandlerList getHandlerList() {
4141
return HANDLER_LIST;
4242
}
4343

44-
@NotNull
44+
@NonNull
4545
public CommandSender getSender() {
4646
return this.sender;
4747
}
4848

49-
@NotNull
49+
@NonNull
5050
public String getContent() {
5151
return this.content;
5252
}
5353

54-
public void setContent(@NotNull String content) {
54+
public void setContent(@NonNull String content) {
5555
if (content == null) {
5656
throw new IllegalArgumentException("Content cannot be null");
5757
}
@@ -69,7 +69,7 @@ public void setCancelled(boolean cancelled) {
6969
}
7070

7171
@Override
72-
@NotNull
72+
@NonNull
7373
public HandlerList getHandlers() {
7474
return HANDLER_LIST;
7575
}

eternalcore-api/src/main/java/com/eternalcode/core/feature/afk/event/AfkSwitchEvent.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import org.bukkit.event.Cancellable;
55
import org.bukkit.event.Event;
66
import org.bukkit.event.HandlerList;
7+
import org.jspecify.annotations.NonNull;
78

89
/**
910
* Called when a player switches their afk status.
@@ -41,7 +42,7 @@ public void setCancelled(boolean cancel) {
4142
}
4243

4344
@Override
44-
public HandlerList getHandlers() {
45+
public @NonNull HandlerList getHandlers() {
4546
return HANDLER_LIST;
4647
}
4748

eternalcore-api/src/main/java/com/eternalcode/core/feature/catboy/CatboyService.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
package com.eternalcode.core.feature.catboy;
22

3-
import org.bukkit.entity.Cat;
4-
import org.bukkit.entity.Player;
5-
import org.jetbrains.annotations.Unmodifiable;
6-
73
import java.util.Collection;
84
import java.util.Optional;
95
import java.util.UUID;
6+
import org.bukkit.entity.Cat;
7+
import org.bukkit.entity.Player;
8+
import org.jetbrains.annotations.Unmodifiable;
109

1110
/**
1211
* Service for managing catboys.

eternalcore-api/src/main/java/com/eternalcode/core/feature/home/HomeService.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
package com.eternalcode.core.feature.home;
22

33
import java.util.Collection;
4-
import java.util.Map;
54
import java.util.Optional;
65
import java.util.UUID;
76
import org.bukkit.Location;
87
import org.bukkit.entity.Player;
9-
import org.jetbrains.annotations.Nullable;
8+
import org.jspecify.annotations.Nullable;
109

1110
public interface HomeService {
1211

eternalcore-api/src/main/java/com/eternalcode/core/feature/ignore/event/IgnoreAllEvent.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import org.bukkit.event.Cancellable;
55
import org.bukkit.event.Event;
66
import org.bukkit.event.HandlerList;
7-
import org.jetbrains.annotations.NotNull;
7+
import org.jspecify.annotations.NonNull;
88

99
/**
1010
* This event is called when a player wants to ignore all players.
@@ -38,7 +38,7 @@ public void setCancelled(boolean cancel) {
3838
this.cancelled = cancel;
3939
}
4040

41-
@NotNull
41+
@NonNull
4242
@Override
4343
public HandlerList getHandlers() {
4444
return HANDLER_LIST;

eternalcore-api/src/main/java/com/eternalcode/core/feature/ignore/event/IgnoreEvent.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import org.bukkit.event.Cancellable;
55
import org.bukkit.event.Event;
66
import org.bukkit.event.HandlerList;
7-
import org.jetbrains.annotations.NotNull;
7+
import org.jspecify.annotations.NonNull;
88

99
/**
1010
* This event is called when a player wants to ignore another player.
@@ -48,7 +48,7 @@ public void setCancelled(boolean cancel) {
4848
}
4949

5050
@Override
51-
public @NotNull HandlerList getHandlers() {
51+
public @NonNull HandlerList getHandlers() {
5252
return HANDLER_LIST;
5353
}
5454

eternalcore-api/src/main/java/com/eternalcode/core/feature/ignore/event/UnIgnoreAllEvent.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import org.bukkit.event.Cancellable;
55
import org.bukkit.event.Event;
66
import org.bukkit.event.HandlerList;
7-
import org.jetbrains.annotations.NotNull;
7+
import org.jspecify.annotations.NonNull;
88

99
/**
1010
* This event is called when a player ignores all other players.
@@ -38,7 +38,7 @@ public void setCancelled(boolean cancel) {
3838
this.cancelled = cancel;
3939
}
4040

41-
@NotNull
41+
@NonNull
4242
@Override
4343
public HandlerList getHandlers() {
4444
return HANDLER_LIST;

0 commit comments

Comments
 (0)