Signed-off-by: Lixfel <git-5w3l@lixfel.de>
Dieser Commit ist enthalten in:
Ursprung
286f06f866
Commit
2ef06f61e4
@ -54,10 +54,10 @@ repositories {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly 'org.projectlombok:lombok:1.18.22'
|
||||
testCompileOnly 'org.projectlombok:lombok:1.18.22'
|
||||
annotationProcessor 'org.projectlombok:lombok:1.18.22'
|
||||
testAnnotationProcessor 'org.projectlombok:lombok:1.18.22'
|
||||
compileOnly 'org.projectlombok:lombok:1.18.32'
|
||||
testCompileOnly 'org.projectlombok:lombok:1.18.32'
|
||||
annotationProcessor 'org.projectlombok:lombok:1.18.32'
|
||||
testAnnotationProcessor 'org.projectlombok:lombok:1.18.32'
|
||||
|
||||
compileOnly 'de.steamwar:velocity:RELEASE'
|
||||
annotationProcessor 'com.velocitypowered:velocity-api:3.3.0-SNAPSHOT'
|
||||
|
@ -251,7 +251,7 @@ public class Subserver {
|
||||
}
|
||||
|
||||
private Component generateBar(int progress) {
|
||||
return Component.text("⬛".repeat(Math.max(0, progress))).color(NamedTextColor.GOLD)
|
||||
return Component.text("⬛".repeat(Math.max(0, progress))).color(NamedTextColor.YELLOW)
|
||||
.append(Component.text("⬛".repeat(Math.max(0, 10 - progress))).color(NamedTextColor.DARK_GRAY));
|
||||
}
|
||||
|
||||
|
16
build.gradle
16
build.gradle
@ -77,22 +77,26 @@ allprojects {
|
||||
shadowJar {
|
||||
exclude 'META-INF/*'
|
||||
//https://imperceptiblethoughts.com/shadow/configuration/minimizing/
|
||||
minimize {
|
||||
/*minimize {
|
||||
exclude project(':')
|
||||
}
|
||||
exclude 'mysql:mysql-connector-java:8.0.33'
|
||||
}*/
|
||||
duplicatesStrategy DuplicatesStrategy.INCLUDE
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly 'org.projectlombok:lombok:1.18.22'
|
||||
testCompileOnly 'org.projectlombok:lombok:1.18.22'
|
||||
annotationProcessor 'org.projectlombok:lombok:1.18.22'
|
||||
testAnnotationProcessor 'org.projectlombok:lombok:1.18.22'
|
||||
compileOnly 'org.projectlombok:lombok:1.18.32'
|
||||
testCompileOnly 'org.projectlombok:lombok:1.18.32'
|
||||
annotationProcessor 'org.projectlombok:lombok:1.18.32'
|
||||
testAnnotationProcessor 'org.projectlombok:lombok:1.18.32'
|
||||
|
||||
annotationProcessor 'com.velocitypowered:velocity-api:3.3.0-SNAPSHOT'
|
||||
compileOnly 'de.steamwar:velocity:RELEASE'
|
||||
compileOnly project(":Persistent")
|
||||
|
||||
runtimeOnly 'org.xerial:sqlite-jdbc:3.36.0' //TODO native only linux
|
||||
implementation 'mysql:mysql-connector-java:8.0.33'
|
||||
|
||||
implementation("net.dv8tion:JDA:4.4.0_352") {
|
||||
exclude module: 'opus-java'
|
||||
}
|
||||
|
@ -25,28 +25,59 @@ import org.yaml.snakeyaml.LoaderOptions;
|
||||
import org.yaml.snakeyaml.TypeDescription;
|
||||
import org.yaml.snakeyaml.Yaml;
|
||||
import org.yaml.snakeyaml.constructor.Constructor;
|
||||
import org.yaml.snakeyaml.introspector.BeanAccess;
|
||||
import org.yaml.snakeyaml.representer.Representer;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
@Getter
|
||||
public class Config {
|
||||
|
||||
public static Config load() {
|
||||
public static <T> T load(Class<T> clazz, File file, Consumer<TypeDescription> description) {
|
||||
TypeDescription typeDescription = new TypeDescription(Config.class);
|
||||
typeDescription.addPropertyParameters("servers", String.class, Config.Server.class);
|
||||
description.accept(typeDescription);
|
||||
|
||||
Constructor constructor = new Constructor(clazz, new LoaderOptions());
|
||||
constructor.addTypeDescription(typeDescription);
|
||||
|
||||
Representer representer = new Representer();
|
||||
representer.getPropertyUtils().setSkipMissingProperties(true);
|
||||
|
||||
Yaml yaml = new Yaml(constructor, representer);
|
||||
yaml.setBeanAccess(BeanAccess.FIELD);
|
||||
|
||||
try{
|
||||
return yaml.load(new FileInputStream(file));
|
||||
}catch(IOException e){
|
||||
VelocityCore.getProxy().shutdown();
|
||||
throw new SecurityException("Could not load config", e);
|
||||
}
|
||||
}
|
||||
|
||||
public static Config load() {
|
||||
return load(Config.class, new File(VelocityCore.get().getDataDirectory().toFile(), "config.yml"), description -> description.addPropertyParameters("servers", String.class, Config.Server.class));
|
||||
|
||||
/*
|
||||
|
||||
typeDescription.addPropertyParameters("servers", String.class, Config.Server.class);
|
||||
Constructor constructor = new Constructor(Config.class, new LoaderOptions());
|
||||
constructor.addTypeDescription(typeDescription);
|
||||
|
||||
Yaml yaml = new Yaml(constructor);
|
||||
yaml.setBeanAccess(BeanAccess.FIELD);
|
||||
|
||||
try{
|
||||
return new Yaml(constructor).load(new FileInputStream(new File(VelocityCore.get().getDataDirectory().toFile(), "config.yml")));
|
||||
return yaml.load(new FileInputStream(new File(VelocityCore.get().getDataDirectory().toFile(), "config.yml")));
|
||||
}catch(IOException e){
|
||||
VelocityCore.getProxy().shutdown();
|
||||
throw new SecurityException("Could not load config.yml", e);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
private String lobbyserver;
|
||||
@ -67,7 +98,6 @@ public class Config {
|
||||
|
||||
@Getter
|
||||
public static class Server {
|
||||
private String permission = "user";
|
||||
private int spectatePort = 0;
|
||||
private List<String> commands;
|
||||
}
|
||||
|
@ -27,19 +27,20 @@ import java.text.MessageFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.logging.Handler;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.LogRecord;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.logging.*;
|
||||
|
||||
public class ErrorLogger extends Handler {
|
||||
|
||||
ErrorLogger(){
|
||||
Logger.getLogger("").addHandler(this);
|
||||
Logger logger = VelocityCore.getLogger();
|
||||
while(logger.getParent() != null)
|
||||
logger = logger.getParent();
|
||||
|
||||
logger.addHandler(this);
|
||||
}
|
||||
|
||||
void unregister(){
|
||||
Logger.getLogger("").removeHandler(this);
|
||||
Logger.getGlobal().removeHandler(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -78,16 +79,6 @@ public class ErrorLogger extends Handler {
|
||||
|
||||
static {
|
||||
List<String> contains = new ArrayList<>();
|
||||
contains.add("Error authenticating ");
|
||||
contains.add("read timed out");
|
||||
contains.add("could not decode packet");
|
||||
contains.add("Connection reset by peer");
|
||||
contains.add("No client connected for pending server");
|
||||
contains.add("Error occurred processing connection for");
|
||||
contains.add("Server is online mode!");
|
||||
contains.add(" took ");
|
||||
contains.add("Could not translate packet ");
|
||||
contains.add("455420");
|
||||
ignoreContains = Collections.unmodifiableList(contains);
|
||||
}
|
||||
}
|
||||
|
@ -21,12 +21,8 @@ package de.steamwar.bungeecore;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.yaml.snakeyaml.Yaml;
|
||||
import org.yaml.snakeyaml.constructor.Constructor;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@ -40,13 +36,13 @@ public class GameModeConfig {
|
||||
if(!folder.exists())
|
||||
return;
|
||||
|
||||
Yaml yaml = new Yaml(new Constructor(config));
|
||||
for(File file : Arrays.stream(folder.listFiles((file, name) -> name.endsWith(".yml") && !name.endsWith(".kits.yml"))).sorted().toList()) {
|
||||
try {
|
||||
consumer.accept(file, Config.load(config, file, description -> {}));
|
||||
/*try {
|
||||
consumer.accept(file, yaml.load(new FileInputStream(file)));
|
||||
} catch (IOException e) {
|
||||
throw new SecurityException("Could not load GameModeConfig", e);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -46,6 +46,8 @@ import de.steamwar.sql.internal.Statement;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -101,6 +103,12 @@ public class VelocityCore {
|
||||
this.dataDirectory = dataDirectory;
|
||||
|
||||
instance = this;
|
||||
|
||||
try {
|
||||
DriverManager.registerDriver(new com.mysql.cj.jdbc.Driver());
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
|
@ -72,7 +72,7 @@ public class PunishmentCommand {
|
||||
} catch (NoSuchElementException e) {
|
||||
// ignore, player does not exist
|
||||
} catch (IOException e) {
|
||||
VelocityCore.getLogger().log(Level.SEVERE, "Could not get offline player UUID {0}".formatted(playerName), e);
|
||||
VelocityCore.getLogger().log(Level.SEVERE, "Could not get offline player UUID %s".formatted(playerName), e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -19,21 +19,22 @@
|
||||
|
||||
package de.steamwar.bungeecore.commands;
|
||||
|
||||
import com.velocitypowered.api.proxy.server.RegisteredServer;
|
||||
import de.steamwar.bungeecore.VelocityCore;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.messages.PlayerChatter;
|
||||
|
||||
public class ServerSwitchCommand extends SWCommand {
|
||||
|
||||
private final String serverName;
|
||||
private final RegisteredServer server;
|
||||
|
||||
public ServerSwitchCommand(String cmd, String name, String... aliases) {
|
||||
super(cmd, null, aliases);
|
||||
serverName = name;
|
||||
server = VelocityCore.getProxy().getServer(name).orElseThrow();
|
||||
}
|
||||
|
||||
@Register
|
||||
public void genericCommand(PlayerChatter sender) {
|
||||
sender.getPlayer().createConnectionRequest(VelocityCore.getProxy().getServer(serverName).orElseThrow()).fireAndForget();
|
||||
sender.getPlayer().createConnectionRequest(server).fireAndForget();
|
||||
}
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ public class VerifyCommand extends SWCommand {
|
||||
|
||||
User user = AuthManager.connectAuth(sender.user(), code);
|
||||
if(user != null) {
|
||||
VelocityCore.getLogger().log(Level.INFO, "{0} Verified with Discorduser: {1}".formatted(sender.user().getUserName(), user.getIdLong()));
|
||||
VelocityCore.getLogger().log(Level.INFO,"%s Verified with Discorduser: %s".formatted(sender.user().getUserName(), user.getIdLong()));
|
||||
sender.system("VERIFY_SUCCESS", user.getAsTag());
|
||||
} else {
|
||||
sender.system("VERIFY_INVALID");
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
package de.steamwar.bungeecore.discord;
|
||||
|
||||
import de.steamwar.bungeecore.Config;
|
||||
import de.steamwar.bungeecore.VelocityCore;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
@ -26,14 +27,8 @@ import lombok.Getter;
|
||||
import net.dv8tion.jda.api.entities.Emoji;
|
||||
import net.dv8tion.jda.api.interactions.components.Button;
|
||||
import net.dv8tion.jda.api.interactions.components.ButtonStyle;
|
||||
import org.yaml.snakeyaml.LoaderOptions;
|
||||
import org.yaml.snakeyaml.TypeDescription;
|
||||
import org.yaml.snakeyaml.Yaml;
|
||||
import org.yaml.snakeyaml.constructor.Constructor;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@ -45,17 +40,21 @@ public class DiscordConfig {
|
||||
if(!file.exists() || VelocityCore.get().getConfig().isEventmode())
|
||||
return null;
|
||||
|
||||
TypeDescription typeDescription = new TypeDescription(DiscordConfig.class);
|
||||
return Config.load(DiscordConfig.class, file, description -> description.addPropertyParameters("roles", String.class, DiscordRole.class));
|
||||
/*TypeDescription typeDescription = new TypeDescription(DiscordConfig.class);
|
||||
typeDescription.addPropertyParameters("roles", String.class, DiscordRole.class);
|
||||
|
||||
Constructor constructor = new Constructor(DiscordConfig.class, new LoaderOptions());
|
||||
constructor.addTypeDescription(typeDescription);
|
||||
|
||||
Yaml yaml = new Yaml(constructor);
|
||||
yaml.setBeanAccess(BeanAccess.FIELD);
|
||||
|
||||
try{
|
||||
return new Yaml(constructor).load(new FileInputStream(file));
|
||||
return yaml.load(new FileInputStream(file));
|
||||
}catch(IOException e){
|
||||
throw new SecurityException("Could not load discord bot configuration", e);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
public String channel(String type) {
|
||||
|
@ -82,7 +82,7 @@ public class DiscordSchemUpload extends ListenerAdapter {
|
||||
} catch (InterruptedException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
} catch (ExecutionException | IOException e) {
|
||||
VelocityCore.getLogger().log(Level.SEVERE, "Could not upload schem \"{0}\" for user \"{1}\"".formatted(name, user.getUserName()), e);
|
||||
VelocityCore.getLogger().log(Level.SEVERE, "Could not upload schem \"%s\" for user \"%s\"".formatted(name, user.getUserName()), e);
|
||||
sender.system("DC_SCHEMUPLOAD_ERROR", name);
|
||||
}
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ public class AuthManager {
|
||||
String code = Base64.getEncoder().encodeToString(randBytes);
|
||||
|
||||
TOKENS.put(code, user);
|
||||
VelocityCore.getLogger().log(Level.INFO, "Created Discord Auth-Token: {0} for: {1}".formatted(code, user.getAsTag()));
|
||||
VelocityCore.getLogger().log(Level.INFO, "Created Discord Auth-Token: %s for: %s".formatted(code, user.getAsTag()));
|
||||
VelocityCore.schedule(() -> TOKENS.remove(code)).delay(10, TimeUnit.MINUTES).schedule();
|
||||
return code;
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ public class ChatListener extends BasicListener {
|
||||
if (message.contains("jndi:ldap")) {
|
||||
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
||||
PunishmentCommand.ban(user, Punishment.PERMA_TIME, "Versuchte Exploit-Ausnutzung", SteamwarUser.get(-1), true);
|
||||
VelocityCore.getLogger().log(Level.SEVERE, "{0} {1} wurde automatisch wegen jndi:ldap gebannt.".formatted(user.getUserName(), user.getId()));
|
||||
VelocityCore.getLogger().log(Level.SEVERE, "%s %s wurde automatisch wegen jndi:ldap gebannt.".formatted(user.getUserName(), user.getId()));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -46,7 +46,7 @@ public class IPSanitizer extends BasicListener {
|
||||
|
||||
@Subscribe
|
||||
public void loginEvent(PreLoginEvent e) {
|
||||
VelocityCore.getLogger().log(Level.INFO, "{0} has logged in with user name {1}".formatted(e.getConnection().getRemoteAddress(), e.getUsername()));
|
||||
VelocityCore.getLogger().log(Level.INFO, "%s has logged in with user name %s".formatted(e.getConnection().getRemoteAddress(), e.getUsername()));
|
||||
remoteAddress.set(Hostname.getInitialInboundConnection((LoginInboundConnection) e.getConnection()).getConnection(), sanitized);
|
||||
}
|
||||
}
|
||||
|
@ -26,6 +26,7 @@ import com.velocitypowered.api.network.ProtocolVersion;
|
||||
import com.velocitypowered.api.proxy.Player;
|
||||
import com.velocitypowered.api.proxy.ServerConnection;
|
||||
import com.velocitypowered.api.proxy.messages.ChannelMessageSource;
|
||||
import com.velocitypowered.api.proxy.messages.LegacyChannelIdentifier;
|
||||
import com.velocitypowered.api.proxy.messages.MinecraftChannelIdentifier;
|
||||
import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
||||
import de.steamwar.bungeecore.VelocityCore;
|
||||
@ -54,7 +55,7 @@ public class PluginMessage extends BasicListener {
|
||||
|
||||
public static void send(Player player, String channel, byte[] data) {
|
||||
//TODO only if player has registered channel
|
||||
player.sendPluginMessage(MinecraftChannelIdentifier.from(channel), data);
|
||||
player.sendPluginMessage(channel.indexOf(':') != -1 ? MinecraftChannelIdentifier.from(channel) : new LegacyChannelIdentifier(channel), data);
|
||||
}
|
||||
|
||||
public static byte[] genBufPacket(Consumer<ByteBuf> generator) {
|
||||
@ -242,7 +243,7 @@ public class PluginMessage extends BasicListener {
|
||||
private void register(String channel, boolean clientSideRegister, Parser handler) {
|
||||
handlers.put(channel, handler);
|
||||
if(clientSideRegister)
|
||||
VelocityCore.getProxy().getChannelRegistrar().register(MinecraftChannelIdentifier.from(channel));
|
||||
VelocityCore.getProxy().getChannelRegistrar().register(channel.indexOf(':') != -1 ? MinecraftChannelIdentifier.from(channel) : new LegacyChannelIdentifier(channel));
|
||||
}
|
||||
|
||||
private void clientRegistersChannel(PluginMessageEvent event) {
|
||||
|
@ -22,8 +22,9 @@ package de.steamwar.bungeecore.mods;
|
||||
import com.velocitypowered.api.event.Subscribe;
|
||||
import com.velocitypowered.api.event.connection.PluginMessageEvent;
|
||||
import com.velocitypowered.api.event.connection.PostLoginEvent;
|
||||
import com.velocitypowered.api.network.ProtocolVersion;
|
||||
import com.velocitypowered.api.proxy.Player;
|
||||
import com.velocitypowered.api.proxy.messages.MinecraftChannelIdentifier;
|
||||
import com.velocitypowered.api.proxy.messages.LegacyChannelIdentifier;
|
||||
import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
||||
import de.steamwar.bungeecore.VelocityCore;
|
||||
import de.steamwar.bungeecore.listeners.BasicListener;
|
||||
@ -59,7 +60,8 @@ public class FML extends BasicListener {
|
||||
}
|
||||
|
||||
//if(isFML(player, "\0FML\0"))
|
||||
player.sendPluginMessage(MinecraftChannelIdentifier.from(CHANNEL), helloPacket);
|
||||
if(player.getProtocolVersion().lessThan(ProtocolVersion.MINECRAFT_1_13))
|
||||
player.sendPluginMessage(new LegacyChannelIdentifier(CHANNEL), helloPacket);
|
||||
}
|
||||
|
||||
public void handlePluginMessage(PluginMessageEvent event) {
|
||||
|
@ -54,7 +54,7 @@ public class ModUtils {
|
||||
Chatter sender = Chatter.of(uuid);
|
||||
SteamwarUser user = sender.user();
|
||||
playerModMap.put(uuid,new ArrayList<>(mods));
|
||||
VelocityCore.getLogger().log(Level.INFO, "{0} declares mods: {1}".formatted(user.getUserName(), mods.stream().map(mod -> mod.getPlatform() + ":" + mod.getModName()).collect(Collectors.joining(" "))));
|
||||
VelocityCore.getLogger().log(Level.INFO, "%s declares mods: %s".formatted(user.getUserName(), mods.stream().map(mod -> mod.getPlatform() + ":" + mod.getModName()).collect(Collectors.joining(" "))));
|
||||
|
||||
ModType max = ModType.YELLOW;
|
||||
Iterator<Mod> it = mods.iterator();
|
||||
@ -83,7 +83,7 @@ public class ModUtils {
|
||||
|
||||
if(max == ModType.RED) {
|
||||
PunishmentCommand.ban(user, Timestamp.from(Instant.now().plus(7, ChronoUnit.DAYS)), message, SteamwarUser.get(-1), false);
|
||||
VelocityCore.getLogger().log(Level.SEVERE, "{0} {1} wurde automatisch wegen der Mods {2} gebannt.".formatted(user.getUserName(), user.getId(), modList));
|
||||
VelocityCore.getLogger().log(Level.SEVERE, "%s %s wurde automatisch wegen der Mods %s gebannt.".formatted(user.getUserName(), user.getId(), modList));
|
||||
}
|
||||
|
||||
disconnect.accept(LegacyComponentSerializer.legacySection().deserialize(message));
|
||||
|
@ -21,10 +21,8 @@ package de.steamwar.bungeecore.mods;
|
||||
|
||||
import com.google.gson.*;
|
||||
import com.velocitypowered.api.proxy.server.ServerPing;
|
||||
import de.steamwar.bungeecore.VelocityCore;
|
||||
import lombok.AllArgsConstructor;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Type;
|
||||
|
||||
@AllArgsConstructor
|
||||
@ -39,23 +37,12 @@ public class ServerListPing implements JsonSerializer<ServerPing>, JsonDeserial
|
||||
};
|
||||
|
||||
public static void init() {
|
||||
try {
|
||||
for (String fieldName : FIELDS_TO_OVERRIDE) {
|
||||
Field field = VelocityCore.getProxy().getClass().getDeclaredField(fieldName);
|
||||
field.setAccessible(true);
|
||||
Object obj = field.get(null);
|
||||
if (obj instanceof Gson gsonOld) {
|
||||
Gson gsonNew = new GsonBuilder()
|
||||
.registerTypeAdapter(ServerPing.class, new ServerListPing(gsonOld))
|
||||
.create();
|
||||
field.set(null, gsonNew);
|
||||
} else {
|
||||
throw new SecurityException("Failed to inject ServerListPing in " + fieldName);
|
||||
}
|
||||
}
|
||||
} catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e) {
|
||||
throw new SecurityException("Failed to inject ServerListPing", e);
|
||||
}
|
||||
/*for (String fieldName : FIELDS_TO_OVERRIDE) {
|
||||
Reflection.Field<VelocityServer, Gson> field = Reflection.getField(VelocityServer.class, fieldName);
|
||||
field.set(null, new GsonBuilder()
|
||||
.registerTypeAdapter(ServerPing.class, new ServerListPing(field.get(null)))
|
||||
.create());
|
||||
}*/
|
||||
}
|
||||
|
||||
private final Gson gson;
|
||||
|
@ -72,7 +72,6 @@ public class Tablist extends ChannelInboundHandlerAdapter {
|
||||
return;
|
||||
|
||||
player.sendPlayerListHeaderAndFooter(header(viewer, seconds), viewer.parse(false, "TABLIST_FOOTER", connection.getServerInfo().getName(), ping(), VelocityCore.getProxy().getPlayerCount()));
|
||||
player.getTabList();
|
||||
|
||||
List<TablistPart.Item> tablist = new ArrayList<>();
|
||||
List<TablistPart.Item> direct = new ArrayList<>();
|
||||
@ -98,7 +97,7 @@ public class Tablist extends ChannelInboundHandlerAdapter {
|
||||
update.add(tabItem);
|
||||
}
|
||||
}
|
||||
boolean playerNotOnTeamserver = !Storage.teamServers.containsValue(player.getCurrentServer().orElseThrow().getServerInfo());
|
||||
boolean playerNotOnTeamserver = !Storage.teamServers.containsValue(connection.getServerInfo());
|
||||
for(UpsertPlayerInfoPacket.Entry item : directTabItems.values()) {
|
||||
if(playerNotOnTeamserver && !nonNPCs.contains(item.getProfileId()) && !npcs.contains(item.getProfileId()) && !player.getUniqueId().equals(item.getProfileId())) {
|
||||
npcs.add(item.getProfileId());
|
||||
|
@ -22,7 +22,7 @@ package de.steamwar.bungeecore.tablist;
|
||||
import com.velocitypowered.api.event.Subscribe;
|
||||
import com.velocitypowered.api.event.connection.DisconnectEvent;
|
||||
import com.velocitypowered.api.event.connection.PostLoginEvent;
|
||||
import com.velocitypowered.api.event.player.ServerConnectedEvent;
|
||||
import com.velocitypowered.api.event.player.ServerPostConnectEvent;
|
||||
import com.velocitypowered.api.proxy.Player;
|
||||
import com.velocitypowered.api.proxy.server.RegisteredServer;
|
||||
import de.steamwar.bungeecore.Servertype;
|
||||
@ -66,7 +66,7 @@ public class TablistManager extends BasicListener {
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onServerConnection(ServerConnectedEvent event) {
|
||||
public void onServerConnection(ServerPostConnectEvent event) {
|
||||
synchronized (tablists) {
|
||||
tablists.get(event.getPlayer()).onServerSwitch();
|
||||
}
|
||||
|
@ -27,5 +27,15 @@ public class Chat19 {
|
||||
|
||||
public static void chat(Player p, String message) {
|
||||
p.spoofChatInput(message);
|
||||
|
||||
/*if(p.getProtocolVersion().greaterThan(ProtocolVersion.MINECRAFT_1_18_2)) {
|
||||
if(message.startsWith("/")) {
|
||||
((ServerConnection) p.getServer()).getCh().write(new ClientCommand(message.substring(1), System.currentTimeMillis(), 0, Collections.emptyMap(), false, new ChatChain(Collections.emptyList(), null), new SeenMessages(0, new BitSet(0))));
|
||||
} else {
|
||||
((ServerConnection) p.getServer()).getCh().write(new ClientChat(message, System.currentTimeMillis(), 0, version < ProtocolConstants.MINECRAFT_1_19_3 ? new byte[0] : null, false, new ChatChain(Collections.emptyList(), null), new SeenMessages(0, new BitSet(0))));
|
||||
}
|
||||
} else {
|
||||
p.spoofChatInput(message);
|
||||
}*/
|
||||
}
|
||||
}
|
@ -30,6 +30,7 @@ import net.kyori.adventure.text.event.ClickEvent;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.function.Supplier;
|
||||
@ -83,6 +84,9 @@ public class SWCommand extends AbstractSWCommand<Chatter> {
|
||||
|
||||
@Override
|
||||
public List<String> suggest(Invocation invocation) {
|
||||
if(invocation.arguments().length == 0)
|
||||
return Collections.emptyList();
|
||||
|
||||
return SWCommand.this.tabComplete(Chatter.of(invocation.source()), invocation.alias(), invocation.arguments());
|
||||
}
|
||||
|
||||
@ -177,7 +181,7 @@ public class SWCommand extends AbstractSWCommand<Chatter> {
|
||||
chatter.prefixless(s, new Message("PLAIN_STRING", hover), ClickEvent.suggestCommand("/" + name + " " + String.join(" ", subCommand.subCommand)));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
VelocityCore.getLogger().log(Level.WARNING, "Failed to send description of registered method '{0}' with description '{1}'".formatted(subCommand.method, Arrays.toString(subCommand.description)), e);
|
||||
VelocityCore.getLogger().log(Level.WARNING, "Failed to send description of registered method '%s' with description '%s'".formatted(subCommand.method, Arrays.toString(subCommand.description)), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren