From 42ee422149c5911007ed6339d4b778e3b8423419 Mon Sep 17 00:00:00 2001 From: Yaruma3341 Date: Sun, 14 Apr 2019 12:16:28 +0200 Subject: [PATCH] hotfixes Signed-off-by: Yaruma3341 --- src/me/yaruma/fightsystem/FightSystem.java | 6 ++ .../yaruma/fightsystem/fight/FightTeam.java | 1 + .../fightsystem/fight/WaterRemover.java | 1 + .../winconditions/WinconditionTechKO.java | 97 +++++++++++++------ 4 files changed, 75 insertions(+), 30 deletions(-) diff --git a/src/me/yaruma/fightsystem/FightSystem.java b/src/me/yaruma/fightsystem/FightSystem.java index 78fe143..fe8a2ea 100644 --- a/src/me/yaruma/fightsystem/FightSystem.java +++ b/src/me/yaruma/fightsystem/FightSystem.java @@ -191,6 +191,12 @@ public class FightSystem extends JavaPlugin { Bukkit.getScheduler().cancelTask(WinconditionTechKO.taskID); setAllPlayersGM(GameMode.SPECTATOR); + for(FightPlayer team1 : winFightTeam.getPlayers()) { + team1.getPlayer().getInventory().clear(); + } + for(FightPlayer team2 : Fight.getOpposite(winFightTeam).getPlayers()) { + team2.getPlayer().getInventory().clear(); + } Bukkit.broadcastMessage(" "); if(winFightTeam != null) { diff --git a/src/me/yaruma/fightsystem/fight/FightTeam.java b/src/me/yaruma/fightsystem/fight/FightTeam.java index 5146633..fdee6b0 100644 --- a/src/me/yaruma/fightsystem/fight/FightTeam.java +++ b/src/me/yaruma/fightsystem/fight/FightTeam.java @@ -155,6 +155,7 @@ public class FightTeam { Bukkit.getScheduler().scheduleSyncDelayedTask(FightSystem.getPlugin(), new Runnable() { @Override public void run() { + Bukkit.broadcastMessage("ADD WATER"); WinconditionTechKO.addWater(); } }, 20*10L); diff --git a/src/me/yaruma/fightsystem/fight/WaterRemover.java b/src/me/yaruma/fightsystem/fight/WaterRemover.java index 9aeffef..2df0aaf 100644 --- a/src/me/yaruma/fightsystem/fight/WaterRemover.java +++ b/src/me/yaruma/fightsystem/fight/WaterRemover.java @@ -71,6 +71,7 @@ public class WaterRemover { for (Block block : blocksToRemove) { block.setType(Material.AIR); } + WinconditionTechKO.removeWater(); }); } diff --git a/src/me/yaruma/fightsystem/winconditions/WinconditionTechKO.java b/src/me/yaruma/fightsystem/winconditions/WinconditionTechKO.java index 46dbdab..7efc60d 100644 --- a/src/me/yaruma/fightsystem/winconditions/WinconditionTechKO.java +++ b/src/me/yaruma/fightsystem/winconditions/WinconditionTechKO.java @@ -19,10 +19,37 @@ public class WinconditionTechKO { public static void addWater() { if(!Config.TechKO) return; + int redMinX = Config.TeamRedCornerX; + int redMinY = Config.TeamRedCornerY; + int redMinZ = Config.TeamRedCornerZ; + int redMaxX = (redMinX + Config.SchemsizeX); + int redMaxY = (redMinY+ Config.SchemsizeY); + int redMaxZ = (redMinZ + Config.SchemsizeZ); + + int blueMinX = Config.TeamBlueCornerX; + int blueMinY = Config.TeamBlueCornerY; + int blueMinZ = Config.TeamBlueCornerZ; + int blueMaxX = (blueMinX + Config.SchemsizeX); + 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 = Config.TeamRedCornerX; x <= (x + Config.SchemsizeX); x++) { - for(int y = Config.TeamRedCornerY; y <= (y + Config.SchemsizeY); y++) { - for(int z = Config.TeamRedCornerZ; z <= (y + Config.SchemsizeZ); z++) { + for(int x = redMinX; x <= redMaxX; x++) { + for(int y = redMinY; y <= redMaxY; y++) { + for(int z = redMinZ; z <= redMaxZ; z++) { Location location = new Location(Bukkit.getWorlds().get(0), x, y, z); if(location.getBlock().getType() == Material.WATER || location.getBlock().getType() == Material.STATIONARY_WATER) @@ -32,9 +59,9 @@ public class WinconditionTechKO { } //Team Blue - for(int x = Config.TeamBlueCornerX; x <= (x + Config.SchemsizeX); x++) { - for(int y = Config.TeamBlueCornerY; y <= (y + Config.SchemsizeY); y++) { - for(int z = Config.TeamBlueCornerZ; z <= (y + Config.SchemsizeZ); z++) { + for(int x = blueMinX; x <= blueMaxX; x++) { + for(int y = blueMinY; y <= blueMaxY; y++) { + for(int z = blueMinZ; z <= blueMaxZ; z++) { Location location = new Location(Bukkit.getWorlds().get(0), x, y, z); if(location.getBlock().getType() == Material.WATER || location.getBlock().getType() == Material.STATIONARY_WATER) @@ -42,6 +69,39 @@ public class WinconditionTechKO { } } } + Bukkit.broadcastMessage("Red: " + teamRedWater.size()); + Bukkit.broadcastMessage("Blue: " + teamBlueWater.size()); + } + + public static void removeWater() { + + //Team Red + Iterator itrRed = teamRedWater.iterator(); + while (itrRed.hasNext()) { + Location location = (Location) itrRed.next(); + if(location.getBlock().getType() != Material.WATER && location.getBlock().getType() != Material.STATIONARY_WATER) { + itrRed.remove(); + Bukkit.broadcastMessage("red remove" + teamRedWater.size()); + } + } + if(teamRedWater.isEmpty()) { + 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(); + while (itrRed.hasNext()) { + Location location = (Location) itrRed.next(); + if(location.getBlock().getType() != Material.WATER && location.getBlock().getType() != Material.STATIONARY_WATER) { + itrRed.remove(); + Bukkit.broadcastMessage("blue remove" + teamBlueWater.size()); + } + } + if(teamBlueWater.isEmpty()) { + Bukkit.broadcastMessage(FightSystem.PREFIX + "6Das Team " + Config.TeamBluePrefix + Config.TeamBlueName + " §6ist Tech K.O. !"); + FightSystem.getPlugin().setSpectateState(Fight.getRedTeam()); + } } public static void startAutoChecker() { @@ -49,30 +109,7 @@ public class WinconditionTechKO { taskID = Bukkit.getScheduler().scheduleAsyncRepeatingTask(FightSystem.getPlugin(), new Runnable() { @Override public void run() { - - //Team Red - Iterator itrRed = teamRedWater.iterator(); - while (itrRed.hasNext()) { - Location location = (Location) itrRed.next(); - if(location.getBlock().getType() != Material.WATER && location.getBlock().getType() != Material.STATIONARY_WATER) - itrRed.remove(); - } - if(teamRedWater.isEmpty()) { - 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(); - while (itrRed.hasNext()) { - Location location = (Location) itrRed.next(); - if(location.getBlock().getType() != Material.WATER && location.getBlock().getType() != Material.STATIONARY_WATER) - itrRed.remove(); - } - if(teamBlueWater.isEmpty()) { - Bukkit.broadcastMessage(FightSystem.PREFIX + "6Das Team " + Config.TeamBluePrefix + Config.TeamBlueName + " §6ist Tech K.O. !"); - FightSystem.getPlugin().setSpectateState(Fight.getRedTeam()); - } + removeWater(); } }, 0, 20*20); }