diff --git a/pom.xml b/pom.xml
index 9dadcf9..33258ef 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
me.totalfreedom
TFGuilds
- 0.0.9
+ 0.1.0
jar
TFGuilds
diff --git a/src/main/java/me/totalfreedom/tfguilds/TFGuilds.java b/src/main/java/me/totalfreedom/tfguilds/TFGuilds.java
index 3fb7b07..c176789 100644
--- a/src/main/java/me/totalfreedom/tfguilds/TFGuilds.java
+++ b/src/main/java/me/totalfreedom/tfguilds/TFGuilds.java
@@ -44,6 +44,7 @@ public final class TFGuilds extends JavaPlugin
this.getCommand("disbandguild").setExecutor(new DisbandGuildCommand());
this.getCommand("guildteleport").setExecutor(new GuildTeleportCommand());
this.getCommand("inviteguild").setExecutor(new InviteGuildCommand());
+ this.getCommand("leaveguild").setExecutor(new LeaveGuildCommand());
}
private void enableListeners()
diff --git a/src/main/java/me/totalfreedom/tfguilds/command/CreateGuildCommand.java b/src/main/java/me/totalfreedom/tfguilds/command/CreateGuildCommand.java
index 7fe0949..9fdeb4a 100644
--- a/src/main/java/me/totalfreedom/tfguilds/command/CreateGuildCommand.java
+++ b/src/main/java/me/totalfreedom/tfguilds/command/CreateGuildCommand.java
@@ -2,6 +2,7 @@ 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;
@@ -67,6 +68,7 @@ public class CreateGuildCommand extends GBase implements CommandExecutor
}
GUtil.createGuild(sender, args[0]);
+ Bukkit.broadcastMessage(GUtil.color("&a" + sender.getName() + " has created guild &a&l" + args[0]));
sender.sendMessage(ChatColor.GREEN + "Successfully created a guild named " + args[0]);
return true;
}
diff --git a/src/main/java/me/totalfreedom/tfguilds/command/DisbandGuildCommand.java b/src/main/java/me/totalfreedom/tfguilds/command/DisbandGuildCommand.java
index fde2f1a..b5b8e2f 100644
--- a/src/main/java/me/totalfreedom/tfguilds/command/DisbandGuildCommand.java
+++ b/src/main/java/me/totalfreedom/tfguilds/command/DisbandGuildCommand.java
@@ -2,6 +2,7 @@ package me.totalfreedom.tfguilds.command;
import me.totalfreedom.tfguilds.util.GLog;
import me.totalfreedom.tfguilds.util.GUtil;
+import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
@@ -44,6 +45,7 @@ public class DisbandGuildCommand implements CommandExecutor
if (args[0].toLowerCase().equalsIgnoreCase("confirm"))
{
GUtil.deleteGuild(player);
+ Bukkit.broadcastMessage(GUtil.color("&c&l" + guild + " &chas been disbanded"));
sender.sendMessage(ChatColor.GREEN + "Successfully deleted and cleared data for " + guild + ".");
GLog.info(player.getName() + " deleted guild " + guild);
return true;
diff --git a/src/main/java/me/totalfreedom/tfguilds/command/InviteGuildCommand.java b/src/main/java/me/totalfreedom/tfguilds/command/InviteGuildCommand.java
index fe138d5..b0553cf 100644
--- a/src/main/java/me/totalfreedom/tfguilds/command/InviteGuildCommand.java
+++ b/src/main/java/me/totalfreedom/tfguilds/command/InviteGuildCommand.java
@@ -37,6 +37,7 @@ public class InviteGuildCommand extends GBase implements CommandExecutor
player.sendMessage(ChatColor.RED + "That player is already in a guild.");
return true;
}
+ target.sendMessage(GUtil.color("&a" + sender.getName() + " has invited you to join &a&l" + GUtil.getGuild(player) + "&a."));
GUtil.invitePlayer(target, GUtil.getGuild(player), 60);
player.sendMessage(GUtil.color("&aSent an invitation to " + target.getName()));
return true;
@@ -53,6 +54,13 @@ public class InviteGuildCommand extends GBase implements CommandExecutor
plugin.guilds.save();
GUtil.invitedPlayers.remove(player.getName());
player.sendMessage(ChatColor.GREEN + "You have successfully joined " + guild);
+ for (Player p : Bukkit.getOnlinePlayers())
+ {
+ if (GUtil.isGuildMember(player, guild))
+ {
+ p.sendMessage(ChatColor.GREEN + player.getName() + " has joined the guild");
+ }
+ }
}
if (args[0].equalsIgnoreCase("deny"))
{
@@ -62,7 +70,7 @@ public class InviteGuildCommand extends GBase implements CommandExecutor
return true;
}
- sender.sendMessage(ChatColor.GRAY + "Player not found.");
+ sender.sendMessage(ChatColor.RED + "Player not found.");
return true;
}
}
\ No newline at end of file
diff --git a/src/main/java/me/totalfreedom/tfguilds/command/LeaveGuildCommand.java b/src/main/java/me/totalfreedom/tfguilds/command/LeaveGuildCommand.java
new file mode 100644
index 0000000..796a41e
--- /dev/null
+++ b/src/main/java/me/totalfreedom/tfguilds/command/LeaveGuildCommand.java
@@ -0,0 +1,65 @@
+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 LeaveGuildCommand extends GBase implements CommandExecutor
+{
+ @Override
+ public boolean onCommand(CommandSender sender, Command command, String label, String[] args)
+ {
+ 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 may not leave your guild. However, if you want to delete it run /disbandguild");
+ return true;
+ }
+
+ if (args.length == 0)
+ {
+ sender.sendMessage(ChatColor.RED + "Are you sure you want to leave your guild? Type 'CONFIRM' to continue.");
+ return true;
+ }
+
+ if (args[0].toLowerCase().equalsIgnoreCase("confirm"))
+ {
+ List players = plugin.guilds.getStringList("guilds." + guild + ".members");
+ players.remove(player.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 + player.getName() + " has left the guild");
+ }
+ }
+ sender.sendMessage(ChatColor.GREEN + "Successfully left " + guild + ".");
+ return true;
+ }
+ return true;
+ }
+}
diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml
index 83a043b..c548032 100644
--- a/src/main/resources/plugin.yml
+++ b/src/main/resources/plugin.yml
@@ -33,4 +33,8 @@ commands:
inviteguild:
description: If invited, allows you to join a guild
usage: /
- aliases: [guildinvite]
\ No newline at end of file
+ aliases: [guildinvite]
+ leaveguild:
+ description: Leave your guild
+ usage: /
+ aliases: [guildleave]
\ No newline at end of file