mirror of
https://github.com/darksaid98/HuskHomes.git
synced 2026-12-01 22:16:08 +00:00
Merge pull request #136 from smooone/master
Make invalid sounds not play any sound
This commit is contained in:
3 files changed
+31
-11
No files matched your search
@@ -7,6 +7,8 @@ import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class Settings {
|
||||
|
||||
private final Plugin plugin;
|
||||
@@ -228,13 +230,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);
|
||||
@@ -442,15 +454,15 @@ public class Settings {
|
||||
public int getWarpsPerPage() {
|
||||
return warpsPerPage;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Sound getTeleportationCompleteSound() {
|
||||
return teleportationCompleteSound;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Sound getTeleportWarmupSound() {
|
||||
return teleportWarmupSound;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Sound getTeleportCancelledSound() {
|
||||
return teleportCancelledSound;
|
||||
}
|
||||
|
||||
@@ -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