Skip to content

Commit

Permalink
Fix compilation error in test sources.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jannyboy11 committed Nov 15, 2024
1 parent 1a4fbfd commit 161c985
Showing 1 changed file with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@

import java.util.Iterator;
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.stream.Stream;

import org.bukkit.Keyed;
import org.bukkit.NamespacedKey;
import org.bukkit.Registry;
import org.jetbrains.annotations.NotNull;

public class FakeRegistry<T extends Keyed> implements Registry<T> {

Expand All @@ -21,6 +23,17 @@ public T get(NamespacedKey namespacedKey) {
return map.get(namespacedKey);
}

@NotNull
@Override
public T getOrThrow(@NotNull NamespacedKey namespacedKey) {
T item = map.get(namespacedKey);
if (item == null) {
throw new NoSuchElementException(namespacedKey.toString());
} else {
return item;
}
}

@Override
public Stream<T> stream() {
return map.values().stream();
Expand Down

0 comments on commit 161c985

Please sign in to comment.