<commit_before>package au.com.mineauz.minigames.commands;

import java.util.ArrayList;
import java.util.List;

import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;

import au.com.mineauz.minigames.MinigamePlayer;
import au.com.mineauz.minigames.MinigameUtils;
import au.com.mineauz.minigames.minigame.Minigame;
import au.com.mineauz.minigames.minigame.Team;
import au.com.mineauz.minigames.minigame.TeamColor;
import au.com.mineauz.minigames.minigame.modules.TeamsModule;

public class TeleportCommand implements ICommand {

	@Override
	public String getName() {
		return "teleport";
	}

	@Override
	public String[] getAliases() {
		return new String[] {"tp"};
	}

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

	@Override
	public String getDescription() {
		return "Teleports a defined player to specific coordinates, another player or a specific Minigame point. " + 
				"Supports the use of ~ in coordinates to teleport them relative to where they are standing. " +
				"\n Eg: \"~ ~5 ~\" will teleport a player 5 blocks above their current position.";
	}

	@Override
	public String[] getParameters() {
		return null;
	}

	@Override
	public String[] getUsage() {
		return new String[] {
				"/minigame teleport <Player> <x> <y> <z>",
				"/minigame teleport <Player> Start [id] [team]",
				"/minigame teleport <Player> Checkpoint",
				"/minigame teleport <Player> <Player>"
		};
	}

	@Override
	public String getPermissionMessage() {
		return "You do not have permission to teleport players!";
	}

	@Override
	public String getPermission() {
		return "minigame.teleport";
	}

