SteamWar/FightSystem
Archiviert
13
1

added spec hider

Dieser Commit ist enthalten in:
Yaruma3341 2020-01-13 21:37:36 +01:00
Ursprung 320083fb08
Commit eabd9ab50b
4 geänderte Dateien mit 32 neuen und 8 gelöschten Zeilen

Datei anzeigen

@ -266,10 +266,10 @@ public class FightSystem extends JavaPlugin {
private static void setAllPlayersGM(GameMode gm) { private static void setAllPlayersGM(GameMode gm) {
for(FightPlayer fightPlayer: Fight.getBlueTeam().getPlayers()){ for(FightPlayer fightPlayer: Fight.getBlueTeam().getPlayers()){
fightPlayer.getPlayer().setGameMode(gm); Fight.setPlayerGamemode(fightPlayer.getPlayer(), gm);
} }
for(FightPlayer fightPlayer: Fight.getRedTeam().getPlayers()){ for(FightPlayer fightPlayer: Fight.getRedTeam().getPlayers()){
fightPlayer.getPlayer().setGameMode(gm); Fight.setPlayerGamemode(fightPlayer.getPlayer(), gm);
} }
} }

Datei anzeigen

@ -1,7 +1,9 @@
package de.steamwar.fightsystem.fight; package de.steamwar.fightsystem.fight;
import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.FightSystem;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.Sound; import org.bukkit.Sound;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -83,4 +85,26 @@ public class Fight {
Fight.getRedTeam().replaceSync(Config.ReplaceBedrock, Material.BEDROCK, Material.SLIME_BLOCK); Fight.getRedTeam().replaceSync(Config.ReplaceBedrock, Material.BEDROCK, Material.SLIME_BLOCK);
Fight.getBlueTeam().replaceSync(Config.ReplaceBedrock, Material.BEDROCK, Material.SLIME_BLOCK); Fight.getBlueTeam().replaceSync(Config.ReplaceBedrock, Material.BEDROCK, Material.SLIME_BLOCK);
} }
public static void setPlayerGamemode(Player player, GameMode gameMode) {
player.setGameMode(gameMode);
if(gameMode == GameMode.SPECTATOR) {
for(Player currentPlayer : Bukkit.getServer().getOnlinePlayers()) {
if(currentPlayer.getUniqueId() != player.getUniqueId() && currentPlayer.getGameMode() == GameMode.SPECTATOR) {
currentPlayer.hidePlayer(FightSystem.getPlugin(), player);
player.hidePlayer(FightSystem.getPlugin(), currentPlayer);
}
}
}
if(gameMode == GameMode.SURVIVAL) {
for(Player currentPlayer : Bukkit.getServer().getOnlinePlayers()) {
if(currentPlayer.getUniqueId() != player.getUniqueId() && currentPlayer.getGameMode() == GameMode.SPECTATOR) {
currentPlayer.showPlayer(FightSystem.getPlugin(), player);
player.showPlayer(FightSystem.getPlugin(), currentPlayer);
}
}
}
}
} }

Datei anzeigen

@ -147,7 +147,7 @@ public class FightTeam implements IFightTeam{
invited.remove(player); invited.remove(player);
team.addEntry(player.getName()); team.addEntry(player.getName());
player.setGameMode(GameMode.SURVIVAL); Fight.setPlayerGamemode(player, GameMode.SURVIVAL);
player.teleport(spawn); player.teleport(spawn);
if(KitManager.getKits(false).size() > 1) if(KitManager.getKits(false).size() > 1)
player.getInventory().setItem(1, new ItemBuilder(Material.LEATHER_CHESTPLATE).removeAllAttributs().addEnchantment(Enchantment.DURABILITY, 1).setDisplayName("§eKit wählen").build()); player.getInventory().setItem(1, new ItemBuilder(Material.LEATHER_CHESTPLATE).removeAllAttributs().addEnchantment(Enchantment.DURABILITY, 1).setDisplayName("§eKit wählen").build());
@ -167,7 +167,7 @@ public class FightTeam implements IFightTeam{
if(fightPlayer.equals(leader) && FightSystem.getFightState().setup()) if(fightPlayer.equals(leader) && FightSystem.getFightState().setup())
setLeader(null); setLeader(null);
player.setGameMode(GameMode.SPECTATOR); Fight.setPlayerGamemode(player, GameMode.SPECTATOR);
player.teleport(Config.SpecSpawn); player.teleport(Config.SpecSpawn);
TechHider.reloadChunks(player, chunksToReload); TechHider.reloadChunks(player, chunksToReload);
} }

Datei anzeigen

@ -40,14 +40,14 @@ public class PlayerStateListener extends BasicListener{
FightTeam fightTeam = Fight.getPlayerTeam(player); FightTeam fightTeam = Fight.getPlayerTeam(player);
if (fightTeam == null) { if (fightTeam == null) {
player.setGameMode(GameMode.SPECTATOR); Fight.setPlayerGamemode(player, GameMode.SPECTATOR);
player.teleport(Config.SpecSpawn); player.teleport(Config.SpecSpawn);
} else { } else {
player.teleport(fightTeam.getSpawn()); player.teleport(fightTeam.getSpawn());
if(FightSystem.getFightState().setup()) if(FightSystem.getFightState().setup())
player.setGameMode(GameMode.SURVIVAL); Fight.setPlayerGamemode(player, GameMode.SURVIVAL);
else else
player.setGameMode(GameMode.SPECTATOR); Fight.setPlayerGamemode(player, GameMode.SPECTATOR);
} }
} }
@ -63,7 +63,7 @@ public class PlayerStateListener extends BasicListener{
Bukkit.broadcastMessage(FightSystem.PREFIX + "§cDer Spieler " + fightTeam.getPrefix() + player.getName() + " §cist gestorben!"); Bukkit.broadcastMessage(FightSystem.PREFIX + "§cDer Spieler " + fightTeam.getPrefix() + player.getName() + " §cist gestorben!");
event.setDeathMessage(null); event.setDeathMessage(null);
fightTeam.getFightPlayer(player).setOut(); fightTeam.getFightPlayer(player).setOut();
player.setGameMode(GameMode.SPECTATOR); Fight.setPlayerGamemode(player, GameMode.SPECTATOR);
player.teleport(fightTeam.getSpawn()); player.teleport(fightTeam.getSpawn());
Fight.playSound(Countdown.getSound(SWSound.ENTITY_WITHER_DEATH), 100.0F, 1.0F); Fight.playSound(Countdown.getSound(SWSound.ENTITY_WITHER_DEATH), 100.0F, 1.0F);
} }