TFGuilds/src/main/java/me/totalfreedom/tfguilds/command/TpSubCommand.java

52 lines
1.3 KiB
Java
Raw Normal View History

package me.totalfreedom.tfguilds.command;
import me.totalfreedom.tfguilds.Common;
import me.totalfreedom.tfguilds.guild.Guild;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class TpSubCommand extends Common implements SubCommand
{
@Override
public void execute(CommandSender sender, Player playerSender, String[] args)
{
if (!(sender instanceof Player))
{
sender.sendMessage(IN_GAME_ONLY);
return;
}
if (args.length != 2)
{
sender.sendMessage(USAGE + "/g tp <player>");
return;
}
Guild guild = Guild.getGuild(playerSender);
if (guild == null)
{
sender.sendMessage(NOT_IN_GUILD);
return;
}
Player player = Bukkit.getPlayer(args[1]);
if (player == null || tfmBridge.isVanished(player))
{
sender.sendMessage(PLAYER_NOT_FOUND);
return;
}
if (!guild.isMember(player))
{
sender.sendMessage(PLAYER_NOT_IN_GUILD);
return;
}
playerSender.teleport(player);
sender.sendMessage(PREFIX + "Successfully teleported to " + ChatColor.GOLD + player.getName());
}
}