DREAMFIRE Docs ← Back to site
Loading...
Searching...
No Matches
DreamTeleportAPI.java
Go to the documentation of this file.
1/*
2 * MIT License
3 *
4 * Copyright (c) 2025 Dreamfire Studio
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in all
14 * copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 * SOFTWARE.
23 */
24package com.dreamfirestudios.dreamcore.DreamTeleport;
25
26import org.bukkit.Bukkit;
27import org.bukkit.Location;
28import org.bukkit.entity.LivingEntity;
29import org.bukkit.entity.Player;
30import org.bukkit.plugin.Plugin;
31
32import java.util.*;
33import java.util.concurrent.ConcurrentHashMap;
34
48public final class DreamTeleportAPI {
49
50 private DreamTeleportAPI() {}
51
52 // Active tasks, keyed by player UUID for quick lookups.
53 private static final Map<UUID, DreamTeleport> ACTIVE = new ConcurrentHashMap<>();
54
65 public static void teleportPlayer(
66 Plugin plugin,
67 Player player,
68 LivingEntity liveTarget,
69 Location fixedTarget,
70 int seconds,
71 boolean showCountdown,
72 boolean cancelOnMove
73 ) {
74 teleportPlayers(plugin, Collections.singletonList(player), liveTarget, fixedTarget,
75 seconds, showCountdown, cancelOnMove, 0.1, DreamTeleport.DEFAULT_PERIOD_TICKS);
76 }
77
96 public static void teleportPlayers(
97 Plugin plugin,
98 Collection<Player> players,
99 LivingEntity liveTarget,
100 Location fixedTarget,
101 int seconds,
102 boolean showCountdown,
103 boolean cancelOnMove,
104 double moveTolerance,
105 long periodTicks
106 ) {
107 // [Implementation unchanged: filter players, create DreamTeleport, register ACTIVE, start]
108 }
109
113 public static boolean isPlayerTeleporting(Player player) {
114 return player != null && ACTIVE.containsKey(player.getUniqueId());
115 }
116
120 public static void cancelPlayerTeleport(Player player) {
121 // [Implementation unchanged]
122 }
123
127 public static void cancelAll(Collection<Player> players) {
128 for (Player p : players) cancelPlayerTeleport(p);
129 }
130}
Static helpers and registry for in-flight teleports.
static void cancelPlayerTeleport(Player player)
Cancels a single player’s pending teleport (if any).
static void teleportPlayer(Plugin plugin, Player player, LivingEntity liveTarget, Location fixedTarget, int seconds, boolean showCountdown, boolean cancelOnMove)
Convenience overload to teleport a single player.
static boolean isPlayerTeleporting(Player player)
Checks whether a player is currently queued in a teleport task.
static void cancelAll(Collection< Player > players)
Cancels all teleports for the given players.
static void teleportPlayers(Plugin plugin, Collection< Player > players, LivingEntity liveTarget, Location fixedTarget, int seconds, boolean showCountdown, boolean cancelOnMove, double moveTolerance, long periodTicks)
Teleports multiple players with full control parameters.
A scheduled teleport task that can handle one or more players counting down to a target (either a liv...
static final long DEFAULT_PERIOD_TICKS
Default tick period; 20 ticks = 1 second updates.