mirror of
https://github.com/darksaid98/HuskHomes.git
synced 2026-12-02 06:28:49 +00:00
Make invalid sounds not play any sound
This commit is contained in:
1 parent
d9ddce44d0
commit
2e7170b518
3 files changed
+26
-8
No files matched your search
@@ -228,13 +228,23 @@ public class Settings {
|
||||
// Retrieve sounds used in plugin; if invalid, use defaults.
|
||||
try {
|
||||
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"));
|
||||
} 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"));
|
||||
} catch (IllegalArgumentException exception) {
|
||||
Bukkit.getLogger().severe("Invalid sound specified in config.yml; using default sounds instead.");
|
||||
this.teleportationCompleteSound = Sound.ENTITY_ENDERMAN_TELEPORT;
|
||||
this.teleportWarmupSound = Sound.BLOCK_NOTE_BLOCK_BANJO;
|
||||
this.teleportCancelledSound = Sound.ENTITY_ITEM_BREAK;
|
||||
Bukkit.getLogger().severe("Invalid sound specified for teleportation_cancelled, using no sound instead");
|
||||
this.teleportCancelledSound = null;
|
||||
}
|
||||
|
||||
this.allowUnicodeInDescriptions = config.getBoolean("allow_unicode_descriptions", true);
|
||||
|
||||
@@ -105,7 +105,9 @@ public class TeleportManager {
|
||||
player.eject(); // Eject passengers before teleporting
|
||||
}
|
||||
PaperLib.teleportAsync(player, targetLocation).thenRun(() -> {
|
||||
player.playSound(targetLocation, HuskHomes.getSettings().getTeleportationCompleteSound(), 1, 1);
|
||||
if (HuskHomes.getSettings().getTeleportationCompleteSound() != null) {
|
||||
player.playSound(targetLocation, HuskHomes.getSettings().getTeleportationCompleteSound(), 1, 1);
|
||||
}
|
||||
MessageManager.sendMessage(player, "teleporting_complete");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -76,14 +76,18 @@ public class TimedTeleport {
|
||||
}
|
||||
if (hasMoved(executablePlayer)) {
|
||||
cancel();
|
||||
executablePlayer.playSound(executablePlayer.getLocation(), HuskHomes.getSettings().getTeleportCancelledSound(), 1, 1);
|
||||
if (HuskHomes.getSettings().getTeleportCancelledSound() != null) {
|
||||
executablePlayer.playSound(executablePlayer.getLocation(), HuskHomes.getSettings().getTeleportCancelledSound(), 1, 1);
|
||||
}
|
||||
MessageManager.sendMessage(player, "teleporting_cancelled_movement");
|
||||
sendWarmupMessage(player, "teleporting_action_bar_cancelled");
|
||||
return;
|
||||
}
|
||||
if (hasLostHealth(executablePlayer)) {
|
||||
cancel();
|
||||
executablePlayer.playSound(executablePlayer.getLocation(), HuskHomes.getSettings().getTeleportCancelledSound(), 1, 1);
|
||||
if (HuskHomes.getSettings().getTeleportCancelledSound() != null) {
|
||||
executablePlayer.playSound(executablePlayer.getLocation(), HuskHomes.getSettings().getTeleportCancelledSound(), 1, 1);
|
||||
}
|
||||
MessageManager.sendMessage(player, "teleporting_cancelled_damage");
|
||||
sendWarmupMessage(player, "teleporting_action_bar_cancelled");
|
||||
return;
|
||||
@@ -138,7 +142,9 @@ public class TimedTeleport {
|
||||
return;
|
||||
}
|
||||
sendWarmupMessage(executablePlayer, "teleporting_action_bar_countdown", Integer.toString(i[0]));
|
||||
executablePlayer.playSound(executablePlayer.getLocation(), HuskHomes.getSettings().getTeleportWarmupSound(), 1, 1);
|
||||
if (HuskHomes.getSettings().getTeleportWarmupSound() != null) {
|
||||
executablePlayer.playSound(executablePlayer.getLocation(), HuskHomes.getSettings().getTeleportWarmupSound(), 1, 1);
|
||||
}
|
||||
}
|
||||
}.runTaskTimer(plugin, 0, 20L);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user