From 1cc57539e4334ce11cd6de64884ea87db49ca886 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Sat, 2 Oct 2021 11:44:12 +0200 Subject: [PATCH 1/8] WIP first half multiling Signed-off-by: Lixfel --- .../de/steamwar/fightsystem/FightSystem.java | 9 ++ .../fightsystem/FightSystem.properties | 119 ++++++++++++++++++ .../fightsystem/FightSystem_de.properties | 19 +++ .../fightsystem/commands/AkCommand.java | 1 - .../fightsystem/commands/Commands.java | 58 +++------ .../de/steamwar/fightsystem/commands/GUI.java | 65 +++++----- .../fightsystem/commands/GamemodeCommand.java | 20 +-- .../fightsystem/commands/InviteCommand.java | 3 +- .../fightsystem/commands/LeaderCommand.java | 20 ++- .../commands/LockschemCommand.java | 19 ++- .../fightsystem/commands/RemoveCommand.java | 3 +- .../fightsystem/commands/ReplayCommand.java | 9 +- .../fightsystem/commands/WinCommand.java | 5 +- .../fightsystem/countdown/Countdown.java | 39 +++--- .../countdown/EnternCountdown.java | 40 ++---- .../countdown/EventSpectateCountdown.java | 2 +- .../countdown/NoPlayersOnlineCountdown.java | 4 +- .../countdown/PostSchemCountdown.java | 2 +- .../countdown/PreRunningCountdown.java | 2 +- .../countdown/PreSchemCountdown.java | 2 +- .../countdown/SpectateOverCountdown.java | 2 +- .../countdown/TimeOverCountdown.java | 2 +- .../fightsystem/event/HellsBells.java | 19 +-- .../fightsystem/fight/FightPlayer.java | 4 - .../fightsystem/fight/FightSchematic.java | 2 +- .../steamwar/fightsystem/fight/FightTeam.java | 10 +- .../fightsystem/record/PacketProcessor.java | 10 ++ .../steamwar/fightsystem/record/Recorder.java | 11 +- .../winconditions/WinconditionTimeTechKO.java | 1 + 29 files changed, 296 insertions(+), 206 deletions(-) create mode 100644 FightSystem_Core/src/de/steamwar/fightsystem/FightSystem.properties create mode 100644 FightSystem_Core/src/de/steamwar/fightsystem/FightSystem_de.properties diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/FightSystem.java b/FightSystem_Core/src/de/steamwar/fightsystem/FightSystem.java index 0e18eca..26f8fad 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/FightSystem.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/FightSystem.java @@ -36,6 +36,7 @@ import de.steamwar.fightsystem.utils.FightStatistics; import de.steamwar.fightsystem.utils.FightUI; import de.steamwar.fightsystem.utils.TechHider; import de.steamwar.fightsystem.winconditions.*; +import de.steamwar.message.Message; import de.steamwar.sql.EventFight; import de.steamwar.sql.Schematic; import org.bukkit.Bukkit; @@ -51,6 +52,8 @@ public class FightSystem extends JavaPlugin { private static EventFight eventFight; private static Player eventLeiter; + private Message message; + @Override public void onLoad() { plugin = this; @@ -58,6 +61,8 @@ public class FightSystem extends JavaPlugin { @Override public void onEnable() { + message = new Message("de.steamwar.fightsystem.FightSystem", FightSystem.class.getClassLoader()); + new EntityDamage(); new WaterRemover(); new Permanent(); @@ -240,6 +245,10 @@ public class FightSystem extends JavaPlugin { GlobalRecorder.getInstance().systemChat(PREFIX + message); } + public static Message getMessage() { + return plugin.message; + } + private static void kickNext(){ if(Bukkit.getOnlinePlayers().isEmpty()){ Bukkit.shutdown(); diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/FightSystem.properties b/FightSystem_Core/src/de/steamwar/fightsystem/FightSystem.properties new file mode 100644 index 0000000..7fb8cef --- /dev/null +++ b/FightSystem_Core/src/de/steamwar/fightsystem/FightSystem.properties @@ -0,0 +1,119 @@ +# +# 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 . +# + +PREFIX=§eArena§8» + +# Commands +NO_TEAM=§cDu bist in keinem Team +FIGHT_ALREADY_STARTED=§cDer Kampf hat bereits begonnen +NOT_LEADER=§cDu bist kein Leader +PLAYER_UNAVAILABLE=§cDer Spieler ist nicht in der Arena + +NO_INVITATION=§cDu wurdest von keinem Team eingeladen +INVITATION_DECLINED=§cEinladung abgelehnt +INVITATION_DECLINED_TEAM=§e{0} §chat die Einladung abgelehnt +PLAYER_IN_TEAM=§e{0} §cist bereits in einem Team +ALREADY_INVITED=§e{0} §cwurde bereits eingeladen +INVITATION_SENT=§e{0} §7eingeladen + +NOT_IN_TEAM=§e{0} §cist nicht in deinem Team + +KIT_UNAVAILABLE=§cDieses Kit gibt es nicht +KIT_CHOSEN=§7Kit §e{0} §7gewählt + +GAMEMODE_NOT_ALLOWED=§cSpielmodusänderung verboten +GAMEMODE_UNKNOWN=§cUnbekannter Spielmodus {0} +GAMEMODE_HELP=§8/§7gm §8[§eSpielmodus§8] + +INVITE_HELP=§8/§einvite §8[§eSpieler§8] + +LEADER_FULL=§cAlle Teams haben bereits einen Leader +ALREADY_IN_TEAM=§cDu bist bereits in einem Team + +LOCKSCHEM_HELP=§8/§7lockschem §8[§eTeam§8] +UNKNOWN_TEAM=§cDieses Team existiert nicht +LOCKSCHEM_LOCKED=§7Schematic gesperrt +LOCKSCHEM_LOCKED_BY=§cDie Schematic wurde von §e{0} §cgesperrt + +REMOVE_HELP=§8/§eremove §8[§eSpieler§8] + +REPLAY_UNAVAILABLE=§cReplay derzeit nicht verfügbar + +NOT_FIGHTLEADER=§cDu bist nicht Kampfleiter +WIN_HELP=§8/§7win §8[§eTeam §8or §etie§8] + + +# GUI +INVITATION_TITLE=Einladung von {0} +INVITATION_ACCEPT=§aAnnehmen +INVITATION_DECLINE=§cAblehnen +INVITATION_CHAT_ACCEPT=§8/§aaccept§8, §7um die Einladung §aanzunehmen +INVITATION_CHAT_DECLINE=§8/§cdecline§8, §7um die Einladung §cabzulehnen + +STATE_TITLE=Kampfstatus +STATE_PRE_LEADER_SETUP=§7Teamleaderwartephase +STATE_PRE_SCHEM_SETUP=§7Schemauswahlphase +STATE_POST_SCHEM_SETUP=§7Vorbereitungsphase +STATE_PRE_RUNNING=§eKitausgabe +STATE_RUNNING=§eKampfphase +STATE_SPECTATE_WIN=§7Sieg {0} +STATE_SPECTATE_TIE=§7Unentschieden + +INVITE_TITLE=Spieler einladen + +REMOVE_TITLE=Spieler rauswerfen + +KIT_SELECTION_TITLE=Kitauswahl +KIT_NO_KITS=§cKeine Kits gefunden +KIT_CREATE=§eNeues Kit +KITNAME_TITLE=Kitname eingeben +KITNAME_IN_USE=§cDieser Kitname wird bereits genutzt +KIT_SEARCH=§eSuchen +KITSEARCH_TITLE=Nach Kit suchen + +SCHEM_NO_ENEMY=§cKeine Schematicwahl ohne Gegner +SCHEM_TITLE={0}-Auswahl +SCHEM_PUBLIC=§eÖffentliches {0} +SCHEM_PRIVATE=§ePrivates {0} +SCHEM_NO_PRIVATE=§7Kein privates {0} vorhanden +SCHEM_PRIVATE_FORBIDDEN=§7Kein privates {0} erlaubt + + +# Countdowns +COUNTDOWN_MINUTES=§e{0} §7Minuten {1} +COUNTDOWN_SECONDS=§e{0} §7Sekunden {1} +COUNTDOWN_SECOND=§eEine §7Sekunde {1} + +ENTERN_COUNTDOWN=bis Entern erlaubt ist +ENTERN_ALLOWED=§eEntern §7ist nun erlaubt + +SHUTDOWN_COUNTDOWN=bis der Server gestoppt wird +PRE_SCHEM_COUNTDOWN=bis eine Public-Schematic gewählt wird +POST_SCHEM_COUNTDOWN=bis die Kits verteilt werden +PRE_RUNNING_COUNTDOWN=bis die Arena freigegeben ist +RUNNING_COUNTDOWN=bis der Kampf vorbei ist +SPECTATE_COUNTDOWN=bis die Arena zurückgesetzt wird + + +# Fight +SCHEMATIC_UNLOADABLE=§cSchematic konnte nicht geladen werden + + +# Winconditions +HELLS_BELLS_COUNTDOWN=bis die Bomben fallen diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/FightSystem_de.properties b/FightSystem_Core/src/de/steamwar/fightsystem/FightSystem_de.properties new file mode 100644 index 0000000..061512e --- /dev/null +++ b/FightSystem_Core/src/de/steamwar/fightsystem/FightSystem_de.properties @@ -0,0 +1,19 @@ +# +# 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 . +# + diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/commands/AkCommand.java b/FightSystem_Core/src/de/steamwar/fightsystem/commands/AkCommand.java index d58d55c..554847a 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/commands/AkCommand.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/commands/AkCommand.java @@ -44,7 +44,6 @@ public class AkCommand implements CommandExecutor { Player player = (Player) sender; if(SteamwarUser.get(player.getUniqueId()).getUserGroup() != UserGroup.Developer){ - Commands.sendHelp(player); return false; } diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/commands/Commands.java b/FightSystem_Core/src/de/steamwar/fightsystem/commands/Commands.java index ed0d06d..e4189c7 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/commands/Commands.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/commands/Commands.java @@ -28,6 +28,7 @@ import de.steamwar.fightsystem.fight.Kit; import de.steamwar.fightsystem.states.FightState; import de.steamwar.sql.PersonalKit; import de.steamwar.sql.SteamwarUser; +import net.md_5.bungee.api.ChatMessageType; import org.bukkit.Bukkit; import org.bukkit.entity.Player; @@ -35,12 +36,12 @@ public class Commands { private Commands(){} private static void errNoTeam(Player p){ - p.sendMessage(FightSystem.PREFIX + "§cDu bist in keinem Team!"); + FightSystem.getMessage().sendPrefixless("NO_TEAM", p, ChatMessageType.ACTION_BAR); } static boolean checkSetup(Player p){ if(!FightState.setup()){ - p.sendMessage(FightSystem.PREFIX + "§cDer Kampf hat bereits begonnen!"); + FightSystem.getMessage().sendPrefixless("FIGHT_ALREADY_STARTED", p, ChatMessageType.ACTION_BAR); return true; } return false; @@ -49,7 +50,7 @@ public class Commands { private static FightTeam checkGetInvitedTeam(Player p){ FightTeam fightTeam = Fight.getInvitedTeam(p); if(fightTeam == null){ - p.sendMessage(FightSystem.PREFIX + "§cDu wurdest von keinem Team eingeladen!"); + FightSystem.getMessage().sendPrefixless("NO_INVITATION", p, ChatMessageType.ACTION_BAR); } return fightTeam; } @@ -65,7 +66,7 @@ public class Commands { private static FightPlayer checkGetLeader(Player p){ FightPlayer fightPlayer = checkGetPlayer(p); if(fightPlayer != null && !fightPlayer.isLeader()){ - p.sendMessage(FightSystem.PREFIX + "§cDu bist kein Leader!"); + FightSystem.getMessage().sendPrefixless("NOT_LEADER", p, ChatMessageType.ACTION_BAR); fightPlayer = null; } return fightPlayer; @@ -82,7 +83,7 @@ public class Commands { private static Player checkGetPlayer(Player p, String t){ Player target = Bukkit.getPlayer(t); if(target == null) { - p.sendMessage(FightSystem.PREFIX + "§cDer Spieler ist nicht in der Arena!"); + FightSystem.getMessage().sendPrefixless("PLAYER_UNAVAILABLE", p, ChatMessageType.ACTION_BAR); } return target; } @@ -111,7 +112,6 @@ public class Commands { if(team == null) return; - p.sendMessage(FightSystem.PREFIX + "§aDu bist Team " + team.getColoredName() + " §abeigetreten!"); team.addMember(p); } @@ -123,8 +123,8 @@ public class Commands { if(team == null) return; - p.sendMessage(FightSystem.PREFIX + "§aDu hast die Einladung von " + team.getColoredName() + " §aabgelehnt!"); - team.broadcast("§e" + p.getName() + " §chat die Einladung abgelehnt"); + FightSystem.getMessage().sendPrefixless("INVITATION_DECLINED", p, ChatMessageType.ACTION_BAR); + team.broadcast("INVITATION_DECLINED_TEAM", p.getName()); team.getInvited().remove(p); } @@ -136,7 +136,6 @@ public class Commands { if(fightTeam == null) return; - p.sendMessage(FightSystem.PREFIX + "§aDu hast das Team " + fightTeam.getColoredName() + " §averlassen!"); fightTeam.removePlayer(p); } @@ -157,17 +156,16 @@ public class Commands { return; if(Fight.getPlayerTeam(target) != null) { - p.sendMessage(FightSystem.PREFIX + "§cDer Spieler §e" + target.getName() + " §cist bereits in einem Team!"); + FightSystem.getMessage().sendPrefixless("PLAYER_IN_TEAM", p, ChatMessageType.ACTION_BAR, target.getName()); return; } if(Fight.getOpposite(fightTeam).getInvited().contains(target) || fightTeam.getInvited().contains(target)) { - p.sendMessage(FightSystem.PREFIX + "§cDieser Spieler wurde bereits eingeladen!"); + FightSystem.getMessage().sendPrefixless("ALREADY_INVITED", p, ChatMessageType.ACTION_BAR, target.getName()); return; } - target.sendMessage(FightSystem.PREFIX + "§aDu wurdest in das Team von §e" + p.getName() + " §aeingeladen!"); - p.sendMessage(FightSystem.PREFIX + "§aDu hast den Spieler §e" + target.getName() + " §ain dein Team eingeladen!"); + FightSystem.getMessage().sendPrefixless("INVITATION_SENT", p, ChatMessageType.ACTION_BAR, target.getName()); fightTeam.getInvited().add(target); GUI.invitation(p, target); } @@ -189,12 +187,10 @@ public class Commands { return; if(!fightTeam.isPlayerInTeam(target)){ - p.sendMessage(FightSystem.PREFIX + "§cDer Spieler " + target.getName() + " §cist nicht in deinem Team§c!"); + FightSystem.getMessage().sendPrefixless("NOT_IN_TEAM", p, ChatMessageType.ACTION_BAR, target.getName()); return; } - p.sendMessage(FightSystem.PREFIX + "§aDu hast den Spieler §e" + target.getName() + " §aaus dem Team entfernt!"); - target.sendMessage(FightSystem.PREFIX + "§cDu wurdest aus dem Team entfernt!"); fightTeam.removePlayer(target); } @@ -217,36 +213,12 @@ public class Commands { k = Kit.getKitByName(kitName); } - if(k == null){ - p.sendMessage(FightSystem.PREFIX + "§cDieses Kit gibt es nicht!"); + if(k == null || !k.canUseKit(fightPlayer.isLeader())){ + FightSystem.getMessage().sendPrefixless("KIT_UNAVAILABLE", p, ChatMessageType.ACTION_BAR); return; } - if(!k.canUseKit(fightPlayer.isLeader())){ - p.sendMessage(FightSystem.PREFIX + "§cDu darfst dieses Kit nicht verwenden!"); - return; - } - - p.sendMessage(FightSystem.PREFIX + "§aDu spielst nun mit dem Kit §e" + kitName + "§a!"); + FightSystem.getMessage().sendPrefixless("KIT_CHOSEN", p, ChatMessageType.ACTION_BAR, kitName); fightPlayer.setKit(k); } - - static void sendHelp(Player p) { - p.sendMessage(FightSystem.PREFIX + "§7Hilfe für das Kampfsystem"); - - FightPlayer fightPlayer = Fight.getFightPlayer(p); - if(fightPlayer == null){ - p.sendMessage("§8/§eaccept §8- §7Einladung annehmen"); - p.sendMessage("§8/§edecline §8- §7Einladung ablehnen"); - p.sendMessage("§8/§eleader §8- §7Werde der Leader eines Teams"); - }else{ - if(fightPlayer.isLeader()){ - p.sendMessage("§8/§eready §8- §7Setzt das eigene Team auf bereit"); - p.sendMessage("§8/§einvite §8<§eSpieler§8> - §7Lade einen Spieler in dein Team ein"); - p.sendMessage("§8/§eremove §8<§eSpieler§8> - §7Wirft einen Spieler aus dem Team"); - } - p.sendMessage("§8/§ekit §8<§eKit§8> - §7Wähle ein Kit"); - p.sendMessage("§8/§eleave §8- §7Team verlassen"); - } - } } diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/commands/GUI.java b/FightSystem_Core/src/de/steamwar/fightsystem/commands/GUI.java index 6c4bb00..c71723f 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/commands/GUI.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/commands/GUI.java @@ -31,9 +31,11 @@ import de.steamwar.inventory.SWAnvilInv; import de.steamwar.inventory.SWInventory; import de.steamwar.inventory.SWItem; import de.steamwar.inventory.SWListInv; +import de.steamwar.message.Message; import de.steamwar.sql.PersonalKit; import de.steamwar.sql.Schematic; import de.steamwar.sql.SteamwarUser; +import net.md_5.bungee.api.ChatMessageType; import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.entity.Player; @@ -44,23 +46,24 @@ import java.util.List; import java.util.UUID; public class GUI { - private GUI(){} + private static final Message msg = FightSystem.getMessage(); + static void invitation(Player p, Player target){ - SWInventory inv = new SWInventory(target, 9, "Einladung von " + p.getName()); - inv.setItem(0, SWItem.getDye(10), (byte)10, "§aAnnehmen", (ClickType click) ->{ + SWInventory inv = new SWInventory(target, 9, msg.parse("INVITATION_TITLE", target, p.getName())); + inv.setItem(0, SWItem.getDye(10), (byte)10, msg.parse("INVITATION_ACCEPT", target), (ClickType click) ->{ Commands.acceptInvitation(target); target.closeInventory(); }); - inv.setItem(8, SWItem.getDye(1), (byte)1, "§cAblehnen", (ClickType click) ->{ + inv.setItem(8, SWItem.getDye(1), (byte)1, msg.parse("INVITATION_DECLINE", target), (ClickType click) ->{ Commands.declineInvitation(target); target.closeInventory(); }); inv.addCloseCallback((ClickType click) ->{ if(Fight.getInvitedTeam(target) != null){ - target.sendMessage(FightSystem.PREFIX + "§7Tippe §8/§aaccept§7, um die Einladung §aanzunehmen"); - target.sendMessage(FightSystem.PREFIX + "§7Tippe §8/§cdecline§7, um die Einladung §cabzulehnen"); + msg.sendPrefixless("INVITATION_CHAT_ACCEPT", target); + msg.sendPrefixless("INVITATION_CHAT_DECLINE", target); } }); inv.setCallback(-999, (ClickType click) -> target.closeInventory()); @@ -68,15 +71,15 @@ public class GUI { } public static void state(Player p){ - SWInventory inv = new SWInventory(p, 9, "Kampfstatus"); - inv.setItem(0, Material.GLASS, "§7PRE_LEADER_SETUP", (ClickType click) -> FightSystem.setPreLeaderState()); - inv.setItem(1, Material.GLASS, "§7PRE_SCHEM_SETUP", (ClickType click) -> FightSystem.setPreSchemState()); - inv.setItem(2, Material.GLASS, "§7POST_SCHEM_SETUP", (ClickType click) -> FightSystem.setPostSchemState()); - inv.setItem(3, Material.GLASS, "§ePRE_RUNNING", (ClickType click) -> FightSystem.setPreRunningState()); - inv.setItem(4, Material.GLASS, "§eRUNNING", (ClickType click) -> FightSystem.setRunningState()); - inv.setItem(5, Material.GLASS, "§7SPECTATE Blue", (ClickType click) -> FightSystem.setSpectateState(Fight.getBlueTeam(), "operator", null)); - inv.setItem(6, Material.GLASS, "§7SPECTATE Red", (ClickType click) -> FightSystem.setSpectateState(Fight.getRedTeam(), "operator", null)); - inv.setItem(7, Material.GLASS, "§7SPECTATE Tie", (ClickType click) -> FightSystem.setSpectateState(null, "operator", null)); + SWInventory inv = new SWInventory(p, 9, msg.parse("STATE_TITLE", p)); + inv.setItem(0, Material.GLASS, msg.parse("STATE_PRE_LEADER_SETUP", p), (ClickType click) -> FightSystem.setPreLeaderState()); + inv.setItem(1, Material.GLASS, msg.parse("STATE_PRE_SCHEM_SETUP", p), (ClickType click) -> FightSystem.setPreSchemState()); + inv.setItem(2, Material.GLASS, msg.parse("STATE_POST_SCHEM_SETUP", p), (ClickType click) -> FightSystem.setPostSchemState()); + inv.setItem(3, Material.GLASS, msg.parse("STATE_PRE_RUNNING", p), (ClickType click) -> FightSystem.setPreRunningState()); + inv.setItem(4, Material.GLASS, msg.parse("STATE_RUNNING", p), (ClickType click) -> FightSystem.setRunningState()); + inv.setItem(5, Material.GLASS, msg.parse("STATE_SPECTATE_WIN", p, Fight.getBlueTeam().getColoredName()), (ClickType click) -> FightSystem.setSpectateState(Fight.getBlueTeam(), "operator", null)); + inv.setItem(6, Material.GLASS, msg.parse("STATE_SPECTATE_WIN", p, Fight.getRedTeam().getColoredName()), (ClickType click) -> FightSystem.setSpectateState(Fight.getRedTeam(), "operator", null)); + inv.setItem(7, Material.GLASS, msg.parse("STATE_SPECTATE_TIE", p), (ClickType click) -> FightSystem.setSpectateState(null, "operator", null)); inv.setCallback(-999, (ClickType click) -> p.closeInventory()); inv.open(); } @@ -84,7 +87,7 @@ public class GUI { public static void chooseInvitation(Player p){ List> players = SWListInv.createPlayerList(p.getUniqueId()); players.removeIf(swItemUUIDPair -> Fight.getFightPlayer(Bukkit.getPlayer(swItemUUIDPair.getObject())) != null); - SWListInv inv = new SWListInv<>(p, "Spieler einladen", players, (ClickType click, UUID player) -> { + SWListInv inv = new SWListInv<>(p, msg.parse("INVITE_TITLE", p), players, (ClickType click, UUID player) -> { Commands.invite(p, SteamwarUser.get(player).getUserName()); p.closeInventory(); }); @@ -98,7 +101,7 @@ public class GUI { if(team == null) return; players.removeIf(swItemUUIDPair -> !team.equals(Fight.getPlayerTeam(Bukkit.getPlayer(swItemUUIDPair.getObject())))); - SWListInv inv = new SWListInv<>(p, "Spieler rauswerfen", players, (ClickType click, UUID player) -> { + SWListInv inv = new SWListInv<>(p, msg.parse("REMOVE_TITLE", p), players, (ClickType click, UUID player) -> { Commands.kick(p, SteamwarUser.get(player).getUserName()); p.closeInventory(); }); @@ -125,19 +128,19 @@ public class GUI { entries.removeIf(entry -> !entry.getObject().getName().toLowerCase().contains(query.toLowerCase())); - SWListInv inv = new SWListInv<>(p, "Kitauswahl", false, entries, (clickType, kit) -> kit.preview(p)); + SWListInv inv = new SWListInv<>(p, msg.parse("KIT_SELECTION_TITLE", p), false, entries, (clickType, kit) -> kit.preview(p)); inv.setCallback(-999, (ClickType click) -> p.closeInventory()); if(entries.isEmpty()) { - inv.setItem(22, new SWItem(Material.BARRIER, "§cKeine Kits gefunden")); + inv.setItem(22, new SWItem(Material.BARRIER, msg.parse("KIT_NO_KITS", p))); } if(Config.PersonalKits){ - inv.setItem(48, Material.NETHER_STAR, "§eNeues Kit", clickType -> { - SWAnvilInv anvilInv = new SWAnvilInv(p, "Kitname eingeben"); + inv.setItem(48, Material.NETHER_STAR, msg.parse("KIT_CREATE", p), clickType -> { + SWAnvilInv anvilInv = new SWAnvilInv(p, msg.parse("KITNAME_TITLE", p)); anvilInv.setItem(Material.LEATHER_CHESTPLATE); anvilInv.setCallback(s -> { SteamwarUser user = SteamwarUser.get(p.getUniqueId()); if(PersonalKit.nameInUse(user.getId(), Config.SchematicType.toDB(), s)) { - p.sendMessage(FightSystem.PREFIX + "§cDieser Kitname wird bereits genutzt!"); + msg.sendPrefixless("KITNAME_IN_USE", p, ChatMessageType.ACTION_BAR); p.closeInventory(); return; } @@ -148,8 +151,8 @@ public class GUI { anvilInv.open(); }); } - inv.setItem(50, Material.NAME_TAG, "§eSuchen", clickType -> { - SWAnvilInv anvilInv = new SWAnvilInv(p, "§eNach Kit suchen"); + inv.setItem(50, Material.NAME_TAG, msg.parse("KIT_SEARCH", p), clickType -> { + SWAnvilInv anvilInv = new SWAnvilInv(p, msg.parse("KITSEARCH_TITLE", p)); anvilInv.setItem(Material.PAPER); anvilInv.setCallback(s -> kitSelection(p, s)); anvilInv.open(); @@ -159,21 +162,21 @@ public class GUI { public static void preSchemDialog(Player p){ if(!Config.test() && FightState.getFightState() != FightState.PRE_SCHEM_SETUP){ - p.sendMessage(FightSystem.PREFIX + "§cDu kannst ohne Gegner keine Schematic wählen"); + msg.sendPrefixless("SCHEM_NO_ENEMY", p, ChatMessageType.ACTION_BAR); return; } - SWInventory inv = new SWInventory(p, 9, Config.GameName + "-Auswahl"); - inv.setItem(8, Material.REDSTONE, "§eÖffentliches " + Config.GameName, (ClickType click) -> { + SWInventory inv = new SWInventory(p, 9, msg.parse("SCHEM_TITLE", p, Config.GameName)); + inv.setItem(8, Material.REDSTONE, msg.parse("SCHEM_PUBLIC", p, Config.GameName), (ClickType click) -> { p.closeInventory(); schemDialog(p, true); }); if(Fight.getMaxRank() == 0){ - inv.setItem(0, SWItem.getDye(8), (byte)8, "§7Keine privaten Schematics erlaubt", (ClickType click)->{}); + inv.setItem(0, SWItem.getDye(8), (byte)8, msg.parse("SCHEM_PRIVATE_FORBIDDEN", p, Config.GameName), (ClickType click)->{}); }else if(Schematic.getSchemsOfType(p.getUniqueId(), Config.SchematicType).isEmpty() && !Config.test()){ - inv.setItem(0, SWItem.getDye(8), (byte)8, "§7Kein privates " + Config.GameName + " vorhanden", (ClickType click)->{}); + inv.setItem(0, SWItem.getDye(8), (byte)8, msg.parse("SCHEM_NO_PRIVATE", p, Config.GameName), (ClickType click)->{}); }else{ - inv.setItem(0, SWItem.getMaterial("CAULDRON_ITEM"), "§ePrivates " + Config.GameName, (ClickType click) -> { + inv.setItem(0, SWItem.getMaterial("CAULDRON_ITEM"), msg.parse("SCHEM_PRIVATE", p, Config.GameName), (ClickType click) -> { p.closeInventory(); schemDialog(p, false); }); @@ -193,7 +196,7 @@ public class GUI { schems.removeIf(schem -> schem.getObject().getRank() > Fight.getMaxRank()); } - SWListInv inv = new SWListInv<>(p, Config.GameName + "-Auswahl", schems, (ClickType click, Schematic s) -> { + SWListInv inv = new SWListInv<>(p, msg.parse("SCHEM_TITLE", p, Config.GameName), schems, (ClickType click, Schematic s) -> { FightTeam fightTeam = Fight.getPlayerTeam(p); if(fightTeam == null) return; diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/commands/GamemodeCommand.java b/FightSystem_Core/src/de/steamwar/fightsystem/commands/GamemodeCommand.java index 1ed1d6a..b5484cf 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/commands/GamemodeCommand.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/commands/GamemodeCommand.java @@ -22,7 +22,7 @@ package de.steamwar.fightsystem.commands; import com.google.common.collect.ImmutableList; import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.FightSystem; -import org.apache.commons.lang.Validate; +import net.md_5.bungee.api.ChatMessageType; import org.bukkit.GameMode; import org.bukkit.command.CommandSender; import org.bukkit.command.defaults.BukkitCommand; @@ -42,14 +42,14 @@ public class GamemodeCommand extends BukkitCommand { List aliases = new ArrayList<>(); aliases.add("gm"); this.setAliases(aliases); - this.description = "Ändert den Spielmodus eines Spielers"; - this.usageMessage = "/gm [Spielmodus]"; } + @Override public boolean execute(CommandSender sender, String currentAlias, String[] args) { if (!(sender instanceof Player)) { return false; }else if (args.length == 0) { + FightSystem.getMessage().sendPrefixless("GAMEMODE_HELP", sender); sender.sendMessage(FightSystem.PREFIX + this.usageMessage); return false; } @@ -57,14 +57,14 @@ public class GamemodeCommand extends BukkitCommand { Player p = (Player) sender; if (!(Config.test() || p == FightSystem.getEventLeiter())) { - p.sendMessage(FightSystem.PREFIX + "§cDu darfst hier deinen Spielmodus nicht ändern"); + FightSystem.getMessage().sendPrefixless("GAMEMODE_NOT_ALLOWED", p, ChatMessageType.ACTION_BAR); return false; } GameMode mode = createMode(args[0]); if(mode == null){ - p.sendMessage(FightSystem.PREFIX + "§cUnbekannter Spielmodus"); + FightSystem.getMessage().sendPrefixless("GAMEMODE_UNKNOWN", p, ChatMessageType.ACTION_BAR, args[0]); return false; } @@ -91,16 +91,8 @@ public class GamemodeCommand extends BukkitCommand { @Override public List tabComplete(CommandSender sender, String alias, String[] args) { - Validate.notNull(sender, "Sender cannot be null"); - Validate.notNull(args, "Arguments cannot be null"); - Validate.notNull(alias, "Alias cannot be null"); - if (args.length == 1) - return StringUtil.copyPartialMatches(args[0], GAMEMODE_NAMES, - new ArrayList<>(GAMEMODE_NAMES.size())); - if (args.length == 2) { - return super.tabComplete(sender, alias, args); - } + return StringUtil.copyPartialMatches(args[0], GAMEMODE_NAMES, new ArrayList<>(GAMEMODE_NAMES.size())); return ImmutableList.of(); } diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/commands/InviteCommand.java b/FightSystem_Core/src/de/steamwar/fightsystem/commands/InviteCommand.java index e6bee2c..67cf6b1 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/commands/InviteCommand.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/commands/InviteCommand.java @@ -20,6 +20,7 @@ package de.steamwar.fightsystem.commands; import de.steamwar.fightsystem.ArenaMode; +import de.steamwar.fightsystem.FightSystem; import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.StateDependentCommand; import org.bukkit.command.Command; @@ -41,7 +42,7 @@ public class InviteCommand implements CommandExecutor { Player player = (Player) sender; if(args.length != 1){ - Commands.sendHelp(player); + FightSystem.getMessage().sendPrefixless("INVITE_HELP", player); return false; } diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/commands/LeaderCommand.java b/FightSystem_Core/src/de/steamwar/fightsystem/commands/LeaderCommand.java index 19d7874..bfc46b8 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/commands/LeaderCommand.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/commands/LeaderCommand.java @@ -24,6 +24,7 @@ import de.steamwar.fightsystem.FightSystem; import de.steamwar.fightsystem.fight.Fight; import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.StateDependentCommand; +import net.md_5.bungee.api.ChatMessageType; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; @@ -41,18 +42,15 @@ public class LeaderCommand implements CommandExecutor { return false; Player player = (Player) sender; - if(args.length == 0){ - if(Fight.getFightPlayer(player) == null){ - if(Fight.getBlueTeam().isLeaderless()) - Fight.getBlueTeam().addMember(player); - else if(Fight.getRedTeam().isLeaderless()) - Fight.getRedTeam().addMember(player); - else - player.sendMessage(FightSystem.PREFIX + "§cEs sind bereits 2 Teamleader vorhanden"); - }else - player.sendMessage(FightSystem.PREFIX + "§cDu bist bereits in einem Team"); + if(Fight.getFightPlayer(player) == null){ + if(Fight.getBlueTeam().isLeaderless()) + Fight.getBlueTeam().addMember(player); + else if(Fight.getRedTeam().isLeaderless()) + Fight.getRedTeam().addMember(player); + else + FightSystem.getMessage().sendPrefixless("LEADER_FULL", player, ChatMessageType.ACTION_BAR); }else - Commands.sendHelp(player); + FightSystem.getMessage().sendPrefixless("ALREADY_IN_TEAM", player, ChatMessageType.ACTION_BAR); return false; } diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/commands/LockschemCommand.java b/FightSystem_Core/src/de/steamwar/fightsystem/commands/LockschemCommand.java index ebb172e..9e7fff3 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/commands/LockschemCommand.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/commands/LockschemCommand.java @@ -29,6 +29,7 @@ import de.steamwar.sql.Schematic; import de.steamwar.sql.SchematicType; import de.steamwar.sql.SteamwarUser; import de.steamwar.sql.UserGroup; +import net.md_5.bungee.api.ChatMessageType; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; @@ -49,15 +50,12 @@ public class LockschemCommand implements CommandExecutor { SteamwarUser steamwarUser = SteamwarUser.get(player.getUniqueId()); UserGroup userGroup = steamwarUser.getUserGroup(); - if(userGroup != UserGroup.Admin && - userGroup != UserGroup.Developer && - userGroup != UserGroup.Moderator && - userGroup != UserGroup.Supporter) + if(!userGroup.isCheckSchematics()) return false; if(args.length != 1) { - sendHelp(player); + FightSystem.getMessage().sendPrefixless("LOCKSCHEM_HELP", player); return false; } @@ -65,16 +63,13 @@ public class LockschemCommand implements CommandExecutor { FightTeam fightTeam = Fight.getTeamByName(teamName); if(fightTeam == null) { - player.sendMessage(FightSystem.PREFIX + "§cDieses Team existiert nicht!"); + FightSystem.getMessage().sendPrefixless("UNKNOWN_TEAM", player, ChatMessageType.ACTION_BAR); return false; } + Schematic.getSchemFromDB(fightTeam.getSchematic()).setSchemType(SchematicType.Normal); - player.sendMessage(FightSystem.PREFIX + "Schematic von " + fightTeam.getColoredName() + " §cgesperrt!"); - fightTeam.broadcast("§cDie Schematic wurde von " + player.getName() + " gesperrt"); + FightSystem.getMessage().sendPrefixless("LOCKSCHEM_LOCKED", player, ChatMessageType.ACTION_BAR); + fightTeam.broadcastSystem("LOCKSCHEM_LOCKED_BY", player.getName()); return false; } - - private void sendHelp(Player player) { - player.sendMessage(FightSystem.PREFIX + "/lockschem [TEAM]"); - } } diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/commands/RemoveCommand.java b/FightSystem_Core/src/de/steamwar/fightsystem/commands/RemoveCommand.java index 29ba6d2..f7c9353 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/commands/RemoveCommand.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/commands/RemoveCommand.java @@ -20,6 +20,7 @@ package de.steamwar.fightsystem.commands; import de.steamwar.fightsystem.ArenaMode; +import de.steamwar.fightsystem.FightSystem; import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.StateDependentCommand; import org.bukkit.command.Command; @@ -41,7 +42,7 @@ public class RemoveCommand implements CommandExecutor { Player player = (Player) sender; if(args.length != 1){ - Commands.sendHelp(player); + FightSystem.getMessage().sendPrefixless("REMOVE_HELP", player); return false; } diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/commands/ReplayCommand.java b/FightSystem_Core/src/de/steamwar/fightsystem/commands/ReplayCommand.java index 170705b..cc81995 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/commands/ReplayCommand.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/commands/ReplayCommand.java @@ -27,12 +27,14 @@ import de.steamwar.fightsystem.record.FileSource; import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.StateDependentCommand; import de.steamwar.sql.SteamwarUser; +import net.md_5.bungee.api.ChatMessageType; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import java.io.IOException; +import java.util.logging.Level; public class ReplayCommand implements CommandExecutor { @@ -50,20 +52,21 @@ public class ReplayCommand implements CommandExecutor { if(!Config.test()){ SteamwarUser user = SteamwarUser.get(player.getUniqueId()); if(!user.getUserGroup().isTeamGroup()){ - sender.sendMessage(FightSystem.PREFIX + "§cDieser Befehl ist zu diesem Kampfzeitpunkt nicht verfügbar."); + FightSystem.getMessage().sendPrefixless("REPLAY_UNAVAILABLE", sender, ChatMessageType.ACTION_BAR); return false; } } if(!FileRecorder.getFile().exists()){ - sender.sendMessage(FightSystem.PREFIX + "§cKein Replay vorhanden."); + FightSystem.getMessage().sendPrefixless("REPLAY_UNAVAILABLE", sender, ChatMessageType.ACTION_BAR); return false; } try { new FileSource(FileRecorder.getFile()); } catch (IOException e) { - sender.sendMessage(FightSystem.PREFIX + "§cDas Replay konnte nicht gestartet werden."); + FightSystem.getMessage().sendPrefixless("REPLAY_UNAVAILABLE", sender, ChatMessageType.ACTION_BAR); + FightSystem.getPlugin().getLogger().log(Level.SEVERE, "Replay could not be started", e); } return false; } diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/commands/WinCommand.java b/FightSystem_Core/src/de/steamwar/fightsystem/commands/WinCommand.java index 776c4a0..9384c9a 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/commands/WinCommand.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/commands/WinCommand.java @@ -5,6 +5,7 @@ import de.steamwar.fightsystem.FightSystem; import de.steamwar.fightsystem.fight.Fight; import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.StateDependentCommand; +import net.md_5.bungee.api.ChatMessageType; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; @@ -24,12 +25,12 @@ public class WinCommand implements CommandExecutor { Player p = (Player) sender; if (p != FightSystem.getEventLeiter()) { - p.sendMessage(FightSystem.PREFIX + "§cDu bist kein Kampfleiter!"); + FightSystem.getMessage().sendPrefixless("NOT_FIGHTLEADER", p, ChatMessageType.ACTION_BAR); return false; } if(args.length == 0){ - p.sendMessage(FightSystem.PREFIX + "/win [Team or Tie]"); + FightSystem.getMessage().sendPrefixless("WIN_HELP", p); return false; } diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/countdown/Countdown.java b/FightSystem_Core/src/de/steamwar/fightsystem/countdown/Countdown.java index 8c8997f..9a74910 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/countdown/Countdown.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/countdown/Countdown.java @@ -21,12 +21,10 @@ package de.steamwar.fightsystem.countdown; import de.steamwar.fightsystem.FightSystem; import de.steamwar.fightsystem.fight.Fight; -import de.steamwar.fightsystem.listener.BasicListener; import de.steamwar.fightsystem.record.GlobalRecorder; import de.steamwar.fightsystem.utils.FightUI; import de.steamwar.fightsystem.utils.SWSound; -import net.md_5.bungee.api.chat.BaseComponent; -import net.md_5.bungee.api.chat.TextComponent; +import net.md_5.bungee.api.ChatMessageType; import org.bukkit.Bukkit; import org.bukkit.Sound; import org.bukkit.entity.Player; @@ -81,22 +79,30 @@ public abstract class Countdown { smallestTime = countdown.time; } - smallestTime--; for(Countdown countdown : currentCountdowns){ countdown.time -= smallestTime; + if(countdown.time <= 1) + countdown.prepareFinish(); countdown.show(); } FightUI.addSubtitle("§7Sprung zum nächsten Ereignis"); } - private void broadcast(String message){ - GlobalRecorder.getInstance().actionBar(message); - BaseComponent[] msg = TextComponent.fromLegacyText(message); - for(Player p : Bukkit.getOnlinePlayers()) - BasicListener.toActionbar(p, msg); + public static void sendCountdownMessage(Player p, String message, int displaytime, String appendix) { + FightSystem.getMessage().sendPrefixless(message, p, ChatMessageType.ACTION_BAR, displaytime, FightSystem.getMessage().parse(appendix, p)); } + protected void broadcast(String message, int divisor){ + if(this.sound != null && divisor == 1) + Fight.playSound(this.sound, 100.0F, 1.0F); + + GlobalRecorder.getInstance().countdown(message, divisor, countdownCounting()); + Bukkit.getOnlinePlayers().forEach(p -> sendCountdownMessage(p, message, time / divisor, countdownCounting())); + } + + protected void prepareFinish() {} + public int getTimeLeft(){ return time; } @@ -106,22 +112,17 @@ public abstract class Countdown { show(); } - void show(){ + private void show(){ switch (time) { case 900: case 600: case 300: case 180: case 120: - broadcast("§rNoch §a" + time / 60 + " §rMinuten " + countdownCounting()); + broadcast("COUNTDOWN_MINUTES", 60); break; case 60: case 30: case 20: case 15: case 10: case 5: case 4: case 3: case 2: - if(this.sound != null) - Fight.playSound(this.sound, 100.0F, 1.0F); - - broadcast("§rNoch §a" + time + " §rSekunden " + countdownCounting()); + broadcast("COUNTDOWN_SECONDS", 1); break; case 1: - if(this.sound != null) - Fight.playSound(this.sound, 100.0F, 1.0F); - - broadcast("§rNoch §aeine §rSekunde " + countdownCounting()); + prepareFinish(); + broadcast("COUNTDOWN_SECOND", 1); break; case 0: if(this.sound != null) diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/countdown/EnternCountdown.java b/FightSystem_Core/src/de/steamwar/fightsystem/countdown/EnternCountdown.java index ec78cc6..1ecc374 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/countdown/EnternCountdown.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/countdown/EnternCountdown.java @@ -22,11 +22,9 @@ package de.steamwar.fightsystem.countdown; import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.FightSystem; import de.steamwar.fightsystem.fight.FightPlayer; -import de.steamwar.fightsystem.listener.BasicListener; import de.steamwar.fightsystem.utils.SWSound; import de.steamwar.fightsystem.utils.TechHider; -import net.md_5.bungee.api.chat.TextComponent; -import org.bukkit.entity.Player; +import net.md_5.bungee.api.ChatMessageType; import java.util.List; @@ -43,41 +41,23 @@ public class EnternCountdown extends Countdown { @Override public String countdownCounting() { - return "bis Entern erlaubt ist!"; + return "ENTERN_COUNTDOWN"; } @Override public void countdownFinished() { - fightPlayer.getPlayer().sendMessage(FightSystem.PREFIX + "§aEntern ist nun erlaubt!"); + FightSystem.getMessage().sendPrefixless("ENTERN_ALLOWED", fightPlayer.getPlayer(), ChatMessageType.ACTION_BAR); TechHider.reloadChunks(fightPlayer.getPlayer(), chunkPos, false); } @Override - void show(){ - Player player = fightPlayer.getPlayer(); - switch (time) { - case 900: case 600: case 300: case 180: case 120: - BasicListener.toActionbar(player, TextComponent.fromLegacyText("§rNoch §a" + time / 60 + " §rMinuten " + countdownCounting())); - break; - case 60: case 30: case 20: case 15: case 10: case 5: case 4: case 3: case 2: - player.playSound(player.getLocation(), sound, 100.0F, 1.0F); + protected void prepareFinish() { + chunkPos = TechHider.prepareChunkReload(fightPlayer.getPlayer(), false); + } - BasicListener.toActionbar(player, TextComponent.fromLegacyText("§rNoch §a" + time + " §rSekunden " + countdownCounting())); - break; - case 1: - player.playSound(player.getLocation(), sound, 100.0F, 1.0F); - - BasicListener.toActionbar(player, TextComponent.fromLegacyText("§rNoch §a1 §rSekunde " + countdownCounting())); - - chunkPos = TechHider.prepareChunkReload(player, false); - break; - case 0: - player.playSound(player.getLocation(), sound, 100.0F, 2.0F); - - disable(); - countdownFinished(); - break; - default: - } + @Override + protected void broadcast(String message, int divisor) { + fightPlayer.getPlayer().playSound(fightPlayer.getPlayer().getLocation(), sound, 100.0f, 1.0f); + sendCountdownMessage(fightPlayer.getPlayer(), message, time / divisor, countdownCounting()); } } diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/countdown/EventSpectateCountdown.java b/FightSystem_Core/src/de/steamwar/fightsystem/countdown/EventSpectateCountdown.java index a26a14d..61be26c 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/countdown/EventSpectateCountdown.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/countdown/EventSpectateCountdown.java @@ -35,7 +35,7 @@ public class EventSpectateCountdown extends Countdown { @Override public String countdownCounting() { - return "bis der Server gestoppt wird!"; + return "SHUTDOWN_COUNTDOWN"; } @Override diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/countdown/NoPlayersOnlineCountdown.java b/FightSystem_Core/src/de/steamwar/fightsystem/countdown/NoPlayersOnlineCountdown.java index 5ab54d7..3b688f1 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/countdown/NoPlayersOnlineCountdown.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/countdown/NoPlayersOnlineCountdown.java @@ -35,7 +35,7 @@ public class NoPlayersOnlineCountdown extends Countdown implements Listener { super(Config.NoPlayerOnlineDuration, null, false); new StateDependentListener(ArenaMode.AntiReplay, FightState.PreLeaderSetup, this); - new StateDependentCountdown(ArenaMode.AntiReplay, FightState.PreLeaderSetup, this){ + new StateDependentCountdown(ArenaMode.AntiReplay, FightState.PreLeaderSetup, this) { @Override public void enable() { if(Bukkit.getOnlinePlayers().isEmpty()) @@ -46,7 +46,7 @@ public class NoPlayersOnlineCountdown extends Countdown implements Listener { @Override public String countdownCounting() { - return "bis der Server gestoppt wird!"; + return "SHUTDOWN_COUNTDOWN"; } @EventHandler diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/countdown/PostSchemCountdown.java b/FightSystem_Core/src/de/steamwar/fightsystem/countdown/PostSchemCountdown.java index a388fbd..70c3f79 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/countdown/PostSchemCountdown.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/countdown/PostSchemCountdown.java @@ -34,7 +34,7 @@ public class PostSchemCountdown extends Countdown { @Override public String countdownCounting() { - return "bis die Kits verteilt werden!"; + return "POST_SCHEM_COUNTDOWN"; } @Override diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/countdown/PreRunningCountdown.java b/FightSystem_Core/src/de/steamwar/fightsystem/countdown/PreRunningCountdown.java index 9a5dac4..faca110 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/countdown/PreRunningCountdown.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/countdown/PreRunningCountdown.java @@ -35,7 +35,7 @@ public class PreRunningCountdown extends Countdown { @Override public String countdownCounting() { - return "bis die Arena freigegeben ist!"; + return "PRE_RUNNING_COUNTDOWN"; } @Override diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/countdown/PreSchemCountdown.java b/FightSystem_Core/src/de/steamwar/fightsystem/countdown/PreSchemCountdown.java index f9c007a..61547c9 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/countdown/PreSchemCountdown.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/countdown/PreSchemCountdown.java @@ -35,7 +35,7 @@ public class PreSchemCountdown extends Countdown { @Override public String countdownCounting() { - return "bis eine Public-Schematic gewählt wird!"; + return "PRE_SCHEM_COUNTDOWN"; } @Override diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/countdown/SpectateOverCountdown.java b/FightSystem_Core/src/de/steamwar/fightsystem/countdown/SpectateOverCountdown.java index 92ac120..9d330c7 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/countdown/SpectateOverCountdown.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/countdown/SpectateOverCountdown.java @@ -35,7 +35,7 @@ public class SpectateOverCountdown extends Countdown { @Override public String countdownCounting() { - return "bis die Arena zurückgesetzt wird!"; + return "SPECTATE_COUNTDOWN"; } @Override diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/countdown/TimeOverCountdown.java b/FightSystem_Core/src/de/steamwar/fightsystem/countdown/TimeOverCountdown.java index 5232087..14d269b 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/countdown/TimeOverCountdown.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/countdown/TimeOverCountdown.java @@ -33,7 +33,7 @@ public class TimeOverCountdown extends Countdown { @Override public String countdownCounting() { - return "bis der Kampf vorbei ist!"; + return "RUNNING_COUNTDOWN"; } @Override diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/event/HellsBells.java b/FightSystem_Core/src/de/steamwar/fightsystem/event/HellsBells.java index a19a3ae..da03e38 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/event/HellsBells.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/event/HellsBells.java @@ -22,9 +22,9 @@ package de.steamwar.fightsystem.event; import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.FightSystem; import de.steamwar.fightsystem.countdown.Countdown; -import de.steamwar.fightsystem.utils.SWSound; import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.StateDependent; +import de.steamwar.fightsystem.utils.SWSound; import de.steamwar.fightsystem.winconditions.Winconditions; import org.bukkit.Bukkit; import org.bukkit.Location; @@ -32,8 +32,6 @@ import org.bukkit.World; import org.bukkit.entity.EntityType; import org.bukkit.scheduler.BukkitTask; -import java.util.Arrays; -import java.util.List; import java.util.Random; import java.util.concurrent.atomic.AtomicInteger; import java.util.logging.Level; @@ -50,23 +48,11 @@ public class HellsBells { private int currentDrops = 0; private HellsBellsCountdown currentCountdown; private BukkitTask currentDropping; - private final List startMessages = Arrays.asList("§c!!Achtung!! Bomber im Anflug, noch ca. eine Minute bis zur Ankunft.", - "§cBomber im Anflug, ca. eine Minute bis zur Ankunft.", - "§cBomber auf dem Radar gesichtet, geschätzte Ankunftszeit: eine Minute.", - "§cUnbekanntes Flugobjekt gesichtet, trifft in ca. einer Minute ein.", - "§cFlugobjekt gesichtet. Ankunft in ca. einer Minute.", - "§cBomber erschienen, Ankunft ca. eine Minute."); - private final List stateSwapMessages = Arrays.asList("§aDie Bomben fallen nun schneller.", - "§aMehr Bomber im Anflug.", - "§aZusätzliche Bomber gesichtet.", - "§aDas Bombardement scheint sich zu erhöhen."); public void startCountdown() { if (current == State.PRE) { - FightSystem.broadcast(startMessages.get(random.nextInt(startMessages.size()))); current = current.getNext(); } else if (current != State.LAST && currentDrops >= current.SWITCH_AFTER) { - FightSystem.broadcast(stateSwapMessages.get(random.nextInt(stateSwapMessages.size()))); currentDrops = 0; } @@ -80,7 +66,6 @@ public class HellsBells { AtomicInteger length = new AtomicInteger(20 + random.nextInt(direction.getLength(zLength, xLength) - 20)); int width = 5 + random.nextInt(5); - Bukkit.getLogger().log(Level.INFO, "Calculating Starts"); int xOffset = getStart(direction.getLength(xLength, zLength), direction.getLength(length.get(), width)); int zOffset = getStart(direction.getLength(zLength, xLength), direction.getLength(width, length.get())); int yOffset = getHeightStart(); @@ -145,7 +130,7 @@ public class HellsBells { @Override public String countdownCounting() { - return "bis die Bomben fallen"; + return "HELLS_BELLS_COUNTDOWN"; } @Override diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/fight/FightPlayer.java b/FightSystem_Core/src/de/steamwar/fightsystem/fight/FightPlayer.java index f0c59bf..f86bb61 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/fight/FightPlayer.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/fight/FightPlayer.java @@ -34,10 +34,6 @@ public class FightPlayer { private int kills; private EnternCountdown enternCountdown = null; - public void sendMessage(String message) { - this.player.sendMessage(message); - } - FightPlayer(Player player, FightTeam team) { this.player = player; this.team = team; diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/fight/FightSchematic.java b/FightSystem_Core/src/de/steamwar/fightsystem/fight/FightSchematic.java index 2c91709..1465c70 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/fight/FightSchematic.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/fight/FightSchematic.java @@ -72,7 +72,7 @@ public class FightSchematic extends StateDependent { try { clipboard = schem.load(); } catch (IOException e) { - team.broadcast("§cSchematic konnte nicht geladen werden"); + team.broadcastSystem("SCHEMATIC_UNLOADABLE"); Bukkit.getLogger().log(Level.SEVERE, e, () -> "Couldn't load Schematic " + schem.getSchemName()); } } diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/fight/FightTeam.java b/FightSystem_Core/src/de/steamwar/fightsystem/fight/FightTeam.java index 7696963..c9c56d9 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/fight/FightTeam.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/fight/FightTeam.java @@ -34,6 +34,7 @@ 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.ChatMessageType; import net.md_5.bungee.api.chat.BaseComponent; import net.md_5.bungee.api.chat.TextComponent; import org.bukkit.*; @@ -186,9 +187,12 @@ public class FightTeam { } } - public void broadcast(String message) { - BaseComponent[] msg = TextComponent.fromLegacyText(message); - players.forEach((player, fp) -> BountifulWrapper.impl.toActionbar(player, msg)); + public void broadcast(String message, Object... params) { + players.forEach((player, fp) -> FightSystem.getMessage().sendPrefixless(message, player, ChatMessageType.ACTION_BAR, params)); + } + + public void broadcastSystem(String message, Object... params) { + players.forEach((player, fp) -> FightSystem.getMessage().send(message, player, params)); } public void broadcastChat(String message) { diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/record/PacketProcessor.java b/FightSystem_Core/src/de/steamwar/fightsystem/record/PacketProcessor.java index 6324d15..656af58 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/record/PacketProcessor.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/record/PacketProcessor.java @@ -24,6 +24,7 @@ import de.steamwar.core.Core; import de.steamwar.fightsystem.ArenaMode; import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.FightSystem; +import de.steamwar.fightsystem.countdown.Countdown; import de.steamwar.fightsystem.countdown.EventSpectateCountdown; import de.steamwar.fightsystem.fight.Fight; import de.steamwar.fightsystem.fight.FightTeam; @@ -102,6 +103,7 @@ public class PacketProcessor { packetDecoder[0xa0] = () -> send(ChatMessageType.CHAT); packetDecoder[0xa1] = () -> send(ChatMessageType.ACTION_BAR); packetDecoder[0xa2] = () -> send(ChatMessageType.SYSTEM); + packetDecoder[0xa3] = this::countdown; packetDecoder[0xb0] = () -> pasteSchem(Fight.getBlueTeam()); packetDecoder[0xb1] = () -> pasteSchem(Fight.getRedTeam()); packetDecoder[0xb2] = this::teams; @@ -248,6 +250,14 @@ public class PacketProcessor { }); } + private void countdown() throws IOException { + String message = source.readUTF(); + int displaytime = source.readInt(); + String appendix = source.readUTF(); + + Bukkit.getOnlinePlayers().forEach(p -> Countdown.sendCountdownMessage(p, message, displaytime, appendix)); + } + private void arenaInfo() throws IOException { rotateZ = source.readBoolean() != Config.blueNegZ(); arenaMinY = Byte.toUnsignedInt(source.readByte()); diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/record/Recorder.java b/FightSystem_Core/src/de/steamwar/fightsystem/record/Recorder.java index e75a016..903ddcf 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/record/Recorder.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/record/Recorder.java @@ -108,8 +108,9 @@ public interface Recorder { * * * ChatPacket (0xA0) + String message - * ActionBarPacket (0xA1) + String message + * DEPRECATED ActionBarPacket (0xA1) + String message * SystemPacket (0xA2) + String message + * CountdownPacket (0xA3) + String message, int displaytime, String appendix * * BlueSchemPacket (0xB0) + int blueSchemId * RedSchemPacket (0xB1) + int redSchemId @@ -228,14 +229,14 @@ public interface Recorder { write(0xa0, s); } - default void actionBar(String s) { - write(0xa1, s); - } - default void systemChat(String s) { write(0xa2, s); } + default void countdown(String message, int displaytime, String appendix) { + write(0xa3, message, displaytime, appendix); + } + default void teamIds(int blueTeamId, int redTeamId) { write(0xb2, blueTeamId, redTeamId); } diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionTimeTechKO.java b/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionTimeTechKO.java index 0e4d069..88fbf70 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionTimeTechKO.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionTimeTechKO.java @@ -115,6 +115,7 @@ public class WinconditionTimeTechKO extends Wincondition { @Override public final String countdownCounting() { + //TODO: ARRRG! return "bis " + team.getColoredName() + " §feinen Schuss abgegeben haben muss!"; } -- 2.39.2 From 6ee276ca826c3c798dfef09b5a64b7028c8ab687 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Thu, 7 Oct 2021 09:54:53 +0200 Subject: [PATCH 2/8] WIP multiling part 2 Signed-off-by: Lixfel --- .../fightsystem/utils/BountifulWrapper8.java | 20 ++------ .../fightsystem/utils/BountifulWrapper9.java | 12 ----- .../fightsystem/FightSystem.properties | 50 +++++++++++++++++++ .../steamwar/fightsystem/fight/FightTeam.java | 44 +++++++--------- .../de/steamwar/fightsystem/fight/Kit.java | 14 +++--- .../fightsystem/listener/ArenaBorder.java | 5 +- .../fightsystem/listener/BasicListener.java | 6 --- .../steamwar/fightsystem/listener/Chat.java | 10 ++-- .../steamwar/fightsystem/listener/Check.java | 5 +- .../listener/DenyWorldInteraction.java | 9 ++-- .../fightsystem/listener/EventJoin.java | 4 +- .../fightsystem/listener/HotbarGUI.java | 38 +++++--------- .../fightsystem/listener/InFightDamage.java | 5 +- .../listener/InFightInventory.java | 5 +- .../fightsystem/listener/Permanent.java | 6 +-- .../listener/PersonalKitCreator.java | 4 +- .../fightsystem/listener/ResourcePack.java | 3 +- .../fightsystem/listener/TeamArea.java | 13 ++--- .../fightsystem/listener/TestJoin.java | 2 +- .../fightsystem/record/PacketProcessor.java | 17 +------ .../states/StateDependentCommand.java | 3 +- .../fightsystem/utils/BountifulWrapper.java | 4 -- .../steamwar/fightsystem/utils/FightUI.java | 8 +-- 23 files changed, 134 insertions(+), 153 deletions(-) diff --git a/FightSystem_8/src/de/steamwar/fightsystem/utils/BountifulWrapper8.java b/FightSystem_8/src/de/steamwar/fightsystem/utils/BountifulWrapper8.java index 93d59fb..cd7a5ef 100644 --- a/FightSystem_8/src/de/steamwar/fightsystem/utils/BountifulWrapper8.java +++ b/FightSystem_8/src/de/steamwar/fightsystem/utils/BountifulWrapper8.java @@ -24,11 +24,11 @@ import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.listener.Recording; import de.steamwar.fightsystem.record.GlobalRecorder; import de.steamwar.fightsystem.record.REntity; -import net.md_5.bungee.api.chat.BaseComponent; -import net.minecraft.server.v1_8_R3.*; +import net.minecraft.server.v1_8_R3.DataWatcher; +import net.minecraft.server.v1_8_R3.EntityEnderDragon; +import net.minecraft.server.v1_8_R3.PacketPlayOutEntityMetadata; +import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntityLiving; import net.royawesome.jlibnoise.MathHelper; -import org.bukkit.Material; -import org.bukkit.World; import org.bukkit.*; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; import org.bukkit.entity.Player; @@ -56,18 +56,6 @@ public class BountifulWrapper8 implements BountifulWrapper.IBountifulWrapper { return p.getInventory().getItemInHand().getType() == Material.BOW; } - @Override - public void toActionbar(Player player, BaseComponent... components) { - PacketPlayOutChat packet = new PacketPlayOutChat(new ChatComponentText(BaseComponent.toLegacyText(components)), (byte)2); - ((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet); - } - - @Override - public void toChat(Player player, BaseComponent... components) { - PacketPlayOutChat packet = new PacketPlayOutChat(new ChatComponentText(BaseComponent.toLegacyText(components)), (byte)0); - ((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet); - } - @Override public void setAttackSpeed(Player player) { // nothing to do diff --git a/FightSystem_9/src/de/steamwar/fightsystem/utils/BountifulWrapper9.java b/FightSystem_9/src/de/steamwar/fightsystem/utils/BountifulWrapper9.java index cfeac37..0a57621 100644 --- a/FightSystem_9/src/de/steamwar/fightsystem/utils/BountifulWrapper9.java +++ b/FightSystem_9/src/de/steamwar/fightsystem/utils/BountifulWrapper9.java @@ -25,8 +25,6 @@ import de.steamwar.fightsystem.fight.FightTeam; import de.steamwar.fightsystem.listener.Recording; import de.steamwar.fightsystem.record.GlobalRecorder; import de.steamwar.fightsystem.record.REntity; -import net.md_5.bungee.api.ChatMessageType; -import net.md_5.bungee.api.chat.BaseComponent; import org.bukkit.*; import org.bukkit.attribute.Attribute; import org.bukkit.attribute.AttributeInstance; @@ -69,16 +67,6 @@ public class BountifulWrapper9 implements BountifulWrapper.IBountifulWrapper { return (mainHand ? p.getInventory().getItemInMainHand() : p.getInventory().getItemInOffHand()).getType() == Material.BOW; } - @Override - public void toActionbar(Player player, BaseComponent... components) { - player.spigot().sendMessage(ChatMessageType.ACTION_BAR, components); - } - - @Override - public void toChat(Player player, BaseComponent... components) { - player.spigot().sendMessage(ChatMessageType.CHAT, components); - } - @Override public void setAttackSpeed(Player player) { AttributeInstance attribute = player.getAttribute(Attribute.GENERIC_ATTACK_SPEED); diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/FightSystem.properties b/FightSystem_Core/src/de/steamwar/fightsystem/FightSystem.properties index 7fb8cef..f646e38 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/FightSystem.properties +++ b/FightSystem_Core/src/de/steamwar/fightsystem/FightSystem.properties @@ -113,6 +113,56 @@ SPECTATE_COUNTDOWN=bis die Arena zur # Fight SCHEMATIC_UNLOADABLE=§cSchematic konnte nicht geladen werden +SCHEMATIC_CHOSEN=§7{0} §e{1} §7gewählt +TEAM_READY=§aTeam bereit +TEAM_NOT_READY=§c§mTeam bereit +SKIP_READY=§aBeschleunigung zum nächsten Event +SKIP_NOT_READY=§c§mBeschleunigung zum nächsten Event +TEAM_CHAT={0}{1}§8» {0}{2} +CHOOSE_KIT=§eKit wählen +RESPAWN=§eRespawn +INVITE_PLAYERS=§eSpieler einladen +REMOVE_PLAYERS=§cSpieler rauswerfen +CHOOSE_SCHEMATIC=§e{0} wählen +SCHEMATIC_REQUIRED=§cZuerst muss eine Schematic gewählt sein + +KIT_PREVIEW_EDIT=§7Kit bearbeiten +KIT_PREVIEW_CHOOSE=§aKit wählen +KIT_PREVIEW_BACK=§cZurück +KIT_PREVIEW_DELETE=§cKit löschen +KIT_DELETION_CONFIRMATION=Kit wirklich löschen? +KIT_DELETION_ABORT=§cAbbrechen +KIT_DELETION_DELETE=§aLöschen + + +# Listener +NO_ARENA_LEAVING=§cDu darfst die Arena nicht verlassen +CHECK_JOIN_DENIED=§cAuf diesem Server wird momentan eine Schematic geprüft! +CHECK_COMMAND_LOCKED=§cDieser Befehl ist beim Prüfen gesperrt! Admin wird benachrichtigt. +NO_BLOCK_BREAK=§cDu darfst derzeit keine Blöcke abbauen +NO_BLOCK_PLACE=§cDu darfst derzeit keine Blöcke setzen +NO_BOW_USAGE=§cDu darfst den Bogen erst nach Kampfbeginn nutzen +NO_PARTICIPANT=§cDu bist kein Kampfteilnehmer +NO_FRIENDLY_FIRE=§cDu darfst deinen Teamkollegen keinen Schaden zufügen +NO_TNT_PLACE=§cDu darfst kein TNT setzen +NO_TELEPORT=§cDu darfst diese Teleportfunktion nicht benutzen +OPEN_INVENTORY_TO_CUSTOMIZE=§eInventar zum Anpassen des Kits öffnen +RESOURCEPACK_REQUIRED=§cAuf Eventserver kann nur mit dem SteamWar-Resourcepack beigetreten werden\n§cDa du abgelehnt hast, musst du nun in der Serverliste erst einmal wieder Ressourcenpakete von SteamWar aktivieren +NO_ENTERN=§cDu darfst nicht entern +NO_TEAMAREA=§cDu darfst nicht zu den Teams +TEST_BECOME_LEADER=§7Werde zum Teamleader mit §8/§eleader + + +# Replay +REPLAY_ENDS=§cReplay beendet + + +# States +COMMAND_CURRENTLY_UNAVAILABLE=§cDieser Befehl ist zu diesem Kampfzeitpunkt nicht verfügbar + + +# Utils +TPS_WARNING=§c{0} §7TPS # Winconditions diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/fight/FightTeam.java b/FightSystem_Core/src/de/steamwar/fightsystem/fight/FightTeam.java index c9c56d9..16d4579 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/fight/FightTeam.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/fight/FightTeam.java @@ -35,8 +35,6 @@ import de.steamwar.inventory.SWItem; import de.steamwar.sql.Schematic; import de.steamwar.sql.SteamwarUser; import net.md_5.bungee.api.ChatMessageType; -import net.md_5.bungee.api.chat.BaseComponent; -import net.md_5.bungee.api.chat.TextComponent; import org.bukkit.*; import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.Player; @@ -45,7 +43,6 @@ import org.bukkit.scoreboard.NameTagVisibility; import org.bukkit.scoreboard.Team; import java.util.*; -import java.util.logging.Level; public class FightTeam { @@ -195,10 +192,8 @@ public class FightTeam { players.forEach((player, fp) -> FightSystem.getMessage().send(message, player, params)); } - public void broadcastChat(String message) { - FightSystem.getPlugin().getLogger().log(Level.INFO, message); - BaseComponent[] msg = TextComponent.fromLegacyText(message); - players.forEach((player, fp) -> BountifulWrapper.impl.toChat(player, msg)); + public void broadcastChat(Player sender, String message) { + players.forEach((player, fp) -> FightSystem.getMessage().sendPrefixless("TEAM_CHAT", player, ChatMessageType.CHAT, prefix, sender.getName(), message)); } public void addMember(Player player) { @@ -215,8 +210,8 @@ public class FightTeam { BountifulWrapper.impl.setAttackSpeed(player); player.teleport(spawn); 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()); + player.getInventory().setItem(1, new ItemBuilder(Material.LEATHER_CHESTPLATE).removeAllAttributs().addEnchantment(Enchantment.DURABILITY, 1).setDisplayName(FightSystem.getMessage().parse("CHOOSE_KIT", player)).build()); + player.getInventory().setItem(7, new ItemBuilder(Material.BEACON).removeAllAttributs().setDisplayName(FightSystem.getMessage().parse("RESPAWN", player)).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); @@ -293,23 +288,22 @@ public class FightTeam { if(!Config.PersonalKits) leader.setKit(Kit.getKitByName(Config.LeaderDefault)); + Player player = leader.getPlayer(); Inventory inventory = leader.getPlayer().getInventory(); - if (Kit.getAvailableKits(true).size() > 1) - inventory.setItem(1, new ItemBuilder(Material.LEATHER_CHESTPLATE).removeAllAttributs().addEnchantment(Enchantment.DURABILITY, 1).setDisplayName("§eKit wählen").build()); - else if(Config.PersonalKits) - inventory.setItem(1, new ItemBuilder(Material.LEATHER_CHESTPLATE).removeAllAttributs().addEnchantment(Enchantment.DURABILITY, 1).setDisplayName("§eKit bearbeiten").build()); + if (Kit.getAvailableKits(true).size() > 1 || Config.PersonalKits) + inventory.setItem(1, new ItemBuilder(Material.LEATHER_CHESTPLATE).removeAllAttributs().addEnchantment(Enchantment.DURABILITY, 1).setDisplayName(FightSystem.getMessage().parse("CHOOSE_KIT", player)).build()); else inventory.setItem(1, new ItemBuilder(Material.AIR).build()); if(!ArenaMode.RankedEvent.contains(Config.mode)){ - inventory.setItem(2, new ItemBuilder(Material.PAPER).removeAllAttributs().setDisplayName("§eSpieler einladen").build()); - inventory.setItem(3, new ItemBuilder(SWItem.getMaterial("FIREWORK_CHARGE")).removeAllAttributs().setDisplayName("§cSpieler rauswerfen").build()); + inventory.setItem(2, new ItemBuilder(Material.PAPER).removeAllAttributs().setDisplayName(FightSystem.getMessage().parse("INVITE_PLAYERS", player)).build()); + inventory.setItem(3, new ItemBuilder(SWItem.getMaterial("FIREWORK_CHARGE")).removeAllAttributs().setDisplayName(FightSystem.getMessage().parse("REMOVE_PLAYERS", player)).build()); } - inventory.setItem(4, new ItemBuilder(SWItem.getDye(10), (short) 10).removeAllAttributs().addEnchantment(Enchantment.DURABILITY, 1).setDisplayName("§cNicht bereit").build()); + inventory.setItem(4, new ItemBuilder(SWItem.getDye(10), (short) 10).removeAllAttributs().addEnchantment(Enchantment.DURABILITY, 1).setDisplayName(FightSystem.getMessage().parse("TEAM_NOT_READY", player)).build()); if(Config.test() || FightState.getFightState() != FightState.POST_SCHEM_SETUP) - inventory.setItem(0, new ItemBuilder(SWItem.getMaterial("CAULDRON_ITEM")).removeAllAttributs().addEnchantment(Enchantment.DURABILITY, 1).setDisplayName("§e" + Config.GameName + " wählen").build()); + inventory.setItem(0, new ItemBuilder(SWItem.getMaterial("CAULDRON_ITEM")).removeAllAttributs().addEnchantment(Enchantment.DURABILITY, 1).setDisplayName(FightSystem.getMessage().parse("CHOOSE_SCHEMATIC", player, Config.GameName)).build()); if(FightState.getFightState() == FightState.PRE_LEADER_SETUP && !Fight.getOpposite(this).isLeaderless()){ FightSystem.setPreSchemState(); @@ -348,40 +342,40 @@ public class FightTeam { public void setSchem(Schematic schematic){ this.schematic.setSchematic(schematic); - broadcast("§e" + Config.GameName + " " + schematic.getSchemName() + " §7gewählt"); + broadcast("SCHEMATIC_CHOSEN", Config.GameName, schematic.getSchemName()); } public void setReady(boolean ready) { Player l = leader.getPlayer(); if(!schematic.hasSchematic()){ - BountifulWrapper.impl.toActionbar(l, TextComponent.fromLegacyText("§cZuerst muss eine Schematic gewählt sein!")); + FightSystem.getMessage().sendPrefixless("SCHEMATIC_REQUIRED", l, ChatMessageType.ACTION_BAR); return; } this.ready = ready; if(ready) { - l.getInventory().setItem(4, new ItemBuilder(SWItem.getDye(8), (short) 8).removeAllAttributs().addEnchantment(Enchantment.DURABILITY,1 ).setDisplayName("§aBereit").build()); - broadcast("§aTeam bereit"); + l.getInventory().setItem(4, new ItemBuilder(SWItem.getDye(8), (short) 8).removeAllAttributs().addEnchantment(Enchantment.DURABILITY,1 ).setDisplayName(FightSystem.getMessage().parse("TEAM_READY", l)).build()); + broadcast("TEAM_READY"); if(Fight.getOpposite(this).isReady() || ArenaMode.SoloLeader.contains(Config.mode)) FightSystem.setPreRunningState(); } else { - l.getInventory().setItem(4, new ItemBuilder(SWItem.getDye(10), (short) 10).removeAllAttributs().addEnchantment(Enchantment.DURABILITY, 1).setDisplayName("§cNicht bereit").build()); - broadcast("§c§mTeam bereit"); + l.getInventory().setItem(4, new ItemBuilder(SWItem.getDye(10), (short) 10).removeAllAttributs().addEnchantment(Enchantment.DURABILITY, 1).setDisplayName(FightSystem.getMessage().parse("TEAM_NOT_READY", l)).build()); + broadcast("TEAM_NOT_READY"); } } public void skip(){ this.skip = !skip; if(skip){ - broadcast("§aBeschleunigung zum nächsten Event"); + broadcast("SKIP_READY"); if(Fight.getOpposite(this).skip || Config.test()){ skip = false; Fight.getOpposite(this).skip = false; Countdown.skip(); } }else{ - broadcast("§c§mBeschleunigung zum nächsten Event"); + broadcast("SKIP_NOT_READY"); } } diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/fight/Kit.java b/FightSystem_Core/src/de/steamwar/fightsystem/fight/Kit.java index 84df9b5..798b6c8 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/fight/Kit.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/fight/Kit.java @@ -287,12 +287,12 @@ public class Kit { inv.setCallback(-999, click -> player.closeInventory()); if(Config.PersonalKits){ - inv.setItem(49, SWItem.getMaterial("WOOD_AXE"), "§7Kit bearbeiten", clickType -> PersonalKitCreator.openKitCreator(player, PersonalKit.get(SteamwarUser.get(player.getUniqueId()).getId(), Config.SchematicType.toDB(), name))); - inv.setItem(53, Material.BARRIER, "§cKit löschen", clickType -> { + inv.setItem(49, SWItem.getMaterial("WOOD_AXE"), FightSystem.getMessage().parse("KIT_PREVIEW_EDIT", player), clickType -> PersonalKitCreator.openKitCreator(player, PersonalKit.get(SteamwarUser.get(player.getUniqueId()).getId(), Config.SchematicType.toDB(), name))); + inv.setItem(53, Material.BARRIER, FightSystem.getMessage().parse("KIT_PREVIEW_DELETE", player), clickType -> { player.closeInventory(); - SWInventory conf = new SWInventory(player, 9, "Kit wirklich löchen?"); - conf.setItem(8, SWItem.getDye(1), "§cAbbrechen", click -> player.closeInventory()); - conf.setItem(0, SWItem.getDye(10), "§aLöschen", click -> { + SWInventory conf = new SWInventory(player, 9, FightSystem.getMessage().parse("KIT_DELETION_CONFIRMATION", player)); + conf.setItem(8, SWItem.getDye(1), FightSystem.getMessage().parse("KIT_DELETION_ABORT", player), click -> player.closeInventory()); + conf.setItem(0, SWItem.getDye(10), FightSystem.getMessage().parse("KIT_DELETION_DELETE", player), click -> { player.closeInventory(); SteamwarUser user = SteamwarUser.get(player.getUniqueId()); PersonalKit kit = PersonalKit.get(user.getId(), Config.SchematicType.toDB(), name); @@ -311,11 +311,11 @@ public class Kit { conf.open(); }); } - inv.setItem(45, SWItem.getDye(10), (byte)10, "§aKit wählen", click -> { + inv.setItem(45, SWItem.getDye(10), (byte)10, FightSystem.getMessage().parse("KIT_PREVIEW_CHOOSE", player), click -> { Commands.kit(player, name); player.closeInventory(); }); - inv.setItem(53, SWItem.getDye(1), (byte)1, "§cZurück", click -> GUI.kitSelection(player, "")); + inv.setItem(53, SWItem.getDye(1), (byte)1, FightSystem.getMessage().parse("KIT_PREVIEW_BACK", player), click -> GUI.kitSelection(player, "")); inv.open(); } diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/listener/ArenaBorder.java b/FightSystem_Core/src/de/steamwar/fightsystem/listener/ArenaBorder.java index 5c39bd4..c51fb06 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/listener/ArenaBorder.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/listener/ArenaBorder.java @@ -21,11 +21,12 @@ package de.steamwar.fightsystem.listener; 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.states.FightState; import de.steamwar.fightsystem.states.StateDependentListener; -import net.md_5.bungee.api.chat.TextComponent; +import net.md_5.bungee.api.ChatMessageType; import org.bukkit.GameMode; import org.bukkit.Location; import org.bukkit.entity.Player; @@ -70,6 +71,6 @@ public class ArenaBorder implements Listener { private void reset(PlayerMoveEvent event){ Player player = event.getPlayer(); player.teleport(event.getFrom()); - BasicListener.toActionbar(player, TextComponent.fromLegacyText("§cDu darfst die Arena nicht verlassen")); + FightSystem.getMessage().sendPrefixless("NO_ARENA_LEAVING", player, ChatMessageType.ACTION_BAR); } } diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/listener/BasicListener.java b/FightSystem_Core/src/de/steamwar/fightsystem/listener/BasicListener.java index f63dc1c..0a32205 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/listener/BasicListener.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/listener/BasicListener.java @@ -20,8 +20,6 @@ package de.steamwar.fightsystem.listener; import de.steamwar.fightsystem.fight.Fight; -import de.steamwar.fightsystem.utils.BountifulWrapper; -import net.md_5.bungee.api.chat.BaseComponent; import org.bukkit.entity.Player; public class BasicListener { @@ -30,8 +28,4 @@ public class BasicListener { public static boolean notFighting(Player p){ return Fight.getFightPlayer(p) == null; } - - public static void toActionbar(Player player, BaseComponent... components){ - BountifulWrapper.impl.toActionbar(player, components); - } } diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/listener/Chat.java b/FightSystem_Core/src/de/steamwar/fightsystem/listener/Chat.java index ec5ee6b..fa5ab7f 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/listener/Chat.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/listener/Chat.java @@ -19,6 +19,7 @@ package de.steamwar.fightsystem.listener; +import de.steamwar.core.BountifulWrapper; import de.steamwar.fightsystem.ArenaMode; import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.FightSystem; @@ -27,7 +28,7 @@ import de.steamwar.fightsystem.fight.FightTeam; import de.steamwar.fightsystem.record.GlobalRecorder; import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.StateDependentListener; -import de.steamwar.fightsystem.utils.BountifulWrapper; +import net.md_5.bungee.api.ChatMessageType; import net.md_5.bungee.api.chat.BaseComponent; import net.md_5.bungee.api.chat.TextComponent; import org.bukkit.Bukkit; @@ -49,11 +50,12 @@ public class Chat implements Listener { Player player = event.getPlayer(); String message = event.getMessage(); + FightSystem.getPlugin().getLogger().log(Level.INFO, player.getName() + "» " + message); FightTeam fightTeam = Fight.getPlayerTeam(player); if(fightTeam != null) { String teamName = fightTeam.getColoredName(); if(message.startsWith(Config.TeamChatDetection)) { - fightTeam.broadcastChat(teamName + " " + player.getName() + "» " + message.substring(1)); + fightTeam.broadcastChat(player, message.substring(1)); } else { broadcastChat(teamName + " " + player.getName() + "§8» §7" + message); } @@ -68,9 +70,7 @@ public class Chat implements Listener { private void broadcastChat(String message) { GlobalRecorder.getInstance().chat(message); - FightSystem.getPlugin().getLogger().log(Level.INFO, message); BaseComponent[] msg = TextComponent.fromLegacyText(message); - for(Player p : Bukkit.getOnlinePlayers()) - BountifulWrapper.impl.toChat(p, msg); + Bukkit.getOnlinePlayers().forEach(p -> BountifulWrapper.impl.sendMessage(p, ChatMessageType.CHAT, msg)); } } diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/listener/Check.java b/FightSystem_Core/src/de/steamwar/fightsystem/listener/Check.java index 0681294..a12b187 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/listener/Check.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/listener/Check.java @@ -21,6 +21,7 @@ package de.steamwar.fightsystem.listener; import de.steamwar.fightsystem.ArenaMode; import de.steamwar.fightsystem.Config; +import de.steamwar.fightsystem.FightSystem; import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.StateDependentListener; import de.steamwar.sql.Schematic; @@ -53,7 +54,7 @@ public class Check implements Listener { if(user.getId() == schem.getSchemOwner()) return; - player.sendMessage("§cAuf diesem Server wird momentan eine Schematic geprüft!"); + FightSystem.getMessage().send("CHECK_JOIN_DENIED", player); player.kickPlayer(""); } @@ -64,7 +65,7 @@ public class Check implements Listener { return; event.setCancelled(true); - player.sendMessage("§cDieser Befehl ist beim Prüfen gesperrt! Admin wird benachrichtigt."); + FightSystem.getMessage().send("CHECK_COMMAND_LOCKED", player); Bukkit.getLogger().log(Level.SEVERE, player.getName() + " tried to use a copy command!"); } diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/listener/DenyWorldInteraction.java b/FightSystem_Core/src/de/steamwar/fightsystem/listener/DenyWorldInteraction.java index 579d303..f706462 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/listener/DenyWorldInteraction.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/listener/DenyWorldInteraction.java @@ -20,10 +20,11 @@ package de.steamwar.fightsystem.listener; import de.steamwar.fightsystem.ArenaMode; +import de.steamwar.fightsystem.FightSystem; import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.StateDependentListener; import de.steamwar.fightsystem.utils.BountifulWrapper; -import net.md_5.bungee.api.chat.TextComponent; +import net.md_5.bungee.api.ChatMessageType; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; @@ -50,14 +51,14 @@ public class DenyWorldInteraction implements Listener { public void handleBlockBreak(BlockBreakEvent event) { Player player = event.getPlayer(); event.setCancelled(true); - BasicListener.toActionbar(player, TextComponent.fromLegacyText("§cDu darfst derzeit keine Blöcke abbauen!")); + FightSystem.getMessage().sendPrefixless("NO_BLOCK_BREAK", player, ChatMessageType.ACTION_BAR); } @EventHandler public void handleBlockPlace(BlockPlaceEvent event) { Player player = event.getPlayer(); event.setCancelled(true); - BasicListener.toActionbar(player, TextComponent.fromLegacyText("§cDu darfst derzeit keine Blöcke setzen!")); + FightSystem.getMessage().sendPrefixless("NO_BLOCK_PLACE", player, ChatMessageType.ACTION_BAR); } @EventHandler @@ -88,7 +89,7 @@ public class DenyWorldInteraction implements Listener { event.setCancelled(true); if(event.getEntity().getShooter() instanceof Player){ Player player = (Player) event.getEntity().getShooter(); - BasicListener.toActionbar(player, TextComponent.fromLegacyText("§cDu darfst den Bogen erst nach Kampfbeginn nutzen!")); + FightSystem.getMessage().sendPrefixless("NO_BOW_USAGE", player, ChatMessageType.ACTION_BAR); } } } diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/listener/EventJoin.java b/FightSystem_Core/src/de/steamwar/fightsystem/listener/EventJoin.java index dc3cca0..9642c6d 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/listener/EventJoin.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/listener/EventJoin.java @@ -52,7 +52,7 @@ public class EventJoin implements Listener { user.getId() == FightSystem.getEventFight().getKampfleiter()) return; - event.disallow(PlayerLoginEvent.Result.KICK_OTHER, "§cDu bist kein Kampfteilnehmer"); + event.disallow(PlayerLoginEvent.Result.KICK_OTHER, FightSystem.getMessage().parse("NO_PARTICIPANT", player)); } @EventHandler @@ -90,7 +90,7 @@ public class EventJoin implements Listener { return; } if(Config.LiveReplay) - player.kickPlayer("§cDu bist kein Kampfteilnehmer"); + player.kickPlayer(FightSystem.getMessage().parse("NO_PARTICIPANT", player)); } @EventHandler diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/listener/HotbarGUI.java b/FightSystem_Core/src/de/steamwar/fightsystem/listener/HotbarGUI.java index 8b3b07f..2906a33 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/listener/HotbarGUI.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/listener/HotbarGUI.java @@ -21,6 +21,7 @@ package de.steamwar.fightsystem.listener; import de.steamwar.fightsystem.ArenaMode; import de.steamwar.fightsystem.Config; +import de.steamwar.fightsystem.FightSystem; import de.steamwar.fightsystem.commands.GUI; import de.steamwar.fightsystem.fight.Fight; import de.steamwar.fightsystem.fight.FightTeam; @@ -59,32 +60,17 @@ public class HotbarGUI implements Listener { if(displayName == null) return; - if(displayName.equals("§e" + Config.GameName + " wählen")){ - GUI.preSchemDialog(player); - return; - } + onMatch(player, displayName, "CHOOSE_SCHEMATIC", () -> GUI.preSchemDialog(player), Config.GameName); + onMatch(player, displayName, "INVITE_PLAYERS", () -> GUI.chooseInvitation(player)); + onMatch(player, displayName, "REMOVE_PLAYERS", () -> GUI.chooseRemove(player)); + onMatch(player, displayName, "TEAM_NOT_READY", () -> fightTeam.setReady(true)); + onMatch(player, displayName, "TEAM_READY", () -> fightTeam.setReady(false)); + onMatch(player, displayName, "CHOOSE_KIT", () -> GUI.kitSelection(player, "")); + onMatch(player, displayName, "RESPAWN", () -> player.teleport(fightTeam.getSpawn())); + } - switch (displayName) { - case "§cSpieler rauswerfen": - GUI.chooseRemove(player); - break; - case "§eSpieler einladen": - GUI.chooseInvitation(player); - break; - case "§cNicht bereit": - fightTeam.setReady(true); - break; - case "§aBereit": - fightTeam.setReady(false); - break; - case "§eKit bearbeiten": - case "§eKit wählen": - GUI.kitSelection(player, ""); - break; - case "§eRespawn": - player.teleport(fightTeam.getSpawn()); - break; - - } + private void onMatch(Player player, String displayName, String message, Runnable run, Object... params) { + if(displayName.equals(FightSystem.getMessage().parse(message, player, params))) + run.run(); } } diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/listener/InFightDamage.java b/FightSystem_Core/src/de/steamwar/fightsystem/listener/InFightDamage.java index f83f39a..921a2a8 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/listener/InFightDamage.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/listener/InFightDamage.java @@ -20,10 +20,11 @@ package de.steamwar.fightsystem.listener; import de.steamwar.fightsystem.ArenaMode; +import de.steamwar.fightsystem.FightSystem; import de.steamwar.fightsystem.fight.Fight; import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.StateDependentListener; -import net.md_5.bungee.api.chat.TextComponent; +import net.md_5.bungee.api.ChatMessageType; import org.bukkit.entity.Arrow; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -83,7 +84,7 @@ public class InFightDamage implements Listener { event.getDamager().setFireTicks(0); player.setFireTicks(0); } - BasicListener.toActionbar(damager, TextComponent.fromLegacyText("§cDu darfst deinen Teamkollegen keinen Schaden zufügen!")); + FightSystem.getMessage().sendPrefixless("NO_FRIENDLY_FIRE", damager, ChatMessageType.ACTION_BAR); } if(player.getHealth() - event.getFinalDamage() <= 0){ diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/listener/InFightInventory.java b/FightSystem_Core/src/de/steamwar/fightsystem/listener/InFightInventory.java index 70ae2ba..72d2857 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/listener/InFightInventory.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/listener/InFightInventory.java @@ -20,12 +20,13 @@ package de.steamwar.fightsystem.listener; import de.steamwar.fightsystem.ArenaMode; +import de.steamwar.fightsystem.FightSystem; import de.steamwar.fightsystem.fight.Fight; import de.steamwar.fightsystem.fight.FightPlayer; import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.StateDependentListener; import de.steamwar.fightsystem.utils.FlatteningWrapper; -import net.md_5.bungee.api.chat.TextComponent; +import net.md_5.bungee.api.ChatMessageType; import org.bukkit.Material; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; @@ -111,7 +112,7 @@ public class InFightInventory implements Listener { public void onBlockPlace(BlockPlaceEvent e) { FightPlayer fp = Fight.getFightPlayer(e.getPlayer()); if(fp != null && !fp.getKit().isTnt() && e.getBlockPlaced().getType() == Material.TNT){ - BasicListener.toActionbar(e.getPlayer(), TextComponent.fromLegacyText("§cDu darfst kein TNT setzen!")); + FightSystem.getMessage().sendPrefixless("NO_TNT_PLACE", e.getPlayer(), ChatMessageType.ACTION_BAR); e.setCancelled(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..f3de423 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/listener/Permanent.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/listener/Permanent.java @@ -29,7 +29,7 @@ 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 net.md_5.bungee.api.ChatMessageType; import org.bukkit.Bukkit; import org.bukkit.GameMode; import org.bukkit.entity.Player; @@ -64,8 +64,8 @@ public class Permanent implements Listener { public void onTpGM3(PlayerTeleportEvent e) { if (e.getCause() == PlayerTeleportEvent.TeleportCause.SPECTATE) { e.setCancelled(true); - BasicListener.toActionbar(e.getPlayer(), TextComponent.fromLegacyText("§cDu darfst diese Teleportfunktion nicht benutzen!")); - e.getPlayer().kickPlayer("§cDu darfst diese Teleportfunktion nicht benutzen!"); + FightSystem.getMessage().sendPrefixless("NO_TELEPORT", e.getPlayer(), ChatMessageType.ACTION_BAR); + e.getPlayer().kickPlayer(null); } } diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/listener/PersonalKitCreator.java b/FightSystem_Core/src/de/steamwar/fightsystem/listener/PersonalKitCreator.java index 297834f..ef57d60 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/listener/PersonalKitCreator.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/listener/PersonalKitCreator.java @@ -27,7 +27,7 @@ import de.steamwar.fightsystem.fight.Kit; import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.StateDependentListener; import de.steamwar.sql.PersonalKit; -import net.md_5.bungee.api.chat.TextComponent; +import net.md_5.bungee.api.ChatMessageType; import org.bukkit.Bukkit; import org.bukkit.GameMode; import org.bukkit.entity.HumanEntity; @@ -58,7 +58,7 @@ public class PersonalKitCreator implements Listener { new InventoryBackup(player, kit); new Kit(kit).loadToPlayer(player); player.setGameMode(GameMode.CREATIVE); - BasicListener.toActionbar(player, TextComponent.fromLegacyText("§eInventar zum Anpassen des Kits öffnen§8!")); + FightSystem.getMessage().sendPrefixless("OPEN_INVENTORY_TO_CUSTOMIZE", player, ChatMessageType.ACTION_BAR); } public static boolean inKitCreator(HumanEntity player){ diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/listener/ResourcePack.java b/FightSystem_Core/src/de/steamwar/fightsystem/listener/ResourcePack.java index dfe27c8..80bb614 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/listener/ResourcePack.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/listener/ResourcePack.java @@ -29,8 +29,7 @@ public class ResourcePack implements Listener { return; Player player = e.getPlayer(); - player.sendMessage(FightSystem.PREFIX + "§cAuf Eventserver kann nur mit dem SteamWar-Resourcepack beigetreten werden"); - player.sendMessage(FightSystem.PREFIX + "§cDa du abgelehnt hast, musst du nun in der Serverliste erst einmal wieder Ressourcenpakete von SteamWar aktivieren."); + FightSystem.getMessage().sendPrefixless("RESOURCEPACK_REQUIRED", player); player.kickPlayer(null); } } diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/listener/TeamArea.java b/FightSystem_Core/src/de/steamwar/fightsystem/listener/TeamArea.java index 6a06a8e..b21bafe 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/listener/TeamArea.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/listener/TeamArea.java @@ -27,7 +27,7 @@ import de.steamwar.fightsystem.fight.FightTeam; import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.StateDependentListener; import de.steamwar.fightsystem.utils.Region; -import net.md_5.bungee.api.chat.TextComponent; +import net.md_5.bungee.api.ChatMessageType; import org.bukkit.Bukkit; import org.bukkit.GameMode; import org.bukkit.entity.Player; @@ -42,9 +42,6 @@ import java.util.logging.Level; public class TeamArea implements Listener { - private static final String DENY_TEAM = "§cDu darfst nicht zu den Teams"; - private static final String DENY_ENTERN = "§cDu darfst nicht entern"; - private static final Set realSpectator = new HashSet<>(); public TeamArea() { @@ -78,16 +75,16 @@ public class TeamArea implements Listener { if(spectator) { realSpectator(inRegion, player); } else if (!playerTeam.canPlayerEntern(player) && !inRegion) { - reset(event, DENY_ENTERN); // Leaving prior to entern + reset(event, "NO_ENTERN"); // Leaving prior to entern } return; // Always allowed in own region } if(inRegion) { - reset(event, DENY_TEAM); // Not allowed in region + reset(event, "NO_TEAMAREA"); // Not allowed in region if(team.getSchemRegion().playerInRegion(event.getTo()) && Config.PreperationArea >= 5){ // Preventing false positives due to small extension player.kickPlayer(null); - Bukkit.getLogger().log(Level.INFO, player.getName() + " ist in einen Teambereich eingedrungen."); + Bukkit.getLogger().log(Level.INFO, player.getName() + " has entered a team area"); } } } @@ -105,6 +102,6 @@ public class TeamArea implements Listener { private void reset(PlayerMoveEvent event, String message){ Player player = event.getPlayer(); player.teleport(event.getFrom()); - BasicListener.toActionbar(player, TextComponent.fromLegacyText(message)); + FightSystem.getMessage().sendPrefixless(message, player, ChatMessageType.ACTION_BAR); } } diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/listener/TestJoin.java b/FightSystem_Core/src/de/steamwar/fightsystem/listener/TestJoin.java index a8fd0eb..8099c24 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/listener/TestJoin.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/listener/TestJoin.java @@ -42,7 +42,7 @@ public class TestJoin implements Listener { FightTeam fightTeam = Fight.getPlayerTeam(player); if (fightTeam == null && (Fight.getRedTeam().isLeaderless() || Fight.getBlueTeam().isLeaderless())) { - player.sendMessage(FightSystem.PREFIX + "§7Werde zum Teamleader mit §8/§eleader"); + FightSystem.getMessage().send("TEST_BECOME_LEADER", player); } player.setOp(true); diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/record/PacketProcessor.java b/FightSystem_Core/src/de/steamwar/fightsystem/record/PacketProcessor.java index 656af58..5fbddf3 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/record/PacketProcessor.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/record/PacketProcessor.java @@ -29,7 +29,6 @@ import de.steamwar.fightsystem.countdown.EventSpectateCountdown; import de.steamwar.fightsystem.fight.Fight; import de.steamwar.fightsystem.fight.FightTeam; import de.steamwar.fightsystem.fight.FreezeWorld; -import de.steamwar.fightsystem.listener.BasicListener; import de.steamwar.fightsystem.listener.FightScoreboard; import de.steamwar.fightsystem.utils.*; import de.steamwar.sql.Schematic; @@ -235,19 +234,7 @@ public class PacketProcessor { String message = source.readUTF(); BaseComponent[] text = TextComponent.fromLegacyText(message); - Bukkit.getOnlinePlayers().forEach(p -> { - switch(type){ - case CHAT: - BountifulWrapper.impl.toChat(p, text); - break; - case SYSTEM: - p.spigot().sendMessage(text); - break; - case ACTION_BAR: - BasicListener.toActionbar(p, text); - break; - } - }); + Bukkit.getOnlinePlayers().forEach(p -> de.steamwar.core.BountifulWrapper.impl.sendMessage(p, type, text)); } private void countdown() throws IOException { @@ -411,7 +398,7 @@ public class PacketProcessor { if(Config.replayserver() || ArenaMode.AntiReplay.contains(Config.mode)) { FightSystem.setSpectateState(null, "Replay ends", null); }else{ - Bukkit.broadcastMessage(FightSystem.PREFIX + "§cReplay beendet"); + FightSystem.getMessage().broadcast("REPLAY_ENDS"); new EventSpectateCountdown().enable(); } replaying = false; diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/states/StateDependentCommand.java b/FightSystem_Core/src/de/steamwar/fightsystem/states/StateDependentCommand.java index b2e63fb..2d25b68 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/states/StateDependentCommand.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/states/StateDependentCommand.java @@ -21,6 +21,7 @@ package de.steamwar.fightsystem.states; import de.steamwar.fightsystem.ArenaMode; import de.steamwar.fightsystem.FightSystem; +import net.md_5.bungee.api.ChatMessageType; import org.bukkit.command.CommandExecutor; import org.bukkit.command.PluginCommand; @@ -29,7 +30,7 @@ import java.util.Set; public class StateDependentCommand extends StateDependent { private static final CommandExecutor unavailable = (sender, cmd, s, strings) -> { - sender.sendMessage(FightSystem.PREFIX + "§cDieser Befehl ist zu diesem Kampfzeitpunkt nicht verfügbar."); + FightSystem.getMessage().sendPrefixless("COMMAND_CURRENTLY_UNAVAILABLE", sender, ChatMessageType.ACTION_BAR); return false; }; diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/utils/BountifulWrapper.java b/FightSystem_Core/src/de/steamwar/fightsystem/utils/BountifulWrapper.java index 06b9c89..023d4fe 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/utils/BountifulWrapper.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/utils/BountifulWrapper.java @@ -20,7 +20,6 @@ package de.steamwar.fightsystem.utils; import de.steamwar.fightsystem.VersionDependent; -import net.md_5.bungee.api.chat.BaseComponent; import org.bukkit.World; import org.bukkit.entity.Player; import org.bukkit.event.Listener; @@ -37,9 +36,6 @@ public class BountifulWrapper { boolean mainHand(Object packet); boolean bowInHand(boolean mainHand, Player p); - void toActionbar(Player player, BaseComponent... components); - void toChat(Player player, BaseComponent... components); - void setAttackSpeed(Player player); void setNametagVisibility(Team team); diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/utils/FightUI.java b/FightSystem_Core/src/de/steamwar/fightsystem/utils/FightUI.java index 79e68d1..719f406 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/utils/FightUI.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/utils/FightUI.java @@ -30,8 +30,6 @@ import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.StateDependentCountdown; import de.steamwar.fightsystem.states.StateDependentTask; import de.steamwar.fightsystem.winconditions.Wincondition; -import net.md_5.bungee.api.chat.BaseComponent; -import net.md_5.bungee.api.chat.TextComponent; import org.bukkit.Bukkit; import org.bukkit.entity.Player; @@ -138,10 +136,8 @@ public class FightUI { private void tpsWatcher() { double tps = TPSWatcher.getTPS(); - if(tps < 15.0) { - BaseComponent[] message = TextComponent.fromLegacyText("§c" + tps + " §7TPS"); - Bukkit.getOnlinePlayers().forEach(player -> BountifulWrapper.impl.toActionbar(player, message)); - } + if(tps < 15.0) + FightSystem.getMessage().broadcastActionbar("TPS_WARNING", tps); } public enum BossBarType { -- 2.39.2 From 4bf27107c64f6195cad592b2823ded3a5880b5cc Mon Sep 17 00:00:00 2001 From: Lixfel Date: Wed, 13 Oct 2021 08:50:49 +0200 Subject: [PATCH 3/8] WIP multiling Signed-off-by: Lixfel --- .../de/steamwar/fightsystem/FightSystem.java | 12 +-- .../fightsystem/FightSystem.properties | 4 + .../countdown/EventSpectateCountdown.java | 2 +- .../fightsystem/listener/PrepareSchem.java | 12 ++- .../fightsystem/record/PacketProcessor.java | 40 ++++++++++ .../steamwar/fightsystem/record/Recorder.java | 77 ++++++++++++++----- .../steamwar/fightsystem/utils/FightUI.java | 4 +- 7 files changed, 116 insertions(+), 35 deletions(-) diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/FightSystem.java b/FightSystem_Core/src/de/steamwar/fightsystem/FightSystem.java index 41f6cd7..6c45bfd 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/FightSystem.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/FightSystem.java @@ -231,13 +231,6 @@ public class FightSystem extends JavaPlugin { return plugin; } - public static void shutdown(String reason){ - if(reason != null) - FightSystem.broadcast(reason); - //Staggered kick to prevent lobby overloading - kickNext(); - } - public static void broadcast(String message) { Bukkit.broadcastMessage(PREFIX + message); GlobalRecorder.getInstance().systemChat(PREFIX + message); @@ -247,13 +240,14 @@ public class FightSystem extends JavaPlugin { return plugin.message; } - private static void kickNext(){ + public static void shutdown() { + //Staggered kick to prevent lobby overloading if(Bukkit.getOnlinePlayers().isEmpty()){ Bukkit.shutdown(); return; } Bukkit.getOnlinePlayers().iterator().next().kickPlayer(null); - Bukkit.getScheduler().runTaskLater(plugin, FightSystem::kickNext, 10); + Bukkit.getScheduler().runTaskLater(plugin, FightSystem::shutdown, 10); } } diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/FightSystem.properties b/FightSystem_Core/src/de/steamwar/fightsystem/FightSystem.properties index f646e38..81bc2f7 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/FightSystem.properties +++ b/FightSystem_Core/src/de/steamwar/fightsystem/FightSystem.properties @@ -151,6 +151,10 @@ RESOURCEPACK_REQUIRED= NO_ENTERN=§cDu darfst nicht entern NO_TEAMAREA=§cDu darfst nicht zu den Teams TEST_BECOME_LEADER=§7Werde zum Teamleader mit §8/§eleader +PREPARE_SCHEM_DELETED=§cAnscheinend wurde die auszufahrende Schematic gelöscht, Einsenden wird abgebrochen. +PREPARE_ACTIVE_PISTON=§cIm Teambereich wurden sich noch bewegende Pistons gefunden, Einsenden wird abgebrochen. +PREPARE_FAILED_SAVING=§cDie Schematic konnte nicht gespeichert werden, Einsenden wird abgebrochen. +PREPARE_SENT_IN=§aDie Schematic wird nun zeitnah von einem Teammitglied überprüft # Replay diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/countdown/EventSpectateCountdown.java b/FightSystem_Core/src/de/steamwar/fightsystem/countdown/EventSpectateCountdown.java index 61be26c..485db37 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/countdown/EventSpectateCountdown.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/countdown/EventSpectateCountdown.java @@ -40,6 +40,6 @@ public class EventSpectateCountdown extends Countdown { @Override public void countdownFinished() { - FightSystem.shutdown(null); + FightSystem.shutdown(); } } diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/listener/PrepareSchem.java b/FightSystem_Core/src/de/steamwar/fightsystem/listener/PrepareSchem.java index f20057f..8efd4ad 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/listener/PrepareSchem.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/listener/PrepareSchem.java @@ -53,14 +53,16 @@ public class PrepareSchem implements Listener { try{ schem = Schematic.getSchemFromDB(Config.PrepareSchemID); }catch(SecurityException e){ - FightSystem.shutdown(FightSystem.PREFIX + "§cAnscheinend wurde die auszufahrende Schematic gelöscht, Einsenden wird abgebrochen."); + FightSystem.getMessage().broadcast("PREPARE_SCHEM_DELETED"); + Bukkit.shutdown(); return; } try{ region.forEach((x, y, z) -> { if(FlatteningWrapper.impl.checkPistonMoving(world.getBlockAt(x, y, z))){ - FightSystem.shutdown(FightSystem.PREFIX + "§cIm Teambereich wurden sich noch bewegende Pistons gefunden, Einsenden wird abgebrochen."); + FightSystem.getMessage().broadcast("PREPARE_ACTIVE_PISTON"); + Bukkit.shutdown(); throw new IllegalStateException(); } }); @@ -71,12 +73,14 @@ public class PrepareSchem implements Listener { try{ WorldeditWrapper.impl.saveSchem(schem, region, minY); }catch(WorldEditException e){ - FightSystem.shutdown(FightSystem.PREFIX + "§cDie Schematic konnte nicht gespeichert werden, Einsenden wird abgebrochen."); + FightSystem.getMessage().broadcast("PREPARE_FAILED_SAVING"); + Bukkit.shutdown(); throw new SecurityException("Could not save schem", e); } schem.setSchemType(Config.SchematicType.checkType()); - FightSystem.shutdown(FightSystem.PREFIX + "§aDie Schematic wird nun zeitnah von einem Teammitglied überprüft"); + FightSystem.getMessage().broadcast("PREPARE_SENT_IN"); + Bukkit.shutdown(); } }; } diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/record/PacketProcessor.java b/FightSystem_Core/src/de/steamwar/fightsystem/record/PacketProcessor.java index 5fbddf3..ba988e9 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/record/PacketProcessor.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/record/PacketProcessor.java @@ -45,7 +45,9 @@ import org.bukkit.scheduler.BukkitTask; import java.io.EOFException; import java.io.IOException; +import java.util.ArrayList; import java.util.LinkedList; +import java.util.List; import java.util.Set; import java.util.logging.Level; @@ -458,6 +460,44 @@ public class PacketProcessor { } } + private Object[] readMessageParams() throws IOException { + List params = new ArrayList<>(); + + int type; + do { + type = Byte.toUnsignedInt(source.readByte()); + switch(type) { + case 0x00: + break; + case 0x01: + params.add(source.readBoolean()); + break; + case 0x02: + params.add(source.readByte()); + break; + case 0x03: + params.add(source.readShort()); + break; + case 0x04: + params.add(source.readInt()); + break; + case 0x05: + params.add(source.readFloat()); + break; + case 0x06: + params.add(source.readDouble()); + break; + case 0x07: + params.add(source.readUTF()); + break; + default: + throw new IOException("Unknown message param type " + type); + } + } while(type != 0x00); + + return params.toArray(); + } + private interface PacketParser{ void process() throws IOException; } diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/record/Recorder.java b/FightSystem_Core/src/de/steamwar/fightsystem/record/Recorder.java index 903ddcf..936f74e 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/record/Recorder.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/record/Recorder.java @@ -126,6 +126,17 @@ public interface Recorder { * * CommentPacket (0xfe) + String comment * TickPacket (0xff) + * + * Message-Format + * String message + byte prefixed Object-Params + byte 0x00 + * 0x00: End of message + * 0x01: boolean following + * 0x02: byte following + * 0x03: short following + * 0x04: int following + * 0x05: float following + * 0x06: double following + * 0x07: String following * */ default void playerJoins(Player p){ @@ -289,25 +300,8 @@ public interface Recorder { DataOutputStream stream = getStream(); try { stream.writeByte(id); - for(Object o : objects){ - if(o instanceof Boolean) - stream.writeBoolean((Boolean)o); - else if(o instanceof Byte) - stream.writeByte((Byte)o); - else if(o instanceof Short) - stream.writeShort((Short)o); - else if(o instanceof Integer) - stream.writeInt((Integer)o); - else if(o instanceof Float) - stream.writeFloat((Float)o); - else if(o instanceof Double) - stream.writeDouble((Double)o); - else if(o instanceof String) - stream.writeUTF((String)o); - else if(o instanceof byte[]) - stream.write((byte[])o); - else - throw new SecurityException("Undefined write for: " + o.getClass().getName()); + for(Object o : objects) { + writeObject(stream, o); } stream.flush(); } catch (IOException e) { @@ -316,6 +310,51 @@ public interface Recorder { } } + default void writeObject(DataOutputStream stream, Object o) throws IOException { + if(o instanceof Boolean) + stream.writeBoolean((Boolean)o); + else if(o instanceof Byte) + stream.writeByte((Byte)o); + else if(o instanceof Short) + stream.writeShort((Short)o); + else if(o instanceof Integer) + stream.writeInt((Integer)o); + else if(o instanceof Float) + stream.writeFloat((Float)o); + else if(o instanceof Double) + stream.writeDouble((Double)o); + else if(o instanceof String) + stream.writeUTF((String)o); + else if(o instanceof byte[]) + stream.write((byte[])o); + else + throw new SecurityException("Undefined write for: " + o.getClass().getName()); + } + + default void writeMessage(DataOutputStream stream, String message, Object... params) throws IOException { + stream.writeUTF(message); + for(Object o : params) { + if(o instanceof Boolean) + stream.writeByte(0x01); + else if(o instanceof Byte) + stream.writeByte(0x02); + else if(o instanceof Short) + stream.writeByte(0x03); + else if(o instanceof Integer) + stream.writeByte(0x04); + else if(o instanceof Float) + stream.writeByte(0x05); + else if(o instanceof Double) + stream.writeByte(0x06); + else if(o instanceof String) + stream.writeByte(0x07); + else + throw new SecurityException("Undefined message serialization for: " + o.getClass().getName()); + writeObject(stream, o); + } + stream.writeByte(0x00); + } + static void copy(InputStream var0, OutputStream var1) throws IOException { int var5; for(byte[] var4 = new byte[8192]; (var5 = var0.read(var4)) > 0;) { diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/utils/FightUI.java b/FightSystem_Core/src/de/steamwar/fightsystem/utils/FightUI.java index 73605cb..cf8f3fe 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/utils/FightUI.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/utils/FightUI.java @@ -144,7 +144,7 @@ public class FightUI { BLUE_LEFT(345, 165), RED_LEFT(165, 345); - private static final boolean blueNegZ = Config.blueNegZ(); + private static final boolean BLUE_NEG_Z = Config.blueNegZ(); private final double minAngle; private final double maxAngle; @@ -155,7 +155,7 @@ public class FightUI { } private static BossBarType byAngle(double angle) { - if(blueNegZ) + if(BLUE_NEG_Z) angle += 180; angle = ((angle % 360) + 360) % 360; -- 2.39.2 From 46a97e779c9bd970a2354ed20ad60aae46626727 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Sat, 23 Oct 2021 08:43:58 +0200 Subject: [PATCH 4/8] More Multiling Signed-off-by: Lixfel --- .../de/steamwar/fightsystem/FightSystem.java | 23 ++--- .../fightsystem/FightSystem.properties | 31 +++++++ .../de/steamwar/fightsystem/commands/GUI.java | 6 +- .../fightsystem/commands/GamemodeCommand.java | 1 - .../fightsystem/commands/WinCommand.java | 6 +- .../fightsystem/countdown/Countdown.java | 17 ++-- .../countdown/EnternCountdown.java | 10 +-- .../countdown/EventSpectateCountdown.java | 8 +- .../countdown/NoPlayersOnlineCountdown.java | 8 +- .../countdown/PostSchemCountdown.java | 8 +- .../countdown/PreRunningCountdown.java | 8 +- .../countdown/PreSchemCountdown.java | 8 +- .../countdown/SpectateOverCountdown.java | 8 +- .../countdown/TimeOverCountdown.java | 8 +- .../fightsystem/event/HellsBells.java | 9 +- .../steamwar/fightsystem/fight/FightTeam.java | 11 ++- .../steamwar/fightsystem/listener/Chat.java | 18 ++-- .../fightsystem/listener/IngameDeath.java | 4 +- .../fightsystem/listener/Permanent.java | 1 + .../fightsystem/record/PacketProcessor.java | 68 +++++++++++--- .../steamwar/fightsystem/record/Recorder.java | 90 +++++++++++-------- .../fightsystem/utils/FightStatistics.java | 4 +- .../steamwar/fightsystem/utils/FightUI.java | 27 +++--- .../steamwar/fightsystem/utils/Message.java | 38 ++++++++ .../EventTeamOffWincondition.java | 4 +- .../RankedPlayerLeftWincondition.java | 2 +- .../winconditions/Wincondition.java | 4 +- .../winconditions/WinconditionAllDead.java | 2 +- .../WinconditionCaptainDead.java | 2 +- .../WinconditionHeartRatioTimeout.java | 6 +- .../WinconditionPercentSystem.java | 2 +- .../WinconditionPercentTimeout.java | 6 +- .../winconditions/WinconditionPoints.java | 6 +- .../WinconditionPumpkinTechKO.java | 2 +- .../WinconditionRelativePercent.java | 2 +- .../winconditions/WinconditionTimeTechKO.java | 11 +-- .../winconditions/WinconditionTimeout.java | 2 +- .../WinconditionWaterTechKO.java | 2 +- 38 files changed, 278 insertions(+), 195 deletions(-) create mode 100644 FightSystem_Core/src/de/steamwar/fightsystem/utils/Message.java diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/FightSystem.java b/FightSystem_Core/src/de/steamwar/fightsystem/FightSystem.java index 6c45bfd..96a5d88 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/FightSystem.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/FightSystem.java @@ -44,7 +44,6 @@ import java.util.logging.Level; public class FightSystem extends JavaPlugin { - public static final String PREFIX = "§eArena§8» "; private static FightSystem plugin; private static EventFight eventFight; private static Player eventLeiter; @@ -133,8 +132,8 @@ public class FightSystem extends JavaPlugin { new LiveRecorder(); new FileRecorder(); - new OneShotStateDependent(ArenaMode.AntiReplay, FightState.PreRunning, () -> FightUI.addSubtitle("§7Kits verteilt")); - new OneShotStateDependent(ArenaMode.AntiReplay, FightState.Running, () -> FightUI.addSubtitle("§aArena freigegeben")); + new OneShotStateDependent(ArenaMode.AntiReplay, FightState.PreRunning, () -> FightUI.addSubtitle("UI_PRE_RUNNING")); + new OneShotStateDependent(ArenaMode.AntiReplay, FightState.Running, () -> FightUI.addSubtitle("UI_RUNNING")); new OneShotStateDependent(ArenaMode.AntiTest, FightState.Running, FightStatistics::start); try { @@ -186,14 +185,8 @@ public class FightSystem extends JavaPlugin { FightState.setFightState(FightState.RUNNING); } - public static void setSpectateState(FightTeam winFightTeam, String windescription, String subtitle) { - if(!PacketProcessor.isReplaying()){ - if(winFightTeam != null) { - FightUI.printWin(winFightTeam.getPrefix() + "Sieg " + winFightTeam.getName(), subtitle); - } else { - FightUI.printWin("§7Unentschieden", subtitle); - } - } + public static void setSpectateState(FightTeam winFightTeam, String winreason, String subtitle, Object... params) { + FightUI.printWin(winFightTeam, subtitle, params); FightState.setFightState(FightState.SPECTATE); @@ -207,7 +200,7 @@ public class FightSystem extends JavaPlugin { getEventFight().setErgebnis(2); } - FightStatistics.saveStats(winFightTeam, windescription); + FightStatistics.saveStats(winFightTeam, winreason); } } @@ -231,9 +224,9 @@ public class FightSystem extends JavaPlugin { return plugin; } - public static void broadcast(String message) { - Bukkit.broadcastMessage(PREFIX + message); - GlobalRecorder.getInstance().systemChat(PREFIX + message); + public static void broadcast(String msg, Object... params) { + getMessage().broadcast(msg, params); + GlobalRecorder.getInstance().system(msg, params); } public static Message getMessage() { diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/FightSystem.properties b/FightSystem_Core/src/de/steamwar/fightsystem/FightSystem.properties index 81bc2f7..bdbdfcf 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/FightSystem.properties +++ b/FightSystem_Core/src/de/steamwar/fightsystem/FightSystem.properties @@ -155,10 +155,14 @@ PREPARE_SCHEM_DELETED= PREPARE_ACTIVE_PISTON=§cIm Teambereich wurden sich noch bewegende Pistons gefunden, Einsenden wird abgebrochen. PREPARE_FAILED_SAVING=§cDie Schematic konnte nicht gespeichert werden, Einsenden wird abgebrochen. PREPARE_SENT_IN=§aDie Schematic wird nun zeitnah von einem Teammitglied überprüft +PARTICIPANT_CHAT={0} {1}§8» §7{2} +FIGHTLEADER_CHAT=§e{0}§8» §e{1} +SPECTATOR_CHAT=§7{0}§8» §7{1} # Replay REPLAY_ENDS=§cReplay beendet +OLD_STRING={0} # States @@ -168,6 +172,33 @@ COMMAND_CURRENTLY_UNAVAILABLE= # Utils TPS_WARNING=§c{0} §7TPS +UI_PRE_RUNNING=§7Kits verteilt +UI_RUNNING=§aArena freigegeben +UI_SKIP=§7Sprung zum nächsten Ereignis +UI_PLAYER_JOINS=§a§l» {0}{1} +UI_PLAYER_LEAVES=§c§l« {0}{1} +UI_LEADER_JOINS=§a§l» {0}Leader {1} +UI_PLAYER_DEATH={0}{1} §7ist gestorben +UI_PLAYER_LEAVE={0}{1} §7hat den Kampf verlassen +UI_ELO=§7ELO von {0}{1}§8: §7{2}§8»§e{3} +UI_WIN={0}Sieg {1} +UI_DRAW=§7Unentschieden + # Winconditions HELLS_BELLS_COUNTDOWN=bis die Bomben fallen +TECHKO_COUNTDOWN=bis {0} §7einen Schuss abgegeben haben muss + +WIN_FIGHTLEADER="§7Kampfleiterentscheidung" +WIN_PERCENT={0} §7zu beschädigt +WIN_OFFLINE_BOTH=§7Beide Teams offline +WIN_OFFLINE={0} §7offline +WIN_RANKED_LEFT={0} §7hat den Kampf verlassen +WIN_ALL_DEAD={0}Alle Spieler kampfunfähig +WIN_LEADER_DEAD={0} kampfunfähig +WIN_TIME_OVER=§7Zeit abgelaufen +WIN_MORE_HEALTH={0}Mehr verbleibende Leben +WIN_LESS_DAMAGE={0} §7weniger beschädigt +WIN_POINTS={0} hat mehr Punkte +WIN_POINTS_EQUAL=§7Gleicher Punktestand +WIN_TECHKO={0} §7ist Tech K.O. diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/commands/GUI.java b/FightSystem_Core/src/de/steamwar/fightsystem/commands/GUI.java index c71723f..a4bebff 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/commands/GUI.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/commands/GUI.java @@ -77,9 +77,9 @@ public class GUI { inv.setItem(2, Material.GLASS, msg.parse("STATE_POST_SCHEM_SETUP", p), (ClickType click) -> FightSystem.setPostSchemState()); inv.setItem(3, Material.GLASS, msg.parse("STATE_PRE_RUNNING", p), (ClickType click) -> FightSystem.setPreRunningState()); inv.setItem(4, Material.GLASS, msg.parse("STATE_RUNNING", p), (ClickType click) -> FightSystem.setRunningState()); - inv.setItem(5, Material.GLASS, msg.parse("STATE_SPECTATE_WIN", p, Fight.getBlueTeam().getColoredName()), (ClickType click) -> FightSystem.setSpectateState(Fight.getBlueTeam(), "operator", null)); - inv.setItem(6, Material.GLASS, msg.parse("STATE_SPECTATE_WIN", p, Fight.getRedTeam().getColoredName()), (ClickType click) -> FightSystem.setSpectateState(Fight.getRedTeam(), "operator", null)); - inv.setItem(7, Material.GLASS, msg.parse("STATE_SPECTATE_TIE", p), (ClickType click) -> FightSystem.setSpectateState(null, "operator", null)); + inv.setItem(5, Material.GLASS, msg.parse("STATE_SPECTATE_WIN", p, Fight.getBlueTeam().getColoredName()), (ClickType click) -> FightSystem.setSpectateState(Fight.getBlueTeam(), "operator", "WIN_FIGHTLEADER")); + inv.setItem(6, Material.GLASS, msg.parse("STATE_SPECTATE_WIN", p, Fight.getRedTeam().getColoredName()), (ClickType click) -> FightSystem.setSpectateState(Fight.getRedTeam(), "operator", "WIN_FIGHTLEADER")); + inv.setItem(7, Material.GLASS, msg.parse("STATE_SPECTATE_TIE", p), (ClickType click) -> FightSystem.setSpectateState(null, "operator", "WIN_FIGHTLEADER")); inv.setCallback(-999, (ClickType click) -> p.closeInventory()); inv.open(); } diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/commands/GamemodeCommand.java b/FightSystem_Core/src/de/steamwar/fightsystem/commands/GamemodeCommand.java index b5484cf..b14cc94 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/commands/GamemodeCommand.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/commands/GamemodeCommand.java @@ -50,7 +50,6 @@ public class GamemodeCommand extends BukkitCommand { return false; }else if (args.length == 0) { FightSystem.getMessage().sendPrefixless("GAMEMODE_HELP", sender); - sender.sendMessage(FightSystem.PREFIX + this.usageMessage); return false; } diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/commands/WinCommand.java b/FightSystem_Core/src/de/steamwar/fightsystem/commands/WinCommand.java index 9384c9a..979a181 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/commands/WinCommand.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/commands/WinCommand.java @@ -35,11 +35,11 @@ public class WinCommand implements CommandExecutor { } if(args[0].equalsIgnoreCase("tie")){ - FightSystem.setSpectateState(null, "Referee", "§7Kampfleiterentscheidung"); + FightSystem.setSpectateState(null, "Referee", "WIN_FIGHTLEADER"); }else if(args[0].equalsIgnoreCase(Fight.getBlueTeam().getName())){ - FightSystem.setSpectateState(Fight.getBlueTeam(), "Referee", "§7Kampfleiterentscheidung"); + FightSystem.setSpectateState(Fight.getBlueTeam(), "Referee", "WIN_FIGHTLEADER"); }else if(args[0].equalsIgnoreCase(Fight.getRedTeam().getName())){ - FightSystem.setSpectateState(Fight.getRedTeam(), "Referee", "§7Kampfleiterentscheidung"); + FightSystem.setSpectateState(Fight.getRedTeam(), "Referee", "WIN_FIGHTLEADER"); } return false; } diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/countdown/Countdown.java b/FightSystem_Core/src/de/steamwar/fightsystem/countdown/Countdown.java index 9a74910..5449e17 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/countdown/Countdown.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/countdown/Countdown.java @@ -23,6 +23,7 @@ import de.steamwar.fightsystem.FightSystem; import de.steamwar.fightsystem.fight.Fight; import de.steamwar.fightsystem.record.GlobalRecorder; import de.steamwar.fightsystem.utils.FightUI; +import de.steamwar.fightsystem.utils.Message; import de.steamwar.fightsystem.utils.SWSound; import net.md_5.bungee.api.ChatMessageType; import org.bukkit.Bukkit; @@ -37,6 +38,8 @@ public abstract class Countdown { private static final List currentCountdowns = new ArrayList<>(); + protected final Message appendix; + private final int totalTime; protected final Sound sound; private final boolean level; @@ -44,12 +47,12 @@ public abstract class Countdown { protected int time; private BukkitTask task = null; - public abstract String countdownCounting(); public abstract void countdownFinished(); - protected Countdown(int time, SWSound sound, boolean level) { + protected Countdown(int time, Message appendix, SWSound sound, boolean level) { this.totalTime = time; this.time = time; + this.appendix = appendix; this.sound = sound != null ? sound.getSound() : null; this.level = level; } @@ -86,19 +89,19 @@ public abstract class Countdown { countdown.show(); } - FightUI.addSubtitle("§7Sprung zum nächsten Ereignis"); + FightUI.addSubtitle("UI_SKIP"); } - public static void sendCountdownMessage(Player p, String message, int displaytime, String appendix) { - FightSystem.getMessage().sendPrefixless(message, p, ChatMessageType.ACTION_BAR, displaytime, FightSystem.getMessage().parse(appendix, p)); + public static void sendCountdownMessage(Player p, String message, int displaytime, Message appendix) { + FightSystem.getMessage().sendPrefixless(message, p, ChatMessageType.ACTION_BAR, displaytime, FightSystem.getMessage().parse(appendix.getMsg(), p, appendix.getParams())); } protected void broadcast(String message, int divisor){ if(this.sound != null && divisor == 1) Fight.playSound(this.sound, 100.0F, 1.0F); - GlobalRecorder.getInstance().countdown(message, divisor, countdownCounting()); - Bukkit.getOnlinePlayers().forEach(p -> sendCountdownMessage(p, message, time / divisor, countdownCounting())); + GlobalRecorder.getInstance().countdown(message, divisor, appendix); + Bukkit.getOnlinePlayers().forEach(p -> sendCountdownMessage(p, message, time / divisor, appendix)); } protected void prepareFinish() {} diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/countdown/EnternCountdown.java b/FightSystem_Core/src/de/steamwar/fightsystem/countdown/EnternCountdown.java index 1ecc374..e4acee0 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/countdown/EnternCountdown.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/countdown/EnternCountdown.java @@ -22,6 +22,7 @@ package de.steamwar.fightsystem.countdown; import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.FightSystem; import de.steamwar.fightsystem.fight.FightPlayer; +import de.steamwar.fightsystem.utils.Message; import de.steamwar.fightsystem.utils.SWSound; import de.steamwar.fightsystem.utils.TechHider; import net.md_5.bungee.api.ChatMessageType; @@ -34,16 +35,11 @@ public class EnternCountdown extends Countdown { private List chunkPos; public EnternCountdown(FightPlayer fp) { - super(Config.EnterStages.get(fp.getKit().getEnterStage()), SWSound.BLOCK_NOTE_PLING, false); + super(Config.EnterStages.get(fp.getKit().getEnterStage()), new Message("ENTERN_COUNTDOWN"), SWSound.BLOCK_NOTE_PLING, false); fightPlayer = fp; enable(); } - @Override - public String countdownCounting() { - return "ENTERN_COUNTDOWN"; - } - @Override public void countdownFinished() { FightSystem.getMessage().sendPrefixless("ENTERN_ALLOWED", fightPlayer.getPlayer(), ChatMessageType.ACTION_BAR); @@ -58,6 +54,6 @@ public class EnternCountdown extends Countdown { @Override protected void broadcast(String message, int divisor) { fightPlayer.getPlayer().playSound(fightPlayer.getPlayer().getLocation(), sound, 100.0f, 1.0f); - sendCountdownMessage(fightPlayer.getPlayer(), message, time / divisor, countdownCounting()); + sendCountdownMessage(fightPlayer.getPlayer(), message, time / divisor, appendix); } } diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/countdown/EventSpectateCountdown.java b/FightSystem_Core/src/de/steamwar/fightsystem/countdown/EventSpectateCountdown.java index 485db37..03342fc 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/countdown/EventSpectateCountdown.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/countdown/EventSpectateCountdown.java @@ -24,20 +24,16 @@ import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.FightSystem; import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.StateDependentCountdown; +import de.steamwar.fightsystem.utils.Message; import de.steamwar.fightsystem.utils.SWSound; public class EventSpectateCountdown extends Countdown { public EventSpectateCountdown() { - super(Config.SpectatorDuration, SWSound.BLOCK_NOTE_PLING, false); + super(Config.SpectatorDuration, new Message("SHUTDOWN_COUNTDOWN"), SWSound.BLOCK_NOTE_PLING, false); new StateDependentCountdown(ArenaMode.Event, FightState.Spectate, this); } - @Override - public String countdownCounting() { - return "SHUTDOWN_COUNTDOWN"; - } - @Override public void countdownFinished() { FightSystem.shutdown(); diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/countdown/NoPlayersOnlineCountdown.java b/FightSystem_Core/src/de/steamwar/fightsystem/countdown/NoPlayersOnlineCountdown.java index 3b688f1..11cb3c9 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/countdown/NoPlayersOnlineCountdown.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/countdown/NoPlayersOnlineCountdown.java @@ -24,6 +24,7 @@ import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.StateDependentCountdown; import de.steamwar.fightsystem.states.StateDependentListener; +import de.steamwar.fightsystem.utils.Message; import org.bukkit.Bukkit; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; @@ -32,7 +33,7 @@ import org.bukkit.event.player.PlayerJoinEvent; public class NoPlayersOnlineCountdown extends Countdown implements Listener { public NoPlayersOnlineCountdown() { - super(Config.NoPlayerOnlineDuration, null, false); + super(Config.NoPlayerOnlineDuration, new Message("SHUTDOWN_COUNTDOWN"), null, false); new StateDependentListener(ArenaMode.AntiReplay, FightState.PreLeaderSetup, this); new StateDependentCountdown(ArenaMode.AntiReplay, FightState.PreLeaderSetup, this) { @@ -44,11 +45,6 @@ public class NoPlayersOnlineCountdown extends Countdown implements Listener { }; } - @Override - public String countdownCounting() { - return "SHUTDOWN_COUNTDOWN"; - } - @EventHandler public void handlePlayerJoin(PlayerJoinEvent event) { disable(); diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/countdown/PostSchemCountdown.java b/FightSystem_Core/src/de/steamwar/fightsystem/countdown/PostSchemCountdown.java index 70c3f79..7a58bbc 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/countdown/PostSchemCountdown.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/countdown/PostSchemCountdown.java @@ -24,19 +24,15 @@ import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.FightSystem; import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.StateDependentCountdown; +import de.steamwar.fightsystem.utils.Message; public class PostSchemCountdown extends Countdown { public PostSchemCountdown() { - super(Config.SetupDuration, null, false); + super(Config.SetupDuration, new Message("POST_SCHEM_COUNTDOWN"), null, false); new StateDependentCountdown(ArenaMode.AntiTest, FightState.PostSchemSetup, this); } - @Override - public String countdownCounting() { - return "POST_SCHEM_COUNTDOWN"; - } - @Override public void countdownFinished() { FightSystem.setPreRunningState(); diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/countdown/PreRunningCountdown.java b/FightSystem_Core/src/de/steamwar/fightsystem/countdown/PreRunningCountdown.java index faca110..87984b1 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/countdown/PreRunningCountdown.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/countdown/PreRunningCountdown.java @@ -24,20 +24,16 @@ import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.FightSystem; import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.StateDependentCountdown; +import de.steamwar.fightsystem.utils.Message; import de.steamwar.fightsystem.utils.SWSound; public class PreRunningCountdown extends Countdown { public PreRunningCountdown() { - super(Config.PreFightDuration, SWSound.BLOCK_NOTE_PLING, true); + super(Config.PreFightDuration, new Message("PRE_RUNNING_COUNTDOWN"), SWSound.BLOCK_NOTE_PLING, true); new StateDependentCountdown(ArenaMode.AntiReplay, FightState.PreRunning, this); } - @Override - public String countdownCounting() { - return "PRE_RUNNING_COUNTDOWN"; - } - @Override public void countdownFinished() { FightSystem.setRunningState(); diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/countdown/PreSchemCountdown.java b/FightSystem_Core/src/de/steamwar/fightsystem/countdown/PreSchemCountdown.java index 61547c9..b88378f 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/countdown/PreSchemCountdown.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/countdown/PreSchemCountdown.java @@ -24,20 +24,16 @@ import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.FightSystem; import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.StateDependentCountdown; +import de.steamwar.fightsystem.utils.Message; import de.steamwar.fightsystem.utils.SWSound; public class PreSchemCountdown extends Countdown { public PreSchemCountdown() { - super(Config.PreSchemPasteDuration, SWSound.BLOCK_NOTE_PLING, false); + super(Config.PreSchemPasteDuration, new Message("PRE_SCHEM_COUNTDOWN"), SWSound.BLOCK_NOTE_PLING, false); new StateDependentCountdown(ArenaMode.AntiReplay, FightState.PreSchemSetup, this); } - @Override - public String countdownCounting() { - return "PRE_SCHEM_COUNTDOWN"; - } - @Override public void countdownFinished() { FightSystem.setPostSchemState(); diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/countdown/SpectateOverCountdown.java b/FightSystem_Core/src/de/steamwar/fightsystem/countdown/SpectateOverCountdown.java index 9d330c7..67bcfb3 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/countdown/SpectateOverCountdown.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/countdown/SpectateOverCountdown.java @@ -24,20 +24,16 @@ import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.FightSystem; import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.StateDependentCountdown; +import de.steamwar.fightsystem.utils.Message; import de.steamwar.fightsystem.utils.SWSound; public class SpectateOverCountdown extends Countdown { public SpectateOverCountdown() { - super(Config.SpectatorDuration, SWSound.BLOCK_NOTE_PLING, false); + super(Config.SpectatorDuration, new Message("SPECTATE_COUNTDOWN"), SWSound.BLOCK_NOTE_PLING, false); new StateDependentCountdown(ArenaMode.Restartable, FightState.Spectate, this); } - @Override - public String countdownCounting() { - return "SPECTATE_COUNTDOWN"; - } - @Override public void countdownFinished() { FightSystem.setPreLeaderState(); diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/countdown/TimeOverCountdown.java b/FightSystem_Core/src/de/steamwar/fightsystem/countdown/TimeOverCountdown.java index 14d269b..3e2dde8 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/countdown/TimeOverCountdown.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/countdown/TimeOverCountdown.java @@ -20,6 +20,7 @@ package de.steamwar.fightsystem.countdown; import de.steamwar.fightsystem.Config; +import de.steamwar.fightsystem.utils.Message; import de.steamwar.fightsystem.utils.SWSound; public class TimeOverCountdown extends Countdown { @@ -27,15 +28,10 @@ public class TimeOverCountdown extends Countdown { private final Runnable timeOver; public TimeOverCountdown(Runnable timeOver) { - super(Config.TimeoutTime, SWSound.BLOCK_NOTE_BASS, false); + super(Config.TimeoutTime, new Message("RUNNING_COUNTDOWN"), SWSound.BLOCK_NOTE_BASS, false); this.timeOver = timeOver; } - @Override - public String countdownCounting() { - return "RUNNING_COUNTDOWN"; - } - @Override public void countdownFinished() { timeOver.run(); diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/event/HellsBells.java b/FightSystem_Core/src/de/steamwar/fightsystem/event/HellsBells.java index da03e38..fbce5a5 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/event/HellsBells.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/event/HellsBells.java @@ -24,6 +24,7 @@ import de.steamwar.fightsystem.FightSystem; import de.steamwar.fightsystem.countdown.Countdown; import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.StateDependent; +import de.steamwar.fightsystem.utils.Message; import de.steamwar.fightsystem.utils.SWSound; import de.steamwar.fightsystem.winconditions.Winconditions; import org.bukkit.Bukkit; @@ -124,13 +125,9 @@ public class HellsBells { } private class HellsBellsCountdown extends Countdown { - public HellsBellsCountdown(int time) { - super(time, SWSound.BLOCK_NOTE_BASS, true); - } - @Override - public String countdownCounting() { - return "HELLS_BELLS_COUNTDOWN"; + public HellsBellsCountdown(int time) { + super(time, new Message("HELLS_BELLS_COUNTDOWN"), SWSound.BLOCK_NOTE_BASS, true); } @Override diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/fight/FightTeam.java b/FightSystem_Core/src/de/steamwar/fightsystem/fight/FightTeam.java index 5ff517e..8b85300 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/fight/FightTeam.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/fight/FightTeam.java @@ -216,7 +216,7 @@ public class FightTeam { if(isLeaderless()) setLeader(fightPlayer); else - FightUI.addSubtitle("§a§l» " + prefix + player.getName()); + FightUI.addSubtitle("UI_PLAYER_JOINS", prefix, player.getName()); } public void removePlayer(Player player) { @@ -227,7 +227,7 @@ public class FightTeam { players.remove(player); team.removeEntry(player.getName()); - FightUI.addSubtitle("§c§l« " + prefix + player.getName()); + FightUI.addSubtitle("UI_PLAYER_LEAVES", prefix, player.getName()); if(fightPlayer.equals(leader)) removeLeader(); @@ -271,7 +271,7 @@ public class FightTeam { if(ready) setReady(false); - FightUI.addSubtitle("§a§l» " + prefix + "Leader " + leader.getPlayer().getName()); + FightUI.addSubtitle("UI_LEADER_JOINS", prefix, leader.getPlayer().getName()); Optional maxRank = Schematic.getSchemsOfType(leader.getPlayer().getUniqueId(), Config.SchematicType).stream().map(Schematic::getRank).max(Integer::compare); if(Config.RanksEnabled) @@ -418,6 +418,11 @@ public class FightTeam { return color; } + @Override + public String toString() { + return name; + } + private class KitLoader extends StateDependent { private KitLoader() { super(ArenaMode.AntiReplay, FightState.Ingame); diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/listener/Chat.java b/FightSystem_Core/src/de/steamwar/fightsystem/listener/Chat.java index fa5ab7f..c562a60 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/listener/Chat.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/listener/Chat.java @@ -19,7 +19,6 @@ package de.steamwar.fightsystem.listener; -import de.steamwar.core.BountifulWrapper; import de.steamwar.fightsystem.ArenaMode; import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.FightSystem; @@ -28,10 +27,6 @@ import de.steamwar.fightsystem.fight.FightTeam; import de.steamwar.fightsystem.record.GlobalRecorder; import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.StateDependentListener; -import net.md_5.bungee.api.ChatMessageType; -import net.md_5.bungee.api.chat.BaseComponent; -import net.md_5.bungee.api.chat.TextComponent; -import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; @@ -57,20 +52,19 @@ public class Chat implements Listener { if(message.startsWith(Config.TeamChatDetection)) { fightTeam.broadcastChat(player, message.substring(1)); } else { - broadcastChat(teamName + " " + player.getName() + "§8» §7" + message); + broadcastChat("PARTICIPANT_CHAT", teamName, player.getName(), message); } }else if(player == FightSystem.getEventLeiter()){ - broadcastChat("§e" + player.getName() + "§8» §e" + message); + broadcastChat("FIGHTLEADER_CHAT", player.getName(), message); }else{ - broadcastChat("§7" + player.getName() + "§8» §7" + message); + broadcastChat("SPECTATOR_CHAT", player.getName(), message); } event.setCancelled(true); } - private void broadcastChat(String message) { - GlobalRecorder.getInstance().chat(message); - BaseComponent[] msg = TextComponent.fromLegacyText(message); - Bukkit.getOnlinePlayers().forEach(p -> BountifulWrapper.impl.sendMessage(p, ChatMessageType.CHAT, msg)); + private void broadcastChat(String message, Object... params) { + GlobalRecorder.getInstance().chat(message, params); + FightSystem.getMessage().chat(message, params); } } diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/listener/IngameDeath.java b/FightSystem_Core/src/de/steamwar/fightsystem/listener/IngameDeath.java index 430e043..822380e 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/listener/IngameDeath.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/listener/IngameDeath.java @@ -52,7 +52,7 @@ public class IngameDeath implements Listener { if(team == null) return; - FightUI.addSubtitle(team.getPrefix() + player.getName() + " §7ist gestorben"); + FightUI.addSubtitle("UI_PLAYER_DEATH", team.getPrefix(), player.getName()); Fight.playSound(SWSound.ENTITY_WITHER_DEATH.getSound(), 100.0F, 1.0F); Bukkit.getScheduler().runTask(FightSystem.getPlugin(), () -> team.getFightPlayer(player).setOut()); } @@ -70,7 +70,7 @@ public class IngameDeath implements Listener { if(!fightPlayer.isLiving()) return; - FightUI.addSubtitle(team.getPrefix() + player.getName() + " §7hat den Kampf verlassen"); + FightUI.addSubtitle("UI_PLAYER_LEAVE", team.getPrefix(), player.getName()); Bukkit.getScheduler().runTask(FightSystem.getPlugin(), () -> team.getFightPlayer(player).setOut()); } } diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/listener/Permanent.java b/FightSystem_Core/src/de/steamwar/fightsystem/listener/Permanent.java index da9c245..1b242a0 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/listener/Permanent.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/listener/Permanent.java @@ -21,6 +21,7 @@ package de.steamwar.fightsystem.listener; 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; diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/record/PacketProcessor.java b/FightSystem_Core/src/de/steamwar/fightsystem/record/PacketProcessor.java index ba988e9..3541258 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/record/PacketProcessor.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/record/PacketProcessor.java @@ -30,6 +30,7 @@ import de.steamwar.fightsystem.fight.Fight; import de.steamwar.fightsystem.fight.FightTeam; import de.steamwar.fightsystem.fight.FreezeWorld; import de.steamwar.fightsystem.listener.FightScoreboard; +import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.utils.*; import de.steamwar.sql.Schematic; import de.steamwar.sql.Team; @@ -105,6 +106,8 @@ public class PacketProcessor { packetDecoder[0xa1] = () -> send(ChatMessageType.ACTION_BAR); packetDecoder[0xa2] = () -> send(ChatMessageType.SYSTEM); packetDecoder[0xa3] = this::countdown; + packetDecoder[0xa4] = this::chat; + packetDecoder[0xa5] = this::system; packetDecoder[0xb0] = () -> pasteSchem(Fight.getBlueTeam()); packetDecoder[0xb1] = () -> pasteSchem(Fight.getRedTeam()); packetDecoder[0xb2] = this::teams; @@ -115,6 +118,8 @@ public class PacketProcessor { packetDecoder[0xc2] = this::bossBar; packetDecoder[0xc3] = this::subtitle; packetDecoder[0xc4] = this::printWin; + packetDecoder[0xc5] = this::messageSubtitle; + packetDecoder[0xc6] = this::winMessage; packetDecoder[0xef] = source::readUTF; packetDecoder[0xff] = this::tick; @@ -125,6 +130,41 @@ public class PacketProcessor { task = Bukkit.getScheduler().runTaskTimer(FightSystem.getPlugin(), this::process, 1, 1); } + private void winMessage() throws IOException { + byte team = source.readByte(); + Message message = readMessage(); + + execSync(() -> { + FightTeam winner = null; + if(team == 0x01) + winner = Fight.getBlueTeam(); + else if(team == 0x02) + winner = Fight.getRedTeam(); + + if(Config.replayserver() || ArenaMode.AntiReplay.contains(Config.mode)) { + FightSystem.setSpectateState(winner, "Replay ends", message.getMsg(), message.getParams()); + }else{ + FightUI.printWin(winner, message.getMsg(), message.getParams()); + new EventSpectateCountdown().enable(); + } + }); + } + + private void system() throws IOException { + Message message = readMessage(); + FightSystem.getMessage().broadcast(message.getMsg(), message.getParams()); + } + + private void messageSubtitle() throws IOException { + Message message = readMessage(); + FightUI.addSubtitle(message.getMsg(), message.getParams()); + } + + private void chat() throws IOException { + Message message = readMessage(); + FightSystem.getMessage().chat(message.getMsg(), message.getParams()); + } + private void runSync() { synchronized (syncList) { for(Runnable runnable : syncList) { @@ -242,7 +282,7 @@ public class PacketProcessor { private void countdown() throws IOException { String message = source.readUTF(); int displaytime = source.readInt(); - String appendix = source.readUTF(); + Message appendix = readMessage(); Bukkit.getOnlinePlayers().forEach(p -> Countdown.sendCountdownMessage(p, message, displaytime, appendix)); } @@ -384,25 +424,28 @@ public class PacketProcessor { private void subtitle() throws IOException { String subtitle = source.readUTF(); - FightUI.addSubtitle(subtitle); + FightUI.addSubtitle("OLD_STRING", subtitle); } private void printWin() throws IOException { String title = source.readUTF(); String subtitle = source.readUTF(); - FightUI.printWin(title, subtitle); - } - - private void endReplay(){ - REntity.dieAll(); - freezer.disable(); + Bukkit.getOnlinePlayers().forEach(p -> { + p.resetTitle(); + WorldOfColorWrapper.impl.sendTitle(p, title, subtitle, 5, 40, 5); + }); if(Config.replayserver() || ArenaMode.AntiReplay.contains(Config.mode)) { - FightSystem.setSpectateState(null, "Replay ends", null); + FightState.setFightState(FightState.SPECTATE); }else{ - FightSystem.getMessage().broadcast("REPLAY_ENDS"); new EventSpectateCountdown().enable(); } + } + + private void endReplay() { + REntity.dieAll(); + freezer.disable(); + FightSystem.getMessage().broadcast("REPLAY_ENDS"); replaying = false; } @@ -460,7 +503,8 @@ public class PacketProcessor { } } - private Object[] readMessageParams() throws IOException { + private Message readMessage() throws IOException { + String msg = source.readUTF(); List params = new ArrayList<>(); int type; @@ -495,7 +539,7 @@ public class PacketProcessor { } } while(type != 0x00); - return params.toArray(); + return new Message(msg, params.toArray()); } private interface PacketParser{ diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/record/Recorder.java b/FightSystem_Core/src/de/steamwar/fightsystem/record/Recorder.java index 936f74e..5d15e7b 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/record/Recorder.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/record/Recorder.java @@ -27,6 +27,7 @@ import de.steamwar.fightsystem.fight.FightTeam; import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.utils.BlockIdWrapper; import de.steamwar.fightsystem.utils.CraftbukkitWrapper; +import de.steamwar.fightsystem.utils.Message; import de.steamwar.fightsystem.utils.SWSound; import de.steamwar.sql.Schematic; import de.steamwar.sql.SteamwarUser; @@ -93,9 +94,9 @@ public interface Recorder { * PlayerItemPacket (0x07) + int EntityId + String item + boolean enchanted + String slot * ArrowSpawnPacket (0x08) + int EntityId * FireballSpawnPacket (0x09) + int EntityId - * BowSpanPacket (0x0A) + int EntityId + boolean start + hand - * PlayerDamagePacket (0x0B) + int EntityId - * SetOnFire (0x0C) + int EntityId + boolean perma + * BowSpanPacket (0x0a) + int EntityId + boolean start + hand + * PlayerDamagePacket (0x0b) + int EntityId + * SetOnFire (0x0c) + int EntityId + boolean perma * * ArenaInfo (0x20) + bool blueNegZ + byte arenaY + int arenaMinX + int arenaMinZ * @@ -107,22 +108,26 @@ public interface Recorder { * ShortBlockPacket (0x35) + pos relative to ArenaMinX,BluePasteY,ArenaMinZ byte, byte, byte + short BlockState * * - * ChatPacket (0xA0) + String message - * DEPRECATED ActionBarPacket (0xA1) + String message - * SystemPacket (0xA2) + String message - * CountdownPacket (0xA3) + String message, int displaytime, String appendix + * DEPRECATED ChatPacket (0xa0) + String message + * DEPRECATED ActionBarPacket (0xa1) + String message + * DEPRECATED SystemPacket (0xa2) + String message + * CountdownPacket (0xa3) + String message, int displaytime, Message appendix + * ChatPacket (0xa4) + Message + * SystemPacket (0xa5) + Message * - * BlueSchemPacket (0xB0) + int blueSchemId - * RedSchemPacket (0xB1) + int redSchemId - * TeamIDPacket (0xB2) + int blueTeamId, redTeamId - * BlueEmbeddedSchemPacket (0xB3) + int blueSchemId + gzipt NBT blob - * RedEmbeddedSchemPacket (0xB4) + int redSchemId + gzipt NBT blob + * BlueSchemPacket (0xb0) + int blueSchemId + * RedSchemPacket (0xb1) + int redSchemId + * TeamIDPacket (0xb2) + int blueTeamId, redTeamId + * BlueEmbeddedSchemPacket (0xb3) + int blueSchemId + gzipt NBT blob + * RedEmbeddedSchemPacket (0xb4) + int redSchemId + gzipt NBT blob * - * DEPRECATED ScoreboardTitlePacket (0xC0) + String scoreboardTitle - * DEPRECATED ScoreboardDataPacket (0xC1) + String key + int value - * BossBarPacket (0xC2) + double leftBlueProgress, leftRedProgress + String leftBlueText, leftRedText - * SubtitlePacket (0xC3) + String subtitle - * PrintWinPacket (0xC4) + String title, subtitle + * DEPRECATED ScoreboardTitlePacket (0xc0) + String scoreboardTitle + * DEPRECATED ScoreboardDataPacket (0xc1) + String key + int value + * BossBarPacket (0xc2) + double leftBlueProgress, leftRedProgress + String leftBlueText, leftRedText + * DEPRECATED SubtitlePacket (0xc3) + String subtitle + * DEPRECATED PrintWinPacket (0xc4) + String title, subtitle + * SubtitlePacket (0xc5) + Message + * WinPacket (0xc6) + byte team + Message subtitle * * CommentPacket (0xfe) + String comment * TickPacket (0xff) @@ -236,18 +241,18 @@ public interface Recorder { write(0x34, soundType, volume, pitch); } - default void chat(String s) { - write(0xa0, s); - } - - default void systemChat(String s) { - write(0xa2, s); - } - - default void countdown(String message, int displaytime, String appendix) { + default void countdown(String message, int displaytime, Message appendix) { write(0xa3, message, displaytime, appendix); } + default void chat(String msg, Object... params) { + write(0xa4, new Message(msg, params)); + } + + default void system(String msg, Object... params) { + write(0xa5, new Message(msg, params)); + } + default void teamIds(int blueTeamId, int redTeamId) { write(0xb2, blueTeamId, redTeamId); } @@ -280,16 +285,27 @@ public interface Recorder { write(embedId, schemId, buffer.toByteArray()); } + static void copy(InputStream input, OutputStream output) throws IOException { + int bytes; + for(byte[] buffer = new byte[8192]; (bytes = input.read(buffer)) > 0;) { + output.write(buffer, 0, bytes); + } + } + default void bossBar(double leftBlueProgress, double leftRedProgress, String leftBlueText, String leftRedText) { write(0xc2, leftBlueProgress, leftRedProgress, leftBlueText, leftRedText); } - default void subtitle(String subtitle) { - write(0xc3, subtitle); + default void subtitle(Message subtitle) { + write(0xc5, subtitle); } - default void printWin(String title, String subtitle) { - write(0xc4, title, subtitle); + default void winMessage(FightTeam team, String subtitle, Object... params) { + byte bTeam = 0x00; + if(team != null) { + bTeam = (byte) (team.isBlue() ? 0x01 : 0x02); + } + write(0xc6, bTeam, new Message(subtitle, params)); } default void tick(){ @@ -327,13 +343,15 @@ public interface Recorder { stream.writeUTF((String)o); else if(o instanceof byte[]) stream.write((byte[])o); + else if(o instanceof Message) + writeMessage(stream, (Message) o); else throw new SecurityException("Undefined write for: " + o.getClass().getName()); } - default void writeMessage(DataOutputStream stream, String message, Object... params) throws IOException { - stream.writeUTF(message); - for(Object o : params) { + default void writeMessage(DataOutputStream stream, Message message) throws IOException { + stream.writeUTF(message.getMsg()); + for(Object o : message.getParams()) { if(o instanceof Boolean) stream.writeByte(0x01); else if(o instanceof Byte) @@ -355,10 +373,4 @@ public interface Recorder { stream.writeByte(0x00); } - static void copy(InputStream var0, OutputStream var1) throws IOException { - int var5; - for(byte[] var4 = new byte[8192]; (var5 = var0.read(var4)) > 0;) { - var1.write(var4, 0, var5); - } - } } diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/utils/FightStatistics.java b/FightSystem_Core/src/de/steamwar/fightsystem/utils/FightStatistics.java index 9c9eacf..ac6d229 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/utils/FightStatistics.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/utils/FightStatistics.java @@ -115,8 +115,8 @@ public class FightStatistics { int newRedElo = (int) Math.round(redElo + K * (1 - blueResult - redWinExpectation)); Elo.setElo(blueLeader, gameMode, newBlueElo); Elo.setElo(redLeader, gameMode, newRedElo); - FightSystem.broadcast("§7ELO von " + Fight.getBlueTeam().getPrefix() + SteamwarUser.get(blueLeader).getUserName() + "§8: §7" + blueElo + "§8Ȥe" + newBlueElo); - FightSystem.broadcast("§7ELO von " + Fight.getRedTeam().getPrefix() + SteamwarUser.get(redLeader).getUserName() + "§8: §7" + redElo + "§8Ȥe" + newRedElo); + FightSystem.broadcast("UI_ELO", Fight.getBlueTeam().getPrefix(), SteamwarUser.get(blueLeader).getUserName(), blueElo, newBlueElo); + FightSystem.broadcast("UI_ELO", Fight.getRedTeam().getPrefix(), SteamwarUser.get(redLeader).getUserName(), redElo, newRedElo); } } diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/utils/FightUI.java b/FightSystem_Core/src/de/steamwar/fightsystem/utils/FightUI.java index cf8f3fe..da9df62 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/utils/FightUI.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/utils/FightUI.java @@ -169,27 +169,30 @@ public class FightUI { } - private static final Queue queue = new LinkedList<>(); + private static final Queue queue = new LinkedList<>(); private static boolean subtitleScheduled = false; - public static void printWin(String title, String winreason) { + public static void printWin(FightTeam winner, String subtitle, Object... params) { queue.clear(); - FightSystem.getPlugin().getLogger().log(Level.INFO, title + " " + winreason); - GlobalRecorder.getInstance().printWin(title, winreason); - Bukkit.getOnlinePlayers().forEach(p -> { - p.resetTitle(); - WorldOfColorWrapper.impl.sendTitle(p, title, winreason, 5, 40, 5); - }); + FightSystem.getPlugin().getLogger().log(Level.INFO, winner + " " + FightSystem.getMessage().parse(subtitle, null, params)); + GlobalRecorder.getInstance().winMessage(winner, subtitle, params); + + Bukkit.getOnlinePlayers().forEach(Player::resetTitle); + if (winner != null) + Bukkit.getOnlinePlayers().forEach(p -> WorldOfColorWrapper.impl.sendTitle(p, FightSystem.getMessage().parse("UI_WIN", p, winner.getColor(), winner.getName()), FightSystem.getMessage().parse(subtitle, p, params), 5, 40, 5)); + else + Bukkit.getOnlinePlayers().forEach(p -> WorldOfColorWrapper.impl.sendTitle(p, FightSystem.getMessage().parse("UI_DRAW", p), FightSystem.getMessage().parse(subtitle, p, params), 5, 40, 5)); } - public static void addSubtitle(String message) { + public static void addSubtitle(String msg, Object... params) { if(FightState.Spectate.contains(FightState.getFightState())) return; + Message message = new Message(msg, params); queue.add(message); GlobalRecorder.getInstance().subtitle(message); - FightSystem.getPlugin().getLogger().log(Level.INFO, message); + FightSystem.getPlugin().getLogger().log(Level.INFO, FightSystem.getMessage().parse(msg, null, params)); if(!subtitleScheduled) printSubtitle(); @@ -200,9 +203,9 @@ public class FightUI { subtitleScheduled = false; return; } - String message = queue.poll(); + Message message = queue.poll(); - Bukkit.getOnlinePlayers().forEach(p -> WorldOfColorWrapper.impl.sendTitle(p, "", message, 5, 40, 5)); + Bukkit.getOnlinePlayers().forEach(p -> WorldOfColorWrapper.impl.sendTitle(p, "", FightSystem.getMessage().parse(message.getMsg(), p, message.getParams()), 5, 40, 5)); Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), FightUI::printSubtitle, 50); subtitleScheduled = true; } diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/utils/Message.java b/FightSystem_Core/src/de/steamwar/fightsystem/utils/Message.java new file mode 100644 index 0000000..a142a7e --- /dev/null +++ b/FightSystem_Core/src/de/steamwar/fightsystem/utils/Message.java @@ -0,0 +1,38 @@ +/* + 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; + +public class Message { + private final String msg; + private final Object[] params; + + public Message(String msg, Object... params) { + this.msg = msg; + this.params = params; + } + + public String getMsg() { + return msg; + } + + public Object[] getParams() { + return params; + } +} diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/EventTeamOffWincondition.java b/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/EventTeamOffWincondition.java index 6d30380..e71a468 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/EventTeamOffWincondition.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/EventTeamOffWincondition.java @@ -33,7 +33,7 @@ public class EventTeamOffWincondition extends Wincondition{ @Override public void enable() { if(Fight.getBlueTeam().allPlayersOut() && Fight.getRedTeam().allPlayersOut()){ - win(null, "§7Beide Teams offline"); + win(null, "WIN_OFFLINE_BOTH"); }else{ teamOff(Fight.getBlueTeam()); teamOff(Fight.getRedTeam()); @@ -49,7 +49,7 @@ public class EventTeamOffWincondition extends Wincondition{ private void teamOff(FightTeam team){ if(team.allPlayersOut()){ - win(Fight.getOpposite(team), team.getColoredName() + " §7offline"); + win(Fight.getOpposite(team), "WIN_OFFLINE", team.getColoredName()); } } } diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/RankedPlayerLeftWincondition.java b/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/RankedPlayerLeftWincondition.java index 9a1b9ba..33f3045 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/RankedPlayerLeftWincondition.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/RankedPlayerLeftWincondition.java @@ -44,7 +44,7 @@ public class RankedPlayerLeftWincondition extends Wincondition implements Listen return; if(team.isPlayerLeader(player)) { - win(Fight.getOpposite(team), team.getPrefix() + team.getLeader().getPlayer().getName() + " §7hat den Kampf verlassen"); + win(Fight.getOpposite(team), "WIN_RANKED_LEFT", team.getPrefix() + team.getLeader().getPlayer().getName()); } } } diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/Wincondition.java b/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/Wincondition.java index 871019e..06f4138 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/Wincondition.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/Wincondition.java @@ -47,8 +47,8 @@ public abstract class Wincondition { return timeOverCountdown.getCountdown(); } - protected void win(FightTeam team, String subtitle){ - FightSystem.setSpectateState(team, windescription, subtitle); + protected void win(FightTeam team, String subtitle, Object... params){ + FightSystem.setSpectateState(team, windescription, subtitle, params); } protected FightTeam isTarget(Player player){ diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionAllDead.java b/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionAllDead.java index 15479fd..882b9ad 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionAllDead.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionAllDead.java @@ -57,6 +57,6 @@ public class WinconditionAllDead extends Wincondition implements Listener { return; } - win(Fight.getOpposite(team), team.getPrefix() + "Alle Spieler kampfunfähig"); + win(Fight.getOpposite(team), "WIN_ALL_DEAD", team.getPrefix()); } } diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionCaptainDead.java b/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionCaptainDead.java index 4db4948..6bbaf0e 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionCaptainDead.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionCaptainDead.java @@ -52,7 +52,7 @@ public class WinconditionCaptainDead extends Wincondition implements Listener { return; if(team.isPlayerLeader(player)) { - win(Fight.getOpposite(team), team.getPrefix() + team.getLeader().getPlayer().getName() + " kampfunfähig"); + win(Fight.getOpposite(team), "WIN_LEADER_DEAD", team.getPrefix() + team.getLeader().getPlayer().getName()); } } } diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionHeartRatioTimeout.java b/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionHeartRatioTimeout.java index 6c36956..35d705f 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionHeartRatioTimeout.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionHeartRatioTimeout.java @@ -39,11 +39,11 @@ public class WinconditionHeartRatioTimeout extends Wincondition { double redHeartRatio = Fight.getRedTeam().getHeartRatio(); if(blueHeartRatio > redHeartRatio) { - win(Fight.getBlueTeam(), Fight.getBlueTeam().getPrefix() + "Mehr verbleibende Leben"); + win(Fight.getBlueTeam(), "WIN_MORE_HEALTH", Fight.getBlueTeam().getPrefix()); }else if(blueHeartRatio < redHeartRatio){ - win(Fight.getRedTeam(), Fight.getRedTeam().getPrefix() + "Mehr verbleibende Leben"); + win(Fight.getRedTeam(), "WIN_MORE_HEALTH", Fight.getRedTeam().getPrefix()); }else{ - win(null, "§7Zeit abgelaufen"); + win(null, "WIN_TIME_OVER"); } } } diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionPercentSystem.java b/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionPercentSystem.java index 6610031..0d815ea 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionPercentSystem.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionPercentSystem.java @@ -91,7 +91,7 @@ public class WinconditionPercentSystem extends Wincondition implements Listener, destroyedBlocks += event.blockList().size(); percent = (double)destroyedBlocks * 100 / volume; if(percent >= Config.PercentWin) { - win(Fight.getOpposite(team), team.getColoredName() + " §7zu beschädigt"); + win(Fight.getOpposite(team), "WIN_PERCENT", team.getColoredName()); } } } diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionPercentTimeout.java b/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionPercentTimeout.java index 2dc96c0..0d8b4f4 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionPercentTimeout.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionPercentTimeout.java @@ -39,11 +39,11 @@ public class WinconditionPercentTimeout extends Wincondition { double redPercent = Wincondition.percentWincondition.getPercent(Fight.getRedTeam()); if(bluePercent > redPercent) { - win(Fight.getRedTeam(), Fight.getRedTeam().getColoredName() + " §7weniger beschädigt"); + win(Fight.getRedTeam(), "WIN_LESS_DAMAGE", Fight.getRedTeam().getColoredName()); }else if(bluePercent < redPercent){ - win(Fight.getBlueTeam(), Fight.getBlueTeam().getColoredName() + " §7weniger beschädigt"); + win(Fight.getBlueTeam(), "WIN_LESS_DAMAGE", Fight.getBlueTeam().getColoredName()); }else{ - win(null, "§7Zeit abgelaufen"); + win(null, "WIN_TIME_OVER"); } } } diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionPoints.java b/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionPoints.java index 6430a17..7daf91d 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionPoints.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionPoints.java @@ -69,11 +69,11 @@ public class WinconditionPoints extends Wincondition implements PrintableWincond int bluePoints = teamMap.get(Fight.getBlueTeam()).getPoints(); if(bluePoints < redPoints) { - win(Fight.getRedTeam(), Fight.getRedTeam().getPrefix() + " hat mehr Punkte"); + win(Fight.getRedTeam(), "WIN_POINTS", Fight.getRedTeam().getPrefix()); }else if(bluePoints > redPoints){ - win(Fight.getBlueTeam(), Fight.getBlueTeam().getPrefix() + " hat mehr Punkte"); + win(Fight.getBlueTeam(), "WIN_POINTS", Fight.getBlueTeam().getPrefix()); }else{ - win(null, "§7Gleicher Punktestand"); + win(null, "WIN_POINTS_EQUAL"); } } diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionPumpkinTechKO.java b/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionPumpkinTechKO.java index 82db796..036f3b8 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionPumpkinTechKO.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionPumpkinTechKO.java @@ -76,7 +76,7 @@ public class WinconditionPumpkinTechKO extends Wincondition implements Printable }); if(pumpkins == 0) { - win(Fight.getOpposite(team), team.getColoredName() + " ist Tech K.O."); + win(Fight.getOpposite(team), "WIN_TECHKO", team.getColoredName()); } } } diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionRelativePercent.java b/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionRelativePercent.java index 219d1cd..8eaa0ae 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionRelativePercent.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionRelativePercent.java @@ -99,7 +99,7 @@ public class WinconditionRelativePercent extends Wincondition implements Printab return; if(getPercent() >= Config.PercentWin){ - FightSystem.setSpectateState(Fight.getOpposite(team), "RelativePercent", team.getColoredName() + " §7zu beschädigt"); + FightSystem.setSpectateState(Fight.getOpposite(team), "RelativePercent", "WIN_PERCENT", team.getColoredName()); } } diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionTimeTechKO.java b/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionTimeTechKO.java index 88fbf70..f1f6577 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionTimeTechKO.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionTimeTechKO.java @@ -25,6 +25,7 @@ import de.steamwar.fightsystem.fight.Fight; import de.steamwar.fightsystem.fight.FightTeam; import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.StateDependentTask; +import de.steamwar.fightsystem.utils.Message; import de.steamwar.fightsystem.utils.SWSound; import org.bukkit.Bukkit; import org.bukkit.World; @@ -108,20 +109,14 @@ public class WinconditionTimeTechKO extends Wincondition { private final FightTeam team; public TechKOCountdown(FightTeam team, int countdownTime) { - super(countdownTime, SWSound.BLOCK_NOTE_PLING, false); + super(countdownTime, new Message("TECHKO_COUNTDOWN", team.getColoredName()), SWSound.BLOCK_NOTE_PLING, false); this.team = team; super.enable(); } - @Override - public final String countdownCounting() { - //TODO: ARRRG! - return "bis " + team.getColoredName() + " §feinen Schuss abgegeben haben muss!"; - } - @Override public void countdownFinished() { - win(Fight.getOpposite(team), team.getColoredName() + " ist Tech K.O."); + win(Fight.getOpposite(team), "WIN_TECHKO", team.getColoredName()); } } } diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionTimeout.java b/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionTimeout.java index f720f8a..3207fee 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionTimeout.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionTimeout.java @@ -34,6 +34,6 @@ public class WinconditionTimeout extends Wincondition { } protected void timeOver() { - win(null, "§7Zeit abgelaufen"); + win(null, "WIN_TIME_OVER"); } } diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionWaterTechKO.java b/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionWaterTechKO.java index 9367406..4a7b05c 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionWaterTechKO.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionWaterTechKO.java @@ -73,7 +73,7 @@ public class WinconditionWaterTechKO extends Wincondition implements PrintableWi }); if(water == 0){ - win(Fight.getOpposite(team), team.getColoredName() + " ist Tech K.O."); + win(Fight.getOpposite(team), "WIN_TECHKO", team.getColoredName()); } } } -- 2.39.2 From 9eefaf9e6ba8f2e7dda64299c3c822df70580f4a Mon Sep 17 00:00:00 2001 From: Lixfel Date: Sun, 24 Oct 2021 15:04:12 +0200 Subject: [PATCH 5/8] Full multiling Signed-off-by: Lixfel --- .../fightsystem/utils/BountifulWrapper8.java | 48 +++--------- .../fightsystem/utils/BountifulWrapper9.java | 38 +++------- .../fightsystem/FightSystem.properties | 14 ++++ .../fightsystem/record/PacketProcessor.java | 13 ++++ .../steamwar/fightsystem/record/Recorder.java | 10 ++- .../fightsystem/utils/BountifulWrapper.java | 6 +- .../steamwar/fightsystem/utils/FightUI.java | 75 ++++++++++++------- .../winconditions/PrintableWincondition.java | 3 +- .../WinconditionPercentSystem.java | 5 +- .../winconditions/WinconditionPoints.java | 5 +- .../WinconditionPumpkinTechKO.java | 5 +- .../WinconditionRelativePercent.java | 5 +- .../WinconditionWaterTechKO.java | 5 +- 13 files changed, 121 insertions(+), 111 deletions(-) diff --git a/FightSystem_8/src/de/steamwar/fightsystem/utils/BountifulWrapper8.java b/FightSystem_8/src/de/steamwar/fightsystem/utils/BountifulWrapper8.java index cd7a5ef..dc31f36 100644 --- a/FightSystem_8/src/de/steamwar/fightsystem/utils/BountifulWrapper8.java +++ b/FightSystem_8/src/de/steamwar/fightsystem/utils/BountifulWrapper8.java @@ -21,6 +21,7 @@ package de.steamwar.fightsystem.utils; import com.comphenix.tinyprotocol.Reflection; import de.steamwar.fightsystem.Config; +import de.steamwar.fightsystem.fight.FightTeam; import de.steamwar.fightsystem.listener.Recording; import de.steamwar.fightsystem.record.GlobalRecorder; import de.steamwar.fightsystem.record.REntity; @@ -150,49 +151,24 @@ public class BountifulWrapper8 implements BountifulWrapper.IBountifulWrapper { } } - private final Map barMap = new HashMap<>(); + private final Set seesDragon = new HashSet<>(); + private final PacketPlayOutSpawnEntityLiving spawnDragon; + private final int spawnDragonId; @Override - public void setBossbar(double leftBlueProgress, double leftRedProgress, String leftBlueText, String leftRedText) { - barMap.clear(); - barMap.put(FightUI.BossBarType.BLUE_LEFT, createPacket(leftBlueProgress, leftBlueText)); - barMap.put(FightUI.BossBarType.RED_LEFT, createPacket(leftRedProgress, leftRedText)); - } + public void sendBar(Player player, FightTeam team, double progress, String text) { + seesDragon.removeIf(p -> !p.isOnline()); + + if(!seesDragon.contains(player)) { + ((CraftPlayer)player).getHandle().playerConnection.sendPacket(spawnDragon); + seesDragon.add(player); + } - private PacketPlayOutEntityMetadata createPacket(double progress, String text) { DataWatcher watcher = new DataWatcher(null); watcher.a(0, (byte) 0x20); watcher.a(2, text); watcher.a(3, (byte) 1); watcher.a(4, (byte) 1); watcher.a(6, (float)(progress * 200)); - //watcher.a(10, text); - //watcher.a(11, (byte) 1); - return new PacketPlayOutEntityMetadata(spawnDragonId, watcher, true); - } - - @Override - public void removeFromBar(Player player, FightUI.BossBarType type) { - // not used - } - - @Override - public void addToBar(Player player, FightUI.BossBarType type) { - // not used - } - - private final Set seesDragon = new HashSet<>(); - private final PacketPlayOutSpawnEntityLiving spawnDragon; - private final int spawnDragonId; - @Override - public void broadcastBossbar() { - seesDragon.removeIf(player -> !player.isOnline()); - Bukkit.getOnlinePlayers().forEach(player -> { - if(!seesDragon.contains(player)) { - ((CraftPlayer)player).getHandle().playerConnection.sendPacket(spawnDragon); - seesDragon.add(player); - } - - ((CraftPlayer) player).getHandle().playerConnection.sendPacket(barMap.get(FightUI.getInstance().bossBarType(player))); - }); + ((CraftPlayer) player).getHandle().playerConnection.sendPacket(new PacketPlayOutEntityMetadata(spawnDragonId, watcher, true)); } } diff --git a/FightSystem_9/src/de/steamwar/fightsystem/utils/BountifulWrapper9.java b/FightSystem_9/src/de/steamwar/fightsystem/utils/BountifulWrapper9.java index 0a57621..dd88a34 100644 --- a/FightSystem_9/src/de/steamwar/fightsystem/utils/BountifulWrapper9.java +++ b/FightSystem_9/src/de/steamwar/fightsystem/utils/BountifulWrapper9.java @@ -20,7 +20,6 @@ package de.steamwar.fightsystem.utils; import com.comphenix.tinyprotocol.Reflection; -import de.steamwar.fightsystem.fight.Fight; import de.steamwar.fightsystem.fight.FightTeam; import de.steamwar.fightsystem.listener.Recording; import de.steamwar.fightsystem.record.GlobalRecorder; @@ -51,12 +50,6 @@ public class BountifulWrapper9 implements BountifulWrapper.IBountifulWrapper { private static final Object mainHand = enumHand.getEnumConstants()[0]; private static final Reflection.FieldAccessor blockPlaceHand = Reflection.getField(Recording.blockPlacePacket, enumHand, 0); - public BountifulWrapper9() { - for(FightUI.BossBarType type : FightUI.BossBarType.values()) { - barMap.put(type, Bukkit.createBossBar(type.name(), BarColor.WHITE, BarStyle.SOLID)); - } - } - @Override public boolean mainHand(Object packet) { return blockPlaceHand.get(packet) == mainHand; @@ -193,14 +186,15 @@ public class BountifulWrapper9 implements BountifulWrapper.IBountifulWrapper { } } - private final Map barMap = new HashMap<>(); + private final Map barMap = new HashMap<>(); @Override - public void setBossbar(double leftBlueProgress, double leftRedProgress, String leftBlueText, String leftRedText) { - setupTeamBar(Fight.getBlueTeam(), barMap.get(FightUI.BossBarType.BLUE_LEFT), leftBlueProgress, leftBlueText); - setupTeamBar(Fight.getRedTeam(), barMap.get(FightUI.BossBarType.RED_LEFT), leftRedProgress, leftRedText); - } + public void sendBar(Player player, FightTeam team, double progress, String text) { + barMap.keySet().removeIf(p -> !p.isOnline()); - private void setupTeamBar(FightTeam team, BossBar bar, double progress, String title) { + if(!barMap.containsKey(player)) + barMap.put(player, Bukkit.createBossBar(player.getName(), BarColor.WHITE, BarStyle.SOLID)); + + BossBar bar = barMap.get(player); BarColor color = chat2bar(team.getColor()); if(bar.getColor() != color) bar.setColor(color); @@ -208,7 +202,8 @@ public class BountifulWrapper9 implements BountifulWrapper.IBountifulWrapper { if(bar.getProgress() != progress) bar.setProgress(progress); - bar.setTitle(title); + if(!bar.getTitle().equals(text)) + bar.setTitle(text); } private BarColor chat2bar(ChatColor color) { @@ -239,19 +234,4 @@ public class BountifulWrapper9 implements BountifulWrapper.IBountifulWrapper { return BarColor.WHITE; } } - - @Override - public void removeFromBar(Player player, FightUI.BossBarType type) { - barMap.get(type).removePlayer(player); - } - - @Override - public void addToBar(Player player, FightUI.BossBarType type) { - barMap.get(type).addPlayer(player); - } - - @Override - public void broadcastBossbar() { - // Handled by Spigot BossBarAPI - } } diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/FightSystem.properties b/FightSystem_Core/src/de/steamwar/fightsystem/FightSystem.properties index bdbdfcf..2d16f10 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/FightSystem.properties +++ b/FightSystem_Core/src/de/steamwar/fightsystem/FightSystem.properties @@ -184,6 +184,20 @@ UI_ELO= UI_WIN={0}Sieg {1} UI_DRAW=§7Unentschieden +BAR_PRE_LEADER=§7Warten auf Teamleader +BAR_PRE_SCHEM={1} §7Schemauswahl {0} {2} +BAR_PREPARE={1} {3} §7Vorbereitung {0} {4} {2} +BAR_PRE_RUNNING={1} {3} §7Kampfbeginn in {0} {4} {2} +BAR_RUNNING0={1} {3} lW {0} rW {4} {2} +BAR_RUNNING1={1} {3} {5} {0} {6} {4} {2} +BAR_RUNNING2={1} {3} {5} {7} {0} {6} {8} {4} {2} +BAR_RUNNING3={1} {3} {5} {7} {9} {0} {6} {8} {10} {4} {2} +BAR_SPECTATE={1} §7Kampf vorbei {0} {2} +BAR_POINTS={0} §8Punkte +BAR_PERCENT={0}§8% +BAR_CANNONS={0} §8Kanonen +BAR_WATER={0} §8Wasser + # Winconditions HELLS_BELLS_COUNTDOWN=bis die Bomben fallen diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/record/PacketProcessor.java b/FightSystem_Core/src/de/steamwar/fightsystem/record/PacketProcessor.java index 3541258..23e937a 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/record/PacketProcessor.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/record/PacketProcessor.java @@ -120,6 +120,7 @@ public class PacketProcessor { packetDecoder[0xc4] = this::printWin; packetDecoder[0xc5] = this::messageSubtitle; packetDecoder[0xc6] = this::winMessage; + packetDecoder[0xc7] = this::bossBarMessage; packetDecoder[0xef] = source::readUTF; packetDecoder[0xff] = this::tick; @@ -421,6 +422,15 @@ public class PacketProcessor { FightUI.getInstance().setBossbar(leftBlueProgress, leftRedProgress, leftBlueText, leftRedText); } + private void bossBarMessage() throws IOException { + double leftBlueProgress = source.readDouble(); + double leftRedProgress = source.readDouble(); + Message leftBlueText = readMessage(); + Message leftRedText = readMessage(); + + FightUI.getInstance().setBossbar(leftBlueProgress, leftRedProgress, leftBlueText, leftRedText); + } + private void subtitle() throws IOException { String subtitle = source.readUTF(); @@ -534,6 +544,9 @@ public class PacketProcessor { case 0x07: params.add(source.readUTF()); break; + case 0x08: + params.add(readMessage()); + break; default: throw new IOException("Unknown message param type " + type); } diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/record/Recorder.java b/FightSystem_Core/src/de/steamwar/fightsystem/record/Recorder.java index 5d15e7b..e4e4ee0 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/record/Recorder.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/record/Recorder.java @@ -123,11 +123,12 @@ public interface Recorder { * * DEPRECATED ScoreboardTitlePacket (0xc0) + String scoreboardTitle * DEPRECATED ScoreboardDataPacket (0xc1) + String key + int value - * BossBarPacket (0xc2) + double leftBlueProgress, leftRedProgress + String leftBlueText, leftRedText + * DEPRECATED BossBarPacket (0xc2) + double leftBlueProgress, leftRedProgress + String leftBlueText, leftRedText * DEPRECATED SubtitlePacket (0xc3) + String subtitle * DEPRECATED PrintWinPacket (0xc4) + String title, subtitle * SubtitlePacket (0xc5) + Message * WinPacket (0xc6) + byte team + Message subtitle + * BossBarPacket (0xc7) + double leftBlueProgress, leftRedProgress + Message leftBlueText, leftRedText * * CommentPacket (0xfe) + String comment * TickPacket (0xff) @@ -142,6 +143,7 @@ public interface Recorder { * 0x05: float following * 0x06: double following * 0x07: String following + * 0x08: Message following * */ default void playerJoins(Player p){ @@ -292,8 +294,8 @@ public interface Recorder { } } - default void bossBar(double leftBlueProgress, double leftRedProgress, String leftBlueText, String leftRedText) { - write(0xc2, leftBlueProgress, leftRedProgress, leftBlueText, leftRedText); + default void bossBar(double leftBlueProgress, double leftRedProgress, Message leftBlueText, Message leftRedText) { + write(0xc7, leftBlueProgress, leftRedProgress, leftBlueText, leftRedText); } default void subtitle(Message subtitle) { @@ -366,6 +368,8 @@ public interface Recorder { stream.writeByte(0x06); else if(o instanceof String) stream.writeByte(0x07); + else if(o instanceof Message) + stream.writeByte(0x08); else throw new SecurityException("Undefined message serialization for: " + o.getClass().getName()); writeObject(stream, o); diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/utils/BountifulWrapper.java b/FightSystem_Core/src/de/steamwar/fightsystem/utils/BountifulWrapper.java index 023d4fe..b951a68 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/utils/BountifulWrapper.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/utils/BountifulWrapper.java @@ -20,6 +20,7 @@ package de.steamwar.fightsystem.utils; import de.steamwar.fightsystem.VersionDependent; +import de.steamwar.fightsystem.fight.FightTeam; import org.bukkit.World; import org.bukkit.entity.Player; import org.bukkit.event.Listener; @@ -54,9 +55,6 @@ public class BountifulWrapper { void setSpawnPacketUUID(Object packet, UUID uuid); void setEquipmentPacketSlot(Object packet, String slot); - void setBossbar(double leftBlueProgress, double leftRedProgress, String leftBlueText, String leftRedText); - void removeFromBar(Player player, FightUI.BossBarType type); - void addToBar(Player player, FightUI.BossBarType type); - void broadcastBossbar(); + void sendBar(Player player, FightTeam team, double progress, String text); } } diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/utils/FightUI.java b/FightSystem_Core/src/de/steamwar/fightsystem/utils/FightUI.java index da9df62..ccd1b12 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/utils/FightUI.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/utils/FightUI.java @@ -33,9 +33,9 @@ import de.steamwar.fightsystem.winconditions.Wincondition; import org.bukkit.Bukkit; import org.bukkit.entity.Player; -import java.util.HashMap; +import java.util.ArrayList; import java.util.LinkedList; -import java.util.Map; +import java.util.List; import java.util.Queue; import java.util.logging.Level; import java.util.stream.Collectors; @@ -47,8 +47,6 @@ public class FightUI { return instance; } - private final Map currentBarType = new HashMap<>(); - public FightUI() { new StateDependentTask(ArenaMode.AntiReplay, FightState.All, this::update, 20, 20); new StateDependentTask(ArenaMode.All, FightState.All, this::sendToPlayers, 5, 5); @@ -73,29 +71,41 @@ public class FightUI { String time = "§7" + (timeLeft/60) + "§8:§7" + (timeLeft%60<10 ? "0" : "") + (timeLeft%60); String bluePlayers = blue.getPrefix() + blue.getAlivePlayers() + "§8/§7" + blue.getPlayerCount(); String redPlayers = red.getPrefix() + red.getAlivePlayers() + "§8/§7" + red.getPlayerCount(); - String redAdditional = Wincondition.getPrintableWinconditions().stream().map(w -> w.getDisplay(red)).collect(Collectors.joining(" ")); - String blueAdditional = Wincondition.getPrintableWinconditions().stream().map(w -> w.getDisplay(blue)).collect(Collectors.joining(" ")); + List redAdditional = Wincondition.getPrintableWinconditions().stream().map(w -> w.getDisplay(red)).collect(Collectors.toList()); + List blueAdditional = Wincondition.getPrintableWinconditions().stream().map(w -> w.getDisplay(blue)).collect(Collectors.toList()); Generator generator; switch(FightState.getFightState()){ case PRE_LEADER_SETUP: - generator = (l, r, lP, rP, lW, rW) -> "§7Warten auf Teamleader"; + generator = (l, r, lP, rP, lW, rW) -> new Message("BAR_PRE_LEADER"); break; case PRE_SCHEM_SETUP: - generator = (l, r, lP, rP, lW, rW) -> l.getColoredName() + " §7Schemauswahl " + time + " " + r.getColoredName(); + generator = (l, r, lP, rP, lW, rW) -> new Message("BAR_PRE_SCHEM", time, l.getColoredName(), r.getColoredName()); break; case POST_SCHEM_SETUP: - generator = (l, r, lP, rP, lW, rW) -> l.getColoredName() + " " + lP + " §7Vorbereitung " + time + " " + rP + " " + r.getColoredName(); + generator = (l, r, lP, rP, lW, rW) -> new Message("BAR_PREPARE", time, l.getColoredName(), r.getColoredName(), lP, rP); break; case PRE_RUNNING: - generator = (l, r, lP, rP, lW, rW) -> l.getColoredName() + " " + lP + " §7Kampfbeginn in " + time + " " + rP + " " + r.getColoredName(); + generator = (l, r, lP, rP, lW, rW) -> new Message("BAR_PRE_RUNNING", time, l.getColoredName(), r.getColoredName(), lP, rP); break; case RUNNING: - generator = (l, r, lP, rP, lW, rW) -> l.getColoredName() + " " + lP + " " + lW + " " + time + " " + rW + " " + rP + " " + r.getColoredName(); + generator = (l, r, lP, rP, lW, rW) -> { + List params = new ArrayList<>(); + params.add(time); + params.add(l.getColoredName()); + params.add(r.getColoredName()); + params.add(lP); + params.add(rP); + for(int i = 0; i < lW.size(); i++) { + params.add(lW.get(i)); + params.add(rW.get(i)); + } + return new Message("BAR_RUNNING" + lW.size(), params.toArray()); + }; break; case SPECTATE: default: - generator = (l, r, lP, rP, lW, rW) -> l.getColoredName() + " §7Kampf vorbei " + time + " " + r.getColoredName(); + generator = (l, r, lP, rP, lW, rW) -> new Message("BAR_SPECTATE", time, l.getColoredName(), r.getColoredName()); break; } @@ -107,31 +117,35 @@ public class FightUI { } private interface Generator { - String gen(FightTeam l, FightTeam r, String lPlayers, String rPlayers, String lWinconditions, String rWinconditions); + Message gen(FightTeam l, FightTeam r, String lPlayers, String rPlayers, List lWinconditions, List rWinconditions); } public void setBossbar(double leftBlueProgress, double leftRedProgress, String leftBlueText, String leftRedText) { - GlobalRecorder.getInstance().bossBar(leftBlueProgress, leftRedProgress, leftBlueText, leftRedText); - BountifulWrapper.impl.setBossbar(leftBlueProgress, leftRedProgress, leftBlueText, leftRedText); + setBossbar(leftBlueProgress, leftRedProgress, new Message("OLD_STRING", leftBlueText), new Message("OLD_STRING", leftRedText)); } - public BossBarType bossBarType(Player player) { - return currentBarType.get(player); + public void setBossbar(double leftBlueProgress, double leftRedProgress, Message leftBlueText, Message leftRedText) { + GlobalRecorder.getInstance().bossBar(leftBlueProgress, leftRedProgress, leftBlueText, leftRedText); + BossBarType.BLUE_LEFT.progress = leftBlueProgress; + BossBarType.RED_LEFT.progress = leftRedProgress; + BossBarType.BLUE_LEFT.text = leftBlueText; + BossBarType.RED_LEFT.text = leftRedText; } private void sendToPlayers() { Bukkit.getOnlinePlayers().forEach(player -> { - BossBarType type = BossBarType.byAngle(CraftbukkitWrapper.impl.headRotation(player)); - BossBarType current = currentBarType.get(player); + BossBarType bar = BossBarType.byAngle(CraftbukkitWrapper.impl.headRotation(player)); - if(type != current) { - if(current != null) - BountifulWrapper.impl.removeFromBar(player, current); - BountifulWrapper.impl.addToBar(player, type); - currentBarType.put(player, type); + Object[] params = bar.text.getParams().clone(); + for(int i = 0; i < params.length; i++) { + if(params[i] instanceof Message) { + Message msg = (Message) params[i]; + params[i] = FightSystem.getMessage().parse(msg.getMsg(), player, msg.getParams()); + } } + + BountifulWrapper.impl.sendBar(player, bar.team, bar.progress, FightSystem.getMessage().parse(bar.text.getMsg(), player, params)); }); - BountifulWrapper.impl.broadcastBossbar(); } private void tpsWatcher() { @@ -141,15 +155,20 @@ public class FightUI { } public enum BossBarType { - BLUE_LEFT(345, 165), - RED_LEFT(165, 345); + BLUE_LEFT(Fight.getBlueTeam(), 345, 165), + RED_LEFT(Fight.getRedTeam(), 165, 345); private static final boolean BLUE_NEG_Z = Config.blueNegZ(); private final double minAngle; private final double maxAngle; - BossBarType(double minAngle, double maxAngle) { + private final FightTeam team; + private double progress; + private Message text; + + BossBarType(FightTeam team, double minAngle, double maxAngle) { + this.team = team; this.minAngle = minAngle; this.maxAngle = maxAngle; } diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/PrintableWincondition.java b/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/PrintableWincondition.java index 31053a8..6af28b0 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/PrintableWincondition.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/PrintableWincondition.java @@ -20,7 +20,8 @@ package de.steamwar.fightsystem.winconditions; import de.steamwar.fightsystem.fight.FightTeam; +import de.steamwar.fightsystem.utils.Message; public interface PrintableWincondition { - String getDisplay(FightTeam team); + Message getDisplay(FightTeam team); } diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionPercentSystem.java b/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionPercentSystem.java index 0d815ea..2f73c42 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionPercentSystem.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionPercentSystem.java @@ -24,6 +24,7 @@ import de.steamwar.fightsystem.fight.Fight; import de.steamwar.fightsystem.fight.FightTeam; import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.StateDependentListener; +import de.steamwar.fightsystem.utils.Message; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.entity.EntityExplodeEvent; @@ -62,8 +63,8 @@ public class WinconditionPercentSystem extends Wincondition implements Listener, } @Override - public String getDisplay(FightTeam team) { - return team.getPrefix() + (Math.round(100.0 * getPercent(team)) / 100.0) + "§8%"; + public Message getDisplay(FightTeam team) { + return new Message("BAR_PERCENT", team.getPrefix() + (Math.round(100.0 * getPercent(team)) / 100.0)); } @Override diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionPoints.java b/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionPoints.java index 7daf91d..b988530 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionPoints.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionPoints.java @@ -27,6 +27,7 @@ import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.StateDependent; import de.steamwar.fightsystem.states.StateDependentCountdown; import de.steamwar.fightsystem.states.StateDependentListener; +import de.steamwar.fightsystem.utils.Message; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; @@ -104,8 +105,8 @@ public class WinconditionPoints extends Wincondition implements PrintableWincond } @Override - public String getDisplay(FightTeam team) { - return team.getPrefix() + teamMap.get(team).getPoints() + " §8Punkte"; + public Message getDisplay(FightTeam team) { + return new Message("BAR_POINTS", team.getPrefix() + teamMap.get(team).getPoints()); } private class TeamPoints { diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionPumpkinTechKO.java b/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionPumpkinTechKO.java index 036f3b8..b6cdfbb 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionPumpkinTechKO.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionPumpkinTechKO.java @@ -24,6 +24,7 @@ import de.steamwar.fightsystem.fight.Fight; import de.steamwar.fightsystem.fight.FightTeam; import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.StateDependentTask; +import de.steamwar.fightsystem.utils.Message; import de.steamwar.inventory.SWItem; import org.bukkit.Bukkit; import org.bukkit.Material; @@ -55,8 +56,8 @@ public class WinconditionPumpkinTechKO extends Wincondition implements Printable } @Override - public String getDisplay(FightTeam team) { - return team.getPrefix() + teamMap.get(team).pumpkins + " §8Kanonen"; + public Message getDisplay(FightTeam team) { + return new Message("BAR_CANNONS", team.getPrefix() + teamMap.get(team).pumpkins); } private class TeamPumpkin { diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionRelativePercent.java b/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionRelativePercent.java index 8eaa0ae..064e444 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionRelativePercent.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionRelativePercent.java @@ -25,6 +25,7 @@ import de.steamwar.fightsystem.fight.Fight; import de.steamwar.fightsystem.fight.FightTeam; import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.StateDependent; +import de.steamwar.fightsystem.utils.Message; import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.World; @@ -63,8 +64,8 @@ public class WinconditionRelativePercent extends Wincondition implements Printab } @Override - public String getDisplay(FightTeam team) { - return team.getPrefix() + (Math.round(100.0 * getPercent(team)) / 100.0) + "§8%"; + public Message getDisplay(FightTeam team) { + return new Message("BAR_PERCENT", team.getPrefix() + (Math.round(100.0 * getPercent(team)) / 100.0)); } public static class TeamPercent extends StateDependent { diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionWaterTechKO.java b/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionWaterTechKO.java index 4a7b05c..8552e24 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionWaterTechKO.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionWaterTechKO.java @@ -25,6 +25,7 @@ import de.steamwar.fightsystem.fight.FightTeam; import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.StateDependentTask; import de.steamwar.fightsystem.utils.FlatteningWrapper; +import de.steamwar.fightsystem.utils.Message; import org.bukkit.Bukkit; import org.bukkit.World; @@ -53,8 +54,8 @@ public class WinconditionWaterTechKO extends Wincondition implements PrintableWi } @Override - public String getDisplay(FightTeam team) { - return team.getPrefix() + teamMap.get(team).water + " §8Wasser"; + public Message getDisplay(FightTeam team) { + return new Message("BAR_WATER", team.getPrefix() + teamMap.get(team).water); } private class TeamWater { -- 2.39.2 From 15e425ac65a020f59db66ab5a1a8865f2acfd993 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Sun, 24 Oct 2021 15:51:15 +0200 Subject: [PATCH 6/8] Fix mapdisplay Signed-off-by: Lixfel --- .../de/steamwar/fightsystem/utils/BountifulWrapper9.java | 7 +++++-- .../src/de/steamwar/fightsystem/utils/FightUI.java | 4 ++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/FightSystem_9/src/de/steamwar/fightsystem/utils/BountifulWrapper9.java b/FightSystem_9/src/de/steamwar/fightsystem/utils/BountifulWrapper9.java index dd88a34..a21a46c 100644 --- a/FightSystem_9/src/de/steamwar/fightsystem/utils/BountifulWrapper9.java +++ b/FightSystem_9/src/de/steamwar/fightsystem/utils/BountifulWrapper9.java @@ -191,8 +191,11 @@ public class BountifulWrapper9 implements BountifulWrapper.IBountifulWrapper { public void sendBar(Player player, FightTeam team, double progress, String text) { barMap.keySet().removeIf(p -> !p.isOnline()); - if(!barMap.containsKey(player)) - barMap.put(player, Bukkit.createBossBar(player.getName(), BarColor.WHITE, BarStyle.SOLID)); + if(!barMap.containsKey(player)) { + BossBar bar = Bukkit.createBossBar(player.getName(), BarColor.WHITE, BarStyle.SOLID); + barMap.put(player, bar); + bar.addPlayer(player); + } BossBar bar = barMap.get(player); BarColor color = chat2bar(team.getColor()); diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/utils/FightUI.java b/FightSystem_Core/src/de/steamwar/fightsystem/utils/FightUI.java index ccd1b12..d5ab97f 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/utils/FightUI.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/utils/FightUI.java @@ -164,8 +164,8 @@ public class FightUI { private final double maxAngle; private final FightTeam team; - private double progress; - private Message text; + private double progress = 0.5; + private Message text = new Message("OLD_STRING", "§7"); BossBarType(FightTeam team, double minAngle, double maxAngle) { this.team = team; -- 2.39.2 From a5f06e6f7cf0d947d83a316fd6d60a7369c44745 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Sun, 24 Oct 2021 15:53:57 +0200 Subject: [PATCH 7/8] Fix countdown replay Signed-off-by: Lixfel --- .../src/de/steamwar/fightsystem/countdown/Countdown.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/countdown/Countdown.java b/FightSystem_Core/src/de/steamwar/fightsystem/countdown/Countdown.java index 5449e17..a2c29a7 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/countdown/Countdown.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/countdown/Countdown.java @@ -100,7 +100,7 @@ public abstract class Countdown { if(this.sound != null && divisor == 1) Fight.playSound(this.sound, 100.0F, 1.0F); - GlobalRecorder.getInstance().countdown(message, divisor, appendix); + GlobalRecorder.getInstance().countdown(message, time / divisor, appendix); Bukkit.getOnlinePlayers().forEach(p -> sendCountdownMessage(p, message, time / divisor, appendix)); } -- 2.39.2 From 1e756abc184f9faf30d264ac3a8cd332fc995196 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Sun, 24 Oct 2021 16:01:25 +0200 Subject: [PATCH 8/8] Fix timing Signed-off-by: Lixfel --- FightSystem_Core/src/de/steamwar/fightsystem/ArenaMode.java | 1 + .../de/steamwar/fightsystem/countdown/PostSchemCountdown.java | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/ArenaMode.java b/FightSystem_Core/src/de/steamwar/fightsystem/ArenaMode.java index bcfb258..ab7cd09 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/ArenaMode.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/ArenaMode.java @@ -52,4 +52,5 @@ public enum ArenaMode { public static final Set Restartable = Collections.unmodifiableSet(EnumSet.of(NORMAL, RANKED, REPLAY)); public static final Set SoloLeader = Collections.unmodifiableSet(EnumSet.of(TEST, CHECK, PREPARE)); public static final Set NotOnBau = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(TEST, CHECK, PREPARE, REPLAY))); + public static final Set VariableTime = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(TEST, CHECK, REPLAY))); } diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/countdown/PostSchemCountdown.java b/FightSystem_Core/src/de/steamwar/fightsystem/countdown/PostSchemCountdown.java index 7a58bbc..812637c 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/countdown/PostSchemCountdown.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/countdown/PostSchemCountdown.java @@ -30,7 +30,7 @@ public class PostSchemCountdown extends Countdown { public PostSchemCountdown() { super(Config.SetupDuration, new Message("POST_SCHEM_COUNTDOWN"), null, false); - new StateDependentCountdown(ArenaMode.AntiTest, FightState.PostSchemSetup, this); + new StateDependentCountdown(ArenaMode.VariableTime, FightState.PostSchemSetup, this); } @Override -- 2.39.2