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

Commit

Permalink
Add author flag in class Sound
Browse files Browse the repository at this point in the history
  • Loading branch information
CiroZDP committed Apr 26, 2024
1 parent 7fc81d6 commit e8c97c3
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 8 deletions.
27 changes: 19 additions & 8 deletions src/main/java/net/op/sound/Sound.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,18 @@ public class Sound {

private final Resource resource;
private final String name;
private final String author;
private final String path;

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

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

public static Sound.Builder of() {
Expand All @@ -39,6 +41,10 @@ public Resource getResource() {
public String getName() {
return name;
}

public String getAuthor() {
return author;
}

public String getPath() {
return path;
Expand All @@ -59,6 +65,7 @@ public static class Builder {

private Resource res = null;
private String name = null;
private String author = "Unknown";
private String path = null;

public Builder resource(Resource res) {
Expand All @@ -67,26 +74,30 @@ public Builder resource(Resource res) {
}

public Builder resource(String res) {
resource(Resource.format(res));
return this;
return resource(Resource.format(res));
}

public Builder name(String name) {
this.name = name;
return this;
}

public Builder author(String author) {
this.author = author;
return this;
}

public Builder path(String path) {
this.path = path;
return this;
}

public Sound build() {
if (res == null || name == null || path == null) {
throw new IllegalArgumentException("res or name or path can't be null!");
if (res == null || name == null || author == null || path == null) {
throw new IllegalArgumentException(String.format("Invalid %s constructor", Sound.class.getName()));
}

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

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

menu_sounds.add(Sound.of()
.name("Menu 3")
.resource("opencraft:sounds.menu_3")
.path("/newmusic/menu3.ogg")
.author("C418")
.build());

menu_sounds.add(Sound.of()
Expand Down

0 comments on commit e8c97c3

Please sign in to comment.