// Path: src/main/java/io/github/hsyyid/essentialcmds/events/TPAHereEvent.java
// public class TPAHereEvent extends AbstractEvent implements Cancellable
// {
// 	private boolean cancelled = false;
// 
// 	private Player sender;
// 	private Player recipient;
// 
// 	public Player getSender()
// 	{
// 		return sender;
// 	}
// 
// 	public Player getRecipient()
// 	{
// 		return recipient;
// 	}
// 
// 	public boolean isCancelled()
// 	{
// 		return cancelled;
// 	}
// 
// 	public void setCancelled(boolean cancel)
// 	{
// 		cancelled = cancel;
// 	}
// 
// 	public TPAHereEvent(Player sender, Player recipient)
// 	{
// 		this.sender = sender;
// 		this.recipient = recipient;
// 	}
// 
// 	@Override
// 	public Cause getCause()
// 	{
// 		return Cause.of(NamedCause.source(this.sender));
// 	}
// }
// 
// Path: src/main/java/io/github/hsyyid/essentialcmds/internal/AsyncCommandExecutorBase.java
// public abstract class AsyncCommandExecutorBase extends CommandExecutorBase {
// 
//     /**
//      * The command to execute on an Async scheduler thread.
//      *
//      * <p>
//      *     <strong>DO NOT USE NON-THREAD SAFE API CALLS WITHIN THIS METHOD</strong> unless you use a scheduler to put the
//      *     calls back on the main thread.
//      * </p>
//      *
//      * @param src The {@link CommandSource}
//      * @param args The arguments.
//      */
//     public abstract void executeAsync(CommandSource src, CommandContext args);
// 
//     @Override
//     public final CommandResult execute(CommandSource src, CommandContext args) throws CommandException {
//         Sponge.getScheduler().createAsyncExecutor(EssentialCmds.getEssentialCmds()).execute(() -> executeAsync(src, args));
//         return CommandResult.success();
//     }
// }
// 
// Path: src/main/java/io/github/hsyyid/essentialcmds/EssentialCmds.java
// public static EssentialCmds getEssentialCmds()
// {
// 	return essentialCmds;
// }


import org.spongepowered.api.command.source.CommandBlockSource;
import org.spongepowered.api.command.source.ConsoleSource;
import org.spongepowered.api.command.spec.CommandSpec;
import org.spongepowered.api.entity.living.player.Player;
import org.spongepowered.api.text.Text;
import org.spongepowered.api.text.format.TextColors;
import javax.annotation.Nonnull;
import static io.github.hsyyid.essentialcmds.EssentialCmds.getEssentialCmds;
import io.github.hsyyid.essentialcmds.events.TPAHereEvent;
import io.github.hsyyid.essentialcmds.internal.AsyncCommandExecutorBase;
import org.spongepowered.api.Game;
import org.spongepowered.api.command.CommandSource;
import org.spongepowered.api.command.args.CommandContext;
import org.spongepowered.api.command.args.GenericArguments;
/*
 * This file is part of EssentialCmds, licensed under the MIT License (MIT).
 *
 * Copyright (c) 2015 - 2015 HassanS6000
 * Copyright (c) contributors
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */
package io.github.hsyyid.essentialcmds.cmdexecutors;




public class TPAHereExecutor extends AsyncCommandExecutorBase
{
	private Game game = getEssentialCmds().getGame();

