Archiviert
1
0

Implement prepare

Signed-off-by: Lixfel <agga-games@gmx.de>
Dieser Commit ist enthalten in:
Lixfel 2021-03-30 19:47:34 +02:00
Ursprung 5ee46a2ca3
Commit 4c2f4fdbcd
11 geänderte Dateien mit 69 neuen und 44 gelöschten Zeilen

Datei anzeigen

@ -19,17 +19,18 @@
package de.steamwar.bungeecore;
import de.steamwar.bungeecore.sql.SchematicType;
import net.md_5.bungee.config.Configuration;
import java.util.*;
public class ArenaMode {
private static Map<String, ArenaMode> byChat = new HashMap<>();
private static Map<String, ArenaMode> byInternal = new HashMap<>();
private static Map<String, ArenaMode> byCheckSchemType = new HashMap<>();
private static List<ArenaMode> allModes = new LinkedList<>();
private static Random random = new Random();
private static final Map<String, ArenaMode> byChat = new HashMap<>();
private static final Map<String, ArenaMode> byInternal = new HashMap<>();
private static final Map<SchematicType, ArenaMode> bySchemType = new HashMap<>();
private static final List<ArenaMode> allModes = new LinkedList<>();
private static final Random random = new Random();
static void init(Configuration config){
for(String internalName : config.getKeys()){
@ -63,8 +64,8 @@ public class ArenaMode {
return chatNames;
}
public static ArenaMode getByCheckSchemType(String checkSchemType){
return byCheckSchemType.get(checkSchemType);
public static ArenaMode getBySchemType(SchematicType schemType){
return bySchemType.get(schemType);
}
public static List<ArenaMode> getAllModes(){
@ -102,7 +103,7 @@ public class ArenaMode {
}
if(!this.schemType.equals(""))
byCheckSchemType.put(this.schemType, this);
bySchemType.put(SchematicType.fromDB(this.schemType), this);
}
public String getDisplayName() {

Datei anzeigen

@ -87,7 +87,7 @@ public class SubserverSystem {
* @return
* The new started subserver.
*/
public static Subserver startArena(ArenaMode modus, String map, int eventFightID, int checkSchemID, String serverName, String mapName, UUID player1, UUID player2, boolean ranked){
public static Subserver startArena(ArenaMode modus, String map, int eventFightID, int checkSchemID, int prepareSchemID, String serverName, String mapName, UUID player1, UUID player2, boolean ranked){
//Generate missing parameters
int port = freePort(firstArenaPort);
@ -123,6 +123,7 @@ public class SubserverSystem {
"fightID=" + eventFightID,
"ranked=" + ranked,
"checkSchemID=" + checkSchemID,
"prepareSchemID=" + prepareSchemID,
player1 != null && eventFightID != -1 ? "blueLeader=" + player1.toString() : null,
player2 != null ? "redLeader=" + player2.toString() : null);
@ -152,24 +153,22 @@ public class SubserverSystem {
});
}
public static Subserver startArena(ArenaMode modus, String map, int eventFightID, int checkSchemID, String serverName, String mapName, UUID player1, UUID player2){
return startArena(modus, map, eventFightID, checkSchemID, serverName, mapName, player1, player2, false);
}
public static Subserver startEventArena(EventFight eventFight, String serverName){
return startArena(
eventFight.getSpielmodus(),
eventFight.getMap(),
eventFight.getFightID(),
0,
0,
serverName,
serverName.replace(' ', '_') + eventFight.getStartTime().toLocalDateTime().format(DateTimeFormatter.ISO_TIME),
null,
null);
null,
false);
}
public static void startTestServer(ProxiedPlayer p, ArenaMode m, String map, int checkSchemId){
startArena(m, map, -1, checkSchemId, p.getName() + "s Bau", p.getName(), p.getUniqueId(), null).sendPlayer(p);
public static void startTestServer(ProxiedPlayer p, ArenaMode m, String map, int checkSchemId, int prepareSchemId){
startArena(m, map, -1, checkSchemId, prepareSchemId, p.getName() + "s Bau", p.getName(), p.getUniqueId(), null, false).sendPlayer(p);
}
public static void sendToBauServer(ProxiedPlayer p, UUID owner){

Datei anzeigen

@ -266,8 +266,7 @@ public class BauCommand {
});
}
private static void testarena(ProxiedPlayer p, String[] command){
FightCommand.createArena(p, "/bau testarena ", command, 2, false, (player, mode, map) -> ProxyServer.getInstance().getScheduler().runAsync(BungeeCore.get(), () -> {
public static void stopBauserver(ProxiedPlayer p){
for (Subserver subserver : Subserver.getServerList()) {
if (subserver.getType() == Servertype.BAUSERVER && ((Bauserver) subserver).getOwner().equals(p.getUniqueId())) {
if(subserver.getServer().getPlayers().isEmpty()){
@ -283,7 +282,12 @@ public class BauCommand {
break;
}
}
SubserverSystem.startTestServer(p, mode, map, 0);
}
private static void testarena(ProxiedPlayer p, String[] command){
FightCommand.createArena(p, "/bau testarena ", command, 2, false, (player, mode, map) -> ProxyServer.getInstance().getScheduler().runAsync(BungeeCore.get(), () -> {
stopBauserver(p);
SubserverSystem.startTestServer(p, mode, map, 0, 0);
}));
}

Datei anzeigen

@ -75,7 +75,7 @@ public class ChallengeCommand extends BasicCommand {
challenges.remove(target);
challenges.remove(player);
Subserver arena = SubserverSystem.startArena(mode, map, 0, 0, null, null, player.getUniqueId(), target.getUniqueId());
Subserver arena = SubserverSystem.startArena(mode, map, 0, 0, 0, null, null, player.getUniqueId(), target.getUniqueId(), false);
arena.sendPlayer(player);
arena.sendPlayer(target);

Datei anzeigen

@ -223,15 +223,10 @@ public class CheckCommand extends BasicCommand {
this.checkList = checkQuestions.get(schematic.getSchemType()).listIterator();
ProxyServer.getInstance().getScheduler().runAsync(BungeeCore.get(), () -> {
for (Subserver subserver : Subserver.getServerList()) {
if (subserver.getType() == Servertype.BAUSERVER && ((Bauserver) subserver).getOwner().equals(checker.getUniqueId())) {
subserver.stop();
break;
}
}
BauCommand.stopBauserver(checker);
ArenaMode mode = ArenaMode.getByCheckSchemType(schematic.getSchemType().toDB());
SubserverSystem.startTestServer(checker, mode, FightCommand.getMap(checker, mode, "Random"), schematic.getSchemID());
ArenaMode mode = ArenaMode.getBySchemType(schematic.getSchemType().fightType());
SubserverSystem.startTestServer(checker, mode, FightCommand.getMap(checker, mode, "Random"), schematic.getSchemID(), 0);
currentCheckers.put(checker.getUniqueId(), this);
currentSchems.put(schematic.getSchemID(), this);
for(CheckedSchematic previous : CheckedSchematic.previousChecks(schematic.getSchemName(), schematic.getSchemOwner()))

Datei anzeigen

@ -164,7 +164,7 @@ public class FightCommand extends BasicCommand {
@Override
public void execute(CommandSender sender, String[] args) {
createArena(sender, "/fight ", args, 0, false, (player, mode, map) -> {
Subserver arena = SubserverSystem.startArena(mode, map, 0, 0, null, null, player.getUniqueId(), null);
Subserver arena = SubserverSystem.startArena(mode, map, 0, 0, 0, null, null, player.getUniqueId(), null, false);
arena.sendPlayer(player);
Message.broadcast("FIGHT_BROADCAST", "FIGHT_BROADCAST_HOVER"
, new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/join " + player.getName()), mode.getDisplayName(), player.getName());

Datei anzeigen

@ -33,7 +33,7 @@ public class HistoricCommand extends BasicCommand {
@Override
public void execute(CommandSender sender, String[] args) {
FightCommand.createArena(sender, "/historic ", args, 0, true, (player, mode, map) -> {
Subserver arena = SubserverSystem.startArena(mode, map, 0, 0, null, null, player.getUniqueId(), null);
Subserver arena = SubserverSystem.startArena(mode, map, 0, 0, 0, null, null, player.getUniqueId(), null, false);
arena.sendPlayer(player);
Message.broadcast("HISTORIC_BROADCAST", "HISTORIC_BROADCAST_HOVER"
, new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/join " + player.getName()), mode.getDisplayName(), player.getName());

Datei anzeigen

@ -165,7 +165,7 @@ public class RankedCommand extends BasicCommand {
removeFromAll(wp1.player);
removeFromAll(wp2.player);
Subserver arena = SubserverSystem.startArena(mode, mode.getRandomMap(), 0, 0, null, null, wp1.player.getUniqueId(), wp2.player.getUniqueId(), true);
Subserver arena = SubserverSystem.startArena(mode, mode.getRandomMap(), 0, 0, 0, null, null, wp1.player.getUniqueId(), wp2.player.getUniqueId(), true);
arena.sendPlayer(wp1.player);
arena.sendPlayer(wp2.player);

Datei anzeigen

@ -24,6 +24,7 @@ public class PacketIdManager {
//0x0(X) Standalone Packets
public static final byte PING_PACKET = 0x01;
public static final byte TABLIST_NAME = 0x02;
public static final byte PREPARE_SCHEM = 0x03;
//0x1(X) Bungee Inventory
public static final byte INVENTORY_PACKET = 0x10;

Datei anzeigen

@ -22,6 +22,7 @@ package de.steamwar.bungeecore.comms;
import com.google.common.io.ByteArrayDataInput;
import com.google.common.io.ByteStreams;
import de.steamwar.bungeecore.comms.handlers.InventoryCallbackHandler;
import de.steamwar.bungeecore.comms.handlers.PrepareSchemHandler;
import de.steamwar.bungeecore.comms.handlers.TablistNameHandler;
import de.steamwar.bungeecore.listeners.BasicListener;
import net.md_5.bungee.api.event.PluginMessageEvent;
@ -55,5 +56,6 @@ public class SpigotReceiver extends BasicListener {
static {
registerHandler(PacketIdManager.INVENTORY_CALLBACK_PACKET, new InventoryCallbackHandler());
registerHandler(PacketIdManager.TABLIST_NAME, new TablistNameHandler());
registerHandler(PacketIdManager.PREPARE_SCHEM, new PrepareSchemHandler());
}
}

Datei anzeigen

@ -0,0 +1,23 @@
package de.steamwar.bungeecore.comms.handlers;
import com.google.common.io.ByteArrayDataInput;
import de.steamwar.bungeecore.ArenaMode;
import de.steamwar.bungeecore.SubserverSystem;
import de.steamwar.bungeecore.commands.BauCommand;
import de.steamwar.bungeecore.comms.SpigotHandler;
import de.steamwar.bungeecore.sql.SchematicType;
import de.steamwar.bungeecore.sql.SteamwarUser;
import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.connection.ProxiedPlayer;
public class PrepareSchemHandler implements SpigotHandler {
@Override
public void handle(ByteArrayDataInput byteArrayDataInput) {
ProxiedPlayer player = ProxyServer.getInstance().getPlayer(SteamwarUser.get(byteArrayDataInput.readInt()).getUuid());
int schematicID = byteArrayDataInput.readInt();
ArenaMode mode = ArenaMode.getBySchemType(SchematicType.fromDB(byteArrayDataInput.readUTF()));
BauCommand.stopBauserver(player);
SubserverSystem.startTestServer(player, mode, mode.getRandomMap(), 0, schematicID);
}
}