diff --git a/pom.xml b/pom.xml index 33258ef..ef5fb91 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ me.totalfreedom TFGuilds - 0.1.0 + 0.1.1 jar TFGuilds diff --git a/src/main/java/me/totalfreedom/tfguilds/TFGuilds.java b/src/main/java/me/totalfreedom/tfguilds/TFGuilds.java index c176789..54d14d8 100644 --- a/src/main/java/me/totalfreedom/tfguilds/TFGuilds.java +++ b/src/main/java/me/totalfreedom/tfguilds/TFGuilds.java @@ -45,6 +45,7 @@ public final class TFGuilds extends JavaPlugin this.getCommand("guildteleport").setExecutor(new GuildTeleportCommand()); this.getCommand("inviteguild").setExecutor(new InviteGuildCommand()); this.getCommand("leaveguild").setExecutor(new LeaveGuildCommand()); + this.getCommand("guildkick").setExecutor(new GuildKickCommand()); } private void enableListeners() diff --git a/src/main/java/me/totalfreedom/tfguilds/command/GuildKickCommand.java b/src/main/java/me/totalfreedom/tfguilds/command/GuildKickCommand.java new file mode 100644 index 0000000..7786136 --- /dev/null +++ b/src/main/java/me/totalfreedom/tfguilds/command/GuildKickCommand.java @@ -0,0 +1,66 @@ +package me.totalfreedom.tfguilds.command; + +import me.totalfreedom.tfguilds.util.GBase; +import me.totalfreedom.tfguilds.util.GUtil; +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.entity.Player; + +import java.util.List; + +public class GuildKickCommand extends GBase implements CommandExecutor +{ + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) + { + if (args.length == 0) + { + return false; + } + + Player player = (Player) sender; + if (GUtil.isConsole(player)) + { + sender.sendMessage(ChatColor.RED + "You are not allowed to run this command."); + return true; + } + + String guild = GUtil.getGuild(player); + if (guild == null) + { + sender.sendMessage(ChatColor.RED + "You aren't in a guild!"); + return true; + } + + String owner = GUtil.getOwner(guild); + if (!owner.equalsIgnoreCase(player.getName())) + { + sender.sendMessage(ChatColor.RED + "You aren't the owner of your guild!"); + return true; + } + + Player target = Bukkit.getPlayer(args[0]); + if (target == null) + { + sender.sendMessage(ChatColor.RED + "Player not found"); + return true; + } + + List players = plugin.guilds.getStringList("guilds." + guild + ".members"); + players.remove(target.getName()); + plugin.guilds.set("guilds." + guild + ".members", players); + plugin.guilds.save(); + for (Player p : Bukkit.getOnlinePlayers()) + { + if (GUtil.isGuildMember(p, guild)) + { + p.sendMessage(ChatColor.RED + target.getName() + " has been kicked from the guild"); + } + } + sender.sendMessage(ChatColor.GREEN + "Successfully kicked " + target.getName() + " from the guild"); + return true; + } +} \ No newline at end of file diff --git a/src/main/java/me/totalfreedom/tfguilds/command/InviteGuildCommand.java b/src/main/java/me/totalfreedom/tfguilds/command/InviteGuildCommand.java index b0553cf..10eab55 100644 --- a/src/main/java/me/totalfreedom/tfguilds/command/InviteGuildCommand.java +++ b/src/main/java/me/totalfreedom/tfguilds/command/InviteGuildCommand.java @@ -56,7 +56,7 @@ public class InviteGuildCommand extends GBase implements CommandExecutor player.sendMessage(ChatColor.GREEN + "You have successfully joined " + guild); for (Player p : Bukkit.getOnlinePlayers()) { - if (GUtil.isGuildMember(player, guild)) + if (GUtil.isGuildMember(p, guild)) { p.sendMessage(ChatColor.GREEN + player.getName() + " has joined the guild"); } diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index c548032..dabf402 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -37,4 +37,7 @@ commands: leaveguild: description: Leave your guild usage: / - aliases: [guildleave] \ No newline at end of file + aliases: [guildleave] + guildkick: + description: Kicks a player from the guild + usage: / \ No newline at end of file