SteamWar/FightSystem
Archiviert
13
1

Preparation for lag-save join order

Dieser Commit ist enthalten in:
Lixfel 2019-10-29 19:49:11 +01:00
Ursprung a3331788d4
Commit c00e276fea
5 geänderte Dateien mit 24 neuen und 10 gelöschten Zeilen

Datei anzeigen

@ -9,8 +9,8 @@ public class Fight {
private Fight(){}
public static final FightTeam redTeam = new FightTeam(Config.TeamRedName, Config.TeamRedPrefix, Config.TeamRedSpawn, Config.TeamRedPaste, Config.TeamRedCorner, Config.TeamRedRotate, false);
public static final FightTeam blueTeam = new FightTeam(Config.TeamBlueName, Config.TeamBluePrefix, Config.TeamBlueSpawn, Config.TeamBluePaste, Config.TeamBlueCorner, Config.TeamBlueRotate, true);
public static final FightTeam redTeam = new FightTeam(Config.TeamRedName, Config.TeamRedPrefix, Config.TeamRedSpawn, Config.TeamRedPaste, Config.TeamRedCorner, Config.TeamRedRotate, false, Config.RedLeader);
public static final FightTeam blueTeam = new FightTeam(Config.TeamBlueName, Config.TeamBluePrefix, Config.TeamBlueSpawn, Config.TeamBluePaste, Config.TeamBlueCorner, Config.TeamBlueRotate, true, Config.BlueLeader);
public static FightTeam getPlayerTeam(Player player) {
if(redTeam.isPlayerInTeam(player))

Datei anzeigen

@ -23,10 +23,7 @@ import org.bukkit.scoreboard.Team;
import java.io.File;
import java.io.IOException;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.*;
import java.util.logging.Level;
@ -56,6 +53,7 @@ public class FightTeam {
private static final Set<BaseBlock> CONCRETE_POWDER_SET = Collections.singleton(CONCRETE_POWDER);
private FightPlayer leader;
private final UUID designatedLeader;
private final Set<FightPlayer> players = new HashSet<>();
private boolean ready;
private final Set<Player> invited = new HashSet<>();
@ -71,7 +69,7 @@ public class FightTeam {
private final Vector corner;
private final boolean rotate;
public FightTeam(String name, String prefix, Location spawn, Vector paste, Vector corner, boolean rotate, boolean blue) {
public FightTeam(String name, String prefix, Location spawn, Vector paste, Vector corner, boolean rotate, boolean blue, UUID designatedLeader) {
this.spawn = spawn;
this.paste = paste;
this.name = name;
@ -80,6 +78,7 @@ public class FightTeam {
this.rotate = rotate;
this.corner = corner;
this.blue = blue;
this.designatedLeader = designatedLeader;
color = ChatColor.getByChar(ChatColor.getLastColors(prefix).replace("§", ""));
if(FightScoreboard.getScoreboard().getTeam(name) == null)
team = FightScoreboard.getScoreboard().registerNewTeam(name);
@ -90,6 +89,10 @@ public class FightTeam {
team.setOption(Team.Option.NAME_TAG_VISIBILITY, Team.OptionStatus.FOR_OWN_TEAM);
}
public boolean canbeLeader(Player p){
return !hasTeamLeader() && (designatedLeader == null || designatedLeader.equals(p.getUniqueId()));
}
public void teleportToSpawn(){
for(FightPlayer player : players){
player.getPlayer().teleport(spawn);

Datei anzeigen

@ -18,9 +18,9 @@ public class NormalJoinListener extends BasicListener {
FightTeam fightTeam = Fight.getPlayerTeam(player);
if (fightTeam == null) {
if(!Fight.getRedTeam().hasTeamLeader()) {
if(Fight.getRedTeam().canbeLeader(player)) {
Fight.getRedTeam().setLeader(Fight.getRedTeam().addMember(player));
} else if(!Fight.getBlueTeam().hasTeamLeader()) {
} else if(Fight.getBlueTeam().canbeLeader(player)) {
Fight.getBlueTeam().setLeader(Fight.getBlueTeam().addMember(player));
}
}

Datei anzeigen

@ -14,6 +14,7 @@ import org.bukkit.configuration.file.YamlConfiguration;
import java.io.File;
import java.util.List;
import java.util.UUID;
import java.util.logging.Level;
public class Config {
@ -102,6 +103,9 @@ public class Config {
public static int EventTeamRedID;
public static int MaximumTeamMembers = Integer.MAX_VALUE;
public static UUID BlueLeader;
public static UUID RedLeader;
public static void load(){
if(!new File(Bukkit.getWorldContainer().getPath() + '/' + Bukkit.getWorlds().get(0).getName() + "/config.yml").exists()) {
FightSystem.getPlugin().saveDefaultConfig();
@ -268,6 +272,13 @@ public class Config {
MaximumTeamMembers = event.getMaximumTeamMembers();
OnlyPublicSchematics = event.publicSchemsOnly();
}
String blueLeader = System.getProperty("blueLeader", null);
String redLeader = System.getProperty("redLeader", null);
if(blueLeader != null)
BlueLeader = UUID.fromString(blueLeader);
if(redLeader != null)
RedLeader = UUID.fromString(redLeader);
}
public static boolean event(){

Datei anzeigen

@ -57,7 +57,7 @@ public class WaterRemover {
while(it.hasNext()){
Block b = it.next();
blocksToRemove.addAll(getSourceBlocksOfWater(b));
if (b.getType() != Material.STATIONARY_WATER)
if (b.getType() != Material.STATIONARY_WATER && b.getType() != Material.WATER)
it.remove();
}