TFGuilds/src/main/java/me/totalfreedom/tfguilds/command/TPSubcommand.java
speedxx 27859eddac add guildchatspy
& add codestyle to project for proper code formatting
2020-07-29 17:03:05 -04:00

55 lines
1.6 KiB
Java

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.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.entity.Player;
public class TPSubcommand extends Common implements CommandExecutor
{
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args)
{
if (sender instanceof ConsoleCommandSender)
{
sender.sendMessage(NO_PERMS);
return true;
}
if (args.length != 2)
{
return false;
}
Player player = (Player)sender;
Guild guild = Guild.getGuild(player);
if (guild == null)
{
sender.sendMessage(ChatColor.RED + "You aren't in a guild!");
return true;
}
Player to = Bukkit.getPlayer(args[1]);
if (to == null)
{
sender.sendMessage(PNF);
return true;
}
if (!guild.getMembers().contains(to.getName()))
{
sender.sendMessage(ChatColor.RED + "That player is not in your guild.");
return true;
}
player.teleport(to.getLocation());
sender.sendMessage(tl("%p%Teleported to %s%" + to.getName() + "%p%."));
to.sendMessage(tl("%s%" + sender.getName() + " %p%has teleported to you."));
return true;
}
}