Archiviert
1
0
Dieser Commit ist enthalten in:
Chaoscaot 2022-04-03 20:58:21 +02:00
Ursprung 143cc279d3
Commit fa8c1c9004
7 geänderte Dateien mit 25 neuen und 16 gelöschten Zeilen

Datei anzeigen

@ -95,11 +95,13 @@ public class ArenaMode {
private final String config; private final String config;
private final List<String> maps; private final List<String> maps;
private final boolean historic; private final boolean historic;
private final String internalName;
private final boolean ranked; private final boolean ranked;
private final String schemType; private final String schemType;
private ArenaMode(String internalName, Configuration config){ private ArenaMode(String internalName, Configuration config){
this.internalName = internalName;
this.folder = config.getString("Server.Folder"); this.folder = config.getString("Server.Folder");
this.serverJar = config.getString("Server.ServerJar"); this.serverJar = config.getString("Server.ServerJar");
this.config = internalName + ".yml"; this.config = internalName + ".yml";
@ -172,4 +174,8 @@ public class ArenaMode {
public String getSchemType() { public String getSchemType() {
return schemType; return schemType;
} }
public String getInternalName() {
return internalName;
}
} }

Datei anzeigen

@ -51,7 +51,7 @@ public class ServerStarter {
serverJar = mode.serverJar(); serverJar = mode.serverJar();
directory = new File(SERVER_PATH, mode.getFolder()); directory = new File(SERVER_PATH, mode.getFolder());
arguments.put("config", mode.getConfig()); 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); tempWorld(SERVER_PATH + mode.getFolder() + "/arenas/" + map);
return this; return this;
} }
@ -62,7 +62,7 @@ public class ServerStarter {
worldDir = EVENT_PATH; worldDir = EVENT_PATH;
worldCleanup = () -> {}; worldCleanup = () -> {};
arguments.put("fightID", String.valueOf(eventFight.getFightID())); 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(); String serverName = Team.get(eventFight.getTeamBlue()).getTeamKuerzel() + " vs " + Team.get(eventFight.getTeamRed()).getTeamKuerzel();
serverNameProvider = port -> serverName; serverNameProvider = port -> serverName;

Datei anzeigen

@ -261,7 +261,7 @@ public class BauCommand extends BasicCommand {
} }
private static void testarena(ProxiedPlayer p, String[] args){ 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){ private static BauweltMember member(ProxiedPlayer p, SteamwarUser member){

Datei anzeigen

@ -71,7 +71,7 @@ public class ChallengeCommand extends BasicCommand {
return; 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)){ if(challenges.containsKey(target) && challenges.get(target).contains(player)){
challenges.remove(target); challenges.remove(target);
challenges.remove(player); challenges.remove(player);

Datei anzeigen

@ -125,7 +125,7 @@ public class FightCommand extends BasicCommand {
return false; 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)) if(!(sender instanceof ProxiedPlayer))
return; return;
@ -160,7 +160,7 @@ public class FightCommand extends BasicCommand {
if(map == null) if(map == null)
return; return;
if(precommand.equals("/bau testarena ") || precommand.startsWith("/challenge ")) { if(!allowMerging) {
callback.run(player, mode, map); callback.run(player, mode, map);
} else if(suggestMerging(player, mode, map, callback)) { } else if(suggestMerging(player, mode, map, callback)) {
callback.run(player, mode, map); 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) { public static boolean suggestMerging(ProxiedPlayer player, ArenaMode mode, String map, FightCallback declineMerge) {
Arenaserver mergable = null; Arenaserver mergable = null;
for (Subserver subserver : Subserver.getServerList()) { synchronized (Subserver.getServerList()) {
if(subserver instanceof Arenaserver) { for (Subserver subserver : Subserver.getServerList()) {
Arenaserver arenaserver = (Arenaserver) subserver; if(subserver instanceof Arenaserver) {
if(mode.getDisplayName().equals(arenaserver.getMode()) && map.equals(arenaserver.getMap()) && arenaserver.isAllowMerge() && arenaserver.getServer().getPlayers().size() == 1) { Arenaserver arenaserver = (Arenaserver) subserver;
mergable = arenaserver; if(mode.getInternalName().equals(arenaserver.getMode()) && map.equals(arenaserver.getMap()) && arenaserver.isAllowMerge() && arenaserver.getServer().getPlayers().size() == 1) {
break; mergable = arenaserver;
break;
}
} }
} }
} }
@ -186,11 +188,11 @@ public class FightCommand extends BasicCommand {
declineMerge.run(player, mode, map); declineMerge.run(player, mode, map);
}); });
Arenaserver finalMergable = mergable; 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?"))); 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(4, item, click -> {});
inventory.addItem(8, new SWItem(Message.parse("FIGHT_MERGE_ACCEPT", player), 10), 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); finalMergable.sendPlayer(player);
} else { } else {
Message.send("FIGHT_MERGE_OFFLINE", player); Message.send("FIGHT_MERGE_OFFLINE", player);
@ -205,7 +207,7 @@ public class FightCommand extends BasicCommand {
@Override @Override
public void execute(CommandSender sender, String[] args) { 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(); Subserver arena = new ServerStarter().arena(mode, map).blueLeader(player).start();
Message.broadcast("FIGHT_BROADCAST", "FIGHT_BROADCAST_HOVER" Message.broadcast("FIGHT_BROADCAST", "FIGHT_BROADCAST_HOVER"
, new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/arena " + arena.getServer().getName()), mode.getDisplayName(), player.getName()); , new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/arena " + arena.getServer().getName()), mode.getDisplayName(), player.getName());

Datei anzeigen

@ -32,7 +32,7 @@ public class HistoricCommand extends BasicCommand {
@Override @Override
public void execute(CommandSender sender, String[] args) { 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(); Subserver arena = new ServerStarter().arena(mode, map).blueLeader(player).start();
Message.broadcast("HISTORIC_BROADCAST", "HISTORIC_BROADCAST_HOVER" Message.broadcast("HISTORIC_BROADCAST", "HISTORIC_BROADCAST_HOVER"
, new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/arena " + arena.getServer().getName()), mode.getDisplayName(), player.getName()); , new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/arena " + arena.getServer().getName()), mode.getDisplayName(), player.getName());

Datei anzeigen

@ -595,3 +595,4 @@ FIGHT_MERGE_DECLINE=Neue Arena starten
FIGHT_MERGE_ACCEPT=Fight beitreten FIGHT_MERGE_ACCEPT=Fight beitreten
FIGHT_MERGE_INFO_LORE_1=§7Von: §e{0} FIGHT_MERGE_INFO_LORE_1=§7Von: §e{0}
FIGHT_MERGE_OFFLINE=Der Server dem du beitreten wolltest ist nicht mehr online FIGHT_MERGE_OFFLINE=Der Server dem du beitreten wolltest ist nicht mehr online
FIGHT_MERGE_INFO=§e{0}§7: §e{1}