	@Override
	public boolean onCommand(CommandSender sender, Minigame minigame,
			String label, String[] args) {
		if(args != null){
			List<Player> plys = plugin.getServer().matchPlayer(args[0]);
			MinigamePlayer ply = null;
			if(!plys.isEmpty()){
				ply = plugin.pdata.getMinigamePlayer(plys.get(0));
			}
			else{
				sender.sendMessage(ChatColor.RED + "No player found by the name " + args[0] + "!");
				return true;
			}
			
			if(args.length == 4 && args[1].matches("~?(-?[0-9]+)|~") && args[2].matches("~?(-?[0-9]+)|~") && args[3].matches("~?(-?[0-9]+)|~")){
				double x = 0;
				double y = 0;
				double z = 0;
				
				if(args[1].contains("~")){
					if(args[1].equals("~"))
						x = ply.getPlayer().getLocation().getX();
					else
						x = ply.getPlayer().getLocation().getX() + Double.parseDouble(args[1].replace("~", ""));
				}
				else{
					x = Double.parseDouble(args[1]);
				}
				
				if(args[2].contains("~")){
					if(args[2].equals("~"))
						y = ply.getPlayer().getLocation().getY();
					else
						y = ply.getPlayer().getLocation().getY() + Double.parseDouble(args[2].replace("~", ""));
				}
				else{
					y = Double.parseDouble(args[2]);
				}
				
				if(args[3].contains("~")){
					if(args[3].equals("~"))
						z = ply.getPlayer().getLocation().getZ();
					else
						z = ply.getPlayer().getLocation().getZ() + Double.parseDouble(args[3].replace("~", ""));
				}
				else{
					z = Double.parseDouble(args[3]);
				}
				
				sender.sendMessage(ChatColor.GRAY + "Teleported " + ply.getName() + " to assigned coordinates.");
				ply.teleport(new Location(ply.getPlayer().getWorld(), x, y, z, ply.getPlayer().getLocation().getYaw(), ply.getPlayer().getLocation().getPitch()));
				return true;
			}
			else if(args.length >= 2 && args[1].equalsIgnoreCase("start")){
				if(ply.isInMinigame()){
					int pos = 0;
					Team team = TeamsModule.getMinigameModule(ply.getMinigame()).getTeam(TeamColor.matchColor(args[3]));
					if(args.length >= 3 && args[2].matches("[0-9]+") && !args[2].equals("0")){
						pos = Integer.parseInt(args[2]) - 1;
					}
					
					if(team == null && pos >= ply.getMinigame().getStartLocations().size()){
						pos = 0;
					}
					else if(team != null && pos >= team.getStartLocations().size()){
						pos = 0;
					}
					
					if(team != null){
						ply.teleport(team.getStartLocations().get(pos));
						sender.sendMessage(ChatColor.GRAY + "Teleported " + ply.getName() + " to " + team.getDisplayName() + " start position " + (pos + 1) + ".");
					}<commit_msg>Added support for decimals and yaw/pitch<commit_after>package au.com.mineauz.minigames.commands;

import java.util.ArrayList;
import java.util.List;

import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;

import au.com.mineauz.minigames.MinigamePlayer;
import au.com.mineauz.minigames.MinigameUtils;
import au.com.mineauz.minigames.minigame.Minigame;
import au.com.mineauz.minigames.minigame.Team;
import au.com.mineauz.minigames.minigame.TeamColor;
import au.com.mineauz.minigames.minigame.modules.TeamsModule;

public class TeleportCommand implements ICommand {

	@Override
	public String getName() {
		return "teleport";
	}

	@Override
	public String[] getAliases() {
		return new String[] {"tp"};
	}

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

	@Override
	public String getDescription() {
		return "Teleports a defined player to specific coordinates, another player or a specific Minigame point. " + 
				"Supports the use of ~ in coordinates to teleport them relative to where they are standing. " +
				"\n Eg: \"~ ~5 ~\" will teleport a player 5 blocks above their current position.";
	}

	@Override
	public String[] getParameters() {
		return null;
	}

	@Override
	public String[] getUsage() {
		return new String[] {
				"/minigame teleport <Player> <x> <y> <z> [yaw] [pitch]",
				"/minigame teleport <Player> Start [id] [team]",
				"/minigame teleport <Player> Checkpoint",
				"/minigame teleport <Player> <Player>"
		};
	}

	@Override
	public String getPermissionMessage() {
		return "You do not have permission to teleport players!";
	}

	@Override
	public String getPermission() {
		return "minigame.teleport";
	}

	@Override
	public boolean onCommand(CommandSender sender, Minigame minigame,
			String label, String[] args) {
		if(args != null){
			List<Player> plys = plugin.getServer().matchPlayer(args[0]);
			MinigamePlayer ply = null;
			if(!plys.isEmpty()){
				ply = plugin.pdata.getMinigamePlayer(plys.get(0));
			}
			else{
				sender.sendMessage(ChatColor.RED + "No player found by the name " + args[0] + "!");
				return true;
			}
			
			if(args.length >= 4 && args[1].matches("~?(-?[0-9]+(.[0-9]+)?)|~") && 
					args[2].matches("~?(-?[0-9]+(.[0-9]+)?)|~") && 
					args[3].matches("~?(-?[0-9]+(.[0-9]+)?)|~")){
				double x = 0;
				double y = 0;
				double z = 0;
				float yaw = ply.getLocation().getYaw();
				float pitch = ply.getLocation().getPitch();
				
				if(args[1].contains("~")){
					if(args[1].equals("~"))
						x = ply.getPlayer().getLocation().getX();
					else
						x = ply.getPlayer().getLocation().getX() + Double.parseDouble(args[1].replace("~", ""));
				}
				else{
					x = Double.parseDouble(args[1]);
				}
				
				if(args[2].contains("~")){
					if(args[2].equals("~"))
						y = ply.getPlayer().getLocation().getY();
					else
						y = ply.getPlayer().getLocation().getY() + Double.parseDouble(args[2].replace("~", ""));
				}
				else{
					y = Double.parseDouble(args[2]);
				}
				
				if(args[3].contains("~")){
					if(args[3].equals("~"))
						z = ply.getPlayer().getLocation().getZ();
					else
						z = ply.getPlayer().getLocation().getZ() + Double.parseDouble(args[3].replace("~", ""));
				}
				else{
					z = Double.parseDouble(args[3]);
				}
				
				if(args.length == 6 && args[4].matches("~?(-?[0-9]+(.[0-9]+)?)|~") && args[5].matches("~?(-?[0-9]+(.[0-9]+)?)|~")){
					if(args[4].contains("~")){
						if(args[4].equals("~"))
							yaw = ply.getPlayer().getLocation().getYaw();
						else
							yaw = ply.getPlayer().getLocation().getYaw() + Float.parseFloat(args[4].replace("~", ""));
					}
					else{
						yaw = Float.parseFloat(args[4]);
					}
					
					if(args[5].contains("~")){
						if(args[5].equals("~"))
							pitch = ply.getPlayer().getLocation().getPitch();
						else{
							pitch = ply.getPlayer().getLocation().getPitch() + Float.parseFloat(args[5].replace("~", ""));
						}
					}
					else{
						pitch = Float.parseFloat(args[5]);
					}
					
					if(pitch > 90){
						pitch = 90f;
					}
					else if(pitch < -90){
						pitch = -90f;
					}
				}
				
				sender.sendMessage(ChatColor.GRAY + "Teleported " + ply.getName() + " to assigned coordinates.");
				ply.teleport(new Location(ply.getPlayer().getWorld(), x, y, z, yaw, pitch));
				return true;
			}
			else if(args.length >= 2 && args[1].equalsIgnoreCase("start")){
				if(ply.isInMinigame()){
					int pos = 0;
					Team team = TeamsModule.getMinigameModule(ply.getMinigame()).getTeam(TeamColor.matchColor(args[3]));
					if(args.length >= 3 && args[2].matches("[0-9]+") && !args[2].equals("0")){
						pos = Integer.parseInt(args[2]) - 1;
					}
					
					if(team == null && pos >= ply.getMinigame().getStartLocations().size()){
						pos = 0;
					}
					else if(team != null && pos >= team.getStartLocations().size()){
						pos = 0;
					}
					
					if(team != null){
						ply.teleport(team.getStartLocations().get(pos));
						sender.sendMessage(ChatColor.GRAY + "Teleported " + ply.getName() + " to " + team.getDisplayName() + " start position " + (pos + 1) + ".");
					}
{'fraction_non_alphanumeric': 0.18657832870271426, 'fraction_numerical': 0.013143834152596708, 'mean_word_length': 3.2793781435756744, 'pattern_counts': {'":': 0, '<': 22, '<?xml version=': 0, '>': 31, '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': '2497547', 'n_tokens_mistral': 4038, 'n_tokens_neox': 3228, 'n_words': 624}