	@Override
	public void executeAsync(CommandSource src, CommandContext ctx)
	{
		Player recipient = ctx.<Player> getOne("player").get();

		if (src instanceof Player)
		{
			Player player = (Player) src;
			if (recipient == player)
			{
				src.sendMessage(Text.of(TextColors.DARK_RED, "Error! ", TextColors.RED, "You cannot teleport to yourself!"));
			}
			else
			{
				src.sendMessage(Text.of(TextColors.GREEN, "Success! ", TextColors.YELLOW, "Requested for " + recipient.getName() + " to be teleported to you"));
// Path: src/main/java/io/github/hsyyid/essentialcmds/events/TPAHereEvent.java
// public class TPAHereEvent extends AbstractEvent implements Cancellable
// {
// 	private boolean cancelled = false;
// 
// 	private Player sender;
// 	private Player recipient;
// 
// 	public Player getSender()
// 	{
// 		return sender;
// 	}
// 
// 	public Player getRecipient()
// 	{
// 		return recipient;
// 	}
// 
// 	public boolean isCancelled()
// 	{
// 		return cancelled;
// 	}
// 
// 	public void setCancelled(boolean cancel)
// 	{
// 		cancelled = cancel;
// 	}
// 
// 	public TPAHereEvent(Player sender, Player recipient)
// 	{
// 		this.sender = sender;
// 		this.recipient = recipient;
// 	}
// 
// 	@Override
// 	public Cause getCause()
// 	{
// 		return Cause.of(NamedCause.source(this.sender));
// 	}
// }
// 
// Path: src/main/java/io/github/hsyyid/essentialcmds/internal/AsyncCommandExecutorBase.java
// public abstract class AsyncCommandExecutorBase extends CommandExecutorBase {
// 
//     /**
//      * The command to execute on an Async scheduler thread.
//      *
//      * <p>
//      *     <strong>DO NOT USE NON-THREAD SAFE API CALLS WITHIN THIS METHOD</strong> unless you use a scheduler to put the
//      *     calls back on the main thread.
//      * </p>
//      *
//      * @param src The {@link CommandSource}
//      * @param args The arguments.
//      */
//     public abstract void executeAsync(CommandSource src, CommandContext args);
// 
//     @Override
//     public final CommandResult execute(CommandSource src, CommandContext args) throws CommandException {
//         Sponge.getScheduler().createAsyncExecutor(EssentialCmds.getEssentialCmds()).execute(() -> executeAsync(src, args));
//         return CommandResult.success();
//     }
// }
// 
// Path: src/main/java/io/github/hsyyid/essentialcmds/EssentialCmds.java
// public static EssentialCmds getEssentialCmds()
// {
// 	return essentialCmds;
// }


// Path: src/main/java/io/github/hsyyid/essentialcmds/cmdexecutors/TPAHereExecutor.java
import org.spongepowered.api.command.source.CommandBlockSource;
import org.spongepowered.api.command.source.ConsoleSource;
import org.spongepowered.api.command.spec.CommandSpec;
import org.spongepowered.api.entity.living.player.Player;
import org.spongepowered.api.text.Text;
import org.spongepowered.api.text.format.TextColors;
import javax.annotation.Nonnull;
import static io.github.hsyyid.essentialcmds.EssentialCmds.getEssentialCmds;
import io.github.hsyyid.essentialcmds.events.TPAHereEvent;
import io.github.hsyyid.essentialcmds.internal.AsyncCommandExecutorBase;
import org.spongepowered.api.Game;
import org.spongepowered.api.command.CommandSource;
import org.spongepowered.api.command.args.CommandContext;
import org.spongepowered.api.command.args.GenericArguments;

/*
 * This file is part of EssentialCmds, licensed under the MIT License (MIT).
 *
 * Copyright (c) 2015 - 2015 HassanS6000
 * Copyright (c) contributors
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */
package io.github.hsyyid.essentialcmds.cmdexecutors;




public class TPAHereExecutor extends AsyncCommandExecutorBase
{
	private Game game = getEssentialCmds().getGame();

	@Override
	public void executeAsync(CommandSource src, CommandContext ctx)
	{
		Player recipient = ctx.<Player> getOne("player").get();

		if (src instanceof Player)
		{
			Player player = (Player) src;
			if (recipient == player)
			{
				src.sendMessage(Text.of(TextColors.DARK_RED, "Error! ", TextColors.RED, "You cannot teleport to yourself!"));
			}
			else
			{
				src.sendMessage(Text.of(TextColors.GREEN, "Success! ", TextColors.YELLOW, "Requested for " + recipient.getName() + " to be teleported to you"));
				game.getEventManager().post(new TPAHereEvent(player, recipient));