From a1bc00f876c8bd2a3a8c731c0d13a8f3a76ac7fa Mon Sep 17 00:00:00 2001 From: Fulminazzo Date: Thu, 12 Dec 2024 23:05:28 +0100 Subject: [PATCH] Explicitly declared parameter types --- .../main/resources/commands/ApplyPotionEffect.groovy | 3 ++- demo/src/main/resources/commands/CreateRecipe.groovy | 11 ++++++----- .../src/main/resources/commands/GetEnchantment.groovy | 5 +++-- demo/src/main/resources/commands/GiveItem.groovy | 3 ++- .../main/resources/commands/GivePersistentItem.groovy | 3 ++- demo/src/main/resources/commands/OpenDataGUI.groovy | 3 ++- demo/src/main/resources/commands/OpenGUI.groovy | 3 ++- .../main/resources/commands/OpenPageableGUI.groovy | 3 ++- demo/src/main/resources/commands/PlayEffect.groovy | 5 +++-- demo/src/main/resources/commands/PlayParticle.groovy | 5 +++-- .../resources/commands/PlayYAGLCustomSound.groovy | 3 ++- demo/src/main/resources/commands/PlayYAGLSound.groovy | 3 ++- 12 files changed, 31 insertions(+), 19 deletions(-) diff --git a/demo/src/main/resources/commands/ApplyPotionEffect.groovy b/demo/src/main/resources/commands/ApplyPotionEffect.groovy index 8fc80c27..7c16eabb 100644 --- a/demo/src/main/resources/commands/ApplyPotionEffect.groovy +++ b/demo/src/main/resources/commands/ApplyPotionEffect.groovy @@ -1,8 +1,9 @@ import it.fulminazzo.yagl.WrappersAdapter import it.fulminazzo.yagl.wrappers.PotionEffect +import org.bukkit.command.CommandSender import org.bukkit.entity.Player -def run = { sender, label, args -> +def run = { CommandSender sender, String label, String[] args -> if (sender instanceof Player) { try { PotionEffect effect = new PotionEffect(args[0], Double.valueOf(args[1]), diff --git a/demo/src/main/resources/commands/CreateRecipe.groovy b/demo/src/main/resources/commands/CreateRecipe.groovy index 025c6dc1..130634d2 100644 --- a/demo/src/main/resources/commands/CreateRecipe.groovy +++ b/demo/src/main/resources/commands/CreateRecipe.groovy @@ -3,9 +3,10 @@ import it.fulminazzo.yagl.items.Item import it.fulminazzo.yagl.items.recipes.FurnaceRecipe import it.fulminazzo.yagl.items.recipes.ShapedRecipe import it.fulminazzo.yagl.items.recipes.ShapelessRecipe +import org.bukkit.command.CommandSender import org.bukkit.entity.Player -static shaped(sender, label, args, output, name) { +static shaped(CommandSender sender, String[] args, String output, String name) { try { def rows = Integer.valueOf(args[0]) def columns = Integer.valueOf(args[1]) @@ -22,7 +23,7 @@ static shaped(sender, label, args, output, name) { } } -static shapeless(sender, label, args, output, name) { +static shapeless(CommandSender sender, String[] args, String output, String name) { try { if (args.length == 0) throw new IndexOutOfBoundsException() BukkitItem.newRecipeItem(output) @@ -39,7 +40,7 @@ static shapeless(sender, label, args, output, name) { } } -static furnace(sender, label, args, output, name) { +static furnace(CommandSender sender, String[] args, String output, String name) { try { BukkitItem.newRecipeItem(output) .addRecipes(new FurnaceRecipe(name) @@ -55,10 +56,10 @@ static furnace(sender, label, args, output, name) { } } -def run = { sender, label, args -> +def run = { CommandSender sender, String label, String[] args -> if (sender instanceof Player) try { - "${args[2].toLowerCase()}"(sender, label, Arrays.copyOfRange(args, 3, args.length), args[1], args[0]) + "${args[2].toLowerCase()}"(sender, Arrays.copyOfRange(args, 3, args.length), args[1], args[0]) } catch (NumberFormatException ignored) { // auto-generated code } catch (IndexOutOfBoundsException ignored) { diff --git a/demo/src/main/resources/commands/GetEnchantment.groovy b/demo/src/main/resources/commands/GetEnchantment.groovy index 547a872c..15599af4 100644 --- a/demo/src/main/resources/commands/GetEnchantment.groovy +++ b/demo/src/main/resources/commands/GetEnchantment.groovy @@ -2,16 +2,17 @@ import it.fulminazzo.yagl.WrappersAdapter import it.fulminazzo.yagl.wrappers.Enchantment import it.fulminazzo.fulmicollection.structures.tuples.Tuple import org.bukkit.Material +import org.bukkit.command.CommandSender import org.bukkit.entity.Player import org.bukkit.inventory.ItemStack import org.bukkit.inventory.meta.EnchantmentStorageMeta -def run = { sender, label, args -> +def run = { CommandSender sender, String label, String[] args -> if (sender instanceof Player) try { Enchantment enchantment = new Enchantment(args[0], Integer.valueOf(args[1])) ItemStack book = new ItemStack(Material.ENCHANTED_BOOK) - EnchantmentStorageMeta meta = book.itemMeta + EnchantmentStorageMeta meta = book.itemMeta as EnchantmentStorageMeta Tuple tuple = WrappersAdapter.wEnchantToEnchant(enchantment) meta.addStoredEnchant(tuple.key, tuple.value, true) book.setItemMeta(meta) diff --git a/demo/src/main/resources/commands/GiveItem.groovy b/demo/src/main/resources/commands/GiveItem.groovy index 2d2cd28a..c3309228 100644 --- a/demo/src/main/resources/commands/GiveItem.groovy +++ b/demo/src/main/resources/commands/GiveItem.groovy @@ -3,9 +3,10 @@ import it.fulminazzo.yagl.items.Item import it.fulminazzo.yagl.items.fields.ItemFlag import it.fulminazzo.yagl.wrappers.Enchantment import it.fulminazzo.yagl.wrappers.WrapperParser +import org.bukkit.command.CommandSender import org.bukkit.entity.Player -def run = { sender, label, args -> +def run = { CommandSender sender, String label, String[] args -> if (sender instanceof Player) try { Item item = Item.newItem(args[0]) diff --git a/demo/src/main/resources/commands/GivePersistentItem.groovy b/demo/src/main/resources/commands/GivePersistentItem.groovy index 1abd2b7a..c81f24fa 100644 --- a/demo/src/main/resources/commands/GivePersistentItem.groovy +++ b/demo/src/main/resources/commands/GivePersistentItem.groovy @@ -5,9 +5,10 @@ import it.fulminazzo.yagl.items.PersistentItem import it.fulminazzo.yagl.items.fields.ItemFlag import it.fulminazzo.yagl.wrappers.Enchantment import it.fulminazzo.yagl.wrappers.WrapperParser +import org.bukkit.command.CommandSender import org.bukkit.entity.Player -def run = { sender, label, args -> +def run = { CommandSender sender, String label, String[] args -> if (sender instanceof Player) try { DeathAction action = DeathAction.valueOf(args[0].toUpperCase()) diff --git a/demo/src/main/resources/commands/OpenDataGUI.groovy b/demo/src/main/resources/commands/OpenDataGUI.groovy index 543123eb..30692963 100644 --- a/demo/src/main/resources/commands/OpenDataGUI.groovy +++ b/demo/src/main/resources/commands/OpenDataGUI.groovy @@ -7,11 +7,12 @@ import it.fulminazzo.yagl.guis.PageableGUI import it.fulminazzo.yagl.items.BukkitItem import it.fulminazzo.yagl.utils.EnumUtils import org.bukkit.Material +import org.bukkit.command.CommandSender import org.bukkit.entity.Player import java.util.function.Function -def run = { sender, label, args -> +def run = { CommandSender sender, String label, String[] args -> if (sender instanceof Player) try { def data = [ diff --git a/demo/src/main/resources/commands/OpenGUI.groovy b/demo/src/main/resources/commands/OpenGUI.groovy index 98d3ce9d..1fc3d8cd 100644 --- a/demo/src/main/resources/commands/OpenGUI.groovy +++ b/demo/src/main/resources/commands/OpenGUI.groovy @@ -5,9 +5,10 @@ import it.fulminazzo.yagl.guis.GUIType import it.fulminazzo.yagl.items.Item import it.fulminazzo.yagl.items.fields.ItemFlag import it.fulminazzo.yagl.utils.EnumUtils +import org.bukkit.command.CommandSender import org.bukkit.entity.Player -def run = { sender, label, args -> +def run = { CommandSender sender, String label, String[] args -> if (sender instanceof Player) try { def columns = 9 diff --git a/demo/src/main/resources/commands/OpenPageableGUI.groovy b/demo/src/main/resources/commands/OpenPageableGUI.groovy index 7b3e6366..79fc0898 100644 --- a/demo/src/main/resources/commands/OpenPageableGUI.groovy +++ b/demo/src/main/resources/commands/OpenPageableGUI.groovy @@ -4,9 +4,10 @@ import it.fulminazzo.yagl.guis.PageableGUI import it.fulminazzo.yagl.items.BukkitItem import it.fulminazzo.yagl.utils.EnumUtils import org.bukkit.Material +import org.bukkit.command.CommandSender import org.bukkit.entity.Player -def run = { sender, label, args -> +def run = { CommandSender sender, String label, String[] args -> if (sender instanceof Player) try { PageableGUI gui diff --git a/demo/src/main/resources/commands/PlayEffect.groovy b/demo/src/main/resources/commands/PlayEffect.groovy index 1f101a23..5b30e8b7 100644 --- a/demo/src/main/resources/commands/PlayEffect.groovy +++ b/demo/src/main/resources/commands/PlayEffect.groovy @@ -14,9 +14,10 @@ import it.fulminazzo.yagl.particles.PotionParticleOption import it.fulminazzo.yagl.particles.PrimitiveParticleOption import it.fulminazzo.yagl.wrappers.Potion import it.fulminazzo.fulmicollection.objects.Refl +import org.bukkit.command.CommandSender import org.bukkit.entity.Player -static getOption(sender, particleType, optionType, args) { +static getOption(CommandSender sender, LegacyParticleType particleType, Class optionType, String[] args) { if (optionType == PotionParticleOption) new PotionParticleOption(new Potion(args[0], Integer.valueOf(args[1]), Boolean.valueOf(args[2]), Boolean.valueOf(args[3]))) @@ -39,7 +40,7 @@ static getOption(sender, particleType, optionType, args) { else throw new IllegalArgumentException("Cannot get particle option of ${optionType}") } -def run = { sender, label, args -> +def run = { CommandSender sender, String label, String[] args -> if (sender instanceof Player) { try { LegacyParticleType type = LegacyParticleType.valueOf(args[0]) diff --git a/demo/src/main/resources/commands/PlayParticle.groovy b/demo/src/main/resources/commands/PlayParticle.groovy index 9078a648..6179a47c 100644 --- a/demo/src/main/resources/commands/PlayParticle.groovy +++ b/demo/src/main/resources/commands/PlayParticle.groovy @@ -16,10 +16,11 @@ import it.fulminazzo.yagl.particles.ParticleType import it.fulminazzo.yagl.particles.PrimitiveParticleOption import it.fulminazzo.fulmicollection.objects.Refl import org.bukkit.Location +import org.bukkit.command.CommandSender import org.bukkit.entity.Player import org.bukkit.inventory.EquipmentSlot -static getOption(sender, particleType, optionType, args) { +static getOption(CommandSender sender, ParticleType particleType, Class optionType, String[] args) { if (optionType == DustParticleOption) new DustParticleOption(Color.fromARGB(args[0]), Float.valueOf(args[1])) else if (optionType == DustTransitionParticleOption) @@ -40,7 +41,7 @@ static getOption(sender, particleType, optionType, args) { else throw new IllegalArgumentException("Cannot get particle option of ${optionType}") } -def run = { sender, label, args -> +def run = { CommandSender sender, String label, String[] args -> if (sender instanceof Player) { try { ParticleType type = ParticleType.valueOf(args[0]) diff --git a/demo/src/main/resources/commands/PlayYAGLCustomSound.groovy b/demo/src/main/resources/commands/PlayYAGLCustomSound.groovy index a1a1dd49..1fc18ec9 100644 --- a/demo/src/main/resources/commands/PlayYAGLCustomSound.groovy +++ b/demo/src/main/resources/commands/PlayYAGLCustomSound.groovy @@ -1,8 +1,9 @@ import it.fulminazzo.yagl.WrappersAdapter import it.fulminazzo.yagl.wrappers.Sound +import org.bukkit.command.CommandSender import org.bukkit.entity.Player -def run = { sender, label, args -> +def run = { CommandSender sender, String label, String[] args -> if (sender instanceof Player) { try { Sound sound = new Sound(args[0], Float.valueOf(args[1]), Float.valueOf(args[2]), args[3]) diff --git a/demo/src/main/resources/commands/PlayYAGLSound.groovy b/demo/src/main/resources/commands/PlayYAGLSound.groovy index 3bb48434..2437bcf5 100644 --- a/demo/src/main/resources/commands/PlayYAGLSound.groovy +++ b/demo/src/main/resources/commands/PlayYAGLSound.groovy @@ -1,8 +1,9 @@ import it.fulminazzo.yagl.WrappersAdapter import it.fulminazzo.yagl.wrappers.Sound +import org.bukkit.command.CommandSender import org.bukkit.entity.Player -def run = { sender, label, args -> +def run = { CommandSender sender, String label, String[] args -> if (sender instanceof Player) { try { Sound sound = new Sound(args[0], Float.valueOf(args[1]), Float.valueOf(args[2]), args[3])