mirror of
https://github.com/Phoenix616/RandomTeleport.git
synced 2024-11-29 06:06:08 +01:00
Only apply cooldown if teleport was successful
This commit is contained in:
parent
a8db0033df
commit
73a49f779b
@ -377,7 +377,6 @@ public class RandomTeleport extends JavaPlugin implements RandomTeleportAPI {
|
|||||||
sendMessage(searcher.getTargets(), "search", "worldname", searcher.getCenter().getWorld().getName());
|
sendMessage(searcher.getTargets(), "search", "worldname", searcher.getCenter().getWorld().getName());
|
||||||
searcher.search().thenApply(targetLoc -> {
|
searcher.search().thenApply(targetLoc -> {
|
||||||
searcher.getTargets().forEach(e -> {
|
searcher.getTargets().forEach(e -> {
|
||||||
cooldowns.put(searcher.getId(), e.getUniqueId(), new AbstractMap.SimpleImmutableEntry<>(System.currentTimeMillis(), searcher.getCooldown()));
|
|
||||||
if (e instanceof Player) {
|
if (e instanceof Player) {
|
||||||
Location belowLoc = targetLoc.clone().subtract(0, 1, 0);
|
Location belowLoc = targetLoc.clone().subtract(0, 1, 0);
|
||||||
Block belowBlock = belowLoc.getBlock();
|
Block belowBlock = belowLoc.getBlock();
|
||||||
@ -388,6 +387,7 @@ public class RandomTeleport extends JavaPlugin implements RandomTeleportAPI {
|
|||||||
targetLoc.setZ(targetLoc.getBlockZ() + 0.5);
|
targetLoc.setZ(targetLoc.getBlockZ() + 0.5);
|
||||||
PaperLib.teleportAsync(e, targetLoc).thenAccept(success -> {
|
PaperLib.teleportAsync(e, targetLoc).thenAccept(success -> {
|
||||||
if (success) {
|
if (success) {
|
||||||
|
cooldowns.put(searcher.getId(), e.getUniqueId(), new AbstractMap.SimpleImmutableEntry<>(System.currentTimeMillis(), searcher.getCooldown()));
|
||||||
sendMessage(e, "teleport",
|
sendMessage(e, "teleport",
|
||||||
"worldname", targetLoc.getWorld().getName(),
|
"worldname", targetLoc.getWorld().getName(),
|
||||||
"x", String.valueOf(targetLoc.getBlockX()),
|
"x", String.valueOf(targetLoc.getBlockX()),
|
||||||
|
Loading…
Reference in New Issue
Block a user