Skip to content

Commit

Permalink
SpigotCommandSender: Added handle getters
Browse files Browse the repository at this point in the history
  • Loading branch information
xDec0de committed Nov 27, 2024
1 parent 3b4b689 commit 0b74f17
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import net.codersky.mcutils.spigot.SpigotUtils;
import net.kyori.adventure.text.Component;
import org.bukkit.command.CommandSender;
import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
Expand All @@ -30,6 +31,12 @@ public boolean isPlayer() {
return sender instanceof Player;
}

@Nullable
@Override
public Player asPlayerHandle() {
return sender instanceof Player player ? player : null;
}

@Nullable
@Override
public MCPlayer asPlayer() {
Expand All @@ -40,6 +47,12 @@ public MCPlayer asPlayer() {
* Console related
*/

@Nullable
@Override
public ConsoleCommandSender asConsoleHandle() {
return sender instanceof ConsoleCommandSender console ? console : null;
}

@Nullable
@Override
public SpigotConsole asConsole() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
public interface MCCommandSender extends MessageReceiver {

/*
* Player related
- Player related
*/

boolean isPlayer();
Expand All @@ -25,7 +25,7 @@ default Object asPlayerHandle() {
}

/*
* Console related
- Console related
*/

default boolean isConsole() {
Expand All @@ -42,11 +42,15 @@ default Object asConsoleHandle() {
}

/*
* Utilities
- Shared methods
*/

boolean hasPermission(@NotNull String permission);

/*
- Utilities
*/

@NotNull
MCUtils<?> getUtils();
}

0 comments on commit 0b74f17

Please sign in to comment.