Archiviert
1
0
Dieser Commit ist enthalten in:
Chaoscaot 2024-05-18 12:56:15 +02:00
Ursprung 153d354c60
Commit c0f8058c60
21 geänderte Dateien mit 169 neuen und 175 gelöschten Zeilen

Datei anzeigen

@ -29,7 +29,7 @@ plugins {
id 'java' id 'java'
id 'application' id 'application'
id 'com.github.johnrengelman.shadow' version '5.0.0' id 'com.github.johnrengelman.shadow' version '8.1.1'
id 'de.steamwar.gradle' version 'RELEASE' id 'de.steamwar.gradle' version 'RELEASE'
} }
@ -38,8 +38,10 @@ version ''
compileJava.options.encoding = 'UTF-8' compileJava.options.encoding = 'UTF-8'
sourceCompatibility = 17 java {
targetCompatibility = 17 sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
mainClassName = '' mainClassName = ''
@ -73,6 +75,7 @@ repositories {
includeGroup 'com.lunarclient' includeGroup 'com.lunarclient'
} }
} }
maven { url 'https://jitpack.io' }
mavenLocal() mavenLocal()
} }
@ -95,7 +98,7 @@ dependencies {
annotationProcessor 'com.velocitypowered:velocity-api:3.3.0-SNAPSHOT' annotationProcessor 'com.velocitypowered:velocity-api:3.3.0-SNAPSHOT'
compileOnly 'com.velocitypowered:velocity-proxy:3.3.0-SNAPSHOT' compileOnly 'com.velocitypowered:velocity-proxy:3.3.0-SNAPSHOT'
compileOnly 'de.steamwar:persistentbungeecore:RELEASE' compileOnly 'de.steamwar:persistentvelocitycore:DEV'
implementation("net.dv8tion:JDA:4.4.0_352") { implementation("net.dv8tion:JDA:4.4.0_352") {
exclude module: 'opus-java' exclude module: 'opus-java'
} }
@ -109,4 +112,6 @@ dependencies {
compileOnly 'io.netty:netty-buffer:4.1.106.Final' compileOnly 'io.netty:netty-buffer:4.1.106.Final'
compileOnly 'io.netty:netty-transport:4.1.106.Final' compileOnly 'io.netty:netty-transport:4.1.106.Final'
implementation 'com.github.Carleslc.Simple-YAML:Simple-Yaml:1.8.4'
} }

Datei anzeigen

@ -1,5 +1,5 @@
#Sat Apr 10 23:34:12 CEST 2021 #Sat Apr 10 23:34:12 CEST 2021
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.1-all.zip distributionUrl=https\://services.gradle.org/distributions/gradle-8.1-all.zip
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
zipStorePath=wrapper/dists zipStorePath=wrapper/dists

Datei anzeigen

