diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/FightSystem.java b/FightSystem_Main/src/de/steamwar/fightsystem/FightSystem.java index 999292d..7f1c098 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/FightSystem.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/FightSystem.java @@ -138,8 +138,8 @@ public class FightSystem extends JavaPlugin { setFightState(FightState.PRE_RUNNING); PersonalKitCreator.closeAll(); - loadKits(Fight.getBlueTeam()); - loadKits(Fight.getRedTeam()); + Fight.getBlueTeam().loadKits(); + Fight.getRedTeam().loadKits(); setAllPlayersGM(GameMode.SURVIVAL); Bukkit.broadcastMessage(PREFIX + "§aDer Kampf beginnt!"); @@ -256,17 +256,6 @@ public class FightSystem extends JavaPlugin { stateDependent.enable(); } - private static void loadKits(FightTeam team){ - for(FightPlayer allFightPlayers : team.getPlayers()) { - if(allFightPlayers.getPlayer() == null) - continue; - allFightPlayers.getPlayer().getInventory().clear(); - if(allFightPlayers.getKit() == null) - continue; - allFightPlayers.getKit().loadToPlayer(allFightPlayers.getPlayer()); - } - } - private static void setAllPlayersGM(GameMode gm) { for(FightPlayer fightPlayer: Fight.getBlueTeam().getPlayers()){ Fight.setPlayerGamemode(fightPlayer.getPlayer(), gm); diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/fight/FightTeam.java b/FightSystem_Main/src/de/steamwar/fightsystem/fight/FightTeam.java index 783a53b..a21c46d 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/fight/FightTeam.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/fight/FightTeam.java @@ -13,7 +13,9 @@ import de.steamwar.fightsystem.utils.ItemBuilder; import de.steamwar.fightsystem.utils.TechHider; import de.steamwar.inventory.SWItem; import de.steamwar.sql.NoClipboardException; +import de.steamwar.sql.PersonalKit; import de.steamwar.sql.Schematic; +import de.steamwar.sql.SteamwarUser; import javafx.util.Pair; import org.bukkit.*; import org.bukkit.block.Block; @@ -24,6 +26,7 @@ import org.bukkit.event.HandlerList; import org.bukkit.event.Listener; import org.bukkit.event.block.BlockPhysicsEvent; import org.bukkit.inventory.Inventory; +import org.bukkit.inventory.PlayerInventory; import org.bukkit.scoreboard.NameTagVisibility; import org.bukkit.scoreboard.Team; @@ -353,6 +356,25 @@ public class FightTeam implements IFightTeam{ return currentHearts / maximumHearts; } + public void loadKits(){ + for(FightPlayer fightPlayer : players) { + if(fightPlayer.getPlayer() == null) + continue; + fightPlayer.getPlayer().getInventory().clear(); + + PersonalKit personalKit = null; + if(Config.PersonalKits) + personalKit = PersonalKit.get(SteamwarUser.get(fightPlayer.getPlayer().getUniqueId()).getId(), Config.SchematicType.toDB()); + + if(personalKit != null){ + PlayerInventory inventory = fightPlayer.getPlayer().getInventory(); + inventory.setContents(personalKit.getInventory()); + inventory.setArmorContents(personalKit.getArmor()); + }else if(fightPlayer.getKit() != null) + fightPlayer.getKit().loadToPlayer(fightPlayer.getPlayer()); + } + } + void replaceSync(boolean replace, Material target, Material replacement) { if(!replace) return;