diff --git a/src/me/yaruma/fightsystem/commands/AkCommand.java b/src/me/yaruma/fightsystem/commands/AkCommand.java index 2e90727..3bdf79c 100644 --- a/src/me/yaruma/fightsystem/commands/AkCommand.java +++ b/src/me/yaruma/fightsystem/commands/AkCommand.java @@ -28,205 +28,209 @@ public class AkCommand implements CommandExecutor { } Player player = (Player) sender; - if(args.length == 1) { + if(FightSystem.getPlugin().getFightState() == FightState.SETUP) { - if(args[0].equalsIgnoreCase("help")) { - sendHelp(player); + if(args.length == 1) { - }else if(args[0].equalsIgnoreCase("ready") && FightSystem.getPlugin().getFightState() == FightState.SETUP){ - FightTeam fightTeam = Fight.getPlayerTeam(player); - if(fightTeam != null) { - fightTeam.setReady(!fightTeam.isReady()); - } - - }else if(args[0].equalsIgnoreCase("accept") && FightSystem.getPlugin().getFightState() == FightState.SETUP){ - FightTeam team = Fight.getInvitedTeam(player); - if(team != null){ - FightPlayer leader = team.getLeader(); - team.addMember(player); - player.setGameMode(GameMode.ADVENTURE); - if(team == Fight.getRedTeam()) - player.teleport(Config.TeamRedSpawn); - else - player.teleport(Config.TeamBlueSpawn); - player.sendMessage(FightSystem.PREFIX + "§aDu bist dem Team von §6" + leader.getPlayer().getName() + " §abeigetreten!"); - leader.sendMessage(FightSystem.PREFIX + "§aDer Spieler §6" + player.getName() + " §aist deinem Team beigetreten"); - } - - }else if(args[0].equalsIgnoreCase("decline") && FightSystem.getPlugin().getFightState() == FightState.SETUP){ - FightTeam team = Fight.getInvitedTeam(player); - if(team != null){ - FightPlayer leader = team.getLeader(); - team.getInvited().remove(player); - player.sendMessage(FightSystem.PREFIX + "§aDu hast die Einladung von §6" + leader.getPlayer().getName() + " §aabgelehnt!"); - leader.sendMessage(FightSystem.PREFIX + "§cDer Spieler §6" + player.getName() + " §chat deine Einladung abgelehnt!"); - } - - }else if(args[0].equalsIgnoreCase("leader")){ - - if(!Fight.getBlueTeam().hasTeamLeader()){ - FightPlayer fightPlayer = new FightPlayer(player, false); - Fight.getBlueTeam().setLeader(fightPlayer); - player.sendMessage(FightSystem.PREFIX + "§aDu bist nun Leader von " + Fight.getBlueTeam().getName()); - - } else if(!Fight.getRedTeam().hasTeamLeader()){ - FightPlayer fightPlayer = new FightPlayer(player, false); - Fight.getBlueTeam().setLeader(fightPlayer); - player.sendMessage(FightSystem.PREFIX + "§aDu bist nun Leader von " + Fight.getRedTeam().getName()); - - } else - player.sendMessage(FightSystem.PREFIX + "§cEs sind bereits zwei Leader vorhanden!"); - } else if(args[0].equalsIgnoreCase("leave")) { - FightTeam fightTeam = Fight.getPlayerTeam(player); - if(fightTeam != null) { - fightTeam.removePlayer(player); - player.setGameMode(GameMode.SPECTATOR); - player.teleport(Config.SpecSpawn); - player.sendMessage(FightSystem.PREFIX + "§aDu hast das Team verlassen!"); - } else - player.sendMessage(FightSystem.PREFIX + "§cDu befindest dich in keinem Team!"); - } - - }else if(args.length == 2) { - - if(args[0].equalsIgnoreCase("invite") && FightSystem.getPlugin().getFightState() == FightState.SETUP){ - FightTeam fightTeam = Fight.getPlayerTeam(player); - if(fightTeam != null) { - FightPlayer fightPlayer = fightTeam.getFightPlayer(player); - if(fightPlayer.isLeader()){ - - Player target = Bukkit.getPlayer(args[1]); - if(target != null) { - if(Fight.getPlayerTeam(target) != null) { - player.sendMessage(FightSystem.PREFIX + "§cDer Spieler §6" + target.getName() + " §cist bereits in einem Team!"); - } else if(!(Fight.getOpposite(fightTeam).getInvited().contains(target) && fightTeam.getInvited().contains(target))) { - fightTeam.getInvited().add(target); - target.sendMessage(FightSystem.PREFIX + "§aDu wurdest von §6" + player.getName() + " §ain sein Team eingeladen!"); - player.sendMessage(FightSystem.PREFIX + "§aDu hast den Spieler §6" + target.getName() + " §ain dein Team eingeladen!"); - } else - player.sendMessage(FightSystem.PREFIX + "§cDieser Spieler wurde bereits eingeladen!"); - } else - player.sendMessage(FightSystem.PREFIX + "§cDieser Spieler ist nicht online!"); - } else - player.sendMessage(FightSystem.PREFIX + "§cDu bist nicht der Leader des Teams!"); - } else - player.sendMessage(FightSystem.PREFIX + "§cDu befindest dich in keinem Team!"); - - }else if(args[0].equalsIgnoreCase("remove")){ - if(FightSystem.getPlugin().getFightState() == FightState.SETUP) { - FightTeam fightTeam = Fight.getPlayerTeam(player); - if(fightTeam != null) { - Player target = Bukkit.getPlayer(args[1]); - if(target != null) { - FightPlayer fightPlayer = fightTeam.getFightPlayer(player); - if(fightPlayer.isLeader() && fightTeam.isPlayerInTeam(target)){ - fightTeam.removePlayer(target); - player.sendMessage(FightSystem.PREFIX + "§aDu hast den Spieler §6" + target.getName() + " §aaus dem Team entfernt!"); - target.sendMessage(FightSystem.PREFIX + "§cDu wurdest aus deinem Team entfernt!"); - } - } - } - } - }else if(args[0].equalsIgnoreCase("kit")) { - if(FightSystem.getPlugin().getFightState() != FightState.SETUP) { - player.sendMessage(FightSystem.PREFIX + "§cDu kannst dein Kit nicht mehr wechseln!"); - return false; - } - - FightTeam fightTeam = Fight.getPlayerTeam(player); - if(fightTeam == null){ - player.sendMessage(FightSystem.PREFIX + "§cDu bist in keinem Team!"); - return false; - } - - Kit kit = KitManager.getKitByName(args[1]); - if(kit == null){ - player.sendMessage(FightSystem.PREFIX + "§cDieses Kit existiert nicht!"); - return false; - } - - FightPlayer fightPlayer = fightTeam.getFightPlayer(player); - if( - (fightPlayer.isLeader() && !kit.isLeaderAllowed()) || - (!fightPlayer.isLeader() && !kit.isMemberAllowed()) - ){ - player.sendMessage(FightSystem.PREFIX + "§cDu darfst dieses Kit nicht verwenden!"); - return false; - } - - //TODO: Owns Kit - - Fight.getFightPlayer(player).setKit(kit); - player.sendMessage(FightSystem.PREFIX + "§aDu hast nun das Kit §6" + args[1] + "§a!"); - - } else if(args[0].equalsIgnoreCase("addkit")){ - if(WarkingUser.get(player.getUniqueId()).getUserGroup() != UserGroup.Developer){ + if(args[0].equalsIgnoreCase("help")) { sendHelp(player); - return false; - } - KitManager.saveInventory(args[1], player); - } else if(args[0].equalsIgnoreCase("schemlist") && FightSystem.getPlugin().getFightState() == FightState.SETUP) { - try { + + }else if(args[0].equalsIgnoreCase("ready") && FightSystem.getPlugin().getFightState() == FightState.SETUP){ FightTeam fightTeam = Fight.getPlayerTeam(player); if(fightTeam != null) { - if(fightTeam.getFightPlayer(player).isLeader()) { - if(args[1].equalsIgnoreCase("public")) { - Fight.getPlayerTeam(player).sendPlayerSchematicList(true, 0, 15, player, Config.SchematicType); - return false; - } else { - int page; - try { - page = Integer.parseInt(args[1]); - } catch (NumberFormatException ex) { - return false; + fightTeam.setReady(!fightTeam.isReady()); + } + + }else if(args[0].equalsIgnoreCase("accept") && FightSystem.getPlugin().getFightState() == FightState.SETUP){ + FightTeam team = Fight.getInvitedTeam(player); + if(team != null){ + FightPlayer leader = team.getLeader(); + team.addMember(player); + player.setGameMode(GameMode.ADVENTURE); + if(team == Fight.getRedTeam()) + player.teleport(Config.TeamRedSpawn); + else + player.teleport(Config.TeamBlueSpawn); + player.sendMessage(FightSystem.PREFIX + "§aDu bist dem Team von §6" + leader.getPlayer().getName() + " §abeigetreten!"); + leader.sendMessage(FightSystem.PREFIX + "§aDer Spieler §6" + player.getName() + " §aist deinem Team beigetreten"); + } + + }else if(args[0].equalsIgnoreCase("decline") && FightSystem.getPlugin().getFightState() == FightState.SETUP){ + FightTeam team = Fight.getInvitedTeam(player); + if(team != null){ + FightPlayer leader = team.getLeader(); + team.getInvited().remove(player); + player.sendMessage(FightSystem.PREFIX + "§aDu hast die Einladung von §6" + leader.getPlayer().getName() + " §aabgelehnt!"); + leader.sendMessage(FightSystem.PREFIX + "§cDer Spieler §6" + player.getName() + " §chat deine Einladung abgelehnt!"); + } + + }else if(args[0].equalsIgnoreCase("leader")){ + + if(!Fight.getBlueTeam().hasTeamLeader()){ + FightPlayer fightPlayer = new FightPlayer(player, false); + Fight.getBlueTeam().setLeader(fightPlayer); + player.sendMessage(FightSystem.PREFIX + "§aDu bist nun Leader von " + Fight.getBlueTeam().getName()); + + } else if(!Fight.getRedTeam().hasTeamLeader()){ + FightPlayer fightPlayer = new FightPlayer(player, false); + Fight.getBlueTeam().setLeader(fightPlayer); + player.sendMessage(FightSystem.PREFIX + "§aDu bist nun Leader von " + Fight.getRedTeam().getName()); + + } else + player.sendMessage(FightSystem.PREFIX + "§cEs sind bereits zwei Leader vorhanden!"); + } else if(args[0].equalsIgnoreCase("leave")) { + FightTeam fightTeam = Fight.getPlayerTeam(player); + if(fightTeam != null) { + fightTeam.removePlayer(player); + player.setGameMode(GameMode.SPECTATOR); + player.teleport(Config.SpecSpawn); + player.sendMessage(FightSystem.PREFIX + "§aDu hast das Team verlassen!"); + } else + player.sendMessage(FightSystem.PREFIX + "§cDu befindest dich in keinem Team!"); + } + + }else if(args.length == 2) { + + if(args[0].equalsIgnoreCase("invite") && FightSystem.getPlugin().getFightState() == FightState.SETUP){ + FightTeam fightTeam = Fight.getPlayerTeam(player); + if(fightTeam != null) { + FightPlayer fightPlayer = fightTeam.getFightPlayer(player); + if(fightPlayer.isLeader()){ + + Player target = Bukkit.getPlayer(args[1]); + if(target != null) { + if(Fight.getPlayerTeam(target) != null) { + player.sendMessage(FightSystem.PREFIX + "§cDer Spieler §6" + target.getName() + " §cist bereits in einem Team!"); + } else if(!(Fight.getOpposite(fightTeam).getInvited().contains(target) && fightTeam.getInvited().contains(target))) { + fightTeam.getInvited().add(target); + target.sendMessage(FightSystem.PREFIX + "§aDu wurdest von §6" + player.getName() + " §ain sein Team eingeladen!"); + player.sendMessage(FightSystem.PREFIX + "§aDu hast den Spieler §6" + target.getName() + " §ain dein Team eingeladen!"); + } else + player.sendMessage(FightSystem.PREFIX + "§cDieser Spieler wurde bereits eingeladen!"); + } else + player.sendMessage(FightSystem.PREFIX + "§cDieser Spieler ist nicht online!"); + } else + player.sendMessage(FightSystem.PREFIX + "§cDu bist nicht der Leader des Teams!"); + } else + player.sendMessage(FightSystem.PREFIX + "§cDu befindest dich in keinem Team!"); + + }else if(args[0].equalsIgnoreCase("remove")){ + if(FightSystem.getPlugin().getFightState() == FightState.SETUP) { + FightTeam fightTeam = Fight.getPlayerTeam(player); + if(fightTeam != null) { + Player target = Bukkit.getPlayer(args[1]); + if(target != null) { + FightPlayer fightPlayer = fightTeam.getFightPlayer(player); + if(fightPlayer.isLeader() && fightTeam.isPlayerInTeam(target)){ + fightTeam.removePlayer(target); + player.sendMessage(FightSystem.PREFIX + "§aDu hast den Spieler §6" + target.getName() + " §aaus dem Team entfernt!"); + target.sendMessage(FightSystem.PREFIX + "§cDu wurdest aus deinem Team entfernt!"); } - Fight.getPlayerTeam(player).sendPlayerSchematicList(false, page, 15, player, Config.SchematicType); } } } - } catch (NumberFormatException ex) { - player.sendMessage(FightSystem.PREFIX + "§cDu musst eine Seitenzahl angeben!"); - return false; - } - } - }else if(args.length == 3) { - if(args[0].equalsIgnoreCase("schem")) { - FightTeam fightTeam = Fight.getPlayerTeam(player); - if(fightTeam == null) { - player.sendMessage(FightSystem.PREFIX + "§cDu bist in keinem Team!"); - return false; - }else if(fightTeam.hasSchematic()) { - player.sendMessage(FightSystem.PREFIX + "§cDie Schematic ist bereits gewählt!"); - return false; - } + }else if(args[0].equalsIgnoreCase("kit")) { + if(FightSystem.getPlugin().getFightState() != FightState.SETUP) { + player.sendMessage(FightSystem.PREFIX + "§cDu kannst dein Kit nicht mehr wechseln!"); + return false; + } - Schematic schem; - if(args[2].equalsIgnoreCase("public")) { - schem = Schematic.getSchemFromDB(args[1], WarkingUser.get(0).getUUID()); - } else if(args[2].equalsIgnoreCase("private")) { - schem = Schematic.getSchemFromDB(args[1], player.getUniqueId()); - } else - return false; + FightTeam fightTeam = Fight.getPlayerTeam(player); + if(fightTeam == null){ + player.sendMessage(FightSystem.PREFIX + "§cDu bist in keinem Team!"); + return false; + } + Kit kit = KitManager.getKitByName(args[1]); + if(kit == null){ + player.sendMessage(FightSystem.PREFIX + "§cDieses Kit existiert nicht!"); + return false; + } - if(schem == null) { - schem = Schematic.getSchemFromDB(args[1], 0); - if(schem == null){ - player.sendMessage(FightSystem.PREFIX + "§cDiese Schematic gibt es nicht!"); + FightPlayer fightPlayer = fightTeam.getFightPlayer(player); + if( + (fightPlayer.isLeader() && !kit.isLeaderAllowed()) || + (!fightPlayer.isLeader() && !kit.isMemberAllowed()) + ){ + player.sendMessage(FightSystem.PREFIX + "§cDu darfst dieses Kit nicht verwenden!"); + return false; + } + + //TODO: Owns Kit + + Fight.getFightPlayer(player).setKit(kit); + player.sendMessage(FightSystem.PREFIX + "§aDu hast nun das Kit §6" + args[1] + "§a!"); + + } else if(args[0].equalsIgnoreCase("addkit")){ + if(WarkingUser.get(player.getUniqueId()).getUserGroup() != UserGroup.Developer){ + sendHelp(player); + return false; + } + KitManager.saveInventory(args[1], player); + } else if(args[0].equalsIgnoreCase("schemlist") && FightSystem.getPlugin().getFightState() == FightState.SETUP) { + try { + FightTeam fightTeam = Fight.getPlayerTeam(player); + if(fightTeam != null) { + if(fightTeam.getFightPlayer(player).isLeader()) { + if(args[1].equalsIgnoreCase("public")) { + Fight.getPlayerTeam(player).sendPlayerSchematicList(true, 0, 15, player, Config.SchematicType); + return false; + } else { + int page; + try { + page = Integer.parseInt(args[1]); + } catch (NumberFormatException ex) { + return false; + } + Fight.getPlayerTeam(player).sendPlayerSchematicList(false, page, 15, player, Config.SchematicType); + } + } + } + } catch (NumberFormatException ex) { + player.sendMessage(FightSystem.PREFIX + "§cDu musst eine Seitenzahl angeben!"); return false; } } - if(schem.getSchemType() != Config.SchematicType) { - player.sendMessage(FightSystem.PREFIX + "§cDiese Schematic ist kein " + Config.GameName); - return false; - } + }else if(args.length == 3) { + if(args[0].equalsIgnoreCase("schem")) { + FightTeam fightTeam = Fight.getPlayerTeam(player); + if(fightTeam == null) { + player.sendMessage(FightSystem.PREFIX + "§cDu bist in keinem Team!"); + return false; + }else if(fightTeam.hasSchematic()) { + player.sendMessage(FightSystem.PREFIX + "§cDie Schematic ist bereits gewählt!"); + return false; + } - fightTeam.setSchematic(schem); - Fight.getPlayerTeam(player).broadcast(FightSystem.PREFIX + "Schematic §6" + args[1] + " §8wird für den Kampf verwendet!"); + Schematic schem; + if(args[2].equalsIgnoreCase("public")) { + schem = Schematic.getSchemFromDB(args[1], WarkingUser.get(0).getUUID()); + } else if(args[2].equalsIgnoreCase("private")) { + schem = Schematic.getSchemFromDB(args[1], player.getUniqueId()); + } else + return false; + + + if(schem == null) { + schem = Schematic.getSchemFromDB(args[1], 0); + if(schem == null){ + player.sendMessage(FightSystem.PREFIX + "§cDiese Schematic gibt es nicht!"); + return false; + } + } + if(schem.getSchemType() != Config.SchematicType) { + player.sendMessage(FightSystem.PREFIX + "§cDiese Schematic ist kein " + Config.GameName); + return false; + } + + fightTeam.setSchematic(schem); + Fight.getPlayerTeam(player).broadcast(FightSystem.PREFIX + "Schematic §6" + args[1] + " §8wird für den Kampf verwendet!"); + } + } else { + sendHelp(player); } - } else { - sendHelp(player); - } + } else + player.sendMessage(FightSystem.PREFIX + "§cDer Fight hat bereits begonnen!"); return false; }