From eabd9ab50bec5ae464c02a98f3f26e251c7622b1 Mon Sep 17 00:00:00 2001 From: Yaruma3341 Date: Mon, 13 Jan 2020 21:37:36 +0100 Subject: [PATCH 1/3] added spec hider --- .../de/steamwar/fightsystem/FightSystem.java | 4 ++-- .../de/steamwar/fightsystem/fight/Fight.java | 24 +++++++++++++++++++ .../steamwar/fightsystem/fight/FightTeam.java | 4 ++-- .../listener/PlayerStateListener.java | 8 +++---- 4 files changed, 32 insertions(+), 8 deletions(-) diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/FightSystem.java b/FightSystem_Main/src/de/steamwar/fightsystem/FightSystem.java index 536f838..3aa0c63 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/FightSystem.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/FightSystem.java @@ -266,10 +266,10 @@ public class FightSystem extends JavaPlugin { private static void setAllPlayersGM(GameMode gm) { for(FightPlayer fightPlayer: Fight.getBlueTeam().getPlayers()){ - fightPlayer.getPlayer().setGameMode(gm); + Fight.setPlayerGamemode(fightPlayer.getPlayer(), gm); } for(FightPlayer fightPlayer: Fight.getRedTeam().getPlayers()){ - fightPlayer.getPlayer().setGameMode(gm); + Fight.setPlayerGamemode(fightPlayer.getPlayer(), gm); } } diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/fight/Fight.java b/FightSystem_Main/src/de/steamwar/fightsystem/fight/Fight.java index ffa907b..6470089 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/fight/Fight.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/fight/Fight.java @@ -1,7 +1,9 @@ package de.steamwar.fightsystem.fight; import de.steamwar.fightsystem.Config; +import de.steamwar.fightsystem.FightSystem; import org.bukkit.Bukkit; +import org.bukkit.GameMode; import org.bukkit.Material; import org.bukkit.Sound; import org.bukkit.entity.Player; @@ -83,4 +85,26 @@ public class Fight { Fight.getRedTeam().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); + } + } + } + } } diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/fight/FightTeam.java b/FightSystem_Main/src/de/steamwar/fightsystem/fight/FightTeam.java index 9326f21..8dc57cf 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/fight/FightTeam.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/fight/FightTeam.java @@ -147,7 +147,7 @@ public class FightTeam implements IFightTeam{ invited.remove(player); team.addEntry(player.getName()); - player.setGameMode(GameMode.SURVIVAL); + Fight.setPlayerGamemode(player, GameMode.SURVIVAL); player.teleport(spawn); 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()); @@ -167,7 +167,7 @@ public class FightTeam implements IFightTeam{ if(fightPlayer.equals(leader) && FightSystem.getFightState().setup()) setLeader(null); - player.setGameMode(GameMode.SPECTATOR); + Fight.setPlayerGamemode(player, GameMode.SPECTATOR); player.teleport(Config.SpecSpawn); TechHider.reloadChunks(player, chunksToReload); } diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/listener/PlayerStateListener.java b/FightSystem_Main/src/de/steamwar/fightsystem/listener/PlayerStateListener.java index 6e3866e..2e68345 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/listener/PlayerStateListener.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/listener/PlayerStateListener.java @@ -40,14 +40,14 @@ public class PlayerStateListener extends BasicListener{ FightTeam fightTeam = Fight.getPlayerTeam(player); if (fightTeam == null) { - player.setGameMode(GameMode.SPECTATOR); + Fight.setPlayerGamemode(player, GameMode.SPECTATOR); player.teleport(Config.SpecSpawn); } else { player.teleport(fightTeam.getSpawn()); if(FightSystem.getFightState().setup()) - player.setGameMode(GameMode.SURVIVAL); + Fight.setPlayerGamemode(player, GameMode.SURVIVAL); 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!"); event.setDeathMessage(null); fightTeam.getFightPlayer(player).setOut(); - player.setGameMode(GameMode.SPECTATOR); + Fight.setPlayerGamemode(player, GameMode.SPECTATOR); player.teleport(fightTeam.getSpawn()); Fight.playSound(Countdown.getSound(SWSound.ENTITY_WITHER_DEATH), 100.0F, 1.0F); } From c463823c059a9239989c9842aeabcb9119d3f5a5 Mon Sep 17 00:00:00 2001 From: Yaruma3341 Date: Tue, 14 Jan 2020 22:16:12 +0100 Subject: [PATCH 2/3] implemented version independence --- .../steamwar/fightsystem/fight/Fight_10.java | 18 ++++++ .../steamwar/fightsystem/fight/Fight_12.java | 19 +++++++ .../steamwar/fightsystem/fight/Fight_14.java | 18 ++++++ .../steamwar/fightsystem/fight/Fight_15.java | 18 ++++++ .../steamwar/fightsystem/fight/Fight_8.java | 18 ++++++ .../steamwar/fightsystem/fight/Fight_9.java | 18 ++++++ .../de/steamwar/fightsystem/fight/Fight.java | 57 +++++++++++++++++-- 7 files changed, 162 insertions(+), 4 deletions(-) create mode 100644 FightSystem_10/src/de/steamwar/fightsystem/fight/Fight_10.java create mode 100644 FightSystem_12/src/de/steamwar/fightsystem/fight/Fight_12.java create mode 100644 FightSystem_14/src/de/steamwar/fightsystem/fight/Fight_14.java create mode 100644 FightSystem_15/src/de/steamwar/fightsystem/fight/Fight_15.java create mode 100644 FightSystem_8/src/de/steamwar/fightsystem/fight/Fight_8.java create mode 100644 FightSystem_9/src/de/steamwar/fightsystem/fight/Fight_9.java diff --git a/FightSystem_10/src/de/steamwar/fightsystem/fight/Fight_10.java b/FightSystem_10/src/de/steamwar/fightsystem/fight/Fight_10.java new file mode 100644 index 0000000..32f331f --- /dev/null +++ b/FightSystem_10/src/de/steamwar/fightsystem/fight/Fight_10.java @@ -0,0 +1,18 @@ +package de.steamwar.fightsystem.fight; + +import org.bukkit.entity.Player; + +public class Fight_10 { + + private Fight_10() {} + + static void hidePlayer(Player target, Player toHide) { + Fight_8.hidePlayer(target, toHide); + } + + static void showPlayer(Player target, Player toShow) { + Fight_8.showPlayer(target, toShow); + } + + +} diff --git a/FightSystem_12/src/de/steamwar/fightsystem/fight/Fight_12.java b/FightSystem_12/src/de/steamwar/fightsystem/fight/Fight_12.java new file mode 100644 index 0000000..1228d4e --- /dev/null +++ b/FightSystem_12/src/de/steamwar/fightsystem/fight/Fight_12.java @@ -0,0 +1,19 @@ +package de.steamwar.fightsystem.fight; + +import de.steamwar.fightsystem.IFightSystem; +import org.bukkit.entity.Player; + +public class Fight_12 { + + private Fight_12() {} + + static void hidePlayer(Player target, Player toHide) { + target.hidePlayer(IFightSystem.getPlugin(), toHide); + } + + static void showPlayer(Player target, Player toShow) { + target.showPlayer(IFightSystem.getPlugin(), toShow); + } + + +} diff --git a/FightSystem_14/src/de/steamwar/fightsystem/fight/Fight_14.java b/FightSystem_14/src/de/steamwar/fightsystem/fight/Fight_14.java new file mode 100644 index 0000000..48e3c57 --- /dev/null +++ b/FightSystem_14/src/de/steamwar/fightsystem/fight/Fight_14.java @@ -0,0 +1,18 @@ +package de.steamwar.fightsystem.fight; + +import org.bukkit.entity.Player; + +public class Fight_14 { + + private Fight_14() {} + + static void hidePlayer(Player target, Player toHide) { + Fight_12.hidePlayer(target, toHide); + } + + static void showPlayer(Player target, Player toShow) { + Fight_12.showPlayer(target, toShow); + } + + +} diff --git a/FightSystem_15/src/de/steamwar/fightsystem/fight/Fight_15.java b/FightSystem_15/src/de/steamwar/fightsystem/fight/Fight_15.java new file mode 100644 index 0000000..486e873 --- /dev/null +++ b/FightSystem_15/src/de/steamwar/fightsystem/fight/Fight_15.java @@ -0,0 +1,18 @@ +package de.steamwar.fightsystem.fight; + +import org.bukkit.entity.Player; + +public class Fight_15 { + + private Fight_15() {} + + static void hidePlayer(Player target, Player toHide) { + Fight_14.hidePlayer(target, toHide); + } + + static void showPlayer(Player target, Player toShow) { + Fight_14.showPlayer(target, toShow); + } + + +} diff --git a/FightSystem_8/src/de/steamwar/fightsystem/fight/Fight_8.java b/FightSystem_8/src/de/steamwar/fightsystem/fight/Fight_8.java new file mode 100644 index 0000000..e006501 --- /dev/null +++ b/FightSystem_8/src/de/steamwar/fightsystem/fight/Fight_8.java @@ -0,0 +1,18 @@ +package de.steamwar.fightsystem.fight; + +import org.bukkit.entity.Player; + +public class Fight_8 { + + private Fight_8() {} + + static void hidePlayer(Player target, Player toHide) { + target.hidePlayer(toHide); + } + + static void showPlayer(Player target, Player toShow) { + target.showPlayer(toShow); + } + + +} diff --git a/FightSystem_9/src/de/steamwar/fightsystem/fight/Fight_9.java b/FightSystem_9/src/de/steamwar/fightsystem/fight/Fight_9.java new file mode 100644 index 0000000..51dda59 --- /dev/null +++ b/FightSystem_9/src/de/steamwar/fightsystem/fight/Fight_9.java @@ -0,0 +1,18 @@ +package de.steamwar.fightsystem.fight; + +import org.bukkit.entity.Player; + +public class Fight_9 { + + private Fight_9() {} + + static void hidePlayer(Player target, Player toHide) { + Fight_8.hidePlayer(target, toHide); + } + + static void showPlayer(Player target, Player toShow) { + Fight_8.showPlayer(target, toShow); + } + + +} diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/fight/Fight.java b/FightSystem_Main/src/de/steamwar/fightsystem/fight/Fight.java index 6470089..488405c 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/fight/Fight.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/fight/Fight.java @@ -1,5 +1,6 @@ package de.steamwar.fightsystem.fight; +import de.steamwar.core.Core; import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.FightSystem; import org.bukkit.Bukkit; @@ -92,8 +93,32 @@ public class Fight { 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); + switch (Core.getVersion()) { + case 8: + Fight_8.hidePlayer(currentPlayer, player); + Fight_8.hidePlayer(player, currentPlayer); + break; + case 9: + Fight_9.hidePlayer(currentPlayer, player); + Fight_9.hidePlayer(player, currentPlayer); + break; + case 10: + Fight_10.hidePlayer(currentPlayer, player); + Fight_10.hidePlayer(player, currentPlayer); + break; + case 14: + Fight_14.hidePlayer(currentPlayer, player); + Fight_14.hidePlayer(player, currentPlayer); + break; + case 15: + Fight_15.hidePlayer(currentPlayer, player); + Fight_15.hidePlayer(player, currentPlayer); + break; + default: + Fight_12.hidePlayer(currentPlayer, player); + Fight_12.hidePlayer(player, currentPlayer); + break; + } } } } @@ -101,8 +126,32 @@ public class Fight { 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); + switch (Core.getVersion()) { + case 8: + Fight_8.showPlayer(currentPlayer, player); + Fight_8.showPlayer(player, currentPlayer); + break; + case 9: + Fight_9.showPlayer(currentPlayer, player); + Fight_9.showPlayer(player, currentPlayer); + break; + case 10: + Fight_10.showPlayer(currentPlayer, player); + Fight_10.showPlayer(player, currentPlayer); + break; + case 14: + Fight_14.showPlayer(currentPlayer, player); + Fight_14.showPlayer(player, currentPlayer); + break; + case 15: + Fight_15.showPlayer(currentPlayer, player); + Fight_15.showPlayer(player, currentPlayer); + break; + default: + Fight_12.showPlayer(currentPlayer, player); + Fight_12.showPlayer(player, currentPlayer); + break; + } } } } From 23a8f9ba846cbe6926247bee535d0179e716ae4b Mon Sep 17 00:00:00 2001 From: Yaruma3341 Date: Wed, 15 Jan 2020 18:44:34 +0100 Subject: [PATCH 3/3] code cleanup; semi version independent --- .../steamwar/fightsystem/fight/Fight_10.java | 18 ------ .../steamwar/fightsystem/fight/Fight_12.java | 19 ------- .../steamwar/fightsystem/fight/Fight_14.java | 18 ------ .../steamwar/fightsystem/fight/Fight_15.java | 18 ------ .../steamwar/fightsystem/fight/Fight_8.java | 18 ------ .../steamwar/fightsystem/fight/Fight_9.java | 18 ------ .../de/steamwar/fightsystem/fight/Fight.java | 56 ++----------------- 7 files changed, 4 insertions(+), 161 deletions(-) delete mode 100644 FightSystem_10/src/de/steamwar/fightsystem/fight/Fight_10.java delete mode 100644 FightSystem_12/src/de/steamwar/fightsystem/fight/Fight_12.java delete mode 100644 FightSystem_14/src/de/steamwar/fightsystem/fight/Fight_14.java delete mode 100644 FightSystem_15/src/de/steamwar/fightsystem/fight/Fight_15.java delete mode 100644 FightSystem_8/src/de/steamwar/fightsystem/fight/Fight_8.java delete mode 100644 FightSystem_9/src/de/steamwar/fightsystem/fight/Fight_9.java diff --git a/FightSystem_10/src/de/steamwar/fightsystem/fight/Fight_10.java b/FightSystem_10/src/de/steamwar/fightsystem/fight/Fight_10.java deleted file mode 100644 index 32f331f..0000000 --- a/FightSystem_10/src/de/steamwar/fightsystem/fight/Fight_10.java +++ /dev/null @@ -1,18 +0,0 @@ -package de.steamwar.fightsystem.fight; - -import org.bukkit.entity.Player; - -public class Fight_10 { - - private Fight_10() {} - - static void hidePlayer(Player target, Player toHide) { - Fight_8.hidePlayer(target, toHide); - } - - static void showPlayer(Player target, Player toShow) { - Fight_8.showPlayer(target, toShow); - } - - -} diff --git a/FightSystem_12/src/de/steamwar/fightsystem/fight/Fight_12.java b/FightSystem_12/src/de/steamwar/fightsystem/fight/Fight_12.java deleted file mode 100644 index 1228d4e..0000000 --- a/FightSystem_12/src/de/steamwar/fightsystem/fight/Fight_12.java +++ /dev/null @@ -1,19 +0,0 @@ -package de.steamwar.fightsystem.fight; - -import de.steamwar.fightsystem.IFightSystem; -import org.bukkit.entity.Player; - -public class Fight_12 { - - private Fight_12() {} - - static void hidePlayer(Player target, Player toHide) { - target.hidePlayer(IFightSystem.getPlugin(), toHide); - } - - static void showPlayer(Player target, Player toShow) { - target.showPlayer(IFightSystem.getPlugin(), toShow); - } - - -} diff --git a/FightSystem_14/src/de/steamwar/fightsystem/fight/Fight_14.java b/FightSystem_14/src/de/steamwar/fightsystem/fight/Fight_14.java deleted file mode 100644 index 48e3c57..0000000 --- a/FightSystem_14/src/de/steamwar/fightsystem/fight/Fight_14.java +++ /dev/null @@ -1,18 +0,0 @@ -package de.steamwar.fightsystem.fight; - -import org.bukkit.entity.Player; - -public class Fight_14 { - - private Fight_14() {} - - static void hidePlayer(Player target, Player toHide) { - Fight_12.hidePlayer(target, toHide); - } - - static void showPlayer(Player target, Player toShow) { - Fight_12.showPlayer(target, toShow); - } - - -} diff --git a/FightSystem_15/src/de/steamwar/fightsystem/fight/Fight_15.java b/FightSystem_15/src/de/steamwar/fightsystem/fight/Fight_15.java deleted file mode 100644 index 486e873..0000000 --- a/FightSystem_15/src/de/steamwar/fightsystem/fight/Fight_15.java +++ /dev/null @@ -1,18 +0,0 @@ -package de.steamwar.fightsystem.fight; - -import org.bukkit.entity.Player; - -public class Fight_15 { - - private Fight_15() {} - - static void hidePlayer(Player target, Player toHide) { - Fight_14.hidePlayer(target, toHide); - } - - static void showPlayer(Player target, Player toShow) { - Fight_14.showPlayer(target, toShow); - } - - -} diff --git a/FightSystem_8/src/de/steamwar/fightsystem/fight/Fight_8.java b/FightSystem_8/src/de/steamwar/fightsystem/fight/Fight_8.java deleted file mode 100644 index e006501..0000000 --- a/FightSystem_8/src/de/steamwar/fightsystem/fight/Fight_8.java +++ /dev/null @@ -1,18 +0,0 @@ -package de.steamwar.fightsystem.fight; - -import org.bukkit.entity.Player; - -public class Fight_8 { - - private Fight_8() {} - - static void hidePlayer(Player target, Player toHide) { - target.hidePlayer(toHide); - } - - static void showPlayer(Player target, Player toShow) { - target.showPlayer(toShow); - } - - -} diff --git a/FightSystem_9/src/de/steamwar/fightsystem/fight/Fight_9.java b/FightSystem_9/src/de/steamwar/fightsystem/fight/Fight_9.java deleted file mode 100644 index 51dda59..0000000 --- a/FightSystem_9/src/de/steamwar/fightsystem/fight/Fight_9.java +++ /dev/null @@ -1,18 +0,0 @@ -package de.steamwar.fightsystem.fight; - -import org.bukkit.entity.Player; - -public class Fight_9 { - - private Fight_9() {} - - static void hidePlayer(Player target, Player toHide) { - Fight_8.hidePlayer(target, toHide); - } - - static void showPlayer(Player target, Player toShow) { - Fight_8.showPlayer(target, toShow); - } - - -} diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/fight/Fight.java b/FightSystem_Main/src/de/steamwar/fightsystem/fight/Fight.java index 488405c..0f9bc15 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/fight/Fight.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/fight/Fight.java @@ -93,32 +93,8 @@ public class Fight { if(gameMode == GameMode.SPECTATOR) { for(Player currentPlayer : Bukkit.getServer().getOnlinePlayers()) { if(currentPlayer.getUniqueId() != player.getUniqueId() && currentPlayer.getGameMode() == GameMode.SPECTATOR) { - switch (Core.getVersion()) { - case 8: - Fight_8.hidePlayer(currentPlayer, player); - Fight_8.hidePlayer(player, currentPlayer); - break; - case 9: - Fight_9.hidePlayer(currentPlayer, player); - Fight_9.hidePlayer(player, currentPlayer); - break; - case 10: - Fight_10.hidePlayer(currentPlayer, player); - Fight_10.hidePlayer(player, currentPlayer); - break; - case 14: - Fight_14.hidePlayer(currentPlayer, player); - Fight_14.hidePlayer(player, currentPlayer); - break; - case 15: - Fight_15.hidePlayer(currentPlayer, player); - Fight_15.hidePlayer(player, currentPlayer); - break; - default: - Fight_12.hidePlayer(currentPlayer, player); - Fight_12.hidePlayer(player, currentPlayer); - break; - } + currentPlayer.hidePlayer(player); + player.hidePlayer(currentPlayer); } } } @@ -126,32 +102,8 @@ public class Fight { if(gameMode == GameMode.SURVIVAL) { for(Player currentPlayer : Bukkit.getServer().getOnlinePlayers()) { if(currentPlayer.getUniqueId() != player.getUniqueId() && currentPlayer.getGameMode() == GameMode.SPECTATOR) { - switch (Core.getVersion()) { - case 8: - Fight_8.showPlayer(currentPlayer, player); - Fight_8.showPlayer(player, currentPlayer); - break; - case 9: - Fight_9.showPlayer(currentPlayer, player); - Fight_9.showPlayer(player, currentPlayer); - break; - case 10: - Fight_10.showPlayer(currentPlayer, player); - Fight_10.showPlayer(player, currentPlayer); - break; - case 14: - Fight_14.showPlayer(currentPlayer, player); - Fight_14.showPlayer(player, currentPlayer); - break; - case 15: - Fight_15.showPlayer(currentPlayer, player); - Fight_15.showPlayer(player, currentPlayer); - break; - default: - Fight_12.showPlayer(currentPlayer, player); - Fight_12.showPlayer(player, currentPlayer); - break; - } + currentPlayer.showPlayer(player); + player.showPlayer(currentPlayer); } } }