SteamWar/BungeeCore
Archiviert
13
2

Bungee Network #362

Zusammengeführt
Lixfel hat 5 Commits von network nach master 2022-06-14 08:50:05 +02:00 zusammengeführt
11 geänderte Dateien mit 137 neuen und 31 gelöschten Zeilen
Nur Änderungen aus Commit 41d27c567d werden angezeigt - Alle Commits anzeigen

Datei anzeigen

@ -26,7 +26,7 @@ public class ServerStarter {
private static final String EVENT_PATH = BACKBONE + "event/";
public static final String TEMP_WORLD_PATH = BACKBONE + "arenaserver/";
public static final String TUTORIAL_PATH = BACKBONE + "tutorials/";
public static final String WORLDS18_PATH = BACKBONE + "userworlds18/";
public static final String WORLDS19_PATH = BACKBONE + "userworlds19/";
private File directory = null;
private String worldDir = null;
@ -109,10 +109,10 @@ public class ServerStarter {
return this;
}
public ServerStarter build18(UUID owner) {
directory = new File(SERVER_PATH, "Bau18");
serverJar = "paper-1.18.2.jar";
worldDir = WORLDS18_PATH;
public ServerStarter build19(UUID owner) {
directory = new File(SERVER_PATH, "Bau19");
serverJar = "paper-1.19.jar";
worldDir = WORLDS19_PATH;
worldName = String.valueOf(SteamwarUser.get(owner).getId());
buildWithWorld(owner, new File(directory, "Bauwelt").getPath());
return this;

Datei anzeigen

@ -47,7 +47,7 @@ public class BauCommand extends BasicCommand {
ProxiedPlayer p = (ProxiedPlayer) sender;
versionSelector(p, args, 0,
() -> new ServerStarter().build18(p.getUniqueId()).send(p).start(),
() -> new ServerStarter().build19(p.getUniqueId()).send(p).start(),
() -> new ServerStarter().build15(p.getUniqueId()).send(p).start(),
() -> new ServerStarter().build12(p.getUniqueId()).send(p).start(),
() -> {
@ -129,13 +129,13 @@ public class BauCommand extends BasicCommand {
}
versionSelector(p, args, 2,
() -> new ServerStarter().build18(worldOwner.getUuid()).send(p).start(),
() -> new ServerStarter().build19(worldOwner.getUuid()).send(p).start(),
() -> new ServerStarter().build15(worldOwner.getUuid()).send(p).start(),
() -> new ServerStarter().build12(worldOwner.getUuid()).send(p).start(),
() -> HelpCommand.sendBauHelp(ChatSender.of(p)));
}
private static void versionSelector(ProxiedPlayer p, String[] args, int pos, Runnable run18, Runnable run15, Runnable run12, Runnable runElse) {
private static void versionSelector(ProxiedPlayer p, String[] args, int pos, Runnable run19, Runnable run15, Runnable run12, Runnable runElse) {
if(args.length <= pos) {
int version = p.getPendingConnection().getVersion();
if(version > 340) { // Version > 1.12.2
@ -147,9 +147,11 @@ public class BauCommand extends BasicCommand {
}
switch (args[pos].toLowerCase()) {
case "19":
case "1.19":
case "18":
case "1.18":
run18.run();
run19.run();
break;
case "ws":
case "warship":
@ -232,7 +234,7 @@ public class BauCommand extends BasicCommand {
private static void delete(ProxiedPlayer p, String[] args){
SteamwarUser user = SteamwarUser.get(p.getUniqueId());
versionSelector(p, args, 1,
() -> deleteConfirmation(p, () -> deleteWorld(p, ServerStarter.WORLDS18_PATH + user.getId())),
() -> deleteConfirmation(p, () -> deleteWorld(p, ServerStarter.WORLDS19_PATH + user.getId())),
() -> deleteConfirmation(p, () -> deleteWorld(p, BungeeCore.USERWORLDS15 + user.getId())),
() -> deleteConfirmation(p, () -> deleteWorld(p, BungeeCore.WORLD_FOLDER + p.getUniqueId().toString())),
() -> HelpCommand.sendBauHelp(ChatSender.of(p)));

Datei anzeigen

@ -31,6 +31,7 @@ import net.md_5.bungee.UserConnection;
import net.md_5.bungee.api.ChatColor;
import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.ServerConnectRequest;
import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.chat.ComponentBuilder;
import net.md_5.bungee.api.chat.HoverEvent;
@ -565,6 +566,11 @@ public class TeamCommand extends BasicCommand {
}
private void tp(ProxiedPlayer player, SteamwarUser user, Team team, String[] args){
if (!user.getUserGroup().isAdminGroup()) {
Message.send("DISABLED", player);
return;
}
if(args.length == 1){
if(notInTeam(player, user))
return;
@ -590,14 +596,32 @@ public class TeamCommand extends BasicCommand {
ProxyServer.getInstance().getServers().put(info.getName(), info);
return info;
});
player.connect(ServerConnectRequest.builder()
.target(serverInfo)
.connectTimeout(BungeeCord.getInstance().getConfig().getServerConnectTimeout())
.retry(false)
.reason(ServerConnectEvent.Reason.PLUGIN)
.callback((success, error) -> {
if (error != null) {
Message.send("TEAM_OFFLINE", player);
}
})
.build());
/*
((UserConnection) player).connect(serverInfo, (success, error) -> {
if (error != null) {
Message.send("TEAM_OFFLINE", player);
}
}, false, ServerConnectEvent.Reason.PLUGIN, BungeeCord.getInstance().getConfig().getServerConnectTimeout(), false);
*/
}
private void server(ProxiedPlayer player, SteamwarUser user, Team team, String[] args){
if (!user.getUserGroup().isAdminGroup()) {
Message.send("DISABLED", player);
return;
}
if(notLeader(player, user, team))
return;
if (user.isPunishedWithMessage(ChatSender.of(player), Punishment.PunishmentType.NoTeamServer)) {

Datei anzeigen

@ -21,6 +21,7 @@ package de.steamwar.bungeecore.commands;
import de.steamwar.bungeecore.*;
import de.steamwar.bungeecore.sql.*;
import de.steamwar.bungeecore.util.Chat19;
import de.steamwar.messages.ChatSender;
import net.md_5.bungee.BungeeCord;
import net.md_5.bungee.api.CommandSender;
@ -55,7 +56,7 @@ public class TpCommand extends BasicCommand {
//Give control of teleport command to server
if(server == null) {
player.chat("/tp " + String.join(" ", args));
Chat19.chat(player, "/tp " + String.join(" ", args));
return;
}

Datei anzeigen

@ -23,6 +23,7 @@ import de.steamwar.bungeecore.*;
import de.steamwar.bungeecore.bot.SteamwarDiscordBot;
import de.steamwar.bungeecore.network.NetworkSender;
import de.steamwar.bungeecore.sql.*;
import de.steamwar.bungeecore.util.Chat19;
import de.steamwar.messages.ChatSender;
import de.steamwar.network.packets.server.PingPacket;
import net.md_5.bungee.api.*;
@ -124,7 +125,7 @@ public class ChatListener extends BasicListener {
return;
}
player.chat(message);
Chat19.chat(player, message);
}
private static String modifyFilter(ChatSender sender, String message) {

Datei anzeigen

@ -19,12 +19,12 @@
package de.steamwar.bungeecore.listeners;
import io.github.waterfallmc.waterfall.utils.UUIDUtils;
import net.md_5.bungee.BungeeCord;
import net.md_5.bungee.api.event.LoginEvent;
import net.md_5.bungee.connection.InitialHandler;
import net.md_5.bungee.connection.LoginResult;
import net.md_5.bungee.event.EventHandler;
import net.md_5.bungee.protocol.Property;
import net.md_5.bungee.util.AddressUtil;
import java.lang.reflect.Field;
@ -50,11 +50,12 @@ public class SubserverProtocolFixer extends BasicListener {
public void loginEvent(LoginEvent e) {
InitialHandler initialHandler = ((InitialHandler) e.getConnection());
String extraData = "\00" + AddressUtil.sanitizeAddress(inetSocketAddress) + "\00" + UUIDUtils.undash(initialHandler.getUniqueId().toString());
String undashedUUID = initialHandler.getUniqueId().toString().replace("-", "");
String extraData = "\00" + AddressUtil.sanitizeAddress(inetSocketAddress) + "\00" + undashedUUID;
LoginResult result = initialHandler.getLoginProfile();
if (result != null) {
LoginResult.Property[] properties = result.getProperties();
Property[] properties = result.getProperties();
if (properties.length > 0) {
extraData += "\00" + BungeeCord.getInstance().gson.toJson(properties);
}

Datei anzeigen

@ -28,6 +28,7 @@ import de.steamwar.bungeecore.Servertype;
import de.steamwar.bungeecore.Subserver;
import de.steamwar.bungeecore.sql.SteamwarUser;
import de.steamwar.bungeecore.sql.UserGroup;
import net.md_5.bungee.BungeeCord;
import de.steamwar.network.packets.common.FightInfoPacket;
import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.config.ServerInfo;
@ -48,7 +49,11 @@ public class TablistManager extends BasicListener {
@EventHandler
public synchronized void onJoin(PostLoginEvent e){
tablists.put(e.getPlayer(), new Tablist(e.getPlayer()));
BungeeCord.getInstance().getScheduler().schedule(BungeeCore.get(), () -> {
if (e.getPlayer().isConnected()) {
tablists.put(e.getPlayer(), new Tablist(e.getPlayer()));
}
}, 1, TimeUnit.SECONDS);
}
@EventHandler
@ -88,7 +93,7 @@ public class TablistManager extends BasicListener {
//Calculate server-player-map
tablist = new TablistGroup(true, "");
TablistGroup bau = new TablistGroup(false, "Bau");
for (ServerInfo server : ProxyServer.getInstance().getServersCopy().values()){
for (ServerInfo server : new ArrayList<>(ProxyServer.getInstance().getServers().values())){
if(server.getPlayers().isEmpty())
continue;

Datei anzeigen

@ -41,6 +41,7 @@ import java.nio.charset.UnsupportedCharsetException;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.logging.Level;
import java.util.stream.Collectors;
public class Fabric extends BasicListener {
@ -59,7 +60,7 @@ public class Fabric extends BasicListener {
continue;
}
if (System.currentTimeMillis() - entry.getValue() > TimeUnit.SECONDS.toMillis(20)) {
banPlayer(SteamwarUser.get(entry.getKey()), entry.getKey());
banPlayer(SteamwarUser.get(entry.getKey()), entry.getKey(), "Expected message not received");
return;
}
}
@ -82,7 +83,7 @@ public class Fabric extends BasicListener {
if (!Storage.fabricCheckedPlayers.containsKey(player)) {
synchronized (Storage.fabricExpectPluginMessage) {
if (Storage.fabricExpectPluginMessage.containsKey(player)) {
banPlayer(user, player);
banPlayer(user, player, "Was not fabric checked but send message nonetheless");
return;
}
}
@ -95,7 +96,7 @@ public class Fabric extends BasicListener {
Utils.VarInt varInt = Utils.readVarInt(data,0);
if(data.length != varInt.length + varInt.value) {
banPlayer(user,player);
banPlayer(user,player, "Invalid message length");
return;
}
@ -106,7 +107,7 @@ public class Fabric extends BasicListener {
try{
dataString = new String(data, StandardCharsets.UTF_8);
}catch (UnsupportedCharsetException exception) {
banPlayer(user, player);
banPlayer(user, player, "Unsupported charset");
return;
}
@ -115,7 +116,7 @@ public class Fabric extends BasicListener {
try {
array = new JsonParser().parse(dataString).getAsJsonArray();
}catch (JsonSyntaxException exception) {
banPlayer(user, player);
banPlayer(user, player, "Invalid json");
return;
}
@ -126,12 +127,12 @@ public class Fabric extends BasicListener {
boolean isSorted = isSortedAlphabetically(mods);
if(!isSorted) {
banPlayer(user, player);
banPlayer(user, player, "Mods are not sorted alphabetically: " + mods.stream().map(Mod::getModName).collect(Collectors.joining(", ")));
return;
}
if(!neededModsContained(mods)) {
banPlayer(user, player);
banPlayer(user, player, "Needed mods are not contained");
return;
}
@ -139,7 +140,7 @@ public class Fabric extends BasicListener {
if (Storage.fabricCheckedPlayers.containsKey(player)) {
long current = Storage.fabricCheckedPlayers.get(player);
if (current != dataString.hashCode()) {
banPlayer(user, player);
banPlayer(user, player, "");
return;
}
} else {
@ -176,11 +177,11 @@ public class Fabric extends BasicListener {
.count() == neededMods.size();
}
public void banPlayer(SteamwarUser user, ProxiedPlayer player) {
public void banPlayer(SteamwarUser user, ProxiedPlayer player, String reason) {
user.punishPerma(Punishment.PunishmentType.Ban,
Message.parse("MODIFICATION_BAN_MESSAGE", player, user.getUserName(), user.getId()),
0);
BungeeCore.log(Level.SEVERE,Message.parse("MODIFICATION_BAN_LOG", player, user.getUserName()));
BungeeCore.log(Level.SEVERE,Message.parse("MODIFICATION_BAN_LOG", player, user.getUserName(), reason));
}
public static void remove(ProxiedPlayer player) {

Datei anzeigen

@ -0,0 +1,67 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2022 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bungeecore.util;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import net.md_5.bungee.ServerConnection;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.protocol.PacketWrapper;
import net.md_5.bungee.protocol.ProtocolConstants;
import net.md_5.bungee.protocol.packet.Chat;
import java.time.Instant;
public class Chat19 extends Chat {
public static void chat(ProxiedPlayer p, String message) {
if(p.getPendingConnection().getVersion() >= 759) {
Chat19 packet = new Chat19(message);
ByteBuf buf = Unpooled.buffer();
writeVarInt(0x04, buf);
packet.write(buf, ProtocolConstants.Direction.TO_SERVER, p.getPendingConnection().getVersion());
((ServerConnection) p.getServer()).getCh().write(new PacketWrapper(packet, buf));
} else {
p.chat(message);
}
}
private final Instant timestamp = Instant.now();
private final long salt = 0L;
private final byte[] signature = new byte[0];
private final boolean signedPreview = false;
public Chat19 (String message) {
super(message);
}
@Override
public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion) {
if (direction == ProtocolConstants.Direction.TO_CLIENT || protocolVersion != 759)
throw new UnsupportedOperationException();
writeString(getMessage(), buf);
buf.writeLong(timestamp.toEpochMilli());
buf.writeLong(salt);
writeArray(signature, buf);
buf.writeBoolean(signedPreview);
}
}

Datei anzeigen

@ -13,6 +13,8 @@ STEAMWAR_BRAND=§eSteam§8War.de §7({0}) §r<- §e{1} §7({2})§r
DEV_NO_SERVER=§cThe server is currently not available.
DEV_UNKNOWN_SERVER=§cPlease specify a dev server.
DISABLED=§cCurrently disabled.
#ModLoader blocker
MODLOADER_INSTALLED=§7You play with §e{0} §7client. Therefore you can't join arenas.
MODLOADER_INSTALLED_FABRIC=§7You play with §e{0} §7client. You can only join arenas with the SteamWar Modsender installed.
@ -210,7 +212,7 @@ BAU_MEMBER_TOGGLE_WORLD_EDIT = use WorldEdit
BAU_MEMBER_TOGGLE_WORLD = change Settings
#ChallengeCommand
CHALLENGE_USAGE=§8/§7challenge §8[§eSpieler§8]
CHALLENGE_USAGE=§8/§7challenge §8[§eplayer§8]
CHALLENGE_OFFLINE=§cThe challenged player isn't online.
CHALLENGE_SELF=§cSchizophrenia?
CHALLENGE_IGNORED=§cThe challenged player has blocked you.
@ -291,7 +293,7 @@ HISTORIC_BROADCAST_HOVER=§afight against §7{1}
JOIN_PLAYER_BLOCK=§cYou currently cannot follow this player.
#JoinmeCommand
JOINME_USAGE=§8/§7join §8[§eSpieler§8].
JOINME_USAGE=§8/§7join §8[§eplayer§8].
JOINME_BROADCAST=§7Click §ehere§8 §7to join §e{0} §7on §e{1}§8!
JOINME_BROADCAST_HOVER=§aJoin player
JOINME_PLAYER_OFFLINE=§cThis player is offline.
@ -613,7 +615,7 @@ RANK_NEEDED_FIGHTS_LEFT={0} §8(§e{1}§7 fights needed§8)
#Fabric Mod Sender
MODIFICATION_BAN_MESSAGE=You tried to bypass / modify the FabricModSender!
MODIFICATION_BAN_LOG={0} has tried to edit / bypass the FabricModSender!
MODIFICATION_BAN_LOG={0} has tried to edit / bypass the FabricModSender! Reason: {1}
MODIFICATION_CHECK_SUCCESS=§eYour mods have been checked and you are now allowed to join arenas!
#Arena Merging

Datei anzeigen

@ -10,6 +10,8 @@ INVALID_TIME=§cUngültige Zeitangabe.
DEV_NO_SERVER=§cDer Server ist derzeit nicht erreichbar.
DEV_UNKNOWN_SERVER=§cBitte gib einen DevServer an.
DISABLED=§cDerzeit deaktiviert.
#ModLoader blocker
MODLOADER_INSTALLED=§7Du spielst mit §e{0} §7Client. Daher kannst du keinen Arenen beitreten.
MODLOADER_INSTALLED_FABRIC=§7Du spielst mit §e{0} §7Client. Nur mit dem SteamWarModSender kannst du Arenen beitreten.
@ -593,7 +595,7 @@ RANK_NEEDED_FIGHTS_LEFT={0} §8(§7noch §e{1}§7 Kämpfe nötig§8)
#Fabric Mod Sender
MODIFICATION_BAN_MESSAGE=Du hast probiert den FabricModSender zu umgehen / zu modifizieren!
MODIFICATION_BAN_LOG={0} hat probiert den Fabric Mod Sender zu editieren / umzugehen!
MODIFICATION_BAN_LOG={0} hat probiert den Fabric Mod Sender zu editieren / umzugehen! Grund: {1}
MODIFICATION_CHECK_SUCCESS=§eDeine Mods wurden geprüft und du darfst nun auf Arenen joinen!
#Arena Merging