geforkt von SteamWar/BungeeCore
✅ PR Stuff
Dieser Commit ist enthalten in:
Ursprung
143cc279d3
Commit
fa8c1c9004
@ -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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -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;
|
||||||
|
@ -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){
|
||||||
|
@ -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);
|
||||||
|
@ -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,15 +169,17 @@ 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;
|
||||||
|
synchronized (Subserver.getServerList()) {
|
||||||
for (Subserver subserver : Subserver.getServerList()) {
|
for (Subserver subserver : Subserver.getServerList()) {
|
||||||
if(subserver instanceof Arenaserver) {
|
if(subserver instanceof Arenaserver) {
|
||||||
Arenaserver arenaserver = (Arenaserver) subserver;
|
Arenaserver arenaserver = (Arenaserver) subserver;
|
||||||
if(mode.getDisplayName().equals(arenaserver.getMode()) && map.equals(arenaserver.getMap()) && arenaserver.isAllowMerge() && arenaserver.getServer().getPlayers().size() == 1) {
|
if(mode.getInternalName().equals(arenaserver.getMode()) && map.equals(arenaserver.getMap()) && arenaserver.isAllowMerge() && arenaserver.getServer().getPlayers().size() == 1) {
|
||||||
mergable = arenaserver;
|
mergable = arenaserver;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(mergable != null) {
|
if(mergable != null) {
|
||||||
SWInventory inventory = new SWInventory(player, 9, Message.parse("FIGHT_MERGE_TITLE", player));
|
SWInventory inventory = new SWInventory(player, 9, Message.parse("FIGHT_MERGE_TITLE", player));
|
||||||
@ -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());
|
||||||
|
@ -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());
|
||||||
|
@ -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}
|
In neuem Issue referenzieren
Einen Benutzer sperren