use of forestry.core.commands.SpeciesNotFoundException in project ForestryMC by ForestryMC.
the class CommandBeeGive method getBeeGenome.
private static IBeeGenome getBeeGenome(String speciesName) throws SpeciesNotFoundException, TemplateNotFoundException {
IAlleleBeeSpecies species = null;
for (String uid : AlleleManager.alleleRegistry.getRegisteredAlleles().keySet()) {
if (!uid.equals(speciesName)) {
continue;
}
IAllele allele = AlleleManager.alleleRegistry.getAllele(uid);
if (allele instanceof IAlleleBeeSpecies) {
species = (IAlleleBeeSpecies) allele;
break;
}
}
if (species == null) {
for (IAllele allele : AlleleManager.alleleRegistry.getRegisteredAlleles().values()) {
if (allele instanceof IAlleleBeeSpecies && allele.getAlleleName().equals(speciesName)) {
species = (IAlleleBeeSpecies) allele;
break;
}
}
}
if (species == null) {
throw new SpeciesNotFoundException(speciesName);
}
IAllele[] template = BeeManager.beeRoot.getTemplate(species);
return BeeManager.beeRoot.templateAsGenome(template);
}
use of forestry.core.commands.SpeciesNotFoundException in project ForestryMC by ForestryMC.
the class TreeGenHelper method getTreeGenome.
private static ITreeGenome getTreeGenome(String speciesName) throws SpeciesNotFoundException, TemplateNotFoundException {
IAlleleTreeSpecies species = null;
for (String uid : AlleleManager.alleleRegistry.getRegisteredAlleles().keySet()) {
if (!uid.equals(speciesName)) {
continue;
}
IAllele allele = AlleleManager.alleleRegistry.getAllele(uid);
if (allele instanceof IAlleleTreeSpecies) {
species = (IAlleleTreeSpecies) allele;
break;
}
}
if (species == null) {
for (IAllele allele : AlleleManager.alleleRegistry.getRegisteredAlleles().values()) {
if (allele instanceof IAlleleTreeSpecies && allele.getAlleleName().replaceAll("\\s", "").equals(speciesName)) {
species = (IAlleleTreeSpecies) allele;
break;
}
}
}
if (species == null) {
throw new SpeciesNotFoundException(speciesName);
}
IAllele[] template = TreeManager.treeRoot.getTemplate(species);
return TreeManager.treeRoot.templateAsGenome(template);
}
Aggregations