mirror of
https://github.com/alexcrea/CustomAnvil.git
synced 2026-06-23 16:16:17 +02:00
Added most of the lore edit unit tests
This commit is contained in:
parent
064f446d68
commit
2c0623cd3e
11 changed files with 834 additions and 60 deletions
|
|
@ -14,7 +14,7 @@ import org.mockbukkit.mockbukkit.entity.PlayerMock;
|
||||||
import org.mockbukkit.mockbukkit.inventory.ItemStackMock;
|
import org.mockbukkit.mockbukkit.inventory.ItemStackMock;
|
||||||
import xyz.alexcrea.cuanvil.config.ConfigHolder;
|
import xyz.alexcrea.cuanvil.config.ConfigHolder;
|
||||||
import xyz.alexcrea.cuanvil.tests.ConfigResetCustomAnvilTest;
|
import xyz.alexcrea.cuanvil.tests.ConfigResetCustomAnvilTest;
|
||||||
import xyz.alexcrea.cuanvil.util.AnvilFuseTestData;
|
import xyz.alexcrea.cuanvil.data.AnvilFuseTestData;
|
||||||
import xyz.alexcrea.cuanvil.util.AnvilFuseTestUtil;
|
import xyz.alexcrea.cuanvil.util.AnvilFuseTestUtil;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
@ -88,16 +88,16 @@ public class EnchantmentUtilTests extends ConfigResetCustomAnvilTest {
|
||||||
);
|
);
|
||||||
|
|
||||||
// Test with no permission
|
// Test with no permission
|
||||||
AnvilFuseTestUtil.executeAnvilTest(anvil, player, nullResultData);
|
AnvilFuseTestUtil.executeAnvilFuseTest(anvil, player, nullResultData);
|
||||||
AnvilFuseTestUtil.executeAnvilTest(anvil, player, nullResultData2);
|
AnvilFuseTestUtil.executeAnvilFuseTest(anvil, player, nullResultData2);
|
||||||
|
|
||||||
// Add permission
|
// Add permission
|
||||||
PermissionAttachment attachment = player.addAttachment(plugin);
|
PermissionAttachment attachment = player.addAttachment(plugin);
|
||||||
attachment.setPermission(permission, true);
|
attachment.setPermission(permission, true);
|
||||||
|
|
||||||
// Test with new permission
|
// Test with new permission
|
||||||
AnvilFuseTestUtil.executeAnvilTest(anvil, player, legalResultData);
|
AnvilFuseTestUtil.executeAnvilFuseTest(anvil, player, legalResultData);
|
||||||
AnvilFuseTestUtil.executeAnvilTest(anvil, player, legalResultData2);
|
AnvilFuseTestUtil.executeAnvilFuseTest(anvil, player, legalResultData2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
@ -161,24 +161,24 @@ public class EnchantmentUtilTests extends ConfigResetCustomAnvilTest {
|
||||||
);
|
);
|
||||||
|
|
||||||
// Test failing result first
|
// Test failing result first
|
||||||
AnvilFuseTestUtil.executeAnvilTest(anvil, player, nullResultData2);
|
AnvilFuseTestUtil.executeAnvilFuseTest(anvil, player, nullResultData2);
|
||||||
AnvilFuseTestUtil.executeAnvilTest(anvil, player, nullResultData3);
|
AnvilFuseTestUtil.executeAnvilFuseTest(anvil, player, nullResultData3);
|
||||||
|
|
||||||
// Test working sharpness 2
|
// Test working sharpness 2
|
||||||
AnvilFuseTestUtil.executeAnvilTest(anvil, player, legalResultData);
|
AnvilFuseTestUtil.executeAnvilFuseTest(anvil, player, legalResultData);
|
||||||
|
|
||||||
// Set merge limit to 2 & test
|
// Set merge limit to 2 & test
|
||||||
ConfigHolder.DEFAULT_CONFIG.getConfig().set("disable-merge-over.minecraft:sharpness", 1);
|
ConfigHolder.DEFAULT_CONFIG.getConfig().set("disable-merge-over.minecraft:sharpness", 1);
|
||||||
AnvilFuseTestUtil.executeAnvilTest(anvil, player, nullResultData);
|
AnvilFuseTestUtil.executeAnvilFuseTest(anvil, player, nullResultData);
|
||||||
|
|
||||||
// Add permission
|
// Add permission
|
||||||
PermissionAttachment attachment = player.addAttachment(plugin);
|
PermissionAttachment attachment = player.addAttachment(plugin);
|
||||||
attachment.setPermission(permission, true);
|
attachment.setPermission(permission, true);
|
||||||
|
|
||||||
// Test working sharpness 2
|
// Test working sharpness 2
|
||||||
AnvilFuseTestUtil.executeAnvilTest(anvil, player, legalResultData);
|
AnvilFuseTestUtil.executeAnvilFuseTest(anvil, player, legalResultData);
|
||||||
AnvilFuseTestUtil.executeAnvilTest(anvil, player, legalResultData2);
|
AnvilFuseTestUtil.executeAnvilFuseTest(anvil, player, legalResultData2);
|
||||||
AnvilFuseTestUtil.executeAnvilTest(anvil, player, legalResultData3);
|
AnvilFuseTestUtil.executeAnvilFuseTest(anvil, player, legalResultData3);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,6 @@ import org.bukkit.inventory.Inventory;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
import org.bukkit.inventory.meta.Repairable;
|
import org.bukkit.inventory.meta.Repairable;
|
||||||
import org.eclipse.aether.util.ConfigUtils;
|
|
||||||
import org.junit.jupiter.api.AfterAll;
|
import org.junit.jupiter.api.AfterAll;
|
||||||
import org.junit.jupiter.api.BeforeAll;
|
import org.junit.jupiter.api.BeforeAll;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
|
|
@ -17,7 +16,7 @@ import org.junit.jupiter.api.Test;
|
||||||
import org.mockbukkit.mockbukkit.entity.PlayerMock;
|
import org.mockbukkit.mockbukkit.entity.PlayerMock;
|
||||||
import xyz.alexcrea.cuanvil.config.ConfigHolder;
|
import xyz.alexcrea.cuanvil.config.ConfigHolder;
|
||||||
import xyz.alexcrea.cuanvil.tests.SharedCustomAnvilTest;
|
import xyz.alexcrea.cuanvil.tests.SharedCustomAnvilTest;
|
||||||
import xyz.alexcrea.cuanvil.util.AnvilFuseTestData;
|
import xyz.alexcrea.cuanvil.data.AnvilFuseTestData;
|
||||||
import xyz.alexcrea.cuanvil.util.AnvilFuseTestUtil;
|
import xyz.alexcrea.cuanvil.util.AnvilFuseTestUtil;
|
||||||
import xyz.alexcrea.cuanvil.util.CommonItemUtil;
|
import xyz.alexcrea.cuanvil.util.CommonItemUtil;
|
||||||
|
|
||||||
|
|
@ -68,7 +67,7 @@ public class AnvilFuseTests extends SharedCustomAnvilTest {
|
||||||
5
|
5
|
||||||
);
|
);
|
||||||
|
|
||||||
AnvilFuseTestUtil.executeAnvilTest(anvil, player, data);
|
AnvilFuseTestUtil.executeAnvilFuseTest(anvil, player, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
@ -88,7 +87,7 @@ public class AnvilFuseTests extends SharedCustomAnvilTest {
|
||||||
5
|
5
|
||||||
);
|
);
|
||||||
|
|
||||||
AnvilFuseTestUtil.executeAnvilTest(anvil, player, data);
|
AnvilFuseTestUtil.executeAnvilFuseTest(anvil, player, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
@ -102,7 +101,7 @@ public class AnvilFuseTests extends SharedCustomAnvilTest {
|
||||||
null
|
null
|
||||||
);
|
);
|
||||||
|
|
||||||
AnvilFuseTestUtil.executeAnvilTest(anvil, player, data);
|
AnvilFuseTestUtil.executeAnvilFuseTest(anvil, player, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Note: currently anvil can only have null name. maybe handle differently later
|
// Note: currently anvil can only have null name. maybe handle differently later
|
||||||
|
|
@ -121,7 +120,7 @@ public class AnvilFuseTests extends SharedCustomAnvilTest {
|
||||||
1, 1, null
|
1, 1, null
|
||||||
);
|
);
|
||||||
|
|
||||||
AnvilFuseTestUtil.executeAnvilTest(anvil, player, data);
|
AnvilFuseTestUtil.executeAnvilFuseTest(anvil, player, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
511
src/test/java/xyz/alexcrea/cuanvil/anvil/LoreEditTests.java
Normal file
511
src/test/java/xyz/alexcrea/cuanvil/anvil/LoreEditTests.java
Normal file
|
|
@ -0,0 +1,511 @@
|
||||||
|
package xyz.alexcrea.cuanvil.anvil;
|
||||||
|
|
||||||
|
import io.delilaheve.util.ConfigOptions;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.event.Event;
|
||||||
|
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.BookMeta;
|
||||||
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
import org.junit.jupiter.api.*;
|
||||||
|
import org.junit.jupiter.params.ParameterizedTest;
|
||||||
|
import org.junit.jupiter.params.provider.EnumSource;
|
||||||
|
import org.mockbukkit.mockbukkit.entity.PlayerMock;
|
||||||
|
import xyz.alexcrea.cuanvil.config.ConfigHolder;
|
||||||
|
import xyz.alexcrea.cuanvil.data.AnvilClickTestData;
|
||||||
|
import xyz.alexcrea.cuanvil.data.AnvilFuseTestData;
|
||||||
|
import xyz.alexcrea.cuanvil.data.TestDataContainer;
|
||||||
|
import xyz.alexcrea.cuanvil.tests.SharedCustomAnvilTest;
|
||||||
|
import xyz.alexcrea.cuanvil.util.config.LoreEditConfigUtil;
|
||||||
|
import xyz.alexcrea.cuanvil.util.config.LoreEditType;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class LoreEditTests extends SharedCustomAnvilTest {
|
||||||
|
|
||||||
|
private static AnvilInventory anvil;
|
||||||
|
private static PlayerMock player;
|
||||||
|
|
||||||
|
private static final String COLORED_LORE_LINE = "§x§1§2§3§4§5§6TEST §atest";
|
||||||
|
private static final String UNCOLORED_LORE_LINE = "#123456TEST &atest";
|
||||||
|
|
||||||
|
private static final int COLOR_USE_COST = 1;
|
||||||
|
private static final int COLOR_REMOVE_COST = 2;
|
||||||
|
private static final int NON_ONE_TEST_FIXED_COST = 10;
|
||||||
|
private static final int NON_ZERO_TEST_LINE_COST = 2;
|
||||||
|
|
||||||
|
private static ItemStack emptyItem;
|
||||||
|
private static ItemStack oneColoredLoreItem;
|
||||||
|
private static ItemStack twoColoredLoreItem;
|
||||||
|
private static ItemStack oneUncoloredLoreItem;
|
||||||
|
private static ItemStack twoUncoloredLoreItem;
|
||||||
|
|
||||||
|
private static ItemStack emptyPaperStack;
|
||||||
|
private static ItemStack emptyPaper63Item;
|
||||||
|
private static ItemStack emptyPaperOne;
|
||||||
|
private static ItemStack coloredPaperStack;
|
||||||
|
private static ItemStack coloredPaper63Item;
|
||||||
|
private static ItemStack coloredPaperOne;
|
||||||
|
private static ItemStack uncoloredPaperStack;
|
||||||
|
private static ItemStack uncoloredPaper63Item;
|
||||||
|
private static ItemStack uncoloredPaperOne;
|
||||||
|
|
||||||
|
private static ItemStack emptyBook;
|
||||||
|
private static ItemStack coloredBook1Line;
|
||||||
|
private static ItemStack coloredBook2Line;
|
||||||
|
private static ItemStack uncoloredBook1Line;
|
||||||
|
private static ItemStack uncoloredBook2Line;
|
||||||
|
|
||||||
|
private static TestDataContainer defBookAppend;
|
||||||
|
private static TestDataContainer defBookRemove;
|
||||||
|
|
||||||
|
private static TestDataContainer defPaperAppend;
|
||||||
|
private static TestDataContainer defPaperRemove;
|
||||||
|
|
||||||
|
private static TestDataContainer defMultilineBookAppend;
|
||||||
|
private static TestDataContainer defMultilineBookRemove;
|
||||||
|
|
||||||
|
private static TestDataContainer defMultilinePaperAppend;
|
||||||
|
private static TestDataContainer defMultilinePaperRemove;
|
||||||
|
|
||||||
|
private static Map<LoreEditType, TestDataContainer> singleLineTypeToTest;
|
||||||
|
private static Map<LoreEditType, TestDataContainer> multiLineTypeToTest;
|
||||||
|
|
||||||
|
@BeforeAll
|
||||||
|
public static void setUp() {
|
||||||
|
// Mock used player & open anvil
|
||||||
|
player = server.addPlayer();
|
||||||
|
|
||||||
|
Inventory anvil = server.createInventory(player, InventoryType.ANVIL);
|
||||||
|
|
||||||
|
LoreEditTests.anvil = (AnvilInventory) anvil;
|
||||||
|
player.openInventory(anvil);
|
||||||
|
|
||||||
|
ConfigHolder.DEFAULT_CONFIG.getConfig().set(ConfigOptions.DEBUG_LOGGING, true);
|
||||||
|
ConfigHolder.DEFAULT_CONFIG.getConfig().set(ConfigOptions.VERBOSE_DEBUG_LOGGING, true);
|
||||||
|
|
||||||
|
// Applied item
|
||||||
|
ItemStack item = new ItemStack(Material.STICK, 33);
|
||||||
|
ItemMeta meta = item.getItemMeta();
|
||||||
|
ArrayList<String> lore = new ArrayList<>();
|
||||||
|
|
||||||
|
emptyItem = item.clone();
|
||||||
|
|
||||||
|
lore.add(COLORED_LORE_LINE);
|
||||||
|
meta.setLore(lore);
|
||||||
|
item.setItemMeta(meta);
|
||||||
|
oneColoredLoreItem = item.clone();
|
||||||
|
|
||||||
|
lore.add(COLORED_LORE_LINE);
|
||||||
|
meta.setLore(lore);
|
||||||
|
item.setItemMeta(meta);
|
||||||
|
twoColoredLoreItem = item.clone();
|
||||||
|
|
||||||
|
lore.clear();
|
||||||
|
lore.add(UNCOLORED_LORE_LINE);
|
||||||
|
meta.setLore(lore);
|
||||||
|
item.setItemMeta(meta);
|
||||||
|
oneUncoloredLoreItem = item.clone();
|
||||||
|
|
||||||
|
lore.add(UNCOLORED_LORE_LINE);
|
||||||
|
meta.setLore(lore);
|
||||||
|
item.setItemMeta(meta);
|
||||||
|
twoUncoloredLoreItem = item.clone();
|
||||||
|
lore.clear();
|
||||||
|
|
||||||
|
// Paper items
|
||||||
|
item = new ItemStack(Material.PAPER, 64);
|
||||||
|
meta = item.getItemMeta();
|
||||||
|
emptyPaperStack = item.clone();
|
||||||
|
item.setAmount(63);
|
||||||
|
emptyPaper63Item = item.clone();
|
||||||
|
item.setAmount(1);
|
||||||
|
emptyPaperOne = item.clone();
|
||||||
|
|
||||||
|
item.setAmount(64);
|
||||||
|
meta.setDisplayName(COLORED_LORE_LINE);
|
||||||
|
item.setItemMeta(meta);
|
||||||
|
coloredPaperStack = item.clone();
|
||||||
|
item.setAmount(63);
|
||||||
|
coloredPaper63Item = item.clone();
|
||||||
|
item.setAmount(1);
|
||||||
|
coloredPaperOne = item.clone();
|
||||||
|
|
||||||
|
item.setAmount(64);
|
||||||
|
meta.setDisplayName(UNCOLORED_LORE_LINE);
|
||||||
|
item.setItemMeta(meta);
|
||||||
|
uncoloredPaperStack = item.clone();
|
||||||
|
item.setAmount(63);
|
||||||
|
uncoloredPaper63Item = item.clone();
|
||||||
|
item.setAmount(1);
|
||||||
|
uncoloredPaperOne = item.clone();
|
||||||
|
|
||||||
|
// Book items
|
||||||
|
item = new ItemStack(Material.WRITABLE_BOOK);
|
||||||
|
BookMeta bookmeta = (BookMeta) item.getItemMeta();
|
||||||
|
emptyBook = item.clone();
|
||||||
|
|
||||||
|
bookmeta.setPages(COLORED_LORE_LINE);
|
||||||
|
item.setItemMeta(bookmeta);
|
||||||
|
coloredBook1Line = item.clone();
|
||||||
|
|
||||||
|
bookmeta.setPages(COLORED_LORE_LINE + "\n" + COLORED_LORE_LINE);
|
||||||
|
item.setItemMeta(bookmeta);
|
||||||
|
coloredBook2Line = item.clone();
|
||||||
|
|
||||||
|
bookmeta.setPages(UNCOLORED_LORE_LINE);
|
||||||
|
item.setItemMeta(bookmeta);
|
||||||
|
uncoloredBook1Line = item.clone();
|
||||||
|
|
||||||
|
bookmeta.setPages(UNCOLORED_LORE_LINE + "\n" + UNCOLORED_LORE_LINE);
|
||||||
|
item.setItemMeta(bookmeta);
|
||||||
|
uncoloredBook2Line = item.clone();
|
||||||
|
|
||||||
|
// Default working test data
|
||||||
|
defBookAppend = new TestDataContainer(
|
||||||
|
new AnvilFuseTestData(
|
||||||
|
emptyItem, uncoloredBook1Line,
|
||||||
|
oneColoredLoreItem,
|
||||||
|
1
|
||||||
|
), new AnvilClickTestData(
|
||||||
|
null, emptyBook, null, oneColoredLoreItem,
|
||||||
|
1, Event.Result.DENY,
|
||||||
|
true, Event.Result.DENY
|
||||||
|
));
|
||||||
|
|
||||||
|
defBookRemove = new TestDataContainer(
|
||||||
|
new AnvilFuseTestData(
|
||||||
|
oneColoredLoreItem, emptyBook,
|
||||||
|
emptyItem,
|
||||||
|
1
|
||||||
|
), new AnvilClickTestData(
|
||||||
|
null, coloredBook1Line, null, emptyItem,
|
||||||
|
1, Event.Result.DENY,
|
||||||
|
true, Event.Result.DENY
|
||||||
|
));
|
||||||
|
|
||||||
|
defPaperAppend = new TestDataContainer(
|
||||||
|
new AnvilFuseTestData(
|
||||||
|
emptyItem, uncoloredPaperStack,
|
||||||
|
oneColoredLoreItem,
|
||||||
|
1
|
||||||
|
), new AnvilClickTestData(
|
||||||
|
emptyPaperOne, uncoloredPaper63Item, null, oneColoredLoreItem,
|
||||||
|
1, Event.Result.DENY,
|
||||||
|
true, Event.Result.DENY
|
||||||
|
));
|
||||||
|
|
||||||
|
defPaperRemove = new TestDataContainer(
|
||||||
|
new AnvilFuseTestData(
|
||||||
|
oneColoredLoreItem, emptyPaperStack,
|
||||||
|
emptyItem,
|
||||||
|
1
|
||||||
|
), new AnvilClickTestData(
|
||||||
|
coloredPaperOne, emptyPaper63Item, null, emptyItem,
|
||||||
|
1, Event.Result.DENY,
|
||||||
|
true, Event.Result.DENY
|
||||||
|
));
|
||||||
|
defMultilineBookAppend = new TestDataContainer(
|
||||||
|
new AnvilFuseTestData(
|
||||||
|
emptyItem, uncoloredBook2Line,
|
||||||
|
twoColoredLoreItem,
|
||||||
|
1
|
||||||
|
), new AnvilClickTestData(
|
||||||
|
null, emptyBook, null, twoColoredLoreItem,
|
||||||
|
1, Event.Result.DENY,
|
||||||
|
true, Event.Result.DENY
|
||||||
|
));
|
||||||
|
|
||||||
|
defMultilineBookRemove = new TestDataContainer(
|
||||||
|
new AnvilFuseTestData(
|
||||||
|
twoColoredLoreItem, emptyBook,
|
||||||
|
emptyItem,
|
||||||
|
1
|
||||||
|
), new AnvilClickTestData(
|
||||||
|
null, coloredBook2Line, null, emptyItem,
|
||||||
|
1, Event.Result.DENY,
|
||||||
|
true, Event.Result.DENY
|
||||||
|
));
|
||||||
|
|
||||||
|
defMultilinePaperAppend = new TestDataContainer(
|
||||||
|
new AnvilFuseTestData(
|
||||||
|
oneColoredLoreItem, uncoloredPaperStack,
|
||||||
|
twoColoredLoreItem,
|
||||||
|
1
|
||||||
|
), new AnvilClickTestData(
|
||||||
|
emptyPaperOne, uncoloredPaper63Item, null, twoColoredLoreItem,
|
||||||
|
1, Event.Result.DENY,
|
||||||
|
true, Event.Result.DENY
|
||||||
|
));
|
||||||
|
|
||||||
|
defMultilinePaperRemove = new TestDataContainer(
|
||||||
|
new AnvilFuseTestData(
|
||||||
|
twoColoredLoreItem, emptyPaperStack,
|
||||||
|
oneColoredLoreItem,
|
||||||
|
1
|
||||||
|
), new AnvilClickTestData(
|
||||||
|
coloredPaperOne, emptyPaper63Item, null, oneColoredLoreItem,
|
||||||
|
1, Event.Result.DENY,
|
||||||
|
true, Event.Result.DENY
|
||||||
|
));
|
||||||
|
|
||||||
|
singleLineTypeToTest = Map.of(
|
||||||
|
LoreEditType.APPEND_BOOK, defBookAppend,
|
||||||
|
LoreEditType.REMOVE_BOOK, defBookRemove,
|
||||||
|
LoreEditType.APPEND_PAPER, defPaperAppend,
|
||||||
|
LoreEditType.REMOVE_PAPER, defPaperRemove
|
||||||
|
);
|
||||||
|
|
||||||
|
multiLineTypeToTest = Map.of(
|
||||||
|
LoreEditType.APPEND_BOOK, defMultilineBookAppend,
|
||||||
|
LoreEditType.REMOVE_BOOK, defMultilineBookRemove,
|
||||||
|
LoreEditType.APPEND_PAPER, defMultilinePaperAppend,
|
||||||
|
LoreEditType.REMOVE_PAPER, defMultilinePaperRemove
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public @Nullable ItemStack uncoloredEquivalent(@Nullable ItemStack colored){
|
||||||
|
// null check
|
||||||
|
if(null == colored) return null;
|
||||||
|
|
||||||
|
if(oneColoredLoreItem == colored) return oneUncoloredLoreItem;
|
||||||
|
if(twoColoredLoreItem == colored) return twoUncoloredLoreItem;
|
||||||
|
|
||||||
|
if(coloredPaperStack == colored) return uncoloredPaperStack;
|
||||||
|
if(coloredPaper63Item == colored) return uncoloredPaper63Item;
|
||||||
|
if(coloredPaperOne == colored) return uncoloredPaperOne;
|
||||||
|
|
||||||
|
if(coloredBook1Line == colored) return uncoloredBook1Line;
|
||||||
|
if(coloredBook2Line == colored) return uncoloredBook2Line;
|
||||||
|
|
||||||
|
// They already are uncolored
|
||||||
|
if(oneUncoloredLoreItem == colored) return oneUncoloredLoreItem;
|
||||||
|
if(twoUncoloredLoreItem == colored) return twoUncoloredLoreItem;
|
||||||
|
|
||||||
|
if(uncoloredPaperStack == colored) return uncoloredPaperStack;
|
||||||
|
if(uncoloredPaper63Item == colored) return uncoloredPaper63Item;
|
||||||
|
if(uncoloredPaperOne == colored) return uncoloredPaperOne;
|
||||||
|
|
||||||
|
if(uncoloredBook1Line == colored) return uncoloredBook1Line;
|
||||||
|
if(uncoloredBook2Line == colored) return uncoloredBook2Line;
|
||||||
|
|
||||||
|
// No lore items return themself
|
||||||
|
if(emptyItem == colored) return emptyItem;
|
||||||
|
if(emptyBook == colored) return emptyBook;
|
||||||
|
if(emptyPaperStack == colored) return emptyPaperStack;
|
||||||
|
if(emptyPaper63Item == colored) return emptyPaper63Item;
|
||||||
|
if(emptyPaperOne == colored) return emptyPaperOne;
|
||||||
|
|
||||||
|
Assertions.fail("Could not find uncolored version of " + colored);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@BeforeEach
|
||||||
|
public void prepareAnvil() {
|
||||||
|
anvil.clear();
|
||||||
|
|
||||||
|
// Make sure we reset value in case it got modified
|
||||||
|
for (@NotNull LoreEditType type : LoreEditType.values()) {
|
||||||
|
// Make sure it is enabled for the tests (unless its is enabled test)
|
||||||
|
ConfigHolder.DEFAULT_CONFIG.getConfig().set(type.getRootPath() + "." + LoreEditConfigUtil.IS_ENABLED, true);
|
||||||
|
|
||||||
|
ConfigHolder.DEFAULT_CONFIG.getConfig().set(type.getRootPath() + "." + LoreEditConfigUtil.DO_CONSUME, false);
|
||||||
|
ConfigHolder.DEFAULT_CONFIG.getConfig().set(type.getRootPath() + "." + LoreEditConfigUtil.FIXED_COST, 1);
|
||||||
|
ConfigHolder.DEFAULT_CONFIG.getConfig().set(type.getRootPath() + "." + LoreEditConfigUtil.PER_LINE_COST, 0);
|
||||||
|
|
||||||
|
|
||||||
|
// Make sur color is enabled by default
|
||||||
|
if (type.isAppend()) {
|
||||||
|
ConfigHolder.DEFAULT_CONFIG.getConfig().set(type.getRootPath() + "." + LoreEditConfigUtil.ALLOW_HEX_COLOR, true);
|
||||||
|
ConfigHolder.DEFAULT_CONFIG.getConfig().set(type.getRootPath() + "." + LoreEditConfigUtil.ALLOW_COLOR_CODE, true);
|
||||||
|
ConfigHolder.DEFAULT_CONFIG.getConfig().set(type.getRootPath() + "." + LoreEditConfigUtil.USE_COLOR_COST, 0);
|
||||||
|
} else {
|
||||||
|
ConfigHolder.DEFAULT_CONFIG.getConfig().set(type.getRootPath() + "." + LoreEditConfigUtil.REMOVE_COLOR_ON_LORE_REMOVE, false);
|
||||||
|
ConfigHolder.DEFAULT_CONFIG.getConfig().set(type.getRootPath() + "." + LoreEditConfigUtil.REMOVE_COLOR_COST, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Disable them by default and test them on specific tests
|
||||||
|
ConfigHolder.DEFAULT_CONFIG.getConfig().set(LoreEditConfigUtil.BOOK_PERMISSION_NEEDED, false);
|
||||||
|
ConfigHolder.DEFAULT_CONFIG.getConfig().set(LoreEditConfigUtil.PAPER_PERMISSION_NEEDED, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@AfterAll
|
||||||
|
public static void tearDown() {
|
||||||
|
player = null;
|
||||||
|
anvil = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void simpleTest() {
|
||||||
|
// Test all defaults to make sure they works
|
||||||
|
for (LoreEditType type : LoreEditType.values()) {
|
||||||
|
singleLineTypeToTest.get(type).executeTest(anvil, player);
|
||||||
|
multiLineTypeToTest.get(type).executeTest(anvil, player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@ParameterizedTest
|
||||||
|
@EnumSource(LoreEditType.class)
|
||||||
|
public void testPermissionNeeded_DEOP(LoreEditType type) {
|
||||||
|
ConfigHolder.DEFAULT_CONFIG.getConfig().set(LoreEditConfigUtil.BOOK_PERMISSION_NEEDED, true);
|
||||||
|
ConfigHolder.DEFAULT_CONFIG.getConfig().set(LoreEditConfigUtil.PAPER_PERMISSION_NEEDED, true);
|
||||||
|
player.setOp(false);
|
||||||
|
|
||||||
|
singleLineTypeToTest.get(type).nullifyResult().executeTest(anvil, player);
|
||||||
|
multiLineTypeToTest.get(type).nullifyResult().executeTest(anvil, player);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ParameterizedTest
|
||||||
|
@EnumSource(LoreEditType.class)
|
||||||
|
public void testPermissionNeeded_OP(LoreEditType type) {
|
||||||
|
ConfigHolder.DEFAULT_CONFIG.getConfig().set(LoreEditConfigUtil.BOOK_PERMISSION_NEEDED, true);
|
||||||
|
ConfigHolder.DEFAULT_CONFIG.getConfig().set(LoreEditConfigUtil.PAPER_PERMISSION_NEEDED, true);
|
||||||
|
player.setOp(true);
|
||||||
|
|
||||||
|
singleLineTypeToTest.get(type).executeTest(anvil, player);
|
||||||
|
multiLineTypeToTest.get(type).executeTest(anvil, player);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ParameterizedTest
|
||||||
|
@EnumSource(LoreEditType.class)
|
||||||
|
public void testLoreTypeDisabled(LoreEditType type) {
|
||||||
|
ConfigHolder.DEFAULT_CONFIG.getConfig().set(type.getRootPath() + "." + LoreEditConfigUtil.IS_ENABLED, false);
|
||||||
|
|
||||||
|
singleLineTypeToTest.get(type).nullifyResult().executeTest(anvil, player);
|
||||||
|
multiLineTypeToTest.get(type).nullifyResult().executeTest(anvil, player);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ParameterizedTest
|
||||||
|
@EnumSource(LoreEditType.class)
|
||||||
|
public void testFixedCost_Default(LoreEditType type) {
|
||||||
|
singleLineTypeToTest.get(type).setCost(1).executeTest(anvil, player);
|
||||||
|
multiLineTypeToTest.get(type).setCost(1).executeTest(anvil, player);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ParameterizedTest
|
||||||
|
@EnumSource(LoreEditType.class)
|
||||||
|
public void testFixedCost_Modified(LoreEditType type) {
|
||||||
|
ConfigHolder.DEFAULT_CONFIG.getConfig().set(type.getRootPath() + "." + LoreEditConfigUtil.FIXED_COST, NON_ONE_TEST_FIXED_COST);
|
||||||
|
|
||||||
|
singleLineTypeToTest.get(type).setCost(NON_ONE_TEST_FIXED_COST).executeTest(anvil, player);
|
||||||
|
multiLineTypeToTest.get(type).setCost(NON_ONE_TEST_FIXED_COST).executeTest(anvil, player);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ParameterizedTest
|
||||||
|
@EnumSource(LoreEditType.class)
|
||||||
|
public void testLineCost_Modified(LoreEditType type) {
|
||||||
|
ConfigHolder.DEFAULT_CONFIG.getConfig().set(type.getRootPath() + "." + LoreEditConfigUtil.PER_LINE_COST, NON_ZERO_TEST_LINE_COST);
|
||||||
|
|
||||||
|
if (type.isMultiLine()) {
|
||||||
|
singleLineTypeToTest.get(type).setCost(NON_ZERO_TEST_LINE_COST + LoreEditConfigUtil.DEFAULT_FIXED_COST).executeTest(anvil, player);
|
||||||
|
multiLineTypeToTest.get(type).setCost(2 * NON_ZERO_TEST_LINE_COST + LoreEditConfigUtil.DEFAULT_FIXED_COST).executeTest(anvil, player);
|
||||||
|
} else {
|
||||||
|
singleLineTypeToTest.get(type).executeTest(anvil, player);
|
||||||
|
multiLineTypeToTest.get(type).executeTest(anvil, player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@ParameterizedTest
|
||||||
|
@EnumSource(LoreEditType.class)
|
||||||
|
public void testColorCost(LoreEditType type) {
|
||||||
|
ConfigHolder.DEFAULT_CONFIG.getConfig().set(type.getRootPath() + "." + LoreEditConfigUtil.USE_COLOR_COST, COLOR_USE_COST);
|
||||||
|
ConfigHolder.DEFAULT_CONFIG.getConfig().set(type.getRootPath() + "." + LoreEditConfigUtil.REMOVE_COLOR_COST, COLOR_REMOVE_COST);
|
||||||
|
ConfigHolder.DEFAULT_CONFIG.getConfig().set(type.getRootPath() + "." + LoreEditConfigUtil.REMOVE_COLOR_ON_LORE_REMOVE, true);
|
||||||
|
|
||||||
|
TestDataContainer singleLData = singleLineTypeToTest.get(type);
|
||||||
|
TestDataContainer multiLData = multiLineTypeToTest.get(type);
|
||||||
|
|
||||||
|
if (type.isAppend()) {
|
||||||
|
singleLData.setCost(COLOR_USE_COST + LoreEditConfigUtil.DEFAULT_FIXED_COST).executeTest(anvil, player);
|
||||||
|
multiLData.setCost(COLOR_USE_COST + LoreEditConfigUtil.DEFAULT_FIXED_COST).executeTest(anvil, player);
|
||||||
|
} else {
|
||||||
|
singleLData
|
||||||
|
.setCost(COLOR_REMOVE_COST + LoreEditConfigUtil.DEFAULT_FIXED_COST)
|
||||||
|
.setClickRight(uncoloredEquivalent(singleLData.getRightClick()))
|
||||||
|
.setClickLeft(uncoloredEquivalent(singleLData.getLeftClick()))
|
||||||
|
.executeTest(anvil, player);
|
||||||
|
|
||||||
|
multiLData.setCost(COLOR_REMOVE_COST + LoreEditConfigUtil.DEFAULT_FIXED_COST)
|
||||||
|
.setClickRight(uncoloredEquivalent(multiLData.getRightClick()))
|
||||||
|
.setClickLeft(uncoloredEquivalent(multiLData.getLeftClick()))
|
||||||
|
.executeTest(anvil, player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@ParameterizedTest
|
||||||
|
@EnumSource(LoreEditType.class)
|
||||||
|
public void testColorDisabled(LoreEditType type) {
|
||||||
|
if(!type.isAppend()) return;
|
||||||
|
ConfigHolder.DEFAULT_CONFIG.getConfig().set(type.getRootPath() + "." + LoreEditConfigUtil.USE_COLOR_COST, COLOR_USE_COST);
|
||||||
|
ConfigHolder.DEFAULT_CONFIG.getConfig().set(type.getRootPath() + "." + LoreEditConfigUtil.ALLOW_HEX_COLOR, false);
|
||||||
|
ConfigHolder.DEFAULT_CONFIG.getConfig().set(type.getRootPath() + "." + LoreEditConfigUtil.ALLOW_COLOR_CODE, false);
|
||||||
|
|
||||||
|
TestDataContainer singleLData = singleLineTypeToTest.get(type);
|
||||||
|
TestDataContainer multiLData = multiLineTypeToTest.get(type);
|
||||||
|
|
||||||
|
singleLData
|
||||||
|
.setExpectedResult(uncoloredEquivalent(singleLData.getExpectedFuse()))
|
||||||
|
.executeTest(anvil, player);
|
||||||
|
multiLData
|
||||||
|
.setFuseLeft(uncoloredEquivalent(multiLData.getLeftFuse()))
|
||||||
|
.setExpectedResult(uncoloredEquivalent(multiLData.getExpectedFuse()))
|
||||||
|
.executeTest(anvil, player);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ParameterizedTest
|
||||||
|
@EnumSource(LoreEditType.class)
|
||||||
|
public void testColorRemoveEnabled(LoreEditType type) {
|
||||||
|
if(type.isAppend()) return;
|
||||||
|
ConfigHolder.DEFAULT_CONFIG.getConfig().set(type.getRootPath() + "." + LoreEditConfigUtil.REMOVE_COLOR_ON_LORE_REMOVE, true);
|
||||||
|
|
||||||
|
TestDataContainer singleLData = singleLineTypeToTest.get(type);
|
||||||
|
TestDataContainer multiLData = multiLineTypeToTest.get(type);
|
||||||
|
|
||||||
|
singleLData
|
||||||
|
.setClickRight(uncoloredEquivalent(singleLData.getRightClick()))
|
||||||
|
.setClickLeft(uncoloredEquivalent(singleLData.getLeftClick()))
|
||||||
|
.executeTest(anvil, player);
|
||||||
|
multiLData
|
||||||
|
.setClickRight(uncoloredEquivalent(multiLData.getRightClick()))
|
||||||
|
.setClickLeft(uncoloredEquivalent(multiLData.getLeftClick()))
|
||||||
|
.executeTest(anvil, player);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ParameterizedTest
|
||||||
|
@EnumSource(LoreEditType.class)
|
||||||
|
public void testDoConsume(LoreEditType type) {
|
||||||
|
if(type.isAppend()) return;
|
||||||
|
ConfigHolder.DEFAULT_CONFIG.getConfig().set(type.getRootPath() + "." + LoreEditConfigUtil.DO_CONSUME, true);
|
||||||
|
|
||||||
|
TestDataContainer singleLData = singleLineTypeToTest.get(type);
|
||||||
|
TestDataContainer multiLData = multiLineTypeToTest.get(type);
|
||||||
|
|
||||||
|
// NOTE: we set to null right item only on multi line bc the default data has more than one paper and would go to the left instead
|
||||||
|
singleLData = singleLData
|
||||||
|
.setClickRight(type.isMultiLine() ? null : singleLData.getRightClick())
|
||||||
|
.setClickLeft(null);
|
||||||
|
singleLData.executeTest(anvil, player);
|
||||||
|
multiLData = multiLData
|
||||||
|
.setClickRight(type.isMultiLine() ? null : singleLData.getRightClick())
|
||||||
|
.setClickLeft(null);
|
||||||
|
multiLData.executeTest(anvil, player);
|
||||||
|
|
||||||
|
if(!type.isMultiLine()){
|
||||||
|
singleLData.setFuseRight(emptyPaperOne).setClickRight(null).executeTest(anvil, player);
|
||||||
|
multiLData.setFuseRight(emptyPaperOne).setClickRight(null).executeTest(anvil, player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//TODO single paper test
|
||||||
|
|
||||||
|
//TODO remove order test
|
||||||
|
//TODO work penalty test
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -16,7 +16,7 @@ import xyz.alexcrea.cuanvil.config.ConfigHolder;
|
||||||
import xyz.alexcrea.cuanvil.enchant.CAEnchantment;
|
import xyz.alexcrea.cuanvil.enchant.CAEnchantment;
|
||||||
import xyz.alexcrea.cuanvil.group.EnchantConflictGroup;
|
import xyz.alexcrea.cuanvil.group.EnchantConflictGroup;
|
||||||
import xyz.alexcrea.cuanvil.tests.ConfigResetCustomAnvilTest;
|
import xyz.alexcrea.cuanvil.tests.ConfigResetCustomAnvilTest;
|
||||||
import xyz.alexcrea.cuanvil.util.AnvilFuseTestData;
|
import xyz.alexcrea.cuanvil.data.AnvilFuseTestData;
|
||||||
import xyz.alexcrea.cuanvil.util.AnvilFuseTestUtil;
|
import xyz.alexcrea.cuanvil.util.AnvilFuseTestUtil;
|
||||||
import xyz.alexcrea.cuanvil.util.CommonItemUtil;
|
import xyz.alexcrea.cuanvil.util.CommonItemUtil;
|
||||||
|
|
||||||
|
|
@ -71,7 +71,7 @@ public class ConflictApiTests extends ConfigResetCustomAnvilTest {
|
||||||
Assertions.assertNotNull(sharpness);
|
Assertions.assertNotNull(sharpness);
|
||||||
|
|
||||||
// Testing default conflict (illegal item should not be produced)
|
// Testing default conflict (illegal item should not be produced)
|
||||||
AnvilFuseTestUtil.executeAnvilTest(anvil, player, nullResultData);
|
AnvilFuseTestUtil.executeAnvilFuseTest(anvil, player, nullResultData);
|
||||||
|
|
||||||
// Try to find & remove conflict
|
// Try to find & remove conflict
|
||||||
EnchantConflictGroup conflict = findGroup("sword_enchant_conflict");
|
EnchantConflictGroup conflict = findGroup("sword_enchant_conflict");
|
||||||
|
|
@ -79,7 +79,7 @@ public class ConflictApiTests extends ConfigResetCustomAnvilTest {
|
||||||
|
|
||||||
// Test what happen when we remove the conflict (illegal item should be allowed)
|
// Test what happen when we remove the conflict (illegal item should be allowed)
|
||||||
ConflictAPI.removeConflict(conflict);
|
ConflictAPI.removeConflict(conflict);
|
||||||
AnvilFuseTestUtil.executeAnvilTest(anvil, player, legalResultData);
|
AnvilFuseTestUtil.executeAnvilFuseTest(anvil, player, legalResultData);
|
||||||
|
|
||||||
// We create and add a new conflict
|
// We create and add a new conflict
|
||||||
ConflictBuilder builder = new ConflictBuilder("sword_enchant_conflict");
|
ConflictBuilder builder = new ConflictBuilder("sword_enchant_conflict");
|
||||||
|
|
@ -88,11 +88,11 @@ public class ConflictApiTests extends ConfigResetCustomAnvilTest {
|
||||||
|
|
||||||
// Nothing should change as it is not new: it was previously deleted
|
// Nothing should change as it is not new: it was previously deleted
|
||||||
Assertions.assertFalse(builder.registerIfNew());
|
Assertions.assertFalse(builder.registerIfNew());
|
||||||
AnvilFuseTestUtil.executeAnvilTest(anvil, player, legalResultData);
|
AnvilFuseTestUtil.executeAnvilFuseTest(anvil, player, legalResultData);
|
||||||
|
|
||||||
// Now the conflict should be registered and conflict should exist
|
// Now the conflict should be registered and conflict should exist
|
||||||
Assertions.assertTrue(builder.registerIfAbsent());
|
Assertions.assertTrue(builder.registerIfAbsent());
|
||||||
AnvilFuseTestUtil.executeAnvilTest(anvil, player, nullResultData);
|
AnvilFuseTestUtil.executeAnvilFuseTest(anvil, player, nullResultData);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ import org.mockbukkit.mockbukkit.inventory.ItemStackMock;
|
||||||
import xyz.alexcrea.cuanvil.config.ConfigHolder;
|
import xyz.alexcrea.cuanvil.config.ConfigHolder;
|
||||||
import xyz.alexcrea.cuanvil.recipe.AnvilCustomRecipe;
|
import xyz.alexcrea.cuanvil.recipe.AnvilCustomRecipe;
|
||||||
import xyz.alexcrea.cuanvil.tests.ConfigResetCustomAnvilTest;
|
import xyz.alexcrea.cuanvil.tests.ConfigResetCustomAnvilTest;
|
||||||
import xyz.alexcrea.cuanvil.util.AnvilFuseTestData;
|
import xyz.alexcrea.cuanvil.data.AnvilFuseTestData;
|
||||||
import xyz.alexcrea.cuanvil.util.AnvilFuseTestUtil;
|
import xyz.alexcrea.cuanvil.util.AnvilFuseTestUtil;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.*;
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
|
@ -57,14 +57,14 @@ public class CustomAnvilRecipeApiTests extends ConfigResetCustomAnvilTest {
|
||||||
);
|
);
|
||||||
|
|
||||||
// Testing default conflict (no recipe exist)
|
// Testing default conflict (no recipe exist)
|
||||||
AnvilFuseTestUtil.executeAnvilTest(anvil, player, nullResultData);
|
AnvilFuseTestUtil.executeAnvilFuseTest(anvil, player, nullResultData);
|
||||||
|
|
||||||
// Add and test recipe
|
// Add and test recipe
|
||||||
AnvilRecipeBuilder builder = new AnvilRecipeBuilder(recipeName);
|
AnvilRecipeBuilder builder = new AnvilRecipeBuilder(recipeName);
|
||||||
builder.setExactCount(true).setLeftItem(stick).setResultItem(stick).setXpCostPerCraft(2);
|
builder.setExactCount(true).setLeftItem(stick).setResultItem(stick).setXpCostPerCraft(2);
|
||||||
|
|
||||||
assertTrue(builder.registerIfAbsent());
|
assertTrue(builder.registerIfAbsent());
|
||||||
AnvilFuseTestUtil.executeAnvilTest(anvil, player, legalResultData);
|
AnvilFuseTestUtil.executeAnvilFuseTest(anvil, player, legalResultData);
|
||||||
|
|
||||||
AnvilCustomRecipe recipe = getByName(recipeName);
|
AnvilCustomRecipe recipe = getByName(recipeName);
|
||||||
assertNotNull(recipe);
|
assertNotNull(recipe);
|
||||||
|
|
@ -72,21 +72,21 @@ public class CustomAnvilRecipeApiTests extends ConfigResetCustomAnvilTest {
|
||||||
// Remove recipe
|
// Remove recipe
|
||||||
assertTrue(CustomAnvilRecipeApi.removeRecipe(recipe));
|
assertTrue(CustomAnvilRecipeApi.removeRecipe(recipe));
|
||||||
assertFalse(CustomAnvilRecipeApi.removeRecipe(recipe));
|
assertFalse(CustomAnvilRecipeApi.removeRecipe(recipe));
|
||||||
AnvilFuseTestUtil.executeAnvilTest(anvil, player, nullResultData);
|
AnvilFuseTestUtil.executeAnvilFuseTest(anvil, player, nullResultData);
|
||||||
|
|
||||||
recipe = getByName(recipeName);
|
recipe = getByName(recipeName);
|
||||||
assertNull(recipe);
|
assertNull(recipe);
|
||||||
|
|
||||||
// Try to add deleted recipe with no override (should not add)
|
// Try to add deleted recipe with no override (should not add)
|
||||||
assertFalse(CustomAnvilRecipeApi.addRecipe(builder, false));
|
assertFalse(CustomAnvilRecipeApi.addRecipe(builder, false));
|
||||||
AnvilFuseTestUtil.executeAnvilTest(anvil, player, nullResultData);
|
AnvilFuseTestUtil.executeAnvilFuseTest(anvil, player, nullResultData);
|
||||||
|
|
||||||
recipe = getByName(recipeName);
|
recipe = getByName(recipeName);
|
||||||
assertNull(recipe);
|
assertNull(recipe);
|
||||||
|
|
||||||
// Try to add deleted recipe with override (should add)
|
// Try to add deleted recipe with override (should add)
|
||||||
assertTrue(CustomAnvilRecipeApi.addRecipe(builder, true));
|
assertTrue(CustomAnvilRecipeApi.addRecipe(builder, true));
|
||||||
AnvilFuseTestUtil.executeAnvilTest(anvil, player, legalResultData);
|
AnvilFuseTestUtil.executeAnvilFuseTest(anvil, player, legalResultData);
|
||||||
|
|
||||||
recipe = getByName(recipeName);
|
recipe = getByName(recipeName);
|
||||||
assertNotNull(recipe);
|
assertNotNull(recipe);
|
||||||
|
|
@ -119,7 +119,7 @@ public class CustomAnvilRecipeApiTests extends ConfigResetCustomAnvilTest {
|
||||||
null, null
|
null, null
|
||||||
);
|
);
|
||||||
|
|
||||||
AnvilFuseTestUtil.executeAnvilTest(anvil, player, nullResultData);
|
AnvilFuseTestUtil.executeAnvilFuseTest(anvil, player, nullResultData);
|
||||||
|
|
||||||
AnvilRecipeBuilder builder = new AnvilRecipeBuilder(recipeName);
|
AnvilRecipeBuilder builder = new AnvilRecipeBuilder(recipeName);
|
||||||
builder.setExactCount(false)
|
builder.setExactCount(false)
|
||||||
|
|
@ -130,8 +130,8 @@ public class CustomAnvilRecipeApiTests extends ConfigResetCustomAnvilTest {
|
||||||
assertTrue(builder.registerIfAbsent());
|
assertTrue(builder.registerIfAbsent());
|
||||||
|
|
||||||
// Now working test
|
// Now working test
|
||||||
AnvilFuseTestUtil.executeAnvilTest(anvil, player, legalResultData1);
|
AnvilFuseTestUtil.executeAnvilFuseTest(anvil, player, legalResultData1);
|
||||||
AnvilFuseTestUtil.executeAnvilTest(anvil, player, legalResultData2);
|
AnvilFuseTestUtil.executeAnvilFuseTest(anvil, player, legalResultData2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ import org.mockbukkit.mockbukkit.entity.PlayerMock;
|
||||||
import org.mockbukkit.mockbukkit.inventory.ItemStackMock;
|
import org.mockbukkit.mockbukkit.inventory.ItemStackMock;
|
||||||
import xyz.alexcrea.cuanvil.config.ConfigHolder;
|
import xyz.alexcrea.cuanvil.config.ConfigHolder;
|
||||||
import xyz.alexcrea.cuanvil.tests.ConfigResetCustomAnvilTest;
|
import xyz.alexcrea.cuanvil.tests.ConfigResetCustomAnvilTest;
|
||||||
import xyz.alexcrea.cuanvil.util.AnvilFuseTestData;
|
import xyz.alexcrea.cuanvil.data.AnvilFuseTestData;
|
||||||
import xyz.alexcrea.cuanvil.util.AnvilFuseTestUtil;
|
import xyz.alexcrea.cuanvil.util.AnvilFuseTestUtil;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.*;
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
|
@ -58,7 +58,7 @@ public class UnitRepairApiTests extends ConfigResetCustomAnvilTest {
|
||||||
2
|
2
|
||||||
);
|
);
|
||||||
|
|
||||||
AnvilFuseTestUtil.executeAnvilTest(anvil, player, legalResultData);
|
AnvilFuseTestUtil.executeAnvilFuseTest(anvil, player, legalResultData);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
@ -76,7 +76,7 @@ public class UnitRepairApiTests extends ConfigResetCustomAnvilTest {
|
||||||
// Remove unit repair
|
// Remove unit repair
|
||||||
assertTrue(UnitRepairApi.removeUnitRepair(Material.DIAMOND, Material.DIAMOND_PICKAXE));
|
assertTrue(UnitRepairApi.removeUnitRepair(Material.DIAMOND, Material.DIAMOND_PICKAXE));
|
||||||
|
|
||||||
AnvilFuseTestUtil.executeAnvilTest(anvil, player, nullResultData);
|
AnvilFuseTestUtil.executeAnvilFuseTest(anvil, player, nullResultData);
|
||||||
|
|
||||||
// see override
|
// see override
|
||||||
assertFalse(UnitRepairApi.addUnitRepair(Material.DIAMOND, Material.DIAMOND_PICKAXE, 0.25));
|
assertFalse(UnitRepairApi.addUnitRepair(Material.DIAMOND, Material.DIAMOND_PICKAXE, 0.25));
|
||||||
|
|
@ -107,12 +107,12 @@ public class UnitRepairApiTests extends ConfigResetCustomAnvilTest {
|
||||||
2
|
2
|
||||||
);
|
);
|
||||||
|
|
||||||
AnvilFuseTestUtil.executeAnvilTest(anvil, player, nullResultData);
|
AnvilFuseTestUtil.executeAnvilFuseTest(anvil, player, nullResultData);
|
||||||
|
|
||||||
// Add unit repair
|
// Add unit repair
|
||||||
assertTrue(UnitRepairApi.addUnitRepair(Material.STICK, Material.DIAMOND_PICKAXE));
|
assertTrue(UnitRepairApi.addUnitRepair(Material.STICK, Material.DIAMOND_PICKAXE));
|
||||||
assertFalse(UnitRepairApi.addUnitRepair(Material.STICK, Material.DIAMOND_PICKAXE));
|
assertFalse(UnitRepairApi.addUnitRepair(Material.STICK, Material.DIAMOND_PICKAXE));
|
||||||
AnvilFuseTestUtil.executeAnvilTest(anvil, player, legalResultData);
|
AnvilFuseTestUtil.executeAnvilFuseTest(anvil, player, legalResultData);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package xyz.alexcrea.cuanvil.util;
|
package xyz.alexcrea.cuanvil.data;
|
||||||
|
|
||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package xyz.alexcrea.cuanvil.util;
|
package xyz.alexcrea.cuanvil.data;
|
||||||
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
250
src/test/java/xyz/alexcrea/cuanvil/data/TestDataContainer.java
Normal file
250
src/test/java/xyz/alexcrea/cuanvil/data/TestDataContainer.java
Normal file
|
|
@ -0,0 +1,250 @@
|
||||||
|
package xyz.alexcrea.cuanvil.data;
|
||||||
|
|
||||||
|
import org.bukkit.entity.HumanEntity;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.inventory.AnvilInventory;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
import org.junit.jupiter.api.Assertions;
|
||||||
|
import xyz.alexcrea.cuanvil.util.AnvilFuseTestUtil;
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
public record TestDataContainer(
|
||||||
|
@NotNull AnvilFuseTestData fuseData,
|
||||||
|
@Nullable AnvilClickTestData clickData
|
||||||
|
) {
|
||||||
|
|
||||||
|
public void executeTest(AnvilInventory anvil, Player player) {
|
||||||
|
executeFuseTest(anvil, player);
|
||||||
|
if (clickData != null) executeClickTest(anvil, player);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void executeFuseTest(AnvilInventory anvil, HumanEntity player) {
|
||||||
|
AnvilFuseTestUtil.executeAnvilFuseTest(anvil, player, fuseData);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void executeClickTest(AnvilInventory anvil, Player player) {
|
||||||
|
Assertions.assertNotNull(clickData);
|
||||||
|
AnvilFuseTestUtil.executeAnvilClickTest(anvil, player, clickData);
|
||||||
|
}
|
||||||
|
|
||||||
|
public @NotNull TestDataContainer nullifyResult() {
|
||||||
|
return new TestDataContainer(
|
||||||
|
new AnvilFuseTestData(
|
||||||
|
fuseData.leftItem(), fuseData.rightItem(),
|
||||||
|
null
|
||||||
|
), null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public @NotNull TestDataContainer setCost(
|
||||||
|
@Nullable Integer priceAfterLeft,
|
||||||
|
@Nullable Integer priceAfterRight,
|
||||||
|
int priceAfterBoth
|
||||||
|
) {
|
||||||
|
AnvilFuseTestData data = new AnvilFuseTestData(
|
||||||
|
fuseData.leftItem(), fuseData.rightItem(), fuseData.expectedResult(),
|
||||||
|
fuseData.expectedAfterLeftPlaced(),
|
||||||
|
fuseData.expectedAfterRightPlaced(),
|
||||||
|
priceAfterLeft,
|
||||||
|
priceAfterRight,
|
||||||
|
priceAfterBoth
|
||||||
|
);
|
||||||
|
|
||||||
|
AnvilClickTestData CData;
|
||||||
|
if (clickData == null) {
|
||||||
|
CData = null;
|
||||||
|
} else {
|
||||||
|
CData = new AnvilClickTestData(
|
||||||
|
clickData.leftItem(), clickData.rightItem(), clickData.resultSlotItem(),
|
||||||
|
clickData.expectedCursor(), priceAfterBoth,
|
||||||
|
clickData.expectedResult(),
|
||||||
|
clickData.testNoLevelNoChange(), clickData.npChangeResult()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return new TestDataContainer(data, CData);
|
||||||
|
}
|
||||||
|
|
||||||
|
public @NotNull TestDataContainer setCost(
|
||||||
|
int priceAfterBoth
|
||||||
|
) {
|
||||||
|
return setCost(null, null, priceAfterBoth);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set fuse items
|
||||||
|
public @NotNull TestDataContainer setFuseItems(@Nullable ItemStack left, @Nullable ItemStack right, @Nullable ItemStack expected) {
|
||||||
|
AnvilFuseTestData data = new AnvilFuseTestData(
|
||||||
|
left, right, expected,
|
||||||
|
fuseData.expectedAfterLeftPlaced(),
|
||||||
|
fuseData.expectedAfterRightPlaced(),
|
||||||
|
fuseData.expectedPriceAfterLeftPlaced(),
|
||||||
|
fuseData.expectedPriceAfterRightPlaced(),
|
||||||
|
fuseData.expectedPriceAfterBothPlaced()
|
||||||
|
);
|
||||||
|
return new TestDataContainer(data, clickData);
|
||||||
|
}
|
||||||
|
|
||||||
|
public @NotNull TestDataContainer setFuseItems(
|
||||||
|
@Nullable ItemStack left, @Nullable ItemStack right, @Nullable ItemStack expected,
|
||||||
|
@Nullable ItemStack leftExpected, @Nullable ItemStack rightExpected) {
|
||||||
|
AnvilFuseTestData data = new AnvilFuseTestData(
|
||||||
|
left, right, expected,
|
||||||
|
leftExpected,
|
||||||
|
rightExpected,
|
||||||
|
fuseData.expectedPriceAfterLeftPlaced(),
|
||||||
|
fuseData.expectedPriceAfterRightPlaced(),
|
||||||
|
fuseData.expectedPriceAfterBothPlaced()
|
||||||
|
);
|
||||||
|
return new TestDataContainer(data, clickData);
|
||||||
|
}
|
||||||
|
|
||||||
|
public @NotNull TestDataContainer setFuseLeft(@Nullable ItemStack left) {
|
||||||
|
AnvilFuseTestData data = new AnvilFuseTestData(
|
||||||
|
left, fuseData.rightItem(), fuseData.expectedResult(),
|
||||||
|
fuseData.expectedAfterLeftPlaced(),
|
||||||
|
fuseData.expectedAfterRightPlaced(),
|
||||||
|
fuseData.expectedPriceAfterLeftPlaced(),
|
||||||
|
fuseData.expectedPriceAfterRightPlaced(),
|
||||||
|
fuseData.expectedPriceAfterBothPlaced()
|
||||||
|
);
|
||||||
|
return new TestDataContainer(data, clickData);
|
||||||
|
}
|
||||||
|
|
||||||
|
public @NotNull TestDataContainer setFuseRight(@Nullable ItemStack right) {
|
||||||
|
AnvilFuseTestData data = new AnvilFuseTestData(
|
||||||
|
fuseData.leftItem(), right, fuseData.expectedResult(),
|
||||||
|
fuseData.expectedAfterLeftPlaced(),
|
||||||
|
fuseData.expectedAfterRightPlaced(),
|
||||||
|
fuseData.expectedPriceAfterLeftPlaced(),
|
||||||
|
fuseData.expectedPriceAfterRightPlaced(),
|
||||||
|
fuseData.expectedPriceAfterBothPlaced()
|
||||||
|
);
|
||||||
|
return new TestDataContainer(data, clickData);
|
||||||
|
}
|
||||||
|
|
||||||
|
public @NotNull TestDataContainer setFuseExpected(@Nullable ItemStack expected) {
|
||||||
|
AnvilFuseTestData data = new AnvilFuseTestData(
|
||||||
|
fuseData.leftItem(), fuseData.rightItem(), expected,
|
||||||
|
fuseData.expectedAfterLeftPlaced(),
|
||||||
|
fuseData.expectedAfterRightPlaced(),
|
||||||
|
fuseData.expectedPriceAfterLeftPlaced(),
|
||||||
|
fuseData.expectedPriceAfterRightPlaced(),
|
||||||
|
fuseData.expectedPriceAfterBothPlaced()
|
||||||
|
);
|
||||||
|
return new TestDataContainer(data, clickData);
|
||||||
|
}
|
||||||
|
|
||||||
|
public @NotNull TestDataContainer setFuseExpectedLeft(@Nullable ItemStack expected) {
|
||||||
|
AnvilFuseTestData data = new AnvilFuseTestData(
|
||||||
|
fuseData.leftItem(), fuseData.rightItem(), fuseData.expectedResult(),
|
||||||
|
expected,
|
||||||
|
fuseData.expectedAfterRightPlaced(),
|
||||||
|
fuseData.expectedPriceAfterLeftPlaced(),
|
||||||
|
fuseData.expectedPriceAfterRightPlaced(),
|
||||||
|
fuseData.expectedPriceAfterBothPlaced()
|
||||||
|
);
|
||||||
|
return new TestDataContainer(data, clickData);
|
||||||
|
}
|
||||||
|
|
||||||
|
public @NotNull TestDataContainer setFuseExpectedRight(@Nullable ItemStack expected) {
|
||||||
|
AnvilFuseTestData data = new AnvilFuseTestData(
|
||||||
|
fuseData.leftItem(), fuseData.rightItem(), fuseData.expectedResult(),
|
||||||
|
fuseData.expectedAfterLeftPlaced(),
|
||||||
|
expected,
|
||||||
|
fuseData.expectedPriceAfterLeftPlaced(),
|
||||||
|
fuseData.expectedPriceAfterRightPlaced(),
|
||||||
|
fuseData.expectedPriceAfterBothPlaced()
|
||||||
|
);
|
||||||
|
return new TestDataContainer(data, clickData);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set click items
|
||||||
|
public @NotNull TestDataContainer setClickLeft(@Nullable ItemStack left) {
|
||||||
|
if (clickData == null) return this;
|
||||||
|
AnvilClickTestData data = new AnvilClickTestData(
|
||||||
|
left, clickData.rightItem(), clickData.resultSlotItem(), clickData.expectedCursor(),
|
||||||
|
clickData.levelCost(), clickData.expectedResult(),
|
||||||
|
clickData.testNoLevelNoChange(), clickData.npChangeResult()
|
||||||
|
);
|
||||||
|
|
||||||
|
return new TestDataContainer(fuseData, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
public @NotNull TestDataContainer setClickRight(@Nullable ItemStack right) {
|
||||||
|
if (clickData == null) return this;
|
||||||
|
AnvilClickTestData data = new AnvilClickTestData(
|
||||||
|
clickData.leftItem(), right, clickData.resultSlotItem(), clickData.expectedCursor(),
|
||||||
|
clickData.levelCost(), clickData.expectedResult(),
|
||||||
|
clickData.testNoLevelNoChange(), clickData.npChangeResult()
|
||||||
|
);
|
||||||
|
|
||||||
|
return new TestDataContainer(fuseData, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
public @NotNull TestDataContainer setClickOutput(@Nullable ItemStack output) {
|
||||||
|
if (clickData == null) return this;
|
||||||
|
AnvilClickTestData data = new AnvilClickTestData(
|
||||||
|
clickData.leftItem(), clickData.rightItem(), output, clickData.expectedCursor(),
|
||||||
|
clickData.levelCost(), clickData.expectedResult(),
|
||||||
|
clickData.testNoLevelNoChange(), clickData.npChangeResult()
|
||||||
|
);
|
||||||
|
|
||||||
|
return new TestDataContainer(fuseData, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
public @NotNull TestDataContainer setClickCursor(@Nullable ItemStack cursor) {
|
||||||
|
if (clickData == null) return this;
|
||||||
|
AnvilClickTestData data = new AnvilClickTestData(
|
||||||
|
clickData.leftItem(), clickData.rightItem(), clickData.resultSlotItem(), cursor,
|
||||||
|
clickData.levelCost(), clickData.expectedResult(),
|
||||||
|
clickData.testNoLevelNoChange(), clickData.npChangeResult()
|
||||||
|
);
|
||||||
|
|
||||||
|
return new TestDataContainer(fuseData, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Both item
|
||||||
|
public @NotNull TestDataContainer setExpectedResult(@Nullable ItemStack result) {
|
||||||
|
return setFuseExpected(result).setClickCursor(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get fuse item
|
||||||
|
public @Nullable ItemStack getLeftFuse() {
|
||||||
|
return fuseData.leftItem();
|
||||||
|
}
|
||||||
|
|
||||||
|
public @Nullable ItemStack getRightFuse() {
|
||||||
|
return fuseData.rightItem();
|
||||||
|
}
|
||||||
|
|
||||||
|
public @Nullable ItemStack getExpectedFuse() {
|
||||||
|
return fuseData.expectedResult();
|
||||||
|
}
|
||||||
|
|
||||||
|
public @Nullable ItemStack getLeftExpectedFuse() {
|
||||||
|
return fuseData.expectedAfterLeftPlaced();
|
||||||
|
}
|
||||||
|
|
||||||
|
public @Nullable ItemStack getRightExpectedFuse() {
|
||||||
|
return fuseData.expectedAfterRightPlaced();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get click item
|
||||||
|
public @Nullable ItemStack getLeftClick() {
|
||||||
|
return clickData == null ? null : clickData.leftItem();
|
||||||
|
}
|
||||||
|
|
||||||
|
public @Nullable ItemStack getRightClick() {
|
||||||
|
return clickData == null ? null : clickData.rightItem();
|
||||||
|
}
|
||||||
|
|
||||||
|
public @Nullable ItemStack getOutputClick() {
|
||||||
|
return clickData == null ? null : clickData.resultSlotItem();
|
||||||
|
}
|
||||||
|
|
||||||
|
public @Nullable ItemStack getCursorClick() {
|
||||||
|
return clickData == null ? null : clickData.expectedCursor();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -13,6 +13,8 @@ import org.bukkit.inventory.meta.Repairable;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.junit.jupiter.api.Assertions;
|
import org.junit.jupiter.api.Assertions;
|
||||||
|
import xyz.alexcrea.cuanvil.data.AnvilClickTestData;
|
||||||
|
import xyz.alexcrea.cuanvil.data.AnvilFuseTestData;
|
||||||
import xyz.alexcrea.cuanvil.enchant.CAEnchantment;
|
import xyz.alexcrea.cuanvil.enchant.CAEnchantment;
|
||||||
import xyz.alexcrea.cuanvil.listener.AnvilResultListener;
|
import xyz.alexcrea.cuanvil.listener.AnvilResultListener;
|
||||||
import xyz.alexcrea.cuanvil.listener.PrepareAnvilListener;
|
import xyz.alexcrea.cuanvil.listener.PrepareAnvilListener;
|
||||||
|
|
@ -60,6 +62,7 @@ public class AnvilFuseTestUtil {
|
||||||
Integer... levels) {
|
Integer... levels) {
|
||||||
return prepareItem(material, 0, enchantmentNames, levels);
|
return prepareItem(material, 0, enchantmentNames, levels);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ItemStack prepareItem(@NotNull Material material,
|
public static ItemStack prepareItem(@NotNull Material material,
|
||||||
int repairCost,
|
int repairCost,
|
||||||
@NotNull List<String> enchantmentNames,
|
@NotNull List<String> enchantmentNames,
|
||||||
|
|
@ -99,7 +102,7 @@ public class AnvilFuseTestUtil {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void executeAnvilTest(
|
public static void executeAnvilFuseTest(
|
||||||
@NotNull AnvilInventory anvil,
|
@NotNull AnvilInventory anvil,
|
||||||
@NotNull HumanEntity player,
|
@NotNull HumanEntity player,
|
||||||
@NotNull AnvilFuseTestData data
|
@NotNull AnvilFuseTestData data
|
||||||
|
|
@ -125,7 +128,7 @@ public class AnvilFuseTestUtil {
|
||||||
data.leftItem(), data.expectedResult());
|
data.leftItem(), data.expectedResult());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void executeAnvilClick(
|
public static void executeAnvilClickTest(
|
||||||
@NotNull AnvilInventory anvil,
|
@NotNull AnvilInventory anvil,
|
||||||
@NotNull Player player,
|
@NotNull Player player,
|
||||||
@NotNull AnvilClickTestData data
|
@NotNull AnvilClickTestData data
|
||||||
|
|
@ -152,11 +155,14 @@ public class AnvilFuseTestUtil {
|
||||||
|
|
||||||
simulateClick(anvil, player, data.expectedResult());
|
simulateClick(anvil, player, data.expectedResult());
|
||||||
|
|
||||||
// Nothing should have changed
|
// Should have similated the click
|
||||||
assertEqual(data.leftItem(), anvil.getFirstItem());
|
assertEqual(data.leftItem(), anvil.getFirstItem());
|
||||||
assertEqual(data.rightItem(), anvil.getSecondItem());
|
assertEqual(data.rightItem(), anvil.getSecondItem());
|
||||||
assertEqual(data.resultSlotItem(), anvil.getResult());
|
assertEqual(data.resultSlotItem(), anvil.getResult());
|
||||||
assertEqual(data.expectedCursor(), data.expectedCursor());
|
assertEqual(data.expectedCursor(), data.expectedCursor());
|
||||||
|
|
||||||
|
// Test if the player has no more xp
|
||||||
|
Assertions.assertEquals(0, player.getLevel(), "Player has more level than expected");
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void simulateClick(
|
private static void simulateClick(
|
||||||
|
|
@ -201,9 +207,10 @@ public class AnvilFuseTestUtil {
|
||||||
|
|
||||||
public static void assertEqual(@Nullable ItemStack expected, @Nullable ItemStack other) {
|
public static void assertEqual(@Nullable ItemStack expected, @Nullable ItemStack other) {
|
||||||
boolean secondIsAir = isAir(other);
|
boolean secondIsAir = isAir(other);
|
||||||
if(isAir(expected)) Assertions.assertTrue(secondIsAir,"Item "+other+" was not AIR but was expected to be air");
|
if (isAir(expected))
|
||||||
|
Assertions.assertTrue(secondIsAir, "Item " + other + " was not air but was expected to be");
|
||||||
else {
|
else {
|
||||||
Assertions.assertFalse(secondIsAir,"Item "+other+" was expected not to be air");
|
Assertions.assertFalse(secondIsAir, "Item " + other + " is air but was expected to be " + expected);
|
||||||
|
|
||||||
expected.setDurability(expected.getDurability());
|
expected.setDurability(expected.getDurability());
|
||||||
other.setDurability(other.getDurability());
|
other.setDurability(other.getDurability());
|
||||||
|
|
|
||||||
|
|
@ -43,10 +43,17 @@ permissions:
|
||||||
# color permissions
|
# color permissions
|
||||||
ca.color.code:
|
ca.color.code:
|
||||||
default: op
|
default: op
|
||||||
description: Allow player to use color code if permission is required (toggleable)
|
description: Allow player to use color code if enabled (toggleable)
|
||||||
ca.color.hex:
|
ca.color.hex:
|
||||||
default: op
|
default: op
|
||||||
description: Allow player to use hexadecimal color if permission is required (toggleable)
|
description: Allow player to use hexadecimal color if enabled (toggleable)
|
||||||
|
# lore edit permissions
|
||||||
|
ca.lore_edit.book:
|
||||||
|
default: op
|
||||||
|
description: Allow player to edit lore via book and quil if enabled (toggleable)
|
||||||
|
ca.lore_edit.paper:
|
||||||
|
default: op
|
||||||
|
description: Allow player to edit lore via paper if enabled (toggleable)
|
||||||
|
|
||||||
|
|
||||||
# soft depend on old name (UnsafeEnchantsPlus), so I can disable it if it is on the same server (old name for this plugin)
|
# soft depend on old name (UnsafeEnchantsPlus), so I can disable it if it is on the same server (old name for this plugin)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue