SteamWar/FightSystem
Archiviert
13
1

Allowing only public schematics if one leader has no private #98

Zusammengeführt
Lixfel hat 1 Commits von schematiclessPublicOnly nach master 2020-01-18 14:43:44 +01:00 zusammengeführt
3 geänderte Dateien mit 20 neuen und 3 gelöschten Zeilen

Datei anzeigen

@ -108,6 +108,7 @@ public class FightSystem extends JavaPlugin {
throw new SecurityException(fightState.name()); throw new SecurityException(fightState.name());
setFightState(FightState.PRE_SCHEM_SETUP); setFightState(FightState.PRE_SCHEM_SETUP);
Fight.calcAvailibleSchemTypes();
mainCountdown = new PreSchemPasteCountdown(); mainCountdown = new PreSchemPasteCountdown();
} }

Datei anzeigen

@ -7,6 +7,7 @@ import de.steamwar.fightsystem.fight.FightTeam;
import de.steamwar.fightsystem.kit.Kit; import de.steamwar.fightsystem.kit.Kit;
import de.steamwar.fightsystem.kit.KitManager; import de.steamwar.fightsystem.kit.KitManager;
import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.inventory.SWInventory; import de.steamwar.inventory.SWInventory;
import de.steamwar.inventory.SWItem; import de.steamwar.inventory.SWItem;
import de.steamwar.inventory.SWListInv; import de.steamwar.inventory.SWListInv;
@ -75,6 +76,7 @@ public class GUI {
FightPlayer fightPlayer = Fight.getFightPlayer(p); FightPlayer fightPlayer = Fight.getFightPlayer(p);
if(fightPlayer == null) if(fightPlayer == null)
return; return;
List<Pair<SWItem, Kit>> iconList = new ArrayList<>(); List<Pair<SWItem, Kit>> iconList = new ArrayList<>();
List<Kit> kitList = KitManager.getKits(fightPlayer.isLeader()); List<Kit> kitList = KitManager.getKits(fightPlayer.isLeader());
@ -88,9 +90,14 @@ public class GUI {
} }
public static void preSchemDialog(Player p){ public static void preSchemDialog(Player p){
if(!Config.test() && FightSystem.getFightState() != FightState.PRE_SCHEM_SETUP){
p.sendMessage(FightSystem.PREFIX + "§cDu kannst ohne Gegner keine Schematic wählen");
return;
}
SWInventory inv = new SWInventory(p, 9, Config.GameName + "-Auswahl"); SWInventory inv = new SWInventory(p, 9, Config.GameName + "-Auswahl");
inv.setItem(8, Material.REDSTONE, "§eÖffentliches " + Config.GameName, (ClickType click) -> schemDialog(p, true)); inv.setItem(8, Material.REDSTONE, "§eÖffentliches " + Config.GameName, (ClickType click) -> schemDialog(p, true));
if(Config.OnlyPublicSchematics){ if(Config.OnlyPublicSchematics || Fight.onlyPublicSchems()){
inv.setItem(0, SWItem.getDye(8), (byte)8, "§7Keine privaten Schematics erlaubt", (ClickType click)->{}); 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()){ }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)->{}); inv.setItem(0, SWItem.getDye(8), (byte)8, "§7Kein privates " + Config.GameName + " vorhanden", (ClickType click)->{});

Datei anzeigen

@ -1,8 +1,7 @@
package de.steamwar.fightsystem.fight; package de.steamwar.fightsystem.fight;
import de.steamwar.core.Core;
import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.FightSystem; import de.steamwar.sql.Schematic;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.GameMode; import org.bukkit.GameMode;
import org.bukkit.Material; import org.bukkit.Material;
@ -14,6 +13,7 @@ public class 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 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); 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;
public static void init(){ public static void init(){
IFight.init(redTeam, blueTeam); IFight.init(redTeam, blueTeam);
@ -108,4 +108,13 @@ public class Fight {
} }
} }
} }
public static boolean onlyPublicSchems() {
return onlyPublicSchems;
}
public static void calcAvailibleSchemTypes() {
onlyPublicSchems = (Schematic.getSchemsOfType(redTeam.getLeader().getPlayer().getUniqueId(), Config.SchematicType).isEmpty() ||
Schematic.getSchemsOfType(blueTeam.getLeader().getPlayer().getUniqueId(), Config.SchematicType).isEmpty());
}
} }