mirror of
https://github.com/PaperMC/Paper.git
synced 2025-03-19 18:19:24 +01:00
#1245: Add a stream method to Registry to make it easier to use and to avoid unnecessary wrapping
By: DerFrZocker <derrieple@gmail.com>
This commit is contained in:
parent
4e2ef19474
commit
2402d5edb4
@ -25,6 +25,7 @@ import org.bukkit.generator.structure.Structure;
|
||||
import org.bukkit.generator.structure.StructureType;
|
||||
import org.bukkit.inventory.meta.trim.TrimMaterial;
|
||||
import org.bukkit.inventory.meta.trim.TrimPattern;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class CraftRegistry<B extends Keyed, M> implements Registry<B> {
|
||||
|
||||
@ -92,9 +93,15 @@ public class CraftRegistry<B extends Keyed, M> implements Registry<B> {
|
||||
return bukkit;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Stream<B> stream() {
|
||||
return minecraftRegistry.keySet().stream().map(minecraftKey -> get(CraftNamespacedKey.fromMinecraft(minecraftKey)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<B> iterator() {
|
||||
return values().iterator();
|
||||
return stream().iterator();
|
||||
}
|
||||
|
||||
public B createBukkit(NamespacedKey namespacedKey, M minecraft) {
|
||||
@ -104,8 +111,4 @@ public class CraftRegistry<B extends Keyed, M> implements Registry<B> {
|
||||
|
||||
return minecraftToBukkit.apply(namespacedKey, minecraft);
|
||||
}
|
||||
|
||||
public Stream<B> values() {
|
||||
return minecraftRegistry.keySet().stream().map(minecraftKey -> get(CraftNamespacedKey.fromMinecraft(minecraftKey)));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user