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(":");
|
String[] split = conversions.split(":");
|
||||||
double convChance = Double.parseDouble(split[0]);
|
double convChance = Double.parseDouble(split[0]);
|
||||||
Material newMaterial = Material.valueOf(split[1]);
|
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);
|
b.addConvBlocks(oldMaterial, newMaterial, convChance, localMaterial);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
@ -199,7 +202,10 @@ public class RecipeManager {
|
||||||
Material oldMaterial = Material.valueOf(split[0].toUpperCase());
|
Material oldMaterial = Material.valueOf(split[0].toUpperCase());
|
||||||
double convChance = Double.parseDouble(split[1]);
|
double convChance = Double.parseDouble(split[1]);
|
||||||
Material newMaterial = Material.valueOf(split[2]);
|
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);
|
b.addConvBlocks(oldMaterial, newMaterial, convChance, localMaterial);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
addon.logError("Could not parse " + oldMat);
|
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
|
@Test
|
||||||
public void testAddMobs() {
|
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
|
@Test
|
||||||
public void testAddMobsOver100Percent() {
|
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
|
@Test
|
||||||
public void testAddMobsOver100PercentDouble() {
|
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
|
@Test
|
||||||
public void testAddPlants() {
|
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
|
@Test
|
||||||
public void testAddPlantsOver100Percent() {
|
public void testAddPlantsOver100Percent() {
|
||||||
|
@ -267,25 +267,6 @@ public class BiomeRecipeTest {
|
||||||
verify(b).setType(Material.CLAY);
|
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)}.
|
* 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);
|
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)}.
|
* Test method for {@link world.bentobox.greenhouses.greenhouse.BiomeRecipe#convertBlock(org.bukkit.block.Block)}.
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue