<commit_before>package info.tregmine.commands;

import info.tregmine.Tregmine; import info.tregmine.api.GenericPlayer;
import org.bukkit.ChatColor;
import org.bukkit.GameMode;

import static org.bukkit.ChatColor.YELLOW;

public class GameModeCommand extends AbstractCommand {
    private GameMode mode;

    public GameModeCommand(Tregmine tregmine, String name, GameMode mode) {
        super(tregmine, name);
        this.mode = mode;
    }

    @Override
    public boolean handlePlayer(GenericPlayer player, String[] args) {
        if (player.getWorld().getName().equalsIgnoreCase("vanilla") || player.isInVanillaWorld()) {
            player.setFireTicks(30);
            player.sendMessage(ChatColor.RED + "You cannot use that command in this world!");
            return true;
        }
        if (this.mode != null) {
            if (!player.getRank().getPermittedGamemodes().contains(this.mode)) {
                player.sendMessage(ChatColor.RED + "You don't have the permissions to switch to " + this.mode.name().toLowerCase() + "!");
                return true;
            }
            player.setGameMode(mode);
            player.sendMessage(YELLOW + "You are now in " + mode.toString().toLowerCase() + " mode. ");

            if (player.getRank().canFly()) {
                player.setAllowFlight(true);
            }
        } else {
            //Generic Mode!
            if (args.length != 1) {
                player.sendMessage(ChatColor.RED + "You must specify a gamemode to switch to!");
                return true;
            }
            GameMode switchTo = GameMode.valueOf(args[0].toUpperCase());
            if (switchTo == null) {
                player.sendMessage(ChatColor.RED + "The specified gamemode does not exist!");
                return true;
            }
            if (!player.getRank().getPermittedGamemodes().contains(switchTo)) {
                player.sendMessage(ChatColor.RED + "You don't have the permissions to switch to " + switchTo.name().toLowerCase() + "!");
                return true;
            }
            player.setGameMode(switchTo);
            player.sendMessage(YELLOW + "You are now in " + switchTo.toString().toLowerCase() + " mode. ");

            if (player.getRank().canFly()) {
                player.setAllowFlight(true);
            }
        }

        return true;
    }
}<commit_msg>Made generic game mode functionality better<commit_after>package info.tregmine.commands;

import info.tregmine.Tregmine; import info.tregmine.api.GenericPlayer;
import org.bukkit.ChatColor;
import org.bukkit.GameMode;

import static org.bukkit.ChatColor.YELLOW;

public class GameModeCommand extends AbstractCommand {
    private GameMode mode;

    public GameModeCommand(Tregmine tregmine, String name, GameMode mode) {
        super(tregmine, name);
        this.mode = mode;
    }

    @Override
    public boolean handlePlayer(GenericPlayer player, String[] args) {
        if (player.getWorld().getName().equalsIgnoreCase("vanilla") || player.isInVanillaWorld()) {
            player.setFireTicks(30);
            player.sendMessage(ChatColor.RED + "You cannot use that command in this world!");
            return true;
        }
        if (this.mode != null) {
            if (!player.getRank().getPermittedGamemodes().contains(this.mode)) {
                player.sendMessage(ChatColor.RED + "You don't have the permissions to switch to " + this.mode.name().toLowerCase() + "!");
                return true;
            }
            player.setGameMode(mode);
            player.sendMessage(YELLOW + "You are now in " + mode.toString().toLowerCase() + " mode. ");

            if (player.getRank().canFly()) {
                player.setAllowFlight(true);
            }
        } else {
            //Generic Mode!
            if (args.length != 1) {
                String modes = "";
                for(GameMode m : GameMode.values()){
                    ChatColor color =
                            player.getRank().getPermittedGamemodes().contains(m) ? ChatColor.GREEN : ChatColor.RED;
                    modes += m.name().toLowerCase() + " ";
                }
                player.sendMessage(ChatColor.AQUA + "Gamemodes available: " + modes);
                return true;
            }
            GameMode switchTo;
            try {
               switchTo = GameMode.valueOf(args[0].toUpperCase());
            }catch(IllegalArgumentException e){
                player.sendMessage(ChatColor.RED + "The specified gamemode does not exist!");
                return true;
            }
            if (!player.getRank().getPermittedGamemodes().contains(switchTo)) {
                player.sendMessage(ChatColor.RED + "You don't have the permissions to switch to " + switchTo.name().toLowerCase() + "!");
                return true;
            }
            player.setGameMode(switchTo);
            player.sendMessage(YELLOW + "You are now in " + switchTo.toString().toLowerCase() + " mode. ");

            if (player.getRank().canFly()) {
                player.setAllowFlight(true);
            }
        }

        return true;
    }
}
{'fraction_non_alphanumeric': 0.11738368697683473, 'fraction_numerical': 0.001557329180455519, 'mean_word_length': 2.0029222676797196, 'pattern_counts': {'":': 0, '<': 3, '<?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': '7587044', 'n_tokens_mistral': 1411, 'n_tokens_neox': 1364, 'n_words': 297}