diff --git a/FightSystem_API/src/de/steamwar/fightsystem/Config.java b/FightSystem_API/src/de/steamwar/fightsystem/Config.java index e08fea0..6bc2361 100644 --- a/FightSystem_API/src/de/steamwar/fightsystem/Config.java +++ b/FightSystem_API/src/de/steamwar/fightsystem/Config.java @@ -62,6 +62,7 @@ public class Config { public static final boolean GroundWalkable; //schematic parameter + public static final boolean RanksEnabled; public static final boolean OnlyPublicSchematics; public static final boolean IgnorePublicOnly; public static final de.steamwar.sql.SchematicType SchematicType; @@ -162,6 +163,7 @@ public class Config { double teamBlueSpawnOffsetY = worldconfig.getDouble("Arena.SpawnOffset.y"); double teamBlueSpawnOffsetZ = worldconfig.getDouble("Arena.SpawnOffset.z"); + RanksEnabled = config.getBoolean("Schematic.RanksEnabled"); SchematicType = de.steamwar.sql.SchematicType.fromDB(config.getString("Schematic.SchematicType")); IgnorePublicOnly = config.getBoolean("Schematic.IgnorePublicOnly"); boolean rotate = config.getBoolean("Schematic.Rotate"); diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/commands/GUI.java b/FightSystem_Main/src/de/steamwar/fightsystem/commands/GUI.java index 5f2f32a..f4e4cc9 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/commands/GUI.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/commands/GUI.java @@ -102,7 +102,7 @@ public class GUI { SWInventory inv = new SWInventory(p, 9, Config.GameName + "-Auswahl"); inv.setItem(8, Material.REDSTONE, "§eÖffentliches " + Config.GameName, (ClickType click) -> schemDialog(p, true)); - if(Config.OnlyPublicSchematics || Fight.onlyPublicSchems()){ + if(Fight.getMaxRank() == 0){ inv.setItem(0, SWItem.getDye(8), (byte)8, "§7Keine privaten Schematics erlaubt", (ClickType click)->{}); }else if(Schematic.getSchemsOfType(p.getUniqueId(), Config.SchematicType).isEmpty() && !Config.test()){ inv.setItem(0, SWItem.getDye(8), (byte)8, "§7Kein privates " + Config.GameName + " vorhanden", (ClickType click)->{}); @@ -119,8 +119,10 @@ public class GUI { schems = SWListInv.getSchemList(Config.SchematicType, 0); else if(Config.test()) schems = SWListInv.getSchemList(null, SteamwarUser.get(p.getUniqueId()).getId()); - else + else{ schems = SWListInv.getSchemList(Config.SchematicType, SteamwarUser.get(p.getUniqueId()).getId()); + schems.removeIf(schem -> schem.getObject().getRank() > Fight.getMaxRank()); + } SWListInv inv = new SWListInv<>(p, Config.GameName + "-Auswahl", schems, (ClickType click, Schematic s) -> { FightTeam fightTeam = Fight.getPlayerTeam(p); diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/fight/Fight.java b/FightSystem_Main/src/de/steamwar/fightsystem/fight/Fight.java index df8fe27..9053ae2 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/fight/Fight.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/fight/Fight.java @@ -8,12 +8,14 @@ import org.bukkit.Material; import org.bukkit.Sound; import org.bukkit.entity.Player; +import java.util.List; + public class Fight { private Fight(){} public static final FightTeam redTeam = new FightTeam(Config.TeamRedName, Config.TeamRedPrefix, Config.TeamRedSpawn, Config.TeamRedCornerX, Config.TeamRedCornerY, Config.TeamRedCornerZ, Config.TeamRedRotate, false, Config.RedLeader); public static final FightTeam blueTeam = new FightTeam(Config.TeamBlueName, Config.TeamBluePrefix, Config.TeamBlueSpawn, Config.TeamBlueCornerX, Config.TeamBlueCornerY, Config.TeamBlueCornerZ, Config.TeamBlueRotate, true, Config.BlueLeader); - private static boolean onlyPublicSchems; + private static int schemRank; public static void init(){ IFight.init(redTeam, blueTeam); @@ -109,33 +111,44 @@ public class Fight { } } - public static boolean onlyPublicSchems() { - return onlyPublicSchems; + public static int getMaxRank(){ + /* MaxRank of 0 is Pubonly*/ + return schemRank; } public static void calcAvailibleSchemTypes() { - if(Config.IgnorePublicOnly){ - onlyPublicSchems = false; - return; - } - if(Config.OnlyPublicSchematics){ - onlyPublicSchems = true; + schemRank = 0; return; } - if(Config.event()){ - onlyPublicSchems = false; + if(Config.IgnorePublicOnly || Config.event()){ + schemRank = 1000; return; } if(redTeam.getLeader() == null || redTeam.getLeader().getPlayer() == null || blueTeam.getLeader() == null || blueTeam.getLeader().getPlayer() == null){ - onlyPublicSchems = false; + schemRank = 1000; return; } - onlyPublicSchems = (Schematic.getSchemsOfType(redTeam.getLeader().getPlayer().getUniqueId(), Config.SchematicType).isEmpty() || - Schematic.getSchemsOfType(blueTeam.getLeader().getPlayer().getUniqueId(), Config.SchematicType).isEmpty()); + if(Config.RanksEnabled) + schemRank = 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()) + schemRank = 0; + else + schemRank = 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; } }