mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-12-23 09:47:38 +00:00
Using an array instead of an EnumMap isn't necessary here
This commit is contained in:
parent
995e1261e5
commit
240a817e6e
@ -27,6 +27,7 @@ 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;
|
||||||
|
|
||||||
@ -38,7 +39,7 @@ import java.util.OptionalInt;
|
|||||||
|
|
||||||
public class BukkitBlockRegistry extends BundledBlockRegistry {
|
public class BukkitBlockRegistry extends BundledBlockRegistry {
|
||||||
|
|
||||||
private BukkitBlockMaterial[] materialMap;
|
private Map<Material, BukkitBlockMaterial> materialMap = new EnumMap<>(Material.class);
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
@ -52,15 +53,17 @@ public class BukkitBlockRegistry extends BundledBlockRegistry {
|
|||||||
if (mat == null) {
|
if (mat == null) {
|
||||||
return new PassthroughBlockMaterial(null);
|
return new PassthroughBlockMaterial(null);
|
||||||
}
|
}
|
||||||
if (materialMap == null) {
|
return materialMap.computeIfAbsent(mat, material -> new BukkitBlockMaterial(BukkitBlockRegistry.super.getMaterial(blockType), material));
|
||||||
materialMap = new BukkitBlockMaterial[Material.values().length];
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
public Map<String, ? extends Property<?>> getProperties(BlockType blockType) {
|
||||||
|
BukkitImplAdapter adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter();
|
||||||
|
if (adapter != null) {
|
||||||
|
return adapter.getProperties(blockType);
|
||||||
}
|
}
|
||||||
BukkitBlockMaterial result = materialMap[mat.ordinal()];
|
return super.getProperties(blockType);
|
||||||
if (result == null) {
|
|
||||||
result = new BukkitBlockMaterial(BukkitBlockRegistry.super.getMaterial(blockType), mat);
|
|
||||||
materialMap[mat.ordinal()] = result;
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@ -73,7 +76,6 @@ 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) {
|
||||||
@ -81,15 +83,6 @@ 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 {
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user