mirror of
https://github.com/alexcrea/CustomAnvil.git
synced 2026-06-23 16:16:17 +02:00
v1.7.1 (#48)
Fix getting cost for color renaming causing null pointer exception when inventory name is null (Fix #47) Add safety when executing dependency handling code
This commit is contained in:
parent
5f557e3d49
commit
33474c379a
7 changed files with 130 additions and 34 deletions
|
|
@ -1,11 +1,15 @@
|
|||
package xyz.alexcrea.cuanvil.anvil;
|
||||
|
||||
import io.delilaheve.util.ConfigOptions;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.event.inventory.InventoryType;
|
||||
import org.bukkit.inventory.AnvilInventory;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.inventory.meta.Repairable;
|
||||
import org.eclipse.aether.util.ConfigUtils;
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
|
|
@ -32,8 +36,9 @@ public class AnvilFuseTests extends SharedCustomAnvilTest {
|
|||
AnvilFuseTests.anvil = (AnvilInventory) anvil;
|
||||
player.openInventory(anvil);
|
||||
|
||||
ConfigHolder.DEFAULT_CONFIG.getConfig().set("debug_log", true);
|
||||
ConfigHolder.DEFAULT_CONFIG.getConfig().set("debug_log_verbose", true);
|
||||
ConfigHolder.DEFAULT_CONFIG.getConfig().set(ConfigOptions.DEBUG_LOGGING, true);
|
||||
ConfigHolder.DEFAULT_CONFIG.getConfig().set(ConfigOptions.VERBOSE_DEBUG_LOGGING, true);
|
||||
ConfigHolder.DEFAULT_CONFIG.getConfig().set(ConfigOptions.ALLOW_COLOR_CODE, true); // For rename test
|
||||
}
|
||||
|
||||
@BeforeEach
|
||||
|
|
@ -100,4 +105,23 @@ public class AnvilFuseTests extends SharedCustomAnvilTest {
|
|||
AnvilFuseTestUtil.executeAnvilTest(anvil, player, data);
|
||||
}
|
||||
|
||||
// Note: currently anvil can only have null name. maybe handle differently later
|
||||
@Test
|
||||
public void nullNameResetTest(){
|
||||
ItemStack base = new ItemStack(Material.NETHERITE_SWORD);
|
||||
ItemStack expected = base.clone();
|
||||
|
||||
ItemMeta meta = expected.getItemMeta();
|
||||
meta.displayName(Component.text("test"));
|
||||
base.setItemMeta(meta);
|
||||
|
||||
AnvilFuseTestData data = new AnvilFuseTestData(
|
||||
base, null,
|
||||
expected, expected, null
|
||||
// TODO add expected price
|
||||
);
|
||||
|
||||
AnvilFuseTestUtil.executeAnvilTest(anvil, player, data);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,4 +36,19 @@ public record AnvilFuseTestData(
|
|||
this(leftItem, rightItem, expectedResult, null
|
||||
);
|
||||
}
|
||||
|
||||
public AnvilFuseTestData(
|
||||
@Nullable ItemStack leftItem,
|
||||
@Nullable ItemStack rightItem,
|
||||
@Nullable ItemStack expectedResult,
|
||||
|
||||
@Nullable ItemStack expectedAfterLeftPlaced,
|
||||
@Nullable ItemStack expectedAfterRightPlaced
|
||||
){
|
||||
this(leftItem, rightItem,
|
||||
expectedResult, expectedAfterLeftPlaced, expectedAfterRightPlaced,
|
||||
null, null, null
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue