SteamWar/FightSystem
Archiviert
13
1

Loading personalKits to player

Signed-off-by: Lixfel <agga-games@gmx.de>
Dieser Commit ist enthalten in:
Lixfel 2020-01-23 17:40:48 +01:00
Ursprung c5c6e8c32b
Commit 0c21251720
2 geänderte Dateien mit 24 neuen und 13 gelöschten Zeilen

Datei anzeigen

@ -138,8 +138,8 @@ public class FightSystem extends JavaPlugin {
setFightState(FightState.PRE_RUNNING); setFightState(FightState.PRE_RUNNING);
PersonalKitCreator.closeAll(); PersonalKitCreator.closeAll();
loadKits(Fight.getBlueTeam()); Fight.getBlueTeam().loadKits();
loadKits(Fight.getRedTeam()); Fight.getRedTeam().loadKits();
setAllPlayersGM(GameMode.SURVIVAL); setAllPlayersGM(GameMode.SURVIVAL);
Bukkit.broadcastMessage(PREFIX + "§aDer Kampf beginnt!"); Bukkit.broadcastMessage(PREFIX + "§aDer Kampf beginnt!");
@ -256,17 +256,6 @@ public class FightSystem extends JavaPlugin {
stateDependent.enable(); 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) { private static void setAllPlayersGM(GameMode gm) {
for(FightPlayer fightPlayer: Fight.getBlueTeam().getPlayers()){ for(FightPlayer fightPlayer: Fight.getBlueTeam().getPlayers()){
Fight.setPlayerGamemode(fightPlayer.getPlayer(), gm); Fight.setPlayerGamemode(fightPlayer.getPlayer(), gm);

Datei anzeigen

@ -13,7 +13,9 @@ import de.steamwar.fightsystem.utils.ItemBuilder;
import de.steamwar.fightsystem.utils.TechHider; import de.steamwar.fightsystem.utils.TechHider;
import de.steamwar.inventory.SWItem; import de.steamwar.inventory.SWItem;
import de.steamwar.sql.NoClipboardException; import de.steamwar.sql.NoClipboardException;
import de.steamwar.sql.PersonalKit;
import de.steamwar.sql.Schematic; import de.steamwar.sql.Schematic;
import de.steamwar.sql.SteamwarUser;
import javafx.util.Pair; import javafx.util.Pair;
import org.bukkit.*; import org.bukkit.*;
import org.bukkit.block.Block; import org.bukkit.block.Block;
@ -24,6 +26,7 @@ import org.bukkit.event.HandlerList;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockPhysicsEvent; import org.bukkit.event.block.BlockPhysicsEvent;
import org.bukkit.inventory.Inventory; import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.PlayerInventory;
import org.bukkit.scoreboard.NameTagVisibility; import org.bukkit.scoreboard.NameTagVisibility;
import org.bukkit.scoreboard.Team; import org.bukkit.scoreboard.Team;
@ -353,6 +356,25 @@ public class FightTeam implements IFightTeam{
return currentHearts / maximumHearts; 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) { void replaceSync(boolean replace, Material target, Material replacement) {
if(!replace) if(!replace)
return; return;