1
0

Merge branch 'master' into BauCommand

# Conflicts:
#	src/de/steamwar/bungeecore/commands/BauCommand.java
Dieser Commit ist enthalten in:
yoyosource 2022-09-14 17:47:48 +02:00
Commit 1a51e2c6a2
14 geänderte Dateien mit 141 neuen und 27 gelöschten Zeilen

Datei anzeigen

@ -97,7 +97,7 @@ dependencies {
compileOnly 'de.steamwar:waterfall:RELEASE'
compileOnly 'de.steamwar:persistentbungeecore:RELEASE'
implementation("net.dv8tion:JDA:4.3.0_299") {
implementation("net.dv8tion:JDA:4.4.0_352") {
exclude module: 'opus-java'
}

Datei anzeigen

@ -94,6 +94,7 @@ public class ArenaMode {
private final String serverJar;
private final String config;
private final List<String> maps;
private final Map<String, String> lowerToRealMapNames = new HashMap<>();
private final boolean historic;
private final String internalName;
@ -106,6 +107,7 @@ public class ArenaMode {
this.serverJar = config.getString("Server.ServerJar");
this.config = internalName + ".yml";
this.maps = config.getStringList("Server.Maps");
maps.forEach(map -> lowerToRealMapNames.put(map.toLowerCase(), map));
this.displayName = config.getString("GameName", internalName);
this.chatNames = config.getStringList("Server.ChatNames");
this.schemType = config.getString("Schematic.Type", "").toLowerCase();
@ -155,6 +157,10 @@ public class ArenaMode {
return maps;
}
public String convertToRealMapName(String map){
return lowerToRealMapNames.get(map.toLowerCase());
}
public String getChatName(){
return chatNames.get(0);
}

Datei anzeigen

@ -33,7 +33,6 @@ import java.util.logging.LogRecord;
import java.util.logging.Logger;
public class ErrorLogger extends Handler {
private int ddosRate = 0;
ErrorLogger(){
Logger.getLogger("").addHandler(this);
@ -57,12 +56,7 @@ public class ErrorLogger extends Handler {
if(logRecord.getThrown() != null)
logRecord.getThrown().printStackTrace(new PrintStream(stacktraceOutput));
String stacktrace = stacktraceOutput.toString();
if(stacktrace.contains("Cannot request protocol")) {
if(++ddosRate % 1000 == 0) {
SWException.log("Bungee", "DDOS", ddosRate + "");
}
return;
} else if (stacktrace.contains("ErrorLogger")) {
if (stacktrace.contains("ErrorLogger")) {
return;
}
@ -86,6 +80,7 @@ public class ErrorLogger extends Handler {
List<String> contains = new ArrayList<>();
contains.add("Error authenticating ");
contains.add("read timed out");
contains.add("could not decode packet");
contains.add("Connection reset by peer");
contains.add("No client connected for pending server");
contains.add("Error occurred processing connection for");

Datei anzeigen

@ -25,6 +25,9 @@ import de.steamwar.bungeecore.sql.SteamwarUser;
import net.dv8tion.jda.api.entities.Message;
import net.dv8tion.jda.api.events.message.priv.PrivateMessageReceivedEvent;
import java.io.InputStream;
import java.util.concurrent.CompletableFuture;
public class PrivateMessageListener extends BasicDiscordListener {
@Override
@ -63,7 +66,9 @@ public class PrivateMessageListener extends BasicDiscordListener {
}
try {
node.saveFromStream(attachment.retrieveInputStream().get(), newFormat);
InputStream in = attachment.retrieveInputStream().get();
node.saveFromStream(in, newFormat);
in.close();
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();

Datei anzeigen

@ -101,7 +101,9 @@ public class HelpCommand extends BasicCommand {
"HELP_BAU_TOGGLEWE", "/build togglewe ",
"HELP_BAU_TOGGLEWORLD", "/build toggleworld ",
"HELP_BAU_DELETE", "/build delete ",
"HELP_BAU_TESTARENA", "/build testarena ");
"HELP_BAU_TESTARENA", "/build testarena ",
"HELP_BAU_LOCK", "/build lock ",
"HELP_BAU_UNLOCK", "/build unlock");
}
private static void printPage(ChatSender sender, ClickEvent.Action action, String... args) {

Datei anzeigen

@ -31,13 +31,7 @@ public class ServerTeamchatCommand extends SWCommand {
}
@Register(description = "STC_USAGE")
public void genericCommand(CommandSender commandSender, String... message) {
ChatSender sender = ChatSender.of(commandSender);
if(message.length == 0) {
sender.system("STC_USAGE");
return;
}
ChatListener.sendChat(sender, ChatSender.serverteamReceivers(), "CHAT_SERVERTEAM", null, String.join(" ", message));
public void genericCommand(CommandSender commandSender, @ErrorMessage(value = "STC_USAGE", allowEAs = false) String... message) {
ChatListener.sendChat(ChatSender.of(commandSender), ChatSender.serverteamReceivers(), "CHAT_SERVERTEAM", null, String.join(" ", message));
}
}

Datei anzeigen

@ -79,15 +79,14 @@ public class TypeMappers {
public String map(CommandSender commandSender, String[] previousArguments, String s) {
if (previousArguments.length == 0) return null;
if (s.equalsIgnoreCase("random")) return "random";
ArenaMode arenaMode = ArenaMode.getByChat(previousArguments[previousArguments.length - 1]);
if (arenaMode.getMaps().contains(s)) return s;
return null;
return ArenaMode.getByChat(previousArguments[previousArguments.length - 1]).convertToRealMapName(s);
}
@Override
public Collection<String> tabCompletes(CommandSender sender, String[] previousArguments, String s) {
if (previousArguments.length == 0) return null;
ArenaMode arenaMode = ArenaMode.getByChat(previousArguments[previousArguments.length - 1]);
if (arenaMode == null) return null;
List<String> stringList = new ArrayList<>(arenaMode.getMaps());
stringList.add("random");
return stringList;

Datei anzeigen

@ -20,6 +20,7 @@
package de.steamwar.bungeecore.commands;
import de.steamwar.bungeecore.Message;
import de.steamwar.bungeecore.Storage;
import de.steamwar.bungeecore.sql.Punishment;
import de.steamwar.bungeecore.sql.SteamwarUser;
import de.steamwar.bungeecore.sql.Team;
@ -31,8 +32,10 @@ import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import java.net.InetSocketAddress;
import java.sql.Timestamp;
import java.text.DecimalFormat;
import java.time.Instant;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@ -78,15 +81,24 @@ public class WhoisCommand extends SWCommand {
Message.send("WHOIS_USERNAME", player, user.getUserName());
Message.send("WHOIS_UUID", player, Message.parse("WHOIS_UUID_HOVER", player), new ClickEvent(ClickEvent.Action.COPY_TO_CLIPBOARD, user.getUuid().toString()), user.getUuid().toString());
Message.send("WHOIS_ID", player, user.getId());
Message.send("WHOIS_GROUP", player, user.getUserGroup().getColorCode(), user.getUserGroup().name());
if (user.getDiscordId() != null) {
Message.send("WHOIS_DISCORD_ID", player, user.getDiscordId());
}
Timestamp firstJoin = user.getFirstjoin();
if (firstJoin == null)
if (firstJoin == null) {
Message.send("WHOIS_JOINED_FIRST", player, "0000-00-00 00:00:00");
else
} else {
Message.send("WHOIS_JOINED_FIRST", player, firstJoin.toString());
Message.send("WHOIS_HOURS_PLAYED", player, new DecimalFormat("###.##").format(user.getOnlinetime() / (double) 3600));
}
Message.send("WHOIS_HOURS_PLAYED", player, new DecimalFormat("###.##").format(user.getOnlinetime() / 3600d));
if(BungeeCord.getInstance().getPlayer(user.getUuid()) != null) {
ProxiedPlayer target = BungeeCord.getInstance().getPlayer(user.getUuid());
Message.send("WHOIS_CURRENT_PLAYED", player, new DecimalFormat("####.##").format((Instant.now().getEpochSecond() - Storage.sessions.get(target).toInstant().getEpochSecond()) / 60d));
Message.send("WHOIS_CURRENT_SERVER", player, target.getServer().getInfo().getName());
Message.send("WHOIS_CURRENT_PROTOCOL", player, target.getPendingConnection().getVersion());
}
Team team = Team.get(user.getTeam());
Message.send("WHOIS_TEAM", player, Message.parse("WHOIS_TEAM_HOVER", player, team.getTeamName()), new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/team info " + team.getTeamKuerzel()), team.getTeamColor(), team.getTeamKuerzel(), team.getTeamName());

Datei anzeigen

@ -41,7 +41,6 @@ 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 {
@ -124,12 +123,14 @@ public class Fabric extends BasicListener {
mods.add(Mod.get(mod.getAsString(), Mod.Platform.FABRIC));
}
/*
boolean isSorted = isSortedAlphabetically(mods);
if(!isSorted) {
banPlayer(user, player, "Mods are not sorted alphabetically: " + mods.stream().map(Mod::getModName).collect(Collectors.joining(", ")));
return;
}
*/
if(!neededModsContained(mods)) {
banPlayer(user, player, "Needed mods are not contained");

Datei anzeigen

@ -0,0 +1,27 @@
/*
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.sql;
public enum BauLockState {
NOBODY, // Locks the build server for all users
TEAM, //opens the build server only for every added user which is in the same team as the buildOwner
OPEN //unlocks the build server for all users
}

Datei anzeigen

@ -268,6 +268,7 @@ public class SteamwarUser {
return team;
}
@Deprecated
public ProxiedPlayer getPlayer() {
return ProxyServer.getInstance().getPlayer(uuid);
}
@ -325,14 +326,14 @@ public class SteamwarUser {
ProxiedPlayer player = ProxyServer.getInstance().getPlayer(uuid);
if (player != null) {
updateBanIP(player.getAddress().getAddress().getHostAddress());
ChatSender.disconnect(player).system(punishmentMessage(punishment));
for (BannedUserIPs banned : BannedUserIPs.get(player.getAddress().getAddress().getHostAddress())) {
SteamwarUser bannedUser = SteamwarUser.get(banned.getUserID());
if (isPunished(punishment) && bannedUser.getPunishment(punishment).getEndTime().before(time)) {
if (bannedUser.isPunished(punishment) && bannedUser.getPunishment(punishment).getEndTime().before(time)) {
bannedUser.punish(punishment, time, banReason, from, perma);
}
}
updateBanIP(player.getAddress().getAddress().getHostAddress());
} else {
updateBanIP("");
}

Datei anzeigen

@ -0,0 +1,46 @@
/*
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.sql;
public class UserConfig {
private UserConfig() {}
private static final Statement insert = new Statement("INSERT INTO UserConfig (User, Config, Value) VALUES (?,?,?) ON DUPLICATE KEY UPDATE Value = VALUES(Value)");
private static final Statement select = new Statement("SELECT Value FROM UserConfig WHERE User = ? AND Config = ?");
private static final Statement delete = new Statement("DELETE FROM UserConfig WHERE User = ? AND Config = ?");
public static String getConfig(int userID, String config) {
return select.select(rs -> {
if(rs.next())
return rs.getString("Value");
return null;
}, userID, config);
}
public static void updateUserConfig(int userID, String config, String value) {
if(value == null) {
delete.update(userID, config);
return;
}
insert.update(userID, config, value);
}
}

Datei anzeigen

@ -101,6 +101,10 @@ HELP_BAU_DELETE=§8/§ebuild delete §8- §7Reset your entire build server
HELP_BAU_DELETE_HOVER=§eReset build server
HELP_BAU_TESTARENA=§8/§ebuild testarena §8- §7Start a test arena
HELP_BAU_TESTARENA_HOVER=§eStart test arena
HELP_BAU_LOCK=§8/§ebuild lock §8- §7Locks the build server for a specified group of players
HELP_BAU_LOCK_HOVER=§eLock your build server
HELP_BAU_UNLOCK=§8/§ebuild unlock §8- §7Unlocks the buildserver for added users
HELP_BAU_UNLOCK_HOVER=§eUnlock your build server
#Usage description of various commands
USAGE_ALERT=§8/§7alert §8[§emessage§8]
@ -198,6 +202,11 @@ BAU_ADDMEMBER_ADDED=§aThe player was added to your world.
BAU_ADDMEMBER_ADDED_TARGET=§aYou have been added to the world of §e{0}§a.
BAU_TP_USAGE=§8/§7build tp §8[§eplayer§8]
BAU_TP_NOALLOWED=§cYou are not allowed to teleport to this player's world.
BAU_LOCKED_NOALLOWED=§cThe build server is currently locked.
BAU_LOCKED_OPTIONS=§7Build server lock options§8: §cnobody§8, §eteam§8, §aopen
BAU_LOCKED_NOBODY=§7You have locked your build server for all players.
BAU_LOCKED_TEAM=§7You've locked your build server for all players except added team members.
BAU_LOCKED_OPEN=§7You have opened your build server for all added players.
BAU_DELMEMBER_USAGE=§8/§7build delmember §8[§eplayer§8]
BAU_DELMEMBER_SELFDEL=§cYou cannot remove yourself!
BAU_DELMEMBER_DELETED=§cPlayer was removed.
@ -574,9 +583,13 @@ WHOIS_USERNAME=§7Username§8: §e{0}
WHOIS_UUID=§7UUID§8: §e{0}
WHOIS_UUID_HOVER=§eCopy UUID
WHOIS_ID=§7ID§8: §e{0}
WHOIS_GROUP=§7Group§8: {0}{1}
WHOIS_DISCORD_ID=§7Discord-ID§8: §e{0}
WHOIS_JOINED_FIRST=§7Joined on§8: §e{0}
WHOIS_HOURS_PLAYED=§7Online Time§8: §e{0}h
WHOIS_CURRENT_PLAYED=§7Current Online Time§8: §e{0}m
WHOIS_CURRENT_SERVER=§7Current Server§8: §e{0}
WHOIS_CURRENT_PROTOCOL=§7Current Protocol§8: §e{0}
WHOIS_TEAM=§7Team§8: §e[§{0}{1}§e] {2}
WHOIS_TEAM_HOVER=§eShow {0}
WHOIS_PUNISHMENTS=§7Punish:

Datei anzeigen

@ -87,6 +87,10 @@ HELP_BAU_DELETE=§8/§ebau delete §8- §7Setzt deine Bauwelt zurück
HELP_BAU_DELETE_HOVER=§eBauwelt zurücksetzen
HELP_BAU_TESTARENA=§8/§ebau testarena §8- §7Starte eine Testarena
HELP_BAU_TESTARENA_HOVER=§eTestarena starten
HELP_BAU_LOCK=§8/§ebau lock §8- §7Sperre deinen Bauserver für bestimmte Spielergruppen
HELP_BAU_LOCK_HOVER=§eSperre deinen Bau
HELP_BAU_UNLOCK=§8/§ebau unlock §8- §7Öffne deinen Bauserver für alle hinzugefügten Spieler
HELP_BAU_UNLOCK_HOVER=§eÖffne deinen Bau
#Usage description of various commands
USAGE_ALERT=§8/§7alert §8[§eNachricht§8]
@ -182,6 +186,11 @@ BAU_ADDMEMBER_ADDED=§aDer Spieler wurde zu deiner Welt hinzugefügt.
BAU_ADDMEMBER_ADDED_TARGET=§aDu wurdest zu der Welt von §e{0} §ahinzugefügt.
BAU_TP_USAGE=§8/§7bau tp §8[§eSpieler§8]
BAU_TP_NOALLOWED=§cDu darfst dich nicht auf diese Welt teleportieren.
BAU_LOCKED_NOALLOWED=§cDer Bauserver ist momentan gesperrt.
BAU_LOCKED_OPTIONS=§7Bauserver-Sperroptionen§8: §cnobody§8, §eteam§8, §aopen
BAU_LOCKED_NOBODY=§7Du hast deinen Bau für alle Spieler geschlossen.
BAU_LOCKED_TEAM=§7Du hast deinen Bau für alle außer hinzugefügte Teammitglieder gesperrt.
BAU_LOCKED_OPEN=§7Du hast deinen Bau für alle hinzugefügten Spieler geöffnet.
BAU_DELMEMBER_USAGE=§8/§7bau delmember §8[§eSpieler§8]
BAU_DELMEMBER_SELFDEL=§cDu kannst dich nicht selbst entfernen!
BAU_DELMEMBER_DELETED=§cDer Spieler wurde entfernt.
@ -550,12 +559,16 @@ SERVER_WORLD_ERROR=§cDas Erstellen der Welt ist fehlgeschlagen.
#WhoisCommand
WHOIS_USAGE=§c/whois [Spieler/ID] <-a>
WHOIS_USERNAME=§7Username§8: §e{0}
WHOIS_GROUP=§7Gruppe§8: {0}{1}
WHOIS_UUID=§7UUID§8: §e{0}
WHOIS_UUID_HOVER=§eUUID Kopieren
WHOIS_ID=§7ID§8: §e{0}
WHOIS_DISCORD_ID=§7Discord-ID§8: §e{0}
WHOIS_JOINED_FIRST=§7Beigetreten am§8: §e{0}
WHOIS_HOURS_PLAYED=§7Spielzeit§8: §e{0}h
WHOIS_CURRENT_PLAYED=§7Aktuell online§8: §e{0}m
WHOIS_CURRENT_SERVER=§7Aktueller Server§8: §e{0}
WHOIS_CURRENT_PROTOCOL=§7Aktuelle Version§8: §e{0}
WHOIS_TEAM=§7Team§8: §e[§{0}{1}§e] {2}
WHOIS_TEAM_HOVER=§e{0} anzeigen
WHOIS_PUNISHMENTS=§7Strafen: