diff --git a/src/de/steamwar/fightsystem/fight/Fight.java b/src/de/steamwar/fightsystem/fight/Fight.java index 2235632..8a69838 100644 --- a/src/de/steamwar/fightsystem/fight/Fight.java +++ b/src/de/steamwar/fightsystem/fight/Fight.java @@ -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)) diff --git a/src/de/steamwar/fightsystem/fight/FightTeam.java b/src/de/steamwar/fightsystem/fight/FightTeam.java index 2db69a8..f970e33 100644 --- a/src/de/steamwar/fightsystem/fight/FightTeam.java +++ b/src/de/steamwar/fightsystem/fight/FightTeam.java @@ -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 CONCRETE_POWDER_SET = Collections.singleton(CONCRETE_POWDER); private FightPlayer leader; + private final UUID designatedLeader; private final Set players = new HashSet<>(); private boolean ready; private final Set 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); diff --git a/src/de/steamwar/fightsystem/listener/NormalJoinListener.java b/src/de/steamwar/fightsystem/listener/NormalJoinListener.java index bb5480e..f1739c3 100644 --- a/src/de/steamwar/fightsystem/listener/NormalJoinListener.java +++ b/src/de/steamwar/fightsystem/listener/NormalJoinListener.java @@ -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)); } } diff --git a/src/de/steamwar/fightsystem/utils/Config.java b/src/de/steamwar/fightsystem/utils/Config.java index 00cf9b2..9b136e9 100644 --- a/src/de/steamwar/fightsystem/utils/Config.java +++ b/src/de/steamwar/fightsystem/utils/Config.java @@ -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(){ diff --git a/src/de/steamwar/fightsystem/utils/WaterRemover.java b/src/de/steamwar/fightsystem/utils/WaterRemover.java index dd72072..2704071 100644 --- a/src/de/steamwar/fightsystem/utils/WaterRemover.java +++ b/src/de/steamwar/fightsystem/utils/WaterRemover.java @@ -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(); }