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,136 +19,101 @@ 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;
}
Player player = (Player) sender;
if(args.length == 0) { if(args.length == 1) {
if(args[0].equalsIgnoreCase("help")) {
sendHelp(player); sendHelp(player);
}else if(args[0].equalsIgnoreCase("ready") && FightSystem.getPlugin().getFightState() == FightState.SETUP){
FightTeam fightTeam = Fight.getPlayerTeam(player);
if(fightTeam != null) {
if(!fightTeam.isReady()) {
fightTeam.setReady(true);
fightTeam.broadcast(FightSystem.PREFIX + "§aEuer Team ist nun bereit!");
} else {
fightTeam.setReady(false);
fightTeam.broadcast(FightSystem.PREFIX + "§cEuer Team ist nicht mehr bereit!");
}
}
}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");
}
}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 " + fileManager.getStringFromConfig("Output.TeamBlueColor") + fileManager.getStringFromConfig("Output.TeamBlueName"));
} 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"));
} else
player.sendMessage(FightSystem.PREFIX + "§cEs sind bereits zwei Leader vorhanden!");
} }
if(args.length == 1) { }else if(args.length == 2) {
if(args[0].equalsIgnoreCase("help")) { if(args[0].equalsIgnoreCase("invite") && FightSystem.getPlugin().getFightState() == FightState.SETUP){
sendHelp(player); FightTeam fightTeam = Fight.getPlayerTeam(player);
return false; if(fightTeam != null) {
} FightPlayer fightPlayer = fightTeam.getFightPlayer(player);
if(fightPlayer.isLeader()){
if(args[0].equalsIgnoreCase("ready")) { Player target = Bukkit.getPlayer(args[1]);
if(FightSystem.getPlugin().getFightState() == FightState.SETUP) { if(target != null) {
FightTeam fightTeam = Fight.getPlayerTeam(player); if(!(Fight.getOpposite(fightTeam).getInvited().contains(player) && fightTeam.getInvited().contains(target))) {
if(fightTeam != null) { fightTeam.getInvited().add(target);
if(!fightTeam.isReady()) { player.sendMessage(FightSystem.PREFIX + "§aDu hast den Spieler §6" + target.getName() + " §ain dein Team eingeladen!");
fightTeam.setReady(true);
fightTeam.broadcast(FightSystem.PREFIX + "§aEuer Team ist nun bereit!");
} else {
fightTeam.setReady(false);
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);
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);
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;
}
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 " + fileManager.getStringFromConfig("Output.TeamBlueColor") + fileManager.getStringFromConfig("Output.TeamBlueName"));
return false;
} 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) {
if(args[0].equalsIgnoreCase("invite")) {
if(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.getOpposite(fightTeam).getInvited().contains(player) && fightTeam.getInvited().contains(target))) {
fightTeam.getInvited().add(target);
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 } else
player.sendMessage(FightSystem.PREFIX + "§cDu bist nicht der Leader des Teams!"); player.sendMessage(FightSystem.PREFIX + "§cDieser Spieler wurde bereits eingeladen!");
} } else
} player.sendMessage(FightSystem.PREFIX + "§cDieser Spieler ist nicht online!");
return false; } else
player.sendMessage(FightSystem.PREFIX + "§cDu bist nicht der Leader des Teams!");
} }
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!");
}
}
} }
} }
} }
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);