Minecraft Java Plugin : Argument problem

Discussion in 'Spigot Discussion' started by ChinoBman, Jul 15, 2018.

  1. Hello,

    So im making a minecraft java plugin and im low experienced so don't blame me pls.
    But i had a problem whilst making a BanGUI problem. First problem was when i click on the icon's he doesn't stay and i can get everything out of the ban inventory. second problem was mentioning offline players in my argument for so far i made it if the player is online i can ban him. but i can't ban offline players

    Sorry for my bad english. i'm 15 xD

    Here's my code
    Code (Text):
     to [CODE=Java]
    package commands;
    import java.util.ArrayList;
    import org.bukkit.Bukkit;
    import org.bukkit.ChatColor;
    import org.bukkit.Material;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandExecutor;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.inventory.InventoryClickEvent;
    import org.bukkit.inventory.Inventory;
    import org.bukkit.inventory.ItemStack;
    import org.bukkit.inventory.meta.ItemMeta;
    public class Ban implements CommandExecutor, Listener {
        Inventory inv = Bukkit.createInventory(null, 36, "Ban selector");
        public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
            if (label.equalsIgnoreCase("ban")) {
                if(!(sender instanceof Player)) {
                    sender.sendMessage(ChatColor.translateAlternateColorCodes('&', "&7[&6GameCordYT&7] &cYou do not have acces to execute this command"));
                    return false;
                    Player player = (Player) sender;
                    if(args.length == 0) {
                        player.sendMessage(ChatColor.translateAlternateColorCodes('&', "&7[&6GameCordYT&7] &cSelect a name please"));
                        return false;
                    boolean playerExist= false;
                    for (Player BanPlayer: Bukkit.getServer().getOnlinePlayers()) {
                        if (BanPlayer.getName().equalsIgnoreCase(args[0])) {  
                            ItemStack iban = new ItemStack(Material.SIGN);
                            ItemMeta imeta = iban.getItemMeta();
                            imeta.setDisplayName(ChatColor.GRAY + "Information about banning: " + args[0]);
                            ArrayList<String> Lore = new ArrayList<String>();
                            Lore.add(ChatColor.RESET + "Under here are all ban types every amount of block stands for how long they will get banned :D");
                            ItemStack item2 = new ItemStack(Material.COAL_BLOCK);
                            ItemMeta meta2 = item2.getItemMeta();
                            meta2.setDisplayName("1 Day's  ban");
                            ItemStack item3 = new ItemStack(Material.IRON_BLOCK);
                            ItemMeta meta3 = item3.getItemMeta();
                            meta3.setDisplayName("2 Day's  ban");
                            ItemStack item4 = new ItemStack(Material.GOLD_BLOCK);
                            ItemMeta meta4 = item4.getItemMeta();
                            meta4.setDisplayName("3 Day's  ban");
                            ItemStack item5 = new ItemStack(Material.LAPIS_BLOCK);
                            ItemMeta meta5 = item5.getItemMeta();
                            meta5.setDisplayName("4 Day's  ban");
                            ItemStack item6 = new ItemStack(Material.REDSTONE_BLOCK);
                            ItemMeta meta6 = item6.getItemMeta();
                            meta6.setDisplayName("5 Day's  ban");
                            ItemStack item7 = new ItemStack(Material.DIAMOND_BLOCK);
                            ItemMeta meta7 = item7.getItemMeta();
                            meta7.setDisplayName("6 Day's  ban");
                            ItemStack item8 = new ItemStack(Material.DIRT
                            ItemMeta meta8 = item8.getItemMeta();
                            meta8.setDisplayName("Perm ban");
                            inv.setItem(4, iban);
                            //inv.setItem(9, item);
                            //inv.setItem(10, item1);
                            inv.setItem(19, item2);
                            inv.setItem(20, item3);
                            inv.setItem(21, item4);
                            inv.setItem(22, item5);
                            inv.setItem(23, item6);
                            inv.setItem(24, item7);
                            inv.setItem(25, item8);
                            return true;
                    if (playerExist == false) {  
                        player.sendMessage(ChatColor.WHITE + args[0] + "is not online, Online player's);
            return false;