Skip to content

Commit

Permalink
[Bukkit] Stop using EnumMap for potential registry types
Browse files Browse the repository at this point in the history
Biome broke in 1.21.3, Material could break in the future
  • Loading branch information
octylFractal committed Nov 1, 2024
1 parent 2655431 commit 9b4d341
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,6 @@
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;

import java.util.Collections;
import java.util.EnumMap;
import java.util.Locale;
import java.util.Map;
import java.util.Objects;
Expand Down Expand Up @@ -362,9 +360,7 @@ public static GameMode adapt(org.bukkit.GameMode gameMode) {
return GameModes.get(gameMode.name().toLowerCase(Locale.ROOT));
}

private static final Map<Biome, BiomeType> biomeBiomeTypeCache = Collections.synchronizedMap(
new EnumMap<>(Biome.class)
);
private static final Map<Biome, BiomeType> biomeBiomeTypeCache = new ConcurrentHashMap<>();
private static final Map<BiomeType, Biome> biomeTypeBiomeCache = new ConcurrentHashMap<>();

/**
Expand Down Expand Up @@ -408,12 +404,8 @@ public static org.bukkit.entity.EntityType adapt(EntityType entityType) {
return Registry.ENTITY_TYPE.get(entityKey);
}

private static final Map<Material, BlockType> materialBlockTypeCache = Collections.synchronizedMap(
new EnumMap<>(Material.class)
);
private static final Map<Material, ItemType> materialItemTypeCache = Collections.synchronizedMap(
new EnumMap<>(Material.class)
);
private static final Map<Material, BlockType> materialBlockTypeCache = new ConcurrentHashMap<>();
private static final Map<Material, ItemType> materialItemTypeCache = new ConcurrentHashMap<>();

/**
* Converts a Material to a BlockType.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@
import com.sk89q.worldedit.world.registry.PassthroughBlockMaterial;
import org.bukkit.Material;

import java.util.EnumMap;
import java.util.HashMap;
import java.util.Map;
import java.util.OptionalInt;
import javax.annotation.Nullable;

public class BukkitBlockRegistry extends BundledBlockRegistry {
private final Map<Material, BukkitBlockMaterial> materialMap = new EnumMap<>(Material.class);
private final Map<Material, BukkitBlockMaterial> materialMap = new HashMap<>();

@Override
public Component getRichName(BlockType blockType) {
Expand Down

0 comments on commit 9b4d341

Please sign in to comment.