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

Requested changes

This commit is contained in:
Daniel Walsh 2021-03-28 13:26:57 +01:00
parent 488ffd951b
commit ec37fb142a
No known key found for this signature in database
GPG Key ID: 91C6D8D7C4011D82
3 changed files with 6 additions and 4 deletions

View File

@ -41,7 +41,7 @@ public class SoulboundListener implements Listener {
for (int slot = 0; slot < p.getInventory().getSize(); slot++) { for (int slot = 0; slot < p.getInventory().getSize(); slot++) {
ItemStack item = p.getInventory().getItem(slot); ItemStack item = p.getInventory().getItem(slot);
// Store soulbound items for later rtrieval // Store soulbound items for later retrieval
if (SlimefunUtils.isSoulbound(item, p.getWorld())) { if (SlimefunUtils.isSoulbound(item, p.getWorld())) {
items.put(slot, item); items.put(slot, item);
} }

View File

@ -113,7 +113,7 @@ public final class SlimefunUtils {
if (sfItem instanceof Soulbound) { if (sfItem instanceof Soulbound) {
if (world != null) { if (world != null) {
return !sfItem.isDisabled() && !sfItem.isDisabledIn(world); return !sfItem.isDisabledIn(world);
} else { } else {
return !sfItem.isDisabled(); return !sfItem.isDisabled();
} }

View File

@ -1,17 +1,16 @@
package io.github.thebusybiscuit.slimefun4.testing.tests.listeners; package io.github.thebusybiscuit.slimefun4.testing.tests.listeners;
import be.seeseemelk.mockbukkit.WorldMock;
import io.github.thebusybiscuit.slimefun4.implementation.items.magical.SoulboundItem; import io.github.thebusybiscuit.slimefun4.implementation.items.magical.SoulboundItem;
import io.github.thebusybiscuit.slimefun4.testing.TestUtilities; import io.github.thebusybiscuit.slimefun4.testing.TestUtilities;
import me.mrCookieSlime.Slimefun.Lists.RecipeType; import me.mrCookieSlime.Slimefun.Lists.RecipeType;
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.event.entity.EntityDeathEvent; import org.bukkit.event.entity.EntityDeathEvent;
import org.bukkit.event.player.PlayerRespawnEvent; import org.bukkit.event.player.PlayerRespawnEvent;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
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.DisplayName;
import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource; import org.junit.jupiter.params.provider.ValueSource;
@ -42,6 +41,7 @@ class TestSoulboundListener {
@ParameterizedTest @ParameterizedTest
@ValueSource(booleans = { true, false }) @ValueSource(booleans = { true, false })
@DisplayName("Test if the soulbound item is dropped or not")
void testItemDrop(boolean soulbound) { void testItemDrop(boolean soulbound) {
PlayerMock player = server.addPlayer(); PlayerMock player = server.addPlayer();
ItemStack item = new CustomItem(Material.DIAMOND_SWORD, "&4Cool Sword"); ItemStack item = new CustomItem(Material.DIAMOND_SWORD, "&4Cool Sword");
@ -56,6 +56,7 @@ class TestSoulboundListener {
@ParameterizedTest @ParameterizedTest
@ValueSource(booleans = { true, false }) @ValueSource(booleans = { true, false })
@DisplayName("Test if soulbound item is dropped if disabled")
void testItemDropIfItemDisabled(boolean enabled) { void testItemDropIfItemDisabled(boolean enabled) {
PlayerMock player = server.addPlayer(); PlayerMock player = server.addPlayer();
@ -79,6 +80,7 @@ class TestSoulboundListener {
@ParameterizedTest @ParameterizedTest
@ValueSource(booleans = { true, false }) @ValueSource(booleans = { true, false })
@DisplayName("Test if soulbound item is returned to player")
void testItemRecover(boolean soulbound) { void testItemRecover(boolean soulbound) {
PlayerMock player = server.addPlayer(); PlayerMock player = server.addPlayer();
ItemStack item = new CustomItem(Material.DIAMOND_SWORD, "&4Cool Sword"); ItemStack item = new CustomItem(Material.DIAMOND_SWORD, "&4Cool Sword");