geforkt von SteamWar/BungeeCore
Commits vergleichen
5 Commits
master
...
tokens-com
Autor | SHA1 | Datum | |
---|---|---|---|
a5bbe63ebf | |||
a2ce616dbb | |||
53249cec61 | |||
18dfcf5025 | |||
b024d24a93 |
@ -1 +1 @@
|
||||
Subproject commit 20c22c47f940c4510de17594b28eb0a96cb9da0c
|
||||
Subproject commit 9a3630b07cb870266669ba120985a2c0a8ebbf5c
|
51
build.gradle
51
build.gradle
@ -29,7 +29,7 @@ plugins {
|
||||
id 'java'
|
||||
id 'application'
|
||||
|
||||
id 'com.github.johnrengelman.shadow' version '8.1.1'
|
||||
id 'com.github.johnrengelman.shadow' version '5.0.0'
|
||||
id 'de.steamwar.gradle' version 'RELEASE'
|
||||
}
|
||||
|
||||
@ -38,10 +38,8 @@ version ''
|
||||
|
||||
compileJava.options.encoding = 'UTF-8'
|
||||
|
||||
java {
|
||||
sourceCompatibility = JavaVersion.VERSION_17
|
||||
targetCompatibility = JavaVersion.VERSION_17
|
||||
}
|
||||
sourceCompatibility = 1.8
|
||||
targetCompatibility = 1.8
|
||||
|
||||
mainClassName = ''
|
||||
|
||||
@ -60,32 +58,8 @@ sourceSets {
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven {
|
||||
name = 'papermc'
|
||||
url = 'https://repo.papermc.io/repository/maven-public/'
|
||||
url 'https://m2.dv8tion.net/releases'
|
||||
}
|
||||
maven {
|
||||
url = 'https://m2.dv8tion.net/releases'
|
||||
content {
|
||||
includeGroup 'net.dv8tion'
|
||||
}
|
||||
}
|
||||
maven {
|
||||
url = 'https://repo.lunarclient.dev'
|
||||
content {
|
||||
includeGroup 'com.lunarclient'
|
||||
}
|
||||
}
|
||||
maven { url 'https://jitpack.io' }
|
||||
mavenLocal()
|
||||
}
|
||||
|
||||
shadowJar {
|
||||
exclude 'META-INF/*'
|
||||
//https://imperceptiblethoughts.com/shadow/configuration/minimizing/
|
||||
minimize {
|
||||
exclude project(':')
|
||||
}
|
||||
duplicatesStrategy DuplicatesStrategy.INCLUDE
|
||||
}
|
||||
|
||||
dependencies {
|
||||
@ -94,24 +68,11 @@ dependencies {
|
||||
annotationProcessor 'org.projectlombok:lombok:1.18.22'
|
||||
testAnnotationProcessor 'org.projectlombok:lombok:1.18.22'
|
||||
|
||||
compileOnly '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 'de.steamwar:persistentvelocitycore:DEV'
|
||||
compileOnly 'de.steamwar:waterfall:RELEASE'
|
||||
compileOnly 'de.steamwar:persistentbungeecore:RELEASE'
|
||||
implementation("net.dv8tion:JDA:4.4.0_352") {
|
||||
exclude module: 'opus-java'
|
||||
}
|
||||
|
||||
implementation project(":CommonCore")
|
||||
|
||||
implementation 'com.lunarclient:apollo-api:1.1.0'
|
||||
implementation 'com.lunarclient:apollo-common:1.1.0'
|
||||
|
||||
implementation 'org.reflections:reflections:0.10.2'
|
||||
|
||||
compileOnly 'io.netty:netty-buffer:4.1.106.Final'
|
||||
compileOnly 'io.netty:netty-transport:4.1.106.Final'
|
||||
|
||||
implementation 'com.github.Carleslc.Simple-YAML:Simple-Yaml:1.8.4'
|
||||
}
|
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@ -1,5 +1,5 @@
|
||||
#Sat Apr 10 23:34:12 CEST 2021
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1-all.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.1-all.zip
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStorePath=wrapper/dists
|
||||
|
@ -26,6 +26,6 @@ pluginManagement {
|
||||
}
|
||||
}
|
||||
|
||||
rootProject.name = 'VelocityCore'
|
||||
rootProject.name = 'BungeeCore'
|
||||
|
||||
include 'CommonCore'
|
@ -20,8 +20,10 @@
|
||||
package de.steamwar.bungeecore;
|
||||
|
||||
import de.steamwar.sql.SchematicType;
|
||||
import org.simpleyaml.configuration.Configuration;
|
||||
import org.simpleyaml.configuration.file.YamlFile;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
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.IOException;
|
||||
@ -47,12 +49,12 @@ public class ArenaMode {
|
||||
bySchemType.clear();
|
||||
allModes.clear();
|
||||
|
||||
File folder = new File(VelocityCore.get().getDataDirectory().getParent().toFile(), "FightSystem");
|
||||
File folder = new File(ProxyServer.getInstance().getPluginsFolder(), "FightSystem");
|
||||
|
||||
for(File configFile : Arrays.stream(folder.listFiles((file, name) -> name.endsWith(".yml") && !name.endsWith(".kits.yml"))).sorted().collect(Collectors.toList())) {
|
||||
Configuration config;
|
||||
try {
|
||||
config = YamlFile.loadConfiguration(configFile);
|
||||
config = ConfigurationProvider.getProvider(YamlConfiguration.class).load(configFile);
|
||||
} catch (IOException e) {
|
||||
throw new SecurityException("Could not load SchematicTypes", e);
|
||||
}
|
||||
|
@ -19,8 +19,7 @@
|
||||
|
||||
package de.steamwar.bungeecore;
|
||||
|
||||
import de.steamwar.messages.ChatSender;
|
||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@ -30,15 +29,14 @@ class Broadcaster {
|
||||
private int lastBroadCast = 0;
|
||||
|
||||
Broadcaster(){
|
||||
VelocityCore.get().getProxyServer().getScheduler().buildTask(VelocityCore.get(), () -> {
|
||||
if(!VelocityCore.get().getProxyServer().getAllPlayers().isEmpty() && broadCastMsgs.length > 0) {
|
||||
VelocityCore.get().getProxyServer().sendMessage(LegacyComponentSerializer.legacySection().deserialize(VelocityCore.CHAT_PREFIX + broadCastMsgs[lastBroadCast]));
|
||||
}
|
||||
ProxyServer.getInstance().getScheduler().schedule(BungeeCore.get(), () -> {
|
||||
if(!ProxyServer.getInstance().getPlayers().isEmpty() && broadCastMsgs.length > 0)
|
||||
BungeeCore.broadcast(BungeeCore.CHAT_PREFIX + broadCastMsgs[lastBroadCast]);
|
||||
lastBroadCast++;
|
||||
if(lastBroadCast == broadCastMsgs.length){
|
||||
lastBroadCast = 0;
|
||||
}
|
||||
}).repeat(10, TimeUnit.MINUTES);
|
||||
}, 10, 10, TimeUnit.MINUTES);
|
||||
}
|
||||
|
||||
static void setBroadCastMsgs(String[] broadCastMsgs) {
|
||||
|
@ -19,25 +19,16 @@
|
||||
|
||||
package de.steamwar.bungeecore;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Injector;
|
||||
import com.velocitypowered.api.event.Subscribe;
|
||||
import com.velocitypowered.api.event.proxy.ProxyInitializeEvent;
|
||||
import com.velocitypowered.api.event.proxy.ProxyReloadEvent;
|
||||
import com.velocitypowered.api.plugin.Plugin;
|
||||
import com.velocitypowered.api.plugin.annotation.DataDirectory;
|
||||
import com.velocitypowered.api.proxy.Player;
|
||||
import com.velocitypowered.api.proxy.ProxyServer;
|
||||
import de.steamwar.bungeecore.bot.SteamwarDiscordBot;
|
||||
import de.steamwar.bungeecore.bot.config.SteamwarDiscordBotConfig;
|
||||
import de.steamwar.bungeecore.commands.*;
|
||||
import de.steamwar.bungeecore.listeners.*;
|
||||
import de.steamwar.bungeecore.mods.ServerListPing;
|
||||
import de.steamwar.bungeecore.mods.*;
|
||||
import de.steamwar.bungeecore.listeners.mods.*;
|
||||
import de.steamwar.bungeecore.listeners.ping.PingListener;
|
||||
import de.steamwar.bungeecore.network.BungeeNetworkHandler;
|
||||
import de.steamwar.bungeecore.network.NetworkReceiver;
|
||||
import de.steamwar.bungeecore.network.SWScriptSyntaxForwarder;
|
||||
import de.steamwar.bungeecore.tablist.TablistManager;
|
||||
import de.steamwar.bungeecore.util.SteamWarModule;
|
||||
import de.steamwar.bungeecore.util.annotations.Create;
|
||||
import de.steamwar.command.SWCommandUtils;
|
||||
import de.steamwar.command.SWTypeMapperCreator;
|
||||
import de.steamwar.command.TabCompletionCache;
|
||||
@ -47,23 +38,29 @@ import de.steamwar.sql.SteamwarUser;
|
||||
import de.steamwar.sql.Team;
|
||||
import de.steamwar.sql.UserElo;
|
||||
import de.steamwar.sql.internal.Statement;
|
||||
import lombok.Getter;
|
||||
import org.reflections.Reflections;
|
||||
import net.md_5.bungee.BungeeCord;
|
||||
import net.md_5.bungee.api.ChatMessageType;
|
||||
import net.md_5.bungee.api.CommandSender;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
import net.md_5.bungee.api.chat.ClickEvent;
|
||||
import net.md_5.bungee.api.chat.HoverEvent;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import net.md_5.bungee.api.config.ServerInfo;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
import net.md_5.bungee.api.plugin.Plugin;
|
||||
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.IOException;
|
||||
import java.nio.file.Path;
|
||||
import java.util.*;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
@Plugin(
|
||||
id = "velocitycore",
|
||||
name = "VelocityCore",
|
||||
authors = {"SteamWar"}
|
||||
)
|
||||
public class VelocityCore {
|
||||
public class BungeeCore extends Plugin {
|
||||
|
||||
public static boolean MAIN_SERVER;
|
||||
|
||||
@ -71,72 +68,57 @@ public class VelocityCore {
|
||||
public static String LOBBY_SERVER;
|
||||
public static boolean EVENT_MODE;
|
||||
|
||||
private static VelocityCore instance;
|
||||
private static BungeeCore instance;
|
||||
|
||||
public static Node local;
|
||||
private ErrorLogger errorLogger;
|
||||
private TablistManager tablistManager;
|
||||
|
||||
@Getter
|
||||
private final ProxyServer proxyServer;
|
||||
@Override
|
||||
public void onEnable(){
|
||||
getProxy().registerChannel("sw:bridge");
|
||||
getProxy().registerChannel("fabricmodsender:mods");
|
||||
getProxy().registerChannel("nochatreports:sync");
|
||||
getProxy().registerChannel("sw:script_syntax");
|
||||
|
||||
@Getter
|
||||
private final Logger logger;
|
||||
|
||||
@Getter
|
||||
private final Path dataDirectory;
|
||||
|
||||
@Getter
|
||||
private Injector injector;
|
||||
|
||||
@Inject
|
||||
public VelocityCore(ProxyServer proxyServer, Logger logger, @DataDirectory Path dataDirectory, Injector injector) {
|
||||
this.proxyServer = proxyServer;
|
||||
this.logger = logger;
|
||||
this.dataDirectory = dataDirectory;
|
||||
this.injector = injector;
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onProxyInitialization(ProxyInitializeEvent event) {
|
||||
setInstance(this);
|
||||
MAIN_SERVER = proxyServer.getBoundAddress().getPort() == 25565;
|
||||
MAIN_SERVER = ProxyServer.getInstance().getConfig().getListeners().stream().anyMatch(info -> ((InetSocketAddress) info.getSocketAddress()).getPort() == 25565);
|
||||
loadConfig();
|
||||
|
||||
injector = injector.createChildInjector(new SteamWarModule(this));
|
||||
|
||||
errorLogger = new ErrorLogger();
|
||||
|
||||
SWCommandUtils.init((SWTypeMapperCreator<TypeMapper<Object>, Player, Object>) (mapper, tabCompleter) -> new TypeMapper<Object>() {
|
||||
SWCommandUtils.init((SWTypeMapperCreator<TypeMapper<Object>, CommandSender, Object>) (mapper, tabCompleter) -> new TypeMapper<Object>() {
|
||||
@Override
|
||||
public Object map(Player commandSender, String[] previousArguments, String s) {
|
||||
public Object map(CommandSender commandSender, String[] previousArguments, String s) {
|
||||
return mapper.apply(s);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<String> tabCompletes(Player sender, String[] previousArguments, String s) {
|
||||
public Collection<String> tabCompletes(CommandSender sender, String[] previousArguments, String s) {
|
||||
return tabCompleter.apply(sender, s);
|
||||
}
|
||||
});
|
||||
proxyServer.getScheduler().buildTask(this, TabCompletionCache::invalidateOldEntries).repeat(1, TimeUnit.SECONDS);
|
||||
BungeeCord.getInstance().getScheduler().schedule(this, TabCompletionCache::invalidateOldEntries, 1, 1, TimeUnit.SECONDS);
|
||||
|
||||
Reflections reflections = new Reflections("de.steamwar.bungeecore");
|
||||
reflections.getTypesAnnotatedWith(Create.class)
|
||||
.forEach(clazz -> {
|
||||
Create create = clazz.getAnnotation(Create.class);
|
||||
if (create.eventProxy() || MAIN_SERVER) {
|
||||
Object obj = injector.getInstance(clazz);
|
||||
if (Arrays.stream(clazz.getDeclaredMethods()).anyMatch(method -> method.isAnnotationPresent(Subscribe.class))) {
|
||||
proxyServer.getEventManager().register(this, obj);
|
||||
}
|
||||
}
|
||||
});
|
||||
new NonFabricFabricCheck();
|
||||
|
||||
new SWScriptSyntaxForwarder();
|
||||
new ConnectionListener();
|
||||
new Forge();
|
||||
new Forge12();
|
||||
new LabyMod();
|
||||
new Badlion();
|
||||
new ChatListener();
|
||||
new BanListener();
|
||||
new CheckListener();
|
||||
new IPSanitizer();
|
||||
new ModLoaderBlocker();
|
||||
new WorldDownloader();
|
||||
new BrandListener();
|
||||
new Fabric();
|
||||
new SubserverProtocolFixer();
|
||||
new PingListener();
|
||||
|
||||
local = new Node.LocalNode();
|
||||
if(MAIN_SERVER) {
|
||||
//new Node.RemoteNode("lx");
|
||||
}
|
||||
@ -204,15 +186,16 @@ public class VelocityCore {
|
||||
|
||||
new EventStarter();
|
||||
new SessionManager();
|
||||
new NetworkReceiver();
|
||||
BungeeNetworkHandler.register();
|
||||
tablistManager = new TablistManager();
|
||||
new SettingsChangedListener();
|
||||
|
||||
proxyServer.getScheduler().buildTask(this, () -> {
|
||||
getProxy().getScheduler().schedule(this, () -> {
|
||||
SteamwarUser.clear();
|
||||
UserElo.clear();
|
||||
Team.clear();
|
||||
}).repeat(1, TimeUnit.HOURS);
|
||||
}, 1, 1, TimeUnit.HOURS);
|
||||
|
||||
if (SteamwarDiscordBotConfig.loaded) {
|
||||
try {
|
||||
@ -223,8 +206,8 @@ public class VelocityCore {
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onDisable(ProxyReloadEvent event) {
|
||||
@Override
|
||||
public void onDisable(){
|
||||
if (SteamwarDiscordBotConfig.loaded) {
|
||||
try {
|
||||
SteamwarDiscordBot.instance().getJda().shutdown();
|
||||
@ -239,10 +222,64 @@ public class VelocityCore {
|
||||
Statement.closeAll();
|
||||
}
|
||||
|
||||
public static VelocityCore get() {
|
||||
public static BungeeCore get() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
public static TextComponent stringToText(String msg){
|
||||
return new TextComponent(TextComponent.fromLegacyText(msg));
|
||||
}
|
||||
public static void send(ProxiedPlayer player, String msg){
|
||||
send(player, msg, null, null);
|
||||
}
|
||||
public static void send(CommandSender sender, String msg){
|
||||
sender.sendMessage(stringToText(msg));
|
||||
}
|
||||
public static void send(ProxiedPlayer player, ChatMessageType type, String msg){
|
||||
send(player, type, msg, null, null);
|
||||
}
|
||||
public static void send(ProxiedPlayer player, String msg, String onHover, ClickEvent onClick){
|
||||
send(player, ChatMessageType.SYSTEM, msg, onHover, onClick);
|
||||
}
|
||||
public static void send(ProxiedPlayer player, ChatMessageType type, String msg, String onHover, ClickEvent onClick){
|
||||
if(type == ChatMessageType.CHAT && player.getChatMode() != ProxiedPlayer.ChatMode.SHOWN)
|
||||
return;
|
||||
TextComponent message = stringToText(msg);
|
||||
if(onHover != null)
|
||||
message.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText(onHover)));
|
||||
if(onClick != null)
|
||||
message.setClickEvent(onClick);
|
||||
player.sendMessage(type, message);
|
||||
}
|
||||
public static void broadcast(String msg){
|
||||
ProxyServer.getInstance().broadcast(stringToText(msg));
|
||||
}
|
||||
public static void broadcast(String msg, String onHover, ClickEvent onClick){
|
||||
TextComponent message = stringToText(msg);
|
||||
if(onHover != null)
|
||||
message.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText(onHover)));
|
||||
if(onClick != null)
|
||||
message.setClickEvent(onClick);
|
||||
ProxyServer.getInstance().broadcast(message);
|
||||
}
|
||||
|
||||
public static void log(final ServerInfo server, final String msg){
|
||||
log(server.getName() + ": " + msg);
|
||||
}
|
||||
public static void log(final ProxiedPlayer player, final String msg){
|
||||
log(player.getName() + ": " + msg);
|
||||
}
|
||||
public static void log(final String msg){
|
||||
log(Level.INFO, msg);
|
||||
}
|
||||
public static void log(final Level logLevel, final String msg){
|
||||
get().getLogger().log(logLevel, msg);
|
||||
}
|
||||
public static void log(final String msg, final Throwable e){
|
||||
get().getLogger().log(Level.SEVERE, msg, e);
|
||||
}
|
||||
|
||||
|
||||
private static void loadConfig(){
|
||||
Configuration config;
|
||||
try{
|
||||
@ -275,15 +312,14 @@ public class VelocityCore {
|
||||
final Configuration server = servers.getSection(serverName);
|
||||
List<String> cmds = server.getStringList("commands");
|
||||
String cmd = cmds.remove(0);
|
||||
|
||||
if(server.contains("spectatePort"))
|
||||
EventStarter.addSpectateServer(server.getInt("spectatePort"), cmd);
|
||||
|
||||
new ServerSwitchCommand(
|
||||
cmd,
|
||||
serverName,
|
||||
cmds.toArray(new String[0])
|
||||
);
|
||||
if(server.getBoolean("modchecked", false)) {
|
||||
ModLoaderBlocker.addServer(serverName);
|
||||
}
|
||||
}
|
||||
|
||||
File discordFile = new File(System.getProperty("user.home"), "discord.yml");
|
||||
@ -296,7 +332,7 @@ public class VelocityCore {
|
||||
}
|
||||
}
|
||||
|
||||
private static void setInstance(VelocityCore core){
|
||||
private static void setInstance(BungeeCore core){
|
||||
instance = core;
|
||||
}
|
||||
}
|
@ -87,7 +87,6 @@ public class ErrorLogger extends Handler {
|
||||
contains.add("Server is online mode!");
|
||||
contains.add(" took ");
|
||||
contains.add("Could not translate packet ");
|
||||
contains.add("455420");
|
||||
ignoreContains = Collections.unmodifiableList(contains);
|
||||
}
|
||||
}
|
||||
|
@ -20,36 +20,41 @@
|
||||
package de.steamwar.bungeecore;
|
||||
|
||||
import de.steamwar.sql.EventFight;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import de.steamwar.sql.Team;
|
||||
import net.kyori.adventure.text.event.ClickEvent;
|
||||
import de.steamwar.sql.Event;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
import net.md_5.bungee.api.chat.ClickEvent;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
import net.md_5.bungee.api.scheduler.ScheduledTask;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Queue;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static de.steamwar.bungeecore.Storage.eventServer;
|
||||
|
||||
public class EventStarter {
|
||||
public class EventStarter implements Runnable {
|
||||
|
||||
private static final Map<Integer, String> spectatePorts = new HashMap<>();
|
||||
private static ScheduledTask task = null;
|
||||
|
||||
public static void addSpectateServer(int port, String command) {
|
||||
spectatePorts.put(port, command);
|
||||
}
|
||||
|
||||
public EventStarter() {
|
||||
EventStarter(){
|
||||
EventFight.loadAllComingFights();
|
||||
VelocityCore.get().getProxyServer().getScheduler().buildTask(VelocityCore.get(), this::run).repeat(10, TimeUnit.SECONDS);
|
||||
|
||||
if(task != null)
|
||||
task.cancel();
|
||||
|
||||
ProxyServer.getInstance().getScheduler().schedule(BungeeCore.get(), this, 1, 10, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
public static Map<Integer, Subserver> getEventServer() {
|
||||
return eventServer;
|
||||
}
|
||||
|
||||
private void run() {
|
||||
eventServer.entrySet().removeIf(entry -> Subserver.getSubserver(entry.getValue().getServer()) == null);
|
||||
@Override
|
||||
public void run() {
|
||||
eventServer.entrySet().removeIf(entry -> !Subserver.getServerList().contains(entry.getValue()));
|
||||
Queue<EventFight> fights = EventFight.getFights();
|
||||
|
||||
EventFight next;
|
||||
@ -58,19 +63,22 @@ public class EventStarter {
|
||||
Team red = Team.get(next.getTeamRed());
|
||||
|
||||
//Don't start EventServer if not the event bungee
|
||||
if(VelocityCore.EVENT_MODE || next.getSpectatePort() == 0) {
|
||||
if(BungeeCore.EVENT_MODE || !Event.get(next.getEventID()).spectateSystem()) {
|
||||
ServerStarter starter = new ServerStarter().event(next);
|
||||
|
||||
starter.callback(subserver -> {
|
||||
eventServer.put(blue.getTeamId(), subserver);
|
||||
eventServer.put(red.getTeamId(), subserver);
|
||||
}).start();
|
||||
ProxiedPlayer leiter = ProxyServer.getInstance().getPlayer(SteamwarUser.get(next.getKampfleiter()).getUUID());
|
||||
if(leiter != null)
|
||||
starter.send(leiter);
|
||||
|
||||
Subserver subserver = starter.start();
|
||||
|
||||
eventServer.put(blue.getTeamId(), subserver);
|
||||
eventServer.put(red.getTeamId(), subserver);
|
||||
Message.broadcast("EVENT_FIGHT_BROADCAST", "EVENT_FIGHT_BROADCAST_HOVER",
|
||||
ClickEvent.runCommand("/event " + blue.getTeamKuerzel()), blue.getTeamColor(), blue.getTeamName(), red.getTeamColor(), red.getTeamName());
|
||||
new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/event " + blue.getTeamKuerzel()), blue.getTeamColor(), blue.getTeamName(), red.getTeamColor(), red.getTeamName());
|
||||
} else {
|
||||
Message.broadcast("EVENT_FIGHT_BROADCAST", "EVENT_FIGHT_BROADCAST_HOVER",
|
||||
ClickEvent.runCommand("/" + spectatePorts.get(next.getSpectatePort())), blue.getTeamColor(), blue.getTeamName(), red.getTeamColor(), red.getTeamName());
|
||||
new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/spectate"), blue.getTeamColor(), blue.getTeamName(), red.getTeamColor(), red.getTeamName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -19,13 +19,12 @@
|
||||
|
||||
package de.steamwar.bungeecore;
|
||||
|
||||
import com.velocitypowered.api.command.CommandSource;
|
||||
import de.steamwar.messages.ChatSender;
|
||||
import de.steamwar.messages.SteamwarResourceBundle;
|
||||
import net.kyori.adventure.identity.Identity;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.event.ClickEvent;
|
||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
import net.md_5.bungee.api.ChatMessageType;
|
||||
import net.md_5.bungee.api.CommandSender;
|
||||
import net.md_5.bungee.api.chat.ClickEvent;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.MessageFormat;
|
||||
@ -36,17 +35,17 @@ import java.util.ResourceBundle;
|
||||
public class Message {
|
||||
|
||||
@Deprecated
|
||||
public static Component parseToComponent(String message, boolean prefixed, CommandSource sender, Object... params){
|
||||
return LegacyComponentSerializer.legacySection().deserialize(parse(message, prefixed, locale(sender), params));
|
||||
public static TextComponent parseToComponent(String message, boolean prefixed, CommandSender sender, Object... params){
|
||||
return new TextComponent(TextComponent.fromLegacyText(parse(message, prefixed, locale(sender), params)));
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static String parsePrefixed(String message, CommandSource sender, Object... params){
|
||||
public static String parsePrefixed(String message, CommandSender sender, Object... params){
|
||||
return parse(message, true, locale(sender), params);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static String parse(String message, CommandSource sender, Object... params){
|
||||
public static String parse(String message, CommandSender sender, Object... params){
|
||||
return parse(message, false, locale(sender), params);
|
||||
}
|
||||
|
||||
@ -56,8 +55,8 @@ public class Message {
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
private static Locale locale(CommandSource sender) {
|
||||
return sender.get(Identity.LOCALE).orElse(Locale.GERMAN);
|
||||
private static Locale locale(CommandSender sender) {
|
||||
return ChatSender.of(sender).getLocale();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@ -83,32 +82,32 @@ public class Message {
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static void send(String message, CommandSource sender, Object... params){
|
||||
send(message, true, sender, null, null, params);
|
||||
public static void send(String message, CommandSender sender, Object... params){
|
||||
send(message, true, sender, ChatMessageType.SYSTEM, null, null, params);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static void sendPrefixless(String message, CommandSource sender, Object... params){
|
||||
send(message, false, sender, null, null, params);
|
||||
public static void sendPrefixless(String message, CommandSender sender, Object... params){
|
||||
send(message, false, sender, ChatMessageType.SYSTEM, null, null, params);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static void send(String message, CommandSource sender, String onHover, ClickEvent onClick, Object... params){
|
||||
send(message, true, sender, onHover, onClick, params);
|
||||
public static void send(String message, CommandSender sender, String onHover, ClickEvent onClick, Object... params){
|
||||
send(message, true, sender, ChatMessageType.SYSTEM, onHover, onClick, params);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static void sendPrefixless(String message, CommandSource sender, String onHover, ClickEvent onClick, Object... params){
|
||||
send(message, false, sender, onHover, onClick, params);
|
||||
public static void sendPrefixless(String message, CommandSender sender, String onHover, ClickEvent onClick, Object... params){
|
||||
send(message, false, sender, ChatMessageType.SYSTEM, onHover, onClick, params);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
private static void send(String message, boolean prefixed, CommandSource s, String onHover, ClickEvent onClick, Object... params){
|
||||
private static void send(String message, boolean prefixed, CommandSender s, ChatMessageType type, String onHover, ClickEvent onClick, Object... params){
|
||||
ChatSender sender = ChatSender.of(s);
|
||||
if(!sender.chatShown())
|
||||
if(type == ChatMessageType.CHAT && !sender.chatShown())
|
||||
return;
|
||||
|
||||
sender.send(prefixed, onHover != null ? new Message("PLAIN_STRING", onHover) : null, onClick, new Message(message, params));
|
||||
sender.send(prefixed, type, onHover != null ? new Message("PLAIN_STRING", onHover) : null, onClick, new Message(message, params));
|
||||
}
|
||||
|
||||
public static void broadcast(String message, Object... params) {
|
||||
|
@ -23,7 +23,6 @@ import net.md_5.bungee.BungeeCord;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
|
||||
import java.io.*;
|
||||
import java.nio.file.Files;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.function.Consumer;
|
||||
@ -31,13 +30,7 @@ import java.util.logging.Level;
|
||||
|
||||
public abstract class Node {
|
||||
|
||||
//-Xquickstart Langzeitperformance testen!
|
||||
private static final List<String> OPENJ9_ARGS = Arrays.asList(
|
||||
"-XX:+EnableCRIUSupport", "-XX:-CRIURestoreNonPortableMode",
|
||||
"-Xgc:excessiveGCratio=80", "-Xdisableexplicitgc", "-Xnoclassgc", "-Xmos128M", "-Xmns48M", "-XX:+ExitOnOutOfMemoryError", // initial heap half values of memory observed by 1.19 spectate server
|
||||
"-Xsyslog:none", "-Xtrace:none", "-Xverify:none", "-Xdump:system:none", "-Xdump:jit:none", "-Xdump:snap:none",
|
||||
"-Dlog4j.configurationFile=log4j2.xml"
|
||||
);
|
||||
private static final List<String> OPENJ9_ARGS = Arrays.asList("-Xgc:excessiveGCratio=80", "-Xsyslog:none", "-Xtrace:none", "-Xdisableexplicitgc", "-XX:+AlwaysPreTouch", "-XX:+CompactStrings", "-XX:-HeapDumpOnOutOfMemory", "-XX:+ExitOnOutOfMemoryError", "-Dlog4j.configurationFile=log4j2.xml", "-Dio.netty.allocator.numHeapArenas=1", "-Xnoclassgc", "-Xmos128M", "-Xmns48M"); // initial heap half values of memory observed by 1.19 spectate server
|
||||
private static final Set<String> JAVA_8 = new HashSet<>();
|
||||
static {
|
||||
JAVA_8.add("paper-1.8.8.jar");
|
||||
@ -48,6 +41,7 @@ public abstract class Node {
|
||||
}
|
||||
|
||||
private static final long MIN_FREE_MEM = 4 * 1024 * 1024L; // 4 GiB
|
||||
private static final double MAX_LOAD = 0.8;
|
||||
|
||||
private static final List<Node> nodes = new ArrayList<>();
|
||||
|
||||
@ -71,10 +65,13 @@ public abstract class Node {
|
||||
protected final String hostname;
|
||||
protected volatile boolean belowLoadLimit = true;
|
||||
|
||||
private long previousCpuLoaded = 0;
|
||||
private long previousCpuTotal = 0;
|
||||
|
||||
protected Node(String hostname) {
|
||||
this.hostname = hostname;
|
||||
nodes.add(this);
|
||||
VelocityCore.get().getProxyServer().getScheduler().buildTask(VelocityCore.get(), () -> calcLoadLimit()).repeat(2, TimeUnit.SECONDS);
|
||||
BungeeCord.getInstance().getScheduler().schedule(BungeeCore.get(), this::calcLoadLimit, 1, 2, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
public void execute(String... command) {
|
||||
@ -83,7 +80,7 @@ public abstract class Node {
|
||||
} catch (IOException e) {
|
||||
throw new SecurityException("Could not execute command", e);
|
||||
} catch (InterruptedException e) {
|
||||
VelocityCore.get().getLogger().log(Level.SEVERE, "Interrupted during execution", e);
|
||||
ProxyServer.getInstance().getLogger().log(Level.SEVERE, "Interrupted during execution", e);
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
}
|
||||
@ -99,18 +96,17 @@ public abstract class Node {
|
||||
if (JAVA_8.contains(serverJar))
|
||||
cmd.add("/usr/lib/jvm/java-8-openj9-amd64/bin/java");
|
||||
else
|
||||
cmd.add("/usr/lib/jvm/java-21-openj9-amd64/bin/java");
|
||||
cmd.add("java");
|
||||
|
||||
for(String param : dParams){
|
||||
cmd.add("-D" + param);
|
||||
}
|
||||
cmd.add("-Xshareclasses:nonfatal,name=" + directory.getName());
|
||||
cmd.add("-Xmx" + xmx);
|
||||
cmd.add("-Xshareclasses:nonfatal,name=" + directory.getName());
|
||||
cmd.addAll(OPENJ9_ARGS);
|
||||
if (!JAVA_8.contains(serverJar)) {
|
||||
cmd.add("--add-opens");
|
||||
cmd.add("java.base/jdk.internal.misc=ALL-UNNAMED");
|
||||
cmd.add("-XX:-CRIUSecProvider");
|
||||
}
|
||||
cmd.add("-jar");
|
||||
cmd.add("/binarys/" + serverJar);
|
||||
@ -124,18 +120,28 @@ public abstract class Node {
|
||||
cmd.add("nogui");
|
||||
}
|
||||
|
||||
protected void calcLoadLimit(BufferedReader meminfo) throws IOException {
|
||||
protected void calcLoadLimit(BufferedReader stat, BufferedReader meminfo) throws IOException {
|
||||
String[] cpuline = stat.readLine().split(" "); // 0-1: prefix, 2: user, 3: nice, 4: system, 5: idle, 6: iowait, 7: irq, 8: softirq, 9: steal, 10: guest, 11: guest_nice
|
||||
long cpuLoaded = Long.parseLong(cpuline[2]) + Long.parseLong(cpuline[4]) + Long.parseLong(cpuline[6]) + Long.parseLong(cpuline[7]) + Long.parseLong(cpuline[8]) + Long.parseLong(cpuline[9]) + Long.parseLong(cpuline[10]) + Long.parseLong(cpuline[11]);
|
||||
long cpuTotal = cpuLoaded + Long.parseLong(cpuline[3]) + Long.parseLong(cpuline[5]);
|
||||
|
||||
cpuLoaded -= previousCpuLoaded;
|
||||
cpuTotal -= previousCpuTotal;
|
||||
previousCpuLoaded += cpuLoaded;
|
||||
previousCpuTotal += cpuTotal;
|
||||
|
||||
String line = meminfo.readLine();
|
||||
while(!line.startsWith("MemAvailable")) {
|
||||
line = meminfo.readLine();
|
||||
}
|
||||
|
||||
long availableMem = Long.parseLong(line.replaceAll(" +", " ").split(" ")[1]);
|
||||
belowLoadLimit = availableMem >= MIN_FREE_MEM;
|
||||
belowLoadLimit = cpuLoaded / (double)cpuTotal <= MAX_LOAD && availableMem >= MIN_FREE_MEM;
|
||||
}
|
||||
|
||||
public static class LocalNode extends Node {
|
||||
private static final File MEMINFO = new File("/proc/meminfo");
|
||||
private static final File STAT = new File("/proc/stat");
|
||||
|
||||
public LocalNode() {
|
||||
super("sw");
|
||||
@ -152,10 +158,12 @@ public abstract class Node {
|
||||
|
||||
@Override
|
||||
protected void calcLoadLimit() {
|
||||
try (BufferedReader meminfo = new BufferedReader(new InputStreamReader(Files.newInputStream(MEMINFO.toPath())))) {
|
||||
calcLoadLimit(meminfo);
|
||||
try (BufferedReader loadavg = new BufferedReader(new InputStreamReader(new FileInputStream(STAT)))) {
|
||||
try (BufferedReader meminfo = new BufferedReader(new InputStreamReader(new FileInputStream(MEMINFO)))) {
|
||||
calcLoadLimit(loadavg, meminfo);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
VelocityCore.get().getLogger().log(Level.SEVERE, "Could not read local load", e);
|
||||
BungeeCore.get().getLogger().log(Level.SEVERE, "Could not read local load", e);
|
||||
belowLoadLimit = false;
|
||||
}
|
||||
}
|
||||
@ -170,7 +178,7 @@ public abstract class Node {
|
||||
|
||||
public RemoteNode(String hostname) {
|
||||
super(hostname);
|
||||
VelocityCore.get().getLogger().log(Level.INFO, "Added node " + hostname);
|
||||
BungeeCore.get().getLogger().log(Level.INFO, "Added node " + hostname);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -199,15 +207,17 @@ public abstract class Node {
|
||||
@Override
|
||||
protected void calcLoadLimit() {
|
||||
try {
|
||||
Process process = prepareExecution("cat /proc/meminfo").start();
|
||||
Process process = prepareExecution("cat /proc/stat /proc/meminfo").start();
|
||||
if(!process.waitFor(1, TimeUnit.SECONDS))
|
||||
throw new IOException(hostname + " timeout");
|
||||
try (BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()))) {
|
||||
calcLoadLimit(reader);
|
||||
if(reader == null)
|
||||
throw new IOException("Why reader null? " + process.getInputStream());
|
||||
calcLoadLimit(reader, reader);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
if(belowLoadLimit)
|
||||
VelocityCore.get().getLogger().log(Level.SEVERE, "Could read remote load", e);
|
||||
BungeeCore.get().getLogger().log(Level.SEVERE, "Could read remote load", e);
|
||||
belowLoadLimit = false;
|
||||
} catch (InterruptedException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
|
@ -1,11 +1,12 @@
|
||||
package de.steamwar.bungeecore;
|
||||
|
||||
import com.velocitypowered.api.proxy.Player;
|
||||
import de.steamwar.sql.EventFight;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import de.steamwar.sql.Team;
|
||||
import de.steamwar.sql.Tutorial;
|
||||
import de.steamwar.messages.ChatSender;
|
||||
import de.steamwar.sql.*;
|
||||
import lombok.Getter;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.InetSocketAddress;
|
||||
@ -13,14 +14,13 @@ import java.nio.file.Files;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
import java.util.function.BooleanSupplier;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class ServerStarter {
|
||||
|
||||
private static final Portrange BAU_PORTS = VelocityCore.MAIN_SERVER ? new Portrange(10100, 20000) : new Portrange(2100, 2200);
|
||||
private static final Portrange ARENA_PORTS = VelocityCore.MAIN_SERVER ? new Portrange(3000, 3100) : (VelocityCore.EVENT_MODE ? new Portrange(4000, 5000) : BAU_PORTS);
|
||||
private static final Portrange BAU_PORTS = BungeeCore.MAIN_SERVER ? new Portrange(10100, 20000) : new Portrange(2100, 2200);
|
||||
private static final Portrange ARENA_PORTS = BungeeCore.MAIN_SERVER ? new Portrange(3000, 3100) : (BungeeCore.EVENT_MODE ? new Portrange(4000, 5000) : BAU_PORTS);
|
||||
|
||||
private static final String SERVER_PATH = "/servers/";
|
||||
private static final String USER_HOME = System.getProperty("user.home") + "/";
|
||||
@ -46,11 +46,9 @@ public class ServerStarter {
|
||||
private boolean allowMerge = false;
|
||||
private String fightMap = null;
|
||||
private String gameMode = null;
|
||||
private boolean checkpoint = false;
|
||||
private ServerConstructor constructor = (serverName, port, builder, shutdownCallback, failureCallback) -> new Arenaserver(serverName, gameMode, fightMap, allowMerge, port, builder, shutdownCallback);
|
||||
private Consumer<Subserver> callback = subserver -> {};
|
||||
private ServerConstructor constructor = (serverName, port, builder, shutdownCallback) -> new Arenaserver(serverName, gameMode, fightMap, allowMerge, port, builder, shutdownCallback);
|
||||
|
||||
private final Set<Player> playersToSend = new HashSet<>();
|
||||
private final Set<ProxiedPlayer> playersToSend = new HashSet<>();
|
||||
private final Map<String, String> arguments = new HashMap<>();
|
||||
|
||||
public ServerStarter arena(ArenaMode mode, String map) {
|
||||
@ -68,7 +66,7 @@ public class ServerStarter {
|
||||
|
||||
public ServerStarter event(EventFight eventFight) {
|
||||
arena(ArenaMode.getByInternal(eventFight.getSpielmodus()), eventFight.getMap());
|
||||
node = Node.LocalNode.getNode();
|
||||
node = BungeeCore.local;
|
||||
worldDir = EVENT_PATH;
|
||||
worldCleanup = () -> {};
|
||||
arguments.put("fightID", String.valueOf(eventFight.getFightID()));
|
||||
@ -81,7 +79,7 @@ public class ServerStarter {
|
||||
return this;
|
||||
}
|
||||
|
||||
public ServerStarter test(ArenaMode mode, String map, Player owner) {
|
||||
public ServerStarter test(ArenaMode mode, String map, ProxiedPlayer owner) {
|
||||
arena(mode, map);
|
||||
buildWithTemp(owner);
|
||||
portrange = BAU_PORTS;
|
||||
@ -89,12 +87,12 @@ public class ServerStarter {
|
||||
return send(owner);
|
||||
}
|
||||
|
||||
public ServerStarter blueLeader(Player player) {
|
||||
public ServerStarter blueLeader(ProxiedPlayer player) {
|
||||
arguments.put("blueLeader", player.getUniqueId().toString());
|
||||
return send(player);
|
||||
}
|
||||
|
||||
public ServerStarter redLeader(Player player) {
|
||||
public ServerStarter redLeader(ProxiedPlayer player) {
|
||||
arguments.put("redLeader", player.getUniqueId().toString());
|
||||
return send(player);
|
||||
}
|
||||
@ -119,7 +117,6 @@ public class ServerStarter {
|
||||
serverJar = version.getServerJar();
|
||||
worldDir = version.getWorldFolder(WORLDS_BASE_PATH);
|
||||
worldName = version != Version.SPIGOT_12 ? String.valueOf(SteamwarUser.get(owner).getId()) : owner.toString();
|
||||
checkpoint = true;
|
||||
|
||||
build(owner);
|
||||
|
||||
@ -131,29 +128,20 @@ public class ServerStarter {
|
||||
|
||||
// Send players to existing server
|
||||
startCondition = () -> {
|
||||
Bauserver subserver = Bauserver.get(owner);
|
||||
if(subserver != null) {
|
||||
for(Player p : playersToSend)
|
||||
SubserverSystem.sendPlayer(subserver, p);
|
||||
return false;
|
||||
}
|
||||
boolean atLeastOneSupervisor = playersToSend.stream().anyMatch(player -> {
|
||||
if (player.getUniqueId().equals(owner)) return true;
|
||||
BauweltMember bauweltMember = BauweltMember.getBauMember(owner, player.getUniqueId());
|
||||
return bauweltMember.isSupervisor();
|
||||
});
|
||||
if (!atLeastOneSupervisor) {
|
||||
for (Player p : playersToSend) {
|
||||
ChatSender.of(p).system("BAU_START_NOT_ALLOWED");
|
||||
for(Subserver subserver : Subserver.getServerList()) {
|
||||
if(subserver.getType() == Servertype.BAUSERVER && ((Bauserver)subserver).getOwner().equals(owner)) {
|
||||
for(ProxiedPlayer p : playersToSend)
|
||||
SubserverSystem.sendPlayer(subserver, p);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return atLeastOneSupervisor;
|
||||
return true;
|
||||
};
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public ServerStarter tutorial(Player owner, Tutorial tutorial) {
|
||||
public ServerStarter tutorial(ProxiedPlayer owner, Tutorial tutorial) {
|
||||
directory = new File(SERVER_PATH, "Tutorial");
|
||||
buildWithTemp(owner);
|
||||
tempWorld(TUTORIAL_PATH + tutorial.getTutorialId());
|
||||
@ -167,7 +155,7 @@ public class ServerStarter {
|
||||
worldCleanup = () -> SubserverSystem.deleteFolder(node, worldDir + worldName);
|
||||
}
|
||||
|
||||
private void buildWithTemp(Player owner) {
|
||||
private void buildWithTemp(ProxiedPlayer owner) {
|
||||
build(owner.getUniqueId());
|
||||
|
||||
// Stop existing build server
|
||||
@ -175,16 +163,19 @@ public class ServerStarter {
|
||||
if(startingBau(owner))
|
||||
return false;
|
||||
|
||||
Bauserver subserver = Bauserver.get(owner.getUniqueId());
|
||||
if(subserver != null && subserver.isStarted())
|
||||
subserver.stop();
|
||||
for (Subserver subserver : Subserver.getServerList()) {
|
||||
if (subserver.getType() == Servertype.BAUSERVER && ((Bauserver) subserver).getOwner().equals(owner.getUniqueId()) && subserver.hasStarted()) {
|
||||
subserver.stop();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return !startingBau(owner);
|
||||
};
|
||||
}
|
||||
|
||||
private void build(UUID owner) {
|
||||
constructor = (serverName, port, builder, shutdownCallback, failureCallback) -> new Bauserver(serverName, owner, port, builder, shutdownCallback, failureCallback);
|
||||
constructor = (serverName, port, builder, shutdownCallback) -> new Bauserver(serverName, owner, port, builder, shutdownCallback);
|
||||
serverNameProvider = port -> bauServerName(SteamwarUser.get(owner));
|
||||
}
|
||||
|
||||
@ -194,16 +185,16 @@ public class ServerStarter {
|
||||
worldDir = version.getWorldFolder(BUILDER_BASE_PATH);
|
||||
worldName = map;
|
||||
serverNameProvider = port -> "⛏" + map;
|
||||
checkpoint = true;
|
||||
constructor = (serverName, port, builder, shutdownCallback, failureCallback) -> new Builderserver(serverName, worldName, port, builder, shutdownCallback, failureCallback);
|
||||
constructor = (serverName, port, builder, shutdownCallback) -> new Builderserver(serverName, worldName, port, builder, shutdownCallback);
|
||||
|
||||
// Send players to existing server
|
||||
startCondition = () -> {
|
||||
Builderserver subserver = Builderserver.get(worldName);
|
||||
if (subserver != null) {
|
||||
for(Player p : playersToSend)
|
||||
SubserverSystem.sendPlayer(subserver, p);
|
||||
return false;
|
||||
for(Subserver subserver : Subserver.getServerList()) {
|
||||
if(subserver.getType() == Servertype.BUILDER && ((Builderserver)subserver).getMap().equals(worldName)) {
|
||||
for(ProxiedPlayer p : playersToSend)
|
||||
SubserverSystem.sendPlayer(subserver, p);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
};
|
||||
@ -222,19 +213,14 @@ public class ServerStarter {
|
||||
return this;
|
||||
}
|
||||
|
||||
public ServerStarter send(Player player) {
|
||||
public ServerStarter send(ProxiedPlayer player) {
|
||||
playersToSend.add(player);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ServerStarter callback(Consumer<Subserver> callback) {
|
||||
this.callback = callback;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean start() {
|
||||
public Subserver start() {
|
||||
if(!startCondition.getAsBoolean())
|
||||
return false;
|
||||
return null;
|
||||
|
||||
int port = portrange.freePort();
|
||||
String serverName = serverNameProvider.apply(port);
|
||||
@ -242,10 +228,10 @@ public class ServerStarter {
|
||||
if(node == null) {
|
||||
node = Node.getNode();
|
||||
if(node == null) {
|
||||
for (Player p : playersToSend)
|
||||
for (ProxiedPlayer p : playersToSend)
|
||||
ChatSender.of(p).system("SERVER_START_OVERLOAD");
|
||||
|
||||
return false;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
if(worldName == null)
|
||||
@ -254,45 +240,22 @@ public class ServerStarter {
|
||||
worldSetup.run();
|
||||
arguments.put("logPath", worldName);
|
||||
|
||||
File checkpointDir = new File("/tmp/" + System.getProperty("user.name") + ".checkpoints/" + directory.getName() + "/" + worldName);
|
||||
if(checkpoint)
|
||||
arguments.put("checkpoint", checkpointDir.getPath());
|
||||
|
||||
if(checkpoint && checkpointDir.exists()) {
|
||||
try {
|
||||
new DataOutputStream(Files.newOutputStream(new File(checkpointDir, "port").toPath())).writeInt(port);
|
||||
} catch (IOException e) {
|
||||
throw new SecurityException(e);
|
||||
}
|
||||
|
||||
postStart(constructor.construct(serverName, port, node.prepareExecution(
|
||||
"criu", "restore", "-D", checkpointDir.getPath(), "--auto-dedup", "--shell-job", "-v"
|
||||
), worldCleanup, e -> regularStart(serverName, port)));
|
||||
} else {
|
||||
regularStart(serverName, port);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void regularStart(String serverName, int port) {
|
||||
postStart(constructor.construct(serverName, port, node.startServer(
|
||||
Subserver subserver = constructor.construct(serverName, port, node.startServer(
|
||||
serverJar, directory, worldDir, worldName, port, xmx, arguments.entrySet().stream().map(entry -> entry.getKey() + "=" + entry.getValue()).toArray(String[]::new)
|
||||
), worldCleanup, null));
|
||||
}
|
||||
), worldCleanup);
|
||||
|
||||
private void postStart(Subserver subserver) {
|
||||
for(Player p : playersToSend)
|
||||
for(ProxiedPlayer p : playersToSend)
|
||||
SubserverSystem.sendPlayer(subserver, p);
|
||||
|
||||
callback.accept(subserver);
|
||||
return subserver;
|
||||
}
|
||||
|
||||
private static boolean startingBau(Player p) {
|
||||
Bauserver subserver = Bauserver.get(p.getUniqueId());
|
||||
if(subserver != null && !subserver.isStarted()) {
|
||||
ChatSender.of(p).system("BAU_START_ALREADY");
|
||||
return true;
|
||||
private static boolean startingBau(ProxiedPlayer p) {
|
||||
for (Subserver subserver : Subserver.getServerList()) {
|
||||
if (subserver.getType() == Servertype.BAUSERVER && ((Bauserver) subserver).getOwner().equals(p.getUniqueId()) && !subserver.hasStarted()) {
|
||||
Message.send("BAU_START_ALREADY", p);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -310,7 +273,7 @@ public class ServerStarter {
|
||||
}
|
||||
|
||||
private interface ServerConstructor {
|
||||
Subserver construct(String serverName, int port, ProcessBuilder builder, Runnable shutdownCallback, Consumer<Exception> failureCallback);
|
||||
Subserver construct(String serverName, int port, ProcessBuilder builder, Runnable shutdownCallback);
|
||||
}
|
||||
|
||||
private static class Portrange {
|
||||
@ -349,7 +312,6 @@ public class ServerStarter {
|
||||
}
|
||||
}
|
||||
|
||||
@Getter
|
||||
public enum Version {
|
||||
SPIGOT_12("spigot-1.12.2.jar", 12),
|
||||
SPIGOT_15("spigot-1.15.2.jar", 15),
|
||||
@ -364,6 +326,14 @@ public class ServerStarter {
|
||||
this.versionSuffix = versionSuffix;
|
||||
}
|
||||
|
||||
public String getServerJar() {
|
||||
return serverJar;
|
||||
}
|
||||
|
||||
public int getVersionSuffix() {
|
||||
return versionSuffix;
|
||||
}
|
||||
|
||||
public String getWorldFolder(String base) {
|
||||
return base + versionSuffix + "/";
|
||||
}
|
||||
|
@ -19,13 +19,14 @@
|
||||
|
||||
package de.steamwar.bungeecore;
|
||||
|
||||
import com.velocitypowered.api.proxy.Player;
|
||||
import de.steamwar.bungeecore.network.NetworkSender;
|
||||
import de.steamwar.bungeecore.network.handlers.FightInfoHandler;
|
||||
import de.steamwar.sql.IgnoreSystem;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import de.steamwar.network.packets.server.StartingServerPacket;
|
||||
import net.kyori.adventure.text.event.ClickEvent;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
import net.md_5.bungee.api.chat.ClickEvent;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@ -36,26 +37,23 @@ public class SubserverSystem {
|
||||
node.execute("rm", "-r", worldName);
|
||||
}
|
||||
|
||||
public static void sendDeniedMessage(Player p, UUID owner){
|
||||
Player o = VelocityCore.get().getProxyServer().getPlayer(owner).orElse(null);
|
||||
|
||||
if(o == null){
|
||||
public static void sendDeniedMessage(ProxiedPlayer p, UUID owner){
|
||||
ProxiedPlayer o = ProxyServer.getInstance().getPlayer(owner);
|
||||
if(o == null)
|
||||
return;
|
||||
}
|
||||
|
||||
if(IgnoreSystem.isIgnored(owner, p.getUniqueId())){
|
||||
Message.send("SERVER_IGNORED", p);
|
||||
return;
|
||||
}
|
||||
|
||||
Message.send("SERVER_ADD_MEMBER", o, p.getUsername());
|
||||
Message.sendPrefixless("SERVER_ADD_MESSAGE", o, Message.parse("SERVER_ADD_MESSAGE_HOVER", o, p.getUsername()),
|
||||
ClickEvent.runCommand("/bau addmember " + p.getUsername()));
|
||||
Message.send("SERVER_ADD_MEMBER", o, p.getName());
|
||||
Message.sendPrefixless("SERVER_ADD_MESSAGE", o, Message.parse("SERVER_ADD_MESSAGE_HOVER", o, p.getName()),
|
||||
new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/bau addmember " + p.getName()));
|
||||
}
|
||||
|
||||
public static void sendPlayer(Subserver subserver, Player player) {
|
||||
public static void sendPlayer(Subserver subserver, ProxiedPlayer player) {
|
||||
subserver.sendPlayer(player);
|
||||
if(!subserver.isStarted() && FightInfoHandler.onLobby(player))
|
||||
if(!subserver.hasStarted() && FightInfoHandler.onLobby(player))
|
||||
NetworkSender.send(player, new StartingServerPacket(SteamwarUser.get(player.getUniqueId()).getId()));
|
||||
}
|
||||
}
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
package de.steamwar.bungeecore.bot;
|
||||
|
||||
import de.steamwar.bungeecore.VelocityCore;
|
||||
import de.steamwar.bungeecore.BungeeCore;
|
||||
import de.steamwar.bungeecore.bot.config.SteamwarDiscordBotConfig;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import net.dv8tion.jda.api.MessageBuilder;
|
||||
@ -46,8 +46,8 @@ public class AuthManager {
|
||||
String code = Base64.getEncoder().encodeToString(randBytes);
|
||||
|
||||
TOKENS.put(code, member.getIdLong());
|
||||
VelocityCore.log("Created Discord Auth-Token: " + code + " for: " + member.getUser().getAsTag());
|
||||
VelocityCore.get().getProxy().getScheduler().schedule(VelocityCore.get(), () -> TOKENS.remove(code), 10, TimeUnit.MINUTES);
|
||||
BungeeCore.log("Created Discord Auth-Token: " + code + " for: " + member.getUser().getAsTag());
|
||||
BungeeCore.get().getProxy().getScheduler().schedule(BungeeCore.get(), () -> TOKENS.remove(code), 10, TimeUnit.MINUTES);
|
||||
return code;
|
||||
}
|
||||
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
package de.steamwar.bungeecore.bot;
|
||||
|
||||
import de.steamwar.bungeecore.VelocityCore;
|
||||
import de.steamwar.bungeecore.BungeeCore;
|
||||
import de.steamwar.bungeecore.bot.commands.*;
|
||||
import de.steamwar.bungeecore.bot.config.SteamwarDiscordBotConfig;
|
||||
import de.steamwar.bungeecore.bot.events.EventManager;
|
||||
@ -81,7 +81,7 @@ public class SteamwarDiscordBot {
|
||||
} catch (LoginException e) {
|
||||
throw new SecurityException("Could not Login: " + SteamwarDiscordBotConfig.TOKEN, e);
|
||||
}
|
||||
ProxyServer.getInstance().getScheduler().runAsync(VelocityCore.get(), () -> {
|
||||
ProxyServer.getInstance().getScheduler().runAsync(BungeeCore.get(), () -> {
|
||||
try {
|
||||
jda.awaitReady();
|
||||
} catch (InterruptedException e) {
|
||||
@ -90,11 +90,11 @@ public class SteamwarDiscordBot {
|
||||
try {
|
||||
activity();
|
||||
} catch (Exception e) {
|
||||
VelocityCore.get().getLogger().log(Level.SEVERE, "Could not set initial activity to discord", e);
|
||||
BungeeCore.get().getLogger().log(Level.SEVERE, "Could not set initial activity to discord", e);
|
||||
}
|
||||
EventManager.update();
|
||||
SchematicsManager.update();
|
||||
ProxyServer.getInstance().getScheduler().schedule(VelocityCore.get(), () -> {
|
||||
ProxyServer.getInstance().getScheduler().schedule(BungeeCore.get(), () -> {
|
||||
try {
|
||||
activity();
|
||||
EventManager.update();
|
||||
@ -148,7 +148,7 @@ public class SteamwarDiscordBot {
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
int count = VelocityCore.get().getProxy().getOnlineCount();
|
||||
int count = BungeeCore.get().getProxy().getOnlineCount();
|
||||
if (count == 1) {
|
||||
jda.getPresence().setActivity(Activity.playing("mit 1 Spieler"));
|
||||
} else {
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
package de.steamwar.bungeecore.bot.listeners;
|
||||
|
||||
import de.steamwar.bungeecore.VelocityCore;
|
||||
import de.steamwar.bungeecore.BungeeCore;
|
||||
import de.steamwar.bungeecore.Message;
|
||||
import de.steamwar.bungeecore.bot.config.DiscordTicketType;
|
||||
import de.steamwar.bungeecore.bot.config.SteamwarDiscordBotConfig;
|
||||
@ -137,7 +137,7 @@ public class DiscordTicketListener extends BasicDiscordListener {
|
||||
public void onGuildMessageReceived(@NotNull GuildMessageReceivedEvent event) {
|
||||
if(event.getChannel().getParent() != null && event.getChannel().getParent().getId().equals(SteamwarDiscordBotConfig.TICKET_CATEGORY)) {
|
||||
if(!event.getChannel().getId().equals(SteamwarDiscordBotConfig.TICKET_CHANNEL) && !event.getChannel().getId().equals(SteamwarDiscordBotConfig.TICKET_LOG)) {
|
||||
VelocityCore.get().getProxy().getPlayers().forEach(player -> {
|
||||
BungeeCore.get().getProxy().getPlayers().forEach(player -> {
|
||||
if(event.getAuthor().isBot() || event.getAuthor().isSystem()) return;
|
||||
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
||||
boolean sendMessage;
|
||||
|
@ -18,7 +18,7 @@
|
||||
|
||||
package de.steamwar.bungeecore.bot.listeners;
|
||||
|
||||
import de.steamwar.bungeecore.VelocityCore;
|
||||
import de.steamwar.bungeecore.BungeeCore;
|
||||
import de.steamwar.sql.NodeData;
|
||||
import de.steamwar.sql.Punishment;
|
||||
import de.steamwar.sql.SchematicNode;
|
||||
@ -72,7 +72,7 @@ public class PrivateMessageListener extends BasicDiscordListener {
|
||||
event.getMessage().reply("`" + name + "` wurde erfolgreich hochgeladen").queue();
|
||||
} catch (Exception e) {
|
||||
event.getMessage().reply("`" + name + "` konnte nicht hochgeladen werden, bitte versuche es später nochmal oder wende dich an einen Developer").queue();
|
||||
VelocityCore.log("Could not Upload Schem \"" + name + "\" from User \"" + user.getUserName() + "\"", e);
|
||||
BungeeCore.log("Could not Upload Schem \"" + name + "\" from User \"" + user.getUserName() + "\"", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -68,17 +68,17 @@ public class BauCommand extends SWCommand {
|
||||
Map<String, ServerStarter.Version> versionMap = new HashMap<>();
|
||||
versionMap.put("20", ServerStarter.Version.PAPER_20);
|
||||
versionMap.put("1.20", ServerStarter.Version.PAPER_20);
|
||||
versionMap.put("as", ServerStarter.Version.PAPER_20);
|
||||
versionMap.put("airship", ServerStarter.Version.PAPER_20);
|
||||
versionMap.put("wg", ServerStarter.Version.PAPER_20);
|
||||
versionMap.put("wargear", ServerStarter.Version.PAPER_20);
|
||||
versionMap.put("ws", ServerStarter.Version.PAPER_20);
|
||||
versionMap.put("warship", ServerStarter.Version.PAPER_20);
|
||||
|
||||
versionMap.put("19", ServerStarter.Version.PAPER_19);
|
||||
versionMap.put("1.19", ServerStarter.Version.PAPER_19);
|
||||
versionMap.put("mwg", ServerStarter.Version.PAPER_19);
|
||||
versionMap.put("miniwargear", ServerStarter.Version.PAPER_19);
|
||||
versionMap.put("wg", ServerStarter.Version.PAPER_19);
|
||||
versionMap.put("wargear", ServerStarter.Version.PAPER_19);
|
||||
versionMap.put("ws", ServerStarter.Version.PAPER_19);
|
||||
versionMap.put("warship", ServerStarter.Version.PAPER_19);
|
||||
versionMap.put("as", ServerStarter.Version.PAPER_19);
|
||||
versionMap.put("airship", ServerStarter.Version.PAPER_19);
|
||||
|
||||
versionMap.put("15", ServerStarter.Version.SPIGOT_15);
|
||||
versionMap.put("1.15", ServerStarter.Version.SPIGOT_15);
|
||||
@ -161,7 +161,11 @@ public class BauCommand extends SWCommand {
|
||||
messageSender.send("BAU_TP_NOALLOWED");
|
||||
return false;
|
||||
}
|
||||
return !BauLock.checkNotifyLocked(value, p);
|
||||
if(BauLock.isLocked(value, SteamwarUser.get(p.getUniqueId()))) {
|
||||
messageSender.send("BAU_LOCKED_NOALLOWED");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
}
|
||||
|
||||
@ -170,52 +174,52 @@ public class BauCommand extends SWCommand {
|
||||
Chat19.chat(p, "/bauinfo");
|
||||
}
|
||||
|
||||
@Register("setspectator")
|
||||
public void setSpectator(ProxiedPlayer p, @Mapper("addedUsers") @AllowNull @OptionalValue("") SteamwarUser user) {
|
||||
@Register("togglewe")
|
||||
public void togglewe(ProxiedPlayer p, @Mapper("addedUsers") @AllowNull @OptionalValue("") SteamwarUser user) {
|
||||
if (user == null) {
|
||||
Message.send("BAU_MEMBER_SET_USAGE", p, "setspectator");
|
||||
Message.send("BAU_MEMBER_TOGGLE_USAGE", p, "togglewe");
|
||||
return;
|
||||
}
|
||||
BauweltMember target = member(p, user);
|
||||
if (target == null)
|
||||
return;
|
||||
|
||||
target.setBuild(false);
|
||||
target.setSupervisor(false);
|
||||
target.setWorldEdit(!target.isWorldEdit());
|
||||
clearMembercache(p);
|
||||
sendPermissionUpdate(p, target, "BAU_MEMBER_SET_SPECTATOR");
|
||||
isAllowedTo(target.isWorldEdit(), p, target, "BAU_MEMBER_TOGGLE_WORLD_EDIT");
|
||||
}
|
||||
|
||||
@Register("setbuild")
|
||||
public void setBuild(ProxiedPlayer p, @Mapper("addedUsers") @AllowNull @OptionalValue("") SteamwarUser user) {
|
||||
@Register("toggleworld")
|
||||
public void toggleworld(ProxiedPlayer p, @Mapper("addedUsers") @AllowNull @OptionalValue("") SteamwarUser user) {
|
||||
if (user == null) {
|
||||
Message.send("BAU_MEMBER_SET_USAGE", p, "setbuild");
|
||||
Message.send("BAU_MEMBER_TOGGLE_USAGE", p, "toggleworld");
|
||||
return;
|
||||
}
|
||||
BauweltMember target = member(p, user);
|
||||
if (target == null)
|
||||
return;
|
||||
|
||||
target.setBuild(true);
|
||||
target.setSupervisor(false);
|
||||
target.setWorld(!target.isWorld());
|
||||
clearMembercache(p);
|
||||
sendPermissionUpdate(p, target, "BAU_MEMBER_SET_BUILDER");
|
||||
isAllowedTo(target.isWorld(), p, target, "BAU_MEMBER_TOGGLE_WORLD");
|
||||
}
|
||||
|
||||
@Register("setsupervisor")
|
||||
public void setSupervisor(ProxiedPlayer p, @Mapper("addedUsers") @AllowNull @OptionalValue("") SteamwarUser user) {
|
||||
@Register("toggleall")
|
||||
public void toggleall(ProxiedPlayer p, @Mapper("addedUsers") @AllowNull @OptionalValue("") SteamwarUser user) {
|
||||
if (user == null) {
|
||||
Message.send("BAU_MEMBER_SET_USAGE", p, "setsupervisor");
|
||||
Message.send("BAU_MEMBER_TOGGLE_USAGE", p, "toggleall");
|
||||
return;
|
||||
}
|
||||
BauweltMember target = member(p, user);
|
||||
if (target == null)
|
||||
return;
|
||||
|
||||
target.setBuild(true);
|
||||
target.setSupervisor(true);
|
||||
boolean state = !target.isWorldEdit() || !target.isWorld();
|
||||
target.setWorldEdit(state);
|
||||
target.setWorld(state);
|
||||
clearMembercache(p);
|
||||
sendPermissionUpdate(p, target, "BAU_MEMBER_SET_SUPERVISOR");
|
||||
isAllowedTo(target.isWorldEdit(), p, target, "BAU_MEMBER_TOGGLE_WORLD_EDIT");
|
||||
isAllowedTo(target.isWorld(), p, target, "BAU_MEMBER_TOGGLE_WORLD");
|
||||
}
|
||||
|
||||
private static void clearMembercache(ProxiedPlayer p){
|
||||
@ -245,7 +249,7 @@ public class BauCommand extends SWCommand {
|
||||
Message.send("BAU_DELMEMBER_DELETED_TARGET", toRemove, p.getName());
|
||||
Subserver currentServer = Subserver.getSubserver(toRemove.getServer().getInfo());
|
||||
if (currentServer != null && currentServer.getType() == Servertype.BAUSERVER && ((Bauserver) currentServer).getOwner().equals(p.getUniqueId())) {
|
||||
toRemove.connect(ProxyServer.getInstance().getServerInfo(VelocityCore.LOBBY_SERVER));
|
||||
toRemove.connect(ProxyServer.getInstance().getServerInfo(BungeeCore.LOBBY_SERVER));
|
||||
}
|
||||
}
|
||||
Message.send("BAU_DELMEMBER_DELETED", p);
|
||||
@ -289,12 +293,14 @@ public class BauCommand extends SWCommand {
|
||||
}
|
||||
|
||||
private static void deleteWorld(ProxiedPlayer player, String world) {
|
||||
ProxyServer.getInstance().getScheduler().runAsync(VelocityCore.get(), () -> {
|
||||
Bauserver subserver = Bauserver.get(player.getUniqueId());
|
||||
if(subserver != null)
|
||||
subserver.stop();
|
||||
|
||||
SubserverSystem.deleteFolder(VelocityCore.local, world);
|
||||
ProxyServer.getInstance().getScheduler().runAsync(BungeeCore.get(), () -> {
|
||||
for (Subserver subserver : Subserver.getServerList()) {
|
||||
if (subserver.getType() == Servertype.BAUSERVER && ((Bauserver) subserver).getOwner().equals(player.getUniqueId())) {
|
||||
subserver.stop();
|
||||
break;
|
||||
}
|
||||
}
|
||||
SubserverSystem.deleteFolder(BungeeCore.local, world);
|
||||
Message.send("BAU_DELETE_DELETED", player);
|
||||
});
|
||||
}
|
||||
@ -303,7 +309,7 @@ public class BauCommand extends SWCommand {
|
||||
@Register("testarena")
|
||||
public void testarena(ProxiedPlayer p, @Mapper("nonHistoricArenaMode") @OptionalValue("") @AllowNull ArenaMode arenaMode, @Mapper("arenaMap") @OptionalValue("") @AllowNull String map) {
|
||||
FightCommand.createArena(p, "/bau testarena ", false, arenaMode, map, false, (player, mode, m) -> {
|
||||
ProxyServer.getInstance().getScheduler().runAsync(VelocityCore.get(), () -> new ServerStarter().test(mode, m, p).start());
|
||||
ProxyServer.getInstance().getScheduler().runAsync(BungeeCore.get(), () -> new ServerStarter().test(mode, m, p).start());
|
||||
});
|
||||
}
|
||||
|
||||
@ -331,10 +337,17 @@ public class BauCommand extends SWCommand {
|
||||
return target;
|
||||
}
|
||||
|
||||
private static void sendPermissionUpdate(ProxiedPlayer p, BauweltMember target, String what){
|
||||
private static void isAllowedTo(boolean permission, ProxiedPlayer p, BauweltMember target, String what){
|
||||
ProxiedPlayer player = ProxyServer.getInstance().getPlayer(SteamwarUser.get(target.getMemberID()).getUUID());
|
||||
if(player != null)
|
||||
Message.send("BAU_MEMBER_SET_TARGET", player, p.getName(), Message.parse(what, player));
|
||||
Message.send("BAU_MEMBER_SET", p, Message.parse(what, p));
|
||||
|
||||
if(permission){
|
||||
if(player != null)
|
||||
Message.send("BAU_MEMBER_TOGGLE_TARGET", player, p.getName(), Message.parse(what, player));
|
||||
Message.send("BAU_MEMBER_TOGGLE", p, Message.parse(what, p));
|
||||
}else{
|
||||
if(player != null)
|
||||
Message.send("BAU_MEMBER_TOGGLE_TARGET_OFF", player, p.getName(), Message.parse(what, player));
|
||||
Message.send("BAU_MEMBER_TOGGLE_OFF", p, Message.parse(what, p));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
package de.steamwar.bungeecore.commands;
|
||||
|
||||
import de.steamwar.bungeecore.ArenaMode;
|
||||
import de.steamwar.bungeecore.VelocityCore;
|
||||
import de.steamwar.bungeecore.BungeeCore;
|
||||
import de.steamwar.bungeecore.ServerStarter;
|
||||
import de.steamwar.bungeecore.listeners.ConnectionListener;
|
||||
import de.steamwar.command.SWCommand;
|
||||
@ -81,8 +81,8 @@ public class BuilderCloudCommand extends SWCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
ProxyServer.getInstance().getScheduler().runAsync(VelocityCore.get(), () -> {
|
||||
VelocityCore.local.execute("/binarys/deployarena.py", arenaMode.getConfig(), Integer.toString(version.getVersionSuffix()), map);
|
||||
ProxyServer.getInstance().getScheduler().runAsync(BungeeCore.get(), () -> {
|
||||
BungeeCore.local.execute("/binarys/deployarena.py", arenaMode.getConfig(), Integer.toString(version.getVersionSuffix()), map);
|
||||
ArenaMode.init();
|
||||
ChatSender.of(player).system("BUILDERCLOUD_DEPLOY_FINISHED");
|
||||
});
|
||||
|
@ -43,9 +43,11 @@ public class ChallengeCommand extends SWCommand {
|
||||
challenges.remove(target);
|
||||
challenges.remove(p);
|
||||
|
||||
new ServerStarter().arena(mode, map).blueLeader(player).redLeader(target).callback(
|
||||
arena -> Message.broadcast("CHALLENGE_BROADCAST", "CHALLENGE_BROADCAST_HOVER", new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/arena " + arena.getServer().getName()), mode.getDisplayName(), p.getName(), target.getName())
|
||||
).start();
|
||||
Subserver arena = new ServerStarter().arena(mode, map).blueLeader(player).redLeader(target).start();
|
||||
if(arena != null) {
|
||||
Message.broadcast("CHALLENGE_BROADCAST", "CHALLENGE_BROADCAST_HOVER",
|
||||
new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/arena " + arena.getServer().getName()), mode.getDisplayName(), p.getName(), target.getName());
|
||||
}
|
||||
}else{
|
||||
if(!challenges.containsKey(p)){
|
||||
challenges.put(p, new LinkedList<>());
|
||||
|
@ -19,14 +19,17 @@
|
||||
|
||||
package de.steamwar.bungeecore.commands;
|
||||
|
||||
import com.velocitypowered.api.proxy.Player;
|
||||
import de.steamwar.bungeecore.*;
|
||||
import de.steamwar.bungeecore.bot.util.DiscordSchemAlert;
|
||||
import de.steamwar.bungeecore.listeners.ConnectionListener;
|
||||
import de.steamwar.sql.*;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import net.kyori.adventure.text.event.ClickEvent;
|
||||
import org.simpleyaml.configuration.Configuration;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
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.time.Instant;
|
||||
@ -52,27 +55,27 @@ public class CheckCommand extends SWCommand {
|
||||
fightTypes.put(checkType, fightType);
|
||||
}
|
||||
|
||||
public static boolean isChecking(Player player){
|
||||
public static boolean isChecking(ProxiedPlayer player){
|
||||
return currentCheckers.containsKey(player.getUniqueId());
|
||||
}
|
||||
|
||||
public static SchematicNode getCheckingSchem(Player player) {
|
||||
public static SchematicNode getCheckingSchem(ProxiedPlayer player) {
|
||||
return currentCheckers.get(player.getUniqueId()).schematic;
|
||||
}
|
||||
|
||||
public CheckCommand() {
|
||||
super("check", ConnectionListener.CHECK_PERMISSION);
|
||||
|
||||
VelocityCore.get().getProxyServer().getScheduler().buildTask(VelocityCore.get(), () -> {
|
||||
ProxyServer.getInstance().getScheduler().schedule(BungeeCore.get(), () -> {
|
||||
List<SchematicNode> schematics = getSchemsToCheck();
|
||||
if(schematics.size() != currentCheckers.size())
|
||||
Message.team("CHECK_REMINDER", "CHECK_REMINDER_HOVER", ClickEvent.runCommand("/check list"), schematics.size() - currentCheckers.size());
|
||||
}).repeat(10, TimeUnit.MINUTES).schedule();
|
||||
Message.team("CHECK_REMINDER", "CHECK_REMINDER_HOVER", new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/check list"), schematics.size() - currentCheckers.size());
|
||||
}, 10, 10, TimeUnit.MINUTES);
|
||||
}
|
||||
public static void sendReminder(Player player) {
|
||||
public static void sendReminder(ProxiedPlayer player) {
|
||||
List<SchematicNode> schematics = getSchemsToCheck();
|
||||
if(schematics.size() != currentCheckers.size())
|
||||
Message.send("CHECK_REMINDER", player, Message.parse("CHECK_REMINDER_HOVER", player), ClickEvent.runCommand("/check list"), 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());
|
||||
}
|
||||
|
||||
@Register(value = "list", description = "CHECK_HELP_LIST")
|
||||
@ -217,9 +220,9 @@ public class CheckCommand extends SWCommand {
|
||||
this.startTime = Timestamp.from(Instant.now());
|
||||
this.checkList = checkQuestions.get(schematic.getSchemtype()).listIterator();
|
||||
|
||||
ProxyServer.getInstance().getScheduler().runAsync(VelocityCore.get(), () -> {
|
||||
ProxyServer.getInstance().getScheduler().runAsync(BungeeCore.get(), () -> {
|
||||
ArenaMode mode = ArenaMode.getBySchemType(fightTypes.get(schematic.getSchemtype()));
|
||||
if(!new ServerStarter().test(mode, mode.getRandomMap(), checker).check(schematic.getId()).start()) {
|
||||
if(new ServerStarter().test(mode, mode.getRandomMap(), checker).check(schematic.getId()).start() == null) {
|
||||
remove();
|
||||
return;
|
||||
}
|
||||
@ -314,10 +317,13 @@ public class CheckCommand extends SWCommand {
|
||||
private void stop(){
|
||||
currentCheckers.remove(checker.getUniqueId());
|
||||
currentSchems.remove(schematic.getId());
|
||||
ProxyServer.getInstance().getScheduler().runAsync(VelocityCore.get(), () -> {
|
||||
Bauserver subserver = Bauserver.get(checker.getUniqueId());
|
||||
if(subserver != null)
|
||||
subserver.stop();
|
||||
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;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -107,7 +107,7 @@ public class EventCommand extends SWCommand {
|
||||
}
|
||||
}
|
||||
|
||||
VelocityCore.send(player, fline.toString());
|
||||
BungeeCore.send(player, fline.toString());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -159,11 +159,13 @@ public class FightCommand extends SWCommand {
|
||||
|
||||
@Register
|
||||
public void fight(@Validator("arenaPlayer") ProxiedPlayer player, @Mapper("nonHistoricArenaMode") @OptionalValue("") @AllowNull ArenaMode arenaMode, @Mapper("arenaMap") @OptionalValue("") @AllowNull String map) {
|
||||
createArena(player, "/fight ", true, arenaMode, map, false,
|
||||
(p, mode, m) -> new ServerStarter().arena(mode, m).blueLeader(p).callback(
|
||||
arena -> Message.broadcast("FIGHT_BROADCAST", "FIGHT_BROADCAST_HOVER", new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/arena " + arena.getServer().getName()), mode.getDisplayName(), p.getName())
|
||||
).start()
|
||||
);
|
||||
createArena(player, "/fight ", true, arenaMode, map, false, (p, mode, m) -> {
|
||||
Subserver arena = new ServerStarter().arena(mode, m).blueLeader(p).start();
|
||||
if(arena != null) {
|
||||
Message.broadcast("FIGHT_BROADCAST", "FIGHT_BROADCAST_HOVER"
|
||||
, new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/arena " + arena.getServer().getName()), mode.getDisplayName(), p.getName());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,6 +1,6 @@
|
||||
package de.steamwar.bungeecore.commands;
|
||||
|
||||
import de.steamwar.bungeecore.VelocityCore;
|
||||
import de.steamwar.bungeecore.BungeeCore;
|
||||
import de.steamwar.bungeecore.Message;
|
||||
import de.steamwar.sql.internal.Statement;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
@ -31,7 +31,7 @@ public class GDPRQuery extends SWCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
BungeeCord.getInstance().getScheduler().runAsync(VelocityCore.get(), () -> {
|
||||
BungeeCord.getInstance().getScheduler().runAsync(BungeeCore.get(), () -> {
|
||||
try {
|
||||
createZip(player, user);
|
||||
} catch (IOException e) {
|
||||
|
@ -91,9 +91,9 @@ public class HelpCommand extends SWCommand {
|
||||
"HELP_BAU_TP", "/build tp ",
|
||||
"HELP_BAU_ADDMEMBER", "/build addmember ",
|
||||
"HELP_BAU_DELMEMBER", "/build delmember ",
|
||||
"HELP_BAU_SET_SPECTATOR", "/build setSpectator ",
|
||||
"HELP_BAU_SET_BUILDER", "/build setBuilder ",
|
||||
"HELP_BAU_SET_SUPERVISOR", "/build setSupervisor ",
|
||||
"HELP_BAU_TOGGLEWE", "/build togglewe ",
|
||||
"HELP_BAU_TOGGLEWORLD", "/build toggleworld ",
|
||||
"HELP_BAU_TOGGLEALL", "/build toggleall ",
|
||||
"HELP_BAU_DELETE", "/build delete ",
|
||||
"HELP_BAU_TESTARENA", "/build testarena ",
|
||||
"HELP_BAU_LOCK", "/build lock ",
|
||||
|
@ -22,6 +22,7 @@ package de.steamwar.bungeecore.commands;
|
||||
import de.steamwar.bungeecore.ArenaMode;
|
||||
import de.steamwar.bungeecore.Message;
|
||||
import de.steamwar.bungeecore.ServerStarter;
|
||||
import de.steamwar.bungeecore.Subserver;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import net.md_5.bungee.api.chat.ClickEvent;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
@ -34,9 +35,11 @@ public class HistoricCommand extends SWCommand {
|
||||
@Register
|
||||
public void historic(@Validator("arenaPlayer") ProxiedPlayer player, @Mapper("historicArenaMode") @OptionalValue("") @AllowNull ArenaMode arenaMode, @Mapper("arenaMap") @OptionalValue("") @AllowNull String map) {
|
||||
FightCommand.createArena(player, "/historic ", true, arenaMode, map, true, (p, mode, m) -> {
|
||||
new ServerStarter().arena(mode, m).blueLeader(p).callback(
|
||||
arena -> Message.broadcast("HISTORIC_BROADCAST", "HISTORIC_BROADCAST_HOVER", new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/arena " + arena.getServer().getName()), mode.getDisplayName(), p.getName())
|
||||
).start();
|
||||
Subserver arena = new ServerStarter().arena(mode, m).blueLeader(p).start();
|
||||
if(arena != null) {
|
||||
Message.broadcast("HISTORIC_BROADCAST", "HISTORIC_BROADCAST_HOVER",
|
||||
new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/arena " + arena.getServer().getName()), mode.getDisplayName(), p.getName());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
package de.steamwar.bungeecore.commands;
|
||||
|
||||
import de.steamwar.bungeecore.VelocityCore;
|
||||
import de.steamwar.bungeecore.BungeeCore;
|
||||
import de.steamwar.bungeecore.Message;
|
||||
import de.steamwar.bungeecore.listeners.ConnectionListener;
|
||||
import de.steamwar.command.SWCommand;
|
||||
@ -37,7 +37,7 @@ public class KickCommand extends SWCommand {
|
||||
if (message.length == 0) {
|
||||
target.disconnect(Message.parseToComponent("KICK_NORMAL", true, target));
|
||||
} else {
|
||||
target.disconnect(VelocityCore.stringToText(VelocityCore.CHAT_PREFIX + "§c" + String.join(" ", message)));
|
||||
target.disconnect(BungeeCore.stringToText(BungeeCore.CHAT_PREFIX + "§c" + String.join(" ", message)));
|
||||
}
|
||||
Message.send("KICK_CONFIRM", sender, target.getName());
|
||||
}
|
||||
|
@ -20,10 +20,9 @@
|
||||
package de.steamwar.bungeecore.commands;
|
||||
|
||||
import com.google.gson.JsonParser;
|
||||
import de.steamwar.bungeecore.VelocityCore;
|
||||
import de.steamwar.bungeecore.BungeeCore;
|
||||
import de.steamwar.bungeecore.Message;
|
||||
import de.steamwar.bungeecore.listeners.ConnectionListener;
|
||||
import de.steamwar.bungeecore.listeners.IPSanitizer;
|
||||
import de.steamwar.command.PreviousArguments;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.command.TypeMapper;
|
||||
@ -78,7 +77,7 @@ public class PunishmentCommand {
|
||||
} catch (NoSuchElementException e) {
|
||||
// ignore, player does not exist
|
||||
} catch (IOException e) {
|
||||
VelocityCore.get().getLogger().log(Level.SEVERE, "Could not get offline player UUID " + playerName, e);
|
||||
BungeeCore.get().getLogger().log(Level.SEVERE, "Could not get offline player UUID " + playerName, e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@ -97,15 +96,14 @@ public class PunishmentCommand {
|
||||
|
||||
ProxiedPlayer player = ProxyServer.getInstance().getPlayer(user.getUUID());
|
||||
if (player != null) {
|
||||
String ip = IPSanitizer.getTrueAddress(player.getPendingConnection()).getHostAddress();
|
||||
ChatSender.disconnect(player).system(punishmentMessage(user, Punishment.PunishmentType.Ban));
|
||||
for (BannedUserIPs banned : BannedUserIPs.get(ip)) {
|
||||
for (BannedUserIPs banned : BannedUserIPs.get(player.getAddress().getAddress().getHostAddress())) {
|
||||
SteamwarUser bannedUser = SteamwarUser.get(banned.getUserID());
|
||||
if (bannedUser.isPunished(Punishment.PunishmentType.Ban) && bannedUser.getPunishment(Punishment.PunishmentType.Ban).getEndTime().before(time)) {
|
||||
bannedUser.punish(Punishment.PunishmentType.Ban, time, banReason, punisher.getId(), perma);
|
||||
}
|
||||
}
|
||||
BannedUserIPs.banIP(user.getId(), ip);
|
||||
BannedUserIPs.banIP(user.getId(), player.getAddress().getAddress().getHostAddress());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -32,7 +32,9 @@ 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.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
public class TpCommand extends SWCommand {
|
||||
|
||||
@ -63,7 +65,7 @@ public class TpCommand extends SWCommand {
|
||||
}
|
||||
|
||||
@Mapper("to")
|
||||
@Cached(cacheDuration = 10)
|
||||
@Cached(cacheDuration = 10, global = true)
|
||||
public TypeMapper<String> tabCompleter() {
|
||||
return new TypeMapper<String>() {
|
||||
@Override
|
||||
@ -84,11 +86,6 @@ public class TpCommand extends SWCommand {
|
||||
list.add(team.getTeamKuerzel());
|
||||
});
|
||||
}
|
||||
if (Storage.teamServers.containsValue(((ProxiedPlayer) sender).getServer().getInfo())) {
|
||||
Storage.directTabItems.getOrDefault((ProxiedPlayer) sender, Collections.emptyMap()).forEach((uuid, item) -> {
|
||||
list.add(item.getUsername());
|
||||
});
|
||||
}
|
||||
return list;
|
||||
}
|
||||
};
|
||||
@ -121,7 +118,8 @@ public class TpCommand extends SWCommand {
|
||||
sender.system("JOIN_PLAYER_BLOCK");
|
||||
return;
|
||||
}
|
||||
} else if (BauLock.checkNotifyLocked(SteamwarUser.get(bauserver.getOwner()), player)) {
|
||||
} else if (BauLock.isLocked(SteamwarUser.get(bauserver.getOwner()), sender.user())) {
|
||||
sender.system("BAU_LOCKED_NOALLOWED");
|
||||
return;
|
||||
} else if (!bauserver.getOwner().equals(player.getUniqueId()) && BauweltMember.getBauMember(bauserver.getOwner(), player.getUniqueId()) == null) {
|
||||
SubserverSystem.sendDeniedMessage(player, bauserver.getOwner());
|
||||
|
@ -100,7 +100,7 @@ public class TutorialCommand extends SWCommand {
|
||||
return;
|
||||
} else if(own && click.isShiftClick() && click.isRightClick()) {
|
||||
tutorial.delete();
|
||||
SubserverSystem.deleteFolder(VelocityCore.local, world(tutorial).getPath());
|
||||
SubserverSystem.deleteFolder(BungeeCore.local, world(tutorial).getPath());
|
||||
openInventory(player, released, own);
|
||||
return;
|
||||
}
|
||||
@ -151,13 +151,13 @@ public class TutorialCommand extends SWCommand {
|
||||
}
|
||||
|
||||
subserver.execute("save-all");
|
||||
ProxyServer.getInstance().getScheduler().schedule(VelocityCore.get(), () -> {
|
||||
ProxyServer.getInstance().getScheduler().schedule(BungeeCore.get(), () -> {
|
||||
Tutorial tutorial = Tutorial.create(user.getId(), name, item);
|
||||
File tutorialWorld = world(tutorial);
|
||||
|
||||
if (tutorialWorld.exists())
|
||||
SubserverSystem.deleteFolder(VelocityCore.local, tutorialWorld.getPath());
|
||||
ServerStarter.copyWorld(VelocityCore.local, tempWorld.getPath(), tutorialWorld.getPath());
|
||||
SubserverSystem.deleteFolder(BungeeCore.local, tutorialWorld.getPath());
|
||||
ServerStarter.copyWorld(BungeeCore.local, tempWorld.getPath(), tutorialWorld.getPath());
|
||||
Message.send("TUTORIAL_CREATED", player);
|
||||
}, 1, TimeUnit.SECONDS);
|
||||
}
|
||||
|
@ -20,6 +20,7 @@
|
||||
package de.steamwar.bungeecore.commands;
|
||||
|
||||
import de.steamwar.bungeecore.ArenaMode;
|
||||
import de.steamwar.bungeecore.listeners.mods.ModLoaderBlocker;
|
||||
import de.steamwar.command.SWCommandUtils;
|
||||
import de.steamwar.command.TypeMapper;
|
||||
import de.steamwar.command.TypeValidator;
|
||||
@ -48,6 +49,10 @@ public class TypeMappers {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (ModLoaderBlocker.isFabric(value)) {
|
||||
messageSender.send("MODLOADER_DENIED");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
}
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
package de.steamwar.bungeecore.commands;
|
||||
|
||||
import de.steamwar.bungeecore.VelocityCore;
|
||||
import de.steamwar.bungeecore.BungeeCore;
|
||||
import de.steamwar.bungeecore.Message;
|
||||
import de.steamwar.bungeecore.bot.AuthManager;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
@ -52,7 +52,7 @@ public class VerifyCommand extends SWCommand {
|
||||
if(bytes[0] == 'D' && bytes[1] == 'C') {
|
||||
Member member = AuthManager.connectAuth(SteamwarUser.get(sender.getName()), code);
|
||||
if(member != null) {
|
||||
VelocityCore.log(sender.getName() + " Verified with Discorduser: " + member.getIdLong());
|
||||
BungeeCore.log(sender.getName() + " Verified with Discorduser: " + member.getIdLong());
|
||||
Message.send("VERIFY_SUCCESS", sender, member.getUser().getAsTag());
|
||||
} else {
|
||||
Message.send("VERIFY_INVALID", sender);
|
||||
|
@ -21,11 +21,11 @@ package de.steamwar.bungeecore.commands;
|
||||
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.messages.ChatSender;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import de.steamwar.sql.Token;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
|
||||
public class WebpasswordCommand extends SWCommand {
|
||||
|
||||
@ -41,25 +41,12 @@ public class WebpasswordCommand extends SWCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
ProcessBuilder pb = new ProcessBuilder("php", "/var/www/register.php", player.getName(), password);
|
||||
pb.redirectErrorStream(true);
|
||||
try {
|
||||
Process regProcess = pb.start();
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(regProcess.getInputStream()));
|
||||
String errorLine;
|
||||
if((errorLine = reader.readLine()) != null) {
|
||||
if ("updated".equals(errorLine)) {
|
||||
ChatSender.of(player).system("WEB_UPDATED");
|
||||
return;
|
||||
} else {
|
||||
throw new SecurityException("Could not create webaccount " + errorLine);
|
||||
}
|
||||
}
|
||||
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
||||
user.setPassword(password);
|
||||
|
||||
ChatSender.of(player).system("WEB_CREATED");
|
||||
} catch (IOException e) {
|
||||
throw new SecurityException("Could not create webaccount", e);
|
||||
}
|
||||
Token.listUser(user).stream().filter(token -> token.getName().startsWith("Website: ")).forEach(token -> token.delete());
|
||||
|
||||
ChatSender.of(player).system("WEB_UPDATED");
|
||||
}
|
||||
|
||||
public static void changeUsername(String oldUsername, String newUsername){
|
||||
|
@ -21,7 +21,7 @@ package de.steamwar.bungeecore.commands;
|
||||
|
||||
import de.steamwar.bungeecore.Message;
|
||||
import de.steamwar.bungeecore.Storage;
|
||||
import de.steamwar.bungeecore.mods.ModUtils;
|
||||
import de.steamwar.bungeecore.listeners.mods.Utils;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.command.SWCommandUtils;
|
||||
import de.steamwar.command.TypeMapper;
|
||||
@ -118,7 +118,7 @@ public class WhoisCommand extends SWCommand {
|
||||
sender.system("WHOIS_CURRENT_SERVER", target.getServer().getInfo().getName());
|
||||
sender.system("WHOIS_CURRENT_PROTOCOL", target.getPendingConnection().getVersion());
|
||||
|
||||
List<Mod> mods = ModUtils.getPlayerModMap().get(user.getUUID());
|
||||
List<Mod> mods = Utils.playerModMap.get(user.getUUID());
|
||||
if(mods == null)
|
||||
mods = Collections.emptyList();
|
||||
|
||||
|
@ -19,10 +19,11 @@
|
||||
|
||||
package de.steamwar.bungeecore.listeners;
|
||||
|
||||
import de.steamwar.bungeecore.VelocityCore;
|
||||
import de.steamwar.bungeecore.BungeeCore;
|
||||
import de.steamwar.bungeecore.Message;
|
||||
import de.steamwar.bungeecore.commands.PunishmentCommand;
|
||||
import de.steamwar.bungeecore.commands.WebpasswordCommand;
|
||||
import de.steamwar.bungeecore.listeners.mods.Forge;
|
||||
import de.steamwar.messages.ChatSender;
|
||||
import de.steamwar.sql.BannedUserIPs;
|
||||
import de.steamwar.sql.Punishment;
|
||||
@ -42,21 +43,21 @@ public class BanListener extends BasicListener {
|
||||
|
||||
@EventHandler
|
||||
public void onLogin(LoginEvent event) {
|
||||
event.registerIntent(VelocityCore.get());
|
||||
ProxyServer.getInstance().getScheduler().runAsync(VelocityCore.get(), () -> {
|
||||
event.registerIntent(BungeeCore.get());
|
||||
ProxyServer.getInstance().getScheduler().runAsync(BungeeCore.get(), () -> {
|
||||
PendingConnection connection = event.getConnection();
|
||||
SteamwarUser user = SteamwarUser.getOrCreate(connection.getUniqueId(), connection.getName(), ConnectionListener::newPlayer, WebpasswordCommand::changeUsername);
|
||||
String ip = IPSanitizer.getTrueAddress(connection).getHostAddress();
|
||||
if (user.isPunished(Punishment.PunishmentType.Ban)) {
|
||||
event.setCancelled(true);
|
||||
BannedUserIPs.banIP(user.getId(), ip);
|
||||
BannedUserIPs.banIP(user.getId(), connection.getAddress().getAddress().getHostAddress());
|
||||
ChatSender.of(event).system(PunishmentCommand.punishmentMessage(user, Punishment.PunishmentType.Ban));
|
||||
event.completeIntent(VelocityCore.get());
|
||||
event.completeIntent(BungeeCore.get());
|
||||
return;
|
||||
}
|
||||
|
||||
List<BannedUserIPs> ips = BannedUserIPs.get(ip);
|
||||
List<BannedUserIPs> ips = BannedUserIPs.get(connection.getAddress().getAddress().getHostAddress());
|
||||
if(!ips.isEmpty()){
|
||||
|
||||
Timestamp highestBan = ips.get(0).getTimestamp();
|
||||
boolean perma = false;
|
||||
for(BannedUserIPs banned : ips) {
|
||||
@ -73,7 +74,7 @@ public class BanListener extends BasicListener {
|
||||
}
|
||||
ClickEvent clickEvent = new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/ban " + user.getUserName() + " "
|
||||
+ (perma?"perma":highestBan.toLocalDateTime().format(DateTimeFormatter.ofPattern("dd.MM.yyyy_HH:mm")))
|
||||
+ " Ban Evasion - Bannumgehung");
|
||||
+ " Bannumgehung");
|
||||
|
||||
ChatSender.serverteamReceivers().forEach(sender -> sender.system(
|
||||
"BAN_AVOIDING_ALERT",
|
||||
@ -88,7 +89,7 @@ public class BanListener extends BasicListener {
|
||||
));
|
||||
}
|
||||
|
||||
event.completeIntent(VelocityCore.get());
|
||||
Forge.onServerConnected(event);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
31
src/de/steamwar/bungeecore/listeners/BasicListener.java
Normale Datei
31
src/de/steamwar/bungeecore/listeners/BasicListener.java
Normale Datei
@ -0,0 +1,31 @@
|
||||
/*
|
||||
This file is a part of the SteamWar software.
|
||||
|
||||
Copyright (C) 2020 SteamWar.de-Serverteam
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bungeecore.listeners;
|
||||
|
||||
import de.steamwar.bungeecore.BungeeCore;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
import net.md_5.bungee.api.plugin.Listener;
|
||||
|
||||
public abstract class BasicListener implements Listener {
|
||||
|
||||
public BasicListener(){
|
||||
ProxyServer.getInstance().getPluginManager().registerListener(BungeeCore.get(), this);
|
||||
}
|
||||
}
|
71
src/de/steamwar/bungeecore/listeners/BrandListener.java
Normale Datei
71
src/de/steamwar/bungeecore/listeners/BrandListener.java
Normale Datei
@ -0,0 +1,71 @@
|
||||
/*
|
||||
This file is a part of the SteamWar software.
|
||||
|
||||
Copyright (C) 2020 SteamWar.de-Serverteam
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bungeecore.listeners;
|
||||
|
||||
import de.steamwar.messages.ChatSender;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.ByteBufAllocator;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
import net.md_5.bungee.api.event.PluginMessageEvent;
|
||||
import net.md_5.bungee.event.EventHandler;
|
||||
import net.md_5.bungee.protocol.DefinedPacket;
|
||||
|
||||
import java.net.InetAddress;
|
||||
import java.net.NetworkInterface;
|
||||
import java.net.SocketException;
|
||||
|
||||
public class BrandListener extends BasicListener {
|
||||
|
||||
private static boolean isLocalHost(InetAddress addr) {
|
||||
if (addr.isAnyLocalAddress() || addr.isLoopbackAddress()) {
|
||||
return true;
|
||||
}
|
||||
try {
|
||||
return NetworkInterface.getByInetAddress(addr) != null;
|
||||
} catch (SocketException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onServerSwitch(PluginMessageEvent event) {
|
||||
if(!event.getTag().equals("minecraft:brand") && !event.getTag().equals("MC|Brand")) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.getReceiver() == null || isLocalHost(event.getReceiver().getAddress().getAddress())) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(event.getReceiver() instanceof ProxiedPlayer)) {
|
||||
return;
|
||||
}
|
||||
event.setCancelled(true);
|
||||
|
||||
ProxiedPlayer player = (ProxiedPlayer) event.getReceiver();
|
||||
String brandString = ChatSender.of(player).parseToLegacy("STEAMWAR_BRAND", ProxyServer.getInstance().getName(), player.getServer().getInfo().getName(), new String(event.getData(), 1, event.getData().length - 1));
|
||||
|
||||
ByteBuf brand = ByteBufAllocator.DEFAULT.heapBuffer();
|
||||
DefinedPacket.writeString(brandString, brand);
|
||||
player.sendData(event.getTag(), DefinedPacket.toArray(brand));
|
||||
brand.release();
|
||||
}
|
||||
}
|
@ -27,6 +27,7 @@ import de.steamwar.bungeecore.util.Chat19;
|
||||
import de.steamwar.messages.ChatSender;
|
||||
import de.steamwar.network.packets.server.PingPacket;
|
||||
import de.steamwar.sql.*;
|
||||
import net.md_5.bungee.api.*;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
import net.md_5.bungee.api.event.ChatEvent;
|
||||
import net.md_5.bungee.api.event.TabCompleteEvent;
|
||||
@ -57,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.log(Level.SEVERE, user.getUserName() + " " + user.getId() + " wurde automatisch wegen jndi:ldap gebannt.");
|
||||
BungeeCore.log(Level.SEVERE, user.getUserName() + " " + user.getId() + " wurde automatisch wegen jndi:ldap gebannt.");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -191,7 +192,7 @@ public class ChatListener extends BasicListener {
|
||||
TaskScheduler scheduler = ProxyServer.getInstance().getScheduler();
|
||||
for(int i = 0; i < delay.length; i++) {
|
||||
int finalI = i;
|
||||
scheduler.schedule(VelocityCore.get(), () -> sender.prefixless("CHAT_MSG", name, sender.user(), new Message(baseMessage + (finalI+1))), delay[i], TimeUnit.SECONDS);
|
||||
scheduler.schedule(BungeeCore.get(), () -> sender.prefixless("CHAT_MSG", name, sender.user(), new Message(baseMessage + (finalI+1))), delay[i], TimeUnit.SECONDS);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
package de.steamwar.bungeecore.listeners;
|
||||
|
||||
import de.steamwar.bungeecore.VelocityCore;
|
||||
import de.steamwar.bungeecore.BungeeCore;
|
||||
import de.steamwar.bungeecore.Message;
|
||||
import de.steamwar.bungeecore.Servertype;
|
||||
import de.steamwar.bungeecore.Subserver;
|
||||
@ -29,7 +29,7 @@ import de.steamwar.bungeecore.commands.ChallengeCommand;
|
||||
import de.steamwar.bungeecore.commands.CheckCommand;
|
||||
import de.steamwar.bungeecore.commands.ModCommand;
|
||||
import de.steamwar.bungeecore.commands.MsgCommand;
|
||||
import de.steamwar.bungeecore.mods.ModUtils;
|
||||
import de.steamwar.bungeecore.listeners.mods.Utils;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import de.steamwar.sql.UserPerm;
|
||||
import net.md_5.bungee.api.AbstractReconnectHandler;
|
||||
@ -142,7 +142,7 @@ public class ConnectionListener extends BasicListener {
|
||||
}
|
||||
}
|
||||
|
||||
ServerInfo kickTo = ProxyServer.getInstance().getServerInfo(VelocityCore.LOBBY_SERVER);
|
||||
ServerInfo kickTo = ProxyServer.getInstance().getServerInfo(BungeeCore.LOBBY_SERVER);
|
||||
|
||||
if (kickedFrom != null && kickedFrom.equals(kickTo)) {
|
||||
return;
|
||||
@ -156,7 +156,7 @@ public class ConnectionListener extends BasicListener {
|
||||
public void onDisconnect(PlayerDisconnectEvent e){
|
||||
ChallengeCommand.remove(e.getPlayer());
|
||||
MsgCommand.remove(e.getPlayer());
|
||||
ModUtils.getPlayerModMap().remove(e.getPlayer().getUniqueId());
|
||||
Utils.playerModMap.remove(e.getPlayer().getUniqueId());
|
||||
ModCommand.playerFilterType.remove(e.getPlayer());
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,10 @@
|
||||
package de.steamwar.bungeecore.listeners;
|
||||
|
||||
import de.steamwar.bungeecore.Message;
|
||||
import de.steamwar.sql.*;
|
||||
import de.steamwar.sql.EventFight;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import de.steamwar.sql.TeamTeilnahme;
|
||||
import de.steamwar.sql.Event;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import net.md_5.bungee.api.event.PostLoginEvent;
|
||||
import net.md_5.bungee.event.EventHandler;
|
||||
@ -21,8 +24,10 @@ public class EventModeListener extends BasicListener {
|
||||
if(TeamTeilnahme.nimmtTeil(user.getTeam(), event.getEventID()))
|
||||
return;
|
||||
|
||||
if(Referee.get(event.getEventID()).contains(user.getId()))
|
||||
return;
|
||||
for(EventFight eventFight : EventFight.getEvent(event.getEventID())){
|
||||
if(eventFight.getKampfleiter() == user.getId())
|
||||
return;
|
||||
}
|
||||
|
||||
e.getPlayer().disconnect(TextComponent.fromLegacyText(Message.parse("EVENTMODE_KICK", e.getPlayer())));
|
||||
}
|
||||
|
@ -1,74 +0,0 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2020 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bungeecore.listeners;
|
||||
|
||||
import com.velocitypowered.api.event.Subscribe;
|
||||
import com.velocitypowered.api.event.connection.PreLoginEvent;
|
||||
import com.velocitypowered.api.proxy.InboundConnection;
|
||||
import com.velocitypowered.proxy.connection.MinecraftConnection;
|
||||
import com.velocitypowered.proxy.connection.client.InitialInboundConnection;
|
||||
import com.velocitypowered.proxy.connection.client.LoginInboundConnection;
|
||||
import de.steamwar.bungeecore.VelocityCore;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.net.InetAddress;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class IPSanitizer {
|
||||
|
||||
private static final Field delegateField;
|
||||
private static final Field remoteAddressField;
|
||||
static {
|
||||
try {
|
||||
delegateField = LoginInboundConnection.class.getDeclaredField("delegate");
|
||||
remoteAddressField = MinecraftConnection.class.getDeclaredField("remoteAddress");
|
||||
} catch (NoSuchFieldException e) {
|
||||
throw new SecurityException("Could not initialize Reflection", e);
|
||||
}
|
||||
delegateField.setAccessible(true);
|
||||
remoteAddressField.setAccessible(true);
|
||||
}
|
||||
|
||||
public static MinecraftConnection getChannelWrapper(InboundConnection connection) {
|
||||
try {
|
||||
return ((InitialInboundConnection) delegateField.get(connection)).getConnection();
|
||||
} catch (IllegalAccessException e) {
|
||||
throw new SecurityException("Could not get channel wrapper", e);
|
||||
}
|
||||
}
|
||||
|
||||
public static InetAddress getTrueAddress(InboundConnection connection) {
|
||||
return ((InetSocketAddress) getChannelWrapper(connection).getRemoteAddress()).getAddress();
|
||||
}
|
||||
|
||||
|
||||
private final InetSocketAddress sanitized = new InetSocketAddress("127.127.127.127", 25565);
|
||||
|
||||
@Subscribe
|
||||
public void loginEvent(PreLoginEvent e) {
|
||||
VelocityCore.get().getLogger().log(Level.INFO, e.getConnection().getRemoteAddress().getAddress().toString() + " has logged in with user name " + e.getUsername());
|
||||
try {
|
||||
remoteAddressField.set(getChannelWrapper(e.getConnection()), sanitized);
|
||||
} catch (IllegalAccessException ex) {
|
||||
throw new SecurityException("Could not set remote address", ex);
|
||||
}
|
||||
}
|
||||
}
|
97
src/de/steamwar/bungeecore/listeners/NonFabricFabricCheck.java
Normale Datei
97
src/de/steamwar/bungeecore/listeners/NonFabricFabricCheck.java
Normale Datei
@ -0,0 +1,97 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2022 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bungeecore.listeners;
|
||||
|
||||
import de.steamwar.bungeecore.BungeeCore;
|
||||
import de.steamwar.bungeecore.Message;
|
||||
import de.steamwar.bungeecore.Storage;
|
||||
import net.md_5.bungee.BungeeCord;
|
||||
import net.md_5.bungee.api.connection.Connection;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
import net.md_5.bungee.api.event.LoginEvent;
|
||||
import net.md_5.bungee.api.event.PlayerDisconnectEvent;
|
||||
import net.md_5.bungee.api.event.PluginMessageEvent;
|
||||
import net.md_5.bungee.event.EventHandler;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Locale;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class NonFabricFabricCheck extends BasicListener {
|
||||
|
||||
private final Set<UUID> usingFabric = new HashSet<>();
|
||||
|
||||
private final Set<ProxiedPlayer> checking = new HashSet<>();
|
||||
private final Set<ProxiedPlayer> vanilla = new HashSet<>();
|
||||
|
||||
{
|
||||
BungeeCord.getInstance().getScheduler().schedule(BungeeCore.get(), usingFabric::clear, 0, 15, TimeUnit.MINUTES);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void pluginMessageEvent(PluginMessageEvent e) {
|
||||
Connection sender = e.getSender();
|
||||
if(!(sender instanceof ProxiedPlayer))
|
||||
return;
|
||||
|
||||
ProxiedPlayer p = (ProxiedPlayer) sender;
|
||||
if (e.getTag().equals("minecraft:register") && new String(e.getData()).contains("fabric-screen-handler-api-v1:open_screen")) {
|
||||
BungeeCord.getInstance().getScheduler().schedule(BungeeCore.get(), () -> {
|
||||
if (!sender.isConnected()) return;
|
||||
if (!vanilla.remove(p)) return;
|
||||
if (Storage.fabricCheckedPlayers.containsKey(p)) return;
|
||||
p.disconnect(Message.parse("MOD_USE_MODSENDER", p));
|
||||
}, 25, TimeUnit.SECONDS);
|
||||
return;
|
||||
}
|
||||
|
||||
if(!e.getTag().equals("minecraft:brand"))
|
||||
return;
|
||||
|
||||
if(!new String(e.getData()).equals("vanilla"))
|
||||
return;
|
||||
vanilla.add(p);
|
||||
|
||||
BungeeCord.getInstance().getScheduler().schedule(BungeeCore.get(), () -> {
|
||||
if (!p.isConnected()) return;
|
||||
if (Storage.fabricCheckedPlayers.containsKey(p)) return;
|
||||
checking.add(p);
|
||||
p.sendData("fabric-screen-handler-api-v1:open_screen", new byte[] {0});
|
||||
BungeeCord.getInstance().getScheduler().schedule(BungeeCore.get(), () -> checking.remove(p), 1, TimeUnit.SECONDS);
|
||||
}, 30, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerPreLogin(LoginEvent e) {
|
||||
if (usingFabric.remove(e.getConnection().getUniqueId())) {
|
||||
e.getConnection().disconnect(Message.parse("MOD_USE_MODSENDER", Locale.getDefault()));
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerDisconnect(PlayerDisconnectEvent e) {
|
||||
if (checking.remove(e.getPlayer())) {
|
||||
usingFabric.add(e.getPlayer().getUniqueId());
|
||||
}
|
||||
vanilla.remove(e.getPlayer());
|
||||
}
|
||||
}
|
@ -1,331 +0,0 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2024 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bungeecore.listeners;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.lunarclient.apollo.ApolloManager;
|
||||
import com.velocitypowered.api.event.connection.PluginMessageEvent;
|
||||
import com.velocitypowered.api.proxy.Player;
|
||||
import com.velocitypowered.api.proxy.ServerConnection;
|
||||
import com.velocitypowered.api.proxy.messages.MinecraftChannelIdentifier;
|
||||
import de.steamwar.bungeecore.VelocityCore;
|
||||
import de.steamwar.bungeecore.Message;
|
||||
import de.steamwar.bungeecore.commands.TeamCommand;
|
||||
import de.steamwar.bungeecore.mods.*;
|
||||
import de.steamwar.bungeecore.network.ServerMetaInfo;
|
||||
import de.steamwar.bungeecore.util.annotations.Create;
|
||||
import de.steamwar.messages.ChatSender;
|
||||
import de.steamwar.network.packets.NetworkPacket;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import net.kyori.adventure.text.Component;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.*;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.logging.Level;
|
||||
|
||||
@Create
|
||||
public class PluginMessage {
|
||||
|
||||
private final Lunar lunar;
|
||||
private final LabyMod labyMod;
|
||||
private final WorldDownloader wdl;
|
||||
private final FabricModSender fms;
|
||||
private final FML flm;
|
||||
|
||||
public static void send(Player player, String legacyChannel, String channel, byte[] data) {
|
||||
// 1.12 format change
|
||||
send(player, player.getProtocolVersion().getProtocol() > 340 ? channel : legacyChannel, data);
|
||||
}
|
||||
|
||||
public static void send(Player player, String channel, byte[] data) {
|
||||
player.sendPluginMessage(MinecraftChannelIdentifier.from(channel), data);
|
||||
}
|
||||
|
||||
public static byte[] genBufPacket(Consumer<ByteBuf> generator) {
|
||||
ByteBuf buf = Unpooled.buffer();
|
||||
generator.accept(buf);
|
||||
|
||||
byte[] packet = new byte[buf.readableBytes()];
|
||||
buf.readBytes(packet);
|
||||
return packet;
|
||||
}
|
||||
|
||||
public static byte[] genStreamPacket(StreamConsumer generator) {
|
||||
ByteArrayOutputStream stream = new ByteArrayOutputStream();
|
||||
DataOutputStream out = new DataOutputStream(stream);
|
||||
|
||||
try {
|
||||
generator.accept(out);
|
||||
} catch (IOException e) {
|
||||
throw new SecurityException("Could not create PluginMessage packet", e);
|
||||
}
|
||||
|
||||
return stream.toByteArray();
|
||||
}
|
||||
|
||||
public interface StreamConsumer {
|
||||
void accept(DataOutputStream out) throws IOException;
|
||||
}
|
||||
|
||||
private static final Parser UNKNOWN = event -> {
|
||||
VelocityCore.get().getLogger().log(Level.WARNING, () -> "Undefined PluginMessage on channel " + event.getIdentifier().getId() + " from " + (event.getSource() instanceof Player pl ? pl.getUsername() : event.getSource().toString()) + " received.\n" + new String(event.getData()) + "\n" + Arrays.toString(event.getData()));
|
||||
event.setResult(PluginMessageEvent.ForwardResult.handled());
|
||||
};
|
||||
private static final Parser PASS_THROUGH = event -> event.setResult(PluginMessageEvent.ForwardResult.forward());
|
||||
private static final Parser DROP = event -> event.setResult(PluginMessageEvent.ForwardResult.handled());
|
||||
|
||||
private final Set<String> knownBrands = new HashSet<>();
|
||||
private final Map<String, Consumer<Player>> channelRegisterHandlers = new HashMap<>();
|
||||
private final Map<String, Parser> handlers = new HashMap<>();
|
||||
|
||||
@Inject
|
||||
public PluginMessage(Lunar lunar, LabyMod labyMod, WorldDownloader wdl, FabricModSender fms, FML flm) {
|
||||
this.lunar = lunar;
|
||||
this.labyMod = labyMod;
|
||||
this.wdl = wdl;
|
||||
this.fms = fms;
|
||||
this.flm = flm;
|
||||
|
||||
knownBrands.addAll(Arrays.asList("vanilla", "fabric", "quilt", "forge", "optifine", "Geyser", "labymod", "Feather Fabric"));
|
||||
|
||||
for(String channel : Arrays.asList(
|
||||
"fabric:container/open", "fabric:registry/sync/direct", "fabric:registry/sync",
|
||||
"fabric-screen-handler-api-v1:open_screen",
|
||||
|
||||
FML.CHANNEL, "fml:loginwrapper", "fml:handshake", "fml:play", "forge:tier_sorting", "forge:split",
|
||||
"forge:login", "forge:handshake",
|
||||
|
||||
"labymod3:main", "labymod:neo",
|
||||
|
||||
"floodgate:skin", "floodgate:form", "floodgate:transfer", "floodgate:packet",
|
||||
|
||||
"Replay|Restrict", "replaymod:restrict",
|
||||
"WDL|CONTROL", "wdl:control",
|
||||
"tpshud:handshake", "tpshud:tps", //https://github.com/mooziii/tpshud-fabric/tree/main
|
||||
"methane_server:statepacket", //https://modrinth.com/mod/methane
|
||||
"servux:structures", //https://modrinth.com/mod/servux
|
||||
"architectury:spawn_entity_packet", //https://modrinth.com/mod/architectury-api
|
||||
"jei:channel", //https://modrinth.com/mod/jei
|
||||
"shulkerboxtooltip:s2c_handshake", "shulkerboxtooltip:ec_update", //https://modrinth.com/mod/shulkerboxtooltip
|
||||
"owo:local_packet", "owo:sync_screen_handler_properties", //https://modrinth.com/mod/owo-lib
|
||||
"essential:", //https://essential.gg/
|
||||
"libgui:screen_message_s2c", //https://github.com/CottonMC/LibGui
|
||||
"minecraft:intave", //https://intave.ac seems to be a client side integration of intave with labymod 4
|
||||
"midnightcontrols:feature", "midnightcontrols:controls_mode", //https://modrinth.com/mod/midnightcontrols
|
||||
"controlify:vibrate_from_origin", "controlify:vibration", "controlify:vibrate_from_entity",
|
||||
"carpet:structures", //https://modrinth.com/mod/carpet
|
||||
"appleskin:exhaustion_sync", "appleskin:saturation_sync", //https://modrinth.com/mod/appleskin
|
||||
"puzzleslib:1/1", //https://modrinth.com/mod/puzzles-lib
|
||||
"pickupnotifier:1/1", //https://modrinth.com/mod/pick-up-notifier
|
||||
"plasmo:voice/v2/installed", "plasmo:voice/v2", //https://modrinth.com/plugin/plasmo-voice
|
||||
"whereisit:s2c_founditem", //https://modrinth.com/mod/where-is-it (needs server side component to work)
|
||||
"inventorysorter:sync_blacklist_packet", //https://github.com/cpw/inventorysorter (needs server side component to work)
|
||||
|
||||
//https://github.com/bernie-g/geckolib
|
||||
"geckolib:block_entity_anim_trigger_sync", "geckolib:entity_anim_trigger_sync",
|
||||
"geckolib:block_entity_anim_data_sync", "geckolib:anim_data_sync",
|
||||
"geckolib:entity_anim_data_sync", "geckolib:anim_trigger_sync",
|
||||
|
||||
//https://github.com/Noxcrew/noxesium
|
||||
"noxesium-v1:reset", "noxesium-v1:change_server_rules", "noxesium-v1:server_info",
|
||||
"noxesium-v1:mcc_server", "noxesium-v1:mcc_game_state", "noxesium-v1:reset_server_rules",
|
||||
"noxesium-v1:stop_sound", "noxesium-v1:start_sound", "noxesium-v1:modify_sound"
|
||||
)) {
|
||||
channelRegisterHandlers.put(channel, player -> {
|
||||
});
|
||||
}
|
||||
|
||||
channelRegisterHandlers.put(ApolloManager.PLUGIN_MESSAGE_CHANNEL, lunar::sendRestrictions);
|
||||
channelRegisterHandlers.put(Feather.CHANNEL.getId(), new Feather()::sendRestrictions);
|
||||
channelRegisterHandlers.put("xaerominimap:main", player -> player.sendMessage(Component.text("§n§o§m§i§n§i§m§a§p"))); //https://www.curseforge.com/minecraft/mc-mods/xaeros-minimap
|
||||
channelRegisterHandlers.put("litemoretica:init_easy_place", player -> player.disconnect(ChatSender.of(player).parseToComponent(false, new Message("MOD_YELLOW_SING", "litematica")))); //https://github.com/Earthcomputer/litemoretica/tree/master
|
||||
channelRegisterHandlers.put("voxelmap:settings", player -> player.disconnect(ChatSender.of(player).parseToComponent(false, new Message("MOD_YELLOW_SING", "voxelmap")))); //https://modrinth.com/mod/voxelmap-updated undocumented
|
||||
channelRegisterHandlers.put("worldinfo:world_id", player -> player.disconnect(ChatSender.of(player).parseToComponent(false, new Message("MOD_YELLOW_SING", "minimap")))); // JourneyMap and VoxelMap
|
||||
channelRegisterHandlers.put(Controlify.CHANNEL.getId(), new Controlify()::onRegister);
|
||||
|
||||
registerBiDirPassthrough("worldedit:cui");
|
||||
|
||||
registerPassthroughToClient(
|
||||
"axiom:enable", "axiom:initialize_hotbars",
|
||||
"axiom:response_chunk_data", "axiom:register_world_properties", "axiom:set_world_property",
|
||||
"axiom:ack_world_properties", "axiom:restrictions", "axiom:marker_data", "axiom:marker_nbt_response",
|
||||
"axiom:custom_blocks", "axiom:editor_warning", "axiom:blueprint_manifest", "axiom:response_blueprint"
|
||||
);
|
||||
registerBiDirPassthrough("axiom:handle_big_payload", "axiom:set_editor_views");
|
||||
registerPassthroughToServer(
|
||||
"axiom:hello", "axiom:set_gamemode", "axiom:set_fly_speed", "axiom:set_world_time",
|
||||
"axiom:set_world_property", "axiom:set_block", "axiom:set_hotbar_slot", "axiom:switch_active_hotbar",
|
||||
"axiom:teleport", "axiom:request_chunk_data", "axiom:spawn_entity",
|
||||
"axiom:manipulate_entity", "axiom:delete_entity", "axiom:marker_nbt_request", "axiom:set_buffer"
|
||||
);
|
||||
|
||||
for(String channel : Arrays.asList(
|
||||
"UNREGISTER", "minecraft:unregister", // used by carpet and servux
|
||||
"WDL|REQUEST", "wdl:request",
|
||||
"minecraft:intave", //undocumented, byte stringlength, clientconfig, byte length, json {"legacySneakHeight":false,"legacyOldRange":false,"legacyOldSlowdown":false}
|
||||
"waila:entity", "waila:block",
|
||||
"lambdacontrols:hello",
|
||||
"midnightcontrols:controls_mode",
|
||||
"inventorysorter:sync_settings_packet",
|
||||
"voicechat:request_secret", "voicechat:update_state", //https://modrinth.com/plugin/simple-voice-chat
|
||||
"shulkerboxtooltip:c2s_handshake"
|
||||
))
|
||||
register(channel, false, directional(UNKNOWN, DROP));
|
||||
|
||||
register("REGISTER", false, directional(this::serverRegistersChannel, this::clientRegistersChannel));
|
||||
register("minecraft:register", false, directional(this::serverRegistersChannel, this::clientRegistersChannel));
|
||||
|
||||
register("BungeeCord", false, onlySWSource(PASS_THROUGH));
|
||||
register("bungeecord:main", false, onlySWSource(PASS_THROUGH));
|
||||
register("MC|Brand", false, directional(this::steamWarBrand, this::userBrand));
|
||||
register("minecraft:brand", false, directional(this::steamWarBrand, this::userBrand));
|
||||
|
||||
//Needs to be registered cause paper refuses to send PluginMessages on unregistered channels...
|
||||
register("sw:bridge", true, directional(onlySWSource(async(event -> NetworkPacket.handle(new ServerMetaInfo(((ServerConnection) event.getSource()).getServerInfo()), event.getData()))), UNKNOWN));
|
||||
register("sw:hotkeys", false, directional(UNKNOWN, PASS_THROUGH));
|
||||
register("fabricmodsender:mods", true, directional(UNKNOWN, async(fms::handlePluginMessage)));
|
||||
|
||||
register("WDL|INIT", true, directional(UNKNOWN, wdl::handlePluginMessage));
|
||||
register("wdl:init", true, directional(UNKNOWN, wdl::handlePluginMessage));
|
||||
|
||||
register(ApolloManager.PLUGIN_MESSAGE_CHANNEL, true, async(lunar::handlePluginMessage));
|
||||
register("LMC", true, directional(UNKNOWN, async(labyMod::handlePluginMessage)));
|
||||
register("labymod3:main", true, directional(UNKNOWN, async(labyMod::handlePluginMessage)));
|
||||
register("labymod:neo", false, directional(UNKNOWN, DROP)); //undocumented, JSON format "0" byte, packetlängen byte, {"version":"4.1.25"}
|
||||
register(FML.CHANNEL, true, directional(UNKNOWN, async(flm::handlePluginMessage)));
|
||||
|
||||
//vanilla does not register any channels (sends only one minecraft:brand vanilla, nothing else (potential spoofed client detection))
|
||||
//Forge interestingly registers all channels the server registers
|
||||
//meteor https://github.com/MeteorDevelopment/meteor-client/blob/master/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/ServerSpoof.java https://github.com/MeteorDevelopment/meteor-client/blob/master/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/DiscordPresence.java
|
||||
//litematica/malilib https://github.com/maruohon/litematica/issues/75 https://github.com/maruohon/malilib/blob/liteloader_1.12.2/src/main/java/malilib/network/message/ConfigLockPacketHandler.java#L65
|
||||
// Hackclientlike modsuppressor for labymod: https://github.com/Neocraftr/LabyMod-NeoEssentials (Potentially recognizable from NO Addons/NO Mods?) https://github.com/Neocraftr/LabyMod-NeoEssentials/blob/master/src/main/java/de/neocraftr/neoessentials/utils/BytecodeMethods.java
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPluginMessage(PluginMessageEvent event) {
|
||||
event.setCancelled(true);
|
||||
|
||||
try {
|
||||
handlers.getOrDefault(event.getTag(), UNKNOWN).handle(event);
|
||||
} catch (Exception e) {
|
||||
throw new SecurityException("PluginMessage handling exception: " + event + "\n" + Arrays.toString(event.getData()), e);
|
||||
}
|
||||
}
|
||||
|
||||
private void registerPassthroughToClient(String... channels) {
|
||||
for(String channel : channels) {
|
||||
channelRegisterHandlers.put(channel, player -> {});
|
||||
register(channel, false, directional(PASS_THROUGH, UNKNOWN));
|
||||
}
|
||||
}
|
||||
|
||||
private void registerPassthroughToServer(String... channels) {
|
||||
for(String channel : channels)
|
||||
register(channel, false, directional(UNKNOWN, PASS_THROUGH));
|
||||
}
|
||||
|
||||
private void registerBiDirPassthrough(String... channels) {
|
||||
for(String channel : channels) {
|
||||
channelRegisterHandlers.put(channel, player -> {});
|
||||
register(channel, false, PASS_THROUGH);
|
||||
}
|
||||
}
|
||||
|
||||
private void register(String channel, boolean clientSideRegister, Parser handler) {
|
||||
handlers.put(channel, handler);
|
||||
if(clientSideRegister)
|
||||
ProxyServer.getInstance().registerChannel(channel);
|
||||
}
|
||||
|
||||
private void clientRegistersChannel(PluginMessageEvent event) {
|
||||
ProxiedPlayer player = (ProxiedPlayer) event.getSender();
|
||||
|
||||
for(String channel : new String(event.getData()).split("\0")) {
|
||||
channelRegisterHandlers.getOrDefault(channel, p -> VelocityCore.get().getLogger().log(Level.WARNING, () -> p.getName() + " registered unknown channel " + channel)).accept(player);
|
||||
}
|
||||
|
||||
PASS_THROUGH.handle(event);
|
||||
}
|
||||
|
||||
private void serverRegistersChannel(PluginMessageEvent event) {
|
||||
ProxiedPlayer player = (ProxiedPlayer)event.getReceiver();
|
||||
|
||||
List<String> channels = new ArrayList<>(Arrays.asList(new String(event.getData()).split("\0")));
|
||||
channels.removeIf(channel -> channel.equals("sw:bridge"));
|
||||
player.sendData((player).getPendingConnection().getVersion() > 340 ? "minecraft:register" : "REGISTER", String.join("\0", channels).getBytes());
|
||||
}
|
||||
|
||||
private void userBrand(PluginMessageEvent event) {
|
||||
ProxiedPlayer player = (ProxiedPlayer) event.getSender();
|
||||
ByteBuf buf = Unpooled.wrappedBuffer(event.getData());
|
||||
String brand = DefinedPacket.readString(buf);
|
||||
boolean lunarclient = brand.startsWith("lunarclient:");
|
||||
|
||||
VelocityCore.get().getLogger().log(knownBrands.contains(brand) || lunarclient ? Level.INFO : Level.WARNING, () -> player.getName() + " joins with brand: " + brand);
|
||||
if(lunarclient)
|
||||
lunar.sendRestrictions(player);
|
||||
|
||||
PASS_THROUGH.handle(event);
|
||||
}
|
||||
|
||||
private void steamWarBrand(PluginMessageEvent event) {
|
||||
ProxiedPlayer player = (ProxiedPlayer) event.getReceiver();
|
||||
String brandString = ChatSender.of(player).parseToLegacy("STEAMWAR_BRAND", ProxyServer.getInstance().getName(), player.getServer().getInfo().getName(), new String(event.getData(), 1, event.getData().length - 1));
|
||||
|
||||
ByteBuf brand = ByteBufAllocator.DEFAULT.heapBuffer();
|
||||
DefinedPacket.writeString(brandString, brand);
|
||||
player.sendData(event.getTag(), DefinedPacket.toArray(brand));
|
||||
brand.release();
|
||||
}
|
||||
|
||||
|
||||
private Parser directional(Parser fromServer, Parser fromPlayer) {
|
||||
return event -> {
|
||||
if(event.getSender() instanceof ProxiedPlayer)
|
||||
fromPlayer.handle(event);
|
||||
else
|
||||
fromServer.handle(event);
|
||||
};
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
private Parser onlySWSource(Parser parser) {
|
||||
return event -> {
|
||||
Connection sender = event.getSender();
|
||||
if(TeamCommand.isLocalhost(sender instanceof ProxiedPlayer ? IPSanitizer.getTrueAddress(((ProxiedPlayer) sender).getPendingConnection()) : sender.getAddress().getAddress()))
|
||||
parser.handle(event);
|
||||
else
|
||||
UNKNOWN.handle(event);
|
||||
};
|
||||
}
|
||||
|
||||
private Parser async(Parser parser) {
|
||||
return event -> ProxyServer.getInstance().getScheduler().runAsync(VelocityCore.get(), () -> parser.handle(event));
|
||||
}
|
||||
|
||||
private interface Parser {
|
||||
void handle(PluginMessageEvent event);
|
||||
}
|
||||
}
|
@ -19,7 +19,7 @@
|
||||
|
||||
package de.steamwar.bungeecore.listeners;
|
||||
|
||||
import de.steamwar.bungeecore.VelocityCore;
|
||||
import de.steamwar.bungeecore.BungeeCore;
|
||||
import de.steamwar.sql.Session;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
@ -43,7 +43,7 @@ public class SessionManager extends BasicListener {
|
||||
public void onDisconnect(PlayerDisconnectEvent e){
|
||||
Timestamp timestamp = sessions.remove(e.getPlayer());
|
||||
if(timestamp != null) {
|
||||
ProxyServer.getInstance().getScheduler().runAsync(VelocityCore.get(), () -> Session.insertSession(SteamwarUser.get(e.getPlayer().getUniqueId()).getId(), timestamp));
|
||||
ProxyServer.getInstance().getScheduler().runAsync(BungeeCore.get(), () -> Session.insertSession(SteamwarUser.get(e.getPlayer().getUniqueId()).getId(), timestamp));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
package de.steamwar.bungeecore.listeners;
|
||||
|
||||
import de.steamwar.bungeecore.VelocityCore;
|
||||
import de.steamwar.bungeecore.BungeeCore;
|
||||
import de.steamwar.bungeecore.network.NetworkSender;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import de.steamwar.network.packets.server.LocaleInvalidationPacket;
|
||||
@ -32,7 +32,7 @@ public class SettingsChangedListener extends BasicListener {
|
||||
|
||||
@EventHandler
|
||||
public void onSettingsChanged(SettingsChangedEvent event) {
|
||||
BungeeCord.getInstance().getScheduler().runAsync(VelocityCore.get(), () -> {
|
||||
BungeeCord.getInstance().getScheduler().runAsync(BungeeCore.get(), () -> {
|
||||
ProxiedPlayer player = event.getPlayer();
|
||||
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
||||
user.setLocale(player.getLocale(), false);
|
||||
|
70
src/de/steamwar/bungeecore/listeners/SubserverProtocolFixer.java
Normale Datei
70
src/de/steamwar/bungeecore/listeners/SubserverProtocolFixer.java
Normale Datei
@ -0,0 +1,70 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2020 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bungeecore.listeners;
|
||||
|
||||
import net.md_5.bungee.BungeeCord;
|
||||
import net.md_5.bungee.api.event.LoginEvent;
|
||||
import net.md_5.bungee.connection.InitialHandler;
|
||||
import net.md_5.bungee.connection.LoginResult;
|
||||
import net.md_5.bungee.event.EventHandler;
|
||||
import net.md_5.bungee.protocol.Property;
|
||||
import net.md_5.bungee.util.AddressUtil;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class SubserverProtocolFixer extends BasicListener {
|
||||
|
||||
private final InetSocketAddress inetSocketAddress = new InetSocketAddress("127.127.127.127", 25565);
|
||||
|
||||
private Field field;
|
||||
|
||||
{
|
||||
try {
|
||||
field = InitialHandler.class.getDeclaredField("extraDataInHandshake");
|
||||
field.setAccessible(true);
|
||||
} catch (NoSuchFieldException e) {
|
||||
BungeeCord.getInstance().getLogger().log(Level.SEVERE, e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void loginEvent(LoginEvent e) {
|
||||
InitialHandler initialHandler = ((InitialHandler) e.getConnection());
|
||||
|
||||
String undashedUUID = initialHandler.getUniqueId().toString().replace("-", "");
|
||||
String extraData = "\00" + AddressUtil.sanitizeAddress(inetSocketAddress) + "\00" + undashedUUID;
|
||||
|
||||
LoginResult result = initialHandler.getLoginProfile();
|
||||
if (result != null) {
|
||||
Property[] properties = result.getProperties();
|
||||
if (properties.length > 0) {
|
||||
extraData += "\00" + BungeeCord.getInstance().gson.toJson(properties);
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
field.set(initialHandler, extraData);
|
||||
} catch (IllegalAccessException ex) {
|
||||
BungeeCord.getInstance().getLogger().log(Level.SEVERE, ex.getMessage(), ex);
|
||||
}
|
||||
}
|
||||
}
|
31
src/de/steamwar/bungeecore/listeners/mods/Badlion.java
Normale Datei
31
src/de/steamwar/bungeecore/listeners/mods/Badlion.java
Normale Datei
@ -0,0 +1,31 @@
|
||||
package de.steamwar.bungeecore.listeners.mods;
|
||||
|
||||
import de.steamwar.bungeecore.listeners.BasicListener;
|
||||
import net.md_5.bungee.api.event.PostLoginEvent;
|
||||
import net.md_5.bungee.event.EventHandler;
|
||||
|
||||
public class Badlion extends BasicListener {
|
||||
|
||||
@EventHandler
|
||||
public void onPostLogin(PostLoginEvent event) {
|
||||
/*
|
||||
{
|
||||
"modsDisallowed": {
|
||||
"Clear Glass":{"disabled":true},
|
||||
"ClearWater":{"disabled":true},
|
||||
"FOV Changer":{"disabled":true},
|
||||
"Hitboxes":{"disabled":true},
|
||||
"MiniMap":{"disabled":true},
|
||||
"MLG Cobweb":{"disabled":true},
|
||||
"Replay":{"disabled":true},
|
||||
"Schematica":{"disabled":true},
|
||||
"ToggleSneak":{"disabled":true},
|
||||
"ToggleSprint":{"disabled":true},
|
||||
"TNT Time":{"disabled":true}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
event.getPlayer().sendData("badlion:mods", ("{\"Clear Glass\":{\"disabled\":true},\"ClearWater\":{\"disabled\":true},\"FOV Changer\":{\"disabled\":true},\"Hitboxes\":{\"disabled\":true},\"LevelHead\":{\"disabled\":true},\"MiniMap\":{\"disabled\":true},\"MLG Cobweb\":{\"disabled\":true},\"Replay\":{\"disabled\":true},\"Schematica\":{\"disabled\":true},\"ToggleSneak\":{\"disabled\":true},\"ToggleSprint\":{\"disabled\":true},\"TNT Time\":{\"disabled\":true}}").getBytes());
|
||||
}
|
||||
}
|
193
src/de/steamwar/bungeecore/listeners/mods/Fabric.java
Normale Datei
193
src/de/steamwar/bungeecore/listeners/mods/Fabric.java
Normale Datei
@ -0,0 +1,193 @@
|
||||
/*
|
||||
This file is a part of the SteamWar software.
|
||||
|
||||
Copyright (C) 2020 SteamWar.de-Serverteam
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bungeecore.listeners.mods;
|
||||
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonParser;
|
||||
import com.google.gson.JsonSyntaxException;
|
||||
import de.steamwar.bungeecore.BungeeCore;
|
||||
import de.steamwar.bungeecore.Storage;
|
||||
import de.steamwar.bungeecore.listeners.BasicListener;
|
||||
import de.steamwar.sql.Mod;
|
||||
import de.steamwar.sql.SWException;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import net.md_5.bungee.BungeeCord;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
import net.md_5.bungee.api.event.PluginMessageEvent;
|
||||
import net.md_5.bungee.api.event.ServerSwitchEvent;
|
||||
import net.md_5.bungee.event.EventHandler;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.charset.UnsupportedCharsetException;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class Fabric extends BasicListener {
|
||||
|
||||
public static void remove(ProxiedPlayer player) {
|
||||
Storage.fabricCheckedPlayers.remove(player);
|
||||
synchronized (Storage.fabricExpectPluginMessage) {
|
||||
Storage.fabricExpectPluginMessage.remove(player);
|
||||
}
|
||||
}
|
||||
|
||||
private static final HashSet<String> ppCircumventerList = new HashSet<>();
|
||||
static {
|
||||
ppCircumventerList.add("java");
|
||||
ppCircumventerList.add("minecraft");
|
||||
ppCircumventerList.add("org_joml_joml");
|
||||
ppCircumventerList.add("steamwarmodsender");
|
||||
}
|
||||
|
||||
private static final Set<String> neededMods = new HashSet<>();
|
||||
static {
|
||||
neededMods.add("java");
|
||||
neededMods.add("minecraft");
|
||||
neededMods.add("fabricloader");
|
||||
neededMods.add("steamwarmodsender");
|
||||
}
|
||||
|
||||
{
|
||||
BungeeCord.getInstance().getScheduler().schedule(BungeeCore.get(), () -> {
|
||||
synchronized (Storage.fabricExpectPluginMessage) {
|
||||
for (Map.Entry<ProxiedPlayer, Long> entry : Storage.fabricExpectPluginMessage.entrySet()) {
|
||||
if (!Storage.fabricCheckedPlayers.containsKey(entry.getKey())) {
|
||||
continue;
|
||||
}
|
||||
if (System.currentTimeMillis() - entry.getValue() > TimeUnit.SECONDS.toMillis(20)) {
|
||||
logMessage(SteamwarUser.get(entry.getKey().getUniqueId()), "Expected message not received", String.valueOf(entry.getValue()));
|
||||
Storage.fabricExpectPluginMessage.remove(entry.getKey());
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}, 0, 1, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPluginMessageEvent(PluginMessageEvent e){
|
||||
if(!e.getTag().equals("fabricmodsender:mods"))
|
||||
return;
|
||||
|
||||
if (!(e.getSender() instanceof ProxiedPlayer)) {
|
||||
return;
|
||||
}
|
||||
|
||||
ProxiedPlayer player = (ProxiedPlayer) e.getSender();
|
||||
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
||||
byte[] data = e.getData();
|
||||
|
||||
if (!Storage.fabricCheckedPlayers.containsKey(player)) {
|
||||
synchronized (Storage.fabricExpectPluginMessage) {
|
||||
if (Storage.fabricExpectPluginMessage.containsKey(player)) {
|
||||
logMessage(user, "Was not fabric checked but send message nonetheless", Arrays.toString(data));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
Storage.fabricExpectPluginMessage.remove(player);
|
||||
|
||||
List<Mod> mods = new ArrayList<>();
|
||||
|
||||
Utils.VarInt varInt = Utils.readVarInt(data,0);
|
||||
|
||||
if(data.length != varInt.length + varInt.value) {
|
||||
logMessage(user, "Invalid message length", Arrays.toString(data));
|
||||
return;
|
||||
}
|
||||
|
||||
data = Arrays.copyOfRange(data,varInt.length, data.length);
|
||||
|
||||
String dataString;
|
||||
|
||||
try{
|
||||
dataString = new String(data, StandardCharsets.UTF_8);
|
||||
}catch (UnsupportedCharsetException exception) {
|
||||
logMessage(user, "Unsupported charset", Arrays.toString(data));
|
||||
return;
|
||||
}
|
||||
|
||||
JsonArray array;
|
||||
|
||||
try {
|
||||
array = JsonParser.parseString(dataString).getAsJsonArray();
|
||||
}catch (JsonSyntaxException exception) {
|
||||
logMessage(user, "Invalid json", dataString);
|
||||
return;
|
||||
}
|
||||
|
||||
for(JsonElement mod : array) {
|
||||
mods.add(Mod.getOrCreate(mod.getAsString(), Mod.Platform.FABRIC));
|
||||
}
|
||||
|
||||
boolean neededMods = neededModsContained(mods);
|
||||
if(!neededMods) {
|
||||
logMessage(user, "Needed mods are not contained", dataString);
|
||||
return;
|
||||
}
|
||||
|
||||
if(ppCircumventerCheck(mods))
|
||||
logMessage(user, "PP circumventer suspicion", dataString);
|
||||
|
||||
if(!Utils.handleMods(player,mods))
|
||||
return;
|
||||
|
||||
if (Storage.fabricCheckedPlayers.containsKey(player)) {
|
||||
long current = Storage.fabricCheckedPlayers.get(player);
|
||||
if (current != dataString.hashCode()) {
|
||||
logMessage(user, "Mods changed during runtime", dataString);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
Storage.fabricCheckedPlayers.put(player, dataString.hashCode());
|
||||
}
|
||||
Storage.fabricPlayers.remove(player);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onServerSwitchEvent(ServerSwitchEvent e) {
|
||||
if (e.getFrom() == null) return;
|
||||
synchronized (Storage.fabricExpectPluginMessage) {
|
||||
Storage.fabricExpectPluginMessage.put(e.getPlayer(), System.currentTimeMillis());
|
||||
}
|
||||
}
|
||||
|
||||
private boolean neededModsContained(List<Mod> mods) {
|
||||
return mods.stream()
|
||||
.map(Mod::getModName)
|
||||
.filter(neededMods::contains)
|
||||
.count() == neededMods.size();
|
||||
}
|
||||
|
||||
private void logMessage(SteamwarUser user, String reason, String data) {
|
||||
SWException.log("FabricModSender " + user.getUserName() + ": " + reason, data);
|
||||
}
|
||||
|
||||
private boolean ppCircumventerCheck(List<Mod> mods) {
|
||||
for(Mod mod : mods) {
|
||||
String name = mod.getModName();
|
||||
if(!name.startsWith("fabric") && !ppCircumventerList.contains(name))
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
147
src/de/steamwar/bungeecore/listeners/mods/Forge.java
Normale Datei
147
src/de/steamwar/bungeecore/listeners/mods/Forge.java
Normale Datei
@ -0,0 +1,147 @@
|
||||
/*
|
||||
This file is a part of the SteamWar software.
|
||||
|
||||
Copyright (C) 2020 SteamWar.de-Serverteam
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bungeecore.listeners.mods;
|
||||
|
||||
import de.steamwar.bungeecore.BungeeCore;
|
||||
import de.steamwar.bungeecore.listeners.BasicListener;
|
||||
import de.steamwar.sql.Mod;
|
||||
import io.netty.channel.ChannelPipeline;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import net.md_5.bungee.api.connection.PendingConnection;
|
||||
import net.md_5.bungee.api.event.LoginEvent;
|
||||
import net.md_5.bungee.connection.InitialHandler;
|
||||
import net.md_5.bungee.netty.ChannelWrapper;
|
||||
import net.md_5.bungee.netty.HandlerBoss;
|
||||
import net.md_5.bungee.netty.PacketHandler;
|
||||
import net.md_5.bungee.protocol.packet.LoginPayloadRequest;
|
||||
import net.md_5.bungee.protocol.packet.LoginPayloadResponse;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class Forge extends BasicListener {
|
||||
|
||||
private static final String WRAPPER = "fml:loginwrapper";
|
||||
|
||||
private static final Field initialHandlerCh;
|
||||
static{
|
||||
try {
|
||||
initialHandlerCh = InitialHandler.class.getDeclaredField("ch");
|
||||
} catch (NoSuchFieldException e) {
|
||||
throw new SecurityException("Could not initialize Reflection", e);
|
||||
}
|
||||
initialHandlerCh.setAccessible(true);
|
||||
}
|
||||
|
||||
public static void onServerConnected(LoginEvent event) {
|
||||
if(event.getConnection().getVersion() < 341 || event.getConnection().getVersion() > 763) { //1.13 - 1.20.1
|
||||
event.completeIntent(BungeeCore.get());
|
||||
return;
|
||||
}
|
||||
|
||||
//fml:handshake without mods, channels and registries
|
||||
//for more information see https://wiki.vg/Minecraft_Forge_Handshake#FML2_protocol_.281.13_-_Current.29
|
||||
event.getConnection().unsafe().sendPacket(new LoginPayloadRequest(1, WRAPPER, new byte[]{13,102,109,108,58,104,97,110,100,115,104,97,107,101,4,1,0,0,0}));
|
||||
|
||||
InitialHandler handler = (InitialHandler) event.getConnection();
|
||||
|
||||
ChannelWrapper wrapper;
|
||||
try{
|
||||
wrapper = (ChannelWrapper) initialHandlerCh.get(handler);
|
||||
} catch (IllegalAccessException e) {
|
||||
BungeeCore.get().getLogger().log(Level.SEVERE, "Could not get Channel", e);
|
||||
event.completeIntent(BungeeCore.get());
|
||||
return;
|
||||
}
|
||||
|
||||
ChannelPipeline pipeline = wrapper.getHandle().pipeline();
|
||||
if(pipeline != null) {
|
||||
HandlerBoss handlerBoss = pipeline.get(HandlerBoss.class);
|
||||
if(handlerBoss != null)
|
||||
handlerBoss.setHandler(new CustomPacketHandler(event));
|
||||
}
|
||||
}
|
||||
|
||||
private static class CustomPacketHandler extends PacketHandler {
|
||||
private final LoginEvent event;
|
||||
|
||||
public CustomPacketHandler(LoginEvent event) {
|
||||
this.event = event;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "SteamWar Forge Handler";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handle(LoginPayloadResponse response){
|
||||
byte[] data = response.getData();
|
||||
if(data == null) {
|
||||
event.completeIntent(BungeeCore.get());
|
||||
return;
|
||||
}
|
||||
|
||||
//for more information see https://wiki.vg/Minecraft_Forge_Handshake#FML2_protocol_.281.13_-_Current.29
|
||||
Utils.VarInt channelLength = Utils.readVarInt(data, 0);
|
||||
int pos = channelLength.length;
|
||||
if(!new String(data, pos, channelLength.value).equals("fml:handshake")) {
|
||||
event.getConnection().disconnect(TextComponent.fromLegacyText("Invalid forge registry response (0x00)"));
|
||||
return;
|
||||
}
|
||||
pos += channelLength.value;
|
||||
|
||||
Utils.VarInt length = Utils.readVarInt(data, pos);
|
||||
pos += length.length;
|
||||
if(channelLength.length + channelLength.value + length.length + length.value != data.length) {
|
||||
event.getConnection().disconnect(TextComponent.fromLegacyText("Invalid forge registry response (0x01)"));
|
||||
return;
|
||||
}
|
||||
|
||||
Utils.VarInt packetId = Utils.readVarInt(data, pos);
|
||||
pos += packetId.length;
|
||||
if(packetId.value != 2) {
|
||||
event.getConnection().disconnect(TextComponent.fromLegacyText("Invalid forge registry response (0x02)"));
|
||||
return;
|
||||
}
|
||||
|
||||
Utils.VarInt modCount = Utils.readVarInt(data, pos);
|
||||
pos += modCount.length;
|
||||
|
||||
List<Mod> mods = new ArrayList<>();
|
||||
for(int i = 0; i < modCount.value; i++) {
|
||||
Utils.VarInt nameLength = Utils.readVarInt(data, pos);
|
||||
pos += nameLength.length;
|
||||
|
||||
mods.add(Mod.getOrCreate(new String(data, pos, nameLength.value), Mod.Platform.FORGE));
|
||||
pos += nameLength.value;
|
||||
}
|
||||
|
||||
PendingConnection connection = event.getConnection();
|
||||
if(!Utils.handleMods(connection.getUniqueId(), Locale.getDefault(), event::setCancelReason, mods)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
event.completeIntent(BungeeCore.get());
|
||||
}
|
||||
}
|
||||
}
|
113
src/de/steamwar/bungeecore/listeners/mods/Forge12.java
Normale Datei
113
src/de/steamwar/bungeecore/listeners/mods/Forge12.java
Normale Datei
@ -0,0 +1,113 @@
|
||||
/*
|
||||
This file is a part of the SteamWar software.
|
||||
|
||||
Copyright (C) 2022 SteamWar.de-Serverteam
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bungeecore.listeners.mods;
|
||||
|
||||
import de.steamwar.bungeecore.BungeeCore;
|
||||
import de.steamwar.bungeecore.listeners.BasicListener;
|
||||
import de.steamwar.sql.Mod;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.UnpooledByteBufAllocator;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
import net.md_5.bungee.api.connection.Connection;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
import net.md_5.bungee.api.event.PluginMessageEvent;
|
||||
import net.md_5.bungee.api.event.PostLoginEvent;
|
||||
import net.md_5.bungee.event.EventHandler;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class Forge12 extends BasicListener {
|
||||
private static final String FMLHS = "FML|HS";
|
||||
private static final byte[] REGISTER;
|
||||
private static final byte[] HELLO = new byte[]{0, 2, 0, 0, 0, 0};
|
||||
|
||||
private static final Set<UUID> unlocked = new HashSet<>();
|
||||
|
||||
static {
|
||||
ByteBuf buf = UnpooledByteBufAllocator.DEFAULT.directBuffer(7);
|
||||
buf.writeByte(6);
|
||||
buf.writeCharSequence(FMLHS, StandardCharsets.UTF_8);
|
||||
REGISTER = new byte[buf.readableBytes()];
|
||||
buf.readBytes(REGISTER);
|
||||
}
|
||||
|
||||
|
||||
@EventHandler
|
||||
public void onPostLogin(PostLoginEvent event) {
|
||||
ProxiedPlayer player = event.getPlayer();
|
||||
|
||||
synchronized (unlocked) {
|
||||
if(unlocked.contains(player.getUniqueId())){
|
||||
unlocked.remove(player.getUniqueId());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if(player.getPendingConnection().getVersion() <= 340) {
|
||||
player.sendData("REGISTER", REGISTER); //1.12-
|
||||
player.sendData(FMLHS, HELLO);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPluginMessageEvent(PluginMessageEvent e){
|
||||
if(!e.getTag().equals(FMLHS))
|
||||
return;
|
||||
|
||||
e.setCancelled(true);
|
||||
byte[] data = e.getData();
|
||||
|
||||
Connection sender = e.getSender();
|
||||
if(!(sender instanceof ProxiedPlayer))
|
||||
return;
|
||||
ProxiedPlayer p = (ProxiedPlayer) sender;
|
||||
|
||||
if (data[0] == 2) {
|
||||
Utils.VarInt numMods = Utils.readVarInt(data, 1);
|
||||
List<Mod> mods = new LinkedList<>();
|
||||
|
||||
int bytePos = 1 + numMods.length;
|
||||
for (int i = 0; i < numMods.value; i++) {
|
||||
byte[] name = Arrays.copyOfRange(data, bytePos + 1, bytePos + data[bytePos] + 1);
|
||||
bytePos += 1 + data[bytePos];
|
||||
//Version information is unused
|
||||
bytePos += 1 + data[bytePos];
|
||||
|
||||
mods.add(Mod.getOrCreate(new String(name), Mod.Platform.FORGE));
|
||||
}
|
||||
|
||||
if (Utils.handleMods(p, mods)) {
|
||||
synchronized (unlocked) {
|
||||
unlocked.add(p.getUniqueId());
|
||||
}
|
||||
ProxyServer.getInstance().getScheduler().schedule(BungeeCore.get(),
|
||||
() -> p.disconnect(BungeeCore.stringToText("§7Deine installierten Mods wurden überprüft\n§aDu kannst nun §eSteam§8War §abetreten")),
|
||||
2, TimeUnit.SECONDS);
|
||||
ProxyServer.getInstance().getScheduler().schedule(BungeeCore.get(), () -> {
|
||||
synchronized (unlocked) {
|
||||
unlocked.remove(p.getUniqueId());
|
||||
}
|
||||
}, 30, TimeUnit.SECONDS);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
184
src/de/steamwar/bungeecore/listeners/mods/LabyMod.java
Normale Datei
184
src/de/steamwar/bungeecore/listeners/mods/LabyMod.java
Normale Datei
@ -0,0 +1,184 @@
|
||||
/*
|
||||
This file is a part of the SteamWar software.
|
||||
|
||||
Copyright (C) 2020 SteamWar.de-Serverteam
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bungeecore.listeners.mods;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.stream.JsonReader;
|
||||
import de.steamwar.bungeecore.BungeeCore;
|
||||
import de.steamwar.bungeecore.listeners.BasicListener;
|
||||
import de.steamwar.sql.Mod;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
import net.md_5.bungee.api.connection.Connection;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
import net.md_5.bungee.api.event.PluginMessageEvent;
|
||||
import net.md_5.bungee.event.EventHandler;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.StringReader;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Arrays;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class LabyMod extends BasicListener {
|
||||
|
||||
@EventHandler
|
||||
public void onPluginMessageEvent(PluginMessageEvent event){
|
||||
if(!event.getTag().equals("LMC"))
|
||||
return;
|
||||
|
||||
Connection sender = event.getSender();
|
||||
if(!(sender instanceof ProxiedPlayer))
|
||||
return;
|
||||
|
||||
event.setCancelled(true);
|
||||
updateGameInfo((ProxiedPlayer) sender);
|
||||
byte[] data = event.getData();
|
||||
|
||||
ProxyServer.getInstance().getScheduler().runAsync(BungeeCore.get(), () -> runAsync(data, (ProxiedPlayer) sender));
|
||||
}
|
||||
|
||||
private void runAsync(byte[] data, ProxiedPlayer player) {
|
||||
VarString purpose = readString(data, 0);
|
||||
if(!"INFO".equals(purpose.value))
|
||||
return;
|
||||
|
||||
VarString value = readString(data, purpose.length);
|
||||
List<Mod> mods = new LinkedList<>();
|
||||
|
||||
try{
|
||||
InfoPacket info = new InfoPacket(value.value);
|
||||
for(InfoPacket.Addon addon : info.addons) {
|
||||
mods.add(Mod.getOrCreate(addon.name, Mod.Platform.LABYMOD));
|
||||
}
|
||||
}catch(IOException e){
|
||||
BungeeCore.log("Could not read JSON", e);
|
||||
}
|
||||
|
||||
Utils.handleMods(player, mods);
|
||||
}
|
||||
|
||||
private VarString readString(byte[] array, int startPos){
|
||||
Utils.VarInt varInt = Utils.readVarInt(array, startPos);
|
||||
startPos += varInt.length;
|
||||
return new VarString(varInt.value+varInt.length, new String(Arrays.copyOfRange(array, startPos, startPos + varInt.value), StandardCharsets.UTF_8));
|
||||
}
|
||||
|
||||
private void updateGameInfo(ProxiedPlayer proxiedPlayer) {
|
||||
JsonObject obj = new JsonObject();
|
||||
obj.addProperty("hasGame", true);
|
||||
obj.addProperty("game_mode", "steamwar.de");
|
||||
obj.addProperty("game_startTime", 0);
|
||||
obj.addProperty("game_endTime", 0);
|
||||
String output = "{ \"hasGame\" : \"true\", \"game_mode\" : \"steamwar.de\", \"game_startTime\" : \"0\", \"game_endTime\" : \"0\" }";
|
||||
|
||||
proxiedPlayer.sendData("LMC", output.getBytes());
|
||||
}
|
||||
|
||||
private static class VarString{
|
||||
private final int length;
|
||||
private final String value;
|
||||
|
||||
private VarString(int length, String value) {
|
||||
this.length = length;
|
||||
this.value = value;
|
||||
}
|
||||
}
|
||||
|
||||
private static class InfoPacket{
|
||||
String version = null;
|
||||
Feature ccp = null;
|
||||
Feature shadow = null;
|
||||
List<Addon> addons = new LinkedList<>();
|
||||
|
||||
InfoPacket(String input) throws IOException {
|
||||
JsonReader reader = new JsonReader(new StringReader(input));
|
||||
reader.beginObject();
|
||||
while(reader.hasNext()){
|
||||
String name = reader.nextName();
|
||||
switch(name){
|
||||
case "version":
|
||||
version = reader.nextString();
|
||||
break;
|
||||
case "ccp":
|
||||
ccp = new Feature(reader);
|
||||
break;
|
||||
case "shadow":
|
||||
shadow = new Feature(reader);
|
||||
break;
|
||||
case "addons":
|
||||
reader.beginArray();
|
||||
while(reader.hasNext()){
|
||||
addons.add(new Addon(reader));
|
||||
}
|
||||
reader.endArray();
|
||||
break;
|
||||
default:
|
||||
reader.skipValue();
|
||||
}
|
||||
}
|
||||
reader.endObject();
|
||||
reader.close();
|
||||
}
|
||||
|
||||
static class Addon{
|
||||
UUID uuid = null;
|
||||
String name = null;
|
||||
|
||||
Addon(JsonReader reader) throws IOException {
|
||||
reader.beginObject();
|
||||
while(reader.hasNext()){
|
||||
String n = reader.nextName();
|
||||
if(n.equals("uuid"))
|
||||
try{
|
||||
uuid = UUID.fromString(reader.nextString());
|
||||
}catch(IllegalArgumentException ignored){
|
||||
//ignored
|
||||
}
|
||||
else if(n.equals("name"))
|
||||
name = reader.nextString();
|
||||
else
|
||||
reader.skipValue();
|
||||
}
|
||||
reader.endObject();
|
||||
}
|
||||
}
|
||||
|
||||
static class Feature{
|
||||
boolean enabled;
|
||||
int version;
|
||||
|
||||
Feature(JsonReader reader) throws IOException {
|
||||
reader.beginObject();
|
||||
while(reader.hasNext()){
|
||||
String name = reader.nextName();
|
||||
if(name.equals("version"))
|
||||
version = reader.nextInt();
|
||||
else if(name.equals("enabled"))
|
||||
enabled = reader.nextBoolean();
|
||||
else
|
||||
reader.skipValue();
|
||||
}
|
||||
reader.endObject();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
87
src/de/steamwar/bungeecore/listeners/mods/ModLoaderBlocker.java
Normale Datei
87
src/de/steamwar/bungeecore/listeners/mods/ModLoaderBlocker.java
Normale Datei
@ -0,0 +1,87 @@
|
||||
/*
|
||||
This file is a part of the SteamWar software.
|
||||
|
||||
Copyright (C) 2020 SteamWar.de-Serverteam
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bungeecore.listeners.mods;
|
||||
|
||||
import de.steamwar.bungeecore.*;
|
||||
import de.steamwar.bungeecore.listeners.BasicListener;
|
||||
import net.md_5.bungee.api.connection.Connection;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
import net.md_5.bungee.api.event.PlayerDisconnectEvent;
|
||||
import net.md_5.bungee.api.event.PluginMessageEvent;
|
||||
import net.md_5.bungee.api.event.ServerSwitchEvent;
|
||||
import net.md_5.bungee.event.EventHandler;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public class ModLoaderBlocker extends BasicListener {
|
||||
|
||||
private static final Set<String> BLOCKED_SERVER = new HashSet<>();
|
||||
|
||||
@EventHandler
|
||||
public void onPluginMessageEvent(PluginMessageEvent e){
|
||||
Connection sender = e.getSender();
|
||||
if(!(sender instanceof ProxiedPlayer))
|
||||
return;
|
||||
|
||||
ProxiedPlayer p = (ProxiedPlayer) sender;
|
||||
if (e.getTag().equals("lunarclient:pm")) {
|
||||
p.disconnect(Message.parseToComponent("MOD_LOADER_LUNAR_CLIENT", false, p));
|
||||
return;
|
||||
}
|
||||
|
||||
if(!e.getTag().equals("minecraft:brand"))
|
||||
return;
|
||||
|
||||
String brand = new String(e.getData());
|
||||
if(brand.contains("fabric") || brand.contains("quilt") || brand.contains("LiteLoader")){
|
||||
if (!Storage.fabricCheckedPlayers.containsKey(p)) {
|
||||
Storage.fabricPlayers.add(p);
|
||||
}
|
||||
} else if (brand.contains("lunar")) {
|
||||
p.disconnect(Message.parseToComponent("MOD_LOADER_LUNAR_CLIENT", false, p));
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onDisconnect(PlayerDisconnectEvent e){
|
||||
Fabric.remove(e.getPlayer());
|
||||
Storage.fabricPlayers.remove(e.getPlayer());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onServerSwitch(ServerSwitchEvent event) {
|
||||
if(((Subserver.getSubserver(event.getPlayer()) != null
|
||||
&& Subserver.getSubserver(event.getPlayer()).getType() == Servertype.ARENA)
|
||||
|| BLOCKED_SERVER.contains(event.getPlayer().getServer().getInfo().getName()))
|
||||
&& isFabric(event.getPlayer())) {
|
||||
event.getPlayer().connect(BungeeCore.get().getProxy().getServerInfo(BungeeCore.LOBBY_SERVER));
|
||||
Message.send("MODLOADER_DENIED", event.getPlayer());
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isFabric(ProxiedPlayer player) {
|
||||
return Storage.fabricPlayers.contains(player);
|
||||
}
|
||||
|
||||
public static void addServer(String server) {
|
||||
BLOCKED_SERVER.add(server);
|
||||
}
|
||||
}
|
117
src/de/steamwar/bungeecore/listeners/mods/Utils.java
Normale Datei
117
src/de/steamwar/bungeecore/listeners/mods/Utils.java
Normale Datei
@ -0,0 +1,117 @@
|
||||
/*
|
||||
This file is a part of the SteamWar software.
|
||||
|
||||
Copyright (C) 2020 SteamWar.de-Serverteam
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bungeecore.listeners.mods;
|
||||
|
||||
import de.steamwar.bungeecore.BungeeCore;
|
||||
import de.steamwar.bungeecore.Message;
|
||||
import de.steamwar.bungeecore.commands.PunishmentCommand;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import de.steamwar.messages.ChatSender;
|
||||
import de.steamwar.sql.Mod;
|
||||
import de.steamwar.sql.Mod.ModType;
|
||||
import de.steamwar.sql.UserPerm;
|
||||
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 java.sql.Timestamp;
|
||||
import java.time.Instant;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.*;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.logging.Level;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class Utils {
|
||||
|
||||
public static final Map<UUID,List<Mod>> playerModMap = new HashMap<>();
|
||||
|
||||
private Utils(){}
|
||||
|
||||
static VarInt readVarInt(byte[] array, int startPos) {
|
||||
int numRead = 0;
|
||||
int result = 0;
|
||||
byte read;
|
||||
do {
|
||||
read = array[startPos + numRead];
|
||||
int value = (read & 0b01111111);
|
||||
result |= (value << (7 * numRead));
|
||||
|
||||
numRead++;
|
||||
if (numRead > 5) {
|
||||
break;
|
||||
}
|
||||
} while ((read & 0b10000000) != 0);
|
||||
|
||||
return new VarInt(numRead, result);
|
||||
}
|
||||
|
||||
static boolean handleMods(ProxiedPlayer player, List<Mod> mods) {
|
||||
return handleMods(player.getUniqueId(), ChatSender.of(player).getLocale(), player::disconnect, mods);
|
||||
}
|
||||
|
||||
static boolean handleMods(UUID uuid, Locale locale, Consumer<BaseComponent[]> disconnect, List<Mod> mods){
|
||||
SteamwarUser user = SteamwarUser.get(uuid);
|
||||
playerModMap.put(uuid,new ArrayList<>(mods));
|
||||
|
||||
ModType max = ModType.YELLOW;
|
||||
Iterator<Mod> it = mods.iterator();
|
||||
while(it.hasNext()){
|
||||
Mod mod = it.next();
|
||||
if(mod.getModType() == ModType.UNKLASSIFIED || mod.getModType() == ModType.GREEN || (mod.getModType() == ModType.YOUTUBER_ONLY && user.hasPerm(UserPerm.RESTRICTED_MODS)))
|
||||
it.remove();
|
||||
else if(mod.getModType() == ModType.RED)
|
||||
max = ModType.RED;
|
||||
}
|
||||
|
||||
if(mods.isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
ModType finalMax = max;
|
||||
String modList = mods.stream().filter(mod -> finalMax == ModType.YELLOW || mod.getModType() == ModType.RED).map(Mod::getModName).collect(Collectors.joining("\n"));
|
||||
String message;
|
||||
|
||||
if(mods.size() == 1) {
|
||||
message = Message.parse(max == ModType.RED ? "MOD_RED_SING" : "MOD_YELLOW_SING", locale, modList);
|
||||
} else {
|
||||
message = Message.parse(max == ModType.RED ? "MOD_RED_PLUR" : "MOD_YELLOW_PLUR", locale, modList);
|
||||
}
|
||||
|
||||
if(max == ModType.RED) {
|
||||
PunishmentCommand.ban(user, Timestamp.from(Instant.now().plus(7, ChronoUnit.DAYS)), message, SteamwarUser.get(-1), false);
|
||||
BungeeCore.log(Level.SEVERE, user.getUserName() + " " + user.getId() + " wurde automatisch wegen der Mods " + modList + " gebannt.");
|
||||
}
|
||||
|
||||
disconnect.accept(TextComponent.fromLegacyText(message));
|
||||
return false;
|
||||
}
|
||||
|
||||
static class VarInt{
|
||||
final int length;
|
||||
final int value;
|
||||
|
||||
VarInt(int length, int value){
|
||||
this.length = length;
|
||||
this.value = value;
|
||||
}
|
||||
}
|
||||
}
|
33
src/de/steamwar/bungeecore/listeners/mods/WorldDownloader.java
Normale Datei
33
src/de/steamwar/bungeecore/listeners/mods/WorldDownloader.java
Normale Datei
@ -0,0 +1,33 @@
|
||||
package de.steamwar.bungeecore.listeners.mods;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Sets;
|
||||
import de.steamwar.bungeecore.listeners.BasicListener;
|
||||
import de.steamwar.sql.Mod;
|
||||
import net.md_5.bungee.api.connection.Connection;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
import net.md_5.bungee.api.event.PluginMessageEvent;
|
||||
import net.md_5.bungee.event.EventHandler;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
|
||||
public class WorldDownloader extends BasicListener {
|
||||
|
||||
private static final Set<String> wdlTags = Collections.unmodifiableSet(
|
||||
Sets.newHashSet("WDL|INIT", "wdl:init", "WDL|REQUEST", "wdl:request")
|
||||
);
|
||||
|
||||
@EventHandler
|
||||
public void onPluginMessageEvent(PluginMessageEvent event){
|
||||
if(!wdlTags.contains(event.getTag()))
|
||||
return;
|
||||
|
||||
Connection sender = event.getSender();
|
||||
if(!(sender instanceof ProxiedPlayer))
|
||||
return;
|
||||
|
||||
event.setCancelled(true);
|
||||
Utils.handleMods((ProxiedPlayer) sender, Lists.newArrayList(Mod.getOrCreate("wdl", Mod.Platform.FORGE)));
|
||||
}
|
||||
}
|
32
src/de/steamwar/bungeecore/listeners/ping/PingListener.java
Normale Datei
32
src/de/steamwar/bungeecore/listeners/ping/PingListener.java
Normale Datei
@ -0,0 +1,32 @@
|
||||
/*
|
||||
This file is a part of the SteamWar software.
|
||||
|
||||
Copyright (C) 2022 SteamWar.de-Serverteam
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bungeecore.listeners.ping;
|
||||
|
||||
import de.steamwar.bungeecore.listeners.BasicListener;
|
||||
import net.md_5.bungee.api.event.ProxyPingEvent;
|
||||
import net.md_5.bungee.event.EventHandler;
|
||||
|
||||
public class PingListener extends BasicListener {
|
||||
|
||||
@EventHandler
|
||||
public void onPing(ProxyPingEvent event) {
|
||||
event.setResponse(new SteamWarServerPing(event.getResponse(), event.getConnection().getVersion()));
|
||||
}
|
||||
}
|
90
src/de/steamwar/bungeecore/listeners/ping/SteamWarServerPing.java
Normale Datei
90
src/de/steamwar/bungeecore/listeners/ping/SteamWarServerPing.java
Normale Datei
@ -0,0 +1,90 @@
|
||||
/*
|
||||
This file is a part of the SteamWar software.
|
||||
|
||||
Copyright (C) 2022 SteamWar.de-Serverteam
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bungeecore.listeners.ping;
|
||||
|
||||
import net.md_5.bungee.api.ServerPing;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class SteamWarServerPing extends ServerPing {
|
||||
|
||||
private final boolean preventsChatReports = true;
|
||||
private final ForgeData forgeData;
|
||||
|
||||
public SteamWarServerPing(ServerPing existing, int version) {
|
||||
super(existing.getVersion(), existing.getPlayers(), existing.getDescriptionComponent(), existing.getFaviconObject());
|
||||
forgeData = new ForgeData(version);
|
||||
}
|
||||
|
||||
private static class ForgeData {
|
||||
private final List<ForgeChannel> channels = new ArrayList<>();
|
||||
private final List<ForgeMod> mods = new ArrayList<>();
|
||||
private final int fmlNetworkVersion = 2;
|
||||
|
||||
public ForgeData(int versionNumber) {
|
||||
channels.add(new ForgeChannel("minecraft:unregister"));
|
||||
channels.add(new ForgeChannel("minecraft:register"));
|
||||
channels.add(new ForgeChannel("fml:handshake"));
|
||||
mods.add(new ForgeMod("minecraft", ProtocolVersion.getVersion(versionNumber)));
|
||||
mods.add(new ForgeMod("forge", "ANY"));
|
||||
}
|
||||
|
||||
public final static class ProtocolVersion {
|
||||
|
||||
private static final HashMap<Integer, String> versions;
|
||||
|
||||
static {
|
||||
versions = new HashMap();
|
||||
versions.put(757, "1.18");
|
||||
versions.put(756, "1.17.1");
|
||||
versions.put(754, "1.16.5");
|
||||
versions.put(578, "1.15.2");
|
||||
versions.put(498, "1.14.1");
|
||||
versions.put(393, "1.13");
|
||||
}
|
||||
|
||||
public static String getVersion(int version) {
|
||||
return versions.get(version);
|
||||
}
|
||||
}
|
||||
|
||||
private static class ForgeChannel {
|
||||
private final String res;
|
||||
private final String version = "FML2";
|
||||
private final boolean required = true;
|
||||
|
||||
private ForgeChannel(String res) {
|
||||
this.res = res;
|
||||
}
|
||||
}
|
||||
|
||||
private static class ForgeMod {
|
||||
private final String modId;
|
||||
private final String modmarker;
|
||||
|
||||
private ForgeMod(String modId, String modmarker) {
|
||||
this.modId = modId;
|
||||
this.modmarker = modmarker;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,59 +0,0 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2024 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bungeecore.mods;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import com.velocitypowered.api.event.Subscribe;
|
||||
import com.velocitypowered.api.event.connection.PostLoginEvent;
|
||||
import com.velocitypowered.api.proxy.messages.MinecraftChannelIdentifier;
|
||||
import de.steamwar.bungeecore.util.annotations.Create;
|
||||
|
||||
@Create
|
||||
public class Badlion {
|
||||
// https://github.com/BadlionClient/BadlionClientModAPI
|
||||
|
||||
private final byte[] packet;
|
||||
|
||||
public Badlion() { //TODO check if working or (json) modsDisallowed wrapper necessary
|
||||
JsonObject disabled = new JsonObject();
|
||||
disabled.addProperty("disabled", true);
|
||||
|
||||
JsonObject json = new JsonObject();
|
||||
json.add("Clear Glass", disabled);
|
||||
json.add("ClearWater", disabled);
|
||||
json.add("FOV Changer", disabled);
|
||||
json.add("Hitboxes", disabled);
|
||||
json.add("LevelHead", disabled);
|
||||
json.add("MiniMap", disabled);
|
||||
json.add("MLG Cobweb", disabled);
|
||||
json.add("Replay", disabled); //TODO check if ReplayMod restrictions work
|
||||
json.add("Schematica", disabled);
|
||||
json.add("ToggleSneak", disabled);
|
||||
json.add("ToggleSprint", disabled);
|
||||
json.add("TNT Time", disabled);
|
||||
|
||||
packet = json.toString().getBytes();
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onPostLogin(PostLoginEvent event) {
|
||||
event.getPlayer().sendPluginMessage(MinecraftChannelIdentifier.from("badlion:mods"), packet);
|
||||
}
|
||||
}
|
@ -1,54 +0,0 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2024 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bungeecore.mods;
|
||||
|
||||
import com.velocitypowered.api.proxy.Player;
|
||||
import com.velocitypowered.api.proxy.messages.ChannelIdentifier;
|
||||
import com.velocitypowered.api.proxy.messages.MinecraftChannelIdentifier;
|
||||
import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
||||
import de.steamwar.bungeecore.listeners.PluginMessage;
|
||||
|
||||
public class Controlify {
|
||||
//https://modrinth.com/mod/controlify
|
||||
//https://github.com/isXander/Controlify/blob/1.20.x/dev/src/main/java/dev/isxander/controlify/server/ServerPolicyPacket.java
|
||||
//https://github.com/isXander/Controlify/blob/1.20.x/dev/src/main/java/dev/isxander/controlify/server/ServerPolicies.java
|
||||
|
||||
public static final ChannelIdentifier CHANNEL = MinecraftChannelIdentifier.from("controlify:server_policy");
|
||||
|
||||
private final byte[][] packets;
|
||||
public Controlify() {
|
||||
packets = new byte[][] {
|
||||
restrict("reachAround"),
|
||||
restrict("disableFlyDrifting")
|
||||
};
|
||||
}
|
||||
|
||||
private byte[] restrict(String name) {
|
||||
return PluginMessage.genBufPacket(buf -> {
|
||||
ProtocolUtils.writeString(buf, name);
|
||||
buf.writeBoolean(false);
|
||||
});
|
||||
}
|
||||
|
||||
public void onRegister(Player player) {
|
||||
for(byte[] packet : packets)
|
||||
player.sendPluginMessage(CHANNEL, packet);
|
||||
}
|
||||
}
|
@ -1,136 +0,0 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2024 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bungeecore.mods;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.velocitypowered.api.event.Subscribe;
|
||||
import com.velocitypowered.api.event.connection.ConnectionHandshakeEvent;
|
||||
import com.velocitypowered.api.event.connection.PluginMessageEvent;
|
||||
import com.velocitypowered.api.event.connection.PostLoginEvent;
|
||||
import com.velocitypowered.api.proxy.LoginPhaseConnection;
|
||||
import com.velocitypowered.api.proxy.Player;
|
||||
import com.velocitypowered.api.proxy.ProxyServer;
|
||||
import com.velocitypowered.api.proxy.messages.ChannelIdentifier;
|
||||
import com.velocitypowered.api.proxy.messages.MinecraftChannelIdentifier;
|
||||
import com.velocitypowered.proxy.connection.ConnectionType;
|
||||
import com.velocitypowered.proxy.connection.ConnectionTypes;
|
||||
import com.velocitypowered.proxy.connection.client.ConnectedPlayer;
|
||||
import com.velocitypowered.proxy.connection.client.InitialInboundConnection;
|
||||
import com.velocitypowered.proxy.connection.client.LoginInboundConnection;
|
||||
import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
||||
import com.velocitypowered.proxy.protocol.packet.HandshakePacket;
|
||||
import de.steamwar.bungeecore.VelocityCore;
|
||||
import de.steamwar.bungeecore.util.annotations.Create;
|
||||
import de.steamwar.sql.Mod;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import lombok.SneakyThrows;
|
||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@Create
|
||||
public class FML {
|
||||
// https://wiki.vg/Minecraft_Forge_Handshake#FML_protocol_.281.7_-_1.12.29
|
||||
|
||||
private static final Field delegateField;
|
||||
private static final Field handshakeField;
|
||||
|
||||
static {
|
||||
try {
|
||||
delegateField = LoginInboundConnection.class.getDeclaredField("delegate");
|
||||
handshakeField = InitialInboundConnection.class.getDeclaredField("handshake");
|
||||
} catch (NoSuchFieldException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private final ModUtils utils;
|
||||
private final ProxyServer proxyServer;
|
||||
private final VelocityCore core;
|
||||
|
||||
@Inject
|
||||
public FML(ModUtils utils, ProxyServer proxyServer, VelocityCore core) {
|
||||
this.utils = utils;
|
||||
this.proxyServer = proxyServer;
|
||||
this.core = core;
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
public static boolean isFML(LoginPhaseConnection connection, String type) {
|
||||
return handshakeField.get(delegateField.get(connection)) instanceof HandshakePacket packet && packet.getServerAddress().endsWith("\0" + type);
|
||||
}
|
||||
|
||||
public static final ChannelIdentifier CHANNEL = MinecraftChannelIdentifier.from("FML|HS");
|
||||
private final byte[] helloPacket = new byte[]{
|
||||
/* Packet type: ServerHello */ 0,
|
||||
/* FML protocol version */ 2,
|
||||
/* Override dimension (int) */ 0, 0, 0, 0
|
||||
};
|
||||
|
||||
private static final Set<UUID> unlocked = new HashSet<>();
|
||||
|
||||
@Subscribe
|
||||
public void onPostLogin(PostLoginEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
|
||||
synchronized (unlocked) {
|
||||
if(unlocked.contains(player.getUniqueId())){
|
||||
unlocked.remove(player.getUniqueId());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if(((ConnectedPlayer) event.getPlayer()).getConnection().getType() == ConnectionTypes.LEGACY_FORGE) {
|
||||
player.sendPluginMessage(CHANNEL, helloPacket);
|
||||
}
|
||||
}
|
||||
|
||||
public void handlePluginMessage(PluginMessageEvent event) {
|
||||
Player p = (Player) event.getSource();
|
||||
ByteBuf buf = Unpooled.wrappedBuffer(event.getData());
|
||||
|
||||
if (buf.readByte() == /* ModList */ 2) {
|
||||
int numMods = ProtocolUtils.readVarInt(buf);
|
||||
|
||||
List<Mod> mods = new ArrayList<>();
|
||||
for(int i = 0; i < numMods; i++) {
|
||||
String name = ProtocolUtils.readString(buf);
|
||||
ProtocolUtils.readString(buf); // version
|
||||
|
||||
mods.add(Mod.getOrCreate(name, Mod.Platform.FORGE));
|
||||
}
|
||||
|
||||
if (utils.handleMods(p, mods)) {
|
||||
synchronized (unlocked) {
|
||||
unlocked.add(p.getUniqueId());
|
||||
}
|
||||
p.disconnect(LegacyComponentSerializer.legacySection().deserialize("§7Deine installierten Mods wurden überprüft\n§aDu kannst nun §eSteam§8War §abetreten"));
|
||||
proxyServer.getScheduler().buildTask(core, () -> {
|
||||
synchronized (unlocked) {
|
||||
unlocked.remove(p.getUniqueId());
|
||||
}
|
||||
}).delay(30, TimeUnit.SECONDS);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,183 +0,0 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2024 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bungeecore.mods;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.velocitypowered.api.event.Subscribe;
|
||||
import com.velocitypowered.api.event.connection.PreLoginEvent;
|
||||
import com.velocitypowered.api.proxy.LoginPhaseConnection;
|
||||
import com.velocitypowered.api.proxy.messages.MinecraftChannelIdentifier;
|
||||
import com.velocitypowered.proxy.connection.client.LoginInboundConnection;
|
||||
import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
||||
import com.velocitypowered.proxy.protocol.StateRegistry;
|
||||
import de.steamwar.bungeecore.VelocityCore;
|
||||
import de.steamwar.bungeecore.listeners.IPSanitizer;
|
||||
import de.steamwar.bungeecore.listeners.PluginMessage;
|
||||
import de.steamwar.bungeecore.util.annotations.Create;
|
||||
import de.steamwar.sql.Mod;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.logging.Level;
|
||||
|
||||
@Create
|
||||
public class FML2 {
|
||||
|
||||
protected final ModUtils modUtils;
|
||||
// FML2: https://wiki.vg/Minecraft_Forge_Handshake#FML2_protocol_.281.13_-_Current.29
|
||||
// FML3: https://github.com/adde0109/Ambassador/tree/non-api/src/main/java/org/adde0109/ambassador/forge
|
||||
|
||||
// FORGE: https://github.com/MinecraftForge/MinecraftForge/blob/1.20.x/src/main/java/net/minecraftforge/network/NetworkInitialization.java
|
||||
// FORGE: https://github.com/MinecraftForge/MinecraftForge/blob/1.20.x/src/main/java/net/minecraftforge/network/ForgePacketHandler.java
|
||||
// FORGE: https://github.com/MinecraftForge/MinecraftForge/blob/1.20.x/src/main/java/net/minecraftforge/network/packets/ModVersions.java
|
||||
|
||||
private final byte[] fml2ModListPacket;
|
||||
private final byte[] fml3ModListPacket;
|
||||
private final byte[] forgeModListPacket;
|
||||
|
||||
@Inject
|
||||
public FML2(ModUtils modUtils) {
|
||||
this.modUtils = modUtils;
|
||||
fml2ModListPacket = generateModListPacket(false);
|
||||
fml3ModListPacket = generateModListPacket(true);
|
||||
forgeModListPacket = PluginMessage.genBufPacket(buf -> {
|
||||
buf.writeByte(0); // Login wrapper packet
|
||||
ProtocolUtils.writeString(buf, "forge:handshake");
|
||||
|
||||
ByteBuf packet = Unpooled.buffer();
|
||||
packet.writeByte(1); // Mod list packet
|
||||
ProtocolUtils.writeVarInt(packet, 0); // Mod amount
|
||||
|
||||
ProtocolUtils.writeVarInt(buf, packet.readableBytes());
|
||||
buf.writeBytes(packet);
|
||||
});
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onLogin(PreLoginEvent event) {
|
||||
LoginInboundConnection connection = (LoginInboundConnection) event.getConnection();
|
||||
|
||||
boolean fml2 = FML.isFML(connection, "FML2\0");
|
||||
boolean fml3 = FML.isFML(connection, "FML3\0");
|
||||
boolean forge = FML.isFML(connection, "FORGE");
|
||||
if(!fml2 && !fml3 && !forge)
|
||||
return;
|
||||
|
||||
FML2LoginHandler handler = new FML2LoginHandler(connection, event.getUniqueId(), forge);
|
||||
|
||||
if(forge) {
|
||||
((LoginInboundConnection) event.getConnection()).sendLoginPluginMessage(MinecraftChannelIdentifier.from("forge:login"), forgeModListPacket, handler);
|
||||
} else {
|
||||
((LoginInboundConnection) event.getConnection()).sendLoginPluginMessage(MinecraftChannelIdentifier.from("fml:loginwrapper"), fml3 ? fml3ModListPacket : fml2ModListPacket, handler);
|
||||
}
|
||||
}
|
||||
|
||||
private byte[] generateModListPacket(boolean fml3) {
|
||||
return PluginMessage.genBufPacket(buf -> {
|
||||
ProtocolUtils.writeString(buf, "fml:handshake");
|
||||
|
||||
ByteBuf packet = Unpooled.buffer();
|
||||
packet.writeByte(1); // Mod list packet
|
||||
ProtocolUtils.writeVarInt(packet, 0); // Mod amount
|
||||
|
||||
if(fml3) {
|
||||
ProtocolUtils.writeVarInt(packet,1); // Channel amount
|
||||
ProtocolUtils.writeString(packet, "forge:tier_sorting");
|
||||
ProtocolUtils.writeString(packet, "1.0");
|
||||
} else {
|
||||
ProtocolUtils.writeVarInt(packet, 0); // Channel amount
|
||||
}
|
||||
|
||||
ProtocolUtils.writeVarInt(packet, 0); // Registries amount
|
||||
if(fml3)
|
||||
ProtocolUtils.writeVarInt(packet, 0); // DataPacks amount
|
||||
|
||||
ProtocolUtils.writeVarInt(buf, packet.readableBytes());
|
||||
buf.writeBytes(packet);
|
||||
});
|
||||
}
|
||||
|
||||
private class FML2LoginHandler implements LoginPhaseConnection.MessageConsumer {
|
||||
private final LoginInboundConnection connection;
|
||||
private final UUID uuid;
|
||||
private final boolean forge;
|
||||
|
||||
private FML2LoginHandler(LoginInboundConnection connection, UUID uuid, boolean forge) {
|
||||
this.connection = connection;
|
||||
this.uuid = uuid;
|
||||
this.forge = forge;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "SteamWar Forge Handler";
|
||||
}
|
||||
|
||||
private void abort(byte[] response, String error) {
|
||||
|
||||
VelocityCore.get().getLogger().log(Level.SEVERE, () -> error + "\n" + Base64.getEncoder().encodeToString(response));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMessageResponse(byte @Nullable [] data) {
|
||||
if(data == null) {
|
||||
abort(null, "Not FML2/3 client");
|
||||
return;
|
||||
}
|
||||
|
||||
ByteBuf buf = Unpooled.wrappedBuffer(data);
|
||||
if(forge && buf.readByte() != 0) {
|
||||
abort(data, "Not FORGE login wrapper");
|
||||
return;
|
||||
}
|
||||
|
||||
if(!ProtocolUtils.readString(buf).equals(forge ? "forge:handshake" : "fml:handshake")) {
|
||||
abort(data, "Not FML2/3/FORGE handshake response");
|
||||
return;
|
||||
}
|
||||
|
||||
if(ProtocolUtils.readVarInt(buf) != buf.readableBytes()) {
|
||||
abort(data, "FML2/3/FORGE packet size mismatch");
|
||||
return;
|
||||
}
|
||||
|
||||
if(ProtocolUtils.readVarInt(buf) != (forge ? /* Mod Versions */ 1 : /* Mod List Reply */ 2)) {
|
||||
abort(data, "Not FML2/3/FORGE mod list reply");
|
||||
return;
|
||||
}
|
||||
|
||||
List<Mod> mods = new ArrayList<>();
|
||||
|
||||
int modCount = ProtocolUtils.readVarInt(buf);
|
||||
for(int i = 0; i < modCount; i++) {
|
||||
mods.add(Mod.getOrCreate(ProtocolUtils.readString(buf), Mod.Platform.FORGE));
|
||||
|
||||
if(forge) {
|
||||
ProtocolUtils.readString(buf); // Human readable name
|
||||
ProtocolUtils.readString(buf); // Version
|
||||
}
|
||||
}
|
||||
|
||||
modUtils.handleMods(uuid, Locale.getDefault(), connection::disconnect, mods);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,156 +0,0 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2024 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bungeecore.mods;
|
||||
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonParser;
|
||||
import com.google.inject.Inject;
|
||||
import com.velocitypowered.api.event.Subscribe;
|
||||
import com.velocitypowered.api.event.connection.DisconnectEvent;
|
||||
import com.velocitypowered.api.event.connection.PluginMessageEvent;
|
||||
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.ProxyServer;
|
||||
import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
||||
import de.steamwar.bungeecore.VelocityCore;
|
||||
import de.steamwar.bungeecore.Storage;
|
||||
import de.steamwar.bungeecore.util.annotations.Create;
|
||||
import de.steamwar.sql.Mod;
|
||||
import de.steamwar.sql.SWException;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@Create
|
||||
public class FabricModSender {
|
||||
|
||||
private final ModUtils utils;
|
||||
private final ProxyServer proxyServer;
|
||||
private final VelocityCore core;
|
||||
|
||||
private final Set<String> neededFabricMods = new HashSet<>();
|
||||
private final Set<String> neededQuiltMods = new HashSet<>();
|
||||
|
||||
@Inject
|
||||
public FabricModSender(ModUtils utils, ProxyServer proxyServer, VelocityCore core) {
|
||||
this.utils = utils;
|
||||
this.proxyServer = proxyServer;
|
||||
this.core = core;
|
||||
neededFabricMods.add("java");
|
||||
neededFabricMods.add("minecraft");
|
||||
neededFabricMods.add("steamwarmodsender");
|
||||
neededQuiltMods.addAll(neededFabricMods);
|
||||
|
||||
neededFabricMods.add("fabricloader");
|
||||
neededQuiltMods.add("quilt_loader");
|
||||
|
||||
proxyServer.getScheduler().buildTask(VelocityCore.get(), () -> {
|
||||
synchronized (Storage.fabricExpectPluginMessage) {
|
||||
for (Map.Entry<Player, Long> entry : Storage.fabricExpectPluginMessage.entrySet()) {
|
||||
if (!Storage.fabricCheckedPlayers.containsKey(entry.getKey())) {
|
||||
continue;
|
||||
}
|
||||
if (System.currentTimeMillis() - entry.getValue() > TimeUnit.SECONDS.toMillis(20)) {
|
||||
Storage.fabricExpectPluginMessage.remove(entry.getKey());
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}).repeat(1, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
public void handlePluginMessage(PluginMessageEvent e){
|
||||
Player player = (Player) e.getSource();
|
||||
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
||||
|
||||
if (!Storage.fabricCheckedPlayers.containsKey(player)) {
|
||||
synchronized (Storage.fabricExpectPluginMessage) {
|
||||
if (Storage.fabricExpectPluginMessage.containsKey(player)) {
|
||||
logMessage(user, "Was not fabric checked but send message nonetheless", Arrays.toString(e.getData()));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
Storage.fabricExpectPluginMessage.remove(player);
|
||||
|
||||
List<Mod> mods = new ArrayList<>();
|
||||
|
||||
ByteBuf buf = Unpooled.wrappedBuffer(e.getData());
|
||||
String data = ProtocolUtils.readString(buf, 1024*1024);
|
||||
if(buf.readableBytes() > 0) {
|
||||
logMessage(user, "Invalid message length", Arrays.toString(e.getData()));
|
||||
return;
|
||||
}
|
||||
|
||||
JsonArray array = JsonParser.parseString(data).getAsJsonArray();
|
||||
|
||||
for(JsonElement mod : array) {
|
||||
mods.add(Mod.getOrCreate(mod.getAsString(), Mod.Platform.FABRIC));
|
||||
}
|
||||
|
||||
if(!neededModsContained(neededFabricMods, mods) && !neededModsContained(neededQuiltMods, mods)) {
|
||||
logMessage(user, "Needed mods are not contained", data);
|
||||
return;
|
||||
}
|
||||
|
||||
if(!utils.handleMods(player,mods))
|
||||
return;
|
||||
|
||||
if (!Storage.fabricCheckedPlayers.containsKey(player)) {
|
||||
Storage.fabricCheckedPlayers.put(player, data.hashCode());
|
||||
} else if (Storage.fabricCheckedPlayers.get(player) != data.hashCode()) {
|
||||
logMessage(user, "Mods changed during runtime", data);
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onServerSwitchEvent(ServerConnectedEvent e) {
|
||||
if (e.getPreviousServer().isEmpty()) return;
|
||||
synchronized (Storage.fabricExpectPluginMessage) {
|
||||
Storage.fabricExpectPluginMessage.put(e.getPlayer(), System.currentTimeMillis());
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onDisconnect(DisconnectEvent e) {
|
||||
Player player = e.getPlayer();
|
||||
|
||||
Storage.fabricCheckedPlayers.remove(player);
|
||||
synchronized (Storage.fabricExpectPluginMessage) {
|
||||
Storage.fabricExpectPluginMessage.remove(player);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean neededModsContained(Set<String> neededMods, List<Mod> mods) {
|
||||
return mods.stream()
|
||||
.map(Mod::getModName)
|
||||
.filter(neededMods::contains)
|
||||
.count() == neededFabricMods.size();
|
||||
}
|
||||
|
||||
private void logMessage(SteamwarUser user, String reason, String data) {
|
||||
SWException.log("FabricModSender " + user.getUserName() + ": " + reason, data);
|
||||
}
|
||||
}
|
@ -1,58 +0,0 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2024 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bungeecore.mods;
|
||||
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.velocitypowered.api.proxy.Player;
|
||||
import com.velocitypowered.api.proxy.messages.ChannelIdentifier;
|
||||
import com.velocitypowered.api.proxy.messages.MinecraftChannelIdentifier;
|
||||
|
||||
public class Feather {
|
||||
//https://github.com/Koupah/Feather-Client-API/blob/main/src/club/koupah/feather/packets/FeatherMod.java
|
||||
//https://archive.org/details/feather-server-api
|
||||
public static final ChannelIdentifier CHANNEL = MinecraftChannelIdentifier.from("feather:client");
|
||||
|
||||
private final byte[] packet;
|
||||
public Feather() {
|
||||
JsonArray array = new JsonArray();
|
||||
array.add("clearWater");
|
||||
array.add("coordinates");
|
||||
array.add("coordinates");
|
||||
array.add("hitbox");
|
||||
array.add("hypixel");
|
||||
array.add("reachDisplay");
|
||||
array.add("snaplook");
|
||||
array.add("toggleSprint");
|
||||
|
||||
JsonObject mods = new JsonObject();
|
||||
mods.add("mods", array);
|
||||
|
||||
JsonObject obj = new JsonObject();
|
||||
obj.addProperty("packetType", "DISABLE_MODS");
|
||||
obj.add("payload", mods);
|
||||
|
||||
packet = obj.toString().getBytes();
|
||||
}
|
||||
|
||||
public void sendRestrictions(Player player) {
|
||||
player.sendPluginMessage(CHANNEL, packet);
|
||||
}
|
||||
}
|
@ -1,56 +0,0 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2024 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bungeecore.mods;
|
||||
|
||||
import com.velocitypowered.api.event.Subscribe;
|
||||
import com.velocitypowered.api.event.proxy.ProxyPingEvent;
|
||||
import de.steamwar.bungeecore.VelocityCore;
|
||||
import de.steamwar.bungeecore.util.annotations.Create;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Level;
|
||||
|
||||
@Create
|
||||
public class Hostname {
|
||||
|
||||
private final Set<String> knownHostnames = new HashSet<>();
|
||||
|
||||
public Hostname() {
|
||||
knownHostnames.add("steamwar.de");
|
||||
knownHostnames.add("78.31.71.136");
|
||||
knownHostnames.add("memewar.de"); // Chaoscaot
|
||||
knownHostnames.add("dampfkrieg.de"); // Chaoscaot
|
||||
knownHostnames.add("127.0.0.1"); // Geyser
|
||||
|
||||
knownHostnames.add("@mat:matdoes.dev "); //https://github.com/mat-1/matscan
|
||||
knownHostnames.add("wtf.mynx.lol"); //https://discord.com/invite/serverseeker
|
||||
knownHostnames.add("masscan");
|
||||
knownHostnames.add("aaa");
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onHandshake(ProxyPingEvent event) {
|
||||
String hostname = event.getConnection().getVirtualHost().map(inetSocketAddress -> inetSocketAddress.getHostName()).orElse("");
|
||||
if (!knownHostnames.contains(hostname) && !hostname.endsWith(".steamwar.de")) {
|
||||
VelocityCore.get().getLogger().log(Level.WARNING, () -> event.getConnection().getRemoteAddress().toString() + " connected with unknown hostname '" + hostname + "'");
|
||||
}
|
||||
}
|
||||
}
|
@ -1,92 +0,0 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2024 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bungeecore.mods;
|
||||
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import com.velocitypowered.api.event.connection.PluginMessageEvent;
|
||||
import com.velocitypowered.api.proxy.Player;
|
||||
import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
||||
import de.steamwar.bungeecore.VelocityCore;
|
||||
import de.steamwar.bungeecore.listeners.PluginMessage;
|
||||
import de.steamwar.bungeecore.util.annotations.Create;
|
||||
import de.steamwar.sql.Mod;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
|
||||
@Create
|
||||
public class LabyMod {
|
||||
// https://docs.labymod.net/pages/server/introduction/
|
||||
// https://github.com/LabyMod/labymod-server-api
|
||||
// https://dl.labymod.net/addons.json
|
||||
|
||||
private final ModUtils utils;
|
||||
|
||||
private final byte[] gameInfoPacket;
|
||||
public LabyMod(ModUtils utils) {
|
||||
this.utils = utils;
|
||||
gameInfoPacket = PluginMessage.genBufPacket(buf -> {
|
||||
ProtocolUtils.writeString(buf, "discord_rpc");
|
||||
|
||||
JsonObject json = new JsonObject();
|
||||
json.addProperty("hasGame", true);
|
||||
json.addProperty("game_mode", "steamwar.de");
|
||||
json.addProperty("game_startTime", 0);
|
||||
json.addProperty("game_endTime", 0);
|
||||
ProtocolUtils.writeString(buf, json.toString());
|
||||
});
|
||||
}
|
||||
|
||||
public void handlePluginMessage(PluginMessageEvent event) {
|
||||
Player player = (Player) event.getSource();
|
||||
player.sendPluginMessage(event.getIdentifier(), gameInfoPacket);
|
||||
|
||||
ByteBuf buf = Unpooled.wrappedBuffer(event.getData());
|
||||
String purpose = ProtocolUtils.readString(buf);
|
||||
if(!"INFO".equals(purpose))
|
||||
return;
|
||||
|
||||
JsonObject message = JsonParser.parseString(ProtocolUtils.readString(buf)).getAsJsonObject();
|
||||
List<Mod> mods = new LinkedList<>();
|
||||
|
||||
if(message.has("addons")) {
|
||||
for(JsonElement element : message.getAsJsonArray("addons")) {
|
||||
JsonObject addon = element.getAsJsonObject();
|
||||
mods.add(Mod.getOrCreate(addon.get("name").getAsString(), Mod.Platform.LABYMOD));
|
||||
}
|
||||
}
|
||||
|
||||
if(message.has("mods")) {
|
||||
VelocityCore.get().getLogger().log(Level.WARNING, () -> "LabyMod External Mods for debugging: " + message.getAsJsonArray("mods"));
|
||||
for(JsonElement element : message.getAsJsonArray("mods")) {
|
||||
JsonObject addon = element.getAsJsonObject();
|
||||
//TODO observe: FORGE and FABRIC mods available, do they always and with .jar? (would equal new mod platform)
|
||||
//mods.add(Mod.getOrCreate(addon.get("name").getAsString().replace(".jar", ""), Mod.Platform.FORGE));
|
||||
}
|
||||
}
|
||||
|
||||
utils.handleMods(player, mods);
|
||||
}
|
||||
}
|
@ -1,142 +0,0 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2024 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bungeecore.mods;
|
||||
|
||||
import com.lunarclient.apollo.ApolloManager;
|
||||
import com.lunarclient.apollo.libs.protobuf.Any;
|
||||
import com.lunarclient.apollo.libs.protobuf.InvalidProtocolBufferException;
|
||||
import com.lunarclient.apollo.libs.protobuf.Message;
|
||||
import com.lunarclient.apollo.mods.impl.*;
|
||||
import com.lunarclient.apollo.module.ApolloModuleManager;
|
||||
import com.lunarclient.apollo.module.ApolloModuleManagerImpl;
|
||||
import com.lunarclient.apollo.module.modsetting.ModSettingModule;
|
||||
import com.lunarclient.apollo.network.NetworkOptions;
|
||||
import com.lunarclient.apollo.option.Options;
|
||||
import com.lunarclient.apollo.player.AbstractApolloPlayer;
|
||||
import com.lunarclient.apollo.player.v1.ModMessage;
|
||||
import com.lunarclient.apollo.player.v1.PlayerHandshakeMessage;
|
||||
import com.velocitypowered.api.event.connection.PluginMessageEvent;
|
||||
import com.velocitypowered.api.proxy.Player;
|
||||
import com.velocitypowered.api.proxy.messages.ChannelIdentifier;
|
||||
import com.velocitypowered.api.proxy.messages.MinecraftChannelIdentifier;
|
||||
import de.steamwar.bungeecore.VelocityCore;
|
||||
import de.steamwar.bungeecore.util.annotations.Create;
|
||||
import de.steamwar.sql.Mod;
|
||||
import lombok.AllArgsConstructor;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.logging.Level;
|
||||
|
||||
@Create
|
||||
public class Lunar {
|
||||
// https://lunarclient.dev/apollo/introduction
|
||||
// https://github.com/LunarClient/Apollo
|
||||
|
||||
private final ApolloModuleManager manager = new ApolloModuleManagerImpl().addModule(ModSettingModule.class);
|
||||
|
||||
private final ModUtils utils;
|
||||
|
||||
public Lunar(ModUtils utils) { //TODO seems defunct
|
||||
Options modSettings = manager.getModule(ModSettingModule.class).getOptions();
|
||||
modSettings.set(ModReplaymod.ENABLED, false); // TODO check if restrictions working
|
||||
modSettings.set(ModFreelook.ENABLED, false);
|
||||
modSettings.set(ModHypixelMod.ENABLED, false);
|
||||
modSettings.set(ModMinimap.ENABLED, false);
|
||||
modSettings.set(ModNametag.ENABLED, false);
|
||||
modSettings.set(ModTeamView.ENABLED, false);
|
||||
modSettings.set(ModTntCountdown.ENABLED, false);
|
||||
modSettings.set(ModToggleSneak.TOGGLE_SNEAK_CONTAINER, false);
|
||||
|
||||
this.utils = utils;
|
||||
}
|
||||
|
||||
public void sendRestrictions(Player player) {
|
||||
NetworkOptions.sendOptions(manager.getModules(), true, new SWApolloPlayer(player));
|
||||
}
|
||||
|
||||
public void handlePluginMessage(PluginMessageEvent event) {
|
||||
Player player = (Player) event.getSource();
|
||||
Any packet;
|
||||
|
||||
try {
|
||||
packet = Any.parseFrom(event.getData());
|
||||
} catch (InvalidProtocolBufferException e) {
|
||||
throw new SecurityException(e);
|
||||
}
|
||||
|
||||
handle(PlayerHandshakeMessage.class, packet, handshake -> {
|
||||
List<Mod> mods = new ArrayList<>();
|
||||
|
||||
for(ModMessage mod : handshake.getInstalledModsList()) {
|
||||
switch(mod.getType()) {
|
||||
case TYPE_FABRIC_INTERNAL:
|
||||
case TYPE_FORGE_INTERNAL:
|
||||
// Controlled with ModSettings
|
||||
break;
|
||||
case TYPE_FABRIC_EXTERNAL:
|
||||
mods.add(Mod.getOrCreate(mod.getName(), Mod.Platform.FABRIC));
|
||||
break;
|
||||
case TYPE_FORGE_EXTERNAL:
|
||||
mods.add(Mod.getOrCreate(mod.getName(), Mod.Platform.FORGE));
|
||||
break;
|
||||
case TYPE_UNSPECIFIED:
|
||||
case UNRECOGNIZED:
|
||||
default:
|
||||
VelocityCore.get().getLogger().log(Level.INFO, () -> player.getUsername() + " uses Lunar mod with unknown type " + mod);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
utils.handleMods(player, mods);
|
||||
});
|
||||
}
|
||||
|
||||
private <T extends Message> void handle(Class<T> type, Any packet, Consumer<T> handler) {
|
||||
try {
|
||||
handler.accept(packet.unpack(type));
|
||||
} catch (InvalidProtocolBufferException ignored) { /*ignored*/ }
|
||||
}
|
||||
|
||||
@AllArgsConstructor
|
||||
private static class SWApolloPlayer extends AbstractApolloPlayer {
|
||||
|
||||
private static final ChannelIdentifier CHANNEL = MinecraftChannelIdentifier.from(ApolloManager.PLUGIN_MESSAGE_CHANNEL);
|
||||
|
||||
private final Player player;
|
||||
|
||||
@Override
|
||||
public void sendPacket(Message message) {
|
||||
sendPacket(Any.pack(message).toByteArray());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendPacket(byte[] bytes) {
|
||||
player.sendPluginMessage(CHANNEL, bytes);
|
||||
}
|
||||
|
||||
@Override public UUID getUniqueId() { return player.getUniqueId(); }
|
||||
@Override public String getName() { return player.getUsername(); }
|
||||
@Override public boolean hasPermission(String s) { return player.hasPermission(s); }
|
||||
@Override public Object getPlayer() { return player; }
|
||||
}
|
||||
}
|
@ -1,101 +0,0 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2024 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bungeecore.mods;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.velocitypowered.api.proxy.Player;
|
||||
import de.steamwar.bungeecore.VelocityCore;
|
||||
import de.steamwar.bungeecore.Message;
|
||||
import de.steamwar.bungeecore.commands.PunishmentCommand;
|
||||
import de.steamwar.bungeecore.util.annotations.Create;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import de.steamwar.messages.ChatSender;
|
||||
import de.steamwar.sql.Mod;
|
||||
import de.steamwar.sql.Mod.ModType;
|
||||
import de.steamwar.sql.UserPerm;
|
||||
import lombok.Getter;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import java.time.Instant;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.*;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Create
|
||||
public class ModUtils {
|
||||
|
||||
private final Logger logger;
|
||||
|
||||
@Getter
|
||||
private final Map<UUID,List<Mod>> playerModMap = new HashMap<>();
|
||||
|
||||
@Inject
|
||||
public ModUtils(Logger logger) {
|
||||
this.logger = logger;
|
||||
}
|
||||
|
||||
public boolean handleMods(Player player, List<Mod> mods) {
|
||||
return handleMods(player.getUniqueId(), ChatSender.of(player).getLocale(), player::disconnect, mods);
|
||||
}
|
||||
|
||||
public boolean handleMods(UUID uuid, Locale locale, Consumer<Component> disconnect, List<Mod> mods){
|
||||
SteamwarUser user = SteamwarUser.get(uuid);
|
||||
playerModMap.put(uuid,new ArrayList<>(mods));
|
||||
VelocityCore.get().getLogger().log(Level.INFO, user.getUserName() + " declares mods: " + mods.stream().map(mod -> mod.getPlatform() + ":" + mod.getModName()).collect(Collectors.joining(" ")));
|
||||
|
||||
ModType max = ModType.YELLOW;
|
||||
Iterator<Mod> it = mods.iterator();
|
||||
while(it.hasNext()){
|
||||
Mod mod = it.next();
|
||||
if(mod.getModType() == ModType.UNKLASSIFIED || mod.getModType() == ModType.GREEN || (mod.getModType() == ModType.YOUTUBER_ONLY && user.hasPerm(UserPerm.RESTRICTED_MODS)))
|
||||
it.remove();
|
||||
else if(mod.getModType() == ModType.RED)
|
||||
max = ModType.RED;
|
||||
}
|
||||
|
||||
if(mods.isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
ModType finalMax = max;
|
||||
String modList = mods.stream().filter(mod -> finalMax == ModType.YELLOW || mod.getModType() == ModType.RED).map(Mod::getModName).collect(Collectors.joining("\n"));
|
||||
String message;
|
||||
|
||||
if(mods.size() == 1) {
|
||||
message = Message.parse(max == ModType.RED ? "MOD_RED_SING" : "MOD_YELLOW_SING", locale, modList);
|
||||
} else {
|
||||
message = Message.parse(max == ModType.RED ? "MOD_RED_PLUR" : "MOD_YELLOW_PLUR", locale, modList);
|
||||
}
|
||||
|
||||
if(max == ModType.RED) {
|
||||
PunishmentCommand.ban(user, Timestamp.from(Instant.now().plus(7, ChronoUnit.DAYS)), message, SteamwarUser.get(-1), false);
|
||||
logger.log(Level.SEVERE, user.getUserName() + " " + user.getId() + " wurde automatisch wegen der Mods " + modList + " gebannt.");
|
||||
}
|
||||
|
||||
disconnect.accept(LegacyComponentSerializer.legacySection().deserialize(message));
|
||||
return false;
|
||||
}
|
||||
}
|
@ -1,67 +0,0 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2024 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bungeecore.mods;
|
||||
|
||||
import de.steamwar.bungeecore.Bauserver;
|
||||
import de.steamwar.bungeecore.Builderserver;
|
||||
import de.steamwar.bungeecore.VelocityCore;
|
||||
import de.steamwar.bungeecore.Subserver;
|
||||
import de.steamwar.bungeecore.listeners.BasicListener;
|
||||
import de.steamwar.bungeecore.listeners.PluginMessage;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
import net.md_5.bungee.api.config.ServerInfo;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
import net.md_5.bungee.api.event.ServerSwitchEvent;
|
||||
import net.md_5.bungee.event.EventHandler;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public class ReplayMod extends BasicListener {
|
||||
// https://gist.github.com/Johni0702/2547c463e51f65f312cb
|
||||
// https://github.com/ReplayMod/replay-restrictions/blob/master/bungeecord/src/main/java/de/johni0702/replay/restrictions/BungeeCordPlugin.java
|
||||
// https://github.com/ReplayMod/ReplayMod/blob/stable/src/main/java/com/replaymod/core/utils/Restrictions.java
|
||||
|
||||
private final byte[] restrict;
|
||||
|
||||
public ReplayMod() {
|
||||
restrict = PluginMessage.genStreamPacket(out -> {
|
||||
for(String restriction : Arrays.asList("no_xray", "no_noclip", "only_first_person", "only_recording_player")) {
|
||||
byte[] bytes = restriction.getBytes();
|
||||
out.writeByte(bytes.length);
|
||||
out.write(bytes);
|
||||
out.writeBoolean(true); // restrict
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerJoin(ServerSwitchEvent event) {
|
||||
ProxiedPlayer player = event.getPlayer();
|
||||
ServerInfo server = player.getServer().getInfo();
|
||||
if(ProxyServer.getInstance().getServerInfo(VelocityCore.LOBBY_SERVER) == server)
|
||||
return;
|
||||
|
||||
Subserver subserver = Subserver.getSubserver(server);
|
||||
if(subserver instanceof Builderserver || (subserver instanceof Bauserver && ((Bauserver) subserver).getOwner().equals(player.getUniqueId())))
|
||||
return;
|
||||
|
||||
PluginMessage.send(player, "Replay|Restrict", "replaymod:restrict", restrict);
|
||||
}
|
||||
}
|
@ -1,40 +0,0 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2024 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bungeecore.mods;
|
||||
|
||||
import de.steamwar.bungeecore.listeners.BasicListener;
|
||||
import net.md_5.bungee.api.event.PostLoginEvent;
|
||||
import net.md_5.bungee.event.EventHandler;
|
||||
|
||||
public class Schematica extends BasicListener {
|
||||
// https://github.com/Lunatrius/SchematicaPlugin/blob/master/src/main/java/com/github/lunatrius/schematica/plugin/SchematicaPlugin.java
|
||||
|
||||
private final byte[] packet = new byte[] {
|
||||
/* ProtocolVersion? */ 0,
|
||||
/* PERM_PRINTER */ 1,
|
||||
/* PERM_SAVE */ 0,
|
||||
/* PERM_LOAD */ 1
|
||||
};
|
||||
|
||||
@EventHandler
|
||||
public void onPostLogin(PostLoginEvent event) {
|
||||
event.getPlayer().sendData("schematica", packet);
|
||||
}
|
||||
}
|
@ -1,86 +0,0 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2024 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bungeecore.mods;
|
||||
|
||||
import com.google.gson.*;
|
||||
import com.google.inject.Inject;
|
||||
import com.velocitypowered.api.proxy.ProxyServer;
|
||||
import com.velocitypowered.api.proxy.server.ServerPing;
|
||||
import de.steamwar.bungeecore.util.annotations.Create;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Type;
|
||||
|
||||
@Create
|
||||
public class ServerListPing {
|
||||
// https://github.com/Aizistral-Studios/No-Chat-Reports/discussions/206
|
||||
// https://github.com/Aizistral-Studios/No-Chat-Reports/wiki/How-to-Get-Safe-Server-Status
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private final ProxyServer proxyServer;
|
||||
|
||||
private static final String[] FIELDS_TO_OVERRIDE = new String[] {
|
||||
"PRE_1_16_PING_SERIALIZER",
|
||||
"PRE_1_20_3_PING_SERIALIZER",
|
||||
"MODERN_PING_SERIALIZER"
|
||||
};
|
||||
|
||||
@Inject
|
||||
public ServerListPing(ProxyServer proxyServer) {
|
||||
this.proxyServer = proxyServer;
|
||||
|
||||
try {
|
||||
for (String fieldName : FIELDS_TO_OVERRIDE) {
|
||||
Field field = proxyServer.getClass().getDeclaredField(fieldName);
|
||||
field.setAccessible(true);
|
||||
Object obj = field.get(null);
|
||||
if (obj instanceof Gson gsonOld) {
|
||||
Gson gsonNew = new GsonBuilder()
|
||||
.registerTypeAdapter(ServerPing.class, new ServerListPingSerializer(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);
|
||||
}
|
||||
}
|
||||
|
||||
private record ServerListPingSerializer(
|
||||
Gson gson) implements JsonSerializer<ServerPing>, JsonDeserializer<ServerPing> {
|
||||
|
||||
@Override
|
||||
public JsonElement serialize(ServerPing ping, Type type, JsonSerializationContext context) {
|
||||
JsonElement element = gson.toJsonTree(ping, type);
|
||||
|
||||
JsonObject object = element.getAsJsonObject();
|
||||
object.addProperty("preventsChatReports", true);
|
||||
|
||||
return element;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServerPing deserialize(JsonElement element, Type type, JsonDeserializationContext context) throws JsonParseException {
|
||||
return gson.fromJson(element, ServerPing.class);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,48 +0,0 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2024 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bungeecore.mods;
|
||||
|
||||
import com.velocitypowered.api.event.connection.PluginMessageEvent;
|
||||
import com.velocitypowered.api.proxy.Player;
|
||||
import de.steamwar.bungeecore.listeners.PluginMessage;
|
||||
|
||||
public class WorldDownloader {
|
||||
// https://wiki.vg/Plugin_channels/World_downloader
|
||||
// https://github.com/Pokechu22/WorldDownloader-Serverside-Companion
|
||||
// https://github.com/Pokechu22/WorldDownloader
|
||||
|
||||
private final byte[] controlPacket;
|
||||
|
||||
public WorldDownloader() {
|
||||
controlPacket = PluginMessage.genStreamPacket(out -> {
|
||||
out.writeInt(1); // basic data packet
|
||||
out.writeBoolean(false); // General download enabled
|
||||
out.writeInt(-1); // Save radius
|
||||
out.writeBoolean(false); // Chunk caching enabled
|
||||
out.writeBoolean(false); // Entity saving enabled
|
||||
out.writeBoolean(false); // Tile entity saving disabled
|
||||
out.writeBoolean(false); // Container saving disabled
|
||||
});
|
||||
}
|
||||
|
||||
public void handlePluginMessage(PluginMessageEvent event) {
|
||||
PluginMessage.send((Player) event.getSource(), "WDL|CONTROL", "wdl:control", controlPacket);
|
||||
}
|
||||
}
|
58
src/de/steamwar/bungeecore/network/NetworkReceiver.java
Normale Datei
58
src/de/steamwar/bungeecore/network/NetworkReceiver.java
Normale Datei
@ -0,0 +1,58 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2022 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bungeecore.network;
|
||||
|
||||
import de.steamwar.bungeecore.BungeeCore;
|
||||
import de.steamwar.bungeecore.commands.TeamCommand;
|
||||
import de.steamwar.bungeecore.listeners.BasicListener;
|
||||
import de.steamwar.sql.SWException;
|
||||
import de.steamwar.network.packets.NetworkPacket;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
import net.md_5.bungee.api.connection.Server;
|
||||
import net.md_5.bungee.api.event.PluginMessageEvent;
|
||||
import net.md_5.bungee.event.EventHandler;
|
||||
import net.md_5.bungee.event.EventPriority;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.Arrays;
|
||||
import java.util.Base64;
|
||||
import java.util.List;
|
||||
|
||||
public class NetworkReceiver extends BasicListener {
|
||||
|
||||
private static final List<String> blockedTags = Arrays.asList("bungeecord:main", "BungeeCord", "sw:bridge");
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onPluginMessage(PluginMessageEvent event) {
|
||||
if (blockedTags.contains(event.getTag()) && !TeamCommand.isLocalhost(((InetSocketAddress) event.getSender().getSocketAddress()).getAddress())) {
|
||||
SWException.log(((InetSocketAddress) event.getSender().getSocketAddress()).getHostString() + " tried to send a plugin message with tag " + event.getTag(), Base64.getEncoder().encodeToString(event.getData()));
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
if(!event.getTag().equals("sw:bridge"))
|
||||
return;
|
||||
|
||||
event.setCancelled(true);
|
||||
if(!(event.getSender() instanceof Server))
|
||||
return;
|
||||
|
||||
ProxyServer.getInstance().getScheduler().runAsync(BungeeCore.get(), () -> NetworkPacket.handle(new ServerMetaInfo(((Server) event.getSender()).getInfo()), event.getData()));
|
||||
}
|
||||
}
|
@ -19,22 +19,20 @@
|
||||
|
||||
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 lombok.SneakyThrows;
|
||||
import net.md_5.bungee.api.config.ServerInfo;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
|
||||
public class NetworkSender {
|
||||
|
||||
private static final ChannelIdentifier CHANNEL = MinecraftChannelIdentifier.create("sw", "bridge");
|
||||
|
||||
public static void send(Player player, NetworkPacket packet) {
|
||||
player.getCurrentServer().ifPresent(serverConnection -> send(serverConnection.getServer(), packet));
|
||||
@SneakyThrows
|
||||
public static void send(ProxiedPlayer player, NetworkPacket packet) {
|
||||
player.getServer().sendData("sw:bridge", packet.serialize());
|
||||
}
|
||||
|
||||
public static void send(RegisteredServer server, NetworkPacket packet) {
|
||||
server.sendPluginMessage(CHANNEL, packet.serialize());
|
||||
public static void send(ServerInfo serverInfo, NetworkPacket packet) {
|
||||
ProxiedPlayer player = serverInfo.getPlayers().iterator().next();
|
||||
send(player, packet);
|
||||
}
|
||||
}
|
||||
|
48
src/de/steamwar/bungeecore/network/SWScriptSyntaxForwarder.java
Normale Datei
48
src/de/steamwar/bungeecore/network/SWScriptSyntaxForwarder.java
Normale Datei
@ -0,0 +1,48 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2022 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bungeecore.network;
|
||||
|
||||
import de.steamwar.bungeecore.commands.TeamCommand;
|
||||
import de.steamwar.bungeecore.listeners.BasicListener;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
import net.md_5.bungee.api.connection.Server;
|
||||
import net.md_5.bungee.api.event.PluginMessageEvent;
|
||||
import net.md_5.bungee.event.EventHandler;
|
||||
import net.md_5.bungee.event.EventPriority;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
|
||||
public class SWScriptSyntaxForwarder extends BasicListener {
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onPluginMessage(PluginMessageEvent event) {
|
||||
if (!event.getTag().equals("sw:script_syntax")) {
|
||||
return;
|
||||
}
|
||||
event.setCancelled(true);
|
||||
if (!(event.getSender() instanceof Server)) {
|
||||
return;
|
||||
}
|
||||
if (!TeamCommand.isLocalhost(((InetSocketAddress) event.getSender().getSocketAddress()).getAddress())) {
|
||||
return;
|
||||
}
|
||||
((ProxiedPlayer) event.getReceiver()).sendData("sw:script_syntax", event.getData());
|
||||
}
|
||||
}
|
@ -19,11 +19,18 @@
|
||||
|
||||
package de.steamwar.bungeecore.network;
|
||||
|
||||
import com.velocitypowered.api.proxy.server.RegisteredServer;
|
||||
import de.steamwar.network.packets.MetaInfos;
|
||||
import lombok.Getter;
|
||||
import net.md_5.bungee.api.config.ServerInfo;
|
||||
|
||||
@Getter
|
||||
public record ServerMetaInfo(RegisteredServer sender) implements MetaInfos {
|
||||
public class ServerMetaInfo implements MetaInfos {
|
||||
|
||||
private ServerInfo sender;
|
||||
|
||||
public ServerMetaInfo(ServerInfo sender) {
|
||||
this.sender = sender;
|
||||
}
|
||||
|
||||
public ServerInfo getSender() {
|
||||
return sender;
|
||||
}
|
||||
}
|
||||
|
@ -19,10 +19,8 @@
|
||||
|
||||
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.VelocityCore;
|
||||
import de.steamwar.bungeecore.BungeeCore;
|
||||
import de.steamwar.network.packets.PacketHandler;
|
||||
import de.steamwar.network.packets.common.FightEndsPacket;
|
||||
import de.steamwar.sql.SchematicNode;
|
||||
@ -30,12 +28,14 @@ import de.steamwar.sql.SchematicType;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import de.steamwar.sql.UserElo;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
import net.kyori.adventure.title.Title;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import net.md_5.bungee.BungeeTitle;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
import net.md_5.bungee.api.Title;
|
||||
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.api.scheduler.TaskScheduler;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
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_LOSE = 20;
|
||||
private static final long REMATCH_LIFETIME = (long) 60 * 60 * 1000;
|
||||
private static final long REMATCH_LIFETIME = 1L * 60 * 60 * 1000;
|
||||
|
||||
private Map<String, LinkedList<Game>> gameModeGames = new HashMap<>();
|
||||
|
||||
@ -183,7 +183,7 @@ public class EloPlayerHandler extends PacketHandler {
|
||||
}
|
||||
}
|
||||
|
||||
private void animate(Player player, String oldEmblem, String newEmblem, String arrowColor, int eloGain) {
|
||||
private void animate(ProxiedPlayer player, String oldEmblem, String newEmblem, String arrowColor, int eloGain) {
|
||||
String finalOldEmblem = (oldEmblem.isEmpty() ? "/" : oldEmblem).trim();
|
||||
String finalNewEmblem = (newEmblem.isEmpty() ? "/" : newEmblem).trim();
|
||||
|
||||
@ -198,25 +198,22 @@ public class EloPlayerHandler extends PacketHandler {
|
||||
|
||||
String color = ((eloGain > 0) ? "§a+" : (eloGain == 0 ? "§7" : "§c"));
|
||||
|
||||
Scheduler scheduler = VelocityCore.get().getProxyServer().getScheduler();
|
||||
TaskScheduler scheduler = ProxyServer.getInstance().getScheduler();
|
||||
double eloStep = eloGain / 40.0;
|
||||
for (int i = 0; i < 40; i++) {
|
||||
Component eloGainComponent = LegacyComponentSerializer.legacySection().deserialize(color + (int) (eloStep * (i + 1)));
|
||||
BaseComponent[] eloGainComponent = TextComponent.fromLegacyText(color + (int) (eloStep * (i + 1)));
|
||||
int finalI = i;
|
||||
scheduler.buildTask(VelocityCore.get(), () -> {
|
||||
scheduler.schedule(BungeeCore.get(), () -> {
|
||||
if (player == null) return;
|
||||
Title title = Title.title(LegacyComponentSerializer.legacySection().deserialize(getRankup.apply(finalI)), eloGainComponent, Title.Times.times(
|
||||
Duration.ofSeconds(finalI == 0 ? 5 : 0),
|
||||
Duration.ofSeconds(2),
|
||||
Duration.ofSeconds(finalI == 39 ? 5 : 0)
|
||||
));
|
||||
player.showTitle(title);
|
||||
}).delay(i * 50L, TimeUnit.MILLISECONDS).schedule();
|
||||
if (!player.isConnected()) return;
|
||||
Title title = new BungeeTitle().title(TextComponent.fromLegacyText(getRankup.apply(finalI))).subTitle(eloGainComponent).fadeIn(finalI == 0 ? 5 : 0).stay(40).fadeOut(finalI == 39 ? 5 : 0);
|
||||
title.send(player);
|
||||
}, i * 50L, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
}
|
||||
|
||||
private @Nullable Player player(int userId) {
|
||||
return VelocityCore.get().getProxyServer().getPlayer(SteamwarUser.get(userId).getUUID()).orElseThrow();
|
||||
private ProxiedPlayer player(int userId) {
|
||||
return ProxyServer.getInstance().getPlayer(SteamwarUser.get(userId).getUUID());
|
||||
}
|
||||
|
||||
private double getTimeFactor(int duration) {
|
||||
@ -248,7 +245,7 @@ public class EloPlayerHandler extends PacketHandler {
|
||||
|
||||
@RequiredArgsConstructor
|
||||
private static class Game {
|
||||
private final long time = System.currentTimeMillis();
|
||||
private long time = System.currentTimeMillis();
|
||||
private final List<Integer> bluePlayers;
|
||||
private final List<Integer> redPlayers;
|
||||
|
||||
|
@ -19,10 +19,10 @@
|
||||
|
||||
package de.steamwar.bungeecore.network.handlers;
|
||||
|
||||
import de.steamwar.bungeecore.VelocityCore;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import de.steamwar.network.packets.PacketHandler;
|
||||
import de.steamwar.network.packets.client.ExecuteCommandPacket;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
|
||||
public class ExecuteCommandHandler extends PacketHandler {
|
||||
|
||||
@ -31,6 +31,6 @@ public class ExecuteCommandHandler extends PacketHandler {
|
||||
SteamwarUser target = SteamwarUser.get(packet.getPlayerId());
|
||||
String command = packet.getCommand();
|
||||
|
||||
VelocityCore.get().getProxyServer().getPlayer(target.getUUID()).ifPresent(player -> VelocityCore.get().getProxyServer().getCommandManager().executeAsync(player, command));
|
||||
ProxyServer.getInstance().getPluginManager().dispatchCommand(ProxyServer.getInstance().getPlayer(target.getUUID()), command);
|
||||
}
|
||||
}
|
||||
|
@ -19,8 +19,6 @@
|
||||
|
||||
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.ServerMetaInfo;
|
||||
import de.steamwar.bungeecore.tablist.TablistManager;
|
||||
@ -35,28 +33,28 @@ import java.util.Set;
|
||||
|
||||
public class FightInfoHandler extends PacketHandler {
|
||||
|
||||
private static final Set<RegisteredServer> lobbys = new HashSet<>();
|
||||
private static final Set<ServerInfo> lobbys = new HashSet<>();
|
||||
|
||||
public static void addLobby(RegisteredServer lobby) {
|
||||
public static void addLobby(ServerInfo lobby) {
|
||||
lobbys.add(lobby);
|
||||
}
|
||||
|
||||
public static boolean onLobby(Player player) {
|
||||
return player.getCurrentServer().map(serverConnection -> lobbys.contains(serverConnection.getServer())).orElse(false);
|
||||
public static boolean onLobby(ProxiedPlayer player) {
|
||||
return lobbys.contains(player.getServer().getInfo());
|
||||
}
|
||||
|
||||
@Handler
|
||||
public void handle(FightInfoPacket packet) {
|
||||
RegisteredServer info = ((ServerMetaInfo) packet.getMetaInfos()).sender();
|
||||
ServerInfo info = ((ServerMetaInfo) packet.getMetaInfos()).getSender();
|
||||
|
||||
FightInfoPacket lobbyPacket = packet.withServerName(info.getServerInfo().getName());
|
||||
FightInfoPacket lobbyPacket = packet.withServerName(info.getName());
|
||||
|
||||
TablistManager.newFightInfo(info, packet);
|
||||
|
||||
Iterator<RegisteredServer> lobbyIt = lobbys.iterator();
|
||||
Iterator<ServerInfo> lobbyIt = lobbys.iterator();
|
||||
while(lobbyIt.hasNext()) {
|
||||
RegisteredServer lobby = lobbyIt.next();
|
||||
Iterator<Player> it = lobby.getPlayersConnected().iterator();
|
||||
ServerInfo lobby = lobbyIt.next();
|
||||
Iterator<ProxiedPlayer> it = lobby.getPlayers().iterator();
|
||||
if(!it.hasNext()){
|
||||
lobbyIt.remove();
|
||||
continue;
|
||||
|
@ -27,6 +27,6 @@ public class ImALobbyHandler extends PacketHandler {
|
||||
|
||||
@Handler
|
||||
public void handle(ImALobbyPacket packet) {
|
||||
FightInfoHandler.addLobby(((ServerMetaInfo) packet.getMetaInfos()).sender());
|
||||
FightInfoHandler.addLobby(((ServerMetaInfo) packet.getMetaInfos()).getSender());
|
||||
}
|
||||
}
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
package de.steamwar.bungeecore.network.handlers;
|
||||
|
||||
import de.steamwar.bungeecore.VelocityCore;
|
||||
import de.steamwar.bungeecore.BungeeCore;
|
||||
import de.steamwar.bungeecore.inventory.InvCallback;
|
||||
import de.steamwar.bungeecore.inventory.SWInventory;
|
||||
import de.steamwar.bungeecore.network.NetworkSender;
|
||||
@ -28,10 +28,7 @@ import de.steamwar.sql.SteamwarUser;
|
||||
import de.steamwar.network.packets.PacketHandler;
|
||||
import de.steamwar.network.packets.client.InventoryCallbackPacket;
|
||||
import de.steamwar.network.packets.server.CloseInventoryPacket;
|
||||
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 net.md_5.bungee.api.ProxyServer;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@ -45,9 +42,9 @@ public class InventoryCallbackHandler extends PacketHandler {
|
||||
SteamwarUser owner = SteamwarUser.get(packet.getOwner());
|
||||
InventoryCallbackPacket.CallbackType type = packet.getType();
|
||||
if(!inventoryHashMap.containsKey(owner.getId())) {
|
||||
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)))));
|
||||
BungeeCore.send(ProxyServer.getInstance().getPlayer(owner.getUUID()), BungeeCore.CHAT_PREFIX + "§cBitte erneut versuchen. Durch ein Softwareupdate konnte die übliche Aktion nicht durchgeführt werden.");
|
||||
if(type == InventoryCallbackPacket.CallbackType.CLICK) {
|
||||
NetworkSender.send(((ServerMetaInfo) packet.getMetaInfos()).sender(), new CloseInventoryPacket(owner.getId()));
|
||||
NetworkSender.send(((ServerMetaInfo) packet.getMetaInfos()).getSender(), new CloseInventoryPacket(owner.getId()));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -19,20 +19,20 @@
|
||||
|
||||
package de.steamwar.bungeecore.network.handlers;
|
||||
|
||||
import com.velocitypowered.api.proxy.Player;
|
||||
import de.steamwar.bungeecore.ArenaMode;
|
||||
import de.steamwar.bungeecore.ServerStarter;
|
||||
import de.steamwar.bungeecore.VelocityCore;
|
||||
import de.steamwar.sql.SchematicType;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import de.steamwar.network.packets.PacketHandler;
|
||||
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 {
|
||||
|
||||
@Handler
|
||||
public void handle(PrepareSchemPacket packet) {
|
||||
Player player = VelocityCore.get().getProxyServer().getPlayer(SteamwarUser.get(packet.getPlayer()).getUUID()).orElseThrow();
|
||||
ProxiedPlayer player = ProxyServer.getInstance().getPlayer(SteamwarUser.get(packet.getPlayer()).getUUID());
|
||||
int schematicID = packet.getSchem();
|
||||
ArenaMode mode = ArenaMode.getBySchemType(SchematicType.fromDB(packet.getSchemType()));
|
||||
|
||||
|
@ -19,12 +19,24 @@
|
||||
|
||||
package de.steamwar.bungeecore.tablist;
|
||||
|
||||
import com.velocitypowered.api.proxy.player.TabList;
|
||||
import de.steamwar.bungeecore.Storage;
|
||||
import de.steamwar.messages.ChatSender;
|
||||
import io.netty.channel.ChannelHandler;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
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.stream.Collectors;
|
||||
@ -36,7 +48,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 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 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 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 final Map<UUID, PlayerListItem.Item> directTabItems;
|
||||
private final Set<UUID> npcs = new HashSet<>();
|
||||
@ -206,7 +218,7 @@ public class Tablist extends MessageToMessageDecoder<PacketWrapper> {
|
||||
item.setDisplayName(new TextComponent());
|
||||
item.setListed(false);
|
||||
} else if (item.getDisplayName() == null) {
|
||||
item.setDisplayName(TextComponent.fromLegacy("§7" + item.getUsername()));
|
||||
item.setDisplayName(new TextComponent(item.getUsername()));
|
||||
}
|
||||
item.setPublicKey(null);
|
||||
if(!player.getUniqueId().equals(item.getUuid()) && item.getGamemode() == 3)
|
||||
@ -261,7 +273,7 @@ public class Tablist extends MessageToMessageDecoder<PacketWrapper> {
|
||||
item.setDisplayName(new TextComponent());
|
||||
item.setListed(false);
|
||||
} else if (item.getDisplayName() == null) {
|
||||
item.setDisplayName(TextComponent.fromLegacy("§7" + item.getUsername()));
|
||||
item.setDisplayName(new TextComponent(item.getUsername()));
|
||||
}
|
||||
item.setPublicKey(null);
|
||||
if(!player.getUniqueId().equals(item.getUuid()) && item.getGamemode() == 3)
|
||||
@ -333,11 +345,15 @@ public class Tablist extends MessageToMessageDecoder<PacketWrapper> {
|
||||
}
|
||||
|
||||
private BaseComponent[] header(ChatSender p, int seconds) {
|
||||
int phase = (seconds % 10) / 5;
|
||||
if (phase == 0)
|
||||
return p.parse(false, "TABLIST_PHASE_DISCORD");
|
||||
else
|
||||
return p.parse(false, "TABLIST_PHASE_WEBSITE");
|
||||
int phase = (seconds % 16) / 3;
|
||||
switch (phase) {
|
||||
case 0:
|
||||
return p.parse(false, "TABLIST_PHASE_1");
|
||||
case 1:
|
||||
return p.parse(false, "TABLIST_PHASE_2");
|
||||
default:
|
||||
return p.parse(false, "TABLIST_PHASE_DEFAULT");
|
||||
}
|
||||
}
|
||||
|
||||
private String ping() {
|
||||
|
@ -19,14 +19,12 @@
|
||||
|
||||
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.Subserver;
|
||||
import de.steamwar.bungeecore.VelocityCore;
|
||||
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.HashMap;
|
||||
@ -36,19 +34,19 @@ import java.util.stream.Collectors;
|
||||
|
||||
public class TablistBuild implements TablistPart {
|
||||
|
||||
private final List<RegisteredServer> servers = new ArrayList<>();
|
||||
private final Map<RegisteredServer, List<Item>> players = new HashMap<>();
|
||||
private final List<ServerInfo> servers = new ArrayList<>();
|
||||
private final Map<ServerInfo, List<Item>> players = new HashMap<>();
|
||||
|
||||
public TablistBuild() {
|
||||
for (RegisteredServer server : new ArrayList<>(VelocityCore.get().getProxyServer().getAllServers())){
|
||||
Subserver subserver = Subserver.getSubserver(server.getServerInfo());
|
||||
if(server.getPlayersConnected().isEmpty() || subserver == null || subserver.getType() != Servertype.BAUSERVER)
|
||||
for (ServerInfo server : new ArrayList<>(ProxyServer.getInstance().getServers().values())){
|
||||
Subserver subserver = Subserver.getSubserver(server);
|
||||
if(server.getPlayers().isEmpty() || subserver == null || subserver.getType() != Servertype.BAUSERVER)
|
||||
continue;
|
||||
|
||||
servers.add(server);
|
||||
players.put(server, server.getPlayersConnected().stream().sorted(((p1, p2) -> p1.getUsername().compareToIgnoreCase(p2.getUsername()))).map(Item::new).collect(Collectors.toList()));
|
||||
players.put(server, server.getPlayers().stream().sorted(((p1, p2) -> p1.getName().compareToIgnoreCase(p2.getName()))).map(Item::new).collect(Collectors.toList()));
|
||||
}
|
||||
servers.sort((s1, s2) -> s1.getServerInfo().getName().compareToIgnoreCase(s2.getServerInfo().getName()));
|
||||
servers.sort((s1, s2) -> s1.getName().compareToIgnoreCase(s2.getName()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -57,14 +55,14 @@ public class TablistBuild implements TablistPart {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void print(ChatSender viewer, Player player, List<Item> tablist, List<Item> direct) {
|
||||
RegisteredServer server = player.getCurrentServer().map(ServerConnection::getServer).orElseThrow();
|
||||
public void print(ChatSender viewer, ProxiedPlayer player, List<Item> tablist, List<Item> direct) {
|
||||
ServerInfo server = player.getServer().getInfo();
|
||||
if(players.keySet().stream().anyMatch(info -> server != info)) {
|
||||
tablist.add(new Item(null, "", TablistServer.GRAY));
|
||||
tablist.add(new Item(null, viewer.parseToLegacy("TABLIST_BAU"), TablistServer.LIGHT_GRAY));
|
||||
}
|
||||
|
||||
for (RegisteredServer info : servers) {
|
||||
for (ServerInfo info : servers) {
|
||||
TablistServer.teamify(players.get(info), player)
|
||||
.forEach(((server == info) ? direct : tablist)::add);
|
||||
}
|
||||
|
@ -19,8 +19,8 @@
|
||||
|
||||
package de.steamwar.bungeecore.tablist;
|
||||
|
||||
import com.velocitypowered.api.proxy.Player;
|
||||
import de.steamwar.messages.ChatSender;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -37,7 +37,7 @@ public class TablistGroup implements TablistPart {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void print(ChatSender viewer, Player player, List<Item> tablist, List<Item> direct) {
|
||||
public void print(ChatSender viewer, ProxiedPlayer player, List<Item> tablist, List<Item> direct) {
|
||||
for (TablistPart sublist : sublists) {
|
||||
sublist.print(viewer, player, tablist, direct);
|
||||
}
|
||||
|
@ -19,8 +19,7 @@
|
||||
|
||||
package de.steamwar.bungeecore.tablist;
|
||||
|
||||
import com.velocitypowered.api.proxy.server.RegisteredServer;
|
||||
import de.steamwar.bungeecore.VelocityCore;
|
||||
import de.steamwar.bungeecore.BungeeCore;
|
||||
import de.steamwar.bungeecore.Servertype;
|
||||
import de.steamwar.bungeecore.Storage;
|
||||
import de.steamwar.bungeecore.Subserver;
|
||||
@ -39,7 +38,7 @@ import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class TablistManager extends BasicListener {
|
||||
|
||||
private static final Map<RegisteredServer, FightInfoPacket> fightInfos = new HashMap<>();
|
||||
private static final Map<ServerInfo, FightInfoPacket> fightInfos = new HashMap<>();
|
||||
|
||||
public static synchronized void newFightInfo(ServerInfo info, FightInfoPacket packet) {
|
||||
fightInfos.put(info, packet);
|
||||
@ -51,7 +50,7 @@ public class TablistManager extends BasicListener {
|
||||
private int seconds = 0;
|
||||
|
||||
public TablistManager() {
|
||||
ProxyServer.getInstance().getScheduler().schedule(VelocityCore.get(), this::updateTablist, 1, 1, TimeUnit.SECONDS);
|
||||
ProxyServer.getInstance().getScheduler().schedule(BungeeCore.get(), this::updateTablist, 1, 1, TimeUnit.SECONDS);
|
||||
synchronized (tablists) {
|
||||
ProxyServer.getInstance().getPlayers().forEach(player -> tablists.put(player, new Tablist(player)));
|
||||
}
|
||||
|
@ -19,54 +19,54 @@
|
||||
|
||||
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.sql.SteamwarUser;
|
||||
import de.steamwar.sql.UserPerm;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.TextComponent;
|
||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
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.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.UUID;
|
||||
|
||||
interface TablistPart {
|
||||
String sortKey();
|
||||
void print(ChatSender viewer, Player player, List<Item> tablist, List<Item> direct);
|
||||
void print(ChatSender viewer, ProxiedPlayer player, List<Item> tablist, List<Item> direct);
|
||||
|
||||
class Item {
|
||||
|
||||
public static List<GameProfile.Property> playerProperties(Player player) {
|
||||
List<GameProfile.Property> loginResult = player.getGameProfileProperties();
|
||||
public static Property[] playerProperties(ProxiedPlayer player) {
|
||||
LoginResult loginResult = ((InitialHandler) player.getPendingConnection()).getLoginProfile();
|
||||
if(loginResult == null)
|
||||
return Collections.emptyList();
|
||||
return new Property[0];
|
||||
|
||||
return loginResult;
|
||||
return loginResult.getProperties();
|
||||
}
|
||||
|
||||
private final UUID uuid;
|
||||
private final Component displayName;
|
||||
private final List<GameProfile.Property> properties;
|
||||
private final BaseComponent displayName;
|
||||
private final Property[] properties;
|
||||
|
||||
public Item(UUID uuid, String displayName, List<GameProfile.Property> properties) {
|
||||
public Item(UUID uuid, String displayName, Property[] properties) {
|
||||
this.uuid = uuid;
|
||||
this.displayName = reformat(displayName);
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
public Item(Player player) {
|
||||
public Item(ProxiedPlayer player) {
|
||||
this(player, false);
|
||||
}
|
||||
|
||||
public Item(Player player, boolean sameTeam) {
|
||||
public Item(ProxiedPlayer player, boolean sameTeam) {
|
||||
this.uuid = player.getUniqueId();
|
||||
UserPerm.Prefix prefix = SteamwarUser.get(player.getUniqueId()).prefix();
|
||||
if (prefix == UserPerm.emptyPrefix && sameTeam) {
|
||||
this.displayName = reformat("§f" + player.getUsername());
|
||||
this.displayName = reformat("§f" + player.getName());
|
||||
} else {
|
||||
this.displayName = reformat(prefix.getColorCode() + player.getUsername());
|
||||
this.displayName = reformat(prefix.getColorCode() + player.getName());
|
||||
}
|
||||
this.properties = playerProperties(player);
|
||||
}
|
||||
@ -75,16 +75,16 @@ interface TablistPart {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
public Component getDisplayName() {
|
||||
public BaseComponent getDisplayName() {
|
||||
return displayName;
|
||||
}
|
||||
|
||||
public List<GameProfile.Property> getProperties() {
|
||||
public Property[] getProperties() {
|
||||
return properties;
|
||||
}
|
||||
|
||||
private Component reformat(String string) {
|
||||
return LegacyComponentSerializer.legacyAmpersand().deserialize(string);
|
||||
private BaseComponent reformat(String string) {
|
||||
return TextComponent.fromArray(TextComponent.fromLegacyText(string));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -19,81 +19,82 @@
|
||||
|
||||
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.Subserver;
|
||||
import de.steamwar.bungeecore.VelocityCore;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import de.steamwar.messages.ChatSender;
|
||||
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.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public class TablistServer implements TablistPart {
|
||||
|
||||
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 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="));
|
||||
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 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=")};
|
||||
|
||||
private final RegisteredServer server;
|
||||
private final ServerInfo server;
|
||||
private final List<Item> players;
|
||||
|
||||
public TablistServer(RegisteredServer server) {
|
||||
this(server, server.getPlayersConnected().stream().sorted((p1, p2) -> p1.getUsername().compareToIgnoreCase(p2.getUsername())).map(TablistPart.Item::new).collect(Collectors.toList()));
|
||||
public TablistServer(ServerInfo server) {
|
||||
this(server, server.getPlayers().stream().sorted((p1, p2) -> p1.getName().compareToIgnoreCase(p2.getName())).map(TablistPart.Item::new).collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
public TablistServer(RegisteredServer server, FightInfoPacket info) {
|
||||
public TablistServer(ServerInfo server, FightInfoPacket info) {
|
||||
this(server, new ArrayList<>());
|
||||
|
||||
Collection<Player> onlinePlayers = server.getPlayersConnected();
|
||||
Collection<ProxiedPlayer> onlinePlayers = server.getPlayers();
|
||||
addPlayers(info.getBlueName().substring(0, 2), info.getBluePlayers(), onlinePlayers);
|
||||
addPlayers(info.getRedName().substring(0, 2), info.getRedPlayers(), onlinePlayers);
|
||||
addPlayers("§7", info.getSpectators(), onlinePlayers);
|
||||
}
|
||||
|
||||
public TablistServer(RegisteredServer server, List<Item> players) {
|
||||
public TablistServer(ServerInfo server, List<Item> players) {
|
||||
this.server = server;
|
||||
this.players = players;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String sortKey() {
|
||||
return server.getServerInfo().getName();
|
||||
return server.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void print(ChatSender viewer, Player player, List<Item> tablist, List<Item> direct) {
|
||||
boolean onServer = server.getPlayersConnected().contains(player);
|
||||
public void print(ChatSender viewer, ProxiedPlayer player, List<Item> tablist, List<Item> direct) {
|
||||
boolean onServer = player.getServer().getInfo() == server;
|
||||
List<Item> items = onServer ? direct : tablist;
|
||||
|
||||
if(!onServer) {
|
||||
items.add(new Item(null, "", GRAY));
|
||||
items.add(new Item(null, "§7§l" + server.getServerInfo().getName(), LIGHT_GRAY));
|
||||
items.add(new Item(null, "§7§l" + server.getName(), LIGHT_GRAY));
|
||||
}
|
||||
|
||||
teamify(players, player).forEach(items::add);
|
||||
}
|
||||
|
||||
private void addPlayers(String prefix, List<Integer> teamPlayers, Collection<Player> onlinePlayers){
|
||||
private void addPlayers(String prefix, List<Integer> teamPlayers, Collection<ProxiedPlayer> onlinePlayers){
|
||||
teamPlayers.stream().map(SteamwarUser::get).map(
|
||||
user -> onlinePlayers.stream().filter(player -> player.getUniqueId().equals(user.getUUID())).findAny()
|
||||
).filter(Optional::isPresent).map(Optional::get).sorted(
|
||||
(p1, p2) -> p1.getUsername().compareToIgnoreCase(p2.getUsername())
|
||||
).forEachOrdered(player -> players.add(new Item(player.getUniqueId(), prefix + player.getUsername(), Item.playerProperties(player))));
|
||||
(p1, p2) -> p1.getName().compareToIgnoreCase(p2.getName())
|
||||
).forEachOrdered(player -> players.add(new Item(player.getUniqueId(), prefix + player.getName(), Item.playerProperties(player))));
|
||||
}
|
||||
|
||||
public static Stream<Item> teamify(List<Item> players, Player player) {
|
||||
public static Stream<Item> teamify(List<Item> players, ProxiedPlayer player) {
|
||||
int team = SteamwarUser.get(player.getUniqueId()).getTeam();
|
||||
if (team == 0) return players.stream();
|
||||
return players.stream().map(item -> {
|
||||
Optional<Player> pOpt = VelocityCore.get().getProxyServer().getPlayer(item.getUuid());
|
||||
if (pOpt.isEmpty()) return item;
|
||||
Player p = pOpt.get();
|
||||
Subserver subserver = Subserver.getSubserver(p.getCurrentServer().map(ServerConnection::getServerInfo).orElse(null));
|
||||
ProxiedPlayer p = BungeeCord.getInstance().getPlayer(item.getUuid());
|
||||
if (p == null) return item;
|
||||
Subserver subserver = Subserver.getSubserver(p.getServer().getInfo());
|
||||
if (subserver != null && subserver.getType() == Servertype.ARENA) return item;
|
||||
if (SteamwarUser.get(p.getUniqueId()).getTeam() != team) return item;
|
||||
return new Item(p, true);
|
||||
|
@ -19,70 +19,36 @@
|
||||
|
||||
package de.steamwar.bungeecore.util;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.velocitypowered.api.proxy.Player;
|
||||
import com.velocitypowered.api.proxy.ProxyServer;
|
||||
import de.steamwar.bungeecore.Message;
|
||||
import de.steamwar.bungeecore.util.annotations.Create;
|
||||
import de.steamwar.messages.ChatSender;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import de.steamwar.sql.UserConfig;
|
||||
import de.steamwar.sql.UserPerm;
|
||||
import lombok.experimental.UtilityClass;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
|
||||
@Create
|
||||
@UtilityClass
|
||||
public class BauLock {
|
||||
|
||||
private final ProxyServer proxy;
|
||||
|
||||
private final String BAU_LOCK_CONFIG_NAME = "baulockstate";
|
||||
|
||||
@Inject
|
||||
public BauLock(ProxyServer proxy) {
|
||||
this.proxy = proxy;
|
||||
}
|
||||
|
||||
public void setLocked(Player p, BauLockState state) {
|
||||
private static final String BAU_LOCK_CONFIG_NAME = "baulockstate";
|
||||
public static void setLocked(ProxiedPlayer p, BauLockState state) {
|
||||
SteamwarUser owner = SteamwarUser.get(p.getUniqueId());
|
||||
UserConfig.updatePlayerConfig(owner.getId(), BAU_LOCK_CONFIG_NAME, state == BauLockState.OPEN ? null : state.name());
|
||||
Message.send("BAU_LOCKED_" + state.name(), p);
|
||||
}
|
||||
|
||||
public boolean checkNotifyLocked(SteamwarUser owner, Player player) {
|
||||
ChatSender sender = ChatSender.of(player);
|
||||
SteamwarUser target = sender.user();
|
||||
public static boolean isLocked(SteamwarUser owner, SteamwarUser target) {
|
||||
if (owner.getId() == target.getId())
|
||||
return false;
|
||||
|
||||
boolean locked;
|
||||
String state = UserConfig.getConfig(owner.getId(), BAU_LOCK_CONFIG_NAME);
|
||||
switch (state == null ? BauLockState.OPEN : BauLockState.valueOf(state)) {
|
||||
case NOBODY:
|
||||
locked = true;
|
||||
break;
|
||||
case SERVERTEAM:
|
||||
locked = !target.hasPerm(UserPerm.TEAM);
|
||||
break;
|
||||
case TEAM_AND_SERVERTEAM:
|
||||
if (target.hasPerm(UserPerm.TEAM)) {
|
||||
return false;
|
||||
}
|
||||
locked = owner.getTeam() != target.getTeam();
|
||||
break;
|
||||
return true;
|
||||
case TEAM:
|
||||
locked = owner.getTeam() != target.getTeam();
|
||||
break;
|
||||
return owner.getTeam() != target.getTeam();
|
||||
case OPEN:
|
||||
default:
|
||||
locked = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
if(locked) {
|
||||
sender.system("BAU_LOCKED_NOALLOWED");
|
||||
|
||||
proxy.getPlayer(owner.getUUID()).ifPresent(ownerPlayer -> ChatSender.of(ownerPlayer).system("BAU_LOCK_BLOCKED", player.getUsername()));
|
||||
}
|
||||
|
||||
return locked;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -22,8 +22,6 @@ package de.steamwar.bungeecore.util;
|
||||
public enum BauLockState {
|
||||
|
||||
NOBODY, // Locks the build server for all users
|
||||
SERVERTEAM, // opens the build server only for every added user which is a server team member
|
||||
TEAM_AND_SERVERTEAM, //opens the build server only for every added user which is in the same team as the buildOwner and every server team member
|
||||
TEAM, //opens the build server only for every added user which is in the same team as the buildOwner
|
||||
OPEN //unlocks the build server for all users
|
||||
}
|
||||
|
@ -19,19 +19,30 @@
|
||||
|
||||
package de.steamwar.bungeecore.util;
|
||||
|
||||
import com.velocitypowered.api.proxy.Player;
|
||||
import com.velocitypowered.proxy.connection.client.ConnectedPlayer;
|
||||
import net.md_5.bungee.ServerConnection;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
import net.md_5.bungee.protocol.ChatChain;
|
||||
import net.md_5.bungee.protocol.ProtocolConstants;
|
||||
import net.md_5.bungee.protocol.SeenMessages;
|
||||
import net.md_5.bungee.protocol.packet.ClientChat;
|
||||
import net.md_5.bungee.protocol.packet.ClientCommand;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.BitSet;
|
||||
import java.util.Collections;
|
||||
|
||||
public class Chat19 {
|
||||
private Chat19(){}
|
||||
|
||||
public static void chat(Player p, String message) {
|
||||
((ConnectedPlayer) p).getChatBuilderFactory().builder()
|
||||
.setTimestamp(Instant.now())
|
||||
.asPlayer(p)
|
||||
.message(message)
|
||||
.toServer();
|
||||
public static void chat(ProxiedPlayer p, String message) {
|
||||
int version = p.getPendingConnection().getVersion();
|
||||
if(version >= ProtocolConstants.MINECRAFT_1_19) {
|
||||
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.chat(message);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,57 +0,0 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2024 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bungeecore.util;
|
||||
|
||||
import com.google.inject.AbstractModule;
|
||||
import com.google.inject.Provides;
|
||||
import com.google.inject.Scopes;
|
||||
import com.google.inject.Singleton;
|
||||
import de.steamwar.bungeecore.Node;
|
||||
import de.steamwar.bungeecore.VelocityCore;
|
||||
import de.steamwar.bungeecore.commands.HelpCommand;
|
||||
import de.steamwar.bungeecore.mods.*;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public final class SteamWarModule extends AbstractModule {
|
||||
|
||||
private final @NotNull VelocityCore core;
|
||||
|
||||
public SteamWarModule(@NotNull VelocityCore core) {
|
||||
this.core = core;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void configure() {
|
||||
bind(VelocityCore.class).toInstance(core);
|
||||
bind(HelpCommand.class).in(Scopes.SINGLETON);
|
||||
bind(ModUtils.class).in(Scopes.SINGLETON);
|
||||
bind(LabyMod.class).in(Scopes.SINGLETON);
|
||||
bind(WorldDownloader.class).in(Scopes.SINGLETON);
|
||||
bind(FML.class).in(Scopes.SINGLETON);
|
||||
bind(FML2.class).in(Scopes.SINGLETON);
|
||||
bind(BauLock.class).in(Scopes.SINGLETON);
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
Node provideNode() {
|
||||
return new Node.LocalNode();
|
||||
}
|
||||
}
|
@ -1,31 +0,0 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2024 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bungeecore.util.annotations;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.TYPE)
|
||||
public @interface Create {
|
||||
boolean eventProxy() default true;
|
||||
}
|
@ -19,69 +19,19 @@
|
||||
|
||||
package de.steamwar.command;
|
||||
|
||||
import com.mojang.brigadier.tree.CommandNode;
|
||||
import com.velocitypowered.api.command.Command;
|
||||
import com.velocitypowered.api.command.CommandManager;
|
||||
import com.velocitypowered.api.command.CommandMeta;
|
||||
import com.velocitypowered.api.command.CommandSource;
|
||||
import de.steamwar.bungeecore.VelocityCore;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
import de.steamwar.bungeecore.BungeeCore;
|
||||
import lombok.experimental.UtilityClass;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import java.util.*;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
import net.md_5.bungee.api.plugin.Command;
|
||||
|
||||
@UtilityClass
|
||||
class CommandRegistering {
|
||||
|
||||
static void unregister(String name) {
|
||||
VelocityCore.get().getProxyServer().getCommandManager().unregister(name);
|
||||
static void unregister(Command command) {
|
||||
ProxyServer.getInstance().getPluginManager().unregisterCommand(command);
|
||||
}
|
||||
|
||||
static void register(Command command, String name, String... aliases) {
|
||||
VelocityCore.get().getProxyServer().getCommandManager().register(new SWCommandMeta(name, aliases), command);
|
||||
}
|
||||
|
||||
private record SWCommandMeta(String name, String[] aliases) implements CommandMeta {
|
||||
|
||||
@Override
|
||||
public Collection<String> getAliases() {
|
||||
List<String> list = new ArrayList<>(aliases.length + 1);
|
||||
list.add(name);
|
||||
list.addAll(Arrays.asList(aliases));
|
||||
return Collections.unmodifiableList(list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<CommandNode<CommandSource>> getHints() {
|
||||
return List.of();
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable Object getPlugin() {
|
||||
return VelocityCore.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "SWCommandMeta{" +
|
||||
"name='" + name + '\'' +
|
||||
", aliases=" + Arrays.toString(aliases) +
|
||||
'}';
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
SWCommandMeta that = (SWCommandMeta) o;
|
||||
return Objects.equals(name, that.name) && Objects.deepEquals(aliases, that.aliases);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(name, Arrays.hashCode(aliases));
|
||||
}
|
||||
static void register(Command command) {
|
||||
ProxyServer.getInstance().getPluginManager().registerCommand(BungeeCore.get(), command);
|
||||
}
|
||||
}
|
||||
|
@ -19,28 +19,29 @@
|
||||
|
||||
package de.steamwar.command;
|
||||
|
||||
import com.velocitypowered.api.command.Command;
|
||||
import com.velocitypowered.api.command.CommandSource;
|
||||
import com.velocitypowered.api.command.SimpleCommand;
|
||||
import com.velocitypowered.api.proxy.Player;
|
||||
import de.steamwar.bungeecore.VelocityCore;
|
||||
import de.steamwar.bungeecore.BungeeCore;
|
||||
import de.steamwar.bungeecore.Message;
|
||||
import de.steamwar.messages.ChatSender;
|
||||
import net.md_5.bungee.BungeeCord;
|
||||
import net.md_5.bungee.api.CommandSender;
|
||||
import net.md_5.bungee.api.chat.ClickEvent;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
import net.md_5.bungee.api.plugin.Command;
|
||||
import net.md_5.bungee.api.plugin.TabExecutor;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class SWCommand extends AbstractSWCommand<CommandSource> {
|
||||
public class SWCommand extends AbstractSWCommand<CommandSender> {
|
||||
|
||||
static {
|
||||
TypeUtils.init();
|
||||
}
|
||||
|
||||
private String name;
|
||||
private String[] aliases;
|
||||
private String permission;
|
||||
private Command command;
|
||||
|
||||
@ -55,10 +56,8 @@ public class SWCommand extends AbstractSWCommand<CommandSource> {
|
||||
}
|
||||
|
||||
protected SWCommand(String command, String permission, String... aliases) {
|
||||
super(CommandSource.class, command, aliases);
|
||||
this.name = command;
|
||||
super(CommandSender.class, command, aliases);
|
||||
this.permission = permission;
|
||||
this.aliases = aliases;
|
||||
create = true;
|
||||
createAndSafeCommand(command, aliases);
|
||||
unregister();
|
||||
@ -70,40 +69,46 @@ public class SWCommand extends AbstractSWCommand<CommandSource> {
|
||||
@Override
|
||||
protected void createAndSafeCommand(String command, String[] aliases) {
|
||||
if (!create) return;
|
||||
this.command = new SimpleCommand() {
|
||||
this.command = new TabCompletableCommand(command, permission, aliases) {
|
||||
@Override
|
||||
public void execute(Invocation invocation) {
|
||||
SWCommand.this.execute(invocation.source(), invocation.alias(), invocation.arguments());
|
||||
public void execute(CommandSender commandSender, String[] strings) {
|
||||
SWCommand.this.execute(commandSender, null, strings);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> suggest(Invocation invocation) {
|
||||
return SWCommand.this.tabComplete(invocation.source(), invocation.alias(), invocation.arguments());
|
||||
public Iterable<String> onTabComplete(CommandSender commandSender, String[] strings) {
|
||||
return SWCommand.this.tabComplete(commandSender, null, strings);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private abstract static class TabCompletableCommand extends Command implements TabExecutor {
|
||||
public TabCompletableCommand(String name, String permission, String... aliases) {
|
||||
super(name, permission, aliases);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unregister() {
|
||||
if (command == null) return;
|
||||
CommandRegistering.unregister(this.name);
|
||||
CommandRegistering.unregister(this.command);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register() {
|
||||
if (command == null) return;
|
||||
CommandRegistering.register(command, name, aliases);
|
||||
CommandRegistering.register(this.command);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void commandSystemError(Player sender, CommandFrameworkException e) {
|
||||
VelocityCore.get().getLogger().log(Level.SEVERE, e.getMessage(), e);
|
||||
protected void commandSystemError(CommandSender sender, CommandFrameworkException e) {
|
||||
BungeeCore.get().getLogger().log(Level.SEVERE, e.getMessage(), e);
|
||||
ChatSender.of(sender).prefixless("COMMAND_SYSTEM_ERROR");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void commandSystemWarning(Supplier<String> message) {
|
||||
VelocityCore.get().getLogger().log(Level.WARNING, message);
|
||||
BungeeCore.get().getLogger().log(Level.WARNING, message);
|
||||
}
|
||||
|
||||
public void addDefaultHelpMessage(String message) {
|
||||
@ -111,18 +116,18 @@ public class SWCommand extends AbstractSWCommand<CommandSource> {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void sendMessage(Player sender, String message, Object[] args) {
|
||||
protected void sendMessage(CommandSender sender, String message, Object[] args) {
|
||||
ChatSender.of(sender).system(message, args);
|
||||
}
|
||||
|
||||
@Register(noTabComplete = true)
|
||||
public void internalHelp(Player p, String... args) {
|
||||
public void internalHelp(ProxiedPlayer p, String... args) {
|
||||
ChatSender chatSender = ChatSender.of(p);
|
||||
try {
|
||||
chatSender.prefixless("COMMAND_HELP_HEAD", command.getName());
|
||||
defaultHelpMessages.forEach(chatSender::prefixless);
|
||||
} catch (Exception e) {
|
||||
VelocityCore.get().getLogger().log(Level.WARNING, "Failed to send help message", e);
|
||||
BungeeCore.get().getLogger().log(Level.WARNING, "Failed to send help message", e);
|
||||
return;
|
||||
}
|
||||
AtomicInteger atomicInteger = new AtomicInteger();
|
||||
@ -151,7 +156,7 @@ public class SWCommand extends AbstractSWCommand<CommandSource> {
|
||||
}
|
||||
}
|
||||
|
||||
private void send(ChatSender chatSender, SubCommand<CommandSource> subCommand) {
|
||||
private void send(ChatSender chatSender, SubCommand<CommandSender> subCommand) {
|
||||
try {
|
||||
for (String s : subCommand.description) {
|
||||
String hover = "§8/§e" + command.getName() + " " + String.join(" ", subCommand.subCommand);
|
||||
@ -159,7 +164,7 @@ public class SWCommand extends AbstractSWCommand<CommandSource> {
|
||||
chatSender.prefixless(s, new Message("PLAIN_STRING", hover), new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, suggest));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
VelocityCore.get().getLogger().log(Level.WARNING, "Failed to send description of registered method '" + subCommand.method + "' with description '" + subCommand.description + "'", e);
|
||||
BungeeCore.get().getLogger().log(Level.WARNING, "Failed to send description of registered method '" + subCommand.method + "' with description '" + subCommand.description + "'", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -19,11 +19,11 @@
|
||||
|
||||
package de.steamwar.command;
|
||||
|
||||
import com.velocitypowered.api.proxy.Player;
|
||||
import net.md_5.bungee.api.CommandSender;
|
||||
|
||||
public interface TypeMapper<T> extends AbstractTypeMapper<Player, T> {
|
||||
public interface TypeMapper<T> extends AbstractTypeMapper<CommandSender, T> {
|
||||
/**
|
||||
* The CommandSender can be null!
|
||||
*/
|
||||
T map(Player commandSender, String[] previousArguments, String s);
|
||||
T map(CommandSender commandSender, String[] previousArguments, String s);
|
||||
}
|
||||
|
@ -20,6 +20,9 @@ DISABLED=§cCurrently disabled.
|
||||
|
||||
SERVER_START_OVERLOAD=§cServer start cancelled due to overload. Please try again later.
|
||||
|
||||
#ModLoader blocker
|
||||
MODLOADER_DENIED=§cYou cannot join arenas with LiteLoader or Fabric without the FabricModSender https://steamwar.de/downloads installed.
|
||||
|
||||
#Help command
|
||||
HELP_LOBBY=§7Return from anywhere to the lobby using §8/§el§7!
|
||||
HELP_LOBBY_HOVER=§eBack to the lobby
|
||||
@ -90,12 +93,12 @@ HELP_BAU_ADDMEMBER=§8/§ebuild addmember §8- §7Allows a friend on your build
|
||||
HELP_BAU_ADDMEMBER_HOVER=§eAdd a friend
|
||||
HELP_BAU_DELMEMBER=§8/§ebuild delmember §8- §7Removes a player
|
||||
HELP_BAU_DELMEMBER_HOVER=§eRemoves a player
|
||||
HELP_BAU_SET_SPECTATOR=§8/§ebuild setspectator §8- §7Spectate build server
|
||||
HELP_BAU_SET_SPECTATOR_HOVER=§eSets the Role to Spectator
|
||||
HELP_BAU_SET_BUILDER=§8/§ebuild setbuilder §8- §7Building, WorldEdit, BauSystem features
|
||||
HELP_BAU_SET_BUILDER_HOVER=§eSets the Role to Builder
|
||||
HELP_BAU_SET_SUPERVISOR=§8/§ebuild supervisor §8- §7Starting build server. Saving schematics
|
||||
HELP_BAU_SET_SUPERVISOR_HOVER=§eSets the Role to Supervisor
|
||||
HELP_BAU_TOGGLEWE=§8/§ebuild togglewe §8- §7Permission to use WorldEdit, /testblock
|
||||
HELP_BAU_TOGGLEWE_HOVER=§eToggles WorldEdit permission
|
||||
HELP_BAU_TOGGLEWORLD=§8/§ebuild toggleworld §8- §7/reset, /trace, /fire, /tnt
|
||||
HELP_BAU_TOGGLEWORLD_HOVER=§eToggles world permission
|
||||
HELP_BAU_TOGGLEALL=§8/§ebuild toggleall §8- §7WorldEdit and world
|
||||
HELP_BAU_TOGGLEALL_HOVER=§eToggles WorldEdit and world permissions
|
||||
HELP_BAU_DELETE=§8/§ebuild delete §8- §7Reset your entire build server
|
||||
HELP_BAU_DELETE_HOVER=§eReset build server
|
||||
HELP_BAU_TESTARENA=§8/§ebuild testarena §8- §7Start a test arena
|
||||
@ -115,6 +118,10 @@ MOD_RED_PLUR=Attempted use of mods:\n{0}
|
||||
MOD_YELLOW_SING=§7Deactivate the mod §e{0}§7 to continue playing on §eSteam§8War§7.
|
||||
MOD_YELLOW_PLUR=§7Deactivate the mods\n§e{0}\n§7to continue playing on §eSteam§8War§7.
|
||||
|
||||
MOD_LOADER_LUNAR_CLIENT=§eLunar Client§7 is not supported on §eSteam§8War§7.
|
||||
|
||||
MOD_USE_MODSENDER=§cPlease use the §c§lFabricModSender§c (https://steamwar.de/downloads/) or remove the mod that is rebranding your installation.
|
||||
|
||||
#Various commands
|
||||
ALERT=§f{0}
|
||||
STAT_SERVER=§7Server §e{0}§8: §7Below limit §e{1} §7Server count §e{2}
|
||||
@ -203,12 +210,9 @@ BAU_ADDMEMBER_ADDED_TARGET=§aYou have been added to the world of §e{0}§a.
|
||||
BAU_TP_USAGE=§8/§7build tp §8[§eplayer§8]
|
||||
BAU_TP_NOALLOWED=§cYou are not allowed to teleport to this player's world.
|
||||
BAU_LOCKED_NOALLOWED=§cThe build server is currently locked.
|
||||
BAU_LOCK_BLOCKED=§cYour build lock has prevented §e{0} §cfrom joining.
|
||||
BAU_LOCKED_OPTIONS=§7Build server lock options§8: §cnobody§8, §eserverteam§8, §eteam_and_serverteam§8, §eteam§8, §aopen
|
||||
BAU_LOCKED_OPTIONS=§7Build server lock options§8: §cnobody§8, §eteam§8, §aopen
|
||||
BAU_LOCKED_NOBODY=§7You have locked your build server for all players.
|
||||
BAU_LOCKED_SERVERTEAM=§7You have locked your build server for all players except added server team members.
|
||||
BAU_LOCKED_TEAM_AND_SERVERTEAM=§7You have locked your build server for all players except added team members and server team members.
|
||||
BAU_LOCKED_TEAM=§7You have locked your build server for all players except added team members.
|
||||
BAU_LOCKED_TEAM=§7You've locked your build server for all players except added team members.
|
||||
BAU_LOCKED_OPEN=§7You have opened your build server for all added players.
|
||||
BAU_DELMEMBER_USAGE=§8/§7build delmember §8[§eplayer§8]
|
||||
BAU_DELMEMBER_SELFDEL=§cYou cannot remove yourself!
|
||||
@ -220,13 +224,13 @@ BAU_DELETE_GUI_CANCEL=§cCancel
|
||||
BAU_DELETE_GUI_DELETE=§aDelete
|
||||
BAU_START_ALREADY=§cThis server is already starting.
|
||||
BAU_MEMBER_NOMEMBER=§cThis player is no member of your world!
|
||||
BAU_MEMBER_SET_USAGE=§8/§7build {0} §8[§eplayer§8]
|
||||
BAU_MEMBER_SET_TARGET=§7You are now a §e{1}§7 on the world of §e{0}§7.
|
||||
BAU_MEMBER_SET=§7The player is now a §e{0}§7.
|
||||
BAU_MEMBER_SET_SPECTATOR = spectator
|
||||
BAU_MEMBER_SET_BUILDER = builder
|
||||
BAU_MEMBER_SET_SUPERVISOR = supervisor
|
||||
BAU_START_NOT_ALLOWED = §cYou are not allowed to start this build server.
|
||||
BAU_MEMBER_TOGGLE_USAGE=§8/§7build {0} §8[§eplayer§8]
|
||||
BAU_MEMBER_TOGGLE_TARGET=§aYou are now allowed to §a{1}§e on the world of §e{0}.
|
||||
BAU_MEMBER_TOGGLE=§aThe player is now allowed to {0}.
|
||||
BAU_MEMBER_TOGGLE_TARGET_OFF=§cYou are no longer allowed to §a{1}§e on the world of §e{0}.
|
||||
BAU_MEMBER_TOGGLE_OFF=§cThe player no longer can {0}.
|
||||
BAU_MEMBER_TOGGLE_WORLD_EDIT = use WorldEdit
|
||||
BAU_MEMBER_TOGGLE_WORLD = change Settings
|
||||
|
||||
#ChallengeCommand
|
||||
CHALLENGE_USAGE=§8/§7challenge §8[§eplayer§8]
|
||||
@ -572,8 +576,10 @@ POLL_ANWSER=§7{0}
|
||||
POLL_ANWSER_HOVER=§eChoose {0}
|
||||
|
||||
#TablistManager
|
||||
TABLIST_PHASE_WEBSITE=§8Website: https://§eSteam§8War.de
|
||||
TABLIST_PHASE_DISCORD=§8Discord: https://§eSteam§8War.de/discord
|
||||
TABLIST_PHASE_0=§8Players online: §e{0}
|
||||
TABLIST_PHASE_1=§8Teamspeak: §eSteam§8War.de
|
||||
TABLIST_PHASE_2=§8Discord: §8https://§eSteam§8War.de/discord
|
||||
TABLIST_PHASE_DEFAULT=§8Website: https://§eSteam§8War.de
|
||||
TABLIST_FOOTER=§e{0} {1}§8ms §ePlayers§8: §7{2}
|
||||
TABLIST_BAU=§7§lBuild
|
||||
LIST_COMMAND=§e{0}§8: §7{1}
|
||||
|
@ -16,6 +16,9 @@ DISABLED=§cDerzeit deaktiviert.
|
||||
|
||||
SERVER_START_OVERLOAD=§cDer Serverstart wurde aufgrund von Überlastung abgebrochen. Versuche es später erneut.
|
||||
|
||||
#ModLoader blocker
|
||||
MODLOADER_DENIED=§cMit LiteLoader oder Fabric kannst du keinen Arenen ohne den FabricModSender https://steamwar.de/downloads beitreten.
|
||||
|
||||
#Help command
|
||||
HELP_LOBBY=§7Kehre von überall mit §8/§el §7zur Lobby zurück!
|
||||
HELP_LOBBY_HOVER=§eZurück zur Lobby
|
||||
@ -75,12 +78,12 @@ HELP_BAU_ADDMEMBER=§8/§ebau addmember §8- §7Fügt einen Freund hinzu
|
||||
HELP_BAU_ADDMEMBER_HOVER=§eFüge einen Freund hinzu
|
||||
HELP_BAU_DELMEMBER=§8/§ebau delmember §8- §7Entfernt einen Spieler
|
||||
HELP_BAU_DELMEMBER_HOVER=§eEntfernt einen Spieler
|
||||
HELP_BAU_SET_SPECTATOR=§8/§ebau setspectator §8- §7Zuschauen auf dem Bauserver
|
||||
HELP_BAU_SET_SPECTATOR_HOVER=§eSetzt die Rolle Spectator
|
||||
HELP_BAU_SET_BUILDER=§8/§ebau setbuilder §8- §7Bauen, WorldEdit, BauSystem Features
|
||||
HELP_BAU_SET_BUILDER_HOVER=§eSetzt die Rolle Builder
|
||||
HELP_BAU_SET_SUPERVISOR=§8/§ebuild setsupervisor §8- §7Starten des Baus. Schematics erstellen
|
||||
HELP_BAU_SET_SUPERVISOR_HOVER=§eSetzt die Rolle Supervisor
|
||||
HELP_BAU_TOGGLEWE=§8/§ebau togglewe §8- §7Berechtigung für WorldEdit, /testblock
|
||||
HELP_BAU_TOGGLEWE_HOVER=§eStellt Spielerberechtigungen ein
|
||||
HELP_BAU_TOGGLEWORLD=§8/§ebau toggleworld §8- §7/reset, /trace, /fire, /tnt
|
||||
HELP_BAU_TOGGLEWORLD_HOVER=§eStellt Spielerberechtigungen ein
|
||||
HELP_BAU_TOGGLEALL=§8/§ebuild toggleall §8- §7WorldEdit und Weltberechtigungen
|
||||
HELP_BAU_TOGGLEALL_HOVER=§eStellt Spielerberechtigungen ein
|
||||
HELP_BAU_DELETE=§8/§ebau delete §8- §7Setzt deine Bauwelt zurück
|
||||
HELP_BAU_DELETE_HOVER=§eBauwelt zurücksetzen
|
||||
HELP_BAU_TESTARENA=§8/§ebau testarena §8- §7Starte eine Testarena
|
||||
@ -100,6 +103,10 @@ MOD_RED_PLUR=Versuchte Benutzung der Mods:\n{0}
|
||||
MOD_YELLOW_SING=§7Deaktiviere den Mod §e{0}§7, um weiter auf §eSteam§8War §7spielen zu können.
|
||||
MOD_YELLOW_PLUR=§7Deaktiviere die Mods\n§e{0}\n§7um weiter auf §eSteam§8War §7spielen zu können.
|
||||
|
||||
MOD_LOADER_LUNAR_CLIENT=§eLunar Client§7 ist auf §eSteam§8War§7 nicht unterstützt.
|
||||
|
||||
MOD_USE_MODSENDER=§cBitte nutze den §c§lFabricModSender§c (https://steamwar.de/downloads/) oder entferne den Mod, der deine Fabric-Installation tarnt.
|
||||
|
||||
#Various commands
|
||||
STAT_SERVER=§7Server §e{0}§8: §7Startfähig §e{1} §7Serveranzahl §e{2}
|
||||
|
||||
@ -186,11 +193,8 @@ BAU_ADDMEMBER_ADDED_TARGET=§aDu wurdest zu der Welt von §e{0} §ahinzugefügt.
|
||||
BAU_TP_USAGE=§8/§7bau tp §8[§eSpieler§8]
|
||||
BAU_TP_NOALLOWED=§cDu darfst dich nicht auf diese Welt teleportieren.
|
||||
BAU_LOCKED_NOALLOWED=§cDer Bauserver ist momentan gesperrt.
|
||||
BAU_LOCK_BLOCKED=§cDeine Bausperre hat den Beitritt von §e{0} §cverhindert.
|
||||
BAU_LOCKED_OPTIONS=§7Bauserver-Sperroptionen§8: §cnobody§8, §eserverteam§8, §eteam_and_serverteam§8, §eteam§8, §aopen
|
||||
BAU_LOCKED_OPTIONS=§7Bauserver-Sperroptionen§8: §cnobody§8, §eteam§8, §aopen
|
||||
BAU_LOCKED_NOBODY=§7Du hast deinen Bau für alle Spieler geschlossen.
|
||||
BAU_LOCKED_SERVERTEAM=§7Du hast deinen Bau für alle außer hinzugefügte Serverteammitglieder gesperrt.
|
||||
BAU_LOCKED_TEAM_AND_SERVERTEAM=§7Du hast deinen Bau für alle außer hinzugefügte Teammitglieder und Serverteammitglieder gesperrt.
|
||||
BAU_LOCKED_TEAM=§7Du hast deinen Bau für alle außer hinzugefügte Teammitglieder gesperrt.
|
||||
BAU_LOCKED_OPEN=§7Du hast deinen Bau für alle hinzugefügten Spieler geöffnet.
|
||||
BAU_DELMEMBER_USAGE=§8/§7bau delmember §8[§eSpieler§8]
|
||||
@ -203,13 +207,13 @@ BAU_DELETE_GUI_CANCEL=§cAbbrechen
|
||||
BAU_DELETE_GUI_DELETE=§aLöschen
|
||||
BAU_START_ALREADY=§cDer Server startet bereits.
|
||||
BAU_MEMBER_NOMEMBER=§cDer Spieler ist kein Mitglied deiner Welt!
|
||||
BAU_MEMBER_SET_USAGE=§8/§7bau {0} §8[§eSpieler§8]
|
||||
BAU_MEMBER_SET_TARGET=§7Du bist nun ein §e{1}§7 auf der Welt von §e{0}§7.
|
||||
BAU_MEMBER_SET=§7Der Spieler ist nun §e{0}§7.
|
||||
BAU_MEMBER_SET_SPECTATOR = Zuschauer
|
||||
BAU_MEMBER_SET_BUILDER = Builder
|
||||
BAU_MEMBER_SET_SUPERVISOR = Supervisor
|
||||
BAU_START_NOT_ALLOWED = §cDu darfst diesen Bauserver nicht starten.
|
||||
BAU_MEMBER_TOGGLE_USAGE=§8/§7bau {0} §8[§eSpieler§8]
|
||||
BAU_MEMBER_TOGGLE_TARGET=§aDu kannst nun auf der Welt von §e{0}§a {1}.
|
||||
BAU_MEMBER_TOGGLE=§aDer Spieler darf nun {0}.
|
||||
BAU_MEMBER_TOGGLE_TARGET_OFF=§cDu kannst nun nicht mehr auf der Welt von §e{0}§c {1}.
|
||||
BAU_MEMBER_TOGGLE_OFF=§cDer Spieler darf nun nicht mehr {0}.
|
||||
BAU_MEMBER_TOGGLE_WORLD_EDIT = WorldEdit verwenden
|
||||
BAU_MEMBER_TOGGLE_WORLD = Einstellungen vornehmen
|
||||
|
||||
#ChallengeCommand
|
||||
CHALLENGE_USAGE=§8/§7challenge §8[§eSpieler§8]
|
||||
@ -550,8 +554,10 @@ POLL_ANWSER=§7{0}
|
||||
POLL_ANWSER_HOVER=§e{0} §ewählen
|
||||
|
||||
#TablistManager
|
||||
TABLIST_PHASE_WEBSITE=§8Website: https://§eSteam§8War.de
|
||||
TABLIST_PHASE_DISCORD=§8Discord: https://§eSteam§8War.de/discord
|
||||
TABLIST_PHASE_0=§8Spieler online: §e{0}
|
||||
TABLIST_PHASE_1=§8Teamspeak: §eSteam§8War.de
|
||||
TABLIST_PHASE_2=§8Discord: §8https://§eSteam§8War.de/discord
|
||||
TABLIST_PHASE_DEFAULT=§8Website: https://§eSteam§8War.de
|
||||
TABLIST_FOOTER=§e{0} {1}§8ms §eSpieler§8: §7{2}
|
||||
TABLIST_BAU=§7§lBau
|
||||
LIST_COMMAND=§e{0}§8: §7{1}
|
||||
@ -651,4 +657,4 @@ ADVENT_CALENDAR_TITLE=§eAdventskalender
|
||||
ADVENT_CALENDAR_DAY=§7Tag§8: §e{0}
|
||||
ADVENT_CALENDAR_MESSAGE=§eHast du heute schon dein Geschenk geholt?
|
||||
ADVENT_CALENDAR_MESSAGE_HOVER=§eKlicken zum öffnen!
|
||||
ADVENT_CALENDAR_OPEN=§7Du hast §e{0}§7 aus dem Adventskalender erhalten!
|
||||
ADVENT_CALENDAR_OPEN=§7Du hast §e{0}§7 aus dem Adventskalender erhalten!
|
||||
|
@ -19,35 +19,35 @@
|
||||
|
||||
package de.steamwar.messages;
|
||||
|
||||
import com.velocitypowered.api.command.CommandSource;
|
||||
import com.velocitypowered.api.event.ResultedEvent;
|
||||
import com.velocitypowered.api.event.connection.LoginEvent;
|
||||
import com.velocitypowered.api.proxy.Player;
|
||||
import com.velocitypowered.api.proxy.player.PlayerSettings;
|
||||
import de.steamwar.bungeecore.*;
|
||||
import de.steamwar.bungeecore.bot.listeners.DiscordChatListener;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import de.steamwar.sql.UserPerm;
|
||||
import net.kyori.adventure.audience.Audience;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.event.ClickEvent;
|
||||
import net.kyori.adventure.text.event.HoverEvent;
|
||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
|
||||
import net.md_5.bungee.api.ChatMessageType;
|
||||
import net.md_5.bungee.api.CommandSender;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
import net.md_5.bungee.api.chat.BaseComponent;
|
||||
import net.md_5.bungee.api.chat.ClickEvent;
|
||||
import net.md_5.bungee.api.chat.HoverEvent;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import net.md_5.bungee.api.chat.hover.content.Text;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
import net.md_5.bungee.api.event.LoginEvent;
|
||||
import net.md_5.bungee.command.ConsoleCommandSender;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
import java.util.ResourceBundle;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.logging.Level;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public interface ChatSender {
|
||||
|
||||
static Stream<Player> all() {
|
||||
return VelocityCore.get().getProxyServer().getAllPlayers().stream();
|
||||
static Stream<ProxiedPlayer> all() {
|
||||
return ProxyServer.getInstance().getPlayers().stream();
|
||||
}
|
||||
|
||||
static Stream<ChatSender> allReceivers() {
|
||||
@ -57,7 +57,7 @@ public interface ChatSender {
|
||||
static Stream<ChatSender> globalReceivers() {
|
||||
return all().filter(player -> {
|
||||
Subserver subserver = Subserver.getSubserver(player);
|
||||
return subserver == null || !(subserver.getType() == Servertype.ARENA && subserver.getServer() == player.getCurrentServer().get());
|
||||
return subserver == null || !(subserver.getType() == Servertype.ARENA && subserver.getServer() == player.getServer().getInfo());
|
||||
}).map(ChatSender::of);
|
||||
}
|
||||
|
||||
@ -69,10 +69,10 @@ public interface ChatSender {
|
||||
|
||||
Locale getLocale();
|
||||
boolean chatShown();
|
||||
void sendMessage(Component msg);
|
||||
void sendMessage(ChatMessageType type, BaseComponent... msg);
|
||||
|
||||
default void chat(Message message) {
|
||||
send(false, null, null, message);
|
||||
send(false, ChatMessageType.CHAT, null, null, message);
|
||||
}
|
||||
|
||||
default void system(String format, Object... params) {
|
||||
@ -80,11 +80,11 @@ public interface ChatSender {
|
||||
}
|
||||
|
||||
default void system(Message message) {
|
||||
send(true, null, null, message);
|
||||
send(true, ChatMessageType.SYSTEM, null, null, message);
|
||||
}
|
||||
|
||||
default void system(String format, Message onHover, ClickEvent onClick, Object... params) {
|
||||
send(true, onHover, onClick, new Message(format, params));
|
||||
send(true, ChatMessageType.SYSTEM, onHover, onClick, new Message(format, params));
|
||||
}
|
||||
|
||||
default void prefixless(String format, Object... params) {
|
||||
@ -92,20 +92,20 @@ public interface ChatSender {
|
||||
}
|
||||
|
||||
default void prefixless(String format, Message onHover, ClickEvent onClick, Object... params) {
|
||||
send(false, onHover, onClick, new Message(format, params));
|
||||
send(false, ChatMessageType.SYSTEM, onHover, onClick, new Message(format, params));
|
||||
}
|
||||
|
||||
default void send(boolean prefixed, Message onHover, ClickEvent onClick, Message message) {
|
||||
Component msg = parseToComponent(prefixed, message);
|
||||
default void send(boolean prefixed, ChatMessageType type, Message onHover, ClickEvent onClick, Message message) {
|
||||
TextComponent msg = parseToComponent(prefixed, message);
|
||||
if(onHover != null)
|
||||
msg = msg.hoverEvent(HoverEvent.showText(parse(false, onHover)));
|
||||
msg.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new Text(parse(false, onHover))));
|
||||
if(onClick != null)
|
||||
msg = msg.clickEvent(onClick);
|
||||
sendMessage(msg);
|
||||
msg.setClickEvent(onClick);
|
||||
sendMessage(type, msg);
|
||||
}
|
||||
|
||||
default Component parseToComponent(boolean prefixed, Message message) {
|
||||
return parse(prefixed, message);
|
||||
default TextComponent parseToComponent(boolean prefixed, Message message) {
|
||||
return new TextComponent(parse(prefixed, message));
|
||||
}
|
||||
|
||||
default String parseToPlain(String format, Object... params) {
|
||||
@ -113,7 +113,7 @@ public interface ChatSender {
|
||||
}
|
||||
|
||||
default String parseToPlain(Message message) {
|
||||
return PlainTextComponentSerializer.plainText().serialize(parseToComponent(false, message));
|
||||
return parseToComponent(false, message).toPlainText();
|
||||
}
|
||||
|
||||
default String parseToLegacy(String format, Object... params) {
|
||||
@ -121,14 +121,14 @@ public interface ChatSender {
|
||||
}
|
||||
|
||||
default String parseToLegacy(Message message) {
|
||||
return LegacyComponentSerializer.legacySection().serialize(parseToComponent(false, message));
|
||||
return parseToComponent(false, message).toLegacyText();
|
||||
}
|
||||
|
||||
default Component parse(boolean prefixed, String format, Object... params) {
|
||||
default BaseComponent[] parse(boolean prefixed, String format, Object... params) {
|
||||
return parse(prefixed, new Message(format, params));
|
||||
}
|
||||
|
||||
default Component parse(boolean prefixed, Message message) {
|
||||
default BaseComponent[] parse(boolean prefixed, Message message) {
|
||||
Locale locale = getLocale();
|
||||
ResourceBundle resourceBundle = SteamwarResourceBundle.getResourceBundle(locale);
|
||||
String pattern = "";
|
||||
@ -141,20 +141,20 @@ public interface ChatSender {
|
||||
for (int i = 0; i < params.length; i++) {
|
||||
if(params[i] instanceof Message) {
|
||||
params[i] = parseToLegacy((Message) params[i]);
|
||||
} else if(params[i] instanceof Date d) {
|
||||
params[i] = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT, locale).format((Date) d);
|
||||
} else if(params[i] instanceof Date) {
|
||||
params[i] = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT, locale).format((Date) params[i]);
|
||||
} else if(params[i] instanceof SteamwarUser) {
|
||||
params[i] = ((SteamwarUser) params[i]).getUserName();
|
||||
} else if(params[i] instanceof Player player) {
|
||||
params[i] = player.getGameProfile().getName();
|
||||
} else if(params[i] instanceof ChatSender cs) {
|
||||
params[i] = cs.user().getUserName();
|
||||
} else if(params[i] instanceof ProxiedPlayer) {
|
||||
params[i] = ((ProxiedPlayer) params[i]).getName();
|
||||
} else if(params[i] instanceof ChatSender) {
|
||||
params[i] = ((ChatSender) params[i]).user().getUserName();
|
||||
}
|
||||
}
|
||||
return LegacyComponentSerializer.legacySection().deserialize(format.format(params));
|
||||
return TextComponent.fromLegacyText(format.format(params));
|
||||
}
|
||||
|
||||
static ChatSender ofProxiedPlayer(Player player, Consumer<Component> sendMessage) {
|
||||
static ChatSender ofProxiedPlayer(ProxiedPlayer player, BiConsumer<ChatMessageType, BaseComponent[]> sendMessage) {
|
||||
return new ChatSender() {
|
||||
@Override
|
||||
public SteamwarUser user() {
|
||||
@ -168,27 +168,27 @@ public interface ChatSender {
|
||||
|
||||
@Override
|
||||
public boolean chatShown() {
|
||||
return player.getPlayerSettings().getChatMode() == PlayerSettings.ChatMode.SHOWN;
|
||||
return player.getChatMode() == ProxiedPlayer.ChatMode.SHOWN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage(Component msg) {
|
||||
sendMessage.accept(msg);
|
||||
public void sendMessage(ChatMessageType type, BaseComponent... msg) {
|
||||
sendMessage.accept(type, msg);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
static ChatSender of(Player player) {
|
||||
static ChatSender of(ProxiedPlayer player) {
|
||||
return ofProxiedPlayer(player, player::sendMessage);
|
||||
}
|
||||
|
||||
static ChatSender disconnect(Player player) {
|
||||
return ofProxiedPlayer(player, player::disconnect);
|
||||
static ChatSender disconnect(ProxiedPlayer player) {
|
||||
return ofProxiedPlayer(player, (type, msg) -> player.disconnect(msg));
|
||||
}
|
||||
|
||||
static ChatSender of(CommandSource sender) {
|
||||
if(sender instanceof Player player)
|
||||
return of(player);
|
||||
static ChatSender of(CommandSender sender) {
|
||||
if(sender instanceof ProxiedPlayer)
|
||||
return of((ProxiedPlayer) sender);
|
||||
|
||||
//Console
|
||||
return new ChatSender() {
|
||||
@ -208,21 +208,21 @@ public interface ChatSender {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage(Component msg) {
|
||||
public void sendMessage(ChatMessageType type, BaseComponent... msg) {
|
||||
sender.sendMessage(msg);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
static ChatSender console() {
|
||||
return of(VelocityCore.get().getProxyServer().getConsoleCommandSource());
|
||||
return of(ConsoleCommandSender.getInstance());
|
||||
}
|
||||
|
||||
static ChatSender of(LoginEvent event) {
|
||||
return new ChatSender() {
|
||||
@Override
|
||||
public SteamwarUser user() {
|
||||
return SteamwarUser.get(event.getPlayer().getUniqueId());
|
||||
return SteamwarUser.get(event.getConnection().getUniqueId());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -236,8 +236,8 @@ public interface ChatSender {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage(Component msg) {
|
||||
event.setResult(ResultedEvent.ComponentResult.denied(msg));
|
||||
public void sendMessage(ChatMessageType type, BaseComponent... msg) {
|
||||
event.setCancelReason(msg);
|
||||
}
|
||||
};
|
||||
}
|
||||
@ -260,11 +260,11 @@ public interface ChatSender {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage(Component msg) {
|
||||
public void sendMessage(ChatMessageType type, BaseComponent... msg) {
|
||||
try {
|
||||
channel.send("<t:" + (System.currentTimeMillis() / 1000) + "> " + PlainTextComponentSerializer.plainText().serialize(msg));
|
||||
channel.send("<t:" + (System.currentTimeMillis() / 1000) + "> " + new TextComponent(msg).toPlainText());
|
||||
} catch (Exception e) {
|
||||
VelocityCore.get().getLogger().log(Level.SEVERE, "Could not send chat message to discord", e);
|
||||
BungeeCore.get().getLogger().log(Level.SEVERE, "Could not send chat message to discord", e);
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -288,11 +288,11 @@ public interface ChatSender {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage(Component msg) {
|
||||
public void sendMessage(ChatMessageType type, BaseComponent... msg) {
|
||||
try {
|
||||
message.delete().queue();
|
||||
} catch (Exception e) {
|
||||
VelocityCore.get().getLogger().log(Level.SEVERE, "Could not send chat reply to discord user", e);
|
||||
BungeeCore.get().getLogger().log(Level.SEVERE, "Could not send chat reply to discord user", e);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -20,9 +20,6 @@
|
||||
package de.steamwar.messages;
|
||||
|
||||
import de.steamwar.bungeecore.Message;
|
||||
import net.kyori.adventure.key.Key;
|
||||
import net.kyori.adventure.translation.GlobalTranslator;
|
||||
import net.kyori.adventure.translation.TranslationRegistry;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
@ -30,28 +27,12 @@ import java.util.*;
|
||||
|
||||
public class SteamwarResourceBundle extends PropertyResourceBundle {
|
||||
|
||||
public static final TranslationRegistry registry = TranslationRegistry.create(Key.key("steamwar:i18n"));
|
||||
|
||||
static {
|
||||
GlobalTranslator.translator().addSource(registry);
|
||||
}
|
||||
|
||||
private static final String BASE_PATH = "/" + "de.steamwar.messages.BungeeCore".replace('.', '/');
|
||||
|
||||
private static final Map<Locale, ResourceBundle> localeBundles = new HashMap<>();
|
||||
|
||||
private static final Map<String, ResourceBundle> bundles = new HashMap<>();
|
||||
|
||||
public static ResourceBundle getResourceBundle(Locale locale) {
|
||||
return getResourceBundleTree(locale);
|
||||
}
|
||||
|
||||
private static ResourceBundle getResourceBundleTree(Locale locale) {
|
||||
return localeBundles.computeIfAbsent(locale, locale1 -> {
|
||||
ResourceBundle bundle = getResourceBundle(locale.toString(), getResourceBundle(locale.getLanguage(), getResourceBundle( "", null)));
|
||||
registry.registerAll(locale, bundle, true);
|
||||
return bundle;
|
||||
});
|
||||
return getResourceBundle(locale.toString(), getResourceBundle(locale.getLanguage(), getResourceBundle( "", null)));
|
||||
}
|
||||
|
||||
private static synchronized ResourceBundle getResourceBundle(String locale, ResourceBundle parent) {
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
package de.steamwar.sql;
|
||||
|
||||
import de.steamwar.bungeecore.VelocityCore;
|
||||
import de.steamwar.bungeecore.BungeeCore;
|
||||
import de.steamwar.sql.internal.SQLConfig;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
@ -27,7 +27,7 @@ import java.util.logging.Logger;
|
||||
public class SQLConfigImpl implements SQLConfig {
|
||||
@Override
|
||||
public Logger getLogger() {
|
||||
return VelocityCore.get().getLogger();
|
||||
return BungeeCore.get().getLogger();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -19,13 +19,14 @@
|
||||
|
||||
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.BungeeCore;
|
||||
import de.steamwar.bungeecore.commands.CheckCommand;
|
||||
import org.simpleyaml.configuration.Configuration;
|
||||
import org.simpleyaml.configuration.file.YamlFile;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
import net.md_5.bungee.api.config.ServerInfo;
|
||||
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.IOException;
|
||||
@ -53,12 +54,12 @@ public class SQLWrapperImpl implements SQLWrapper {
|
||||
|
||||
@Override
|
||||
public void loadSchemTypes(List<SchematicType> tmpTypes, Map<String, SchematicType> tmpFromDB) {
|
||||
File folder = new File(VelocityCore.get().getDataDirectory().getParent().toFile(), "FightSystem");
|
||||
File folder = new File(BungeeCore.get().getDataFolder().getParentFile(), "FightSystem");
|
||||
if(folder.exists()) {
|
||||
for(File configFile : Arrays.stream(folder.listFiles((file, name) -> name.endsWith(".yml") && !name.endsWith(".kits.yml"))).sorted().collect(Collectors.toList())) {
|
||||
Configuration config;
|
||||
try {
|
||||
config = YamlFile.loadConfiguration(configFile);
|
||||
config = ConfigurationProvider.getProvider(YamlConfiguration.class).load(configFile);
|
||||
} catch (IOException e) {
|
||||
throw new SecurityException("Could not load SchematicTypes", e);
|
||||
}
|
||||
@ -95,10 +96,10 @@ public class SQLWrapperImpl implements SQLWrapper {
|
||||
@Override
|
||||
public void additionalExceptionMetadata(StringBuilder builder) {
|
||||
builder.append("\nServers: ");
|
||||
for(RegisteredServer server : VelocityCore.get().getProxyServer().getAllServers()) {
|
||||
builder.append(server.getServerInfo().getName()).append("(");
|
||||
for(Player player : server.getPlayersConnected()) {
|
||||
builder.append(player.getUsername()).append(" ");
|
||||
for(Map.Entry<String, ServerInfo> server : ProxyServer.getInstance().getServers().entrySet()) {
|
||||
builder.append(server.getKey()).append("(");
|
||||
for(ProxiedPlayer player : server.getValue().getPlayers()) {
|
||||
builder.append(player.getName()).append(" ");
|
||||
}
|
||||
builder.append(") ");
|
||||
}
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren