try this daniel

This commit is contained in:
Super_ 2020-06-20 17:32:08 -04:00
parent c7acd5d062
commit a10542f3eb

View file

@ -16,56 +16,51 @@ public class InviteGuildCommand extends GBase implements CommandExecutor
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) public boolean onCommand(CommandSender sender, Command command, String label, String[] args)
{ {
if (args.length == 1) if (args.length != 1)
{ {
return false;
}
if (GUtil.isConsole(sender))
{
sender.sendMessage(ChatColor.RED + "You are not allowed to run this command.");
return true;
}
Player player = (Player) sender; Player player = (Player) sender;
String guild = GUtil.getGuild(player); String guild = GUtil.getGuild(player);
Player target = Bukkit.getPlayer(args[0]); Player target = Bukkit.getPlayer(args[0]);
if (GUtil.isConsole(player)) if (target != null)
{ {
player.sendMessage(ChatColor.RED + "You are not allowed to run this command."); if (GUtil.isGuildMember(player, GUtil.getGuild(target)))
return true;
}
GUtil.invitePlayer(target, 60);
if (!(target == null))
{
if (GUtil.invitedPlayers.containsKey(target.getName()))
{
if (GUtil.isGuildMember(target, GUtil.getGuild(target)))
{ {
player.sendMessage(ChatColor.RED + "That player is already in a guild."); player.sendMessage(ChatColor.RED + "That player is already in a guild.");
return true; return true;
} }
GUtil.invitePlayer(target, 60);
player.sendMessage(GUtil.color("&aSent an invitation to " + target.getName())); player.sendMessage(GUtil.color("&aSent an invitation to " + target.getName()));
return true;
}
if (GUtil.invitedPlayers.containsKey(player.getName()))
{
if (args[0].equalsIgnoreCase("accept")) if (args[0].equalsIgnoreCase("accept"))
{ {
List<String> players = plugin.guilds.getStringList("guilds." + guild + ".members"); List<String> players = plugin.guilds.getStringList("guilds." + guild + ".members");
players.add(target.getName()); players.add(player.getName());
GUtil.invitedPlayers.remove(target.getName()); GUtil.invitedPlayers.remove(player.getName());
target.sendMessage(ChatColor.GREEN + "You have successfully joined " + guild); player.sendMessage(ChatColor.GREEN + "You have successfully joined " + guild);
} }
if (args[0].equalsIgnoreCase("deny")) if (args[0].equalsIgnoreCase("deny"))
{ {
GUtil.invitedPlayers.remove(target.getName()); GUtil.invitedPlayers.remove(player.getName());
target.sendMessage(ChatColor.GREEN + "You have declined to join " + guild); player.sendMessage(ChatColor.GREEN + "You have declined to join " + guild);
} }
} return true;
else }
{
sender.sendMessage(ChatColor.RED + "You haven't received any guild invitations."); sender.sendMessage(ChatColor.GRAY + "Player not found.");
} return true;
}
else
{
sender.sendMessage(ChatColor.RED + "Player not found.");
}
}
return false;
} }
} }