Solved Why can i not call arg[0] here

Discussion in 'Spigot Plugin Development' started by Carster, Feb 9, 2020.

  1. Hiii spigot why can i not call arg[] here again
    Code (Java):
    package Commands;

    import org.bukkit.Material;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandExecutor;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.EntityType;
    import org.bukkit.entity.Player;
    import org.bukkit.entity.ArmorStand;
    import org.bukkit.event.EventHandler;
    import org.bukkit.inventory.ItemStack;
    import org.inventivetalent.nicknamer.api.event.disguise.SkinDisguiseEvent;

    public class nametagcmd implements CommandExecutor {

        @Override
        public  boolean onCommand(CommandSender sender, Command command, String label, String[] args){
            if(sender instanceof Player){

                Player player = (Player) sender;

                player.setPlayerListName(args[0]);
                player.setDisplayName(args[0]);
               

            }
           


            return true;
        }
        //Its here i cant .-.
        @EventHandler
        public void on(SkinDisguiseEvent event) {
            event.setSkin(args[0]);
        }
     
  2. SteelPhoenix

    Moderator

    Because there is no array called args defined in the #on() method's scope..?
     
  3. But how can i call the arg from the first #on()
     
  4. you don't
     
  5. But how so?
     
  6. Because that’s how any programming language works.

    What is your end goal here? Your logic is mostly likely wrong.
     
  7. simpleauthority

    Supporter

    This is why we learn Java before we try to make plugins with it.
     
    • Informative Informative x 1
    • Creative Creative x 1