1
mirror of https://github.com/StarWishsama/Slimefun4.git synced 2024-09-20 03:35:51 +00:00

Hey unit tests, you work now, k pls?

This commit is contained in:
TheBusyBiscuit 2020-10-04 12:42:59 +02:00
parent c8d2bea162
commit 5753def8e9
3 changed files with 16 additions and 4 deletions

View File

@ -153,4 +153,10 @@ public class ItemSetting<T> {
}
}
@Override
public String toString() {
T currentValue = this.value != null ? this.value : defaultValue;
return getClass().getSimpleName() + " {" + getKey() + " = " + currentValue + " (default: " + getDefaultValue() + ")";
}
}

View File

@ -143,10 +143,13 @@ public class ClimbingPick extends SimpleSlimefunItem<ItemUseHandler> implements
*/
public double getClimbingSpeed(@Nonnull ItemStack item, @Nonnull Material type) {
double speed = getClimbingSpeed(type);
int efficiencyLevel = item.getEnchantmentLevel(Enchantment.DIG_SPEED);
if (speed > 0 && efficiencyLevel > 0) {
speed += efficiencyLevel * EFFICIENCY_MODIFIER;
if (speed > 0) {
int efficiencyLevel = item.getEnchantmentLevel(Enchantment.DIG_SPEED);
if (efficiencyLevel > 0) {
speed += efficiencyLevel * EFFICIENCY_MODIFIER;
}
}
return speed;

View File

@ -56,6 +56,7 @@ class TestClimbingPick implements SlimefunItemTest<ClimbingPick> {
@Override
public ClimbingPick registerSlimefunItem(SlimefunPlugin plugin, String id) {
try {
TestUtilities.registerDefaultTags(server);
SlimefunTag.CLIMBING_PICK_WEAK_SURFACES.reload();
SlimefunTag.CLIMBING_PICK_STRONG_SURFACES.reload();
}
@ -63,7 +64,7 @@ class TestClimbingPick implements SlimefunItemTest<ClimbingPick> {
Assertions.fail(e);
}
SlimefunItemStack item = new SlimefunItemStack(id, Material.IRON_PICKAXE, "&5Test Pick");
SlimefunItemStack item = new SlimefunItemStack(id, Material.IRON_PICKAXE, "&5Test Pick", id);
ClimbingPick pick = new ClimbingPick(TestUtilities.getCategory(plugin, "climbing_pick"), item, RecipeType.NULL, new ItemStack[9]) {
@Override
@ -91,6 +92,7 @@ class TestClimbingPick implements SlimefunItemTest<ClimbingPick> {
}
private static Stream<Arguments> getStrongSurfaces() throws TagMisconfigurationException {
TestUtilities.registerDefaultTags(server);
SlimefunTag.CLIMBING_PICK_STRONG_SURFACES.reload();
return SlimefunTag.CLIMBING_PICK_STRONG_SURFACES.getValues().stream().map(Arguments::of);
}
@ -108,6 +110,7 @@ class TestClimbingPick implements SlimefunItemTest<ClimbingPick> {
}
private static Stream<Arguments> getWeakSurfaces() throws TagMisconfigurationException {
TestUtilities.registerDefaultTags(server);
SlimefunTag.CLIMBING_PICK_WEAK_SURFACES.reload();
return SlimefunTag.CLIMBING_PICK_WEAK_SURFACES.getValues().stream().map(Arguments::of);
}