From 737f8f6ebd6ce7b5d6f35d622c09b92f3b57f864 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Wed, 23 Feb 2022 10:02:13 +0100 Subject: [PATCH] Add initial setup for ranked rework --- .../src/de/steamwar/fightsystem/Config.java | 15 +++++++++++++++ .../src/de/steamwar/fightsystem/fight/Fight.java | 4 ++-- .../de/steamwar/fightsystem/fight/FightTeam.java | 7 +++++-- .../steamwar/fightsystem/listener/NormalJoin.java | 5 +++++ .../steamwar/fightsystem/listener/RankedJoin.java | 5 +++++ 5 files changed, 32 insertions(+), 4 deletions(-) diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/Config.java b/FightSystem_Core/src/de/steamwar/fightsystem/Config.java index 1292a70..673e37d 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/Config.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/Config.java @@ -92,6 +92,8 @@ public class Config { public static final UUID BlueLeader; public static final UUID RedLeader; public static final boolean Ranked; + public static final List BlueTeam; + public static final List RedTeam; //Active win conditions public static final Set ActiveWinconditions; @@ -371,6 +373,19 @@ public class Config { Ranked = Boolean.parseBoolean(System.getProperty("ranked", "false")); ReplayID = Integer.parseInt(System.getProperty("replay", "0")); + String blueTeam = System.getProperty("blueTeam", null); + String redTeam = System.getProperty("redTeam", null); + if (blueTeam != null) { + BlueTeam = Arrays.stream(blueTeam.split(",")).map(UUID::fromString).collect(Collectors.toList()); + } else { + BlueTeam = new ArrayList<>(0); + } + if (redTeam != null) { + RedTeam = Arrays.stream(redTeam.split(",")).map(UUID::fromString).collect(Collectors.toList()); + } else { + RedTeam = new ArrayList<>(0); + } + if(Ranked){ mode = ArenaMode.RANKED; }else if(CheckSchemID != 0){ diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/fight/Fight.java b/FightSystem_Core/src/de/steamwar/fightsystem/fight/Fight.java index 431cbc6..cb1a528 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/fight/Fight.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/fight/Fight.java @@ -39,8 +39,8 @@ import java.util.List; public class Fight { private Fight(){} - private static final FightTeam redTeam = new FightTeam(Config.TeamRedName, Config.TeamRedColor, Config.TeamRedSpawn, Config.RedPasteRegion, Config.RedExtendRegion, Config.RedRotate, false, Config.RedLeader); - private static final FightTeam blueTeam = new FightTeam(Config.TeamBlueName, Config.TeamBlueColor, Config.TeamBlueSpawn, Config.BluePasteRegion, Config.BlueExtendRegion, Config.BlueRotate, true, Config.BlueLeader); + private static final FightTeam redTeam = new FightTeam(Config.TeamRedName, Config.TeamRedColor, Config.TeamRedSpawn, Config.RedPasteRegion, Config.RedExtendRegion, Config.RedRotate, false, Config.RedLeader, Config.RedTeam); + private static final FightTeam blueTeam = new FightTeam(Config.TeamBlueName, Config.TeamBlueColor, Config.TeamBlueSpawn, Config.BluePasteRegion, Config.BlueExtendRegion, Config.BlueRotate, true, Config.BlueLeader, Config.BlueTeam); public static FightTeam getPlayerTeam(Player player) { if(redTeam.isPlayerInTeam(player)) diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/fight/FightTeam.java b/FightSystem_Core/src/de/steamwar/fightsystem/fight/FightTeam.java index d1e888f..13868d0 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/fight/FightTeam.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/fight/FightTeam.java @@ -48,6 +48,7 @@ import java.util.*; public class FightTeam { private UUID designatedLeader; + private List designatedMembers; private FightPlayer leader; private int schemRank; @@ -69,7 +70,7 @@ public class FightTeam { private final Region extendRegion; @SuppressWarnings("deprecation") - public FightTeam(String name, String prefix, Location spawn, Region schemRegion, Region extendRegion, boolean rotate, boolean blue, UUID designatedLeader) { + public FightTeam(String name, String prefix, Location spawn, Region schemRegion, Region extendRegion, boolean rotate, boolean blue, UUID designatedLeader, List designatedMembers) { this.spawn = spawn; this.schemRegion = schemRegion; this.extendRegion = extendRegion; @@ -78,6 +79,7 @@ public class FightTeam { this.skip = false; this.blue = blue; this.designatedLeader = designatedLeader; + this.designatedMembers = designatedMembers; setPrefixAndName(prefix, name); this.schematic = new FightSchematic(this, rotate); new KitLoader(); @@ -221,7 +223,7 @@ public class FightTeam { GlobalRecorder.getInstance().playerJoins(player); TechHider.reloadChunks(player, chunksToReload, false); - if(isLeaderless()) + if(isLeaderless() && canbeLeader(player)) setLeader(fightPlayer, silent); else if(!silent) FightUI.addSubtitle("UI_PLAYER_JOINS", prefix, player.getName()); @@ -276,6 +278,7 @@ public class FightTeam { this.leader = leader; designatedLeader = null; + designatedMembers = null; if(ready) setReady(false); diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/listener/NormalJoin.java b/FightSystem_Core/src/de/steamwar/fightsystem/listener/NormalJoin.java index c8c08c4..9a592f8 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/listener/NormalJoin.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/listener/NormalJoin.java @@ -47,6 +47,11 @@ public class NormalJoin implements Listener { }else if(Fight.getRedTeam().canbeLeader(player)) { Fight.getRedTeam().addMember(player); } + if (Config.RedTeam.contains(player.getUniqueId())) { + Fight.getBlueTeam().addMember(player, true); + } else if (Config.BlueTeam.contains(player.getUniqueId())) { + Fight.getRedTeam().addMember(player, true); + } } } } diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/listener/RankedJoin.java b/FightSystem_Core/src/de/steamwar/fightsystem/listener/RankedJoin.java index 49ec963..23f49ad 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/listener/RankedJoin.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/listener/RankedJoin.java @@ -47,6 +47,11 @@ public class RankedJoin implements Listener { }else if(Fight.getRedTeam().canbeLeader(player)) { Fight.getRedTeam().addMember(player); } + if (Config.RedTeam.contains(player.getUniqueId())) { + Fight.getBlueTeam().addMember(player, true); + } else if (Config.BlueTeam.contains(player.getUniqueId())) { + Fight.getRedTeam().addMember(player, true); + } } } }