9
0
mirror of https://github.com/VolmitSoftware/Iris.git synced 2026-01-02 13:56:40 +00:00

Delete fbd

This commit is contained in:
Daniel Mills
2020-10-28 00:29:37 -04:00
parent 9e062acafb
commit 6a03b4b125
34 changed files with 0 additions and 175 deletions

View File

@@ -1,142 +0,0 @@
package com.volmit.iris.util;
import org.bukkit.Material;
import org.bukkit.block.data.BlockData;
public class FastBlockData
{
private static final KMap<Material, BlockData> defaultBlockData = new KMap<>();
private BlockData blockData;
private Material type;
private FastBlockData(BlockData d)
{
this.blockData = d;
this.type = null;
optimize();
}
private FastBlockData(Material m)
{
this.type = m;
this.blockData = null;
}
public Material getMaterial()
{
return type != null ? type : blockData.getMaterial();
}
public static FastBlockData of(Material type)
{
return new FastBlockData(type);
}
public static FastBlockData of(BlockData type)
{
return new FastBlockData(type);
}
public Material getType()
{
return type != null ? type : blockData.getMaterial();
}
public FastBlockData optimize()
{
if(hasBlockData())
{
BlockData f = getDefaultBlockData(getMaterial());
if(f.hashCode() == getBlockData().hashCode())
{
type = getBlockData().getMaterial();
blockData = null;
return this;
}
}
return this;
}
private static BlockData getDefaultBlockData(Material type)
{
return defaultBlockData.compute(type, (k, v) -> v != null ? v : type.createBlockData());
}
public boolean hasBlockData()
{
return blockData != null;
}
public BlockData createBlockData()
{
if(blockData != null)
{
return blockData;
}
return type.createBlockData();
}
public BlockData getBlockData()
{
if(blockData == null)
{
blockData = createBlockData();
}
return blockData;
}
@Override
public int hashCode()
{
if(hasBlockData())
{
return getBlockData().hashCode();
}
return getType().hashCode();
}
public boolean matEquals(FastBlockData obj)
{
return getMaterial().equals(obj.getMaterial());
}
@Override
public boolean equals(Object obj)
{
if(this == obj)
{
return true;
}
if(obj == null)
{
return false;
}
if(getClass() != obj.getClass())
{
return false;
}
FastBlockData other = (FastBlockData) obj;
if(other.hashCode() == hashCode())
{
return true;
}
return false;
}
public FastBlockData clone()
{
return hasBlockData() ? new FastBlockData(blockData.clone()) : new FastBlockData(getType());
}
public boolean matches(FastBlockData data)
{
return (data.hasBlockData() && hasBlockData() && getBlockData().matches(data.getBlockData())) || (!data.hasBlockData() && !hasBlockData() && getType().equals(data.getType()));
}
}