From 700d01bdac6f60fb371ca5138e5619c23546adb3 Mon Sep 17 00:00:00 2001 From: Yaruma3341 Date: Sun, 14 Apr 2019 13:55:40 +0200 Subject: [PATCH] hotfixes Signed-off-by: Yaruma3341 --- .../fightsystem/commands/AkCommand.java | 9 ++++- .../listener/PlayerJoinListener.java | 13 +++--- .../winconditions/WinconditionTechKO.java | 40 ++++++++++--------- 3 files changed, 35 insertions(+), 27 deletions(-) diff --git a/src/me/yaruma/fightsystem/commands/AkCommand.java b/src/me/yaruma/fightsystem/commands/AkCommand.java index 919004a..ef68961 100644 --- a/src/me/yaruma/fightsystem/commands/AkCommand.java +++ b/src/me/yaruma/fightsystem/commands/AkCommand.java @@ -44,6 +44,11 @@ public class AkCommand implements CommandExecutor { if(team != null){ FightPlayer leader = team.getLeader(); team.addMember(player); + player.setGameMode(GameMode.ADVENTURE); + if(team == Fight.getRedTeam()) + player.teleport(Config.TeamRedSpawn); + else + player.teleport(Config.TeamBlueSpawn); 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"); } @@ -92,7 +97,9 @@ public class AkCommand implements CommandExecutor { Player target = Bukkit.getPlayer(args[1]); if(target != null) { - if(!(Fight.getOpposite(fightTeam).getInvited().contains(target) && fightTeam.getInvited().contains(target))) { + if(Fight.getPlayerTeam(target) != null) { + player.sendMessage(FightSystem.PREFIX + "§cDer Spieler §6" + target.getName() + " §cist bereits in einem Team!"); + } else if(!(Fight.getOpposite(fightTeam).getInvited().contains(target) && fightTeam.getInvited().contains(target))) { fightTeam.getInvited().add(target); target.sendMessage(FightSystem.PREFIX + "§aDu wurdest von §6" + player.getName() + " §ain sein Team eingeladen!"); player.sendMessage(FightSystem.PREFIX + "§aDu hast den Spieler §6" + target.getName() + " §ain dein Team eingeladen!"); diff --git a/src/me/yaruma/fightsystem/listener/PlayerJoinListener.java b/src/me/yaruma/fightsystem/listener/PlayerJoinListener.java index dde3672..09b95d2 100644 --- a/src/me/yaruma/fightsystem/listener/PlayerJoinListener.java +++ b/src/me/yaruma/fightsystem/listener/PlayerJoinListener.java @@ -94,13 +94,12 @@ public class PlayerJoinListener implements Listener { } } - if(Fight.getRedTeam().getLeader().getPlayer() == player - || Fight.getBlueTeam().getLeader().getPlayer() == player - && Fight.getBlueTeam().hasTeamLeader() - && Fight.getRedTeam().hasTeamLeader()) { - Countdown.cancelTimerType(CountdownType.NO_PLAYERS_ONLINE); - Countdown countdown = new Countdown(Config.SetupDuration, new FinishSetupOver()); - countdown.startTimer(instance); + if(Fight.getRedTeam().hasTeamLeader() && Fight.getBlueTeam().hasTeamLeader() && instance.getFightState() == FightState.SETUP) { + if(Fight.getRedTeam().getLeader().getPlayer() == player || Fight.getBlueTeam().getLeader().getPlayer() == player) { + Countdown.cancelTimerType(CountdownType.NO_PLAYERS_ONLINE); + Countdown countdown = new Countdown(Config.SetupDuration, new FinishSetupOver()); + countdown.startTimer(instance); + } } instance.getScoreboard().setAutoScoreboard(20*10, player); diff --git a/src/me/yaruma/fightsystem/winconditions/WinconditionTechKO.java b/src/me/yaruma/fightsystem/winconditions/WinconditionTechKO.java index 7efc60d..f464926 100644 --- a/src/me/yaruma/fightsystem/winconditions/WinconditionTechKO.java +++ b/src/me/yaruma/fightsystem/winconditions/WinconditionTechKO.java @@ -19,6 +19,9 @@ public class WinconditionTechKO { public static void addWater() { if(!Config.TechKO) return; + teamRedWater.clear(); + teamBlueWater.clear(); + int redMinX = Config.TeamRedCornerX; int redMinY = Config.TeamRedCornerY; int redMinZ = Config.TeamRedCornerZ; @@ -33,19 +36,6 @@ public class WinconditionTechKO { int blueMaxY = (blueMinY + Config.SchemsizeY); int blueMaxZ = (blueMinZ + Config.SchemsizeZ); - Bukkit.broadcastMessage(" " + redMinX); - Bukkit.broadcastMessage(" " + redMinY); - Bukkit.broadcastMessage(" " + redMinZ); - Bukkit.broadcastMessage(" " + redMaxX); - Bukkit.broadcastMessage(" " + redMaxY); - Bukkit.broadcastMessage(" " + redMaxZ); - Bukkit.broadcastMessage(" " + blueMinX); - Bukkit.broadcastMessage(" " + blueMinY); - Bukkit.broadcastMessage(" " + blueMinZ); - Bukkit.broadcastMessage(" " + blueMaxX); - Bukkit.broadcastMessage(" " + blueMaxY); - Bukkit.broadcastMessage(" " + blueMaxZ); - //Team Red for(int x = redMinX; x <= redMaxX; x++) { for(int y = redMinY; y <= redMaxY; y++) { @@ -69,8 +59,18 @@ public class WinconditionTechKO { } } } - Bukkit.broadcastMessage("Red: " + teamRedWater.size()); - Bukkit.broadcastMessage("Blue: " + teamBlueWater.size()); + + if(teamRedWater.isEmpty()) { + Bukkit.getScheduler().cancelTask(taskID); + Bukkit.broadcastMessage(FightSystem.PREFIX + "§6Das Team " + Config.TeamRedPrefix + Config.TeamRedName + " §6ist Tech K.O. !"); + FightSystem.getPlugin().setSpectateState(Fight.getBlueTeam()); + } else if(teamBlueWater.isEmpty()) { + Bukkit.getScheduler().cancelTask(taskID); + Bukkit.broadcastMessage(FightSystem.PREFIX + "§6Das Team " + Config.TeamBluePrefix + Config.TeamBlueName + " §6ist Tech K.O. !"); + FightSystem.getPlugin().setSpectateState(Fight.getRedTeam()); + } + Bukkit.broadcastMessage("RedList: " + teamRedWater.size()); + Bukkit.broadcastMessage("BlueList: " + teamBlueWater.size()); } public static void removeWater() { @@ -85,12 +85,13 @@ public class WinconditionTechKO { } } if(teamRedWater.isEmpty()) { - Bukkit.broadcastMessage(FightSystem.PREFIX + "6Das Team " + Config.TeamRedPrefix + Config.TeamRedName + " §6ist Tech K.O. !"); + Bukkit.getScheduler().cancelTask(taskID); + Bukkit.broadcastMessage(FightSystem.PREFIX + "§6Das Team " + Config.TeamRedPrefix + Config.TeamRedName + " §6ist Tech K.O. !"); FightSystem.getPlugin().setSpectateState(Fight.getBlueTeam()); } //Team Blue - Iterator itrBlue = teamRedWater.iterator(); + Iterator itrBlue = teamBlueWater.iterator(); while (itrRed.hasNext()) { Location location = (Location) itrRed.next(); if(location.getBlock().getType() != Material.WATER && location.getBlock().getType() != Material.STATIONARY_WATER) { @@ -99,7 +100,8 @@ public class WinconditionTechKO { } } if(teamBlueWater.isEmpty()) { - Bukkit.broadcastMessage(FightSystem.PREFIX + "6Das Team " + Config.TeamBluePrefix + Config.TeamBlueName + " §6ist Tech K.O. !"); + Bukkit.getScheduler().cancelTask(taskID); + Bukkit.broadcastMessage(FightSystem.PREFIX + "§6Das Team " + Config.TeamBluePrefix + Config.TeamBlueName + " §6ist Tech K.O. !"); FightSystem.getPlugin().setSpectateState(Fight.getRedTeam()); } } @@ -109,7 +111,7 @@ public class WinconditionTechKO { taskID = Bukkit.getScheduler().scheduleAsyncRepeatingTask(FightSystem.getPlugin(), new Runnable() { @Override public void run() { - removeWater(); + addWater(); } }, 0, 20*20); }