From a09ee039374be64bbc475fdc5c8ae78b0056bd1b Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Thu, 31 Mar 2022 22:49:24 +0200 Subject: [PATCH 1/7] :art: Using code that is already Present --- src/de/steamwar/bungeecore/ServerStarter.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/de/steamwar/bungeecore/ServerStarter.java b/src/de/steamwar/bungeecore/ServerStarter.java index 1128b7d..e8cd6e3 100644 --- a/src/de/steamwar/bungeecore/ServerStarter.java +++ b/src/de/steamwar/bungeecore/ServerStarter.java @@ -51,6 +51,7 @@ public class ServerStarter { serverJar = mode.serverJar(); directory = new File(SERVER_PATH, mode.getFolder()); arguments.put("config", mode.getConfig()); + constructor = (serverName, port, builder, shutdownCallback) -> new Arenaserver(serverName, mode.getDisplayName(), map, !mode.isRanked(), port, builder, shutdownCallback); tempWorld(SERVER_PATH + mode.getFolder() + "/arenas/" + map); return this; } @@ -61,6 +62,7 @@ public class ServerStarter { worldDir = EVENT_PATH; worldCleanup = () -> {}; arguments.put("fightID", String.valueOf(eventFight.getFightID())); + constructor = (serverName, port, builder, shutdownCallback) -> new Arenaserver(serverName, eventFight.getSpielmodus().getDisplayName(), eventFight.getMap(), false, port, builder, shutdownCallback); String serverName = Team.get(eventFight.getTeamBlue()).getTeamKuerzel() + " vs " + Team.get(eventFight.getTeamRed()).getTeamKuerzel(); serverNameProvider = port -> serverName; -- 2.39.2 From ef8e5a3a0d01730b3ba77da08f6607321e6c5f9d Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Thu, 31 Mar 2022 23:01:20 +0200 Subject: [PATCH 2/7] :sparkles: Add Arena Merging 2.0 --- .../bungeecore/commands/FightCommand.java | 38 +++++++++++++++++++ .../steamwar/messages/BungeeCore.properties | 7 ++++ 2 files changed, 45 insertions(+) diff --git a/src/de/steamwar/bungeecore/commands/FightCommand.java b/src/de/steamwar/bungeecore/commands/FightCommand.java index 736d78d..aeeb8dc 100644 --- a/src/de/steamwar/bungeecore/commands/FightCommand.java +++ b/src/de/steamwar/bungeecore/commands/FightCommand.java @@ -20,6 +20,8 @@ package de.steamwar.bungeecore.commands; import de.steamwar.bungeecore.*; +import de.steamwar.bungeecore.inventory.SWInventory; +import de.steamwar.bungeecore.inventory.SWItem; import de.steamwar.bungeecore.listeners.mods.ModLoaderBlocker; import net.md_5.bungee.api.ChatColor; import net.md_5.bungee.api.CommandSender; @@ -161,6 +163,42 @@ public class FightCommand extends BasicCommand { callback.run(player, mode, map); } + public static boolean suggestMerging(ProxiedPlayer player, ArenaMode mode, String map, FightCallback declineMerge) { + Arenaserver mergable = null; + for (Subserver subserver : Subserver.getServerList()) { + if(subserver instanceof Arenaserver) { + Arenaserver arenaserver = (Arenaserver) subserver; + if(mode.getDisplayName().equals(arenaserver.getMode()) && map.equals(arenaserver.getMap()) && arenaserver.isAllowMerge() && arenaserver.getServer().getPlayers().size() == 1) { + mergable = arenaserver; + break; + } + } + } + + if(mergable != null) { + SWInventory inventory = new SWInventory(player, 9, Message.parse("FIGHT_MERGE_TITLE", player)); + inventory.addItem(0, new SWItem(Message.parse("FIGHT_MERGE_DECLINE", player), 1), click -> { + inventory.close(); + declineMerge.run(player, mode, map); + }); + Arenaserver finalMergable = mergable; + SWItem item = new SWItem("§e" + ArenaMode.getByInternal(finalMergable.getMode()).getDisplayName() + "§7: §e" + finalMergable.getMap().toUpperCase(), 11); + item.addLore(Message.parse("FIGHT_MERGE_INFO_LORE_1", player, finalMergable.getServer().getPlayers().stream().map(ProxiedPlayer::getDisplayName).reduce((player1, player2) -> player1 + ", " + player2).orElse("Error?"))); + inventory.addItem(4, item, click -> {}); + inventory.addItem(8, new SWItem(Message.parse("FIGHT_MERGE_ACCEPT", player), 10), click -> { + if(BungeeCore.get().getProxy().getServerInfo(finalMergable.getServer().getName()) != null) { + finalMergable.sendPlayer(player); + } else { + Message.send("FIGHT_MERGE_OFFLINE", player); + declineMerge.run(player, mode, map); + } + }); + inventory.open(); + return false; + } + return true; + } + @Override public void execute(CommandSender sender, String[] args) { createArena(sender, "/fight ", args, 0, false, (player, mode, map) -> { diff --git a/src/de/steamwar/messages/BungeeCore.properties b/src/de/steamwar/messages/BungeeCore.properties index d8b87bf..5ec4361 100644 --- a/src/de/steamwar/messages/BungeeCore.properties +++ b/src/de/steamwar/messages/BungeeCore.properties @@ -588,3 +588,10 @@ RANK_NEEDED_FIGHTS_LEFT={0} §8(§7noch §e{1}§7 Kämpfe nötig§8) MODIFICATION_BAN_MESSAGE=Du hast probiert den FabricModSender zu umgehen / zu modifizieren! MODIFICATION_BAN_LOG={0} hat probiert den Fabric Mod Sender zu editieren / umzugehen! MODIFICATION_CHECK_SUCCESS=§eDeine Mods wurden geprüft und du darfst nun auf Arenen joinen! + +#Arena Merging +FIGHT_MERGE_TITLE=Gleicher Fight gefunden! +FIGHT_MERGE_DECLINE=Neue Arena starten +FIGHT_MERGE_ACCEPT=Fight beitreten +FIGHT_MERGE_INFO_LORE_1=§7Von: §e{0} +FIGHT_MERGE_OFFLINE=Der Server dem du beitreten wolltest ist nicht mehr online -- 2.39.2 From 143cc279d30c31278933e090e0a8ce1923eaf24e Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Thu, 31 Mar 2022 23:02:26 +0200 Subject: [PATCH 3/7] :bug: Use it now --- src/de/steamwar/bungeecore/commands/FightCommand.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/de/steamwar/bungeecore/commands/FightCommand.java b/src/de/steamwar/bungeecore/commands/FightCommand.java index aeeb8dc..b71736f 100644 --- a/src/de/steamwar/bungeecore/commands/FightCommand.java +++ b/src/de/steamwar/bungeecore/commands/FightCommand.java @@ -160,7 +160,11 @@ public class FightCommand extends BasicCommand { if(map == null) return; - callback.run(player, mode, map); + if(precommand.equals("/bau testarena ") || precommand.startsWith("/challenge ")) { + callback.run(player, mode, map); + } else if(suggestMerging(player, mode, map, callback)) { + callback.run(player, mode, map); + } } public static boolean suggestMerging(ProxiedPlayer player, ArenaMode mode, String map, FightCallback declineMerge) { -- 2.39.2 From fa8c1c9004dfd876bae0c23fbbac14fd99a382c8 Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Sun, 3 Apr 2022 20:58:21 +0200 Subject: [PATCH 4/7] :white_check_mark: PR Stuff --- src/de/steamwar/bungeecore/ArenaMode.java | 6 +++++ src/de/steamwar/bungeecore/ServerStarter.java | 4 ++-- .../bungeecore/commands/BauCommand.java | 2 +- .../bungeecore/commands/ChallengeCommand.java | 2 +- .../bungeecore/commands/FightCommand.java | 24 ++++++++++--------- .../bungeecore/commands/HistoricCommand.java | 2 +- .../steamwar/messages/BungeeCore.properties | 1 + 7 files changed, 25 insertions(+), 16 deletions(-) diff --git a/src/de/steamwar/bungeecore/ArenaMode.java b/src/de/steamwar/bungeecore/ArenaMode.java index 13db3f4..9057691 100644 --- a/src/de/steamwar/bungeecore/ArenaMode.java +++ b/src/de/steamwar/bungeecore/ArenaMode.java @@ -95,11 +95,13 @@ public class ArenaMode { private final String config; private final List maps; private final boolean historic; + private final String internalName; private final boolean ranked; private final String schemType; private ArenaMode(String internalName, Configuration config){ + this.internalName = internalName; this.folder = config.getString("Server.Folder"); this.serverJar = config.getString("Server.ServerJar"); this.config = internalName + ".yml"; @@ -172,4 +174,8 @@ public class ArenaMode { public String getSchemType() { return schemType; } + + public String getInternalName() { + return internalName; + } } diff --git a/src/de/steamwar/bungeecore/ServerStarter.java b/src/de/steamwar/bungeecore/ServerStarter.java index e8cd6e3..5d23ae4 100644 --- a/src/de/steamwar/bungeecore/ServerStarter.java +++ b/src/de/steamwar/bungeecore/ServerStarter.java @@ -51,7 +51,7 @@ public class ServerStarter { serverJar = mode.serverJar(); directory = new File(SERVER_PATH, mode.getFolder()); arguments.put("config", mode.getConfig()); - constructor = (serverName, port, builder, shutdownCallback) -> new Arenaserver(serverName, mode.getDisplayName(), map, !mode.isRanked(), port, builder, shutdownCallback); + constructor = (serverName, port, builder, shutdownCallback) -> new Arenaserver(serverName, mode.getInternalName(), map, true, port, builder, shutdownCallback); tempWorld(SERVER_PATH + mode.getFolder() + "/arenas/" + map); return this; } @@ -62,7 +62,7 @@ public class ServerStarter { worldDir = EVENT_PATH; worldCleanup = () -> {}; arguments.put("fightID", String.valueOf(eventFight.getFightID())); - constructor = (serverName, port, builder, shutdownCallback) -> new Arenaserver(serverName, eventFight.getSpielmodus().getDisplayName(), eventFight.getMap(), false, port, builder, shutdownCallback); + constructor = (serverName, port, builder, shutdownCallback) -> new Arenaserver(serverName, eventFight.getSpielmodus().getInternalName(), eventFight.getMap(), false, port, builder, shutdownCallback); String serverName = Team.get(eventFight.getTeamBlue()).getTeamKuerzel() + " vs " + Team.get(eventFight.getTeamRed()).getTeamKuerzel(); serverNameProvider = port -> serverName; diff --git a/src/de/steamwar/bungeecore/commands/BauCommand.java b/src/de/steamwar/bungeecore/commands/BauCommand.java index 93c4866..744d48f 100644 --- a/src/de/steamwar/bungeecore/commands/BauCommand.java +++ b/src/de/steamwar/bungeecore/commands/BauCommand.java @@ -261,7 +261,7 @@ public class BauCommand extends BasicCommand { } private static void testarena(ProxiedPlayer p, String[] args){ - FightCommand.createArena(p, "/bau testarena ", args, 1, false, (player, mode, map) -> ProxyServer.getInstance().getScheduler().runAsync(BungeeCore.get(), () -> new ServerStarter().test(mode, map, p).start())); + FightCommand.createArena(p, "/bau testarena ", false, args, 1, false, (player, mode, map) -> ProxyServer.getInstance().getScheduler().runAsync(BungeeCore.get(), () -> new ServerStarter().test(mode, map, p).start())); } private static BauweltMember member(ProxiedPlayer p, SteamwarUser member){ diff --git a/src/de/steamwar/bungeecore/commands/ChallengeCommand.java b/src/de/steamwar/bungeecore/commands/ChallengeCommand.java index 7f480c1..ed80159 100644 --- a/src/de/steamwar/bungeecore/commands/ChallengeCommand.java +++ b/src/de/steamwar/bungeecore/commands/ChallengeCommand.java @@ -71,7 +71,7 @@ public class ChallengeCommand extends BasicCommand { return; } - FightCommand.createArena(sender, "/challenge " + target.getName() + " ", args, 1, false, (player, mode, map) -> { + FightCommand.createArena(sender, "/challenge " + target.getName() + " ", true, args, 1, false, (player, mode, map) -> { if(challenges.containsKey(target) && challenges.get(target).contains(player)){ challenges.remove(target); challenges.remove(player); diff --git a/src/de/steamwar/bungeecore/commands/FightCommand.java b/src/de/steamwar/bungeecore/commands/FightCommand.java index b71736f..5653052 100644 --- a/src/de/steamwar/bungeecore/commands/FightCommand.java +++ b/src/de/steamwar/bungeecore/commands/FightCommand.java @@ -125,7 +125,7 @@ public class FightCommand extends BasicCommand { return false; } - static void createArena(CommandSender sender, String precommand, String[] args, int startArg, boolean historic, FightCallback callback){ + static void createArena(CommandSender sender, String precommand, boolean allowMerging, String[] args, int startArg, boolean historic, FightCallback callback){ if(!(sender instanceof ProxiedPlayer)) return; @@ -160,7 +160,7 @@ public class FightCommand extends BasicCommand { if(map == null) return; - if(precommand.equals("/bau testarena ") || precommand.startsWith("/challenge ")) { + if(!allowMerging) { callback.run(player, mode, map); } else if(suggestMerging(player, mode, map, callback)) { callback.run(player, mode, map); @@ -169,12 +169,14 @@ public class FightCommand extends BasicCommand { public static boolean suggestMerging(ProxiedPlayer player, ArenaMode mode, String map, FightCallback declineMerge) { Arenaserver mergable = null; - for (Subserver subserver : Subserver.getServerList()) { - if(subserver instanceof Arenaserver) { - Arenaserver arenaserver = (Arenaserver) subserver; - if(mode.getDisplayName().equals(arenaserver.getMode()) && map.equals(arenaserver.getMap()) && arenaserver.isAllowMerge() && arenaserver.getServer().getPlayers().size() == 1) { - mergable = arenaserver; - break; + synchronized (Subserver.getServerList()) { + for (Subserver subserver : Subserver.getServerList()) { + if(subserver instanceof Arenaserver) { + Arenaserver arenaserver = (Arenaserver) subserver; + if(mode.getInternalName().equals(arenaserver.getMode()) && map.equals(arenaserver.getMap()) && arenaserver.isAllowMerge() && arenaserver.getServer().getPlayers().size() == 1) { + mergable = arenaserver; + break; + } } } } @@ -186,11 +188,11 @@ public class FightCommand extends BasicCommand { declineMerge.run(player, mode, map); }); Arenaserver finalMergable = mergable; - SWItem item = new SWItem("§e" + ArenaMode.getByInternal(finalMergable.getMode()).getDisplayName() + "§7: §e" + finalMergable.getMap().toUpperCase(), 11); + SWItem item = new SWItem(Message.parse("FIGHT_MERGE_INFO", player, mode.getDisplayName(), finalMergable.getMap()), 11); item.addLore(Message.parse("FIGHT_MERGE_INFO_LORE_1", player, finalMergable.getServer().getPlayers().stream().map(ProxiedPlayer::getDisplayName).reduce((player1, player2) -> player1 + ", " + player2).orElse("Error?"))); inventory.addItem(4, item, click -> {}); inventory.addItem(8, new SWItem(Message.parse("FIGHT_MERGE_ACCEPT", player), 10), click -> { - if(BungeeCore.get().getProxy().getServerInfo(finalMergable.getServer().getName()) != null) { + if(Subserver.getServerList().contains(finalMergable)) { finalMergable.sendPlayer(player); } else { Message.send("FIGHT_MERGE_OFFLINE", player); @@ -205,7 +207,7 @@ public class FightCommand extends BasicCommand { @Override public void execute(CommandSender sender, String[] args) { - createArena(sender, "/fight ", args, 0, false, (player, mode, map) -> { + createArena(sender, "/fight ", true, args, 0, false, (player, mode, map) -> { Subserver arena = new ServerStarter().arena(mode, map).blueLeader(player).start(); Message.broadcast("FIGHT_BROADCAST", "FIGHT_BROADCAST_HOVER" , new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/arena " + arena.getServer().getName()), mode.getDisplayName(), player.getName()); diff --git a/src/de/steamwar/bungeecore/commands/HistoricCommand.java b/src/de/steamwar/bungeecore/commands/HistoricCommand.java index f07a6a3..d26730f 100644 --- a/src/de/steamwar/bungeecore/commands/HistoricCommand.java +++ b/src/de/steamwar/bungeecore/commands/HistoricCommand.java @@ -32,7 +32,7 @@ public class HistoricCommand extends BasicCommand { @Override public void execute(CommandSender sender, String[] args) { - FightCommand.createArena(sender, "/historic ", args, 0, true, (player, mode, map) -> { + FightCommand.createArena(sender, "/historic ", true, args, 0, true, (player, mode, map) -> { Subserver arena = new ServerStarter().arena(mode, map).blueLeader(player).start(); Message.broadcast("HISTORIC_BROADCAST", "HISTORIC_BROADCAST_HOVER" , new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/arena " + arena.getServer().getName()), mode.getDisplayName(), player.getName()); diff --git a/src/de/steamwar/messages/BungeeCore.properties b/src/de/steamwar/messages/BungeeCore.properties index 5ec4361..9cc792b 100644 --- a/src/de/steamwar/messages/BungeeCore.properties +++ b/src/de/steamwar/messages/BungeeCore.properties @@ -595,3 +595,4 @@ FIGHT_MERGE_DECLINE=Neue Arena starten FIGHT_MERGE_ACCEPT=Fight beitreten FIGHT_MERGE_INFO_LORE_1=§7Von: §e{0} FIGHT_MERGE_OFFLINE=Der Server dem du beitreten wolltest ist nicht mehr online +FIGHT_MERGE_INFO=§e{0}§7: §e{1} \ No newline at end of file -- 2.39.2 From f5eaadba4fd75cdd7bc12192e580232dc3c24145 Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Wed, 6 Apr 2022 18:33:44 +0200 Subject: [PATCH 5/7] :art: Now? --- src/de/steamwar/bungeecore/ServerStarter.java | 18 ++++--- .../bungeecore/commands/ChallengeCommand.java | 2 +- .../bungeecore/commands/FightCommand.java | 47 +++++++++---------- .../steamwar/messages/BungeeCore.properties | 10 ++-- 4 files changed, 41 insertions(+), 36 deletions(-) diff --git a/src/de/steamwar/bungeecore/ServerStarter.java b/src/de/steamwar/bungeecore/ServerStarter.java index 5d23ae4..cb456db 100644 --- a/src/de/steamwar/bungeecore/ServerStarter.java +++ b/src/de/steamwar/bungeecore/ServerStarter.java @@ -37,10 +37,13 @@ public class ServerStarter { private Portrange portrange = BAU_PORTS; private Function serverNameProvider = port -> node.getName() + port; private BooleanSupplier startCondition = () -> true; - private ServerConstructor constructor = (serverName, port, builder, shutdownCallback) -> new Subserver(Servertype.ARENA, serverName, port, builder, shutdownCallback); private Runnable worldSetup = () -> {}; private String worldName = null; private Runnable worldCleanup = () -> {}; + private boolean allowMerge = false; + private String fightMap = null; + private String gameMode = null; + private ServerConstructor constructor = (serverName, port, allowMerge, builder, shutdownCallback) -> new Arenaserver(serverName, gameMode, fightMap, false, port, builder, shutdownCallback); private final Set playersToSend = new HashSet<>(); private final Map arguments = new HashMap<>(); @@ -49,9 +52,11 @@ public class ServerStarter { portrange = ARENA_PORTS; serverNameProvider = port -> mode.getDisplayName() + (port - portrange.start); serverJar = mode.serverJar(); + allowMerge = true; + fightMap = map; + gameMode = mode.getInternalName(); directory = new File(SERVER_PATH, mode.getFolder()); arguments.put("config", mode.getConfig()); - constructor = (serverName, port, builder, shutdownCallback) -> new Arenaserver(serverName, mode.getInternalName(), map, true, port, builder, shutdownCallback); tempWorld(SERVER_PATH + mode.getFolder() + "/arenas/" + map); return this; } @@ -62,7 +67,8 @@ public class ServerStarter { worldDir = EVENT_PATH; worldCleanup = () -> {}; arguments.put("fightID", String.valueOf(eventFight.getFightID())); - constructor = (serverName, port, builder, shutdownCallback) -> new Arenaserver(serverName, eventFight.getSpielmodus().getInternalName(), eventFight.getMap(), false, port, builder, shutdownCallback); + fightMap = eventFight.getMap(); + gameMode = eventFight.getSpielmodus().getInternalName(); String serverName = Team.get(eventFight.getTeamBlue()).getTeamKuerzel() + " vs " + Team.get(eventFight.getTeamRed()).getTeamKuerzel(); serverNameProvider = port -> serverName; @@ -186,7 +192,7 @@ public class ServerStarter { } private void build(UUID owner) { - constructor = (serverName, port, builder, shutdownCallback) -> new Bauserver(serverName, owner, port, builder, shutdownCallback); + constructor = (serverName, port, allowMerge, builder, shutdownCallback) -> new Bauserver(serverName, owner, port, builder, shutdownCallback); serverNameProvider = port -> bauServerName(SteamwarUser.get(owner)); } @@ -210,7 +216,7 @@ public class ServerStarter { worldSetup.run(); arguments.put("logPath", worldName); - Subserver subserver = constructor.construct(serverName, port, node.startServer( + Subserver subserver = constructor.construct(serverName, port, allowMerge, node.startServer( serverJar, directory, worldDir, worldName, port, xmx, arguments.entrySet().stream().map(entry -> entry.getKey() + "=" + entry.getValue()).toArray(String[]::new) ), worldCleanup); @@ -243,7 +249,7 @@ public class ServerStarter { } private interface ServerConstructor { - Subserver construct(String serverName, int port, ProcessBuilder builder, Runnable shutdownCallback); + Subserver construct(String serverName, int port, boolean merge, ProcessBuilder builder, Runnable shutdownCallback); } private static class Portrange { diff --git a/src/de/steamwar/bungeecore/commands/ChallengeCommand.java b/src/de/steamwar/bungeecore/commands/ChallengeCommand.java index ed80159..92fa0a7 100644 --- a/src/de/steamwar/bungeecore/commands/ChallengeCommand.java +++ b/src/de/steamwar/bungeecore/commands/ChallengeCommand.java @@ -71,7 +71,7 @@ public class ChallengeCommand extends BasicCommand { return; } - FightCommand.createArena(sender, "/challenge " + target.getName() + " ", true, args, 1, false, (player, mode, map) -> { + FightCommand.createArena(sender, "/challenge " + target.getName() + " ", false, args, 1, false, (player, mode, map) -> { if(challenges.containsKey(target) && challenges.get(target).contains(player)){ challenges.remove(target); challenges.remove(player); diff --git a/src/de/steamwar/bungeecore/commands/FightCommand.java b/src/de/steamwar/bungeecore/commands/FightCommand.java index 3119c30..07eb5d6 100644 --- a/src/de/steamwar/bungeecore/commands/FightCommand.java +++ b/src/de/steamwar/bungeecore/commands/FightCommand.java @@ -168,9 +168,7 @@ public class FightCommand extends BasicCommand { if(map == null) return; - if(!allowMerging) { - callback.run(player, mode, map); - } else if(suggestMerging(player, mode, map, callback)) { + if(!allowMerging || suggestMerging(player, mode, map, callback)) { callback.run(player, mode, map); } } @@ -189,28 +187,29 @@ public class FightCommand extends BasicCommand { } } - if(mergable != null) { - SWInventory inventory = new SWInventory(player, 9, Message.parse("FIGHT_MERGE_TITLE", player)); - inventory.addItem(0, new SWItem(Message.parse("FIGHT_MERGE_DECLINE", player), 1), click -> { - inventory.close(); - declineMerge.run(player, mode, map); - }); - Arenaserver finalMergable = mergable; - SWItem item = new SWItem(Message.parse("FIGHT_MERGE_INFO", player, mode.getDisplayName(), finalMergable.getMap()), 11); - item.addLore(Message.parse("FIGHT_MERGE_INFO_LORE_1", player, finalMergable.getServer().getPlayers().stream().map(ProxiedPlayer::getDisplayName).reduce((player1, player2) -> player1 + ", " + player2).orElse("Error?"))); - inventory.addItem(4, item, click -> {}); - inventory.addItem(8, new SWItem(Message.parse("FIGHT_MERGE_ACCEPT", player), 10), click -> { - if(Subserver.getServerList().contains(finalMergable)) { - finalMergable.sendPlayer(player); - } else { - Message.send("FIGHT_MERGE_OFFLINE", player); - declineMerge.run(player, mode, map); - } - }); - inventory.open(); - return false; + if(mergable == null) { + return true; } - return true; + + SWInventory inventory = new SWInventory(player, 9, Message.parse("FIGHT_MERGE_TITLE", player)); + inventory.addItem(0, new SWItem(Message.parse("FIGHT_MERGE_DECLINE", player), 1), click -> { + inventory.close(); + declineMerge.run(player, mode, map); + }); + Arenaserver finalMergable = mergable; + SWItem item = new SWItem(Message.parse("FIGHT_MERGE_INFO", player, mode.getDisplayName(), finalMergable.getMap()), 11); + item.addLore(Message.parse("FIGHT_MERGE_INFO_LORE_1", player, finalMergable.getServer().getPlayers().toArray(new ProxiedPlayer[1])[0].getName())); + inventory.addItem(4, item, click -> {}); + inventory.addItem(8, new SWItem(Message.parse("FIGHT_MERGE_ACCEPT", player), 10), click -> { + if(Subserver.getServerList().contains(finalMergable)) { + finalMergable.sendPlayer(player); + } else { + Message.send("FIGHT_MERGE_OFFLINE", player); + declineMerge.run(player, mode, map); + } + }); + inventory.open(); + return false; } @Override diff --git a/src/de/steamwar/messages/BungeeCore.properties b/src/de/steamwar/messages/BungeeCore.properties index dd646c9..40b7bdc 100644 --- a/src/de/steamwar/messages/BungeeCore.properties +++ b/src/de/steamwar/messages/BungeeCore.properties @@ -597,9 +597,9 @@ MODIFICATION_BAN_LOG={0} hat probiert den Fabric Mod Sender zu editieren / umzug MODIFICATION_CHECK_SUCCESS=§eDeine Mods wurden geprüft und du darfst nun auf Arenen joinen! #Arena Merging -FIGHT_MERGE_TITLE=Gleicher Fight gefunden! +FIGHT_MERGE_TITLE=Gleicher Kampf gefunden! FIGHT_MERGE_DECLINE=Neue Arena starten -FIGHT_MERGE_ACCEPT=Fight beitreten -FIGHT_MERGE_INFO_LORE_1=§7Von: §e{0} -FIGHT_MERGE_OFFLINE=Der Server dem du beitreten wolltest ist nicht mehr online -FIGHT_MERGE_INFO=§e{0}§7: §e{1} \ No newline at end of file +FIGHT_MERGE_ACCEPT=Kampf beitreten +FIGHT_MERGE_INFO_LORE_1=§8Von: §e{0} +FIGHT_MERGE_OFFLINE=§7Die vorgeschlagene Arena wurde in der Zwischenzeit beendet, es wird eine neue Arena gestartet. +FIGHT_MERGE_INFO=§e{0}§8: §e{1} \ No newline at end of file -- 2.39.2 From d8546217528891ced11a48e78e554f43e9faf8d3 Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Sat, 16 Apr 2022 16:13:10 +0200 Subject: [PATCH 6/7] :bug: Fixes --- src/de/steamwar/bungeecore/ServerStarter.java | 8 ++++---- src/de/steamwar/bungeecore/commands/FightCommand.java | 10 ++++++---- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/de/steamwar/bungeecore/ServerStarter.java b/src/de/steamwar/bungeecore/ServerStarter.java index cb456db..36ccac6 100644 --- a/src/de/steamwar/bungeecore/ServerStarter.java +++ b/src/de/steamwar/bungeecore/ServerStarter.java @@ -43,7 +43,7 @@ public class ServerStarter { private boolean allowMerge = false; private String fightMap = null; private String gameMode = null; - private ServerConstructor constructor = (serverName, port, allowMerge, builder, shutdownCallback) -> new Arenaserver(serverName, gameMode, fightMap, false, port, builder, shutdownCallback); + private ServerConstructor constructor = (serverName, port, builder, shutdownCallback) -> new Arenaserver(serverName, gameMode, fightMap, allowMerge, port, builder, shutdownCallback); private final Set playersToSend = new HashSet<>(); private final Map arguments = new HashMap<>(); @@ -192,7 +192,7 @@ public class ServerStarter { } private void build(UUID owner) { - constructor = (serverName, port, allowMerge, builder, shutdownCallback) -> new Bauserver(serverName, owner, port, builder, shutdownCallback); + constructor = (serverName, port, builder, shutdownCallback) -> new Bauserver(serverName, owner, port, builder, shutdownCallback); serverNameProvider = port -> bauServerName(SteamwarUser.get(owner)); } @@ -216,7 +216,7 @@ public class ServerStarter { worldSetup.run(); arguments.put("logPath", worldName); - Subserver subserver = constructor.construct(serverName, port, allowMerge, node.startServer( + Subserver subserver = constructor.construct(serverName, port, node.startServer( serverJar, directory, worldDir, worldName, port, xmx, arguments.entrySet().stream().map(entry -> entry.getKey() + "=" + entry.getValue()).toArray(String[]::new) ), worldCleanup); @@ -249,7 +249,7 @@ public class ServerStarter { } private interface ServerConstructor { - Subserver construct(String serverName, int port, boolean merge, ProcessBuilder builder, Runnable shutdownCallback); + Subserver construct(String serverName, int port, ProcessBuilder builder, Runnable shutdownCallback); } private static class Portrange { diff --git a/src/de/steamwar/bungeecore/commands/FightCommand.java b/src/de/steamwar/bungeecore/commands/FightCommand.java index 07eb5d6..c463239 100644 --- a/src/de/steamwar/bungeecore/commands/FightCommand.java +++ b/src/de/steamwar/bungeecore/commands/FightCommand.java @@ -168,12 +168,14 @@ public class FightCommand extends BasicCommand { if(map == null) return; - if(!allowMerging || suggestMerging(player, mode, map, callback)) { + if(!allowMerging) { callback.run(player, mode, map); + } else { + suggestMerging(player, mode, map, callback); } } - public static boolean suggestMerging(ProxiedPlayer player, ArenaMode mode, String map, FightCallback declineMerge) { + public static void suggestMerging(ProxiedPlayer player, ArenaMode mode, String map, FightCallback declineMerge) { Arenaserver mergable = null; synchronized (Subserver.getServerList()) { for (Subserver subserver : Subserver.getServerList()) { @@ -188,7 +190,8 @@ public class FightCommand extends BasicCommand { } if(mergable == null) { - return true; + declineMerge.run(player, mode, map); + return; } SWInventory inventory = new SWInventory(player, 9, Message.parse("FIGHT_MERGE_TITLE", player)); @@ -209,7 +212,6 @@ public class FightCommand extends BasicCommand { } }); inventory.open(); - return false; } @Override -- 2.39.2 From 0d6d342740bd038fb5132b55f47dadb7d2a11ca2 Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Sat, 16 Apr 2022 16:24:38 +0200 Subject: [PATCH 7/7] :bug: Fixes --- src/de/steamwar/bungeecore/commands/FightCommand.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/de/steamwar/bungeecore/commands/FightCommand.java b/src/de/steamwar/bungeecore/commands/FightCommand.java index c463239..e42e396 100644 --- a/src/de/steamwar/bungeecore/commands/FightCommand.java +++ b/src/de/steamwar/bungeecore/commands/FightCommand.java @@ -43,6 +43,7 @@ import java.util.LinkedList; * Sollte der ArenaMode fehlen, kann er mit getMode() bestimmt werden. * Sollte die Map fehlen, kann sie mit getMap() bestimmt werden. */ + public class FightCommand extends BasicCommand { public FightCommand() { -- 2.39.2