-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added play sound nearby feature by #25.
- Loading branch information
Showing
6 changed files
with
73 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
doublejump-core/src/main/java/com/github/imdmk/doublejump/jump/sound/JumpSoundService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package com.github.imdmk.doublejump.jump.sound; | ||
|
||
import com.github.imdmk.doublejump.configuration.implementation.PluginConfiguration; | ||
import com.github.imdmk.doublejump.jump.JumpSettings; | ||
import com.github.imdmk.doublejump.placeholder.PlaceholderRegistry; | ||
import org.bukkit.entity.Entity; | ||
import org.bukkit.entity.Player; | ||
|
||
import java.util.List; | ||
|
||
public class JumpSoundService { | ||
|
||
private final JumpSoundSettings jumpSoundSettings; | ||
|
||
public JumpSoundService(PluginConfiguration pluginConfiguration) { | ||
this.jumpSoundSettings = pluginConfiguration.jumpSettings.soundSettings; | ||
} | ||
|
||
public void play(Player player) { | ||
this.jumpSoundSettings.sounds.forEach(sound -> sound.play(player)); | ||
} | ||
|
||
public void playNearby(Player player) { | ||
double nearbyX = this.jumpSoundSettings.playNearbyX; | ||
double nearbyY = this.jumpSoundSettings.playNearbyY; | ||
double nearbyZ = this.jumpSoundSettings.playNearbyZ; | ||
|
||
List<Entity> nearbyEntities = player.getNearbyEntities(nearbyX, nearbyY, nearbyZ); | ||
|
||
for (Entity entity : nearbyEntities) { | ||
if (!(entity instanceof Player other)) { | ||
return; | ||
} | ||
|
||
this.play(other); | ||
} | ||
} | ||
|
||
public boolean isSoundsEnabled() { | ||
return this.jumpSoundSettings.enabled; | ||
} | ||
|
||
public boolean isPlayNearbyEnabled() { | ||
return this.jumpSoundSettings.playNearbyEnabled; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters