Skip to content

Commit

Permalink
Merge pull request #42 from SkolkovoLab/pr/to-builder
Browse files Browse the repository at this point in the history
add some missing toBuilder() methods
  • Loading branch information
yusshu committed Dec 29, 2023
2 parents 1bc8834 + 14634dd commit db65d6f
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 0 deletions.
10 changes: 10 additions & 0 deletions api/src/main/java/team/unnamed/creative/sound/SoundEntry.java
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,16 @@ static SoundEntry event(final @NotNull @Subst("minecraft:sound") String name, fi
*/
boolean allDefault();

/**
* Converts this sound entry instance to its builder type,
* with all the properties already set
*
* @return The created builder
* @since 1.6.0
*/
@Contract("-> new")
@NotNull Builder toBuilder();

/**
* Specifies the type of {@link SoundEntry}
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,11 @@ public boolean allDefault() {
&& type == DEFAULT_TYPE;
}

@Override
public @NotNull Builder toBuilder() {
return SoundEntry.soundEntry().key(key).volume(volume).pitch(pitch).weight(weight).stream(stream).attenuationDistance(attenuationDistance).preload(preload).type(type);
}

@Override
public @NotNull Stream<? extends ExaminableProperty> examinableProperties() {
return Stream.of(
Expand Down
10 changes: 10 additions & 0 deletions api/src/main/java/team/unnamed/creative/sound/SoundEvent.java
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,16 @@ default void addTo(final @NotNull ResourceContainer resourceContainer) {
resourceContainer.soundEvent(this);
}

/**
* Converts this sound event instance to its builder type,
* with all the properties already set
*
* @return The created builder
* @since 1.6.0
*/
@Contract("-> new")
@NotNull Builder toBuilder();

/**
* Builder implementation for ease the
* construction of {@link SoundEvent}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ public boolean replace() {
return sounds;
}

@Override
public @NotNull Builder toBuilder() {
return SoundEvent.soundEvent().key(key).replace(replace).subtitle(subtitle).sounds(sounds);
}

@Override
public @NotNull Stream<? extends ExaminableProperty> examinableProperties() {
return Stream.of(
Expand Down

0 comments on commit db65d6f

Please sign in to comment.