SteamWar/FightSystem
Archiviert
13
1

Merge branch 'AkCommand-Cleanup' into 'master'

AkCommand Cleanup

Closes #1 and #2

See merge request Yaruma3341/fightsystem!1
Dieser Commit ist enthalten in:
Yaruma3341 2019-02-15 18:04:44 +01:00
Commit 15d25dfea9
3 geänderte Dateien mit 91 neuen und 117 gelöschten Zeilen

2
.gitignore vendored
Datei anzeigen

@ -1,3 +1,3 @@
.idea
pom.xml
WarShipFactory.iml
*.iml

Datei anzeigen

@ -19,22 +19,17 @@ public class AkCommand implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if(sender instanceof Player) {
Player player = (Player) sender;
if(args.length == 0) {
sendHelp(player);
if(!(sender instanceof Player)) {
return false;
}
Player player = (Player) sender;
if(args.length == 1) {
if(args[0].equalsIgnoreCase("help")) {
sendHelp(player);
return false;
}
if(args[0].equalsIgnoreCase("ready")) {
if(FightSystem.getPlugin().getFightState() == FightState.SETUP) {
}else if(args[0].equalsIgnoreCase("ready") && FightSystem.getPlugin().getFightState() == FightState.SETUP){
FightTeam fightTeam = Fight.getPlayerTeam(player);
if(fightTeam != null) {
if(!fightTeam.isReady()) {
@ -45,73 +40,48 @@ public class AkCommand implements CommandExecutor {
fightTeam.broadcast(FightSystem.PREFIX + "§cEuer Team ist nicht mehr bereit!");
}
}
}
return false;
}
if(args[0].equalsIgnoreCase("accept")) {
if(FightSystem.getPlugin().getFightState() == FightState.SETUP) {
if(Fight.getRedTeam().getInvited().contains(player)) {
FightPlayer leader = Fight.getRedTeam().getLeader();
Fight.getRedTeam().addMember(player);
}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.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");
}
if(Fight.getBlueTeam().getInvited().contains(player)) {
FightPlayer leader = Fight.getRedTeam().getLeader();
Fight.getRedTeam().addMember(player);
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");
}
}
return false;
}
if(args[0].equalsIgnoreCase("decline")) {
if(FightSystem.getPlugin().getFightState() == FightState.SETUP) {
if(Fight.getRedTeam().getInvited().contains(player)) {
FightPlayer leader = Fight.getRedTeam().getLeader();
Fight.getRedTeam().getInvited().remove(player);
}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!");
}
if(Fight.getBlueTeam().getInvited().contains(player)) {
FightPlayer leader = Fight.getBlueTeam().getLeader();
Fight.getBlueTeam().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!");
}
}
return false;
}
}else if(args[0].equalsIgnoreCase("leader")){
if(args[0].equalsIgnoreCase("leader")) {
if(!Fight.getBlueTeam().hasTeamLeader()) {
if(!Fight.getBlueTeam().hasTeamLeader()){
FightPlayer fightPlayer = new FightPlayer(player, false);
Fight.getBlueTeam().setLeader(fightPlayer);
player.sendMessage(FightSystem.PREFIX + "§aDu bist nun Leader von " + fileManager.getStringFromConfig("Output.TeamBlueColor") + fileManager.getStringFromConfig("Output.TeamBlueName"));
return false;
} else if(!Fight.getRedTeam().hasTeamLeader()) {
} else if(!Fight.getRedTeam().hasTeamLeader()){
FightPlayer fightPlayer = new FightPlayer(player, false);
Fight.getBlueTeam().setLeader(fightPlayer);
player.sendMessage(FightSystem.PREFIX + "§aDu bist nun Leader von " + fileManager.getStringFromConfig("Output.TeamRedColor") + fileManager.getStringFromConfig("Output.TeamRedName"));
return false;
} else
player.sendMessage(FightSystem.PREFIX + "§cEs sind bereits zwei Leader vorhanden!");
return false;
}
}
if(args.length == 2) {
}else if(args.length == 2) {
if(args[0].equalsIgnoreCase("invite")) {
if(FightSystem.getPlugin().getFightState() == FightState.SETUP) {
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()) {
if(fightPlayer.isLeader()){
Player target = Bukkit.getPlayer(args[1]);
if(target != null) {
@ -125,19 +95,15 @@ public class AkCommand implements CommandExecutor {
} else
player.sendMessage(FightSystem.PREFIX + "§cDu bist nicht der Leader des Teams!");
}
}
return false;
}
if(args[0].equalsIgnoreCase("remove")) {
}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()) {
if(fightTeam.isPlayerInTeam(target)) {
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 + "§4Du wurdest auf deinem Team entfernt!");
@ -146,9 +112,8 @@ public class AkCommand implements CommandExecutor {
}
}
}
return false;
}
}
}else{
sendHelp(player);
}
return false;
}

Datei anzeigen

@ -28,6 +28,15 @@ public class Fight {
return null;
}
public static FightTeam getInvitedTeam(Player player){
if(redTeam.getInvited().contains(player)) {
return redTeam;
}else if(blueTeam.getInvited().contains(player)) {
return blueTeam;
}
return null;
}
public void broadcast(String message) {
blueTeam.broadcast(message);
redTeam.broadcast(message);