Skip to content

Commit

Permalink
Closes #8, adds options for setting custom teleport sounds
Browse files Browse the repository at this point in the history
  • Loading branch information
WiIIiam278 committed Jan 25, 2021
1 parent 5c6a3df commit 90127d8
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 1 deletion.
15 changes: 15 additions & 0 deletions src/main/java/me/william278/huskhomes2/Objects/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -308,4 +315,12 @@ public int getPublicHomesPerPage() {
public int getWarpsPerPage() {
return warpsPerPage;
}

public String getTeleportationCompleteSound() {
return teleportationCompleteSound;
}

public String getTeleportWarmupSound() {
return teleportWarmupSound;
}
}
2 changes: 1 addition & 1 deletion src/main/java/me/william278/huskhomes2/runEverySecond.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/me/william278/huskhomes2/teleportManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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());
Expand Down
3 changes: 3 additions & 0 deletions src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 90127d8

Please sign in to comment.