Skip to content

Commit

Permalink
move sound methods and refactor some stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
Snabeldier committed Jan 27, 2025
1 parent 4b8df70 commit aff37b5
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 54 deletions.
28 changes: 28 additions & 0 deletions src/main/java/minevalley/core/api/audio/SoundReceiver.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package minevalley.core.api.audio;

import net.kyori.adventure.sound.Sound;
import org.bukkit.Location;

import javax.annotation.Nonnull;

@SuppressWarnings("unused")
public interface SoundReceiver {

/**
* Plays a specific sound.
*
* @param sound sound to be played
* @throws IllegalArgumentException if sound is null or an empty string
*/
void playSound(@Nonnull Sound.Type sound) throws IllegalArgumentException;

/**
* Plays a specific sound.
*
* @param sound sound to be played
* @param location location where the sound will be played
* @param spatial defines whether the sound should be spatial
* @throws IllegalArgumentException if sound or location is null, or the location is not in the same world as the user
*/
void playSound(@Nonnull Sound.Type sound, @Nonnull Location location, boolean spatial) throws IllegalArgumentException;
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
package minevalley.core.api.enums.sounds;
package minevalley.core.api.audio.sounds;

import lombok.AccessLevel;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import net.kyori.adventure.key.Key;
import net.kyori.adventure.sound.Sound;
import org.bukkit.NamespacedKey;

@Getter
import javax.annotation.Nonnull;

@SuppressWarnings("unused")
@RequiredArgsConstructor(access = AccessLevel.PRIVATE)
public enum Sound {
public enum SystemSound implements Sound.Type {

/**
* Used to get the user's attention.
Expand All @@ -23,5 +27,10 @@ public enum Sound {
*/
NOTIFICATION_ERROR("notification_error");

private final String name;
private final String key;

@Override
public @Nonnull Key key() {
return new NamespacedKey("minevalley", key);
}
}

This file was deleted.

7 changes: 7 additions & 0 deletions src/main/java/minevalley/core/api/users/Ambient.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package minevalley.core.api.users;

public enum Ambient {

NONE,
TRAIN_STATION
}
44 changes: 2 additions & 42 deletions src/main/java/minevalley/core/api/users/OnlineUser.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

import minevalley.core.api.economy.AccountUser;
import minevalley.core.api.economy.BankAccount;
import minevalley.core.api.enums.sounds.AmbientSound;
import minevalley.core.api.enums.sounds.Sound;
import minevalley.core.api.messaging.MessageReceiver;
import minevalley.core.api.messaging.instruction.Instruction;
import minevalley.core.api.regions.utils.PlayerLocation;
Expand Down Expand Up @@ -137,60 +135,22 @@ void input(@Nonnull String text, @Nonnull Instruction instruction, @Nonnull Cons
@Contract(pure = true)
McVersion getVersion();

// Sounds

/**
* Plays a specific sound.
*
* @param sound sound to be played
* @throws IllegalArgumentException if sound is null or an empty string
*/
void playSound(@Nonnull String sound) throws IllegalArgumentException;

/**
* Plays a specific sound.
*
* @param sound sound to be played
* @throws IllegalArgumentException if sound is null
*/
void playSound(@Nonnull Sound sound) throws IllegalArgumentException;

/**
* Plays a specific sound.
*
* @param sound sound to be played
* @param location location where the sound will be played
* @param spatial defines whether the sound should be spatial
* @throws IllegalArgumentException if sound or location is null, or the location is not in the same world as the user
*/
void playSound(@Nonnull Sound sound, @Nonnull Location location, boolean spatial) throws IllegalArgumentException;

/**
* Plays a specific sound.
*
* @param sound sound to be played
* @param location location where the sound will be played
* @param spatial defines whether the sound should be spatial
* @throws IllegalArgumentException if sound or location is null, or the location is not in the same world as the user
*/
void playSound(@Nonnull String sound, @Nonnull Location location, boolean spatial) throws IllegalArgumentException;

/**
* Gets the ambient this user is currently hearing
*
* @return ambient this user is hearing
*/
@Nonnull
@Contract(pure = true)
AmbientSound getAmbient();
Ambient getAmbient();

/**
* Sets the ambient this user is hearing
*
* @param ambient ambient to be set
* @throws IllegalArgumentException if ambient is null
*/
void setAmbient(@Nonnull AmbientSound ambient) throws IllegalArgumentException;
void setAmbient(@Nonnull Ambient ambient) throws IllegalArgumentException;

/**
* Starts the credits sequence.
Expand Down

0 comments on commit aff37b5

Please sign in to comment.