3
0
Mirror von https://github.com/IntellectualSites/FastAsyncWorldEdit.git synchronisiert 2024-11-08 04:20:06 +01:00

Revert "Using an array instead of an EnumMap isn't necessary here"

This reverts commit 240a817e
Dieser Commit ist enthalten in:
MattBDev 2020-01-29 16:03:02 -05:00
Ursprung df60e50c96
Commit d381617f11

Datei anzeigen

@ -27,7 +27,6 @@ import com.sk89q.worldedit.world.block.BlockTypes;
import com.sk89q.worldedit.world.registry.BlockMaterial; import com.sk89q.worldedit.world.registry.BlockMaterial;
import com.sk89q.worldedit.world.registry.BundledBlockRegistry; import com.sk89q.worldedit.world.registry.BundledBlockRegistry;
import com.sk89q.worldedit.world.registry.PassthroughBlockMaterial; import com.sk89q.worldedit.world.registry.PassthroughBlockMaterial;
import java.util.EnumMap;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.data.BlockData; import org.bukkit.block.data.BlockData;
@ -39,7 +38,7 @@ import java.util.OptionalInt;
public class BukkitBlockRegistry extends BundledBlockRegistry { public class BukkitBlockRegistry extends BundledBlockRegistry {
private Map<Material, BukkitBlockMaterial> materialMap = new EnumMap<>(Material.class); private BukkitBlockMaterial[] materialMap;
@Nullable @Nullable
@Override @Override
@ -53,17 +52,15 @@ public class BukkitBlockRegistry extends BundledBlockRegistry {
if (mat == null) { if (mat == null) {
return new PassthroughBlockMaterial(null); return new PassthroughBlockMaterial(null);
} }
return materialMap.computeIfAbsent(mat, material -> new BukkitBlockMaterial(BukkitBlockRegistry.super.getMaterial(blockType), material)); if (materialMap == null) {
materialMap = new BukkitBlockMaterial[Material.values().length];
} }
BukkitBlockMaterial result = materialMap[mat.ordinal()];
@Nullable if (result == null) {
@Override result = new BukkitBlockMaterial(BukkitBlockRegistry.super.getMaterial(blockType), mat);
public Map<String, ? extends Property<?>> getProperties(BlockType blockType) { materialMap[mat.ordinal()] = result;
BukkitImplAdapter adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter();
if (adapter != null) {
return adapter.getProperties(blockType);
} }
return super.getProperties(blockType); return result;
} }
@Nullable @Nullable
@ -76,6 +73,7 @@ public class BukkitBlockRegistry extends BundledBlockRegistry {
} }
return super.getMaterial(state); return super.getMaterial(state);
} }
@Override @Override
public OptionalInt getInternalBlockStateId(BlockState state) { public OptionalInt getInternalBlockStateId(BlockState state) {
if (WorldEditPlugin.getInstance().getBukkitImplAdapter() != null) { if (WorldEditPlugin.getInstance().getBukkitImplAdapter() != null) {
@ -83,6 +81,15 @@ public class BukkitBlockRegistry extends BundledBlockRegistry {
} }
return OptionalInt.empty(); return OptionalInt.empty();
} }
@Nullable
@Override
public Map<String, ? extends Property<?>> getProperties(BlockType blockType) {
BukkitImplAdapter adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter();
if (adapter != null) {
return adapter.getProperties(blockType);
}
return super.getProperties(blockType);
}
public static class BukkitBlockMaterial extends PassthroughBlockMaterial { public static class BukkitBlockMaterial extends PassthroughBlockMaterial {