Skip to content
This repository has been archived by the owner on Oct 24, 2024. It is now read-only.

Commit

Permalink
Synthwave is such a bad idea
Browse files Browse the repository at this point in the history
  • Loading branch information
CiroZDP committed Apr 25, 2024
1 parent d0187d6 commit 3f54c86
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 23 deletions.
Binary file removed opcraft/resources/newmusic/creative4.wav
Binary file not shown.
Binary file removed opcraft/resources/newmusic/menu3.wav
Binary file not shown.
20 changes: 4 additions & 16 deletions src/main/java/net/op/sound/Sound.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,15 @@ public class Sound {
private final Resource resource;
private final String name;
private final String path;
private final boolean synthwave;

public Sound(Resource resource, String name, String path, boolean synthwave) {
public Sound(Resource resource, String name, String path) {
this.resource = resource;
this.name = name;
this.path = path;
this.synthwave = synthwave;
}

public Sound(String resource, String name, String path, boolean synthwave) {
this(Resource.format(resource), name, path, synthwave);
public Sound(String resource, String name, String path) {
this(Resource.format(resource), name, path);
}

public static Sound.Builder of() {
Expand All @@ -46,10 +44,6 @@ public String getPath() {
return path;
}

public boolean isSynthwave() {
return synthwave;
}

public void play() {
SoundManager.playSound(this);
}
Expand All @@ -66,7 +60,6 @@ public static class Builder {
private Resource res = null;
private String name = null;
private String path = null;
private boolean synthwave = false;

public Builder resource(Resource res) {
this.res = res;
Expand All @@ -88,17 +81,12 @@ public Builder path(String path) {
return this;
}

public Builder synthwave(boolean synthwave) {
this.synthwave = synthwave;
return this;
}

public Sound build() {
if (res == null || name == null || path == null) {
throw new IllegalArgumentException("res or name or path can't be null!");
}

return new Sound(res, name, path, synthwave);
return new Sound(res, name, path);
}

}
Expand Down
8 changes: 3 additions & 5 deletions src/main/java/net/op/sound/SoundManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import java.util.List;
import java.util.Random;
import java.util.logging.Logger;
import java.util.stream.Stream;

public class SoundManager {

Expand Down Expand Up @@ -32,10 +31,9 @@ public static void update() {

int r = (int) (System.currentTimeMillis() / 1000 % TIMEOUT);
if (r == 0) {
Stream<Sound> sounds = Tracks.get("Menu Sounds").getSounds().filter(sound -> !sound.isSynthwave());
List<Sound> soundList = sounds.toList();
int index = new Random().nextInt(soundList.size());
playSound(soundList.get(index));
List<Sound> sounds = Tracks.get("Menu Sounds").getSounds().toList();
int index = new Random().nextInt(sounds.size());
playSound(sounds.get(index));
}

}
Expand Down
2 changes: 0 additions & 2 deletions src/main/java/net/op/sound/Tracks.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,12 @@ public class Tracks {
.name("Menu 2")
.resource("opencraft.sound:menu_2")
.path("/menu2.wav")
.synthwave(false)
.build());

menu_sounds.add(Sound.of()
.name("Menu 3")
.resource("opencraft.sound:menu_3")
.path("/menu3.wav")
.synthwave(false)
.build());

menu = new Track("Menu Sounds", menu_sounds);
Expand Down

0 comments on commit 3f54c86

Please sign in to comment.