diff --git a/src/main/java/fr/communaywen/core/commands/TeamCommand.java b/src/main/java/fr/communaywen/core/commands/TeamCommand.java index f7d7caf1..463b8ab9 100644 --- a/src/main/java/fr/communaywen/core/commands/TeamCommand.java +++ b/src/main/java/fr/communaywen/core/commands/TeamCommand.java @@ -33,9 +33,15 @@ public class TeamCommand { TeamManager teamManager = AywenCraftPlugin.getInstance().getTeamManager(); @DefaultFor("~") - public void sendHelp(BukkitCommandActor actor, ExecutableCommand command) { - String helpCommandPath = command.getPath().toRealString() + " help"; - actor.getCommandHandler().dispatch(actor, helpCommandPath); + public void sendHelp(Player player, ExecutableCommand command, CommandHelp help, @Default("1") @Range(min = 1) int page) { + if(teamManager.isInTeam(player.getUniqueId())) { + Team team = teamManager.getTeamByPlayer(player.getUniqueId()); + TeamMenu teamMenu = new TeamMenu(player, team, false); + teamMenu.open(); + } else { + Audience audience = AywenCraftPlugin.getInstance().getAdventure().sender(player); + AywenCraftPlugin.getInstance().getInteractiveHelpMenu().sendInteractiveMenu(audience, help, 1, command, "§b§lTEAM"); + } } @Subcommand("help") @@ -48,8 +54,8 @@ public void sendHelp(BukkitCommandActor sender, CommandHelp help, Exe @Subcommand("menu") @Description("Menu de la team") public void teamMenu(Player player) { - Team team = teamManager.isInTeam(player.getUniqueId()); - if (team == null) { + Team team = teamManager.getTeamByPlayer(player.getUniqueId()); + if (teamManager.isInTeam(player.getUniqueId())) { CommandUtils.sendMessage(player, "Vous n'êtes pas dans une team !", true); return; } @@ -61,7 +67,7 @@ public void teamMenu(Player player) { @Description("Créer une team") public void createTeam(Player player, @Named("nom") String teamName) { TeamManager teamManager = AywenCraftPlugin.getInstance().getTeamManager(); - if (teamManager.isInTeam(player.getUniqueId()) != null) { + if (teamManager.isInTeam(player.getUniqueId())) { CommandUtils.sendMessage(player, "Vous êtes déjà dans une team !", true); return; } @@ -89,8 +95,8 @@ public void listTeams(Player player) { @Subcommand("invite") @Description("Inviter un joueur dans la team") public void invitePlayer(Player player, @Named("joueur") Player target) { - Team team = teamManager.isInTeam(player.getUniqueId()); - if (team == null) { + Team team = teamManager.getTeamByPlayer(player.getUniqueId()); + if (team.isIn(target.getUniqueId())) { CommandUtils.sendMessage(player, "Vous n'êtes pas dans une team !", true); return; } @@ -98,7 +104,7 @@ public void invitePlayer(Player player, @Named("joueur") Player target) { CommandUtils.sendMessage(player, "Vous n'êtes pas le propriétaire de la team !", true); return; } - if (teamManager.isInTeam(target.getUniqueId()) != null) { + if (teamManager.isInTeam(target.getUniqueId())) { CommandUtils.sendMessage(player, "Le joueur " + target.getName() + " est déjà dans une team !", true); return; } @@ -117,8 +123,8 @@ public void invitePlayer(Player player, @Named("joueur") Player target) { @Subcommand("accept") @Description("Accepter une invitation") public void acceptInvite(Player player) { - Team team = teamManager.isInTeam(player.getUniqueId()); - if (team != null) { + Team team = teamManager.getTeamByPlayer(player.getUniqueId()); + if (team.isIn(player.getUniqueId())) { CommandUtils.sendMessage(player, "Vous êtes déjà dans une team !", true); return; } @@ -139,8 +145,8 @@ public void acceptInvite(Player player) { @Subcommand("kick") @Description("Kick un joueur de la team") public void kickPlayer(Player player, @Named("joueur") Player target) { - Team team = teamManager.isInTeam(player.getUniqueId()); - if (team == null) { + Team team = teamManager.getTeamByPlayer(player.getUniqueId()); + if (team.isIn(target.getUniqueId())) { CommandUtils.sendMessage(player, "Vous n'êtes pas dans une team !", true); return; } @@ -164,8 +170,8 @@ public void kickPlayer(Player player, @Named("joueur") Player target) { @Subcommand("leave") @Description("Quitter la team") public void leaveTeam(Player player) { - Team team = teamManager.isInTeam(player.getUniqueId()); - if (team == null) { + Team team = teamManager.getTeamByPlayer(player.getUniqueId()); + if (team.isIn(player.getUniqueId())) { CommandUtils.sendMessage(player, "Vous n'êtes pas dans une team !", true); return; } @@ -175,8 +181,8 @@ public void leaveTeam(Player player) { @Subcommand("inventory") @Description("Inventaire de la team") public void teamInventory(Player player) { - Team team = teamManager.isInTeam(player.getUniqueId()); - if (team == null) { + Team team = teamManager.getTeamByPlayer(player.getUniqueId()); + if (team.isIn(player.getUniqueId())) { CommandUtils.sendMessage(player, "Vous n'êtes pas dans une team !", true); return; } diff --git a/src/main/java/fr/communaywen/core/teams/TeamManager.java b/src/main/java/fr/communaywen/core/teams/TeamManager.java index 0b357ebd..70080f48 100644 --- a/src/main/java/fr/communaywen/core/teams/TeamManager.java +++ b/src/main/java/fr/communaywen/core/teams/TeamManager.java @@ -40,7 +40,16 @@ public boolean deleteTeam(Team team) { return true; } - public Team isInTeam(UUID player) { + public boolean isInTeam(UUID player) { + for (Team team : teams) { + if (team.getPlayers().contains(player)) { + return true; + } + } + return false; + } + + public Team getTeamByPlayer(UUID player) { for (Team team : teams) { if (team.getPlayers().contains(player)) { return team;