Archiviert
1
0

Add Arena Merging 2.0

Dieser Commit ist enthalten in:
Chaoscaot 2022-03-31 23:01:20 +02:00
Ursprung a09ee03937
Commit ef8e5a3a0d
2 geänderte Dateien mit 45 neuen und 0 gelöschten Zeilen

Datei anzeigen

@ -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) -> {

Datei anzeigen

@ -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