-
Notifications
You must be signed in to change notification settings - Fork 0
M | Utility: TeleportUtils
Sartaj Singh edited this page May 31, 2025
·
4 revisions
- 1. Overview
- 2. What is TeleportUtils?
- 3. Basic Usage
- 4. API Reference
- 5. Advanced Patterns
- 6. Troubleshooting & Notes
- 7. See Also
TeleportUtils is a utility class in FXItems for teleporting players safely, with optional particle and sound effects.
It provides a centralized way to handle player teleportation with distance checks and effect options.
- Teleports a player to a target location.
- Optionally limits teleport distance.
- Can preserve the player's yaw/pitch direction.
- Optionally plays a sound and/or spawns particles on teleport.
boolean success = TeleportUtils.teleportPlayer(
player,
targetLocation,
40, // maxDistance in blocks
true, // preserveDirection
true, // playSound
true // spawnParticles
);
if (!success) {
player.sendMessage("Teleport failed!");
}/**
* Teleports a player to a target location with optional distance limit, direction preservation, sound, and particles.
*
* @param player The player to teleport.
* @param targetLocation The location to teleport to.
* @param maxDistance The maximum allowed distance for teleportation.
* @param preserveDirection Whether to preserve the player's original yaw and pitch.
* @param playSound Whether to play a sound effect during teleportation.
* @param spawnParticles Whether to spawn particles at the teleportation location.
* @return True if the teleportation was successful, false otherwise.
*/
public static boolean teleportPlayer(Player player, Location targetLocation, int maxDistance, boolean preserveDirection, boolean playSound, boolean spawnParticles)-
Restricting ability range:
UsemaxDistanceto limit how far a player can teleport, e.g., for wands or teleport items. -
Visual feedback:
UseplaySoundandspawnParticlesfor better player experience. -
Preserving orientation:
preserveDirectionis useful for blink/warp effects where facing matters.
- If the target location is too far, teleport will fail and send a message to the player.
-
playSounduses the Enderman teleport sound at the origin location. -
spawnParticlesspawnsParticle.PORTALat the destination.
- Home
- A | Getting Started & Plugin Overview
- B | The Registry System: Items, Foods, Commands, Events
- C | Creating Custom Items
- D | Creating Custom Foods
- E | Advanced: Custom Effects in FXItems
- F | Creating Custom Commands
- G | Creating Custom Events & Behaviors
- H | Utility: CooldownUtils
- I | Utility: CustomItemUtils
- J | Utility: EffectUtils
- K | Utility: ManaUtils
- L | Utility: OneTimeCraftUtils
- M | Utility: TeleportUtils
- N | Utility: ProjectileUtils
- O | Utility: GammaUtils
- P | Utility: EntitySizeUtils
- Q | FXItems API (com.noctify.API) & Making Addons
- R | Advanced Techniques, Gotchas & FAQ
- S | Auto-Registration System
- T | Migration Guide (v1.1 → v1.2+)
- U | Changelog