diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/fight/Fight.java b/FightSystem_Core/src/de/steamwar/fightsystem/fight/Fight.java index 4033521..c2e2965 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/fight/Fight.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/fight/Fight.java @@ -30,7 +30,6 @@ import de.steamwar.fightsystem.ArenaMode; import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.FightSystem; import de.steamwar.fightsystem.record.GlobalRecorder; -import de.steamwar.sql.Schematic; import org.bukkit.Bukkit; import org.bukkit.GameMode; import org.bukkit.Sound; @@ -159,22 +158,6 @@ public class Fight { return 1000; } - if(Config.RanksEnabled) - return Math.min(schemRank(redTeam.getLeader()), schemRank(blueTeam.getLeader())); - else if(Schematic.getSchemsOfType(redTeam.getLeader().getPlayer().getUniqueId(), Config.SchematicType).isEmpty() || - Schematic.getSchemsOfType(blueTeam.getLeader().getPlayer().getUniqueId(), Config.SchematicType).isEmpty()) - return 0; - else - return 1; - } - - private static int schemRank(FightPlayer fightPlayer){ - int rank = 1; - List schematics = Schematic.getSchemsOfType(fightPlayer.getPlayer().getUniqueId(), Config.SchematicType); - for(Schematic schem : schematics){ - if(schem.getRank() > rank) - rank = schem.getRank(); - } - return rank; + return Math.min(redTeam.getSchemRank(), blueTeam.getSchemRank()); } } diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/fight/FightTeam.java b/FightSystem_Core/src/de/steamwar/fightsystem/fight/FightTeam.java index 0f80fe0..be1f4b5 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/fight/FightTeam.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/fight/FightTeam.java @@ -48,6 +48,8 @@ public class FightTeam { private UUID designatedLeader; private FightPlayer leader; + private int schemRank; + private final Map players = new HashMap<>(); private final Set invited = new HashSet<>(); @@ -69,6 +71,7 @@ public class FightTeam { this.spawn = spawn; this.schemRegion = schemRegion; this.extendRegion = extendRegion; + this.schemRank = 0; this.ready = false; this.skip = false; this.blue = blue; @@ -112,6 +115,10 @@ public class FightTeam { return isLeaderless() && (designatedLeader == null || designatedLeader.equals(p.getUniqueId())); } + public int getSchemRank() { + return schemRank; + } + public void teleportToSpawn(){ players.forEach((player, fp) -> player.teleport(spawn)); } @@ -258,6 +265,12 @@ public class FightTeam { if(ready) setReady(false); + Optional maxRank = Schematic.getSchemsOfType(leader.getPlayer().getUniqueId(), Config.SchematicType).stream().map(Schematic::getRank).max(Integer::compare); + if(Config.RanksEnabled) + schemRank = maxRank.orElse(1); + else + schemRank = maxRank.isPresent() ? 1 : 0; + if(!Config.PersonalKits) leader.setKit(Kit.getKitByName(Config.LeaderDefault));