Skip to content

Commit

Permalink
Use Bukkit Registry API where possible
Browse files Browse the repository at this point in the history
  • Loading branch information
me4502 committed Jul 7, 2024
1 parent f31c2e6 commit 3fc4b2f
Showing 1 changed file with 8 additions and 11 deletions.
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

0 comments on commit 3fc4b2f

Please sign in to comment.