Skip to content

Commit

Permalink
Added getRepeating method to AnimationHandler (#28)
Browse files Browse the repository at this point in the history
Added getRepeating method to get the animation looping on the background when using playOnce(..., false, ...)
  • Loading branch information
Lukadcf authored Oct 15, 2024
1 parent 002c9f6 commit ec6926f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package net.worldseed.multipart.animations;

import com.google.gson.JsonElement;
import org.jetbrains.annotations.Nullable;

import java.util.Map;

Expand All @@ -26,7 +27,6 @@ public interface AnimationHandler {
void stopRepeat(String animation) throws IllegalArgumentException;



/**
* Play an animation once
*
Expand Down Expand Up @@ -56,7 +56,15 @@ public interface AnimationHandler {
*
* @return current animation
*/
String getPlaying();
@Nullable String getPlaying();


/**
* Get the current repeating animation
*
* @return current repeating animation
*/
@Nullable String getRepeating();

Map<String, Integer> animationPriorities();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import net.minestom.server.timer.TaskSchedule;
import net.worldseed.multipart.GenericModel;
import net.worldseed.multipart.ModelLoader;
import org.jetbrains.annotations.Nullable;

import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
Expand Down Expand Up @@ -238,8 +239,14 @@ public void destroy() {
this.task.cancel();
}

public String getPlaying() {
@Override
public @Nullable String getPlaying() {
if (this.playingOnce != null) return this.playingOnce;
return getRepeating();
}

@Override
public @Nullable String getRepeating() {
var playing = this.repeating.firstEntry();
return playing != null ? playing.getValue().name() : null;
}
Expand Down

0 comments on commit ec6926f

Please sign in to comment.