Merge branch 'AkCommand-Cleanup' into 'master'
AkCommand Cleanup Closes #1 and #2 See merge request Yaruma3341/fightsystem!1
Dieser Commit ist enthalten in:
Commit
15d25dfea9
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,3 +1,3 @@
|
||||
.idea
|
||||
pom.xml
|
||||
WarShipFactory.iml
|
||||
*.iml
|
@ -19,136 +19,101 @@ 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(!(sender instanceof Player)) {
|
||||
return false;
|
||||
}
|
||||
Player player = (Player) sender;
|
||||
|
||||
if(args.length == 0) {
|
||||
if(args.length == 1) {
|
||||
|
||||
if(args[0].equalsIgnoreCase("help")) {
|
||||
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")) {
|
||||
sendHelp(player);
|
||||
return false;
|
||||
}
|
||||
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(args[0].equalsIgnoreCase("ready")) {
|
||||
if(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!");
|
||||
}
|
||||
}
|
||||
}
|
||||
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!");
|
||||
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 + "§cDu bist nicht der Leader des Teams!");
|
||||
}
|
||||
}
|
||||
return false;
|
||||
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!");
|
||||
}
|
||||
|
||||
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)) {
|
||||
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!");
|
||||
}
|
||||
}
|
||||
}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 + "§4Du wurdest auf deinem Team entfernt!");
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}else{
|
||||
sendHelp(player);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -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);
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren