geforkt von SteamWar/BungeeCore
A Starting point
Dieser Commit ist enthalten in:
Ursprung
59b2e397ba
Commit
c6ccaa6abb
18
build.gradle
18
build.gradle
@ -38,8 +38,8 @@ version ''
|
||||
|
||||
compileJava.options.encoding = 'UTF-8'
|
||||
|
||||
sourceCompatibility = 1.8
|
||||
targetCompatibility = 1.8
|
||||
sourceCompatibility = 17
|
||||
targetCompatibility = 17
|
||||
|
||||
mainClassName = ''
|
||||
|
||||
@ -58,13 +58,17 @@ sourceSets {
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven {
|
||||
url 'https://m2.dv8tion.net/releases'
|
||||
name = 'papermc'
|
||||
url = 'https://repo.papermc.io/repository/maven-public/'
|
||||
}
|
||||
maven {
|
||||
url = 'https://m2.dv8tion.net/releases'
|
||||
content {
|
||||
includeGroup 'net.dv8tion'
|
||||
}
|
||||
}
|
||||
maven {
|
||||
url 'https://repo.lunarclient.dev'
|
||||
url = 'https://repo.lunarclient.dev'
|
||||
content {
|
||||
includeGroup 'com.lunarclient'
|
||||
}
|
||||
@ -86,7 +90,9 @@ dependencies {
|
||||
annotationProcessor 'org.projectlombok:lombok:1.18.22'
|
||||
testAnnotationProcessor 'org.projectlombok:lombok:1.18.22'
|
||||
|
||||
compileOnly 'de.steamwar:waterfall:RELEASE'
|
||||
compileOnly 'com.velocitypowered:velocity-api:3.3.0-SNAPSHOT'
|
||||
annotationProcessor 'com.velocitypowered:velocity-api:3.3.0-SNAPSHOT'
|
||||
|
||||
compileOnly 'de.steamwar:persistentbungeecore:RELEASE'
|
||||
implementation("net.dv8tion:JDA:4.4.0_352") {
|
||||
exclude module: 'opus-java'
|
||||
@ -96,4 +102,6 @@ dependencies {
|
||||
|
||||
implementation 'com.lunarclient:apollo-api:1.1.0'
|
||||
implementation 'com.lunarclient:apollo-common:1.1.0'
|
||||
|
||||
implementation 'org.reflections:reflections:0.10.2'
|
||||
}
|
@ -26,6 +26,6 @@ pluginManagement {
|
||||
}
|
||||
}
|
||||
|
||||
rootProject.name = 'BungeeCore'
|
||||
rootProject.name = 'VelocityCore'
|
||||
|
||||
include 'CommonCore'
|
@ -19,7 +19,7 @@
|
||||
|
||||
package de.steamwar.bungeecore;
|
||||
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
import de.steamwar.messages.ChatSender;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@ -29,14 +29,15 @@ class Broadcaster {
|
||||
private int lastBroadCast = 0;
|
||||
|
||||
Broadcaster(){
|
||||
ProxyServer.getInstance().getScheduler().schedule(BungeeCore.get(), () -> {
|
||||
if(!ProxyServer.getInstance().getPlayers().isEmpty() && broadCastMsgs.length > 0)
|
||||
BungeeCore.broadcast(BungeeCore.CHAT_PREFIX + broadCastMsgs[lastBroadCast]);
|
||||
VelocityCore.get().getProxyServer().getScheduler().buildTask(VelocityCore.get(), () -> {
|
||||
if(!VelocityCore.get().getProxyServer().getAllPlayers().isEmpty() && broadCastMsgs.length > 0) {
|
||||
VelocityCore.broadcast(VelocityCore.CHAT_PREFIX + broadCastMsgs[lastBroadCast]);
|
||||
}
|
||||
lastBroadCast++;
|
||||
if(lastBroadCast == broadCastMsgs.length){
|
||||
lastBroadCast = 0;
|
||||
}
|
||||
}, 10, 10, TimeUnit.MINUTES);
|
||||
}).repeat(10, TimeUnit.MINUTES);
|
||||
}
|
||||
|
||||
static void setBroadCastMsgs(String[] broadCastMsgs) {
|
||||
|
@ -21,8 +21,7 @@ package de.steamwar.bungeecore;
|
||||
|
||||
import de.steamwar.sql.EventFight;
|
||||
import de.steamwar.sql.Team;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
import net.md_5.bungee.api.chat.ClickEvent;
|
||||
import net.kyori.adventure.text.event.ClickEvent;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import java.util.HashMap;
|
||||
@ -42,7 +41,7 @@ public class EventStarter {
|
||||
|
||||
public EventStarter() {
|
||||
EventFight.loadAllComingFights();
|
||||
ProxyServer.getInstance().getScheduler().schedule(BungeeCore.get(), this::run, 1, 10, TimeUnit.SECONDS);
|
||||
VelocityCore.get().getProxyServer().getScheduler().buildTask(VelocityCore.get(), this::run).repeat(10, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
public static Map<Integer, Subserver> getEventServer() {
|
||||
@ -59,7 +58,7 @@ public class EventStarter {
|
||||
Team red = Team.get(next.getTeamRed());
|
||||
|
||||
//Don't start EventServer if not the event bungee
|
||||
if(BungeeCore.EVENT_MODE || next.getSpectatePort() == 0) {
|
||||
if(VelocityCore.EVENT_MODE || next.getSpectatePort() == 0) {
|
||||
ServerStarter starter = new ServerStarter().event(next);
|
||||
|
||||
starter.callback(subserver -> {
|
||||
@ -68,10 +67,10 @@ public class EventStarter {
|
||||
}).start();
|
||||
|
||||
Message.broadcast("EVENT_FIGHT_BROADCAST", "EVENT_FIGHT_BROADCAST_HOVER",
|
||||
new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/event " + blue.getTeamKuerzel()), blue.getTeamColor(), blue.getTeamName(), red.getTeamColor(), red.getTeamName());
|
||||
ClickEvent.runCommand("/event " + blue.getTeamKuerzel()), blue.getTeamColor(), blue.getTeamName(), red.getTeamColor(), red.getTeamName());
|
||||
} else {
|
||||
Message.broadcast("EVENT_FIGHT_BROADCAST", "EVENT_FIGHT_BROADCAST_HOVER",
|
||||
new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/" + spectatePorts.get(next.getSpectatePort())), blue.getTeamColor(), blue.getTeamName(), red.getTeamColor(), red.getTeamName());
|
||||
ClickEvent.runCommand("/" + spectatePorts.get(next.getSpectatePort())), blue.getTeamColor(), blue.getTeamName(), red.getTeamColor(), red.getTeamName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -19,12 +19,13 @@
|
||||
|
||||
package de.steamwar.bungeecore;
|
||||
|
||||
import com.velocitypowered.api.command.CommandSource;
|
||||
import de.steamwar.messages.ChatSender;
|
||||
import de.steamwar.messages.SteamwarResourceBundle;
|
||||
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 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 java.text.DateFormat;
|
||||
import java.text.MessageFormat;
|
||||
@ -35,17 +36,17 @@ import java.util.ResourceBundle;
|
||||
public class Message {
|
||||
|
||||
@Deprecated
|
||||
public static TextComponent parseToComponent(String message, boolean prefixed, CommandSender sender, Object... params){
|
||||
return new TextComponent(TextComponent.fromLegacyText(parse(message, prefixed, locale(sender), params)));
|
||||
public static Component parseToComponent(String message, boolean prefixed, CommandSource sender, Object... params){
|
||||
return LegacyComponentSerializer.legacySection().deserialize(parse(message, prefixed, locale(sender), params));
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static String parsePrefixed(String message, CommandSender sender, Object... params){
|
||||
public static String parsePrefixed(String message, CommandSource sender, Object... params){
|
||||
return parse(message, true, locale(sender), params);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static String parse(String message, CommandSender sender, Object... params){
|
||||
public static String parse(String message, CommandSource sender, Object... params){
|
||||
return parse(message, false, locale(sender), params);
|
||||
}
|
||||
|
||||
@ -55,8 +56,8 @@ public class Message {
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
private static Locale locale(CommandSender sender) {
|
||||
return ChatSender.of(sender).getLocale();
|
||||
private static Locale locale(CommandSource sender) {
|
||||
return sender.get(Identity.LOCALE).orElse(Locale.GERMAN);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@ -82,32 +83,32 @@ public class Message {
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static void send(String message, CommandSender sender, Object... params){
|
||||
send(message, true, sender, ChatMessageType.SYSTEM, null, null, params);
|
||||
public static void send(String message, CommandSource sender, Object... params){
|
||||
send(message, true, sender, null, null, params);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static void sendPrefixless(String message, CommandSender sender, Object... params){
|
||||
send(message, false, sender, ChatMessageType.SYSTEM, null, null, params);
|
||||
public static void sendPrefixless(String message, CommandSource sender, Object... params){
|
||||
send(message, false, sender, null, null, params);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static void send(String message, CommandSender sender, String onHover, ClickEvent onClick, Object... params){
|
||||
send(message, true, sender, ChatMessageType.SYSTEM, onHover, onClick, params);
|
||||
public static void send(String message, CommandSource sender, String onHover, ClickEvent onClick, Object... params){
|
||||
send(message, true, sender, onHover, onClick, params);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static void sendPrefixless(String message, CommandSender sender, String onHover, ClickEvent onClick, Object... params){
|
||||
send(message, false, sender, ChatMessageType.SYSTEM, onHover, onClick, params);
|
||||
public static void sendPrefixless(String message, CommandSource sender, String onHover, ClickEvent onClick, Object... params){
|
||||
send(message, false, sender, onHover, onClick, params);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
private static void send(String message, boolean prefixed, CommandSender s, ChatMessageType type, String onHover, ClickEvent onClick, Object... params){
|
||||
private static void send(String message, boolean prefixed, CommandSource s, String onHover, ClickEvent onClick, Object... params){
|
||||
ChatSender sender = ChatSender.of(s);
|
||||
if(type == ChatMessageType.CHAT && !sender.chatShown())
|
||||
if(!sender.chatShown())
|
||||
return;
|
||||
|
||||
sender.send(prefixed, type, onHover != null ? new Message("PLAIN_STRING", onHover) : null, onClick, new Message(message, params));
|
||||
sender.send(prefixed, onHover != null ? new Message("PLAIN_STRING", onHover) : null, onClick, new Message(message, params));
|
||||
}
|
||||
|
||||
public static void broadcast(String message, Object... params) {
|
||||
|
@ -74,7 +74,7 @@ public abstract class Node {
|
||||
protected Node(String hostname) {
|
||||
this.hostname = hostname;
|
||||
nodes.add(this);
|
||||
BungeeCord.getInstance().getScheduler().schedule(BungeeCore.get(), this::calcLoadLimit, 1, 2, TimeUnit.SECONDS);
|
||||
VelocityCore.get().getProxyServer().getScheduler().buildTask(VelocityCore.get(), () -> calcLoadLimit()).repeat(2, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
public void execute(String... command) {
|
||||
@ -83,7 +83,7 @@ public abstract class Node {
|
||||
} catch (IOException e) {
|
||||
throw new SecurityException("Could not execute command", e);
|
||||
} catch (InterruptedException e) {
|
||||
ProxyServer.getInstance().getLogger().log(Level.SEVERE, "Interrupted during execution", e);
|
||||
VelocityCore.get().getLogger().log(Level.SEVERE, "Interrupted during execution", e);
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
}
|
||||
@ -155,7 +155,7 @@ public abstract class Node {
|
||||
try (BufferedReader meminfo = new BufferedReader(new InputStreamReader(Files.newInputStream(MEMINFO.toPath())))) {
|
||||
calcLoadLimit(meminfo);
|
||||
} catch (IOException e) {
|
||||
BungeeCore.get().getLogger().log(Level.SEVERE, "Could not read local load", e);
|
||||
VelocityCore.get().getLogger().log(Level.SEVERE, "Could not read local load", e);
|
||||
belowLoadLimit = false;
|
||||
}
|
||||
}
|
||||
@ -170,7 +170,7 @@ public abstract class Node {
|
||||
|
||||
public RemoteNode(String hostname) {
|
||||
super(hostname);
|
||||
BungeeCore.get().getLogger().log(Level.INFO, "Added node " + hostname);
|
||||
VelocityCore.get().getLogger().log(Level.INFO, "Added node " + hostname);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -207,7 +207,7 @@ public abstract class Node {
|
||||
}
|
||||
} catch (IOException e) {
|
||||
if(belowLoadLimit)
|
||||
BungeeCore.get().getLogger().log(Level.SEVERE, "Could read remote load", e);
|
||||
VelocityCore.get().getLogger().log(Level.SEVERE, "Could read remote load", e);
|
||||
belowLoadLimit = false;
|
||||
} catch (InterruptedException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
|
@ -1,9 +1,9 @@
|
||||
package de.steamwar.bungeecore;
|
||||
|
||||
import com.velocitypowered.api.proxy.Player;
|
||||
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;
|
||||
@ -19,8 +19,8 @@ import java.util.stream.Collectors;
|
||||
|
||||
public class ServerStarter {
|
||||
|
||||
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 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 String SERVER_PATH = "/servers/";
|
||||
private static final String USER_HOME = System.getProperty("user.home") + "/";
|
||||
@ -50,7 +50,7 @@ public class ServerStarter {
|
||||
private ServerConstructor constructor = (serverName, port, builder, shutdownCallback, failureCallback) -> new Arenaserver(serverName, gameMode, fightMap, allowMerge, port, builder, shutdownCallback);
|
||||
private Consumer<Subserver> callback = subserver -> {};
|
||||
|
||||
private final Set<ProxiedPlayer> playersToSend = new HashSet<>();
|
||||
private final Set<Player> playersToSend = new HashSet<>();
|
||||
private final Map<String, String> arguments = new HashMap<>();
|
||||
|
||||
public ServerStarter arena(ArenaMode mode, String map) {
|
||||
@ -68,7 +68,7 @@ public class ServerStarter {
|
||||
|
||||
public ServerStarter event(EventFight eventFight) {
|
||||
arena(ArenaMode.getByInternal(eventFight.getSpielmodus()), eventFight.getMap());
|
||||
node = BungeeCore.local;
|
||||
node = VelocityCore.local;
|
||||
worldDir = EVENT_PATH;
|
||||
worldCleanup = () -> {};
|
||||
arguments.put("fightID", String.valueOf(eventFight.getFightID()));
|
||||
@ -81,7 +81,7 @@ public class ServerStarter {
|
||||
return this;
|
||||
}
|
||||
|
||||
public ServerStarter test(ArenaMode mode, String map, ProxiedPlayer owner) {
|
||||
public ServerStarter test(ArenaMode mode, String map, Player owner) {
|
||||
arena(mode, map);
|
||||
buildWithTemp(owner);
|
||||
portrange = BAU_PORTS;
|
||||
@ -89,12 +89,12 @@ public class ServerStarter {
|
||||
return send(owner);
|
||||
}
|
||||
|
||||
public ServerStarter blueLeader(ProxiedPlayer player) {
|
||||
public ServerStarter blueLeader(Player player) {
|
||||
arguments.put("blueLeader", player.getUniqueId().toString());
|
||||
return send(player);
|
||||
}
|
||||
|
||||
public ServerStarter redLeader(ProxiedPlayer player) {
|
||||
public ServerStarter redLeader(Player player) {
|
||||
arguments.put("redLeader", player.getUniqueId().toString());
|
||||
return send(player);
|
||||
}
|
||||
@ -133,7 +133,7 @@ public class ServerStarter {
|
||||
startCondition = () -> {
|
||||
Bauserver subserver = Bauserver.get(owner);
|
||||
if(subserver != null) {
|
||||
for(ProxiedPlayer p : playersToSend)
|
||||
for(Player p : playersToSend)
|
||||
SubserverSystem.sendPlayer(subserver, p);
|
||||
return false;
|
||||
}
|
||||
@ -143,7 +143,7 @@ public class ServerStarter {
|
||||
return bauweltMember.isSupervisor();
|
||||
});
|
||||
if (!atLeastOneSupervisor) {
|
||||
for (ProxiedPlayer p : playersToSend) {
|
||||
for (Player p : playersToSend) {
|
||||
ChatSender.of(p).system("BAU_START_NOT_ALLOWED");
|
||||
}
|
||||
}
|
||||
@ -153,7 +153,7 @@ public class ServerStarter {
|
||||
return this;
|
||||
}
|
||||
|
||||
public ServerStarter tutorial(ProxiedPlayer owner, Tutorial tutorial) {
|
||||
public ServerStarter tutorial(Player owner, Tutorial tutorial) {
|
||||
directory = new File(SERVER_PATH, "Tutorial");
|
||||
buildWithTemp(owner);
|
||||
tempWorld(TUTORIAL_PATH + tutorial.getTutorialId());
|
||||
@ -167,7 +167,7 @@ public class ServerStarter {
|
||||
worldCleanup = () -> SubserverSystem.deleteFolder(node, worldDir + worldName);
|
||||
}
|
||||
|
||||
private void buildWithTemp(ProxiedPlayer owner) {
|
||||
private void buildWithTemp(Player owner) {
|
||||
build(owner.getUniqueId());
|
||||
|
||||
// Stop existing build server
|
||||
@ -201,7 +201,7 @@ public class ServerStarter {
|
||||
startCondition = () -> {
|
||||
Builderserver subserver = Builderserver.get(worldName);
|
||||
if (subserver != null) {
|
||||
for(ProxiedPlayer p : playersToSend)
|
||||
for(Player p : playersToSend)
|
||||
SubserverSystem.sendPlayer(subserver, p);
|
||||
return false;
|
||||
}
|
||||
@ -222,7 +222,7 @@ public class ServerStarter {
|
||||
return this;
|
||||
}
|
||||
|
||||
public ServerStarter send(ProxiedPlayer player) {
|
||||
public ServerStarter send(Player player) {
|
||||
playersToSend.add(player);
|
||||
return this;
|
||||
}
|
||||
@ -242,7 +242,7 @@ public class ServerStarter {
|
||||
if(node == null) {
|
||||
node = Node.getNode();
|
||||
if(node == null) {
|
||||
for (ProxiedPlayer p : playersToSend)
|
||||
for (Player p : playersToSend)
|
||||
ChatSender.of(p).system("SERVER_START_OVERLOAD");
|
||||
|
||||
return false;
|
||||
@ -282,13 +282,13 @@ public class ServerStarter {
|
||||
}
|
||||
|
||||
private void postStart(Subserver subserver) {
|
||||
for(ProxiedPlayer p : playersToSend)
|
||||
for(Player p : playersToSend)
|
||||
SubserverSystem.sendPlayer(subserver, p);
|
||||
|
||||
callback.accept(subserver);
|
||||
}
|
||||
|
||||
private static boolean startingBau(ProxiedPlayer p) {
|
||||
private static boolean startingBau(Player p) {
|
||||
Bauserver subserver = Bauserver.get(p.getUniqueId());
|
||||
if(subserver != null && !subserver.isStarted()) {
|
||||
ChatSender.of(p).system("BAU_START_ALREADY");
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
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;
|
||||
@ -37,10 +38,13 @@ public class SubserverSystem {
|
||||
node.execute("rm", "-r", worldName);
|
||||
}
|
||||
|
||||
public static void sendDeniedMessage(ProxiedPlayer p, UUID owner){
|
||||
ProxiedPlayer o = ProxyServer.getInstance().getPlayer(owner);
|
||||
if(o == null)
|
||||
public static void sendDeniedMessage(Player p, UUID owner){
|
||||
Player o = VelocityCore.get().getProxyServer().getPlayer(owner).orElse(null);
|
||||
|
||||
if(o == null){
|
||||
return;
|
||||
}
|
||||
|
||||
if(IgnoreSystem.isIgnored(owner, p.getUniqueId())){
|
||||
Message.send("SERVER_IGNORED", p);
|
||||
return;
|
||||
|
@ -19,6 +19,15 @@
|
||||
|
||||
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.*;
|
||||
@ -27,6 +36,8 @@ import de.steamwar.bungeecore.mods.ServerListPing;
|
||||
import de.steamwar.bungeecore.mods.*;
|
||||
import de.steamwar.bungeecore.network.BungeeNetworkHandler;
|
||||
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;
|
||||
@ -36,28 +47,23 @@ import de.steamwar.sql.SteamwarUser;
|
||||
import de.steamwar.sql.Team;
|
||||
import de.steamwar.sql.UserElo;
|
||||
import de.steamwar.sql.internal.Statement;
|
||||
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 lombok.Getter;
|
||||
import org.reflections.Reflections;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.nio.file.Path;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class BungeeCore extends Plugin {
|
||||
@Plugin(
|
||||
id = "velocitycore",
|
||||
name = "VelocityCore",
|
||||
authors = {"SteamWar"}
|
||||
)
|
||||
public class VelocityCore {
|
||||
|
||||
public static boolean MAIN_SERVER;
|
||||
|
||||
@ -65,35 +71,66 @@ public class BungeeCore extends Plugin {
|
||||
public static String LOBBY_SERVER;
|
||||
public static boolean EVENT_MODE;
|
||||
|
||||
private static BungeeCore instance;
|
||||
private static VelocityCore instance;
|
||||
|
||||
public static Node local;
|
||||
private ErrorLogger errorLogger;
|
||||
private TablistManager tablistManager;
|
||||
|
||||
@Override
|
||||
public void onEnable(){
|
||||
@Getter
|
||||
private final ProxyServer proxyServer;
|
||||
|
||||
@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.getInstance().getConfig().getListeners().stream().anyMatch(info -> ((InetSocketAddress) info.getSocketAddress()).getPort() == 25565);
|
||||
MAIN_SERVER = proxyServer.getBoundAddress().getPort() == 25565;
|
||||
loadConfig();
|
||||
|
||||
injector = injector.createChildInjector(new SteamWarModule(this));
|
||||
|
||||
errorLogger = new ErrorLogger();
|
||||
|
||||
SWCommandUtils.init((SWTypeMapperCreator<TypeMapper<Object>, CommandSender, Object>) (mapper, tabCompleter) -> new TypeMapper<Object>() {
|
||||
SWCommandUtils.init((SWTypeMapperCreator<TypeMapper<Object>, Player, Object>) (mapper, tabCompleter) -> new TypeMapper<Object>() {
|
||||
@Override
|
||||
public Object map(CommandSender commandSender, String[] previousArguments, String s) {
|
||||
public Object map(Player commandSender, String[] previousArguments, String s) {
|
||||
return mapper.apply(s);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<String> tabCompletes(CommandSender sender, String[] previousArguments, String s) {
|
||||
public Collection<String> tabCompletes(Player sender, String[] previousArguments, String s) {
|
||||
return tabCompleter.apply(sender, s);
|
||||
}
|
||||
});
|
||||
ProxyServer.getInstance().getScheduler().schedule(this, TabCompletionCache::invalidateOldEntries, 1, 1, TimeUnit.SECONDS);
|
||||
proxyServer.getScheduler().buildTask(this, TabCompletionCache::invalidateOldEntries).repeat(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 Hostname();
|
||||
new ServerListPing();
|
||||
new PluginMessage();
|
||||
new Schematica();
|
||||
new Badlion();
|
||||
@ -107,7 +144,6 @@ public class BungeeCore extends Plugin {
|
||||
new CheckListener();
|
||||
new IPSanitizer();
|
||||
|
||||
local = new Node.LocalNode();
|
||||
if(MAIN_SERVER) {
|
||||
//new Node.RemoteNode("lx");
|
||||
}
|
||||
@ -179,11 +215,11 @@ public class BungeeCore extends Plugin {
|
||||
tablistManager = new TablistManager();
|
||||
new SettingsChangedListener();
|
||||
|
||||
getProxy().getScheduler().schedule(this, () -> {
|
||||
proxyServer.getScheduler().buildTask(this, () -> {
|
||||
SteamwarUser.clear();
|
||||
UserElo.clear();
|
||||
Team.clear();
|
||||
}, 1, 1, TimeUnit.HOURS);
|
||||
}).repeat(1, TimeUnit.HOURS);
|
||||
|
||||
if (SteamwarDiscordBotConfig.loaded) {
|
||||
try {
|
||||
@ -194,8 +230,8 @@ public class BungeeCore extends Plugin {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable(){
|
||||
@Subscribe
|
||||
public void onDisable(ProxyReloadEvent event) {
|
||||
if (SteamwarDiscordBotConfig.loaded) {
|
||||
try {
|
||||
SteamwarDiscordBot.instance().getJda().shutdown();
|
||||
@ -210,64 +246,10 @@ public class BungeeCore extends Plugin {
|
||||
Statement.closeAll();
|
||||
}
|
||||
|
||||
public static BungeeCore get() {
|
||||
public static VelocityCore 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{
|
||||
@ -321,7 +303,7 @@ public class BungeeCore extends Plugin {
|
||||
}
|
||||
}
|
||||
|
||||
private static void setInstance(BungeeCore core){
|
||||
private static void setInstance(VelocityCore core){
|
||||
instance = core;
|
||||
}
|
||||
}
|
@ -19,7 +19,7 @@
|
||||
|
||||
package de.steamwar.bungeecore.bot;
|
||||
|
||||
import de.steamwar.bungeecore.BungeeCore;
|
||||
import de.steamwar.bungeecore.VelocityCore;
|
||||
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());
|
||||
BungeeCore.log("Created Discord Auth-Token: " + code + " for: " + member.getUser().getAsTag());
|
||||
BungeeCore.get().getProxy().getScheduler().schedule(BungeeCore.get(), () -> TOKENS.remove(code), 10, TimeUnit.MINUTES);
|
||||
VelocityCore.log("Created Discord Auth-Token: " + code + " for: " + member.getUser().getAsTag());
|
||||
VelocityCore.get().getProxy().getScheduler().schedule(VelocityCore.get(), () -> TOKENS.remove(code), 10, TimeUnit.MINUTES);
|
||||
return code;
|
||||
}
|
||||
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
package de.steamwar.bungeecore.bot;
|
||||
|
||||
import de.steamwar.bungeecore.BungeeCore;
|
||||
import de.steamwar.bungeecore.VelocityCore;
|
||||
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(BungeeCore.get(), () -> {
|
||||
ProxyServer.getInstance().getScheduler().runAsync(VelocityCore.get(), () -> {
|
||||
try {
|
||||
jda.awaitReady();
|
||||
} catch (InterruptedException e) {
|
||||
@ -90,11 +90,11 @@ public class SteamwarDiscordBot {
|
||||
try {
|
||||
activity();
|
||||
} catch (Exception e) {
|
||||
BungeeCore.get().getLogger().log(Level.SEVERE, "Could not set initial activity to discord", e);
|
||||
VelocityCore.get().getLogger().log(Level.SEVERE, "Could not set initial activity to discord", e);
|
||||
}
|
||||
EventManager.update();
|
||||
SchematicsManager.update();
|
||||
ProxyServer.getInstance().getScheduler().schedule(BungeeCore.get(), () -> {
|
||||
ProxyServer.getInstance().getScheduler().schedule(VelocityCore.get(), () -> {
|
||||
try {
|
||||
activity();
|
||||
EventManager.update();
|
||||
@ -148,7 +148,7 @@ public class SteamwarDiscordBot {
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
int count = BungeeCore.get().getProxy().getOnlineCount();
|
||||
int count = VelocityCore.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.BungeeCore;
|
||||
import de.steamwar.bungeecore.VelocityCore;
|
||||
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)) {
|
||||
BungeeCore.get().getProxy().getPlayers().forEach(player -> {
|
||||
VelocityCore.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.BungeeCore;
|
||||
import de.steamwar.bungeecore.VelocityCore;
|
||||
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();
|
||||
BungeeCore.log("Could not Upload Schem \"" + name + "\" from User \"" + user.getUserName() + "\"", e);
|
||||
VelocityCore.log("Could not Upload Schem \"" + name + "\" from User \"" + user.getUserName() + "\"", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -245,7 +245,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(BungeeCore.LOBBY_SERVER));
|
||||
toRemove.connect(ProxyServer.getInstance().getServerInfo(VelocityCore.LOBBY_SERVER));
|
||||
}
|
||||
}
|
||||
Message.send("BAU_DELMEMBER_DELETED", p);
|
||||
@ -289,12 +289,12 @@ public class BauCommand extends SWCommand {
|
||||
}
|
||||
|
||||
private static void deleteWorld(ProxiedPlayer player, String world) {
|
||||
ProxyServer.getInstance().getScheduler().runAsync(BungeeCore.get(), () -> {
|
||||
ProxyServer.getInstance().getScheduler().runAsync(VelocityCore.get(), () -> {
|
||||
Bauserver subserver = Bauserver.get(player.getUniqueId());
|
||||
if(subserver != null)
|
||||
subserver.stop();
|
||||
|
||||
SubserverSystem.deleteFolder(BungeeCore.local, world);
|
||||
SubserverSystem.deleteFolder(VelocityCore.local, world);
|
||||
Message.send("BAU_DELETE_DELETED", player);
|
||||
});
|
||||
}
|
||||
@ -303,7 +303,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(BungeeCore.get(), () -> new ServerStarter().test(mode, m, p).start());
|
||||
ProxyServer.getInstance().getScheduler().runAsync(VelocityCore.get(), () -> new ServerStarter().test(mode, m, p).start());
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
package de.steamwar.bungeecore.commands;
|
||||
|
||||
import de.steamwar.bungeecore.ArenaMode;
|
||||
import de.steamwar.bungeecore.BungeeCore;
|
||||
import de.steamwar.bungeecore.VelocityCore;
|
||||
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(BungeeCore.get(), () -> {
|
||||
BungeeCore.local.execute("/binarys/deployarena.py", arenaMode.getConfig(), Integer.toString(version.getVersionSuffix()), map);
|
||||
ProxyServer.getInstance().getScheduler().runAsync(VelocityCore.get(), () -> {
|
||||
VelocityCore.local.execute("/binarys/deployarena.py", arenaMode.getConfig(), Integer.toString(version.getVersionSuffix()), map);
|
||||
ArenaMode.init();
|
||||
ChatSender.of(player).system("BUILDERCLOUD_DEPLOY_FINISHED");
|
||||
});
|
||||
|
@ -66,7 +66,7 @@ public class CheckCommand extends SWCommand {
|
||||
public CheckCommand() {
|
||||
super("check", ConnectionListener.CHECK_PERMISSION);
|
||||
|
||||
ProxyServer.getInstance().getScheduler().schedule(BungeeCore.get(), () -> {
|
||||
ProxyServer.getInstance().getScheduler().schedule(VelocityCore.get(), () -> {
|
||||
List<SchematicNode> schematics = getSchemsToCheck();
|
||||
if(schematics.size() != currentCheckers.size())
|
||||
Message.team("CHECK_REMINDER", "CHECK_REMINDER_HOVER", new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/check list"), schematics.size() - currentCheckers.size());
|
||||
@ -220,7 +220,7 @@ public class CheckCommand extends SWCommand {
|
||||
this.startTime = Timestamp.from(Instant.now());
|
||||
this.checkList = checkQuestions.get(schematic.getSchemtype()).listIterator();
|
||||
|
||||
ProxyServer.getInstance().getScheduler().runAsync(BungeeCore.get(), () -> {
|
||||
ProxyServer.getInstance().getScheduler().runAsync(VelocityCore.get(), () -> {
|
||||
ArenaMode mode = ArenaMode.getBySchemType(fightTypes.get(schematic.getSchemtype()));
|
||||
if(!new ServerStarter().test(mode, mode.getRandomMap(), checker).check(schematic.getId()).start()) {
|
||||
remove();
|
||||
@ -317,7 +317,7 @@ public class CheckCommand extends SWCommand {
|
||||
private void stop(){
|
||||
currentCheckers.remove(checker.getUniqueId());
|
||||
currentSchems.remove(schematic.getId());
|
||||
ProxyServer.getInstance().getScheduler().runAsync(BungeeCore.get(), () -> {
|
||||
ProxyServer.getInstance().getScheduler().runAsync(VelocityCore.get(), () -> {
|
||||
Bauserver subserver = Bauserver.get(checker.getUniqueId());
|
||||
if(subserver != null)
|
||||
subserver.stop();
|
||||
|
@ -107,7 +107,7 @@ public class EventCommand extends SWCommand {
|
||||
}
|
||||
}
|
||||
|
||||
BungeeCore.send(player, fline.toString());
|
||||
VelocityCore.send(player, fline.toString());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
package de.steamwar.bungeecore.commands;
|
||||
|
||||
import de.steamwar.bungeecore.BungeeCore;
|
||||
import de.steamwar.bungeecore.VelocityCore;
|
||||
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(BungeeCore.get(), () -> {
|
||||
BungeeCord.getInstance().getScheduler().runAsync(VelocityCore.get(), () -> {
|
||||
try {
|
||||
createZip(player, user);
|
||||
} catch (IOException e) {
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
package de.steamwar.bungeecore.commands;
|
||||
|
||||
import de.steamwar.bungeecore.BungeeCore;
|
||||
import de.steamwar.bungeecore.VelocityCore;
|
||||
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(BungeeCore.stringToText(BungeeCore.CHAT_PREFIX + "§c" + String.join(" ", message)));
|
||||
target.disconnect(VelocityCore.stringToText(VelocityCore.CHAT_PREFIX + "§c" + String.join(" ", message)));
|
||||
}
|
||||
Message.send("KICK_CONFIRM", sender, target.getName());
|
||||
}
|
||||
|
@ -20,7 +20,7 @@
|
||||
package de.steamwar.bungeecore.commands;
|
||||
|
||||
import com.google.gson.JsonParser;
|
||||
import de.steamwar.bungeecore.BungeeCore;
|
||||
import de.steamwar.bungeecore.VelocityCore;
|
||||
import de.steamwar.bungeecore.Message;
|
||||
import de.steamwar.bungeecore.listeners.ConnectionListener;
|
||||
import de.steamwar.bungeecore.listeners.IPSanitizer;
|
||||
@ -78,7 +78,7 @@ public class PunishmentCommand {
|
||||
} catch (NoSuchElementException e) {
|
||||
// ignore, player does not exist
|
||||
} catch (IOException e) {
|
||||
BungeeCore.get().getLogger().log(Level.SEVERE, "Could not get offline player UUID " + playerName, e);
|
||||
VelocityCore.get().getLogger().log(Level.SEVERE, "Could not get offline player UUID " + playerName, e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -100,7 +100,7 @@ public class TutorialCommand extends SWCommand {
|
||||
return;
|
||||
} else if(own && click.isShiftClick() && click.isRightClick()) {
|
||||
tutorial.delete();
|
||||
SubserverSystem.deleteFolder(BungeeCore.local, world(tutorial).getPath());
|
||||
SubserverSystem.deleteFolder(VelocityCore.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(BungeeCore.get(), () -> {
|
||||
ProxyServer.getInstance().getScheduler().schedule(VelocityCore.get(), () -> {
|
||||
Tutorial tutorial = Tutorial.create(user.getId(), name, item);
|
||||
File tutorialWorld = world(tutorial);
|
||||
|
||||
if (tutorialWorld.exists())
|
||||
SubserverSystem.deleteFolder(BungeeCore.local, tutorialWorld.getPath());
|
||||
ServerStarter.copyWorld(BungeeCore.local, tempWorld.getPath(), tutorialWorld.getPath());
|
||||
SubserverSystem.deleteFolder(VelocityCore.local, tutorialWorld.getPath());
|
||||
ServerStarter.copyWorld(VelocityCore.local, tempWorld.getPath(), tutorialWorld.getPath());
|
||||
Message.send("TUTORIAL_CREATED", player);
|
||||
}, 1, TimeUnit.SECONDS);
|
||||
}
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
package de.steamwar.bungeecore.commands;
|
||||
|
||||
import de.steamwar.bungeecore.BungeeCore;
|
||||
import de.steamwar.bungeecore.VelocityCore;
|
||||
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) {
|
||||
BungeeCore.log(sender.getName() + " Verified with Discorduser: " + member.getIdLong());
|
||||
VelocityCore.log(sender.getName() + " Verified with Discorduser: " + member.getIdLong());
|
||||
Message.send("VERIFY_SUCCESS", sender, member.getUser().getAsTag());
|
||||
} else {
|
||||
Message.send("VERIFY_INVALID", sender);
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
package de.steamwar.bungeecore.listeners;
|
||||
|
||||
import de.steamwar.bungeecore.BungeeCore;
|
||||
import de.steamwar.bungeecore.VelocityCore;
|
||||
import de.steamwar.bungeecore.Message;
|
||||
import de.steamwar.bungeecore.commands.PunishmentCommand;
|
||||
import de.steamwar.bungeecore.commands.WebpasswordCommand;
|
||||
@ -42,8 +42,8 @@ public class BanListener extends BasicListener {
|
||||
|
||||
@EventHandler
|
||||
public void onLogin(LoginEvent event) {
|
||||
event.registerIntent(BungeeCore.get());
|
||||
ProxyServer.getInstance().getScheduler().runAsync(BungeeCore.get(), () -> {
|
||||
event.registerIntent(VelocityCore.get());
|
||||
ProxyServer.getInstance().getScheduler().runAsync(VelocityCore.get(), () -> {
|
||||
PendingConnection connection = event.getConnection();
|
||||
SteamwarUser user = SteamwarUser.getOrCreate(connection.getUniqueId(), connection.getName(), ConnectionListener::newPlayer, WebpasswordCommand::changeUsername);
|
||||
String ip = IPSanitizer.getTrueAddress(connection).getHostAddress();
|
||||
@ -51,7 +51,7 @@ public class BanListener extends BasicListener {
|
||||
event.setCancelled(true);
|
||||
BannedUserIPs.banIP(user.getId(), ip);
|
||||
ChatSender.of(event).system(PunishmentCommand.punishmentMessage(user, Punishment.PunishmentType.Ban));
|
||||
event.completeIntent(BungeeCore.get());
|
||||
event.completeIntent(VelocityCore.get());
|
||||
return;
|
||||
}
|
||||
|
||||
@ -88,7 +88,7 @@ public class BanListener extends BasicListener {
|
||||
));
|
||||
}
|
||||
|
||||
event.completeIntent(BungeeCore.get());
|
||||
event.completeIntent(VelocityCore.get());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -1,31 +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 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);
|
||||
}
|
||||
}
|
@ -27,7 +27,6 @@ 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;
|
||||
@ -58,7 +57,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);
|
||||
BungeeCore.log(Level.SEVERE, user.getUserName() + " " + user.getId() + " wurde automatisch wegen jndi:ldap gebannt.");
|
||||
VelocityCore.log(Level.SEVERE, user.getUserName() + " " + user.getId() + " wurde automatisch wegen jndi:ldap gebannt.");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -192,7 +191,7 @@ public class ChatListener extends BasicListener {
|
||||
TaskScheduler scheduler = ProxyServer.getInstance().getScheduler();
|
||||
for(int i = 0; i < delay.length; i++) {
|
||||
int finalI = i;
|
||||
scheduler.schedule(BungeeCore.get(), () -> sender.prefixless("CHAT_MSG", name, sender.user(), new Message(baseMessage + (finalI+1))), delay[i], TimeUnit.SECONDS);
|
||||
scheduler.schedule(VelocityCore.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.BungeeCore;
|
||||
import de.steamwar.bungeecore.VelocityCore;
|
||||
import de.steamwar.bungeecore.Message;
|
||||
import de.steamwar.bungeecore.Servertype;
|
||||
import de.steamwar.bungeecore.Subserver;
|
||||
@ -142,7 +142,7 @@ public class ConnectionListener extends BasicListener {
|
||||
}
|
||||
}
|
||||
|
||||
ServerInfo kickTo = ProxyServer.getInstance().getServerInfo(BungeeCore.LOBBY_SERVER);
|
||||
ServerInfo kickTo = ProxyServer.getInstance().getServerInfo(VelocityCore.LOBBY_SERVER);
|
||||
|
||||
if (kickedFrom != null && kickedFrom.equals(kickTo)) {
|
||||
return;
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
package de.steamwar.bungeecore.listeners;
|
||||
|
||||
import de.steamwar.bungeecore.BungeeCore;
|
||||
import de.steamwar.bungeecore.VelocityCore;
|
||||
import net.md_5.bungee.api.connection.PendingConnection;
|
||||
import net.md_5.bungee.api.event.LoginEvent;
|
||||
import net.md_5.bungee.connection.InitialHandler;
|
||||
@ -60,7 +60,7 @@ public class IPSanitizer extends BasicListener {
|
||||
|
||||
@EventHandler
|
||||
public void loginEvent(LoginEvent e) {
|
||||
BungeeCore.get().getLogger().log(Level.INFO, e.getConnection().getSocketAddress() + " has logged in with user name " + e.getConnection().getName());
|
||||
VelocityCore.get().getLogger().log(Level.INFO, e.getConnection().getSocketAddress() + " has logged in with user name " + e.getConnection().getName());
|
||||
getChannelWrapper(e.getConnection()).setRemoteAddress(sanitized);
|
||||
}
|
||||
}
|
||||
|
@ -20,26 +20,17 @@
|
||||
package de.steamwar.bungeecore.listeners;
|
||||
|
||||
import com.lunarclient.apollo.ApolloManager;
|
||||
import de.steamwar.bungeecore.BungeeCore;
|
||||
import com.velocitypowered.api.event.connection.PluginMessageEvent;
|
||||
import com.velocitypowered.api.proxy.Player;
|
||||
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.ByteBufAllocator;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import net.md_5.bungee.api.ChatMessageType;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import net.md_5.bungee.api.connection.Connection;
|
||||
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.connection.InitialHandler;
|
||||
import net.md_5.bungee.event.EventHandler;
|
||||
import net.md_5.bungee.protocol.DefinedPacket;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataOutputStream;
|
||||
@ -48,25 +39,16 @@ import java.util.*;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class PluginMessage extends BasicListener {
|
||||
@Create
|
||||
public class PluginMessage {
|
||||
|
||||
public static void send(ProxiedPlayer player, String legacyChannel, String channel, byte[] data) {
|
||||
public static void send(Player player, String legacyChannel, String channel, byte[] data) {
|
||||
// 1.12 format change
|
||||
send(player, player.getPendingConnection().getVersion() > 340 ? channel : legacyChannel, data);
|
||||
send(player, player.getProtocolVersion().getProtocol() > 340 ? channel : legacyChannel, data);
|
||||
}
|
||||
|
||||
public static void send(ProxiedPlayer player, String channel, byte[] data) {
|
||||
if(((InitialHandler)player.getPendingConnection()).getRegisteredChannels().contains(channel))
|
||||
player.sendData(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 void send(Player player, String channel, byte[] data) {
|
||||
player.sendPluginMessage(MinecraftChannelIdentifier.from(channel), data);
|
||||
}
|
||||
|
||||
public static byte[] genStreamPacket(StreamConsumer generator) {
|
||||
@ -86,14 +68,17 @@ public class PluginMessage extends BasicListener {
|
||||
void accept(DataOutputStream out) throws IOException;
|
||||
}
|
||||
|
||||
private static final Parser UNKNOWN = event -> BungeeCore.get().getLogger().log(Level.WARNING, () -> "Undefined PluginMessage on channel " + event.getTag() + " from " + event.getSender() + " received.\n" + new String(event.getData()) + "\n" + Arrays.toString(event.getData()));
|
||||
private static final Parser PASS_THROUGH = event -> event.setCancelled(false);
|
||||
private static final Parser DROP = event -> {};
|
||||
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 Lunar lunar = new Lunar();
|
||||
|
||||
private final Set<String> knownBrands = new HashSet<>();
|
||||
private final Map<String, Consumer<ProxiedPlayer>> channelRegisterHandlers = new HashMap<>();
|
||||
private final Map<String, Consumer<Player>> channelRegisterHandlers = new HashMap<>();
|
||||
private final Map<String, Parser> handlers = new HashMap<>();
|
||||
|
||||
public PluginMessage() {
|
||||
@ -145,8 +130,10 @@ public class PluginMessage extends BasicListener {
|
||||
"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(channel, player -> {
|
||||
});
|
||||
}
|
||||
|
||||
channelRegisterHandlers.put(ApolloManager.PLUGIN_MESSAGE_CHANNEL, lunar::sendRestrictions);
|
||||
channelRegisterHandlers.put(Feather.CHANNEL, new Feather()::sendRestrictions);
|
||||
@ -254,7 +241,7 @@ public class PluginMessage extends BasicListener {
|
||||
ProxiedPlayer player = (ProxiedPlayer) event.getSender();
|
||||
|
||||
for(String channel : new String(event.getData()).split("\0")) {
|
||||
channelRegisterHandlers.getOrDefault(channel, p -> BungeeCore.get().getLogger().log(Level.WARNING, () -> p.getName() + " registered unknown channel " + channel)).accept(player);
|
||||
channelRegisterHandlers.getOrDefault(channel, p -> VelocityCore.get().getLogger().log(Level.WARNING, () -> p.getName() + " registered unknown channel " + channel)).accept(player);
|
||||
}
|
||||
|
||||
PASS_THROUGH.handle(event);
|
||||
@ -274,7 +261,7 @@ public class PluginMessage extends BasicListener {
|
||||
String brand = DefinedPacket.readString(buf);
|
||||
boolean lunarclient = brand.startsWith("lunarclient:");
|
||||
|
||||
BungeeCore.get().getLogger().log(knownBrands.contains(brand) || lunarclient ? Level.INFO : Level.WARNING, () -> player.getName() + " joins with brand: " + brand);
|
||||
VelocityCore.get().getLogger().log(knownBrands.contains(brand) || lunarclient ? Level.INFO : Level.WARNING, () -> player.getName() + " joins with brand: " + brand);
|
||||
if(lunarclient)
|
||||
lunar.sendRestrictions(player);
|
||||
|
||||
@ -313,7 +300,7 @@ public class PluginMessage extends BasicListener {
|
||||
}
|
||||
|
||||
private Parser async(Parser parser) {
|
||||
return event -> ProxyServer.getInstance().getScheduler().runAsync(BungeeCore.get(), () -> parser.handle(event));
|
||||
return event -> ProxyServer.getInstance().getScheduler().runAsync(VelocityCore.get(), () -> parser.handle(event));
|
||||
}
|
||||
|
||||
private interface Parser {
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
package de.steamwar.bungeecore.listeners;
|
||||
|
||||
import de.steamwar.bungeecore.BungeeCore;
|
||||
import de.steamwar.bungeecore.VelocityCore;
|
||||
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(BungeeCore.get(), () -> Session.insertSession(SteamwarUser.get(e.getPlayer().getUniqueId()).getId(), timestamp));
|
||||
ProxyServer.getInstance().getScheduler().runAsync(VelocityCore.get(), () -> Session.insertSession(SteamwarUser.get(e.getPlayer().getUniqueId()).getId(), timestamp));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
package de.steamwar.bungeecore.listeners;
|
||||
|
||||
import de.steamwar.bungeecore.BungeeCore;
|
||||
import de.steamwar.bungeecore.VelocityCore;
|
||||
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(BungeeCore.get(), () -> {
|
||||
BungeeCord.getInstance().getScheduler().runAsync(VelocityCore.get(), () -> {
|
||||
ProxiedPlayer player = event.getPlayer();
|
||||
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
||||
user.setLocale(player.getLocale(), false);
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
package de.steamwar.bungeecore.mods;
|
||||
|
||||
import de.steamwar.bungeecore.BungeeCore;
|
||||
import de.steamwar.bungeecore.VelocityCore;
|
||||
import de.steamwar.bungeecore.listeners.BasicListener;
|
||||
import de.steamwar.sql.Mod;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
@ -86,8 +86,8 @@ public class FML extends BasicListener {
|
||||
synchronized (unlocked) {
|
||||
unlocked.add(p.getUniqueId());
|
||||
}
|
||||
p.disconnect(BungeeCore.stringToText("§7Deine installierten Mods wurden überprüft\n§aDu kannst nun §eSteam§8War §abetreten"));
|
||||
ProxyServer.getInstance().getScheduler().schedule(BungeeCore.get(), () -> {
|
||||
p.disconnect(VelocityCore.stringToText("§7Deine installierten Mods wurden überprüft\n§aDu kannst nun §eSteam§8War §abetreten"));
|
||||
ProxyServer.getInstance().getScheduler().schedule(VelocityCore.get(), () -> {
|
||||
synchronized (unlocked) {
|
||||
unlocked.remove(p.getUniqueId());
|
||||
}
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
package de.steamwar.bungeecore.mods;
|
||||
|
||||
import de.steamwar.bungeecore.BungeeCore;
|
||||
import de.steamwar.bungeecore.VelocityCore;
|
||||
import de.steamwar.bungeecore.listeners.BasicListener;
|
||||
import de.steamwar.bungeecore.listeners.IPSanitizer;
|
||||
import de.steamwar.bungeecore.listeners.PluginMessage;
|
||||
@ -81,7 +81,7 @@ public class FML2 extends BasicListener {
|
||||
|
||||
IPSanitizer.getChannelWrapper(connection).getHandle().pipeline().get(HandlerBoss.class).setHandler(new FML2LoginHandler(event));
|
||||
|
||||
event.registerIntent(BungeeCore.get());
|
||||
event.registerIntent(VelocityCore.get());
|
||||
if(forge)
|
||||
connection.unsafe().sendPacket(new LoginPayloadRequest(1, "forge:login", forgeModListPacket));
|
||||
else
|
||||
@ -170,14 +170,14 @@ public class FML2 extends BasicListener {
|
||||
if(!ModUtils.handleMods(event.getConnection().getUniqueId(), Locale.getDefault(), event::setReason, mods))
|
||||
event.setCancelled(true);
|
||||
|
||||
event.completeIntent(BungeeCore.get());
|
||||
event.completeIntent(VelocityCore.get());
|
||||
}
|
||||
|
||||
private void abort(LoginPayloadResponse response, String error) {
|
||||
event.setReason(TextComponent.fromLegacy(error));
|
||||
event.setCancelled(true);
|
||||
event.completeIntent(BungeeCore.get());
|
||||
BungeeCore.get().getLogger().log(Level.SEVERE, () -> error + "\n" + response);
|
||||
event.completeIntent(VelocityCore.get());
|
||||
VelocityCore.get().getLogger().log(Level.SEVERE, () -> error + "\n" + response);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ package de.steamwar.bungeecore.mods;
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonParser;
|
||||
import de.steamwar.bungeecore.BungeeCore;
|
||||
import de.steamwar.bungeecore.VelocityCore;
|
||||
import de.steamwar.bungeecore.Storage;
|
||||
import de.steamwar.bungeecore.listeners.BasicListener;
|
||||
import de.steamwar.sql.Mod;
|
||||
@ -55,7 +55,7 @@ public class FabricModSender extends BasicListener {
|
||||
neededFabricMods.add("fabricloader");
|
||||
neededQuiltMods.add("quilt_loader");
|
||||
|
||||
BungeeCord.getInstance().getScheduler().schedule(BungeeCore.get(), () -> {
|
||||
BungeeCord.getInstance().getScheduler().schedule(VelocityCore.get(), () -> {
|
||||
synchronized (Storage.fabricExpectPluginMessage) {
|
||||
for (Map.Entry<ProxiedPlayer, Long> entry : Storage.fabricExpectPluginMessage.entrySet()) {
|
||||
if (!Storage.fabricCheckedPlayers.containsKey(entry.getKey())) {
|
||||
|
@ -19,20 +19,19 @@
|
||||
|
||||
package de.steamwar.bungeecore.mods;
|
||||
|
||||
import de.steamwar.bungeecore.BungeeCore;
|
||||
import de.steamwar.bungeecore.listeners.BasicListener;
|
||||
import net.md_5.bungee.api.event.PlayerHandshakeEvent;
|
||||
import net.md_5.bungee.connection.InitialHandler;
|
||||
import net.md_5.bungee.event.EventHandler;
|
||||
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;
|
||||
|
||||
public class Hostname extends BasicListener {
|
||||
@Create
|
||||
public class Hostname {
|
||||
|
||||
private final Set<String> knownHostnames = new HashSet<>();
|
||||
private final Set<String> knownExtraData = new HashSet<>();
|
||||
|
||||
public Hostname() {
|
||||
knownHostnames.add("steamwar.de");
|
||||
@ -45,22 +44,13 @@ public class Hostname extends BasicListener {
|
||||
knownHostnames.add("wtf.mynx.lol"); //https://discord.com/invite/serverseeker
|
||||
knownHostnames.add("masscan");
|
||||
knownHostnames.add("aaa");
|
||||
|
||||
knownExtraData.add("");
|
||||
knownExtraData.add("\0FML\0");
|
||||
knownExtraData.add("\0FML2\0");
|
||||
knownExtraData.add("\0FML3\0");
|
||||
knownExtraData.add("\0FORGE");
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onHandshake(PlayerHandshakeEvent event) {
|
||||
String hostname = event.getHandshake().getHost().toLowerCase();
|
||||
String extraDataInHandshake = ((InitialHandler) event.getConnection()).getExtraDataInHandshake();
|
||||
@Subscribe
|
||||
public void onHandshake(ProxyPingEvent event) {
|
||||
String hostname = event.getConnection().getVirtualHost().map(inetSocketAddress -> inetSocketAddress.getHostName()).orElse("");
|
||||
if (!knownHostnames.contains(hostname) && !hostname.endsWith(".steamwar.de")) {
|
||||
BungeeCore.get().getLogger().log(Level.WARNING, () -> event.getConnection().getSocketAddress() + " connected with unknown hostname " + event.getHandshake() + " " + extraDataInHandshake);
|
||||
} else if (!knownExtraData.contains(extraDataInHandshake)) {
|
||||
BungeeCore.get().getLogger().log(Level.WARNING, () -> event.getConnection().getSocketAddress() + " connected with unknown extra data " + event.getHandshake() + " " + extraDataInHandshake);
|
||||
VelocityCore.get().getLogger().log(Level.WARNING, () -> event.getConnection().getRemoteAddress().toString() + " connected with unknown hostname '" + hostname + "'");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ package de.steamwar.bungeecore.mods;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import de.steamwar.bungeecore.BungeeCore;
|
||||
import de.steamwar.bungeecore.VelocityCore;
|
||||
import de.steamwar.bungeecore.listeners.PluginMessage;
|
||||
import de.steamwar.sql.Mod;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
@ -74,7 +74,7 @@ public class LabyMod {
|
||||
}
|
||||
|
||||
if(message.has("mods")) {
|
||||
BungeeCore.get().getLogger().log(Level.WARNING, () -> "LabyMod External Mods for debugging: " + message.getAsJsonArray("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)
|
||||
|
@ -32,7 +32,7 @@ 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 de.steamwar.bungeecore.BungeeCore;
|
||||
import de.steamwar.bungeecore.VelocityCore;
|
||||
import de.steamwar.sql.Mod;
|
||||
import lombok.AllArgsConstructor;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
@ -94,7 +94,7 @@ public class Lunar {
|
||||
case TYPE_UNSPECIFIED:
|
||||
case UNRECOGNIZED:
|
||||
default:
|
||||
BungeeCore.get().getLogger().log(Level.INFO, () -> player.getName() + " uses Lunar mod with unknown type " + mod);
|
||||
VelocityCore.get().getLogger().log(Level.INFO, () -> player.getName() + " uses Lunar mod with unknown type " + mod);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
package de.steamwar.bungeecore.mods;
|
||||
|
||||
import de.steamwar.bungeecore.BungeeCore;
|
||||
import de.steamwar.bungeecore.VelocityCore;
|
||||
import de.steamwar.bungeecore.Message;
|
||||
import de.steamwar.bungeecore.commands.PunishmentCommand;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
@ -54,7 +54,7 @@ public class ModUtils {
|
||||
public static boolean handleMods(UUID uuid, Locale locale, Consumer<BaseComponent> disconnect, List<Mod> mods){
|
||||
SteamwarUser user = SteamwarUser.get(uuid);
|
||||
playerModMap.put(uuid,new ArrayList<>(mods));
|
||||
BungeeCore.get().getLogger().log(Level.INFO, user.getUserName() + " declares mods: " + mods.stream().map(mod -> mod.getPlatform() + ":" + mod.getModName()).collect(Collectors.joining(" ")));
|
||||
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();
|
||||
@ -83,7 +83,7 @@ public class ModUtils {
|
||||
|
||||
if(max == ModType.RED) {
|
||||
PunishmentCommand.ban(user, Timestamp.from(Instant.now().plus(7, ChronoUnit.DAYS)), message, SteamwarUser.get(-1), false);
|
||||
BungeeCore.log(Level.SEVERE, user.getUserName() + " " + user.getId() + " wurde automatisch wegen der Mods " + modList + " gebannt.");
|
||||
VelocityCore.log(Level.SEVERE, user.getUserName() + " " + user.getId() + " wurde automatisch wegen der Mods " + modList + " gebannt.");
|
||||
}
|
||||
|
||||
disconnect.accept(TextComponent.fromLegacy(message));
|
||||
|
@ -21,7 +21,7 @@ package de.steamwar.bungeecore.mods;
|
||||
|
||||
import de.steamwar.bungeecore.Bauserver;
|
||||
import de.steamwar.bungeecore.Builderserver;
|
||||
import de.steamwar.bungeecore.BungeeCore;
|
||||
import de.steamwar.bungeecore.VelocityCore;
|
||||
import de.steamwar.bungeecore.Subserver;
|
||||
import de.steamwar.bungeecore.listeners.BasicListener;
|
||||
import de.steamwar.bungeecore.listeners.PluginMessage;
|
||||
@ -55,7 +55,7 @@ public class ReplayMod extends BasicListener {
|
||||
public void onPlayerJoin(ServerSwitchEvent event) {
|
||||
ProxiedPlayer player = event.getPlayer();
|
||||
ServerInfo server = player.getServer().getInfo();
|
||||
if(ProxyServer.getInstance().getServerInfo(BungeeCore.LOBBY_SERVER) == server)
|
||||
if(ProxyServer.getInstance().getServerInfo(VelocityCore.LOBBY_SERVER) == server)
|
||||
return;
|
||||
|
||||
Subserver subserver = Subserver.getSubserver(server);
|
||||
|
@ -20,44 +20,67 @@
|
||||
package de.steamwar.bungeecore.mods;
|
||||
|
||||
import com.google.gson.*;
|
||||
import de.steamwar.bungeecore.listeners.BasicListener;
|
||||
import net.md_5.bungee.BungeeCord;
|
||||
import net.md_5.bungee.api.ServerPing;
|
||||
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;
|
||||
|
||||
public class ServerListPing extends BasicListener implements JsonSerializer<ServerPing>, JsonDeserializer<ServerPing> {
|
||||
@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
|
||||
|
||||
private final Gson gson;
|
||||
@SuppressWarnings("unused")
|
||||
private final ProxyServer proxyServer;
|
||||
|
||||
public ServerListPing() {
|
||||
BungeeCord bungeeCord = BungeeCord.getInstance();
|
||||
gson = bungeeCord.gson;
|
||||
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 {
|
||||
Field gsonField = BungeeCord.class.getDeclaredField("gson");
|
||||
gsonField.setAccessible(true);
|
||||
gsonField.set(bungeeCord, gson.newBuilder().registerTypeAdapter(ServerPing.class, this).create());
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public JsonElement serialize(ServerPing ping, Type type, JsonSerializationContext context) {
|
||||
JsonElement element = gson.toJsonTree(ping, type);
|
||||
private record ServerListPingSerializer(
|
||||
Gson gson) implements JsonSerializer<ServerPing>, JsonDeserializer<ServerPing> {
|
||||
|
||||
JsonObject object = element.getAsJsonObject();
|
||||
object.addProperty("preventsChatReports", true);
|
||||
@Override
|
||||
public JsonElement serialize(ServerPing ping, Type type, JsonSerializationContext context) {
|
||||
JsonElement element = gson.toJsonTree(ping, type);
|
||||
|
||||
return element;
|
||||
}
|
||||
JsonObject object = element.getAsJsonObject();
|
||||
object.addProperty("preventsChatReports", true);
|
||||
|
||||
@Override
|
||||
public ServerPing deserialize(JsonElement element, Type type, JsonDeserializationContext context) throws JsonParseException {
|
||||
return gson.fromJson(element, ServerPing.class);
|
||||
}
|
||||
return element;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServerPing deserialize(JsonElement element, Type type, JsonDeserializationContext context) throws JsonParseException {
|
||||
return gson.fromJson(element, ServerPing.class);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -20,7 +20,7 @@
|
||||
package de.steamwar.bungeecore.network.handlers;
|
||||
|
||||
import de.steamwar.bungeecore.ArenaMode;
|
||||
import de.steamwar.bungeecore.BungeeCore;
|
||||
import de.steamwar.bungeecore.VelocityCore;
|
||||
import de.steamwar.network.packets.PacketHandler;
|
||||
import de.steamwar.network.packets.common.FightEndsPacket;
|
||||
import de.steamwar.sql.SchematicNode;
|
||||
@ -203,7 +203,7 @@ public class EloPlayerHandler extends PacketHandler {
|
||||
for (int i = 0; i < 40; i++) {
|
||||
BaseComponent[] eloGainComponent = TextComponent.fromLegacyText(color + (int) (eloStep * (i + 1)));
|
||||
int finalI = i;
|
||||
scheduler.schedule(BungeeCore.get(), () -> {
|
||||
scheduler.schedule(VelocityCore.get(), () -> {
|
||||
if (player == null) return;
|
||||
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);
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
package de.steamwar.bungeecore.network.handlers;
|
||||
|
||||
import de.steamwar.bungeecore.BungeeCore;
|
||||
import de.steamwar.bungeecore.VelocityCore;
|
||||
import de.steamwar.bungeecore.inventory.InvCallback;
|
||||
import de.steamwar.bungeecore.inventory.SWInventory;
|
||||
import de.steamwar.bungeecore.network.NetworkSender;
|
||||
@ -42,7 +42,7 @@ public class InventoryCallbackHandler extends PacketHandler {
|
||||
SteamwarUser owner = SteamwarUser.get(packet.getOwner());
|
||||
InventoryCallbackPacket.CallbackType type = packet.getType();
|
||||
if(!inventoryHashMap.containsKey(owner.getId())) {
|
||||
BungeeCore.send(ProxyServer.getInstance().getPlayer(owner.getUUID()), BungeeCore.CHAT_PREFIX + "§cBitte erneut versuchen. Durch ein Softwareupdate konnte die übliche Aktion nicht durchgeführt werden.");
|
||||
VelocityCore.send(ProxyServer.getInstance().getPlayer(owner.getUUID()), VelocityCore.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()).getSender(), new CloseInventoryPacket(owner.getId()));
|
||||
}
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
package de.steamwar.bungeecore.tablist;
|
||||
|
||||
import de.steamwar.bungeecore.BungeeCore;
|
||||
import de.steamwar.bungeecore.VelocityCore;
|
||||
import de.steamwar.bungeecore.Servertype;
|
||||
import de.steamwar.bungeecore.Storage;
|
||||
import de.steamwar.bungeecore.Subserver;
|
||||
@ -50,7 +50,7 @@ public class TablistManager extends BasicListener {
|
||||
private int seconds = 0;
|
||||
|
||||
public TablistManager() {
|
||||
ProxyServer.getInstance().getScheduler().schedule(BungeeCore.get(), this::updateTablist, 1, 1, TimeUnit.SECONDS);
|
||||
ProxyServer.getInstance().getScheduler().schedule(VelocityCore.get(), this::updateTablist, 1, 1, TimeUnit.SECONDS);
|
||||
synchronized (tablists) {
|
||||
ProxyServer.getInstance().getPlayers().forEach(player -> tablists.put(player, new Tablist(player)));
|
||||
}
|
||||
|
49
src/de/steamwar/bungeecore/util/SteamWarModule.java
Normale Datei
49
src/de/steamwar/bungeecore/util/SteamWarModule.java
Normale Datei
@ -0,0 +1,49 @@
|
||||
/*
|
||||
* 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.Singleton;
|
||||
import de.steamwar.bungeecore.Node;
|
||||
import de.steamwar.bungeecore.VelocityCore;
|
||||
import de.steamwar.bungeecore.commands.HelpCommand;
|
||||
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(Singleton.class);
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
Node provideNode() {
|
||||
return new Node.LocalNode();
|
||||
}
|
||||
}
|
31
src/de/steamwar/bungeecore/util/annotations/Create.java
Normale Datei
31
src/de/steamwar/bungeecore/util/annotations/Create.java
Normale Datei
@ -0,0 +1,31 @@
|
||||
/*
|
||||
* 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,19 +19,18 @@
|
||||
|
||||
package de.steamwar.command;
|
||||
|
||||
import de.steamwar.bungeecore.BungeeCore;
|
||||
import com.velocitypowered.api.command.Command;
|
||||
import de.steamwar.bungeecore.VelocityCore;
|
||||
import lombok.experimental.UtilityClass;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
import net.md_5.bungee.api.plugin.Command;
|
||||
|
||||
@UtilityClass
|
||||
class CommandRegistering {
|
||||
|
||||
static void unregister(Command command) {
|
||||
ProxyServer.getInstance().getPluginManager().unregisterCommand(command);
|
||||
static void unregister(String name) {
|
||||
VelocityCore.getProxy().getCommandManager().unregister(name);
|
||||
}
|
||||
|
||||
static void register(Command command) {
|
||||
ProxyServer.getInstance().getPluginManager().registerCommand(BungeeCore.get(), command);
|
||||
static void register(Command command, String name, String... aliases) {
|
||||
VelocityCore.getProxy().getCommandManager().register(name, command, aliases);
|
||||
}
|
||||
}
|
||||
|
@ -19,29 +19,28 @@
|
||||
|
||||
package de.steamwar.command;
|
||||
|
||||
import de.steamwar.bungeecore.BungeeCore;
|
||||
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.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<CommandSender> {
|
||||
public class SWCommand extends AbstractSWCommand<CommandSource> {
|
||||
|
||||
static {
|
||||
TypeUtils.init();
|
||||
}
|
||||
|
||||
private String name;
|
||||
private String[] aliases;
|
||||
private String permission;
|
||||
private Command command;
|
||||
|
||||
@ -56,8 +55,10 @@ public class SWCommand extends AbstractSWCommand<CommandSender> {
|
||||
}
|
||||
|
||||
protected SWCommand(String command, String permission, String... aliases) {
|
||||
super(CommandSender.class, command, aliases);
|
||||
super(CommandSource.class, command, aliases);
|
||||
this.name = command;
|
||||
this.permission = permission;
|
||||
this.aliases = aliases;
|
||||
create = true;
|
||||
createAndSafeCommand(command, aliases);
|
||||
unregister();
|
||||
@ -69,46 +70,40 @@ public class SWCommand extends AbstractSWCommand<CommandSender> {
|
||||
@Override
|
||||
protected void createAndSafeCommand(String command, String[] aliases) {
|
||||
if (!create) return;
|
||||
this.command = new TabCompletableCommand(command, permission, aliases) {
|
||||
this.command = new SimpleCommand() {
|
||||
@Override
|
||||
public void execute(CommandSender commandSender, String[] strings) {
|
||||
SWCommand.this.execute(commandSender, null, strings);
|
||||
public void execute(Invocation invocation) {
|
||||
SWCommand.this.execute(invocation.source(), invocation.alias(), invocation.arguments());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<String> onTabComplete(CommandSender commandSender, String[] strings) {
|
||||
return SWCommand.this.tabComplete(commandSender, null, strings);
|
||||
public List<String> suggest(Invocation invocation) {
|
||||
return SWCommand.this.tabComplete(invocation.source(), invocation.alias(), invocation.arguments());
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
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.command);
|
||||
CommandRegistering.unregister(this.name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register() {
|
||||
if (command == null) return;
|
||||
CommandRegistering.register(this.command);
|
||||
CommandRegistering.register(command, name, aliases);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void commandSystemError(CommandSender sender, CommandFrameworkException e) {
|
||||
BungeeCore.get().getLogger().log(Level.SEVERE, e.getMessage(), e);
|
||||
protected void commandSystemError(Player sender, CommandFrameworkException e) {
|
||||
VelocityCore.get().getLogger().log(Level.SEVERE, e.getMessage(), e);
|
||||
ChatSender.of(sender).prefixless("COMMAND_SYSTEM_ERROR");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void commandSystemWarning(Supplier<String> message) {
|
||||
BungeeCore.get().getLogger().log(Level.WARNING, message);
|
||||
VelocityCore.get().getLogger().log(Level.WARNING, message);
|
||||
}
|
||||
|
||||
public void addDefaultHelpMessage(String message) {
|
||||
@ -116,18 +111,18 @@ public class SWCommand extends AbstractSWCommand<CommandSender> {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void sendMessage(CommandSender sender, String message, Object[] args) {
|
||||
protected void sendMessage(Player sender, String message, Object[] args) {
|
||||
ChatSender.of(sender).system(message, args);
|
||||
}
|
||||
|
||||
@Register(noTabComplete = true)
|
||||
public void internalHelp(ProxiedPlayer p, String... args) {
|
||||
public void internalHelp(Player p, String... args) {
|
||||
ChatSender chatSender = ChatSender.of(p);
|
||||
try {
|
||||
chatSender.prefixless("COMMAND_HELP_HEAD", command.getName());
|
||||
defaultHelpMessages.forEach(chatSender::prefixless);
|
||||
} catch (Exception e) {
|
||||
BungeeCore.get().getLogger().log(Level.WARNING, "Failed to send help message", e);
|
||||
VelocityCore.get().getLogger().log(Level.WARNING, "Failed to send help message", e);
|
||||
return;
|
||||
}
|
||||
AtomicInteger atomicInteger = new AtomicInteger();
|
||||
@ -156,7 +151,7 @@ public class SWCommand extends AbstractSWCommand<CommandSender> {
|
||||
}
|
||||
}
|
||||
|
||||
private void send(ChatSender chatSender, SubCommand<CommandSender> subCommand) {
|
||||
private void send(ChatSender chatSender, SubCommand<CommandSource> subCommand) {
|
||||
try {
|
||||
for (String s : subCommand.description) {
|
||||
String hover = "§8/§e" + command.getName() + " " + String.join(" ", subCommand.subCommand);
|
||||
@ -164,7 +159,7 @@ public class SWCommand extends AbstractSWCommand<CommandSender> {
|
||||
chatSender.prefixless(s, new Message("PLAIN_STRING", hover), new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, suggest));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
BungeeCore.get().getLogger().log(Level.WARNING, "Failed to send description of registered method '" + subCommand.method + "' with description '" + subCommand.description + "'", e);
|
||||
VelocityCore.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 net.md_5.bungee.api.CommandSender;
|
||||
import com.velocitypowered.api.proxy.Player;
|
||||
|
||||
public interface TypeMapper<T> extends AbstractTypeMapper<CommandSender, T> {
|
||||
public interface TypeMapper<T> extends AbstractTypeMapper<Player, T> {
|
||||
/**
|
||||
* The CommandSender can be null!
|
||||
*/
|
||||
T map(CommandSender commandSender, String[] previousArguments, String s);
|
||||
T map(Player commandSender, String[] previousArguments, String s);
|
||||
}
|
||||
|
@ -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.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 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 java.text.DateFormat;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
import java.util.ResourceBundle;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.logging.Level;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public interface ChatSender {
|
||||
|
||||
static Stream<ProxiedPlayer> all() {
|
||||
return ProxyServer.getInstance().getPlayers().stream();
|
||||
static Stream<Player> all() {
|
||||
return VelocityCore.get().getProxyServer().getAllPlayers().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.getServer().getInfo());
|
||||
return subserver == null || !(subserver.getType() == Servertype.ARENA && subserver.getServer() == player.getCurrentServer().get());
|
||||
}).map(ChatSender::of);
|
||||
}
|
||||
|
||||
@ -69,10 +69,10 @@ public interface ChatSender {
|
||||
|
||||
Locale getLocale();
|
||||
boolean chatShown();
|
||||
void sendMessage(ChatMessageType type, BaseComponent... msg);
|
||||
void sendMessage(Component msg);
|
||||
|
||||
default void chat(Message message) {
|
||||
send(false, ChatMessageType.CHAT, null, null, message);
|
||||
send(false, null, null, message);
|
||||
}
|
||||
|
||||
default void system(String format, Object... params) {
|
||||
@ -80,11 +80,11 @@ public interface ChatSender {
|
||||
}
|
||||
|
||||
default void system(Message message) {
|
||||
send(true, ChatMessageType.SYSTEM, null, null, message);
|
||||
send(true, null, null, message);
|
||||
}
|
||||
|
||||
default void system(String format, Message onHover, ClickEvent onClick, Object... params) {
|
||||
send(true, ChatMessageType.SYSTEM, onHover, onClick, new Message(format, params));
|
||||
send(true, 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, ChatMessageType.SYSTEM, onHover, onClick, new Message(format, params));
|
||||
send(false, onHover, onClick, new Message(format, params));
|
||||
}
|
||||
|
||||
default void send(boolean prefixed, ChatMessageType type, Message onHover, ClickEvent onClick, Message message) {
|
||||
TextComponent msg = parseToComponent(prefixed, message);
|
||||
default void send(boolean prefixed, Message onHover, ClickEvent onClick, Message message) {
|
||||
Component msg = parseToComponent(prefixed, message);
|
||||
if(onHover != null)
|
||||
msg.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new Text(parse(false, onHover))));
|
||||
msg = msg.hoverEvent(HoverEvent.showText(parse(false, onHover)));
|
||||
if(onClick != null)
|
||||
msg.setClickEvent(onClick);
|
||||
sendMessage(type, msg);
|
||||
msg = msg.clickEvent(onClick);
|
||||
sendMessage(msg);
|
||||
}
|
||||
|
||||
default TextComponent parseToComponent(boolean prefixed, Message message) {
|
||||
return new TextComponent(parse(prefixed, message));
|
||||
default Component parseToComponent(boolean prefixed, Message message) {
|
||||
return parse(prefixed, message);
|
||||
}
|
||||
|
||||
default String parseToPlain(String format, Object... params) {
|
||||
@ -113,7 +113,7 @@ public interface ChatSender {
|
||||
}
|
||||
|
||||
default String parseToPlain(Message message) {
|
||||
return parseToComponent(false, message).toPlainText();
|
||||
return PlainTextComponentSerializer.plainText().serialize(parseToComponent(false, message));
|
||||
}
|
||||
|
||||
default String parseToLegacy(String format, Object... params) {
|
||||
@ -121,14 +121,14 @@ public interface ChatSender {
|
||||
}
|
||||
|
||||
default String parseToLegacy(Message message) {
|
||||
return parseToComponent(false, message).toLegacyText();
|
||||
return LegacyComponentSerializer.legacySection().serialize(parseToComponent(false, message));
|
||||
}
|
||||
|
||||
default BaseComponent[] parse(boolean prefixed, String format, Object... params) {
|
||||
default Component parse(boolean prefixed, String format, Object... params) {
|
||||
return parse(prefixed, new Message(format, params));
|
||||
}
|
||||
|
||||
default BaseComponent[] parse(boolean prefixed, Message message) {
|
||||
default Component 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) {
|
||||
params[i] = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT, locale).format((Date) 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 SteamwarUser) {
|
||||
params[i] = ((SteamwarUser) params[i]).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();
|
||||
} else if(params[i] instanceof Player player) {
|
||||
params[i] = player.getGameProfile().getName();
|
||||
} else if(params[i] instanceof ChatSender cs) {
|
||||
params[i] = cs.user().getUserName();
|
||||
}
|
||||
}
|
||||
return TextComponent.fromLegacyText(format.format(params));
|
||||
return LegacyComponentSerializer.legacySection().deserialize(format.format(params));
|
||||
}
|
||||
|
||||
static ChatSender ofProxiedPlayer(ProxiedPlayer player, BiConsumer<ChatMessageType, BaseComponent[]> sendMessage) {
|
||||
static ChatSender ofProxiedPlayer(Player player, Consumer<Component> sendMessage) {
|
||||
return new ChatSender() {
|
||||
@Override
|
||||
public SteamwarUser user() {
|
||||
@ -168,27 +168,27 @@ public interface ChatSender {
|
||||
|
||||
@Override
|
||||
public boolean chatShown() {
|
||||
return player.getChatMode() == ProxiedPlayer.ChatMode.SHOWN;
|
||||
return player.getPlayerSettings().getChatMode() == PlayerSettings.ChatMode.SHOWN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage(ChatMessageType type, BaseComponent... msg) {
|
||||
sendMessage.accept(type, msg);
|
||||
public void sendMessage(Component msg) {
|
||||
sendMessage.accept(msg);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
static ChatSender of(ProxiedPlayer player) {
|
||||
static ChatSender of(Player player) {
|
||||
return ofProxiedPlayer(player, player::sendMessage);
|
||||
}
|
||||
|
||||
static ChatSender disconnect(ProxiedPlayer player) {
|
||||
return ofProxiedPlayer(player, (type, msg) -> player.disconnect(msg));
|
||||
static ChatSender disconnect(Player player) {
|
||||
return ofProxiedPlayer(player, player::disconnect);
|
||||
}
|
||||
|
||||
static ChatSender of(CommandSender sender) {
|
||||
if(sender instanceof ProxiedPlayer)
|
||||
return of((ProxiedPlayer) sender);
|
||||
static ChatSender of(CommandSource sender) {
|
||||
if(sender instanceof Player player)
|
||||
return of(player);
|
||||
|
||||
//Console
|
||||
return new ChatSender() {
|
||||
@ -208,21 +208,21 @@ public interface ChatSender {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage(ChatMessageType type, BaseComponent... msg) {
|
||||
public void sendMessage(Component msg) {
|
||||
sender.sendMessage(msg);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
static ChatSender console() {
|
||||
return of(ConsoleCommandSender.getInstance());
|
||||
return of(VelocityCore.get().getProxyServer().getConsoleCommandSource());
|
||||
}
|
||||
|
||||
static ChatSender of(LoginEvent event) {
|
||||
return new ChatSender() {
|
||||
@Override
|
||||
public SteamwarUser user() {
|
||||
return SteamwarUser.get(event.getConnection().getUniqueId());
|
||||
return SteamwarUser.get(event.getPlayer().getUniqueId());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -236,8 +236,8 @@ public interface ChatSender {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage(ChatMessageType type, BaseComponent... msg) {
|
||||
event.setCancelReason(msg);
|
||||
public void sendMessage(Component msg) {
|
||||
event.setResult(ResultedEvent.ComponentResult.denied(msg));
|
||||
}
|
||||
};
|
||||
}
|
||||
@ -260,11 +260,11 @@ public interface ChatSender {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage(ChatMessageType type, BaseComponent... msg) {
|
||||
public void sendMessage(Component msg) {
|
||||
try {
|
||||
channel.send("<t:" + (System.currentTimeMillis() / 1000) + "> " + new TextComponent(msg).toPlainText());
|
||||
channel.send("<t:" + (System.currentTimeMillis() / 1000) + "> " + PlainTextComponentSerializer.plainText().serialize(msg));
|
||||
} catch (Exception e) {
|
||||
BungeeCore.get().getLogger().log(Level.SEVERE, "Could not send chat message to discord", e);
|
||||
VelocityCore.get().getLogger().log(Level.SEVERE, "Could not send chat message to discord", e);
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -288,11 +288,11 @@ public interface ChatSender {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage(ChatMessageType type, BaseComponent... msg) {
|
||||
public void sendMessage(Component msg) {
|
||||
try {
|
||||
message.delete().queue();
|
||||
} catch (Exception e) {
|
||||
BungeeCore.get().getLogger().log(Level.SEVERE, "Could not send chat reply to discord user", e);
|
||||
VelocityCore.get().getLogger().log(Level.SEVERE, "Could not send chat reply to discord user", e);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -20,6 +20,9 @@
|
||||
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;
|
||||
@ -27,12 +30,28 @@ 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 getResourceBundle(locale.toString(), getResourceBundle(locale.getLanguage(), getResourceBundle( "", null)));
|
||||
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;
|
||||
});
|
||||
}
|
||||
|
||||
private static synchronized ResourceBundle getResourceBundle(String locale, ResourceBundle parent) {
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
package de.steamwar.sql;
|
||||
|
||||
import de.steamwar.bungeecore.BungeeCore;
|
||||
import de.steamwar.bungeecore.VelocityCore;
|
||||
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 BungeeCore.get().getLogger();
|
||||
return VelocityCore.get().getLogger();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
package de.steamwar.sql;
|
||||
|
||||
import de.steamwar.bungeecore.BungeeCore;
|
||||
import de.steamwar.bungeecore.VelocityCore;
|
||||
import de.steamwar.bungeecore.commands.CheckCommand;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
import net.md_5.bungee.api.config.ServerInfo;
|
||||
@ -54,7 +54,7 @@ public class SQLWrapperImpl implements SQLWrapper {
|
||||
|
||||
@Override
|
||||
public void loadSchemTypes(List<SchematicType> tmpTypes, Map<String, SchematicType> tmpFromDB) {
|
||||
File folder = new File(BungeeCore.get().getDataFolder().getParentFile(), "FightSystem");
|
||||
File folder = new File(VelocityCore.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;
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren