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

Fixed some unit tests

This commit is contained in:
TheBusyBiscuit 2020-05-08 21:26:18 +02:00
parent cc21fb8fe3
commit 974657fadc
3 changed files with 9 additions and 10 deletions

View File

@ -196,10 +196,7 @@ public final class Slimefun {
* <code>false</code> otherwise.
*/
public static boolean isEnabled(Player p, SlimefunItem sfItem, boolean message) {
if (sfItem.getState() == ItemState.VANILLA_FALLBACK) {
return true;
}
else if (sfItem.isDisabled()) {
if (sfItem.isDisabled()) {
if (message) {
SlimefunPlugin.getLocal().sendMessage(p, "messages.disabled-item", true);
}

View File

@ -20,7 +20,6 @@ import io.github.thebusybiscuit.slimefun4.core.categories.FlexCategory;
import io.github.thebusybiscuit.slimefun4.core.categories.LockedCategory;
import io.github.thebusybiscuit.slimefun4.core.categories.SeasonalCategory;
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideLayout;
import io.github.thebusybiscuit.slimefun4.implementation.items.VanillaItem;
import io.github.thebusybiscuit.slimefun4.mocks.SlimefunMocks;
import me.mrCookieSlime.Slimefun.SlimefunPlugin;
import me.mrCookieSlime.Slimefun.Objects.Category;
@ -61,16 +60,17 @@ public class TestCategories {
@Test
public void testHidden() {
Category category = new Category(new NamespacedKey(plugin, "testCategory2"), new ItemStack(Material.BEACON));
Category category = new Category(new NamespacedKey(plugin, "hiddenCategory"), new ItemStack(Material.BEACON));
Player player = server.addPlayer();
// Empty Categories are also hidden
Assertions.assertTrue(category.isHidden(player));
VanillaItem vanillaItem = SlimefunMocks.mockVanillaItem(Material.BEETROOT, false);
vanillaItem.setCategory(category);
vanillaItem.register(plugin);
vanillaItem.load();
SlimefunItem disabledItem = SlimefunMocks.mockSlimefunItem("DISABLED_CATEGORY_ITEM", new CustomItem(Material.BEETROOT, "&4Disabled"));
SlimefunPlugin.getItemCfg().setValue("DISABLED_CATEGORY_ITEM.enabled", false);
disabledItem.setCategory(category);
disabledItem.register(plugin);
disabledItem.load();
// A disabled Item should also make the Category hide
Assertions.assertTrue(category.isHidden(player));

View File

@ -68,6 +68,8 @@ public class TextCustomTextureService {
ItemStack stack = new ItemStack(Material.DIAMOND);
service.setTexture(stack, item.getID());
Assertions.assertTrue(stack.getItemMeta().hasCustomModelData());
Assertions.assertEquals(300, stack.getItemMeta().getCustomModelData());
}
}