From c00dd470f1ccfcf17040f92f334275329da04b9d Mon Sep 17 00:00:00 2001 From: Lixfel Date: Sun, 3 Oct 2021 20:35:37 +0200 Subject: [PATCH] Move to FightInfoPacket Signed-off-by: Lixfel --- .../de/steamwar/fightsystem/FightSystem.java | 6 +- .../steamwar/fightsystem/fight/FightTeam.java | 6 -- .../fightsystem/listener/Permanent.java | 6 -- .../fightsystem/utils/BungeeFightInfo.java | 63 +++++++++++++++++++ 4 files changed, 65 insertions(+), 16 deletions(-) create mode 100644 FightSystem_Core/src/de/steamwar/fightsystem/utils/BungeeFightInfo.java diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/FightSystem.java b/FightSystem_Core/src/de/steamwar/fightsystem/FightSystem.java index 0e18eca..5f77e09 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/FightSystem.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/FightSystem.java @@ -31,10 +31,7 @@ import de.steamwar.fightsystem.listener.*; import de.steamwar.fightsystem.record.*; import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.OneShotStateDependent; -import de.steamwar.fightsystem.utils.EnterHandler; -import de.steamwar.fightsystem.utils.FightStatistics; -import de.steamwar.fightsystem.utils.FightUI; -import de.steamwar.fightsystem.utils.TechHider; +import de.steamwar.fightsystem.utils.*; import de.steamwar.fightsystem.winconditions.*; import de.steamwar.sql.EventFight; import de.steamwar.sql.Schematic; @@ -88,6 +85,7 @@ public class FightSystem extends JavaPlugin { new TechHider(); new FightWorld(); new FightUI(); + new BungeeFightInfo(); new WinconditionAllDead(); new WinconditionCaptainDead(); diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/fight/FightTeam.java b/FightSystem_Core/src/de/steamwar/fightsystem/fight/FightTeam.java index 7696963..2d12cb9 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/fight/FightTeam.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/fight/FightTeam.java @@ -20,7 +20,6 @@ package de.steamwar.fightsystem.fight; import com.sk89q.worldedit.extent.clipboard.Clipboard; -import de.steamwar.comms.packets.TablistNamePacket; import de.steamwar.fightsystem.ArenaMode; import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.FightSystem; @@ -33,7 +32,6 @@ import de.steamwar.fightsystem.states.StateDependent; import de.steamwar.fightsystem.utils.*; import de.steamwar.inventory.SWItem; import de.steamwar.sql.Schematic; -import de.steamwar.sql.SteamwarUser; import net.md_5.bungee.api.chat.BaseComponent; import net.md_5.bungee.api.chat.TextComponent; import org.bukkit.*; @@ -213,8 +211,6 @@ public class FightTeam { if(Kit.getAvailableKits(false).size() > 1 || Config.PersonalKits) player.getInventory().setItem(1, new ItemBuilder(Material.LEATHER_CHESTPLATE).removeAllAttributs().addEnchantment(Enchantment.DURABILITY, 1).setDisplayName("§eKit wählen").build()); player.getInventory().setItem(7, new ItemBuilder(Material.BEACON).removeAllAttributs().setDisplayName("§eRespawn").build()); - if(ArenaMode.NotOnBau.contains(Config.mode)) - Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), () -> new TablistNamePacket(SteamwarUser.get(player.getUniqueId()).getId(), prefix + player.getName()).send(player), 5); GlobalRecorder.getInstance().playerJoins(player); TechHider.reloadChunks(player, chunksToReload, false); @@ -243,8 +239,6 @@ public class FightTeam { player.getInventory().clear(); if(player.isOnline()){ - if(ArenaMode.NotOnBau.contains(Config.mode)) - new TablistNamePacket(SteamwarUser.get(player.getUniqueId()).getId(), "§7" + player.getName()).send(player); TechHider.reloadChunks(player, chunksToReload, true); } } diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/listener/Permanent.java b/FightSystem_Core/src/de/steamwar/fightsystem/listener/Permanent.java index 4463317..29ef016 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/listener/Permanent.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/listener/Permanent.java @@ -19,18 +19,14 @@ package de.steamwar.fightsystem.listener; -import de.steamwar.comms.packets.TablistNamePacket; import de.steamwar.fightsystem.ArenaMode; import de.steamwar.fightsystem.Config; -import de.steamwar.fightsystem.FightSystem; import de.steamwar.fightsystem.fight.Fight; import de.steamwar.fightsystem.fight.FightTeam; import de.steamwar.fightsystem.record.REntity; import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.StateDependentListener; -import de.steamwar.sql.SteamwarUser; import net.md_5.bungee.api.chat.TextComponent; -import org.bukkit.Bukkit; import org.bukkit.GameMode; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -79,8 +75,6 @@ public class Permanent implements Listener { if (fightTeam == null) { Fight.setPlayerGamemode(player, GameMode.SPECTATOR); player.teleport(Config.SpecSpawn); - if(ArenaMode.NotOnBau.contains(Config.mode)) - Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), () -> new TablistNamePacket(SteamwarUser.get(player.getUniqueId()).getId(), "§7" + player.getName()).send(player), 5); } REntity.playerJoins(player); diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/utils/BungeeFightInfo.java b/FightSystem_Core/src/de/steamwar/fightsystem/utils/BungeeFightInfo.java new file mode 100644 index 0000000..f9ebb3c --- /dev/null +++ b/FightSystem_Core/src/de/steamwar/fightsystem/utils/BungeeFightInfo.java @@ -0,0 +1,63 @@ +/* + This file is a part of the SteamWar software. + + Copyright (C) 2021 SteamWar.de-Serverteam + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + */ + +package de.steamwar.fightsystem.utils; + +import de.steamwar.comms.packets.FightInfoPacket; +import de.steamwar.fightsystem.ArenaMode; +import de.steamwar.fightsystem.Config; +import de.steamwar.fightsystem.fight.Fight; +import de.steamwar.fightsystem.states.FightState; +import de.steamwar.fightsystem.states.StateDependentCountdown; +import de.steamwar.fightsystem.states.StateDependentTask; +import de.steamwar.sql.SteamwarUser; +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; + +import java.util.stream.Collectors; + +public class BungeeFightInfo { + + public BungeeFightInfo() { + new StateDependentTask(ArenaMode.NotOnBau, FightState.All, this::send, 20, 20); + } + + private void send() { + Player player = Bukkit.getOnlinePlayers().stream().findAny().orElse(null); + if(player == null) + return; + + new FightInfoPacket( + Bukkit.getWorlds().get(0).getName(), + Config.SchematicType.toDB(), + "", + Fight.getBlueTeam().getColoredName(), + Fight.getRedTeam().getColoredName(), + FightState.getFightState().name(), + StateDependentCountdown.getMainCountdown() != null ? StateDependentCountdown.getMainCountdown().getTimeLeft() : 0, + Fight.getBlueTeam().getLeader() != null ? SteamwarUser.get(Fight.getBlueTeam().getLeader().getPlayer().getUniqueId()).getId() : 0, + Fight.getRedTeam().getLeader() != null ? SteamwarUser.get(Fight.getRedTeam().getLeader().getPlayer().getUniqueId()).getId() : 0, + Fight.getBlueTeam().getSchematic(), + Fight.getRedTeam().getSchematic(), + Fight.getBlueTeam().getPlayers().stream().map(p -> SteamwarUser.get(p.getPlayer().getUniqueId()).getId()).collect(Collectors.toList()), + Fight.getRedTeam().getPlayers().stream().map(p -> SteamwarUser.get(p.getPlayer().getUniqueId()).getId()).collect(Collectors.toList()), + Bukkit.getOnlinePlayers().stream().filter(p -> Fight.getPlayerTeam(p) == null).map(p -> SteamwarUser.get(p.getUniqueId()).getId()).collect(Collectors.toList()) + ).send(player); + } +} -- 2.39.2