@ -20,10 +20,8 @@
package de.steamwar.bungeecore; package de.steamwar.bungeecore;
import de.steamwar.sql.SchematicType; import de.steamwar.sql.SchematicType;
import net.md_5.bungee.api.ProxyServer; import org.simpleyaml.configuration.Configuration;
import net.md_5.bungee.config.Configuration; import org.simpleyaml.configuration.file.YamlFile;
import net.md_5.bungee.config.ConfigurationProvider;
import net.md_5.bungee.config.YamlConfiguration;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
@ -49,12 +47,12 @@ public class ArenaMode {
bySchemType.clear(); bySchemType.clear();
allModes.clear(); allModes.clear();
File folder = new File(ProxyServer.getInstance().getPluginsFolder(), "FightSystem"); File folder = new File(VelocityCore.get().getDataDirectory().getParent().toFile(), "FightSystem");
for(File configFile : Arrays.stream(folder.listFiles((file, name) -> name.endsWith(".yml") && !name.endsWith(".kits.yml"))).sorted().collect(Collectors.toList())) { for(File configFile : Arrays.stream(folder.listFiles((file, name) -> name.endsWith(".yml") && !name.endsWith(".kits.yml"))).sorted().collect(Collectors.toList())) {
Configuration config; Configuration config;
try { try {
config = ConfigurationProvider.getProvider(YamlConfiguration.class).load(configFile); config = YamlFile.loadConfiguration(configFile);
} catch (IOException e) { } catch (IOException e) {
throw new SecurityException("Could not load SchematicTypes", e); throw new SecurityException("Could not load SchematicTypes", e);
} }

Datei anzeigen

@ -20,6 +20,7 @@
package de.steamwar.bungeecore; package de.steamwar.bungeecore;
import de.steamwar.messages.ChatSender; import de.steamwar.messages.ChatSender;
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
@ -31,7 +32,7 @@ class Broadcaster {
Broadcaster(){ Broadcaster(){
VelocityCore.get().getProxyServer().getScheduler().buildTask(VelocityCore.get(), () -> { VelocityCore.get().getProxyServer().getScheduler().buildTask(VelocityCore.get(), () -> {
if(!VelocityCore.get().getProxyServer().getAllPlayers().isEmpty() && broadCastMsgs.length > 0) { if(!VelocityCore.get().getProxyServer().getAllPlayers().isEmpty() && broadCastMsgs.length > 0) {
VelocityCore.broadcast(VelocityCore.CHAT_PREFIX + broadCastMsgs[lastBroadCast]); VelocityCore.get().getProxyServer().sendMessage(LegacyComponentSerializer.legacySection().deserialize(VelocityCore.CHAT_PREFIX + broadCastMsgs[lastBroadCast]));
} }
lastBroadCast++; lastBroadCast++;
if(lastBroadCast == broadCastMsgs.length){ if(lastBroadCast == broadCastMsgs.length){

Datei anzeigen

@ -25,6 +25,7 @@ import de.steamwar.bungeecore.network.handlers.FightInfoHandler;
import de.steamwar.sql.IgnoreSystem; import de.steamwar.sql.IgnoreSystem;
import de.steamwar.sql.SteamwarUser; import de.steamwar.sql.SteamwarUser;
import de.steamwar.network.packets.server.StartingServerPacket; import de.steamwar.network.packets.server.StartingServerPacket;
import net.kyori.adventure.text.event.ClickEvent;
import java.util.UUID; import java.util.UUID;
@ -48,13 +49,13 @@ public class SubserverSystem {
} }
Message.send("SERVER_ADD_MEMBER", o, p.getUsername()); Message.send("SERVER_ADD_MEMBER", o, p.getUsername());
Message.sendPrefixless("SERVER_ADD_MESSAGE", o, Message.parse("SERVER_ADD_MESSAGE_HOVER", o, p.getName()), Message.sendPrefixless("SERVER_ADD_MESSAGE", o, Message.parse("SERVER_ADD_MESSAGE_HOVER", o, p.getUsername()),
new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/bau addmember " + p.getName())); ClickEvent.runCommand("/bau addmember " + p.getUsername()));
} }
public static void sendPlayer(Subserver subserver, Player player) { public static void sendPlayer(Subserver subserver, Player player) {
subserver.sendPlayer(player); subserver.sendPlayer(player);
if(!subserver.hasStarted() && FightInfoHandler.onLobby(player)) if(!subserver.isStarted() && FightInfoHandler.onLobby(player))
NetworkSender.send(player, new StartingServerPacket(SteamwarUser.get(player.getUniqueId()).getId())); NetworkSender.send(player, new StartingServerPacket(SteamwarUser.get(player.getUniqueId()).getId()));
} }
} }

Datei anzeigen

@ -19,17 +19,14 @@
package de.steamwar.bungeecore.commands; package de.steamwar.bungeecore.commands;
import com.velocitypowered.api.proxy.Player;
import de.steamwar.bungeecore.*; import de.steamwar.bungeecore.*;
import de.steamwar.bungeecore.bot.util.DiscordSchemAlert; import de.steamwar.bungeecore.bot.util.DiscordSchemAlert;
import de.steamwar.bungeecore.listeners.ConnectionListener; import de.steamwar.bungeecore.listeners.ConnectionListener;
import de.steamwar.sql.*; import de.steamwar.sql.*;
import de.steamwar.command.SWCommand; import de.steamwar.command.SWCommand;
import net.md_5.bungee.api.ChatColor; import net.kyori.adventure.text.event.ClickEvent;
import net.md_5.bungee.api.ProxyServer; import org.simpleyaml.configuration.Configuration;
import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.chat.TextComponent;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.config.Configuration;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.time.Instant; import java.time.Instant;
@ -55,27 +52,27 @@ public class CheckCommand extends SWCommand {
fightTypes.put(checkType, fightType); fightTypes.put(checkType, fightType);
} }
public static boolean isChecking(ProxiedPlayer player){ public static boolean isChecking(Player player){
return currentCheckers.containsKey(player.getUniqueId()); return currentCheckers.containsKey(player.getUniqueId());
} }
public static SchematicNode getCheckingSchem(ProxiedPlayer player) { public static SchematicNode getCheckingSchem(Player player) {
return currentCheckers.get(player.getUniqueId()).schematic; return currentCheckers.get(player.getUniqueId()).schematic;
} }
public CheckCommand() { public CheckCommand() {
super("check", ConnectionListener.CHECK_PERMISSION); super("check", ConnectionListener.CHECK_PERMISSION);
ProxyServer.getInstance().getScheduler().schedule(VelocityCore.get(), () -> { VelocityCore.get().getProxyServer().getScheduler().buildTask(VelocityCore.get(), () -> {
List<SchematicNode> schematics = getSchemsToCheck(); List<SchematicNode> schematics = getSchemsToCheck();
if(schematics.size() != currentCheckers.size()) if(schematics.size() != currentCheckers.size())
Message.team("CHECK_REMINDER", "CHECK_REMINDER_HOVER", new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/check list"), schematics.size() - currentCheckers.size()); Message.team("CHECK_REMINDER", "CHECK_REMINDER_HOVER", ClickEvent.runCommand("/check list"), schematics.size() - currentCheckers.size());
}, 10, 10, TimeUnit.MINUTES); }).repeat(10, TimeUnit.MINUTES).schedule();
} }
public static void sendReminder(ProxiedPlayer player) { public static void sendReminder(Player player) {
List<SchematicNode> schematics = getSchemsToCheck(); List<SchematicNode> schematics = getSchemsToCheck();
if(schematics.size() != currentCheckers.size()) if(schematics.size() != currentCheckers.size())
Message.send("CHECK_REMINDER", player, Message.parse("CHECK_REMINDER_HOVER", player), new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/check list"), schematics.size() - currentCheckers.size()); Message.send("CHECK_REMINDER", player, Message.parse("CHECK_REMINDER_HOVER", player), ClickEvent.runCommand("/check list"), schematics.size() - currentCheckers.size());
} }
@Register(value = "list", description = "CHECK_HELP_LIST") @Register(value = "list", description = "CHECK_HELP_LIST")

Datei anzeigen

@ -19,20 +19,22 @@
package de.steamwar.bungeecore.network; package de.steamwar.bungeecore.network;
import com.velocitypowered.api.proxy.Player;
import com.velocitypowered.api.proxy.messages.ChannelIdentifier;
import com.velocitypowered.api.proxy.messages.MinecraftChannelIdentifier;
import com.velocitypowered.api.proxy.server.RegisteredServer;
import de.steamwar.network.packets.NetworkPacket; import de.steamwar.network.packets.NetworkPacket;
import lombok.SneakyThrows; import lombok.SneakyThrows;
import net.md_5.bungee.api.config.ServerInfo;
import net.md_5.bungee.api.connection.ProxiedPlayer;
public class NetworkSender { public class NetworkSender {
@SneakyThrows private static final ChannelIdentifier CHANNEL = MinecraftChannelIdentifier.create("sw", "bridge");
public static void send(ProxiedPlayer player, NetworkPacket packet) {
player.getServer().sendData("sw:bridge", packet.serialize()); public static void send(Player player, NetworkPacket packet) {
player.getCurrentServer().ifPresent(serverConnection -> send(serverConnection.getServer(), packet));
} }
public static void send(ServerInfo serverInfo, NetworkPacket packet) { public static void send(RegisteredServer server, NetworkPacket packet) {
ProxiedPlayer player = serverInfo.getPlayers().iterator().next(); server.sendPluginMessage(CHANNEL, packet.serialize());
send(player, packet);
} }
} }

Datei anzeigen

@ -19,18 +19,11 @@
package de.steamwar.bungeecore.network; package de.steamwar.bungeecore.network;
import com.velocitypowered.api.proxy.server.ServerInfo; import com.velocitypowered.api.proxy.server.RegisteredServer;
import de.steamwar.network.packets.MetaInfos; import de.steamwar.network.packets.MetaInfos;
import lombok.Getter;
public class ServerMetaInfo implements MetaInfos { @Getter
public record ServerMetaInfo(RegisteredServer sender) implements MetaInfos {
private ServerInfo sender;
public ServerMetaInfo(ServerInfo sender) {
this.sender = sender;
}
public ServerInfo getSender() {
return sender;
}
} }

Datei anzeigen

@ -19,6 +19,8 @@
package de.steamwar.bungeecore.network.handlers; package de.steamwar.bungeecore.network.handlers;
import com.velocitypowered.api.proxy.Player;
import com.velocitypowered.api.scheduler.Scheduler;
import de.steamwar.bungeecore.ArenaMode; import de.steamwar.bungeecore.ArenaMode;
import de.steamwar.bungeecore.VelocityCore; import de.steamwar.bungeecore.VelocityCore;
import de.steamwar.network.packets.PacketHandler; import de.steamwar.network.packets.PacketHandler;
@ -28,14 +30,12 @@ import de.steamwar.sql.SchematicType;
import de.steamwar.sql.SteamwarUser; import de.steamwar.sql.SteamwarUser;
import de.steamwar.sql.UserElo; import de.steamwar.sql.UserElo;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import net.md_5.bungee.BungeeTitle; import net.kyori.adventure.text.Component;
import net.md_5.bungee.api.ProxyServer; import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
import net.md_5.bungee.api.Title; import net.kyori.adventure.title.Title;
import net.md_5.bungee.api.chat.BaseComponent; import org.jetbrains.annotations.Nullable;
import net.md_5.bungee.api.chat.TextComponent;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.api.scheduler.TaskScheduler;
import java.time.Duration;
import java.util.*; import java.util.*;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.function.IntFunction; import java.util.function.IntFunction;
@ -45,7 +45,7 @@ public class EloPlayerHandler extends PacketHandler {
private static final int MEDIAN_ELO_GAIN = 40; private static final int MEDIAN_ELO_GAIN = 40;
private static final int MEDIAN_ELO_LOSE = 20; private static final int MEDIAN_ELO_LOSE = 20;
private static final long REMATCH_LIFETIME = 1L * 60 * 60 * 1000; private static final long REMATCH_LIFETIME = (long) 60 * 60 * 1000;
private Map<String, LinkedList<Game>> gameModeGames = new HashMap<>(); private Map<String, LinkedList<Game>> gameModeGames = new HashMap<>();
@ -183,7 +183,7 @@ public class EloPlayerHandler extends PacketHandler {
} }
} }
private void animate(ProxiedPlayer player, String oldEmblem, String newEmblem, String arrowColor, int eloGain) { private void animate(Player player, String oldEmblem, String newEmblem, String arrowColor, int eloGain) {
String finalOldEmblem = (oldEmblem.isEmpty() ? "/" : oldEmblem).trim(); String finalOldEmblem = (oldEmblem.isEmpty() ? "/" : oldEmblem).trim();
String finalNewEmblem = (newEmblem.isEmpty() ? "/" : newEmblem).trim(); String finalNewEmblem = (newEmblem.isEmpty() ? "/" : newEmblem).trim();
@ -198,22 +198,25 @@ public class EloPlayerHandler extends PacketHandler {
String color = ((eloGain > 0) ? "§a+" : (eloGain == 0 ? "§7" : "§c")); String color = ((eloGain > 0) ? "§a+" : (eloGain == 0 ? "§7" : "§c"));
TaskScheduler scheduler = ProxyServer.getInstance().getScheduler(); Scheduler scheduler = VelocityCore.get().getProxyServer().getScheduler();
double eloStep = eloGain / 40.0; double eloStep = eloGain / 40.0;
for (int i = 0; i < 40; i++) { for (int i = 0; i < 40; i++) {
BaseComponent[] eloGainComponent = TextComponent.fromLegacyText(color + (int) (eloStep * (i + 1))); Component eloGainComponent = LegacyComponentSerializer.legacySection().deserialize(color + (int) (eloStep * (i + 1)));
int finalI = i; int finalI = i;
scheduler.schedule(VelocityCore.get(), () -> { scheduler.buildTask(VelocityCore.get(), () -> {
if (player == null) return; if (player == null) return;
if (!player.isConnected()) return; Title title = Title.title(LegacyComponentSerializer.legacySection().deserialize(getRankup.apply(finalI)), eloGainComponent, Title.Times.times(
Title title = new BungeeTitle().title(TextComponent.fromLegacyText(getRankup.apply(finalI))).subTitle(eloGainComponent).fadeIn(finalI == 0 ? 5 : 0).stay(40).fadeOut(finalI == 39 ? 5 : 0); Duration.ofSeconds(finalI == 0 ? 5 : 0),
title.send(player); Duration.ofSeconds(2),
}, i * 50L, TimeUnit.MILLISECONDS); Duration.ofSeconds(finalI == 39 ? 5 : 0)
));
player.showTitle(title);
}).delay(i * 50L, TimeUnit.MILLISECONDS).schedule();
} }
} }
private ProxiedPlayer player(int userId) { private @Nullable Player player(int userId) {
return ProxyServer.getInstance().getPlayer(SteamwarUser.get(userId).getUUID()); return VelocityCore.get().getProxyServer().getPlayer(SteamwarUser.get(userId).getUUID()).orElseThrow();
} }
private double getTimeFactor(int duration) { private double getTimeFactor(int duration) {
@ -245,7 +248,7 @@ public class EloPlayerHandler extends PacketHandler {
@RequiredArgsConstructor @RequiredArgsConstructor
private static class Game { private static class Game {
private long time = System.currentTimeMillis(); private final long time = System.currentTimeMillis();
private final List<Integer> bluePlayers; private final List<Integer> bluePlayers;
private final List<Integer> redPlayers; private final List<Integer> redPlayers;

Datei anzeigen

@ -19,10 +19,10 @@
package de.steamwar.bungeecore.network.handlers; package de.steamwar.bungeecore.network.handlers;
import de.steamwar.bungeecore.VelocityCore;
import de.steamwar.sql.SteamwarUser; import de.steamwar.sql.SteamwarUser;
import de.steamwar.network.packets.PacketHandler; import de.steamwar.network.packets.PacketHandler;
import de.steamwar.network.packets.client.ExecuteCommandPacket; import de.steamwar.network.packets.client.ExecuteCommandPacket;
import net.md_5.bungee.api.ProxyServer;
public class ExecuteCommandHandler extends PacketHandler { public class ExecuteCommandHandler extends PacketHandler {
@ -31,6 +31,6 @@ public class ExecuteCommandHandler extends PacketHandler {
SteamwarUser target = SteamwarUser.get(packet.getPlayerId()); SteamwarUser target = SteamwarUser.get(packet.getPlayerId());
String command = packet.getCommand(); String command = packet.getCommand();
ProxyServer.getInstance().getPluginManager().dispatchCommand(ProxyServer.getInstance().getPlayer(target.getUUID()), command); VelocityCore.get().getProxyServer().getPlayer(target.getUUID()).ifPresent(player -> VelocityCore.get().getProxyServer().getCommandManager().executeAsync(player, command));
} }
} }

Datei anzeigen

@ -19,6 +19,8 @@
package de.steamwar.bungeecore.network.handlers; package de.steamwar.bungeecore.network.handlers;
import com.velocitypowered.api.proxy.Player;
import com.velocitypowered.api.proxy.server.RegisteredServer;
import de.steamwar.bungeecore.network.NetworkSender; import de.steamwar.bungeecore.network.NetworkSender;
import de.steamwar.bungeecore.network.ServerMetaInfo; import de.steamwar.bungeecore.network.ServerMetaInfo;
import de.steamwar.bungeecore.tablist.TablistManager; import de.steamwar.bungeecore.tablist.TablistManager;
@ -33,28 +35,28 @@ import java.util.Set;
public class FightInfoHandler extends PacketHandler { public class FightInfoHandler extends PacketHandler {
private static final Set<ServerInfo> lobbys = new HashSet<>(); private static final Set<RegisteredServer> lobbys = new HashSet<>();
public static void addLobby(ServerInfo lobby) { public static void addLobby(RegisteredServer lobby) {
lobbys.add(lobby); lobbys.add(lobby);
} }
public static boolean onLobby(ProxiedPlayer player) { public static boolean onLobby(Player player) {
return lobbys.contains(player.getServer().getInfo()); return player.getCurrentServer().map(serverConnection -> lobbys.contains(serverConnection.getServer())).orElse(false);
} }
@Handler @Handler
public void handle(FightInfoPacket packet) { public void handle(FightInfoPacket packet) {
ServerInfo info = ((ServerMetaInfo) packet.getMetaInfos()).getSender(); RegisteredServer info = ((ServerMetaInfo) packet.getMetaInfos()).sender();
FightInfoPacket lobbyPacket = packet.withServerName(info.getName()); FightInfoPacket lobbyPacket = packet.withServerName(info.getServerInfo().getName());
TablistManager.newFightInfo(info, packet); TablistManager.newFightInfo(info, packet);
Iterator<ServerInfo> lobbyIt = lobbys.iterator(); Iterator<RegisteredServer> lobbyIt = lobbys.iterator();
while(lobbyIt.hasNext()) { while(lobbyIt.hasNext()) {
ServerInfo lobby = lobbyIt.next(); RegisteredServer lobby = lobbyIt.next();
Iterator<ProxiedPlayer> it = lobby.getPlayers().iterator(); Iterator<Player> it = lobby.getPlayersConnected().iterator();
if(!it.hasNext()){ if(!it.hasNext()){
lobbyIt.remove(); lobbyIt.remove();
continue; continue;

Datei anzeigen

@ -27,6 +27,6 @@ public class ImALobbyHandler extends PacketHandler {
@Handler @Handler
public void handle(ImALobbyPacket packet) { public void handle(ImALobbyPacket packet) {
FightInfoHandler.addLobby(((ServerMetaInfo) packet.getMetaInfos()).getSender()); FightInfoHandler.addLobby(((ServerMetaInfo) packet.getMetaInfos()).sender());
} }
} }

Datei anzeigen

@ -28,7 +28,10 @@ import de.steamwar.sql.SteamwarUser;
import de.steamwar.network.packets.PacketHandler; import de.steamwar.network.packets.PacketHandler;
import de.steamwar.network.packets.client.InventoryCallbackPacket; import de.steamwar.network.packets.client.InventoryCallbackPacket;
import de.steamwar.network.packets.server.CloseInventoryPacket; import de.steamwar.network.packets.server.CloseInventoryPacket;
import net.md_5.bungee.api.ProxyServer; import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.NamedTextColor;
import net.kyori.adventure.text.format.Style;
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@ -42,9 +45,9 @@ public class InventoryCallbackHandler extends PacketHandler {
SteamwarUser owner = SteamwarUser.get(packet.getOwner()); SteamwarUser owner = SteamwarUser.get(packet.getOwner());
InventoryCallbackPacket.CallbackType type = packet.getType(); InventoryCallbackPacket.CallbackType type = packet.getType();
if(!inventoryHashMap.containsKey(owner.getId())) { if(!inventoryHashMap.containsKey(owner.getId())) {
VelocityCore.send(ProxyServer.getInstance().getPlayer(owner.getUUID()), VelocityCore.CHAT_PREFIX + "§cBitte erneut versuchen. Durch ein Softwareupdate konnte die übliche Aktion nicht durchgeführt werden."); VelocityCore.get().getProxyServer().getPlayer(owner.getUUID()).ifPresent(player -> player.sendMessage(LegacyComponentSerializer.legacySection().deserialize(VelocityCore.CHAT_PREFIX).append(Component.text("Bitte erneut versuchen. Durch ein Softwareupdate konnte die übliche Aktion nicht durchgeführt werden.", Style.style(NamedTextColor.RED)))));
if(type == InventoryCallbackPacket.CallbackType.CLICK) { if(type == InventoryCallbackPacket.CallbackType.CLICK) {
NetworkSender.send(((ServerMetaInfo) packet.getMetaInfos()).getSender(), new CloseInventoryPacket(owner.getId())); NetworkSender.send(((ServerMetaInfo) packet.getMetaInfos()).sender(), new CloseInventoryPacket(owner.getId()));
} }
return; return;
} }

Datei anzeigen

@ -19,20 +19,20 @@
package de.steamwar.bungeecore.network.handlers; package de.steamwar.bungeecore.network.handlers;
import com.velocitypowered.api.proxy.Player;
import de.steamwar.bungeecore.ArenaMode; import de.steamwar.bungeecore.ArenaMode;
import de.steamwar.bungeecore.ServerStarter; import de.steamwar.bungeecore.ServerStarter;
import de.steamwar.bungeecore.VelocityCore;
import de.steamwar.sql.SchematicType; import de.steamwar.sql.SchematicType;
import de.steamwar.sql.SteamwarUser; import de.steamwar.sql.SteamwarUser;
import de.steamwar.network.packets.PacketHandler; import de.steamwar.network.packets.PacketHandler;
import de.steamwar.network.packets.client.PrepareSchemPacket; import de.steamwar.network.packets.client.PrepareSchemPacket;
import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.connection.ProxiedPlayer;
public class PrepareSchemHandler extends PacketHandler { public class PrepareSchemHandler extends PacketHandler {
@Handler @Handler
public void handle(PrepareSchemPacket packet) { public void handle(PrepareSchemPacket packet) {
ProxiedPlayer player = ProxyServer.getInstance().getPlayer(SteamwarUser.get(packet.getPlayer()).getUUID()); Player player = VelocityCore.get().getProxyServer().getPlayer(SteamwarUser.get(packet.getPlayer()).getUUID()).orElseThrow();
int schematicID = packet.getSchem(); int schematicID = packet.getSchem();
ArenaMode mode = ArenaMode.getBySchemType(SchematicType.fromDB(packet.getSchemType())); ArenaMode mode = ArenaMode.getBySchemType(SchematicType.fromDB(packet.getSchemType()));

Datei anzeigen

@ -19,24 +19,12 @@
package de.steamwar.bungeecore.tablist; package de.steamwar.bungeecore.tablist;
import com.velocitypowered.api.proxy.player.TabList;
import de.steamwar.bungeecore.Storage; import de.steamwar.bungeecore.Storage;
import de.steamwar.messages.ChatSender; import de.steamwar.messages.ChatSender;
import io.netty.channel.ChannelHandler; import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelPipeline; import io.netty.channel.ChannelPipeline;
import io.netty.handler.codec.MessageToMessageDecoder;
import net.md_5.bungee.ServerConnection;
import net.md_5.bungee.UserConnection;
import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.chat.BaseComponent;
import net.md_5.bungee.api.chat.TextComponent;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.netty.PipelineUtils;
import net.md_5.bungee.protocol.DefinedPacket;
import net.md_5.bungee.protocol.Either;
import net.md_5.bungee.protocol.PacketWrapper;
import net.md_5.bungee.protocol.ProtocolConstants;
import net.md_5.bungee.protocol.packet.*;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -48,7 +36,7 @@ public class Tablist extends MessageToMessageDecoder<PacketWrapper> {
private static final UUID[] uuids = IntStream.range(0, 80).mapToObj(i -> UUID.randomUUID()).toArray(UUID[]::new); private static final UUID[] uuids = IntStream.range(0, 80).mapToObj(i -> UUID.randomUUID()).toArray(UUID[]::new);
private static final String[] names = IntStream.range(0, 80).mapToObj(i -> " »SW« " + String.format("%02d", i)).toArray(String[]::new); private static final String[] names = IntStream.range(0, 80).mapToObj(i -> " »SW« " + String.format("%02d", i)).toArray(String[]::new);
private static final String TAB_TEAM = "zzzzzsw-tab"; private static final String TAB_TEAM = "zzzzzsw-tab";
private static final Team teamPacket = new Team(TAB_TEAM, (byte) 0, Either.right(TextComponent.fromLegacy("")), Either.right(TextComponent.fromLegacy("")), Either.right(TextComponent.fromLegacy("")), "never", "always", 21, (byte)0x00, names); private static final TabList teamPacket = new Team(TAB_TEAM, (byte) 0, Either.right(TextComponent.fromLegacy("")), Either.right(TextComponent.fromLegacy("")), Either.right(TextComponent.fromLegacy("")), "never", "always", 21, (byte)0x00, names);
private final Map<UUID, PlayerListItem.Item> directTabItems; private final Map<UUID, PlayerListItem.Item> directTabItems;
private final Set<UUID> npcs = new HashSet<>(); private final Set<UUID> npcs = new HashSet<>();

Datei anzeigen

@ -19,12 +19,14 @@
package de.steamwar.bungeecore.tablist; package de.steamwar.bungeecore.tablist;
import com.velocitypowered.api.proxy.Player;
import com.velocitypowered.api.proxy.ServerConnection;
import com.velocitypowered.api.proxy.server.RegisteredServer;
import com.velocitypowered.api.proxy.server.ServerInfo;
import de.steamwar.bungeecore.Servertype; import de.steamwar.bungeecore.Servertype;
import de.steamwar.bungeecore.Subserver; import de.steamwar.bungeecore.Subserver;
import de.steamwar.bungeecore.VelocityCore;
import de.steamwar.messages.ChatSender; import de.steamwar.messages.ChatSender;
import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.config.ServerInfo;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
@ -34,19 +36,19 @@ import java.util.stream.Collectors;
public class TablistBuild implements TablistPart { public class TablistBuild implements TablistPart {
private final List<ServerInfo> servers = new ArrayList<>(); private final List<RegisteredServer> servers = new ArrayList<>();
private final Map<ServerInfo, List<Item>> players = new HashMap<>(); private final Map<RegisteredServer, List<Item>> players = new HashMap<>();
public TablistBuild() { public TablistBuild() {
for (ServerInfo server : new ArrayList<>(ProxyServer.getInstance().getServers().values())){ for (RegisteredServer server : new ArrayList<>(VelocityCore.get().getProxyServer().getAllServers())){
Subserver subserver = Subserver.getSubserver(server); Subserver subserver = Subserver.getSubserver(server.getServerInfo());
if(server.getPlayers().isEmpty() || subserver == null || subserver.getType() != Servertype.BAUSERVER) if(server.getPlayersConnected().isEmpty() || subserver == null || subserver.getType() != Servertype.BAUSERVER)
continue; continue;
servers.add(server); servers.add(server);
players.put(server, server.getPlayers().stream().sorted(((p1, p2) -> p1.getName().compareToIgnoreCase(p2.getName()))).map(Item::new).collect(Collectors.toList())); players.put(server, server.getPlayersConnected().stream().sorted(((p1, p2) -> p1.getUsername().compareToIgnoreCase(p2.getUsername()))).map(Item::new).collect(Collectors.toList()));
} }
servers.sort((s1, s2) -> s1.getName().compareToIgnoreCase(s2.getName())); servers.sort((s1, s2) -> s1.getServerInfo().getName().compareToIgnoreCase(s2.getServerInfo().getName()));
} }
@Override @Override
@ -55,14 +57,14 @@ public class TablistBuild implements TablistPart {
} }
@Override @Override
public void print(ChatSender viewer, ProxiedPlayer player, List<Item> tablist, List<Item> direct) { public void print(ChatSender viewer, Player player, List<Item> tablist, List<Item> direct) {
ServerInfo server = player.getServer().getInfo(); RegisteredServer server = player.getCurrentServer().map(ServerConnection::getServer).orElseThrow();
if(players.keySet().stream().anyMatch(info -> server != info)) { if(players.keySet().stream().anyMatch(info -> server != info)) {
tablist.add(new Item(null, "", TablistServer.GRAY)); tablist.add(new Item(null, "", TablistServer.GRAY));
tablist.add(new Item(null, viewer.parseToLegacy("TABLIST_BAU"), TablistServer.LIGHT_GRAY)); tablist.add(new Item(null, viewer.parseToLegacy("TABLIST_BAU"), TablistServer.LIGHT_GRAY));
} }
for (ServerInfo info : servers) { for (RegisteredServer info : servers) {
TablistServer.teamify(players.get(info), player) TablistServer.teamify(players.get(info), player)
.forEach(((server == info) ? direct : tablist)::add); .forEach(((server == info) ? direct : tablist)::add);
} }

Datei anzeigen

@ -19,8 +19,8 @@
package de.steamwar.bungeecore.tablist; package de.steamwar.bungeecore.tablist;
import com.velocitypowered.api.proxy.Player;
import de.steamwar.messages.ChatSender; import de.steamwar.messages.ChatSender;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import java.util.List; import java.util.List;
@ -37,7 +37,7 @@ public class TablistGroup implements TablistPart {
} }
@Override @Override
public void print(ChatSender viewer, ProxiedPlayer player, List<Item> tablist, List<Item> direct) { public void print(ChatSender viewer, Player player, List<Item> tablist, List<Item> direct) {
for (TablistPart sublist : sublists) { for (TablistPart sublist : sublists) {
sublist.print(viewer, player, tablist, direct); sublist.print(viewer, player, tablist, direct);
} }

Datei anzeigen

@ -19,6 +19,7 @@
package de.steamwar.bungeecore.tablist; package de.steamwar.bungeecore.tablist;
import com.velocitypowered.api.proxy.server.RegisteredServer;
import de.steamwar.bungeecore.VelocityCore; import de.steamwar.bungeecore.VelocityCore;
import de.steamwar.bungeecore.Servertype; import de.steamwar.bungeecore.Servertype;
import de.steamwar.bungeecore.Storage; import de.steamwar.bungeecore.Storage;
@ -38,7 +39,7 @@ import java.util.concurrent.TimeUnit;
public class TablistManager extends BasicListener { public class TablistManager extends BasicListener {
private static final Map<ServerInfo, FightInfoPacket> fightInfos = new HashMap<>(); private static final Map<RegisteredServer, FightInfoPacket> fightInfos = new HashMap<>();
public static synchronized void newFightInfo(ServerInfo info, FightInfoPacket packet) { public static synchronized void newFightInfo(ServerInfo info, FightInfoPacket packet) {
fightInfos.put(info, packet); fightInfos.put(info, packet);

Datei anzeigen

@ -19,54 +19,54 @@
package de.steamwar.bungeecore.tablist; package de.steamwar.bungeecore.tablist;
import com.velocitypowered.api.proxy.Player;
import com.velocitypowered.api.util.GameProfile;
import de.steamwar.messages.ChatSender; import de.steamwar.messages.ChatSender;
import de.steamwar.sql.SteamwarUser; import de.steamwar.sql.SteamwarUser;
import de.steamwar.sql.UserPerm; import de.steamwar.sql.UserPerm;
import net.md_5.bungee.api.chat.BaseComponent; import net.kyori.adventure.text.Component;
import net.md_5.bungee.api.chat.TextComponent; import net.kyori.adventure.text.TextComponent;
import net.md_5.bungee.api.connection.ProxiedPlayer; import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
import net.md_5.bungee.connection.InitialHandler;
import net.md_5.bungee.connection.LoginResult;
import net.md_5.bungee.protocol.Property;
import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
interface TablistPart { interface TablistPart {
String sortKey(); String sortKey();
void print(ChatSender viewer, ProxiedPlayer player, List<Item> tablist, List<Item> direct); void print(ChatSender viewer, Player player, List<Item> tablist, List<Item> direct);
class Item { class Item {
public static Property[] playerProperties(ProxiedPlayer player) { public static List<GameProfile.Property> playerProperties(Player player) {
LoginResult loginResult = ((InitialHandler) player.getPendingConnection()).getLoginProfile(); List<GameProfile.Property> loginResult = player.getGameProfileProperties();
if(loginResult == null) if(loginResult == null)
return new Property[0]; return Collections.emptyList();
return loginResult.getProperties(); return loginResult;
} }
private final UUID uuid; private final UUID uuid;
private final BaseComponent displayName; private final Component displayName;
private final Property[] properties; private final List<GameProfile.Property> properties;
public Item(UUID uuid, String displayName, Property[] properties) { public Item(UUID uuid, String displayName, List<GameProfile.Property> properties) {
this.uuid = uuid; this.uuid = uuid;
this.displayName = reformat(displayName); this.displayName = reformat(displayName);
this.properties = properties; this.properties = properties;
} }
public Item(ProxiedPlayer player) { public Item(Player player) {
this(player, false); this(player, false);
} }
public Item(ProxiedPlayer player, boolean sameTeam) { public Item(Player player, boolean sameTeam) {
this.uuid = player.getUniqueId(); this.uuid = player.getUniqueId();
UserPerm.Prefix prefix = SteamwarUser.get(player.getUniqueId()).prefix(); UserPerm.Prefix prefix = SteamwarUser.get(player.getUniqueId()).prefix();
if (prefix == UserPerm.emptyPrefix && sameTeam) { if (prefix == UserPerm.emptyPrefix && sameTeam) {
this.displayName = reformat("§f" + player.getName()); this.displayName = reformat("§f" + player.getUsername());
} else { } else {
this.displayName = reformat(prefix.getColorCode() + player.getName()); this.displayName = reformat(prefix.getColorCode() + player.getUsername());
} }
this.properties = playerProperties(player); this.properties = playerProperties(player);
} }
@ -75,16 +75,16 @@ interface TablistPart {
return uuid; return uuid;
} }
public BaseComponent getDisplayName() { public Component getDisplayName() {
return displayName; return displayName;
} }
public Property[] getProperties() { public List<GameProfile.Property> getProperties() {
return properties; return properties;
} }
private BaseComponent reformat(String string) { private Component reformat(String string) {
return TextComponent.fromArray(TextComponent.fromLegacyText(string)); return LegacyComponentSerializer.legacyAmpersand().deserialize(string);
} }
} }
} }

Datei anzeigen

@ -19,82 +19,81 @@
package de.steamwar.bungeecore.tablist; package de.steamwar.bungeecore.tablist;
import com.velocitypowered.api.proxy.Player;
import com.velocitypowered.api.proxy.ServerConnection;
import com.velocitypowered.api.proxy.server.RegisteredServer;
import com.velocitypowered.api.util.GameProfile;
import de.steamwar.bungeecore.Servertype; import de.steamwar.bungeecore.Servertype;
import de.steamwar.bungeecore.Subserver; import de.steamwar.bungeecore.Subserver;
import de.steamwar.bungeecore.VelocityCore;
import de.steamwar.sql.SteamwarUser; import de.steamwar.sql.SteamwarUser;
import de.steamwar.messages.ChatSender; import de.steamwar.messages.ChatSender;
import de.steamwar.network.packets.common.FightInfoPacket; import de.steamwar.network.packets.common.FightInfoPacket;
import net.md_5.bungee.BungeeCord;
import net.md_5.bungee.api.config.ServerInfo;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.protocol.Property;
import java.util.ArrayList; import java.util.*;
import java.util.Collection;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
public class TablistServer implements TablistPart { public class TablistServer implements TablistPart {
public static final Property[] GRAY = new Property[]{new Property("textures", "eyJ0aW1lc3RhbXAiOjE0NTU1NzQxMTk0MzMsInByb2ZpbGVJZCI6ImIzYjE4MzQ1MzViZjRiNzU4ZTBjZGJmMGY4MjA2NTZlIiwicHJvZmlsZU5hbWUiOiIxMDExMTEiLCJzaWduYXR1cmVSZXF1aXJlZCI6dHJ1ZSwidGV4dHVyZXMiOnsiU0tJTiI6eyJ1cmwiOiJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlLzZlNzJkMzE0NzczMmQ5NzFkZWZhZTIzMWIzOGQ5NDI0MTRiMDU3YTcxNTFjNTNjNWZkNjI5NmEzYjllZGEwYWIifX19", "ro/ZKHt7278yhCr+CFTcPp/q6wAUlef//85k2DzkfRaZqy0CtGgwisDs2U4pVKvQ2pfXvitzWgbJvD0bLeQ12xWi4c1Fc29LCArosVJoFmrJDHz7N2MlstHT+ynQROb9d2aiFA6uOXfLjPKb1noUZ/YQoZjqcPIvD5oFZtD5DHV5O4hYz0IvgHbIjDqjz6ITsTcKiBlbxNg2loTFxSlW1ZfnNCO+kcAmeyB5NFY3j0e+/AqVANiNoiC3OKsECM/yEx/acf+vKWcT8mQn4wRoIGtxfEU7ZjNtgdh73NvXXBygW+K9AiJ242g8Y06Xxuk8kaNEGmT6H/mM7nbwjZmQQXpi/Pao2gYqyeIofeCPfr8RsGXoDX3nXDAw8/LyhTCHgx+sp6IQYSfGcSMJtoNeTJ0liIFxqn1V9/zKmzOZAPzR6qrQPOjoRFljLAlv7rfzotaEqh/1ldd40GdS8tstczn7f29OQerNDaqvbDb00Gy0STdUr1bVyCDptA54XKjT9WFv7QpBikEculxqSppAXPxD2Fb/ZmphbZx8WEGfG6bVFhf6fQdDAUXlcv8BxjElNPwlolF86M2KJd5VquLluhrCjwID7OK/pffNultAVH+Lxw4QOAXmJqjUrA1KHgyG1S0Cwj/f4E2hdxZJBvkfVtq9qPkd9nignhEoTCTOHf0=")}; public static final List<GameProfile.Property> GRAY = Collections.singletonList(new GameProfile.Property("textures", "eyJ0aW1lc3RhbXAiOjE0NTU1NzQxMTk0MzMsInByb2ZpbGVJZCI6ImIzYjE4MzQ1MzViZjRiNzU4ZTBjZGJmMGY4MjA2NTZlIiwicHJvZmlsZU5hbWUiOiIxMDExMTEiLCJzaWduYXR1cmVSZXF1aXJlZCI6dHJ1ZSwidGV4dHVyZXMiOnsiU0tJTiI6eyJ1cmwiOiJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlLzZlNzJkMzE0NzczMmQ5NzFkZWZhZTIzMWIzOGQ5NDI0MTRiMDU3YTcxNTFjNTNjNWZkNjI5NmEzYjllZGEwYWIifX19", "ro/ZKHt7278yhCr+CFTcPp/q6wAUlef//85k2DzkfRaZqy0CtGgwisDs2U4pVKvQ2pfXvitzWgbJvD0bLeQ12xWi4c1Fc29LCArosVJoFmrJDHz7N2MlstHT+ynQROb9d2aiFA6uOXfLjPKb1noUZ/YQoZjqcPIvD5oFZtD5DHV5O4hYz0IvgHbIjDqjz6ITsTcKiBlbxNg2loTFxSlW1ZfnNCO+kcAmeyB5NFY3j0e+/AqVANiNoiC3OKsECM/yEx/acf+vKWcT8mQn4wRoIGtxfEU7ZjNtgdh73NvXXBygW+K9AiJ242g8Y06Xxuk8kaNEGmT6H/mM7nbwjZmQQXpi/Pao2gYqyeIofeCPfr8RsGXoDX3nXDAw8/LyhTCHgx+sp6IQYSfGcSMJtoNeTJ0liIFxqn1V9/zKmzOZAPzR6qrQPOjoRFljLAlv7rfzotaEqh/1ldd40GdS8tstczn7f29OQerNDaqvbDb00Gy0STdUr1bVyCDptA54XKjT9WFv7QpBikEculxqSppAXPxD2Fb/ZmphbZx8WEGfG6bVFhf6fQdDAUXlcv8BxjElNPwlolF86M2KJd5VquLluhrCjwID7OK/pffNultAVH+Lxw4QOAXmJqjUrA1KHgyG1S0Cwj/f4E2hdxZJBvkfVtq9qPkd9nignhEoTCTOHf0="));
public static final Property[] LIGHT_GRAY = new Property[]{new Property("textures", "eyJ0aW1lc3RhbXAiOjE0NTU2MjU1OTM5NjIsInByb2ZpbGVJZCI6ImIzYjE4MzQ1MzViZjRiNzU4ZTBjZGJmMGY4MjA2NTZlIiwicHJvZmlsZU5hbWUiOiIxMDExMTEiLCJzaWduYXR1cmVSZXF1aXJlZCI6dHJ1ZSwidGV4dHVyZXMiOnsiU0tJTiI6eyJ1cmwiOiJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlLzc4Y2I3ZmMyMDhiMzM4NTUwNGE4MTQ0MjA0NDI4ZmRjZDYzMjRiZWIzMWNhMmNlODZjYzQyNGI5NjNkODVjIn19fQ==", "R/wZUZRC1dishRdM9a2SSxxW3oYa0XSb/MxHbQpEUA791HxyqjaKLDu0wFX2r2a8ZTeVjzXpNzkg3+PkrA11o8h7lt86MTD1pi/rQqj/WRuoqf2LP+ypbssKV+LU15cYez2cj3QQVcJDXgWEnfSLNuBv6NG8BDUpUAjTWldvu99NCJHUoD0jNMHxY/fu4k5vCgOjaBaKgkjVk2bmUhegusmtMwco+3pYx+y8+gUW8ptx5SnePG+dOwTqLyBFiOt2AQ+gSvbU/jP9aAXgxOwz/b1pMaBWtzVhFU865NHlIdSpIHg/sh3uNah3a7gTgtTvxPQv1OzM/KtqYKiamsrRzAQMzRcs4A7Tp0GakLuxEaz401IwvQ7UGVYLFzGUVLB2MyqtPgifiqQSQxZpiqj9sM5QadhsUw00nfX7mTdW46U0MtNIbby1rLrvgQKoj08zt6LJlhI3yjyawy4iZkgF4oc+PCNwZc93GIbVL9LJaGkXk3RVA+JpGwfMJrGVbL7hl8ibbAcUv7uCEWdkAgZCd6w75jEE4tlhDSPDD4rXbn+FeTZRg2n/PGKtnoTZRzbniiFaNoSAHDZSVRG39xvBDFvtmL3SPaKhzKaifiYrgNn453WtR3kymqdAtPf1GN9d1VltGZ/+vMPwqPJb6thcrlcU64UGHbg1olRkiyZHvY8=")}; public static final List<GameProfile.Property> LIGHT_GRAY = Collections.singletonList(new GameProfile.Property("textures", "eyJ0aW1lc3RhbXAiOjE0NTU2MjU1OTM5NjIsInByb2ZpbGVJZCI6ImIzYjE4MzQ1MzViZjRiNzU4ZTBjZGJmMGY4MjA2NTZlIiwicHJvZmlsZU5hbWUiOiIxMDExMTEiLCJzaWduYXR1cmVSZXF1aXJlZCI6dHJ1ZSwidGV4dHVyZXMiOnsiU0tJTiI6eyJ1cmwiOiJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlLzc4Y2I3ZmMyMDhiMzM4NTUwNGE4MTQ0MjA0NDI4ZmRjZDYzMjRiZWIzMWNhMmNlODZjYzQyNGI5NjNkODVjIn19fQ==", "R/wZUZRC1dishRdM9a2SSxxW3oYa0XSb/MxHbQpEUA791HxyqjaKLDu0wFX2r2a8ZTeVjzXpNzkg3+PkrA11o8h7lt86MTD1pi/rQqj/WRuoqf2LP+ypbssKV+LU15cYez2cj3QQVcJDXgWEnfSLNuBv6NG8BDUpUAjTWldvu99NCJHUoD0jNMHxY/fu4k5vCgOjaBaKgkjVk2bmUhegusmtMwco+3pYx+y8+gUW8ptx5SnePG+dOwTqLyBFiOt2AQ+gSvbU/jP9aAXgxOwz/b1pMaBWtzVhFU865NHlIdSpIHg/sh3uNah3a7gTgtTvxPQv1OzM/KtqYKiamsrRzAQMzRcs4A7Tp0GakLuxEaz401IwvQ7UGVYLFzGUVLB2MyqtPgifiqQSQxZpiqj9sM5QadhsUw00nfX7mTdW46U0MtNIbby1rLrvgQKoj08zt6LJlhI3yjyawy4iZkgF4oc+PCNwZc93GIbVL9LJaGkXk3RVA+JpGwfMJrGVbL7hl8ibbAcUv7uCEWdkAgZCd6w75jEE4tlhDSPDD4rXbn+FeTZRg2n/PGKtnoTZRzbniiFaNoSAHDZSVRG39xvBDFvtmL3SPaKhzKaifiYrgNn453WtR3kymqdAtPf1GN9d1VltGZ/+vMPwqPJb6thcrlcU64UGHbg1olRkiyZHvY8="));
private final ServerInfo server; private final RegisteredServer server;
private final List<Item> players; private final List<Item> players;
public TablistServer(ServerInfo server) { public TablistServer(RegisteredServer server) {
this(server, server.getPlayers().stream().sorted((p1, p2) -> p1.getName().compareToIgnoreCase(p2.getName())).map(TablistPart.Item::new).collect(Collectors.toList())); this(server, server.getPlayersConnected().stream().sorted((p1, p2) -> p1.getUsername().compareToIgnoreCase(p2.getUsername())).map(TablistPart.Item::new).collect(Collectors.toList()));
} }
public TablistServer(ServerInfo server, FightInfoPacket info) { public TablistServer(RegisteredServer server, FightInfoPacket info) {
this(server, new ArrayList<>()); this(server, new ArrayList<>());
Collection<ProxiedPlayer> onlinePlayers = server.getPlayers(); Collection<Player> onlinePlayers = server.getPlayersConnected();
addPlayers(info.getBlueName().substring(0, 2), info.getBluePlayers(), onlinePlayers); addPlayers(info.getBlueName().substring(0, 2), info.getBluePlayers(), onlinePlayers);
addPlayers(info.getRedName().substring(0, 2), info.getRedPlayers(), onlinePlayers); addPlayers(info.getRedName().substring(0, 2), info.getRedPlayers(), onlinePlayers);
addPlayers("§7", info.getSpectators(), onlinePlayers); addPlayers("§7", info.getSpectators(), onlinePlayers);
} }
public TablistServer(ServerInfo server, List<Item> players) { public TablistServer(RegisteredServer server, List<Item> players) {
this.server = server; this.server = server;
this.players = players; this.players = players;
} }
@Override @Override
public String sortKey() { public String sortKey() {
return server.getName(); return server.getServerInfo().getName();
} }
@Override @Override
public void print(ChatSender viewer, ProxiedPlayer player, List<Item> tablist, List<Item> direct) { public void print(ChatSender viewer, Player player, List<Item> tablist, List<Item> direct) {
boolean onServer = player.getServer().getInfo() == server; boolean onServer = server.getPlayersConnected().contains(player);
List<Item> items = onServer ? direct : tablist; List<Item> items = onServer ? direct : tablist;
if(!onServer) { if(!onServer) {
items.add(new Item(null, "", GRAY)); items.add(new Item(null, "", GRAY));
items.add(new Item(null, "§7§l" + server.getName(), LIGHT_GRAY)); items.add(new Item(null, "§7§l" + server.getServerInfo().getName(), LIGHT_GRAY));
} }
teamify(players, player).forEach(items::add); teamify(players, player).forEach(items::add);
} }
private void addPlayers(String prefix, List<Integer> teamPlayers, Collection<ProxiedPlayer> onlinePlayers){ private void addPlayers(String prefix, List<Integer> teamPlayers, Collection<Player> onlinePlayers){
teamPlayers.stream().map(SteamwarUser::get).map( teamPlayers.stream().map(SteamwarUser::get).map(
user -> onlinePlayers.stream().filter(player -> player.getUniqueId().equals(user.getUUID())).findAny() user -> onlinePlayers.stream().filter(player -> player.getUniqueId().equals(user.getUUID())).findAny()
).filter(Optional::isPresent).map(Optional::get).sorted( ).filter(Optional::isPresent).map(Optional::get).sorted(
(p1, p2) -> p1.getName().compareToIgnoreCase(p2.getName()) (p1, p2) -> p1.getUsername().compareToIgnoreCase(p2.getUsername())
).forEachOrdered(player -> players.add(new Item(player.getUniqueId(), prefix + player.getName(), Item.playerProperties(player)))); ).forEachOrdered(player -> players.add(new Item(player.getUniqueId(), prefix + player.getUsername(), Item.playerProperties(player))));
} }
public static Stream<Item> teamify(List<Item> players, ProxiedPlayer player) { public static Stream<Item> teamify(List<Item> players, Player player) {
int team = SteamwarUser.get(player.getUniqueId()).getTeam(); int team = SteamwarUser.get(player.getUniqueId()).getTeam();
if (team == 0) return players.stream(); if (team == 0) return players.stream();
return players.stream().map(item -> { return players.stream().map(item -> {
ProxiedPlayer p = BungeeCord.getInstance().getPlayer(item.getUuid()); Optional<Player> pOpt = VelocityCore.get().getProxyServer().getPlayer(item.getUuid());
if (p == null) return item; if (pOpt.isEmpty()) return item;
Subserver subserver = Subserver.getSubserver(p.getServer().getInfo()); Player p = pOpt.get();
Subserver subserver = Subserver.getSubserver(p.getCurrentServer().map(ServerConnection::getServerInfo).orElse(null));
if (subserver != null && subserver.getType() == Servertype.ARENA) return item; if (subserver != null && subserver.getType() == Servertype.ARENA) return item;
if (SteamwarUser.get(p.getUniqueId()).getTeam() != team) return item; if (SteamwarUser.get(p.getUniqueId()).getTeam() != team) return item;
return new Item(p, true); return new Item(p, true);

Datei anzeigen

@ -19,14 +19,13 @@
package de.steamwar.sql; package de.steamwar.sql;
import com.velocitypowered.api.proxy.Player;
import com.velocitypowered.api.proxy.server.RegisteredServer;
import com.velocitypowered.api.proxy.server.ServerInfo;
import de.steamwar.bungeecore.VelocityCore; import de.steamwar.bungeecore.VelocityCore;
import de.steamwar.bungeecore.commands.CheckCommand; import de.steamwar.bungeecore.commands.CheckCommand;
import net.md_5.bungee.api.ProxyServer; import org.simpleyaml.configuration.Configuration;
import net.md_5.bungee.api.config.ServerInfo; import org.simpleyaml.configuration.file.YamlFile;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.config.Configuration;
import net.md_5.bungee.config.ConfigurationProvider;
import net.md_5.bungee.config.YamlConfiguration;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
@ -54,12 +53,12 @@ public class SQLWrapperImpl implements SQLWrapper {
@Override @Override
public void loadSchemTypes(List<SchematicType> tmpTypes, Map<String, SchematicType> tmpFromDB) { public void loadSchemTypes(List<SchematicType> tmpTypes, Map<String, SchematicType> tmpFromDB) {
File folder = new File(VelocityCore.get().getDataFolder().getParentFile(), "FightSystem"); File folder = new File(VelocityCore.get().getDataDirectory().getParent().toFile(), "FightSystem");
if(folder.exists()) { if(folder.exists()) {
for(File configFile : Arrays.stream(folder.listFiles((file, name) -> name.endsWith(".yml") && !name.endsWith(".kits.yml"))).sorted().collect(Collectors.toList())) { for(File configFile : Arrays.stream(folder.listFiles((file, name) -> name.endsWith(".yml") && !name.endsWith(".kits.yml"))).sorted().collect(Collectors.toList())) {
Configuration config; Configuration config;
try { try {
config = ConfigurationProvider.getProvider(YamlConfiguration.class).load(configFile); config = YamlFile.loadConfiguration(configFile);
} catch (IOException e) { } catch (IOException e) {
throw new SecurityException("Could not load SchematicTypes", e); throw new SecurityException("Could not load SchematicTypes", e);
} }
@ -96,10 +95,10 @@ public class SQLWrapperImpl implements SQLWrapper {
@Override @Override
public void additionalExceptionMetadata(StringBuilder builder) { public void additionalExceptionMetadata(StringBuilder builder) {
builder.append("\nServers: "); builder.append("\nServers: ");
for(Map.Entry<String, ServerInfo> server : ProxyServer.getInstance().getServers().entrySet()) { for(RegisteredServer server : VelocityCore.get().getProxyServer().getAllServers()) {
builder.append(server.getKey()).append("("); builder.append(server.getServerInfo().getName()).append("(");
for(ProxiedPlayer player : server.getValue().getPlayers()) { for(Player player : server.getPlayersConnected()) {
builder.append(player.getName()).append(" "); builder.append(player.getUsername()).append(" ");
} }
builder.append(") "); builder.append(") ");
} }