add guild teleportation

This commit is contained in:
speedxx 2020-06-19 20:10:25 -04:00
parent 110963efc7
commit 20ab49ae8d
5 changed files with 63 additions and 2 deletions

View file

@ -6,7 +6,7 @@
<groupId>me.totalfreedom</groupId> <groupId>me.totalfreedom</groupId>
<artifactId>TFGuilds</artifactId> <artifactId>TFGuilds</artifactId>
<version>0.0.8</version> <version>0.0.9</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>TFGuilds</name> <name>TFGuilds</name>

View file

@ -42,6 +42,7 @@ public final class TFGuilds extends JavaPlugin
this.getCommand("guildtag").setExecutor(new GuildTagCommand()); this.getCommand("guildtag").setExecutor(new GuildTagCommand());
this.getCommand("guildchat").setExecutor(new GuildChatCommand()); this.getCommand("guildchat").setExecutor(new GuildChatCommand());
this.getCommand("disbandguild").setExecutor(new DisbandGuildCommand()); this.getCommand("disbandguild").setExecutor(new DisbandGuildCommand());
this.getCommand("guildteleport").setExecutor(new GuildTeleportCommand());
} }
private void enableListeners() private void enableListeners()

View file

@ -0,0 +1,55 @@
package me.totalfreedom.tfguilds.command;
import me.totalfreedom.tfguilds.util.GUtil;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class GuildTeleportCommand implements CommandExecutor
{
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args)
{
if (args.length == 0)
{
return false;
}
if (GUtil.isConsole(sender))
{
sender.sendMessage(ChatColor.RED + "You are not allowed to run this command.");
return true;
}
String guild = GUtil.getGuild((Player) sender);
if (guild == null)
{
sender.sendMessage(ChatColor.RED + "You aren't in a guild!");
return true;
}
Player target = Bukkit.getPlayer(args[0]);
if (target == null)
{
sender.sendMessage(ChatColor.RED + "Player not found.");
return true;
}
if (!GUtil.isGuildMember(target, GUtil.getGuild((Player) sender)))
{
sender.sendMessage(ChatColor.RED + "That player isn't in your guild.");
return true;
}
Location targetLoc = target.getLocation();
((Player) sender).teleport(targetLoc);
sender.sendMessage(ChatColor.GREEN + "Teleported to " + target.getName() + " successfully.");
target.sendMessage(ChatColor.GREEN + sender.getName() + " has teleported to you.");
return true;
}
}

View file

@ -19,6 +19,7 @@ public class TfGuildsCommand extends GBase implements CommandExecutor
sender.sendMessage(GUtil.color("&aTFGuilds &2is a plugin which allows for players to make their own guilds, providing guild chat, guild teleportation, and more.")); sender.sendMessage(GUtil.color("&aTFGuilds &2is a plugin which allows for players to make their own guilds, providing guild chat, guild teleportation, and more."));
sender.sendMessage(String.format(GUtil.color("&2Version &av%s"), plugin.getDescription().getVersion())); sender.sendMessage(String.format(GUtil.color("&2Version &av%s"), plugin.getDescription().getVersion()));
sender.sendMessage(GUtil.color("&2Developed by &aspeednt & supernt")); sender.sendMessage(GUtil.color("&2Developed by &aspeednt & supernt"));
sender.sendMessage(GUtil.color("&2https://github.com/speedxx/TFGuilds"));
return true; return true;
} }

View file

@ -25,4 +25,8 @@ commands:
disbandguild: disbandguild:
description: Deletes your guild description: Deletes your guild
usage: /<command> usage: /<command>
aliases: [deleteguild] aliases: [deleteguild]
guildteleport:
description: Teleport to other guild members
usage: /<command> <player>
aliases: [guildtp, tpguild]