From a95c3e03b75aca2812dc5551878df58e3735dc47 Mon Sep 17 00:00:00 2001 From: William Date: Sun, 31 Mar 2024 19:37:30 +0100 Subject: [PATCH] feat: make warmup cancellation conditions configurable, close #564 --- .../main/java/net/william278/huskhomes/config/Settings.java | 6 ++++++ .../net/william278/huskhomes/teleport/TimedTeleport.java | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/common/src/main/java/net/william278/huskhomes/config/Settings.java b/common/src/main/java/net/william278/huskhomes/config/Settings.java index 52b5c257..0f9da6e5 100644 --- a/common/src/main/java/net/william278/huskhomes/config/Settings.java +++ b/common/src/main/java/net/william278/huskhomes/config/Settings.java @@ -137,6 +137,12 @@ public final class Settings { @Comment("How long a player has to stand still and not take damage for when teleporting (in seconds) ") private int teleportWarmupTime = 5; + @Comment("Whether the teleport warmup timer should be cancelled if the player takes damage") + private boolean teleportWarmupCancelOnDamage = true; + + @Comment("Whether the teleport warmup timer should be cancelled if the player moves") + private boolean teleportWarmupCancelOnMove = true; + @Comment("Where the teleport warmup timer should display (CHAT, ACTION_BAR, TITLE, SUBTITLE or NONE)") private Locales.DisplaySlot teleportWarmupDisplay = Locales.DisplaySlot.ACTION_BAR; diff --git a/common/src/main/java/net/william278/huskhomes/teleport/TimedTeleport.java b/common/src/main/java/net/william278/huskhomes/teleport/TimedTeleport.java index cffe5b9a..243b099e 100644 --- a/common/src/main/java/net/william278/huskhomes/teleport/TimedTeleport.java +++ b/common/src/main/java/net/william278/huskhomes/teleport/TimedTeleport.java @@ -141,7 +141,7 @@ public class TimedTeleport extends Teleport implements Runnable, Completable { } // Cancel the timed teleport if the player takes damage - if (hasTeleporterTakenDamage()) { + if (hasTeleporterTakenDamage() && plugin.getSettings().getGeneral().isTeleportWarmupCancelOnDamage()) { plugin.getLocales().getLocale("teleporting_cancelled_damage") .ifPresent(teleporter::sendMessage); plugin.getLocales().getLocale("teleporting_action_bar_cancelled") @@ -152,7 +152,7 @@ public class TimedTeleport extends Teleport implements Runnable, Completable { } // Cancel the timed teleport if the player moves - if (hasTeleporterMoved()) { + if (hasTeleporterMoved() && plugin.getSettings().getGeneral().isTeleportWarmupCancelOnMove()) { plugin.getLocales().getLocale("teleporting_cancelled_movement") .ifPresent(teleporter::sendMessage); plugin.getLocales().getLocale("teleporting_action_bar_cancelled")