mirror of
https://github.com/TotalFreedomMC/TFGuilds.git
synced 2024-12-22 07:55:03 +00:00
leaveguild and announce what guild action player does
This commit is contained in:
parent
e1aa50565e
commit
5659744cfd
7 changed files with 85 additions and 3 deletions
2
pom.xml
2
pom.xml
|
@ -6,7 +6,7 @@
|
|||
|
||||
<groupId>me.totalfreedom</groupId>
|
||||
<artifactId>TFGuilds</artifactId>
|
||||
<version>0.0.9</version>
|
||||
<version>0.1.0</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>TFGuilds</name>
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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<String> 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;
|
||||
}
|
||||
}
|
|
@ -34,3 +34,7 @@ commands:
|
|||
description: If invited, allows you to join a guild
|
||||
usage: /<command> <player>
|
||||
aliases: [guildinvite]
|
||||
leaveguild:
|
||||
description: Leave your guild
|
||||
usage: /<command>
|
||||
aliases: [guildleave]
|
Loading…
Reference in a new issue