mirror of
https://github.com/songoda/SongodaCore.git
synced 2024-11-23 18:45:34 +01:00
add block method for compatible material lookup
This commit is contained in:
parent
f024b78043
commit
4578f40ffa
@ -6,6 +6,7 @@ import java.util.LinkedHashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
@ -1220,6 +1221,27 @@ public enum CompatibleMaterial {
|
||||
return m != null ? m : lookupMap.get(key + item.getDurability());
|
||||
}
|
||||
|
||||
/**
|
||||
* Lookup a Material by Block, corrected for legacy
|
||||
*
|
||||
* @param block block to check
|
||||
* @return LegacyMaterial or null if none found
|
||||
*/
|
||||
public static CompatibleMaterial getMaterial(Block block) {
|
||||
if (block == null) {
|
||||
return null;
|
||||
}
|
||||
Material mat = block.getType();
|
||||
if(mat == null) return null;
|
||||
else if (useLegacy) {
|
||||
LegacyMaterialBlockType legacyBlock = LegacyMaterialBlockType.getFromLegacy(mat.name());
|
||||
if (legacyBlock != null) {
|
||||
return lookupMap.get(legacyBlock.name());
|
||||
}
|
||||
}
|
||||
return lookupMap.get(mat.name());
|
||||
}
|
||||
|
||||
/**
|
||||
* Lookup a Block Material by its modern id name. <br />
|
||||
* This also can grab materials by their legacy, but only if there is no
|
||||
|
Loading…
Reference in New Issue
Block a user