From 90127d819d029ea7931e30c79cb3b57fe74f8942 Mon Sep 17 00:00:00 2001 From: William278 Date: Mon, 25 Jan 2021 14:18:57 +0000 Subject: [PATCH] Closes #8, adds options for setting custom teleport sounds --- .../william278/huskhomes2/Objects/Settings.java | 15 +++++++++++++++ .../me/william278/huskhomes2/runEverySecond.java | 2 +- .../me/william278/huskhomes2/teleportManager.java | 2 ++ src/main/resources/config.yml | 3 +++ 4 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/main/java/me/william278/huskhomes2/Objects/Settings.java b/src/main/java/me/william278/huskhomes2/Objects/Settings.java index 542976bd8..93d64f800 100644 --- a/src/main/java/me/william278/huskhomes2/Objects/Settings.java +++ b/src/main/java/me/william278/huskhomes2/Objects/Settings.java @@ -53,6 +53,10 @@ public class Settings { int teleportRequestExpiryTime; int teleportWarmupTime; + // Sounds + String teleportationCompleteSound; + String teleportWarmupSound; + // Number of items per page on lists int privateHomesPerPage; int publicHomesPerPage; @@ -130,6 +134,9 @@ private void setSettings(FileConfiguration configFile) { this.publicHomeCost = configFile.getDouble("economy_integration.costs.make_home_public"); this.rtpCost = configFile.getDouble("economy_integration.costs.random_teleport"); + this.teleportationCompleteSound = configFile.getString("general.sounds.teleportation_complete"); + this.teleportWarmupSound = configFile.getString("general.sounds.teleportation_warmup"); + this.checkVanishedPlayers = configFile.getBoolean("handle_vanished_players"); this.doSpawnCommand = configFile.getBoolean("spawn_command.enabled"); @@ -308,4 +315,12 @@ public int getPublicHomesPerPage() { public int getWarpsPerPage() { return warpsPerPage; } + + public String getTeleportationCompleteSound() { + return teleportationCompleteSound; + } + + public String getTeleportWarmupSound() { + return teleportWarmupSound; + } } diff --git a/src/main/java/me/william278/huskhomes2/runEverySecond.java b/src/main/java/me/william278/huskhomes2/runEverySecond.java index 33bba6052..e980d28cc 100644 --- a/src/main/java/me/william278/huskhomes2/runEverySecond.java +++ b/src/main/java/me/william278/huskhomes2/runEverySecond.java @@ -53,7 +53,7 @@ public static void startLoop() { if (timedTeleport.getTimeRemaining() > 0) { if (!timedTeleport.hasMoved(teleporter)) { if (!timedTeleport.hasLostHealth(teleporter)) { - teleporter.playSound(teleporter.getLocation(), Sound.BLOCK_NOTE_BLOCK_BANJO, 2, 1); + teleporter.playSound(teleporter.getLocation(), Sound.valueOf(HuskHomes.settings.getTeleportWarmupSound()), 2, 1); messageManager.sendActionBarMessage(teleporter, "teleporting_action_bar_countdown", Integer.toString(timedTeleport.getTimeRemaining())); timedTeleport.decrementTimeRemaining(); diff --git a/src/main/java/me/william278/huskhomes2/teleportManager.java b/src/main/java/me/william278/huskhomes2/teleportManager.java index 8a5790d0e..41c6ac3cf 100644 --- a/src/main/java/me/william278/huskhomes2/teleportManager.java +++ b/src/main/java/me/william278/huskhomes2/teleportManager.java @@ -5,6 +5,7 @@ import me.william278.huskhomes2.Objects.TeleportationPoint; import me.william278.huskhomes2.Objects.TimedTeleport; import org.bukkit.Bukkit; +import org.bukkit.Sound; import org.bukkit.entity.Player; import java.time.Instant; @@ -33,6 +34,7 @@ public static void teleportPlayer(Player p) { String server = teleportationPoint.getServer(); if (!HuskHomes.settings.doBungee() || server.equals(HuskHomes.settings.getServerID())) { p.teleport(teleportationPoint.getLocation()); + p.playSound(p.getLocation(), Sound.valueOf(HuskHomes.settings.getTeleportationCompleteSound()), 1, 1); messageManager.sendMessage(p, "teleporting_complete"); dataManager.setPlayerTeleporting(p, false); dataManager.clearPlayerDestination(p.getName()); diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 66b4f46c5..a36592be7 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -16,6 +16,9 @@ general: max_sethomes: 10 teleport_warmup_time: 5 teleport_request_expiry_time: 60 + sounds: + teleportation_complete: 'ENTITY_ENDERMAN_TELEPORT' + teleportation_warmup: 'BLOCK_NOTE_BLOCK_BANJO' lists: private_homes_per_page: 10 public_homes_per_page: 10