Interface MagicSender
-
Method Summary
Modifier and TypeMethodDescriptiondefault @Nullable Stringaddress()IP address of the sender, if available.audience()Audience for sending messages back to the sender.@Nullable Objecthandle()Raw platform sender handle.static booleanhasPermission(Object sender, String permission) Checks permission on raw sender using registered adapters.static booleanhasPermission(Object sender, String permission, int fallbackOpLevel) Checks permission on raw sender using registered adapters and a custom op-level fallback.booleanhasPermission(String permission) Permission check for the sender.default booleanhasPermission(String permission, int fallbackOpLevel) Permission check for the sender with a custom op-level fallback.default @Nullable UUIDid()Optional sender id (player UUID, if available).name()Human-readable sender name.default CompletableFuture<Boolean> Teleports the sender to a location, if the platform and sender support it.default <T> TAttempt to unwrap the raw handle to the given type.static @Nullable MagicSenderWrap raw sender instance into MagicSender if a platform adapter is available.
-
Method Details
-
wrap
Wrap raw sender instance into MagicSender if a platform adapter is available.- Parameters:
sender- raw sender instance- Returns:
- wrapped sender or null if unsupported
-
hasPermission
-
hasPermission
Checks permission on raw sender using registered adapters and a custom op-level fallback.- Parameters:
sender- raw sender instancepermission- permission nodefallbackOpLevel- op level to treat as granted when no permission backend answers- Returns:
- true if granted
-
audience
-
name
-
id
Optional sender id (player UUID, if available).- Returns:
- sender id or null
-
hasPermission
Permission check for the sender.- Parameters:
permission- permission node- Returns:
- true if granted
-
hasPermission
Permission check for the sender with a custom op-level fallback.Platforms that support fallback-aware permission checks should override this method. The default implementation preserves existing behavior.
- Parameters:
permission- permission nodefallbackOpLevel- op level to treat as granted when no permission backend answers- Returns:
- true if granted
-
address
IP address of the sender, if available.- Returns:
- IP address string or null
-
teleport
default CompletableFuture<Boolean> teleport(@Nullable @Nullable String worldName, double x, double y, double z) Teleports the sender to a location, if the platform and sender support it.Coordinates are used rather than a platform
Locationso this stays on the platform-agnostic interface. AworldNameof null means "the sender's current world"; platforms that cannot resolve a world by name may ignore it. The move is asynchronous by contract: on Folia/Canvas a synchronous teleport throws on any thread, so implementations must route through the platform's async teleport and complete the returned future when the move resolves.The default implementation is a no-op for senders that cannot be teleported (console, non-player) and completes with
false. Platforms whose senders can move (e.g. Bukkit players) override this.- Parameters:
worldName- target world name, or null for the sender's current worldx- target xy- target yz- target z- Returns:
- a future completed with true once the sender arrives, false if the sender cannot be teleported
-
handle
-
unwrap
Attempt to unwrap the raw handle to the given type.- Type Parameters:
T- type parameter- Parameters:
type- target class- Returns:
- unwrapped handle or null if not compatible
-