Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Bukkit Registry API where possible #2573

Merged
merged 1 commit into from
Jul 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@
import org.bstats.bukkit.Metrics;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.Registry;
import org.bukkit.Tag;
import org.bukkit.block.Biome;
import org.bukkit.command.BlockCommandSender;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
Expand Down Expand Up @@ -208,14 +208,14 @@ private void setupWorldData() {
@SuppressWarnings({ "unchecked" })
private void initializeRegistries() {
// Biome
for (Biome biome : Biome.values()) {
Registry.BIOME.forEach(biome -> {
if (!biome.name().equals("CUSTOM")) {
String key = biome.getKey().toString();
BiomeType.REGISTRY.register(key, new BiomeType(key));
}
}
});
// Block & Item
for (Material material : Material.values()) {
Registry.MATERIAL.forEach(material -> {
if (material.isBlock()) {
BlockType.REGISTRY.register(material.getKey().toString(), new BlockType(material.getKey().toString(), blockState -> {
// TODO Use something way less hacky than this.
Expand All @@ -242,16 +242,13 @@ private void initializeRegistries() {
if (material.isItem()) {
ItemType.REGISTRY.register(material.getKey().toString(), new ItemType(material.getKey().toString()));
}
}
});
// Entity
for (org.bukkit.entity.EntityType entityType : org.bukkit.entity.EntityType.values()) {
if (entityType == org.bukkit.entity.EntityType.UNKNOWN) {
// This doesn't have a key - skip it
continue;
}
Registry.ENTITY_TYPE.forEach(entityType -> {
String key = entityType.getKey().toString();
EntityType.REGISTRY.register(key, new EntityType(key));
}
});

// ... :|
GameModes.get("");
WeatherTypes.get("");
Expand Down