From 2ad40ae3d003a319ede9abb8e28857cc1e360d45 Mon Sep 17 00:00:00 2001 From: Fulminazzo Date: Sat, 13 Apr 2024 09:35:28 +0200 Subject: [PATCH] Updated PersistentItem references --- .../it/angrybear/yagl/items/BukkitItemTest.java | 2 +- .../angrybear/yagl/items/PersistentItemTest.java | 12 ++++++------ .../yagl/listeners/PersistentListenerTest.java | 16 ++++++++-------- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/item/bukkit/src/test/java/it/angrybear/yagl/items/BukkitItemTest.java b/item/bukkit/src/test/java/it/angrybear/yagl/items/BukkitItemTest.java index 83f3abc9..2acfea98 100644 --- a/item/bukkit/src/test/java/it/angrybear/yagl/items/BukkitItemTest.java +++ b/item/bukkit/src/test/java/it/angrybear/yagl/items/BukkitItemTest.java @@ -130,7 +130,7 @@ private static Item[] testItems() { mockItem(Item.newRecipeItem()), mockItem(BukkitItem.newItem()), mockItem(BukkitItem.newRecipeItem()), - mockItem(new PersistentItem()) + mockItem(PersistentItem.newItem()) }; } diff --git a/item/bukkit/src/test/java/it/angrybear/yagl/items/PersistentItemTest.java b/item/bukkit/src/test/java/it/angrybear/yagl/items/PersistentItemTest.java index 12cc8c1f..f17290c9 100644 --- a/item/bukkit/src/test/java/it/angrybear/yagl/items/PersistentItemTest.java +++ b/item/bukkit/src/test/java/it/angrybear/yagl/items/PersistentItemTest.java @@ -24,7 +24,7 @@ void setUp() { @Test void testNullInteractAction() { - PersistentItem persistentItem = new PersistentItem("stone"); + PersistentItem persistentItem = PersistentItem.newItem("stone"); Player player = mock(Player.class); ItemStack itemStack = mock(ItemStack.class); assertDoesNotThrow(() -> persistentItem.interact(player, itemStack, Action.LEFT_CLICK_AIR)); @@ -32,7 +32,7 @@ void testNullInteractAction() { @Test void testNullClickAction() { - PersistentItem persistentItem = new PersistentItem("stone"); + PersistentItem persistentItem = PersistentItem.newItem("stone"); Player player = mock(Player.class); ItemStack itemStack = mock(ItemStack.class); assertDoesNotThrow(() -> persistentItem.click(player, itemStack, ClickType.DOUBLE_CLICK)); @@ -43,7 +43,7 @@ void testClearPersistentItem() { // Clear previous PersistentItem.clearPersistentItems(); - PersistentItem persistentItem = new PersistentItem(Material.STONE); + PersistentItem persistentItem = PersistentItem.newItem(Material.STONE); ItemStack itemStack = persistentItem.create(); PersistentItem.clearPersistentItems(); @@ -53,7 +53,7 @@ void testClearPersistentItem() { @Test void testGetPersistentItem() { BukkitUtils.setupEnchantments(); - PersistentItem expected = new PersistentItem(Material.DIAMOND_SWORD, 1) + PersistentItem expected = PersistentItem.newItem(Material.DIAMOND_SWORD, 1) .addLore("Extremely deep lore").setDisplayName("Cool sword") .addEnchantment("flame", 3).addItemFlags(ItemFlag.HIDE_ATTRIBUTES) .setCustomModelData(3); @@ -65,7 +65,7 @@ void testGetPersistentItem() { @Test void testInteract() { AtomicBoolean value = new AtomicBoolean(false); - PersistentItem persistentItem = new PersistentItem().setMaterial("STONE") + PersistentItem persistentItem = PersistentItem.newItem().setMaterial("STONE") .onInteract((i, p, a) -> value.set(true)) .onClick((i, p, a) -> value.set(false)); persistentItem.click(mock(Player.class), persistentItem.create(), ClickType.DOUBLE_CLICK); @@ -77,7 +77,7 @@ void testInteract() { @Test void testClick() { AtomicBoolean value = new AtomicBoolean(false); - PersistentItem persistentItem = new PersistentItem().setMaterial("STONE") + PersistentItem persistentItem = PersistentItem.newItem().setMaterial("STONE") .onClick((i, p, a) -> value.set(true)) .onInteract((i, p, a) -> value.set(false)); persistentItem.interact(mock(Player.class), persistentItem.create(), Action.LEFT_CLICK_AIR); diff --git a/item/bukkit/src/test/java/it/angrybear/yagl/listeners/PersistentListenerTest.java b/item/bukkit/src/test/java/it/angrybear/yagl/listeners/PersistentListenerTest.java index edef3f91..160f1f6b 100644 --- a/item/bukkit/src/test/java/it/angrybear/yagl/listeners/PersistentListenerTest.java +++ b/item/bukkit/src/test/java/it/angrybear/yagl/listeners/PersistentListenerTest.java @@ -54,9 +54,9 @@ class PersistentListenerTest { @BeforeAll static void setAllUp() { BukkitUtils.setupServer(); - maintain = new PersistentItem(Material.DIAMOND_SWORD, 1).setDisplayName("Maintain").setDeathAction(DeathAction.MAINTAIN); - disappear = new PersistentItem(Material.IRON_SWORD, 1).setDisplayName("Disappear").setDeathAction(DeathAction.DISAPPEAR); - none = new PersistentItem(Material.STONE_SWORD, 1).setDisplayName("None").setDeathAction(null); + maintain = PersistentItem.newItem(Material.DIAMOND_SWORD, 1).setDisplayName("Maintain").setDeathAction(DeathAction.MAINTAIN); + disappear = PersistentItem.newItem(Material.IRON_SWORD, 1).setDisplayName("Disappear").setDeathAction(DeathAction.DISAPPEAR); + none = PersistentItem.newItem(Material.STONE_SWORD, 1).setDisplayName("None").setDeathAction(null); listener = new PersistentListener(); } @@ -149,7 +149,7 @@ void testClickPersistentItem() { List items = new ArrayList<>(); for (int i = 0; i < itemSize; i++) { int finalI = i; - items.add(new PersistentItem().setMaterial(Material.values()[13 + i]).onClick((p, s, c) -> clickedItems.add(finalI))); + items.add(PersistentItem.newItem().setMaterial(Material.values()[13 + i]).onClick((p, s, c) -> clickedItems.add(finalI))); } assertTrue(listener.clickPersistentItem(mock(Player.class), ClickType.DOUBLE_CLICK, null, items.stream().map(BukkitItem::create).collect(Collectors.toList())), "Should have been true for found"); @@ -163,7 +163,7 @@ void testInteractPersistentItem() { List items = new ArrayList<>(); for (int i = 0; i < itemSize; i++) { int finalI = i; - items.add(new PersistentItem().setMaterial(Material.values()[3 + i]).onInteract((p, s, c) -> interactItems.add(finalI))); + items.add(PersistentItem.newItem().setMaterial(Material.values()[3 + i]).onInteract((p, s, c) -> interactItems.add(finalI))); } assertTrue(listener.interactPersistentItem(mock(Player.class), Action.LEFT_CLICK_AIR, null, items.stream().map(BukkitItem::create).collect(Collectors.toList())), "Should have been true for found"); @@ -261,8 +261,8 @@ void simulateInventoryClick(InventoryClickEvent event) { private Object[] notMovableItems() { return new Object[]{ - new PersistentItem(Material.IRON_HOE).setMobility(Mobility.INTERNAL), - new PersistentItem(Material.GOLDEN_HOE).setMobility(Mobility.STATIC) + PersistentItem.newItem(Material.IRON_HOE).setMobility(Mobility.INTERNAL), + PersistentItem.newItem(Material.GOLDEN_HOE).setMobility(Mobility.STATIC) }; } @@ -296,7 +296,7 @@ void testItemInsideShouldNotBeMoved(PersistentItem persistentItem) { @Test void testClickInBottomInventoryWithNoKeyPress() { - PersistentItem persistentItem = new PersistentItem(Material.ACACIA_BOAT); + PersistentItem persistentItem = PersistentItem.newItem(Material.ACACIA_BOAT); InventoryView view = setupInventoryClickEventView(); int slot = view.getTopInventory().getSize(); view.getBottomInventory().setItem(0, persistentItem.create());