<commit_before>package guilds.commands;

import guilds.Guild;
import guilds.GuildsBasic;
import guilds.User;
import guilds.messages.Console;
import guilds.messages.Message;
import guilds.messages.MessageType;
import guilds.utilities.Settings;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;

public class CommandInvite {

    private GuildsBasic GuildsBasic;

    public CommandInvite(CommandSender sender, String[] args, GuildsBasic GuildsBasic) {

        this.GuildsBasic = GuildsBasic;

        if (sender instanceof Player) {
            Player(args, (Player) sender);
        } else {
            Console(args);
        }

    }

    private void Player(String[] args, Player player) {

        if (args[0].equalsIgnoreCase("invite")) {
            Player playerTarget = User.getPlayer(args[1]);
            Guild guild = GuildsBasic.getPlayerGuild(player);

            if (guild == null) {
                new Message(MessageType.NOT_IN_GUILD, player, GuildsBasic);
                return;
            }
            if (args.length < 2) {
                new Message(MessageType.COMMAND_INVITE, player, GuildsBasic);
                return;
            }

            if (!player.hasPermission("guilds.user.invite")) {
                new Message(MessageType.NO_PERMISSION, player, GuildsBasic);
                return;
            }

            if (playerTarget == null) {
                new Message(MessageType.PLAYER_NOT_RECOGNISED, player, args[1], GuildsBasic);
                return;
            }

            if (GuildsBasic.getPlayerGuild(playerTarget) != null) {
                new Message(MessageType.ALREADY_IN_GUILD, player, player, GuildsBasic);
                return;
            }

            String currentGuildPending = GuildsBasic.getPlayerPending(playerTarget);
            if (currentGuildPending != null) {
                new Message(MessageType.ALREADY_PENDING, player, currentGuildPending, GuildsBasic);
            }

            GuildsBasic.setPlayerPending(playerTarget, guild);

            GuildsBasic.savePlayers();
            GuildsBasic.loadPlayers();
            new Message(MessageType.INVITATION, playerTarget, guild, GuildsBasic);
            new Message(MessageType.PLAYER_INVITED, playerTarget, GuildsBasic);
        }

        if (args[0].equalsIgnoreCase("accept")) {

            String guildName = GuildsBasic.getPlayerPending(player);
            if (guildName == null) {
                new Message(MessageType.NO_PENDING, player, GuildsBasic);
            }

            if (!player.hasPermission("guilds.user.join")) {
                new Message(MessageType.NO_PERMISSION, player, GuildsBasic);
                return;
            }

            Guild guild = GuildsBasic.getGuild(guildName);
            if (guild == null) {
                new Message(MessageType.GUILD_NOT_RECOGNISED, player, guildName, GuildsBasic);
            }

            if (!GuildsBasic.getEnabled(Settings.ENABLE_CHANGE_GUILD)) {
                new Message(MessageType.GUILD_CHOSEN, player, player, GuildsBasic);
                return;
            }

            if (GuildsBasic.getPlayerGuild(player) != null) {
                new Message(MessageType.ALREADY_IN_GUILD, player, player, GuildsBasic);
                return;
            }

            if (GuildsBasic.PlayerGuild.containsKey(player.getName())) {
                GuildsBasic.PlayerGuild.remove(player.getName());
            }

            if (GuildsBasic.PlayerJoined.containsKey(player.getName())) {
                GuildsBasic.PlayerJoined.remove(player.getName());
            }

            GuildsBasic.PlayerGuild.put(player.getName(), guild);
            GuildsBasic.PlayerJoined.put(player.getName(), System.currentTimeMillis());
            GuildsBasic.PlayerPending.remove(player.getName());
            GuildsBasic.PlayerRank.put(player.getName(), "Recrue");

            GuildsBasic.savePlayers();
            GuildsBasic.loadPlayers();

            new Message(MessageType.GUILD_JOIN, player, player, guild, GuildsBasic);

        }

        if (args[0].equalsIgnoreCase("deny")) {
            String guildName = GuildsBasic.getPlayerPending(player);
            if (guildName == null) {
                new Message(MessageType.NO_PENDING, player, GuildsBasic);
            }

            GuildsBasic.PlayerPending.remove(player.getName());
            Guild guild = GuildsBasic.getGuild(guildName);
            String leadName = guild.getLead();
            if (leadName != null) {<commit_msg>Fix return statments and null pointers<commit_after>package guilds.commands;

import guilds.Guild;
import guilds.GuildsBasic;
import guilds.User;
import guilds.messages.Console;
import guilds.messages.Message;
import guilds.messages.MessageType;
import guilds.utilities.Settings;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;

public class CommandInvite {

    private GuildsBasic GuildsBasic;

    public CommandInvite(CommandSender sender, String[] args, GuildsBasic GuildsBasic) {

        this.GuildsBasic = GuildsBasic;

        if (sender instanceof Player) {
            Player(args, (Player) sender);
        } else {
            Console(args);
        }

    }

    private void Player(String[] args, Player player) {

        if (args[0].equalsIgnoreCase("invite")) {
            Player playerTarget = User.getPlayer(args[1]);
            Guild guild = GuildsBasic.getPlayerGuild(player);

            if (guild == null) {
                new Message(MessageType.NOT_IN_GUILD, player, GuildsBasic);
                return;
            }
            if (args.length < 2) {
                new Message(MessageType.COMMAND_INVITE, player, GuildsBasic);
                return;
            }

            if (!player.hasPermission("guilds.user.invite")) {
                new Message(MessageType.NO_PERMISSION, player, GuildsBasic);
                return;
            }

            if (playerTarget == null) {
                new Message(MessageType.PLAYER_NOT_RECOGNISED, player, args[1], GuildsBasic);
                return;
            }

            if (GuildsBasic.getPlayerGuild(playerTarget) != null) {
                new Message(MessageType.ALREADY_IN_GUILD, player, player, GuildsBasic);
                return;
            }

            String currentGuildPending = GuildsBasic.getPlayerPending(playerTarget);
            if (currentGuildPending != null) {
                new Message(MessageType.ALREADY_PENDING, player, currentGuildPending, GuildsBasic);
            }

            GuildsBasic.setPlayerPending(playerTarget, guild);

            GuildsBasic.savePlayers();
            GuildsBasic.loadPlayers();
            new Message(MessageType.INVITATION, playerTarget, guild, GuildsBasic);
            new Message(MessageType.PLAYER_INVITED, player, playerTarget, GuildsBasic);
        }

        if (args[0].equalsIgnoreCase("accept")) {

            String guildName = GuildsBasic.getPlayerPending(player);
            if (guildName == null) {
                new Message(MessageType.NO_PENDING, player, GuildsBasic);
                return;
            }

            if (!player.hasPermission("guilds.user.join")) {
                new Message(MessageType.NO_PERMISSION, player, GuildsBasic);
                return;
            }

            Guild guild = GuildsBasic.getGuild(guildName);
            if (guild == null) {
                new Message(MessageType.GUILD_NOT_RECOGNISED, player, guildName, GuildsBasic);
            }

            if (!GuildsBasic.getEnabled(Settings.ENABLE_CHANGE_GUILD)) {
                new Message(MessageType.GUILD_CHOSEN, player, player, GuildsBasic);
                return;
            }

            if (GuildsBasic.getPlayerGuild(player) != null) {
                new Message(MessageType.ALREADY_IN_GUILD, player, player, GuildsBasic);
                return;
            }

            if (GuildsBasic.PlayerGuild.containsKey(player.getName())) {
                GuildsBasic.PlayerGuild.remove(player.getName());
            }

            if (GuildsBasic.PlayerJoined.containsKey(player.getName())) {
                GuildsBasic.PlayerJoined.remove(player.getName());
            }

            GuildsBasic.PlayerGuild.put(player.getName(), guild);
            GuildsBasic.PlayerJoined.put(player.getName(), System.currentTimeMillis());
            GuildsBasic.PlayerPending.remove(player.getName());
            GuildsBasic.PlayerRank.put(player.getName(), "Recrue");

            GuildsBasic.savePlayers();
            GuildsBasic.loadPlayers();

            new Message(MessageType.GUILD_JOIN, player, player, guild, GuildsBasic);

        }

        if (args[0].equalsIgnoreCase("deny")) {
            String guildName = GuildsBasic.getPlayerPending(player);
            if (guildName == null) {
                new Message(MessageType.NO_PENDING, player, GuildsBasic);
                return;
            }

            GuildsBasic.PlayerPending.remove(player.getName());
            Guild guild = GuildsBasic.getGuild(guildName);
            String leadName = guild.getLead();
            if (leadName != null) {
{'fraction_non_alphanumeric': 0.09916003054434384, 'fraction_numerical': 0.0013090433075160903, 'mean_word_length': 2.104639349813749, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7234451', 'n_tokens_mistral': 2664, 'n_tokens_neox': 2480, 'n_words': 434}