From 20ab49ae8d80a80db179570dabefa56e97f6fe8a Mon Sep 17 00:00:00 2001 From: speedxx <43330808+speedxx@users.noreply.github.com> Date: Fri, 19 Jun 2020 20:10:25 -0400 Subject: [PATCH] add guild teleportation --- pom.xml | 2 +- .../me/totalfreedom/tfguilds/TFGuilds.java | 1 + .../command/GuildTeleportCommand.java | 55 +++++++++++++++++++ .../tfguilds/command/TfGuildsCommand.java | 1 + src/main/resources/plugin.yml | 6 +- 5 files changed, 63 insertions(+), 2 deletions(-) create mode 100644 src/main/java/me/totalfreedom/tfguilds/command/GuildTeleportCommand.java diff --git a/pom.xml b/pom.xml index bd298bb..9dadcf9 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ me.totalfreedom TFGuilds - 0.0.8 + 0.0.9 jar TFGuilds diff --git a/src/main/java/me/totalfreedom/tfguilds/TFGuilds.java b/src/main/java/me/totalfreedom/tfguilds/TFGuilds.java index 7cc68e6..6b08dd2 100644 --- a/src/main/java/me/totalfreedom/tfguilds/TFGuilds.java +++ b/src/main/java/me/totalfreedom/tfguilds/TFGuilds.java @@ -42,6 +42,7 @@ public final class TFGuilds extends JavaPlugin this.getCommand("guildtag").setExecutor(new GuildTagCommand()); this.getCommand("guildchat").setExecutor(new GuildChatCommand()); this.getCommand("disbandguild").setExecutor(new DisbandGuildCommand()); + this.getCommand("guildteleport").setExecutor(new GuildTeleportCommand()); } private void enableListeners() diff --git a/src/main/java/me/totalfreedom/tfguilds/command/GuildTeleportCommand.java b/src/main/java/me/totalfreedom/tfguilds/command/GuildTeleportCommand.java new file mode 100644 index 0000000..1886608 --- /dev/null +++ b/src/main/java/me/totalfreedom/tfguilds/command/GuildTeleportCommand.java @@ -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; + } +} \ No newline at end of file diff --git a/src/main/java/me/totalfreedom/tfguilds/command/TfGuildsCommand.java b/src/main/java/me/totalfreedom/tfguilds/command/TfGuildsCommand.java index 072ab2b..040c117 100644 --- a/src/main/java/me/totalfreedom/tfguilds/command/TfGuildsCommand.java +++ b/src/main/java/me/totalfreedom/tfguilds/command/TfGuildsCommand.java @@ -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(String.format(GUtil.color("&2Version &av%s"), plugin.getDescription().getVersion())); sender.sendMessage(GUtil.color("&2Developed by &aspeednt & supernt")); + sender.sendMessage(GUtil.color("&2https://github.com/speedxx/TFGuilds")); return true; } diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index c150d2f..e7b89b5 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -25,4 +25,8 @@ commands: disbandguild: description: Deletes your guild usage: / - aliases: [deleteguild] \ No newline at end of file + aliases: [deleteguild] + guildteleport: + description: Teleport to other guild members + usage: / + aliases: [guildtp, tpguild] \ No newline at end of file