Skip to content

Commit

Permalink
Warn when requesting a missing sprite
Browse files Browse the repository at this point in the history
  • Loading branch information
SmylerMC committed Jun 8, 2024
1 parent d2fff66 commit 7bf37c7
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import static java.util.Objects.requireNonNull;
import static net.smyler.smylib.Preconditions.checkArgument;
import static net.smyler.smylib.Preconditions.checkState;
import static net.smyler.smylib.SmyLib.getLogger;

public class SpriteLibrary {

Expand Down Expand Up @@ -45,11 +46,15 @@ public void registerSprite(@NotNull String identifier, @NotNull Sprite sprite) {
}

public Sprite getSprite(@NotNull Identifier identifier) {
return this.registered.get(requireNonNull(identifier));
Sprite sprite = this.readOnly.get(identifier);
if (sprite == null) {
getLogger().warn("Tried to get missing sprite for identifier {}", identifier);
}
return sprite;
}

public Sprite getSprite(@NotNull String identifier) {
return this.registered.get(Identifier.parse(identifier));
return this.getSprite(Identifier.parse(identifier));
}

/**
Expand Down

0 comments on commit 7bf37c7

Please sign in to comment.