From 69d74a10f16ac197a905123daf0a487c8d9b1e6c Mon Sep 17 00:00:00 2001 From: Fulminazzo Date: Wed, 3 Apr 2024 19:07:04 +0200 Subject: [PATCH] Refactored code to use fully qualified name only for Bukkit classes --- .../angrybear/yagl/LegacyItemAdapterTest.java | 25 +++++----- .../java/it/angrybear/yagl/ItemAdapter.java | 50 ++++++++++--------- .../it/angrybear/yagl/ItemAdapterTest.java | 26 ++++++---- .../yagl/LegacyWrappersAdapterTest.java | 6 +-- .../yagl/ObsoleteWrappersAdapterTest.java | 7 ++- .../angrybear/yagl/WrappersAdapterTest.java | 45 +++++++++-------- 6 files changed, 85 insertions(+), 74 deletions(-) diff --git a/item/bukkit/legacy/src/test/java/it/angrybear/yagl/LegacyItemAdapterTest.java b/item/bukkit/legacy/src/test/java/it/angrybear/yagl/LegacyItemAdapterTest.java index 0380280d..9f10212d 100644 --- a/item/bukkit/legacy/src/test/java/it/angrybear/yagl/LegacyItemAdapterTest.java +++ b/item/bukkit/legacy/src/test/java/it/angrybear/yagl/LegacyItemAdapterTest.java @@ -3,13 +3,14 @@ import it.angrybear.yagl.items.BukkitItem; import it.angrybear.yagl.items.Item; import it.angrybear.yagl.items.fields.ItemFlag; +import it.angrybear.yagl.items.recipes.FurnaceRecipe; +import it.angrybear.yagl.items.recipes.Recipe; +import it.angrybear.yagl.items.recipes.ShapedRecipe; +import it.angrybear.yagl.items.recipes.ShapelessRecipe; import it.fulminazzo.fulmicollection.objects.Refl; import it.fulminazzo.jbukkit.BukkitUtils; import org.bukkit.Material; -import org.bukkit.inventory.FurnaceRecipe; import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.ShapedRecipe; -import org.bukkit.inventory.ShapelessRecipe; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -41,14 +42,14 @@ void testItemConversion() { @Test void testShapedRecipeConversion() { - ShapedRecipe expected = new ShapedRecipe(new ItemStack(Material.STONE)); + org.bukkit.inventory.ShapedRecipe expected = new org.bukkit.inventory.ShapedRecipe(new ItemStack(Material.STONE)); expected.shape("ABC", "DEF"); Material[] materials = new Material[]{Material.IRON_INGOT, Material.GOLD_INGOT, Material.REDSTONE, Material.DIAMOND, Material.EMERALD, Material.INK_SACK}; for (int i = 0; i < materials.length; i++) expected.setIngredient((char) ('A' + i), new ItemStack(materials[i]).getData()); - it.angrybear.yagl.items.recipes.ShapedRecipe recipe = new it.angrybear.yagl.items.recipes.ShapedRecipe("test") + ShapedRecipe recipe = new ShapedRecipe("test") .setOutput(Item.newItem("STONE")).setShape(2, 3); for (int i = 0; i < materials.length; i++) recipe.setIngredient(i, BukkitItem.newItem(materials[i])); @@ -66,10 +67,10 @@ void testShapedRecipeConversion() { @Test void testShapelessRecipeConversion() { - ShapelessRecipe expected = new ShapelessRecipe(new ItemStack(Material.STONE)); + org.bukkit.inventory.ShapelessRecipe expected = new org.bukkit.inventory.ShapelessRecipe(new ItemStack(Material.STONE)); expected.addIngredient(new ItemStack(Material.GRASS).getData()); - it.angrybear.yagl.items.recipes.ShapelessRecipe recipe = new it.angrybear.yagl.items.recipes.ShapelessRecipe("test") + ShapelessRecipe recipe = new ShapelessRecipe("test") .setOutput(Item.newItem("STONE")).addIngredient(Item.newItem("GRASS")); Refl r1 = new Refl<>(expected); @@ -81,10 +82,10 @@ void testShapelessRecipeConversion() { @Test void testFurnaceRecipeConversion() { - FurnaceRecipe expected = new FurnaceRecipe(new ItemStack(Material.STONE), Material.COAL); + org.bukkit.inventory.FurnaceRecipe expected = new org.bukkit.inventory.FurnaceRecipe(new ItemStack(Material.STONE), Material.COAL); new Refl<>(expected).setFieldObject("ingredient", new ItemStack(Material.COAL)); - it.angrybear.yagl.items.recipes.FurnaceRecipe recipe = new it.angrybear.yagl.items.recipes.FurnaceRecipe("test") + FurnaceRecipe recipe = new FurnaceRecipe("test") .setOutput(Item.newItem("STONE")).setIngredient(Item.newItem("COAL")) .setExperience(10).setCookingTime(20); @@ -102,11 +103,11 @@ void testResizeRecipe() { final BukkitItem returnItem = BukkitItem.newItem(Material.REDSTONE_BLOCK); final int size = 4; - ShapedRecipe expected = new ShapedRecipe(returnItem.create()); + org.bukkit.inventory.ShapedRecipe expected = new org.bukkit.inventory.ShapedRecipe(returnItem.create()); expected.shape("AB", "CD"); for (int i = 0; i < size; i++) expected.setIngredient((char) ('A' + i), new ItemStack(craftMaterial).getData()); - it.angrybear.yagl.items.recipes.ShapedRecipe recipe = new it.angrybear.yagl.items.recipes.ShapedRecipe(id) + ShapedRecipe recipe = new ShapedRecipe(id) .setOutput(returnItem).setShape(3, 3); for (int i = 0; i < 9; i++) recipe.setIngredient(i, BukkitItem.newItem(Material.COBBLESTONE)); @@ -131,6 +132,6 @@ void testResizeRecipe() { @Test void testInvalidRecipeType() { - assertThrowsExactly(IllegalArgumentException.class, () -> ItemAdapter.recipeToMinecraft(mock(it.angrybear.yagl.items.recipes.Recipe.class))); + assertThrowsExactly(IllegalArgumentException.class, () -> ItemAdapter.recipeToMinecraft(mock(Recipe.class))); } } \ No newline at end of file diff --git a/item/bukkit/src/main/java/it/angrybear/yagl/ItemAdapter.java b/item/bukkit/src/main/java/it/angrybear/yagl/ItemAdapter.java index 0021fe3e..5b79f302 100644 --- a/item/bukkit/src/main/java/it/angrybear/yagl/ItemAdapter.java +++ b/item/bukkit/src/main/java/it/angrybear/yagl/ItemAdapter.java @@ -3,13 +3,17 @@ import it.angrybear.yagl.items.BukkitItem; import it.angrybear.yagl.items.Item; import it.angrybear.yagl.items.fields.ItemFlag; +import it.angrybear.yagl.items.recipes.FurnaceRecipe; +import it.angrybear.yagl.items.recipes.Recipe; +import it.angrybear.yagl.items.recipes.ShapedRecipe; +import it.angrybear.yagl.items.recipes.ShapelessRecipe; import it.angrybear.yagl.utils.EnumUtils; import it.fulminazzo.fulmicollection.objects.Refl; import it.fulminazzo.fulmicollection.structures.Tuple; import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.enchantments.Enchantment; -import org.bukkit.inventory.*; +import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -110,39 +114,39 @@ private static void invokeNoSuchMethod(final @NotNull Runnable get, final @Nulla } /** - * Converts the {@link it.angrybear.yagl.items.recipes.Recipe} to a Minecraft {@link Recipe}. + * Converts the {@link Recipe} to a Minecraft {@link org.bukkit.inventory.Recipe}. * * @param recipe the recipe * @return the recipe */ - public static Recipe recipeToMinecraft(final @Nullable it.angrybear.yagl.items.recipes.Recipe recipe) { + public static org.bukkit.inventory.Recipe recipeToMinecraft(final @Nullable Recipe recipe) { if (recipe == null) return null; - Recipe result; - if (recipe instanceof it.angrybear.yagl.items.recipes.ShapedRecipe) - result = recipeToMinecraft((it.angrybear.yagl.items.recipes.ShapedRecipe) recipe); - else if (recipe instanceof it.angrybear.yagl.items.recipes.ShapelessRecipe) - result = recipeToMinecraft((it.angrybear.yagl.items.recipes.ShapelessRecipe) recipe); - else if (recipe instanceof it.angrybear.yagl.items.recipes.FurnaceRecipe) - result = recipeToMinecraft((it.angrybear.yagl.items.recipes.FurnaceRecipe) recipe); + org.bukkit.inventory.Recipe result; + if (recipe instanceof ShapedRecipe) + result = recipeToMinecraft((ShapedRecipe) recipe); + else if (recipe instanceof ShapelessRecipe) + result = recipeToMinecraft((ShapelessRecipe) recipe); + else if (recipe instanceof FurnaceRecipe) + result = recipeToMinecraft((FurnaceRecipe) recipe); else throw new IllegalArgumentException("Unrecognized recipe type: " + recipe.getClass()); return result; } - private static Recipe recipeToMinecraft(final @Nullable it.angrybear.yagl.items.recipes.ShapedRecipe recipe) { + private static org.bukkit.inventory.Recipe recipeToMinecraft(final @Nullable ShapedRecipe recipe) { if (recipe == null) return null; final ItemStack output = recipe.getOutput().copy(BukkitItem.class).create(); - Refl r; + Refl r; try { final Object namespacedKey = WrappersAdapter.getNamespacedKey(ID_KEY, recipe.getId()); - r = new Refl<>(ShapedRecipe.class, namespacedKey, output); + r = new Refl<>(org.bukkit.inventory.ShapedRecipe.class, namespacedKey, output); } catch (IllegalStateException e) { - r = new Refl<>(ShapedRecipe.class, output); + r = new Refl<>(org.bukkit.inventory.ShapedRecipe.class, output); } StringBuilder charShape = new StringBuilder(); - it.angrybear.yagl.items.recipes.ShapedRecipe.Shape shape = recipe.getShape(); + ShapedRecipe.Shape shape = recipe.getShape(); char c = 'A'; for (int i = 0; i < shape.getRows(); i++) { for (int j = 0; j < shape.getColumns(); j++) { @@ -162,7 +166,7 @@ private static Recipe recipeToMinecraft(final @Nullable it.angrybear.yagl.items. return r.getObject(); } - private static Recipe recipeToMinecraft(final @Nullable it.angrybear.yagl.items.recipes.ShapelessRecipe recipe) { + private static org.bukkit.inventory.Recipe recipeToMinecraft(final @Nullable ShapelessRecipe recipe) { if (recipe == null) return null; final List ingredients = recipe.getIngredients().stream() @@ -170,12 +174,12 @@ private static Recipe recipeToMinecraft(final @Nullable it.angrybear.yagl.items. .collect(Collectors.toList()); final ItemStack output = recipe.getOutput().copy(BukkitItem.class).create(); - Refl r; + Refl r; try { final Object namespacedKey = WrappersAdapter.getNamespacedKey(ID_KEY, recipe.getId()); - r = new Refl<>(ShapelessRecipe.class, namespacedKey, output); + r = new Refl<>(org.bukkit.inventory.ShapelessRecipe.class, namespacedKey, output); } catch (IllegalStateException e) { - r = new Refl<>(ShapelessRecipe.class, output); + r = new Refl<>(org.bukkit.inventory.ShapelessRecipe.class, output); } r.setFieldObject("ingredients", ingredients); @@ -183,7 +187,7 @@ private static Recipe recipeToMinecraft(final @Nullable it.angrybear.yagl.items. return r.getObject(); } - private static Recipe recipeToMinecraft(final @Nullable it.angrybear.yagl.items.recipes.FurnaceRecipe recipe) { + private static org.bukkit.inventory.Recipe recipeToMinecraft(final @Nullable FurnaceRecipe recipe) { if (recipe == null) return null; final Object ingredient = getItemOrRecipeChoice(recipe.getIngredients().get(0)); @@ -191,12 +195,12 @@ private static Recipe recipeToMinecraft(final @Nullable it.angrybear.yagl.items. final int cookingTime = recipe.getCookingTime(); final float experience = recipe.getExperience(); - Refl r; + Refl r; try { final Object namespacedKey = WrappersAdapter.getNamespacedKey(ID_KEY, recipe.getId()); - r = new Refl<>(FurnaceRecipe.class, namespacedKey, output, Material.STONE, experience, cookingTime); + r = new Refl<>(org.bukkit.inventory.FurnaceRecipe.class, namespacedKey, output, Material.STONE, experience, cookingTime); } catch (IllegalStateException e) { - r = new Refl<>(FurnaceRecipe.class, output, Material.STONE); + r = new Refl<>(org.bukkit.inventory.FurnaceRecipe.class, output, Material.STONE); } r.setFieldObject("ingredient", ingredient); diff --git a/item/bukkit/src/test/java/it/angrybear/yagl/ItemAdapterTest.java b/item/bukkit/src/test/java/it/angrybear/yagl/ItemAdapterTest.java index 1452ce19..4c81e6e2 100644 --- a/item/bukkit/src/test/java/it/angrybear/yagl/ItemAdapterTest.java +++ b/item/bukkit/src/test/java/it/angrybear/yagl/ItemAdapterTest.java @@ -3,11 +3,16 @@ import it.angrybear.yagl.items.BukkitItem; import it.angrybear.yagl.items.Item; import it.angrybear.yagl.items.fields.ItemFlag; +import it.angrybear.yagl.items.recipes.FurnaceRecipe; +import it.angrybear.yagl.items.recipes.Recipe; +import it.angrybear.yagl.items.recipes.ShapedRecipe; +import it.angrybear.yagl.items.recipes.ShapelessRecipe; import it.fulminazzo.fulmicollection.objects.Refl; import it.fulminazzo.jbukkit.BukkitUtils; import org.bukkit.Material; import org.bukkit.NamespacedKey; -import org.bukkit.inventory.*; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.RecipeChoice; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -40,7 +45,7 @@ void testItemConversion() { @Test void testShapedRecipeConversion() { - ShapedRecipe expected = new ShapedRecipe(new NamespacedKey("yagl", "test"), + org.bukkit.inventory.ShapedRecipe expected = new org.bukkit.inventory.ShapedRecipe(new NamespacedKey("yagl", "test"), new ItemStack(Material.STONE)); expected.shape("ABC", "DEF"); Material[] materials = new Material[]{Material.IRON_INGOT, Material.GOLD_INGOT, Material.REDSTONE, @@ -48,7 +53,7 @@ void testShapedRecipeConversion() { for (int i = 0; i < materials.length; i++) expected.setIngredient((char) ('A' + i), new RecipeChoice.ExactChoice(new ItemStack(materials[i]))); - it.angrybear.yagl.items.recipes.ShapedRecipe recipe = new it.angrybear.yagl.items.recipes.ShapedRecipe("test") + ShapedRecipe recipe = new ShapedRecipe("test") .setOutput(Item.newItem("STONE")).setShape(2, 3); for (int i = 0; i < materials.length; i++) recipe.setIngredient(i, BukkitItem.newItem(materials[i])); @@ -66,11 +71,11 @@ void testShapedRecipeConversion() { @Test void testShapelessRecipeConversion() { - ShapelessRecipe expected = new ShapelessRecipe(new NamespacedKey("yagl", "test"), + org.bukkit.inventory.ShapelessRecipe expected = new org.bukkit.inventory.ShapelessRecipe(new NamespacedKey("yagl", "test"), new ItemStack(Material.STONE)); expected.addIngredient(new RecipeChoice.ExactChoice(new ItemStack(Material.GRASS))); - it.angrybear.yagl.items.recipes.ShapelessRecipe recipe = new it.angrybear.yagl.items.recipes.ShapelessRecipe("test") + ShapelessRecipe recipe = new ShapelessRecipe("test") .setOutput(Item.newItem("STONE")).addIngredient(Item.newItem("GRASS")); Refl r1 = new Refl<>(expected); @@ -82,11 +87,11 @@ void testShapelessRecipeConversion() { @Test void testFurnaceRecipeConversion() { - FurnaceRecipe expected = new FurnaceRecipe(new NamespacedKey("yagl", "test"), + org.bukkit.inventory.FurnaceRecipe expected = new org.bukkit.inventory.FurnaceRecipe(new NamespacedKey("yagl", "test"), new ItemStack(Material.STONE), Material.COAL, 10, 20); new Refl<>(expected).setFieldObject("ingredient", new RecipeChoice.ExactChoice(new ItemStack(Material.COAL))); - it.angrybear.yagl.items.recipes.FurnaceRecipe recipe = new it.angrybear.yagl.items.recipes.FurnaceRecipe("test") + FurnaceRecipe recipe = new FurnaceRecipe("test") .setOutput(Item.newItem("STONE")).setIngredient(Item.newItem("COAL")) .setExperience(10).setCookingTime(20); @@ -104,11 +109,12 @@ void testResizeRecipe() { final BukkitItem returnItem = BukkitItem.newItem(Material.REDSTONE_BLOCK); final int size = 4; - ShapedRecipe expected = new ShapedRecipe(new NamespacedKey("yagl", id), returnItem.create()); + org.bukkit.inventory.ShapedRecipe expected = new org.bukkit.inventory.ShapedRecipe(new NamespacedKey("yagl", id), + returnItem.create()); expected.shape("AB", "CD"); for (int i = 0; i < size; i++) expected.setIngredient((char) ('A' + i), new RecipeChoice.ExactChoice(new ItemStack(craftMaterial))); - it.angrybear.yagl.items.recipes.ShapedRecipe recipe = new it.angrybear.yagl.items.recipes.ShapedRecipe(id) + ShapedRecipe recipe = new ShapedRecipe(id) .setOutput(returnItem).setShape(3, 3); for (int i = 0; i < 9; i++) recipe.setIngredient(i, BukkitItem.newItem(Material.COBBLESTONE)); @@ -133,6 +139,6 @@ void testResizeRecipe() { @Test void testInvalidRecipeType() { - assertThrowsExactly(IllegalArgumentException.class, () -> ItemAdapter.recipeToMinecraft(mock(it.angrybear.yagl.items.recipes.Recipe.class))); + assertThrowsExactly(IllegalArgumentException.class, () -> ItemAdapter.recipeToMinecraft(mock(Recipe.class))); } } \ No newline at end of file diff --git a/wrappers/bukkit/legacy/src/test/java/it/angrybear/yagl/LegacyWrappersAdapterTest.java b/wrappers/bukkit/legacy/src/test/java/it/angrybear/yagl/LegacyWrappersAdapterTest.java index 56eebb3a..a7c43b24 100644 --- a/wrappers/bukkit/legacy/src/test/java/it/angrybear/yagl/LegacyWrappersAdapterTest.java +++ b/wrappers/bukkit/legacy/src/test/java/it/angrybear/yagl/LegacyWrappersAdapterTest.java @@ -26,8 +26,8 @@ public class LegacyWrappersAdapterTest { - private static it.angrybear.yagl.Color[] getColors() { - return it.angrybear.yagl.Color.values(); + private static Color[] getColors() { + return Color.values(); } private static Particle[] getTestLegacyParticles() { @@ -90,7 +90,7 @@ void testPotionConversion() { @ParameterizedTest @MethodSource("getColors") - void testColorConversion(it.angrybear.yagl.Color expected) { + void testColorConversion(Color expected) { org.bukkit.Color color = WrappersAdapter.wColorToColor(expected); assertEquals(expected, WrappersAdapter.colorToWColor(color)); } diff --git a/wrappers/bukkit/obsolete/src/test/java/it/angrybear/yagl/ObsoleteWrappersAdapterTest.java b/wrappers/bukkit/obsolete/src/test/java/it/angrybear/yagl/ObsoleteWrappersAdapterTest.java index 175f0b48..4f056088 100644 --- a/wrappers/bukkit/obsolete/src/test/java/it/angrybear/yagl/ObsoleteWrappersAdapterTest.java +++ b/wrappers/bukkit/obsolete/src/test/java/it/angrybear/yagl/ObsoleteWrappersAdapterTest.java @@ -1,7 +1,7 @@ package it.angrybear.yagl; +import it.angrybear.yagl.wrappers.Sound; import org.bukkit.Location; -import org.bukkit.Sound; import org.bukkit.entity.Player; import org.junit.jupiter.api.Test; import org.mockito.ArgumentCaptor; @@ -14,15 +14,14 @@ public class ObsoleteWrappersAdapterTest { @Test void testPlaySound() { - it.angrybear.yagl.wrappers.Sound sound = new it.angrybear.yagl.wrappers.Sound( - Sound.AMBIENCE_CAVE.name(),10, 2, "BLOCKS"); + Sound sound = new Sound(org.bukkit.Sound.AMBIENCE_CAVE.name(),10, 2, "BLOCKS"); Player player = mock(Player.class); when(player.getLocation()).thenReturn(new Location(null, 0, 1, 0)); WrappersAdapter.playSound(player, sound); - ArgumentCaptor soundArg = ArgumentCaptor.forClass(Sound.class); + ArgumentCaptor soundArg = ArgumentCaptor.forClass(org.bukkit.Sound.class); ArgumentCaptor volumeArg = ArgumentCaptor.forClass(Float.class); ArgumentCaptor pitchArg = ArgumentCaptor.forClass(Float.class); verify(player).playSound(any(Location.class), soundArg.capture(), volumeArg.capture(), pitchArg.capture()); diff --git a/wrappers/bukkit/src/test/java/it/angrybear/yagl/WrappersAdapterTest.java b/wrappers/bukkit/src/test/java/it/angrybear/yagl/WrappersAdapterTest.java index 415aafa5..67345ba7 100644 --- a/wrappers/bukkit/src/test/java/it/angrybear/yagl/WrappersAdapterTest.java +++ b/wrappers/bukkit/src/test/java/it/angrybear/yagl/WrappersAdapterTest.java @@ -1,13 +1,13 @@ package it.angrybear.yagl; import it.angrybear.yagl.items.AbstractItem; -import it.angrybear.yagl.particles.Particle; import it.angrybear.yagl.particles.*; +import it.angrybear.yagl.particles.Particle; import it.angrybear.yagl.wrappers.Enchantment; import it.angrybear.yagl.wrappers.PotionEffect; +import it.angrybear.yagl.wrappers.Sound; import it.fulminazzo.fulmicollection.objects.Refl; import it.fulminazzo.jbukkit.BukkitUtils; -import org.bukkit.Color; import org.bukkit.*; import org.bukkit.block.data.BlockData; import org.bukkit.enchantments.EnchantmentTarget; @@ -24,7 +24,10 @@ import org.mockito.ArgumentCaptor; import java.lang.reflect.Field; -import java.util.*; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Map; import java.util.function.Consumer; import java.util.function.Function; @@ -41,7 +44,7 @@ private static Particle[] getTestLegacyParticles() { particles.removeIf(t -> t.getType().equalsIgnoreCase(type.name())); particles.add(LegacyParticleType.COMPOSTER_FILL_ATTEMPT.create(new PrimitiveParticleOption<>(true))); particles.add(LegacyParticleType.BONE_MEAL_USE.create(new PrimitiveParticleOption<>(1))); - particles.add(LegacyParticleType.INSTANT_POTION_BREAK.create(new ColorParticleOption(it.angrybear.yagl.Color.AQUA))); + particles.add(LegacyParticleType.INSTANT_POTION_BREAK.create(new ColorParticleOption(Color.AQUA))); return particles.toArray(new Particle[0]); } @@ -79,9 +82,9 @@ private static Particle[] getTestParticles() { for (ParticleType type : ParticleType.values()) particles.add(type.create()); particles.add(ParticleType.SCULK_CHARGE.create(new PrimitiveParticleOption<>(10f))); particles.add(ParticleType.SHRIEK.create(new PrimitiveParticleOption<>(11))); - particles.add(ParticleType.REDSTONE.create(new DustParticleOption(it.angrybear.yagl.Color.RED, 12f))); + particles.add(ParticleType.REDSTONE.create(new DustParticleOption(Color.RED, 12f))); particles.add(ParticleType.DUST_COLOR_TRANSITION.create(new DustTransitionParticleOption( - it.angrybear.yagl.Color.RED, it.angrybear.yagl.Color.BLUE, 12f))); + Color.RED, Color.BLUE, 12f))); particles.add(ParticleType.VIBRATION.create(new PrimitiveParticleOption<>( new Vibration(mock(Location.class), mock(Vibration.Destination.class), 10)))); particles.add(ParticleType.ITEM_CRACK.create(new ItemParticleOption(mock(AbstractItem.class)))); @@ -163,15 +166,14 @@ void testSpawnItemCrack() throws NoSuchMethodException { @Test void testPlaySound() { - it.angrybear.yagl.wrappers.Sound sound = new it.angrybear.yagl.wrappers.Sound( - Sound.BLOCK_GLASS_STEP.name(),10, 2, SoundCategory.BLOCKS.name()); + Sound sound = new Sound(org.bukkit.Sound.BLOCK_GLASS_STEP.name(),10, 2, SoundCategory.BLOCKS.name()); Player player = mock(Player.class); when(player.getLocation()).thenReturn(new Location(null, 0, 1, 0)); WrappersAdapter.playSound(player, sound); - ArgumentCaptor soundArg = ArgumentCaptor.forClass(Sound.class); + ArgumentCaptor soundArg = ArgumentCaptor.forClass(org.bukkit.Sound.class); ArgumentCaptor categoryArg = ArgumentCaptor.forClass(SoundCategory.class); ArgumentCaptor volumeArg = ArgumentCaptor.forClass(Float.class); ArgumentCaptor pitchArg = ArgumentCaptor.forClass(Float.class); @@ -188,15 +190,14 @@ void testPlaySound() { @Test void testPlaySoundNoCategory() { - it.angrybear.yagl.wrappers.Sound sound = new it.angrybear.yagl.wrappers.Sound( - Sound.BLOCK_GLASS_STEP.name(),10, 2); + Sound sound = new Sound(org.bukkit.Sound.BLOCK_GLASS_STEP.name(),10, 2); Player player = mock(Player.class); when(player.getLocation()).thenReturn(new Location(null, 0, 1, 0)); WrappersAdapter.playSound(player, sound); - ArgumentCaptor soundArg = ArgumentCaptor.forClass(Sound.class); + ArgumentCaptor soundArg = ArgumentCaptor.forClass(org.bukkit.Sound.class); ArgumentCaptor volumeArg = ArgumentCaptor.forClass(Float.class); ArgumentCaptor pitchArg = ArgumentCaptor.forClass(Float.class); verify(player).playSound(any(Location.class), soundArg.capture(), volumeArg.capture(), pitchArg.capture()); @@ -211,13 +212,13 @@ void testPlaySoundNoCategory() { void testPlaySoundInvalidCategory() { Player player = mock(Player.class); assertThrowsExactly(IllegalArgumentException.class, () -> - WrappersAdapter.playSound(player, new it.angrybear.yagl.wrappers.Sound(Sound.BLOCK_AZALEA_FALL.name(), + WrappersAdapter.playSound(player, new Sound(org.bukkit.Sound.BLOCK_AZALEA_FALL.name(), 1f, 1f, "hostiles"))); } @Test void testCustomPlaySound() { - it.angrybear.yagl.wrappers.Sound sound = new it.angrybear.yagl.wrappers.Sound( + Sound sound = new Sound( "custom_sound",10, 2, SoundCategory.BLOCKS.name()); Player player = mock(Player.class); @@ -242,7 +243,7 @@ void testCustomPlaySound() { @Test void testCustomPlaySoundNoCategory() { - it.angrybear.yagl.wrappers.Sound sound = new it.angrybear.yagl.wrappers.Sound( + Sound sound = new Sound( "custom_sound",10, 2); Player player = mock(Player.class); @@ -326,7 +327,7 @@ void testEnchantmentConversionByName() { void testInvalidClassProvided() { Refl refl = new Refl<>(WrappersAdapter.class); assertThrowsExactly(IllegalArgumentException.class, () -> refl.invokeMethod("wParticleToGeneral", - ParticleType.DUST_COLOR_TRANSITION.create(it.angrybear.yagl.Color.RED, it.angrybear.yagl.Color.RED, 3f), + ParticleType.DUST_COLOR_TRANSITION.create(Color.RED, Color.RED, 3f), org.bukkit.Particle.class, (Function>) s -> org.bukkit.Particle.REDSTONE.getDataType())); } @@ -334,18 +335,18 @@ void testInvalidClassProvided() { void testNoConstructorDataTypeProvided() { Refl refl = new Refl<>(WrappersAdapter.class); assertThrowsExactly(IllegalArgumentException.class, () -> refl.invokeMethod("wParticleToGeneral", - ParticleType.REDSTONE.create(it.angrybear.yagl.Color.RED, 3f), org.bukkit.Particle.class, + ParticleType.REDSTONE.create(Color.RED, 3f), org.bukkit.Particle.class, (Function>) s -> AbstractItem.class)); } - private static it.angrybear.yagl.Color[] getColors() { - return it.angrybear.yagl.Color.values(); + private static Color[] getColors() { + return Color.values(); } @ParameterizedTest @MethodSource("getColors") - void testColorConversion(it.angrybear.yagl.Color expected) { - Color color = WrappersAdapter.wColorToColor(expected); + void testColorConversion(Color expected) { + org.bukkit.Color color = WrappersAdapter.wColorToColor(expected); assertEquals(expected, WrappersAdapter.colorToWColor(color)); } @@ -395,7 +396,7 @@ public boolean isInstant() { @NotNull @Override - public Color getColor() { + public org.bukkit.Color getColor() { return null; } }