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 .idea
pom.xml pom.xml
WarShipFactory.iml *.iml

Datei anzeigen

@ -19,22 +19,17 @@ public class AkCommand 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(sender instanceof Player) { if(!(sender instanceof Player)) {
Player player = (Player) sender; return false;
if(args.length == 0) {
sendHelp(player);
} }
Player player = (Player) sender;
if(args.length == 1) { if(args.length == 1) {
if(args[0].equalsIgnoreCase("help")) { if(args[0].equalsIgnoreCase("help")) {
sendHelp(player); sendHelp(player);
return false;
}
if(args[0].equalsIgnoreCase("ready")) { }else if(args[0].equalsIgnoreCase("ready") && FightSystem.getPlugin().getFightState() == FightState.SETUP){
if(FightSystem.getPlugin().getFightState() == FightState.SETUP) {
FightTeam fightTeam = Fight.getPlayerTeam(player); FightTeam fightTeam = Fight.getPlayerTeam(player);
if(fightTeam != null) { if(fightTeam != null) {
if(!fightTeam.isReady()) { if(!fightTeam.isReady()) {
@ -45,73 +40,48 @@ public class AkCommand implements CommandExecutor {
fightTeam.broadcast(FightSystem.PREFIX + "§cEuer Team ist nicht mehr bereit!"); fightTeam.broadcast(FightSystem.PREFIX + "§cEuer Team ist nicht mehr bereit!");
} }
} }
}
return false;
}
if(args[0].equalsIgnoreCase("accept")) { }else if(args[0].equalsIgnoreCase("accept") && FightSystem.getPlugin().getFightState() == FightState.SETUP){
if(FightSystem.getPlugin().getFightState() == FightState.SETUP) { FightTeam team = Fight.getInvitedTeam(player);
if(Fight.getRedTeam().getInvited().contains(player)) { if(team != null){
FightPlayer leader = Fight.getRedTeam().getLeader(); FightPlayer leader = team.getLeader();
Fight.getRedTeam().addMember(player); team.addMember(player);
player.sendMessage(FightSystem.PREFIX + "§aDu bist dem Team von §6" + leader.getPlayer().getName() + " §abeigetreten!"); 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"); leader.sendMessage(FightSystem.PREFIX + "§aDer Spieler §6" + player.getName() + " §aist deinem Team beigetreten");
} }
if(Fight.getBlueTeam().getInvited().contains(player)) { }else if(args[0].equalsIgnoreCase("decline") && FightSystem.getPlugin().getFightState() == FightState.SETUP){
FightPlayer leader = Fight.getRedTeam().getLeader(); FightTeam team = Fight.getInvitedTeam(player);
Fight.getRedTeam().addMember(player); if(team != null){
player.sendMessage(FightSystem.PREFIX + "§aDu bist dem Team von §6" + leader.getPlayer().getName() + " §abeigetreten!"); FightPlayer leader = team.getLeader();
leader.sendMessage(FightSystem.PREFIX + "§aDer Spieler §6" + player.getName() + " §aist deinem Team beigetreten"); team.getInvited().remove(player);
}
}
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);
player.sendMessage(FightSystem.PREFIX + "§aDu hast die Einladung von §6" + leader.getPlayer().getName() + " §aabgelehnt!"); 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!"); leader.sendMessage(FightSystem.PREFIX + "§cDer Spieler §6" + player.getName() + " §chat deine Einladung abgelehnt!");
} }
if(Fight.getBlueTeam().getInvited().contains(player)) { }else if(args[0].equalsIgnoreCase("leader")){
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;
}
if(args[0].equalsIgnoreCase("leader")) { if(!Fight.getBlueTeam().hasTeamLeader()){
if(!Fight.getBlueTeam().hasTeamLeader()) {
FightPlayer fightPlayer = new FightPlayer(player, false); FightPlayer fightPlayer = new FightPlayer(player, false);
Fight.getBlueTeam().setLeader(fightPlayer); Fight.getBlueTeam().setLeader(fightPlayer);
player.sendMessage(FightSystem.PREFIX + "§aDu bist nun Leader von " + fileManager.getStringFromConfig("Output.TeamBlueColor") + fileManager.getStringFromConfig("Output.TeamBlueName")); 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); FightPlayer fightPlayer = new FightPlayer(player, false);
Fight.getBlueTeam().setLeader(fightPlayer); Fight.getBlueTeam().setLeader(fightPlayer);
player.sendMessage(FightSystem.PREFIX + "§aDu bist nun Leader von " + fileManager.getStringFromConfig("Output.TeamRedColor") + fileManager.getStringFromConfig("Output.TeamRedName")); player.sendMessage(FightSystem.PREFIX + "§aDu bist nun Leader von " + fileManager.getStringFromConfig("Output.TeamRedColor") + fileManager.getStringFromConfig("Output.TeamRedName"));
return false;
} else } else
player.sendMessage(FightSystem.PREFIX + "§cEs sind bereits zwei Leader vorhanden!"); 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(args[0].equalsIgnoreCase("invite") && FightSystem.getPlugin().getFightState() == FightState.SETUP){
if(FightSystem.getPlugin().getFightState() == FightState.SETUP) {
FightTeam fightTeam = Fight.getPlayerTeam(player); FightTeam fightTeam = Fight.getPlayerTeam(player);
if(fightTeam != null) { if(fightTeam != null) {
FightPlayer fightPlayer = fightTeam.getFightPlayer(player); FightPlayer fightPlayer = fightTeam.getFightPlayer(player);
if(fightPlayer.isLeader()) { if(fightPlayer.isLeader()){
Player target = Bukkit.getPlayer(args[1]); Player target = Bukkit.getPlayer(args[1]);
if(target != null) { if(target != null) {
@ -125,19 +95,15 @@ public class AkCommand implements CommandExecutor {
} else } else
player.sendMessage(FightSystem.PREFIX + "§cDu bist nicht der Leader des Teams!"); 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) { if(FightSystem.getPlugin().getFightState() == FightState.SETUP) {
FightTeam fightTeam = Fight.getPlayerTeam(player); FightTeam fightTeam = Fight.getPlayerTeam(player);
if(fightTeam != null) { if(fightTeam != null) {
Player target = Bukkit.getPlayer(args[1]); Player target = Bukkit.getPlayer(args[1]);
if(target != null) { if(target != null) {
FightPlayer fightPlayer = fightTeam.getFightPlayer(player); FightPlayer fightPlayer = fightTeam.getFightPlayer(player);
if(fightPlayer.isLeader()) { if(fightPlayer.isLeader() && fightTeam.isPlayerInTeam(target)){
if(fightTeam.isPlayerInTeam(target)) {
fightTeam.removePlayer(target); fightTeam.removePlayer(target);
player.sendMessage(FightSystem.PREFIX + "§aDu hast den Spieler §6" + target.getName() + " §aaus dem Team entfernt!"); 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!"); 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; return false;
} }

Datei anzeigen

@ -28,6 +28,15 @@ public class Fight {
return null; 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) { public void broadcast(String message) {
blueTeam.broadcast(message); blueTeam.broadcast(message);
redTeam.broadcast(message); redTeam.broadcast(message);