<commit_before>package com.forgeessentials.commands.player;

import java.util.List;

import com.forgeessentials.api.APIRegistry;
import com.forgeessentials.api.UserIdent;
import com.forgeessentials.commands.util.FEcmdModuleCommands;
import com.forgeessentials.core.misc.Translator;
import com.forgeessentials.util.output.ChatOutputHandler;

import net.minecraft.command.CommandException;
import net.minecraft.command.ICommandSender;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.util.BlockPos;
import net.minecraft.util.StatCollector;
import net.minecraft.world.WorldSettings;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.permission.PermissionLevel;

public class CommandGameMode extends FEcmdModuleCommands {
	@Override
	public List<String> addTabCompletionOptions(ICommandSender sender, String[] args, BlockPos pos) {
		if (args.length == 1) {
			return getListOfStringsMatchingLastWord(args, new String[] { "survival", "creative", "adventure" });
		} else {
			return getListOfStringsMatchingLastWord(args,
					FMLCommonHandler.instance().getMinecraftServerInstance().getAllUsernames());
		}

	}

	@Override
	public boolean canConsoleUseCommand() {
		return true;
	}

	@Override
	public String getCommandName() {
		return "gamemode";
	}

	@Override
	public String getCommandUsage(ICommandSender sender) {
		if (sender instanceof EntityPlayer) {
			return "/gamemode [gamemode] [player(s)] Change a player's gamemode.";
		} else {
			return "/gamemode [gamemode] <player(s)> Change a player's gamemode.";
		}
	}

	@Override
	public String[] getDefaultAliases() {
		return new String[] { "gm" };
	}

	private WorldSettings.GameType getGameTypeFromString(String string) {
		if (string.equalsIgnoreCase(WorldSettings.GameType.SURVIVAL.getName()) || string.equalsIgnoreCase("s")
				|| string.equals("0")) {
			return WorldSettings.GameType.SURVIVAL;
		} else if (string.equalsIgnoreCase(WorldSettings.GameType.CREATIVE.getName()) || string.equalsIgnoreCase("c")
				|| string.equals("1")) {
			return WorldSettings.GameType.CREATIVE;
		} else if (string.equalsIgnoreCase(WorldSettings.GameType.ADVENTURE.getName()) || string.equalsIgnoreCase("a")
				|| string.equals("2")) {
			return WorldSettings.GameType.ADVENTURE;
		} else {
			return null;
		}
	}

	@Override
	public PermissionLevel getPermissionLevel() {
		return PermissionLevel.OP;
	}

	@Override<commit_msg>add spectator mode<commit_after>package com.forgeessentials.commands.player;

import java.util.List;

import com.forgeessentials.api.APIRegistry;
import com.forgeessentials.api.UserIdent;
import com.forgeessentials.commands.util.FEcmdModuleCommands;
import com.forgeessentials.core.misc.Translator;
import com.forgeessentials.util.output.ChatOutputHandler;

import net.minecraft.command.CommandException;
import net.minecraft.command.ICommandSender;
import net.minecraft.command.NumberInvalidException;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.util.BlockPos;
import net.minecraft.util.StatCollector;
import net.minecraft.world.WorldSettings;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.permission.PermissionLevel;

public class CommandGameMode extends FEcmdModuleCommands {
	@Override
	public List<String> addTabCompletionOptions(ICommandSender sender, String[] args, BlockPos pos) {
		if (args.length == 1) {
			return getListOfStringsMatchingLastWord(args, new String[] { "survival", "creative", "adventure", "spectator" });
		} else {
			return getListOfStringsMatchingLastWord(args,
					FMLCommonHandler.instance().getMinecraftServerInstance().getAllUsernames());
		}

	}

	@Override
	public boolean canConsoleUseCommand() {
		return true;
	}

	@Override
	public String getCommandName() {
		return "gamemode";
	}

	@Override
	public String getCommandUsage(ICommandSender sender) {
		if (sender instanceof EntityPlayer) {
			return "/gamemode [gamemode] [player(s)] Change a player's gamemode.";
		} else {
			return "/gamemode [gamemode] <player(s)> Change a player's gamemode.";
		}
	}

	@Override
	public String[] getDefaultAliases() {
		return new String[] { };
	}

	private WorldSettings.GameType getGameTypeFromString(String string) {
		if (string.equalsIgnoreCase(WorldSettings.GameType.SURVIVAL.getName()) || string.equalsIgnoreCase("s")
				|| string.equals("0")) {
			return WorldSettings.GameType.SURVIVAL;
		} else if (string.equalsIgnoreCase(WorldSettings.GameType.CREATIVE.getName()) || string.equalsIgnoreCase("c")
				|| string.equals("1")) {
			return WorldSettings.GameType.CREATIVE;
		} else if (string.equalsIgnoreCase(WorldSettings.GameType.ADVENTURE.getName()) || string.equalsIgnoreCase("a")
				|| string.equals("2")) {
			return WorldSettings.GameType.ADVENTURE;
		} else if (string.equalsIgnoreCase(WorldSettings.GameType.SPECTATOR.getName()) || string.equalsIgnoreCase("sp")
				|| string.equals("3")) {
			return WorldSettings.GameType.SPECTATOR;
		} else {
			return null;
		}
	}
	
	@Override
	public PermissionLevel getPermissionLevel() {
		return PermissionLevel.OP;
	}

	@Override
{'fraction_non_alphanumeric': 0.1170376055257099, 'fraction_numerical': 0.0017267843438219493, 'mean_word_length': 5.674775928297055, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '1089971', 'n_tokens_mistral': 1719, 'n_tokens_neox': 1609, 'n_words': 290}