package de.steamwar.fightsystem.commands; import de.steamwar.fightsystem.FightSystem; import de.steamwar.fightsystem.fight.Fight; import de.steamwar.fightsystem.fight.FightPlayer; import de.steamwar.fightsystem.fight.FightState; import de.steamwar.fightsystem.fight.FightTeam; import de.steamwar.fightsystem.kit.Kit; import de.steamwar.fightsystem.kit.KitManager; import org.bukkit.Bukkit; import org.bukkit.entity.Player; class Commands { private Commands(){} private static void errNoTeam(Player p){ p.sendMessage(FightSystem.PREFIX + "§cDu bist in keinem Team!"); } static boolean checkSetup(Player p){ if(FightSystem.getFightState() != FightState.SETUP){ p.sendMessage(FightSystem.PREFIX + "§cDer Kampf hat bereits begonnen!"); return true; } return false; } private static FightTeam checkGetInvitedTeam(Player p){ FightTeam fightTeam = Fight.getInvitedTeam(p); if(fightTeam == null){ p.sendMessage(FightSystem.PREFIX + "§cDu wurdest von keinem Team eingeladen!"); } return fightTeam; } private static FightPlayer checkGetPlayer(Player p){ FightPlayer fightPlayer = Fight.getFightPlayer(p); if(fightPlayer == null){ errNoTeam(p); } return fightPlayer; } private static FightPlayer checkGetLeader(Player p){ FightPlayer fightPlayer = checkGetPlayer(p); if(fightPlayer != null && !fightPlayer.isLeader()){ p.sendMessage(FightSystem.PREFIX + "§cDu bist kein Leader!"); fightPlayer = null; } return fightPlayer; } private static FightTeam checkGetTeam(Player p){ FightTeam fightTeam = Fight.getPlayerTeam(p); if(fightTeam == null){ errNoTeam(p); } return fightTeam; } private static Player checkGetPlayer(Player p, String t){ Player target = Bukkit.getPlayer(t); if(target == null) { p.sendMessage(FightSystem.PREFIX + "§cDer Spieler ist nicht in der Arena!"); } return target; } static void toggleReady(Player p){ if(checkSetup(p)) return; FightTeam fightTeam = checkGetTeam(p); if(fightTeam == null || checkGetLeader(p) == null) return; fightTeam.setReady(!fightTeam.isReady()); } static void acceptInvitation(Player p){ if(checkSetup(p)) return; FightTeam team = checkGetInvitedTeam(p); if(team == null) return; FightPlayer leader = team.getLeader(); p.sendMessage(FightSystem.PREFIX + "§aDu bist Team " + team.getColoredName() + " §abeigetreten!"); leader.sendMessage(FightSystem.PREFIX + "§aDer Spieler §e" + p.getName() + " §aist deinem Team beigetreten!"); team.addMember(p); } static void declineInvitation(Player p){ if(checkSetup(p)) return; FightTeam team = checkGetInvitedTeam(p); if(team == null) return; FightPlayer leader = team.getLeader(); p.sendMessage(FightSystem.PREFIX + "§aDu hast die Einladung von " + team.getColoredName() + " §aabgelehnt!"); leader.sendMessage(FightSystem.PREFIX + "§cDer Spieler §e" + p.getName() + " §chat deine Einladung abgelehnt!"); team.getInvited().remove(p); } static void leaveTeam(Player p){ if(checkSetup(p)) return; FightTeam fightTeam = checkGetTeam(p); if(fightTeam == null) return; p.sendMessage(FightSystem.PREFIX + "§aDu hast das Team " + fightTeam.getColoredName() + " §averlassen!"); fightTeam.removePlayer(p); } static void invite(Player p, String invited){ if(checkSetup(p)) return; FightTeam fightTeam = checkGetTeam(p); if(fightTeam == null) return; FightPlayer fightPlayer = checkGetLeader(p); if(fightPlayer == null) return; Player target = checkGetPlayer(p, invited); if(target == null) return; if(Fight.getPlayerTeam(target) != null) { p.sendMessage(FightSystem.PREFIX + "§cDer Spieler §e" + target.getName() + " §cist bereits in einem Team!"); return; } if(Fight.getOpposite(fightTeam).getInvited().contains(target) || fightTeam.getInvited().contains(target)) { p.sendMessage(FightSystem.PREFIX + "§cDieser Spieler wurde bereits eingeladen!"); return; } target.sendMessage(FightSystem.PREFIX + "§aDu wurdest in das Team von §e" + p.getName() + " §aeingeladen!"); p.sendMessage(FightSystem.PREFIX + "§aDu hast den Spieler §e" + target.getName() + " §ain dein Team eingeladen!"); fightTeam.getInvited().add(target); GUI.invitation(p, target); } static void kick(Player p, String kicked){ if(checkSetup(p)) return; FightTeam fightTeam = checkGetTeam(p); if(fightTeam == null) return; FightPlayer fightPlayer = checkGetLeader(p); if(fightPlayer == null) return; Player target = checkGetPlayer(p, kicked); if(target == null) return; if(!fightTeam.isPlayerInTeam(target)){ p.sendMessage(FightSystem.PREFIX + "§cDer Spieler " + target.getName() + " §cist nicht in deinem Team§c!"); return; } p.sendMessage(FightSystem.PREFIX + "§aDu hast den Spieler §e" + target.getName() + " §aaus dem Team entfernt!"); target.sendMessage(FightSystem.PREFIX + "§cDu wurdest aus dem Team entfernt!"); fightTeam.removePlayer(target); } static void kit(Player p, String kitName){ if(checkSetup(p)) return; FightPlayer fightPlayer = checkGetPlayer(p); if(fightPlayer == null) return; Kit k = KitManager.getKitByName(kitName); if(k == null){ p.sendMessage(FightSystem.PREFIX + "§cDieses Kit gibt es nicht!"); return; } if((fightPlayer.isLeader() && !k.isLeaderAllowed()) || (!fightPlayer.isLeader() && !k.isMemberAllowed())){ p.sendMessage(FightSystem.PREFIX + "§cDu darfst dieses Kit nicht verwenden!"); return; } p.sendMessage(FightSystem.PREFIX + "§aDu spielst nun mit dem Kit §e" + kitName + "§a!"); fightPlayer.setKit(k); } static void sendHelp(Player p) { p.sendMessage(FightSystem.PREFIX + "§7Hilfe für das Kampfsystem"); FightPlayer fightPlayer = Fight.getFightPlayer(p); if(fightPlayer == null){ p.sendMessage("§8/§eaccept §8- §7Einladung annehmen"); p.sendMessage("§8/§edecline §8- §7Einladung ablehnen"); p.sendMessage("§8/§eleader §8- §7Werde der Leader eines Teams"); }else{ if(fightPlayer.isLeader()){ p.sendMessage("§8/§eak schem §8<§eSchematic§8> - §7Setze deine Schematic"); p.sendMessage("§8/§eready §8- §7Setzt das eigene Team auf bereit"); p.sendMessage("§8/§einvite §8<§eSpieler§8> - §7Lade einen Spieler in dein Team ein"); p.sendMessage("§8/§eremove §8<§eSpieler§8> - §7Wirft einen Spieler aus dem Team"); } p.sendMessage("§8/§ekit §8<§eKit§8> - §7Wähle ein Kit"); p.sendMessage("§8/§eleave §8- §7Team verlassen"); } } }