Skip to content

Commit 5f32afe

Browse files
committed
Add null checks and update `@NotNull for action handler methods
1 parent fb9dfe8 commit 5f32afe

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/main/java/org/mvplugins/multiverse/portals/MVPortal.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import org.bukkit.configuration.ConfigurationSection;
2424
import org.bukkit.entity.Entity;
2525
import org.jetbrains.annotations.ApiStatus;
26+
import org.jetbrains.annotations.NotNull;
2627
import org.jetbrains.annotations.Nullable;
2728
import org.mvplugins.multiverse.core.command.MVCommandManager;
2829
import org.mvplugins.multiverse.core.config.handle.MemoryConfigurationHandle;
@@ -302,7 +303,8 @@ public PortalLocation getPortalLocation() {
302303
}
303304

304305
@ApiStatus.AvailableSince("5.2")
305-
public Try<Void> setActionType(ActionHandlerType<?, ?> actionType) {
306+
public Try<Void> setActionType(@NotNull ActionHandlerType<?, ?> actionType) {
307+
Objects.requireNonNull(actionType, "actionType cannot be null");
306308
return configHandle.set(configNodes.actionType, actionType.getName());
307309
}
308310

@@ -327,24 +329,24 @@ public String getAction() {
327329
}
328330

329331
@ApiStatus.AvailableSince("5.2")
330-
public Try<Void> setActionHandler(ActionHandler<?, ?> action) {
332+
public Try<Void> setActionHandler(@NotNull ActionHandler<?, ?> action) {
331333
Objects.requireNonNull(action, "action cannot be null");
332334
return setActionType(action.getHandlerType())
333335
.flatMap(v -> setAction(action.serialise()));
334336
}
335337

336338
@ApiStatus.AvailableSince("5.2")
337-
public Attempt<? extends ActionHandler<?, ?>, ActionFailureReason> getActionHandler() {
339+
public @NotNull Attempt<? extends ActionHandler<?, ?>, ActionFailureReason> getActionHandler() {
338340
return actionHandlerProvider.parseHandler(getActionType(), getAction());
339341
}
340342

341343
@ApiStatus.AvailableSince("5.2")
342-
public Attempt<? extends ActionHandler<?, ?>, ActionFailureReason> getActionHandler(CommandSender sender) {
344+
public @NotNull Attempt<? extends ActionHandler<?, ?>, ActionFailureReason> getActionHandler(@NotNull CommandSender sender) {
343345
return actionHandlerProvider.parseHandler(sender, getActionType(), getAction());
344346
}
345347

346348
@ApiStatus.AvailableSince("5.2")
347-
public Attempt<Void, ActionFailureReason> runActionFor(Entity entity) {
349+
public @NotNull Attempt<Void, ActionFailureReason> runActionFor(Entity entity) {
348350
return getActionHandler(entity)
349351
.mapAttempt(actionHandler -> actionHandler.runAction(this, entity))
350352
.onSuccess(() -> {

0 commit comments

Comments
 (0)