mirror of
https://github.com/darksaid98/HuskHomes.git
synced 2026-12-04 14:38:53 +00:00
Add option to display teleport warmup countdown numbers as titles, subtitles, chat as well as default action bar, Close #48
This commit is contained in:
1 parent
e22367a2ec
commit
db06622622
3 files changed
+28
-3
No files matched your search
@@ -78,6 +78,7 @@ public class Settings {
|
|||||||
private int maximumHomes;
|
private int maximumHomes;
|
||||||
private int teleportRequestExpiryTime;
|
private int teleportRequestExpiryTime;
|
||||||
private int teleportWarmupTime;
|
private int teleportWarmupTime;
|
||||||
|
private DisplayStyle teleportWarmupDisplayStyle;
|
||||||
|
|
||||||
// Sounds
|
// Sounds
|
||||||
private Sound teleportationCompleteSound;
|
private Sound teleportationCompleteSound;
|
||||||
@@ -263,6 +264,7 @@ public class Settings {
|
|||||||
this.maximumHomes = config.getInt("general.max_sethomes", 10);
|
this.maximumHomes = config.getInt("general.max_sethomes", 10);
|
||||||
this.teleportRequestExpiryTime = config.getInt("general.teleport_request_expiry_time", 60);
|
this.teleportRequestExpiryTime = config.getInt("general.teleport_request_expiry_time", 60);
|
||||||
this.teleportWarmupTime = config.getInt("general.teleport_warmup_time", 5);
|
this.teleportWarmupTime = config.getInt("general.teleport_warmup_time", 5);
|
||||||
|
this.teleportWarmupDisplayStyle = DisplayStyle.valueOf(config.getString("general.teleport_warmup_display", "ACTION_BAR"));
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
HuskHomes.disablePlugin("An error occurred loading the HuskHomes config (" + e.getCause() + ")");
|
HuskHomes.disablePlugin("An error occurred loading the HuskHomes config (" + e.getCause() + ")");
|
||||||
@@ -529,4 +531,15 @@ public class Settings {
|
|||||||
public boolean doHomeLimitPermissionStacking() {
|
public boolean doHomeLimitPermissionStacking() {
|
||||||
return homeLimitPermissionStacking;
|
return homeLimitPermissionStacking;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public DisplayStyle getWarmupDisplayStyle() {
|
||||||
|
return teleportWarmupDisplayStyle;
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum DisplayStyle {
|
||||||
|
ACTION_BAR,
|
||||||
|
TITLE,
|
||||||
|
SUBTITLE,
|
||||||
|
CHAT
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,11 +1,13 @@
|
|||||||
package me.william278.huskhomes2.teleport;
|
package me.william278.huskhomes2.teleport;
|
||||||
|
|
||||||
|
import de.themoep.minedown.MineDown;
|
||||||
import me.william278.huskhomes2.HuskHomes;
|
import me.william278.huskhomes2.HuskHomes;
|
||||||
import me.william278.huskhomes2.MessageManager;
|
import me.william278.huskhomes2.MessageManager;
|
||||||
import me.william278.huskhomes2.data.DataManager;
|
import me.william278.huskhomes2.data.DataManager;
|
||||||
import me.william278.huskhomes2.integrations.VaultIntegration;
|
import me.william278.huskhomes2.integrations.VaultIntegration;
|
||||||
import me.william278.huskhomes2.teleport.points.RandomPoint;
|
import me.william278.huskhomes2.teleport.points.RandomPoint;
|
||||||
import me.william278.huskhomes2.teleport.points.TeleportationPoint;
|
import me.william278.huskhomes2.teleport.points.TeleportationPoint;
|
||||||
|
import net.md_5.bungee.api.chat.TextComponent;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@@ -76,14 +78,14 @@ public class TimedTeleport {
|
|||||||
cancel();
|
cancel();
|
||||||
executablePlayer.playSound(executablePlayer.getLocation(), HuskHomes.getSettings().getTeleportCancelledSound(), 1, 1);
|
executablePlayer.playSound(executablePlayer.getLocation(), HuskHomes.getSettings().getTeleportCancelledSound(), 1, 1);
|
||||||
MessageManager.sendMessage(player, "teleporting_cancelled_movement");
|
MessageManager.sendMessage(player, "teleporting_cancelled_movement");
|
||||||
MessageManager.sendActionBar(player, "teleporting_action_bar_cancelled");
|
sendWarmupMessage(player, "teleporting_action_bar_cancelled");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (hasLostHealth(executablePlayer)) {
|
if (hasLostHealth(executablePlayer)) {
|
||||||
cancel();
|
cancel();
|
||||||
executablePlayer.playSound(executablePlayer.getLocation(), HuskHomes.getSettings().getTeleportCancelledSound(), 1, 1);
|
executablePlayer.playSound(executablePlayer.getLocation(), HuskHomes.getSettings().getTeleportCancelledSound(), 1, 1);
|
||||||
MessageManager.sendMessage(player, "teleporting_cancelled_damage");
|
MessageManager.sendMessage(player, "teleporting_cancelled_damage");
|
||||||
MessageManager.sendActionBar(player, "teleporting_action_bar_cancelled");
|
sendWarmupMessage(player, "teleporting_action_bar_cancelled");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
i[0] = i[0] -1;
|
i[0] = i[0] -1;
|
||||||
@@ -135,7 +137,7 @@ public class TimedTeleport {
|
|||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
MessageManager.sendActionBar(executablePlayer, "teleporting_action_bar_countdown", Integer.toString(i[0]));
|
sendWarmupMessage(executablePlayer, "teleporting_action_bar_countdown", Integer.toString(i[0]));
|
||||||
executablePlayer.playSound(executablePlayer.getLocation(), HuskHomes.getSettings().getTeleportWarmupSound(), 1, 1);
|
executablePlayer.playSound(executablePlayer.getLocation(), HuskHomes.getSettings().getTeleportWarmupSound(), 1, 1);
|
||||||
}
|
}
|
||||||
}.runTaskTimer(plugin, 0, 20L);
|
}.runTaskTimer(plugin, 0, 20L);
|
||||||
@@ -153,6 +155,15 @@ public class TimedTeleport {
|
|||||||
return targetPlayerName;
|
return targetPlayerName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void sendWarmupMessage(Player player, String messageID, String... replacements) {
|
||||||
|
switch (HuskHomes.getSettings().getWarmupDisplayStyle()) {
|
||||||
|
case ACTION_BAR -> MessageManager.sendActionBar(player, messageID, replacements);
|
||||||
|
case TITLE -> player.sendTitle(TextComponent.toLegacyText(new MineDown(MessageManager.getRawMessage(messageID, replacements)).toComponent()), "", 20, 60, 20);
|
||||||
|
case SUBTITLE -> player.sendTitle("", TextComponent.toLegacyText(new MineDown(MessageManager.getRawMessage(messageID, replacements)).toComponent()), 20, 60, 20);
|
||||||
|
case CHAT -> MessageManager.sendMessage(player, messageID, replacements);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// This converts a negative to a positive double, used in checking if a player has moved
|
// This converts a negative to a positive double, used in checking if a player has moved
|
||||||
private static double makePositive(double d) {
|
private static double makePositive(double d) {
|
||||||
if (d < 0) {
|
if (d < 0) {
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ general:
|
|||||||
auto_complete_player_names: true
|
auto_complete_player_names: true
|
||||||
home_limit_permission_stacking: false
|
home_limit_permission_stacking: false
|
||||||
teleport_warmup_time: 5
|
teleport_warmup_time: 5
|
||||||
|
teleport_warmup_display: ACTION_BAR
|
||||||
teleport_request_expiry_time: 60
|
teleport_request_expiry_time: 60
|
||||||
allow_unicode_descriptions: true
|
allow_unicode_descriptions: true
|
||||||
sounds:
|
sounds:
|
||||||
|
|||||||
Reference in new issue
Block a user