Make invalid sounds not play any sound

This commit is contained in:
smooone committed 2022-01-31 14:26:00 +01:00
1 parent d9ddce44d0
commit 2e7170b518
3 files changed
+22 -4

No files matched your search

@@ -228,13 +228,23 @@ public class Settings {
// Retrieve sounds used in plugin; if invalid, use defaults. // Retrieve sounds used in plugin; if invalid, use defaults.
try { try {
this.teleportationCompleteSound = Sound.valueOf(config.getString("general.sounds.teleportation_complete", "ENTITY_ENDERMAN_TELEPORT")); this.teleportationCompleteSound = Sound.valueOf(config.getString("general.sounds.teleportation_complete", "ENTITY_ENDERMAN_TELEPORT"));
} catch (IllegalArgumentException exception) {
Bukkit.getLogger().severe("Invalid sound specified for teleportation_complete, using no sound instead");
this.teleportationCompleteSound = null;
}
try {
this.teleportWarmupSound = Sound.valueOf(config.getString("general.sounds.teleportation_warmup", "BLOCK_NOTE_BLOCK_BANJO")); this.teleportWarmupSound = Sound.valueOf(config.getString("general.sounds.teleportation_warmup", "BLOCK_NOTE_BLOCK_BANJO"));
} catch (IllegalArgumentException exception) {
Bukkit.getLogger().severe("Invalid sound specified for teleportation_warmup, using no sound instead");
this.teleportWarmupSound = null;
}
try {
this.teleportCancelledSound = Sound.valueOf(config.getString("general.sounds.teleportation_cancelled", "ENTITY_ITEM_BREAK")); this.teleportCancelledSound = Sound.valueOf(config.getString("general.sounds.teleportation_cancelled", "ENTITY_ITEM_BREAK"));
} catch (IllegalArgumentException exception) { } catch (IllegalArgumentException exception) {
Bukkit.getLogger().severe("Invalid sound specified in config.yml; using default sounds instead."); Bukkit.getLogger().severe("Invalid sound specified for teleportation_cancelled, using no sound instead");
this.teleportationCompleteSound = Sound.ENTITY_ENDERMAN_TELEPORT; this.teleportCancelledSound = null;
this.teleportWarmupSound = Sound.BLOCK_NOTE_BLOCK_BANJO;
this.teleportCancelledSound = Sound.ENTITY_ITEM_BREAK;
} }
this.allowUnicodeInDescriptions = config.getBoolean("allow_unicode_descriptions", true); this.allowUnicodeInDescriptions = config.getBoolean("allow_unicode_descriptions", true);
@@ -105,7 +105,9 @@ public class TeleportManager {
player.eject(); // Eject passengers before teleporting player.eject(); // Eject passengers before teleporting
} }
PaperLib.teleportAsync(player, targetLocation).thenRun(() -> { PaperLib.teleportAsync(player, targetLocation).thenRun(() -> {
if (HuskHomes.getSettings().getTeleportationCompleteSound() != null) {
player.playSound(targetLocation, HuskHomes.getSettings().getTeleportationCompleteSound(), 1, 1); player.playSound(targetLocation, HuskHomes.getSettings().getTeleportationCompleteSound(), 1, 1);
}
MessageManager.sendMessage(player, "teleporting_complete"); MessageManager.sendMessage(player, "teleporting_complete");
}); });
}); });
@@ -76,14 +76,18 @@ public class TimedTeleport {
} }
if (hasMoved(executablePlayer)) { if (hasMoved(executablePlayer)) {
cancel(); cancel();
if (HuskHomes.getSettings().getTeleportCancelledSound() != null) {
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");
sendWarmupMessage(player, "teleporting_action_bar_cancelled"); sendWarmupMessage(player, "teleporting_action_bar_cancelled");
return; return;
} }
if (hasLostHealth(executablePlayer)) { if (hasLostHealth(executablePlayer)) {
cancel(); cancel();
if (HuskHomes.getSettings().getTeleportCancelledSound() != null) {
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");
sendWarmupMessage(player, "teleporting_action_bar_cancelled"); sendWarmupMessage(player, "teleporting_action_bar_cancelled");
return; return;
@@ -138,8 +142,10 @@ public class TimedTeleport {
return; return;
} }
sendWarmupMessage(executablePlayer, "teleporting_action_bar_countdown", Integer.toString(i[0])); sendWarmupMessage(executablePlayer, "teleporting_action_bar_countdown", Integer.toString(i[0]));
if (HuskHomes.getSettings().getTeleportWarmupSound() != null) {
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);
} }