Fix laggy schemselect
Signed-off-by: Lixfel <agga-games@gmx.de>
Dieser Commit ist enthalten in:
Ursprung
05d121fe63
Commit
194adf8970
@ -30,7 +30,6 @@ import de.steamwar.fightsystem.ArenaMode;
|
|||||||
import de.steamwar.fightsystem.Config;
|
import de.steamwar.fightsystem.Config;
|
||||||
import de.steamwar.fightsystem.FightSystem;
|
import de.steamwar.fightsystem.FightSystem;
|
||||||
import de.steamwar.fightsystem.record.GlobalRecorder;
|
import de.steamwar.fightsystem.record.GlobalRecorder;
|
||||||
import de.steamwar.sql.Schematic;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
@ -159,22 +158,6 @@ public class Fight {
|
|||||||
return 1000;
|
return 1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(Config.RanksEnabled)
|
return Math.min(redTeam.getSchemRank(), blueTeam.getSchemRank());
|
||||||
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<Schematic> schematics = Schematic.getSchemsOfType(fightPlayer.getPlayer().getUniqueId(), Config.SchematicType);
|
|
||||||
for(Schematic schem : schematics){
|
|
||||||
if(schem.getRank() > rank)
|
|
||||||
rank = schem.getRank();
|
|
||||||
}
|
|
||||||
return rank;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -48,6 +48,8 @@ public class FightTeam {
|
|||||||
|
|
||||||
private UUID designatedLeader;
|
private UUID designatedLeader;
|
||||||
private FightPlayer leader;
|
private FightPlayer leader;
|
||||||
|
private int schemRank;
|
||||||
|
|
||||||
private final Map<Player, FightPlayer> players = new HashMap<>();
|
private final Map<Player, FightPlayer> players = new HashMap<>();
|
||||||
private final Set<Player> invited = new HashSet<>();
|
private final Set<Player> invited = new HashSet<>();
|
||||||
|
|
||||||
@ -69,6 +71,7 @@ public class FightTeam {
|
|||||||
this.spawn = spawn;
|
this.spawn = spawn;
|
||||||
this.schemRegion = schemRegion;
|
this.schemRegion = schemRegion;
|
||||||
this.extendRegion = extendRegion;
|
this.extendRegion = extendRegion;
|
||||||
|
this.schemRank = 0;
|
||||||
this.ready = false;
|
this.ready = false;
|
||||||
this.skip = false;
|
this.skip = false;
|
||||||
this.blue = blue;
|
this.blue = blue;
|
||||||
@ -112,6 +115,10 @@ public class FightTeam {
|
|||||||
return isLeaderless() && (designatedLeader == null || designatedLeader.equals(p.getUniqueId()));
|
return isLeaderless() && (designatedLeader == null || designatedLeader.equals(p.getUniqueId()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getSchemRank() {
|
||||||
|
return schemRank;
|
||||||
|
}
|
||||||
|
|
||||||
public void teleportToSpawn(){
|
public void teleportToSpawn(){
|
||||||
players.forEach((player, fp) -> player.teleport(spawn));
|
players.forEach((player, fp) -> player.teleport(spawn));
|
||||||
}
|
}
|
||||||
@ -258,6 +265,12 @@ public class FightTeam {
|
|||||||
if(ready)
|
if(ready)
|
||||||
setReady(false);
|
setReady(false);
|
||||||
|
|
||||||
|
Optional<Integer> 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)
|
if(!Config.PersonalKits)
|
||||||
leader.setKit(Kit.getKitByName(Config.LeaderDefault));
|
leader.setKit(Kit.getKitByName(Config.LeaderDefault));
|
||||||
|
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren