mirror of
https://github.com/BentoBoxWorld/Greenhouses.git
synced 2025-01-20 15:11:38 +01:00
Allow omitting LocalMaterial in biomes.yml if you don't want a local blo… (#79)
This commit is contained in:
parent
db3054ab0c
commit
d1d3004262
@ -182,7 +182,10 @@ public class RecipeManager {
|
||||
String[] split = conversions.split(":");
|
||||
double convChance = Double.parseDouble(split[0]);
|
||||
Material newMaterial = Material.valueOf(split[1]);
|
||||
Material localMaterial = Material.valueOf(split[2]);
|
||||
Material localMaterial = null;
|
||||
if(split.length > 2) {
|
||||
localMaterial = Material.valueOf(split[2]);
|
||||
}
|
||||
b.addConvBlocks(oldMaterial, newMaterial, convChance, localMaterial);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
@ -199,7 +202,10 @@ public class RecipeManager {
|
||||
Material oldMaterial = Material.valueOf(split[0].toUpperCase());
|
||||
double convChance = Double.parseDouble(split[1]);
|
||||
Material newMaterial = Material.valueOf(split[2]);
|
||||
Material localMaterial = Material.valueOf(split[3]);
|
||||
Material localMaterial = null;
|
||||
if(split.length > 3) {
|
||||
localMaterial = Material.valueOf(split[3]);
|
||||
}
|
||||
b.addConvBlocks(oldMaterial, newMaterial, convChance, localMaterial);
|
||||
} catch (Exception e) {
|
||||
addon.logError("Could not parse " + oldMat);
|
||||
|
@ -156,7 +156,7 @@ public class BiomeRecipeTest {
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link world.bentobox.greenhouses.greenhouse.BiomeRecipe#addMobs(org.bukkit.entity.EntityType, int, org.bukkit.Material)}.
|
||||
* Test method for {@link world.bentobox.greenhouses.greenhouse.BiomeRecipe#addMobs(org.bukkit.entity.EntityType, double, org.bukkit.Material)}.
|
||||
*/
|
||||
@Test
|
||||
public void testAddMobs() {
|
||||
@ -168,7 +168,7 @@ public class BiomeRecipeTest {
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link world.bentobox.greenhouses.greenhouse.BiomeRecipe#addMobs(org.bukkit.entity.EntityType, int, org.bukkit.Material)}.
|
||||
* Test method for {@link world.bentobox.greenhouses.greenhouse.BiomeRecipe#addMobs(org.bukkit.entity.EntityType, double, org.bukkit.Material)}.
|
||||
*/
|
||||
@Test
|
||||
public void testAddMobsOver100Percent() {
|
||||
@ -182,7 +182,7 @@ public class BiomeRecipeTest {
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link world.bentobox.greenhouses.greenhouse.BiomeRecipe#addMobs(org.bukkit.entity.EntityType, int, org.bukkit.Material)}.
|
||||
* Test method for {@link world.bentobox.greenhouses.greenhouse.BiomeRecipe#addMobs(org.bukkit.entity.EntityType, double, org.bukkit.Material)}.
|
||||
*/
|
||||
@Test
|
||||
public void testAddMobsOver100PercentDouble() {
|
||||
@ -195,7 +195,7 @@ public class BiomeRecipeTest {
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link world.bentobox.greenhouses.greenhouse.BiomeRecipe#addPlants(org.bukkit.Material, int, org.bukkit.Material)}.
|
||||
* Test method for {@link world.bentobox.greenhouses.greenhouse.BiomeRecipe#addPlants(org.bukkit.Material, double, org.bukkit.Material)}.
|
||||
*/
|
||||
@Test
|
||||
public void testAddPlants() {
|
||||
@ -207,7 +207,7 @@ public class BiomeRecipeTest {
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link world.bentobox.greenhouses.greenhouse.BiomeRecipe#addPlants(org.bukkit.Material, int, org.bukkit.Material)}.
|
||||
* Test method for {@link world.bentobox.greenhouses.greenhouse.BiomeRecipe#addPlants(org.bukkit.Material, double, org.bukkit.Material)}.
|
||||
*/
|
||||
@Test
|
||||
public void testAddPlantsOver100Percent() {
|
||||
@ -267,25 +267,6 @@ public class BiomeRecipeTest {
|
||||
verify(b).setType(Material.CLAY);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link world.bentobox.greenhouses.greenhouse.BiomeRecipe#convertBlock(org.bukkit.block.Block)}.
|
||||
*/
|
||||
@Test
|
||||
public void testConvertBlockNotInGreenhouse() {
|
||||
// Setup
|
||||
this.testAddConvBlocks();
|
||||
// Mock
|
||||
Block b = mock(Block.class);
|
||||
when(b.getType()).thenReturn(Material.SAND);
|
||||
Block ab = mock(Block.class);
|
||||
when(ab.getType()).thenReturn(Material.WATER);
|
||||
when(b.getRelative(any())).thenReturn(ab);
|
||||
when(ab.getLocation()).thenReturn(location);
|
||||
when(gh.contains(any())).thenReturn(false);
|
||||
br.convertBlock(b);
|
||||
verify(b, never()).setType(any());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link world.bentobox.greenhouses.greenhouse.BiomeRecipe#convertBlock(org.bukkit.block.Block)}.
|
||||
*/
|
||||
@ -315,6 +296,26 @@ public class BiomeRecipeTest {
|
||||
verify(b, never()).setType(Material.CLAY);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link world.bentobox.greenhouses.greenhouse.BiomeRecipe#convertBlock(org.bukkit.block.Block)}.
|
||||
*/
|
||||
@Test
|
||||
public void testConvertBlockNoLocalBlock() {
|
||||
// Setup
|
||||
Material oldMaterial = Material.SAND;
|
||||
Material newMaterial = Material.CLAY;
|
||||
double convChance = 100D;
|
||||
br.addConvBlocks(oldMaterial, newMaterial, convChance, null);
|
||||
|
||||
// Mock
|
||||
Block b = mock(Block.class);
|
||||
when(b.getType()).thenReturn(Material.SAND);
|
||||
br.convertBlock(b);
|
||||
|
||||
verify(b, never()).getRelative(any());
|
||||
verify(b).setType(Material.CLAY);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link world.bentobox.greenhouses.greenhouse.BiomeRecipe#convertBlock(org.bukkit.block.Block)}.
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user