SteamWar/BungeeCore
Archiviert
13
2

Merge branch 'master' into ModCommand

# Conflicts:
#	src/de/steamwar/bungeecore/listeners/ConnectionListener.java
#	src/de/steamwar/bungeecore/sql/Mod.java
Dieser Commit ist enthalten in:
zOnlyKroks 2023-01-23 15:39:58 +01:00
Commit 39c52211a8
35 geänderte Dateien mit 265 neuen und 252 gelöschten Zeilen

@ -1 +1 @@
Subproject commit c6da22f0bee3865b7b3283bc17275e12c5de14af
Subproject commit d12fbbd339f6f34108301aa08d1377eceea250a5

Datei anzeigen

@ -34,6 +34,7 @@ import de.steamwar.command.SWCommandUtils;
import de.steamwar.command.SWTypeMapperCreator;
import de.steamwar.command.TabCompletionCache;
import de.steamwar.command.TypeMapper;
import de.steamwar.sql.internal.Statement;
import net.md_5.bungee.BungeeCord;
import net.md_5.bungee.api.ChatMessageType;
import net.md_5.bungee.api.CommandSender;

Datei anzeigen

@ -30,7 +30,7 @@ import java.util.logging.Level;
public abstract class Node {
private static final List<String> OPENJ9_ARGS = Arrays.asList("-Xgc:excessiveGCratio=80", "-Xsyslog:none", "-Xtrace:none", "-Xdisableexplicitgc", "-XX:+AlwaysPreTouch", "-XX:+CompactStrings", "-XX:-HeapDumpOnOutOfMemory", "-XX:+ExitOnOutOfMemoryError", "-Dlog4j.configurationFile=log4j2.xml");
private static final List<String> OPENJ9_ARGS = Arrays.asList("-Xgc:excessiveGCratio=80", "-Xsyslog:none", "-Xtrace:none", "-Xdisableexplicitgc", "-XX:+AlwaysPreTouch", "-XX:+CompactStrings", "-XX:-HeapDumpOnOutOfMemory", "-XX:+ExitOnOutOfMemoryError", "-Dlog4j.configurationFile=log4j2.xml", "-Dio.netty.allocator.numHeapArenas=1", "-Xmos128M", "-Xmns48M"); // initial heap half values of memory observed by 1.19 spectate server
private static final Set<String> JAVA_8 = new HashSet<>();
static {
JAVA_8.add("paper-1.8.8.jar");

Datei anzeigen

@ -2,11 +2,10 @@ package de.steamwar.bungeecore.commands;
import de.steamwar.bungeecore.BungeeCore;
import de.steamwar.bungeecore.Message;
import de.steamwar.bungeecore.sql.Statement;
import de.steamwar.sql.internal.Statement;
import de.steamwar.bungeecore.sql.SteamwarUser;
import de.steamwar.command.SWCommand;
import net.md_5.bungee.BungeeCord;
import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import java.io.*;

Datei anzeigen

@ -21,33 +21,32 @@ 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;
import de.steamwar.bungeecore.listeners.mods.Utils;
import de.steamwar.bungeecore.sql.*;
import de.steamwar.command.SWCommand;
import de.steamwar.command.SWCommandUtils;
import de.steamwar.command.TypeMapper;
import lombok.Getter;
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 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;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;
public class WhoisCommand extends SWCommand {
public WhoisCommand() {
super("whois", "bungeecore.teamchat");
super("whois");
}
@Register(description = "WHOIS_USAGE")
public void genericCommand(ProxiedPlayer player, @Mapper("player") String target, @OptionalValue("") @StaticValue(value = {"", "-all", "-a"}, allowISE = true) boolean all) {
public void genericCommand(ProxiedPlayer player, @Mapper("player") String target, WhoisParameterTypes... parameters) {
SteamwarUser user = SteamwarUser.get(target);
if (user == null) {
try {
@ -68,7 +67,8 @@ public class WhoisCommand extends SWCommand {
if (user == null) {
Message.send("UNKNOWN_PLAYER", player);
} else {
sendUserinfo(player, user, all);
EnumSet<WhoisParameterTypes> set = parameters.length == 0 ? EnumSet.noneOf(WhoisParameterTypes.class) : EnumSet.copyOf(Arrays.asList(parameters));
sendUserinfo(player, user, set);
}
}
@ -77,14 +77,23 @@ public class WhoisCommand extends SWCommand {
return SWCommandUtils.createMapper(s -> s, s -> BungeeCord.getInstance().getPlayers().stream().map(ProxiedPlayer::getName).collect(Collectors.toList()));
}
private static void sendUserinfo(ProxiedPlayer player, SteamwarUser user, boolean all) {
private static void sendUserinfo(ProxiedPlayer player, SteamwarUser user, EnumSet<WhoisParameterTypes> parameterTypes) {
UserGroup userGroup = SteamwarUser.get(player.getUniqueId()).getUserGroup();
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());
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());
if (!userGroup.isTeamGroup()) return;
if (userGroup.isAdminGroup()) {
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());
if (user.getDiscordId() != null) {
Message.send("WHOIS_DISCORD_ID", player, user.getDiscordId());
}
}
Timestamp firstJoin = user.getFirstjoin();
if (firstJoin == null) {
Message.send("WHOIS_JOINED_FIRST", player, "0000-00-00 00:00:00");
@ -100,13 +109,28 @@ public class WhoisCommand extends SWCommand {
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());
if (Utils.playerModMap.containsKey(user.getUuid())) {
Mod.Platform modPlatform = Utils.playerModMap.get(user.getUuid()).get(0).getPlatform();
Message.send("WHOIS_PLATFORM", player, modPlatform.toString());
}
if (parameterTypes.contains(WhoisParameterTypes.MOD)) {
List<Mod> activeMods = Utils.playerModMap.get(user.getUuid());
if (activeMods != null && !activeMods.isEmpty()) {
Message.send("WHOIS_ACTIVE_MODS", player,activeMods.size());
String result = activeMods.stream().map(mod -> "§" + mod.getModType().getColorCode() + mod.getModName()).collect(Collectors.joining("§8, "));
Message.send("WHOIS_ACTIVE_MOD", player, result);
} else {
Message.send("WHOIS_NO_ACTIVE_MODS", player);
}
}
Message.send("WHOIS_PUNISHMENTS", player);
List<Punishment> punishmentList = Punishment.getAllPunishmentsOfPlayer(user.getId());
Set<Punishment.PunishmentType> found = new HashSet<>();
boolean isPunished = false;
boolean all = parameterTypes.contains(WhoisParameterTypes.ALL);
for (Punishment punishment : punishmentList) {
if (!all && !punishment.getType().isMulti() && !found.add(punishment.getType())) {
continue;
@ -121,4 +145,46 @@ public class WhoisCommand extends SWCommand {
Message.send(all ? "WHOIS_NO_ALL_PUNISHMENT" : "WHOIS_NO_PUNISHMENT", player);
}
}
@ClassMapper(value = WhoisParameterTypes.class, local = true)
public TypeMapper<WhoisParameterTypes> argumentTypeMapper() {
WhoisParameterTypes[] values = WhoisParameterTypes.values();
return new TypeMapper<WhoisParameterTypes>() {
@Override
public WhoisParameterTypes map(CommandSender commandSender, String[] previousArguments, String s) {
UserGroup userGroup = SteamwarUser.get(((ProxiedPlayer) commandSender).getUniqueId()).getUserGroup();
return Stream.of(values)
.filter(p -> p.userGroupSet.contains(userGroup))
.filter(p -> p.getTabCompletes().contains(s))
.findFirst()
.orElse(null);
}
@Override
public Collection<String> tabCompletes(CommandSender commandSender, String[] previousArguments, String s) {
UserGroup userGroup = SteamwarUser.get(((ProxiedPlayer) commandSender).getUniqueId()).getUserGroup();
return Stream.of(values)
.filter(p -> p.userGroupSet.contains(userGroup))
.flatMap(p -> p.getTabCompletes().stream())
.collect(Collectors.toList());
}
};
}
private enum WhoisParameterTypes {
ALL(Arrays.asList("-a", "-all"), UserGroup.Admin, UserGroup.Moderator, UserGroup.Developer, UserGroup.Supporter, UserGroup.Builder),
MOD(Arrays.asList("-m", "-mod", "-mods"), UserGroup.Admin, UserGroup.Moderator, UserGroup.Developer);
private final EnumSet<UserGroup> userGroupSet;
@Getter
private List<String> tabCompletes;
WhoisParameterTypes(List<String> tabCompletes, UserGroup... userGroups) {
this.userGroupSet = EnumSet.copyOf(Arrays.asList(userGroups));
this.tabCompletes = tabCompletes;
}
}
}

Datei anzeigen

@ -27,8 +27,8 @@ import de.steamwar.bungeecore.bot.config.SteamwarDiscordBotConfig;
import de.steamwar.bungeecore.bot.util.DiscordRanks;
import de.steamwar.bungeecore.commands.ChallengeCommand;
import de.steamwar.bungeecore.commands.CheckCommand;
import de.steamwar.bungeecore.commands.ModCommand;
import de.steamwar.bungeecore.commands.MsgCommand;
import de.steamwar.bungeecore.listeners.mods.Utils;
import de.steamwar.bungeecore.sql.SteamwarUser;
import de.steamwar.bungeecore.sql.UserGroup;
import net.md_5.bungee.api.AbstractReconnectHandler;
@ -136,7 +136,7 @@ public class ConnectionListener extends BasicListener {
public void onDisconnect(PlayerDisconnectEvent e){
ChallengeCommand.remove(e.getPlayer());
MsgCommand.remove(e.getPlayer());
ModCommand.playerFilterType.remove(e.getPlayer());
Utils.playerModMap.remove(e.getPlayer().getUniqueId());
}
@EventHandler

Datei anzeigen

@ -89,7 +89,7 @@ public class Fabric extends BasicListener {
}
Storage.fabricExpectPluginMessage.remove(player);
List<Mod> mods = new LinkedList<>();
List<Mod> mods = new ArrayList<>();
Utils.VarInt varInt = Utils.readVarInt(data,0);
@ -122,15 +122,6 @@ public class Fabric extends BasicListener {
mods.add(Mod.getOrCreate(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)) {
logMessage(user, "Needed mods are not contained", dataString);
return;
@ -159,17 +150,6 @@ public class Fabric extends BasicListener {
}
}
private boolean isSortedAlphabetically(List<Mod> mods) {
boolean isSorted = true;
for(int i = 0; i < mods.size() - 1; i++) {
if(mods.get(i).getModName().compareToIgnoreCase(mods.get(i + 1).getModName()) > 0) {
isSorted = false;
break;
}
}
return isSorted;
}
private boolean neededModsContained(List<Mod> mods) {
return mods.stream()
.map(Mod::getModName)

Datei anzeigen

@ -33,15 +33,15 @@ import net.md_5.bungee.api.connection.ProxiedPlayer;
import java.sql.Timestamp;
import java.time.Instant;
import java.time.temporal.ChronoUnit;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.UUID;
import java.util.*;
import java.util.function.Consumer;
import java.util.logging.Level;
import java.util.stream.Collectors;
class Utils {
public class Utils {
public static final Map<UUID,List<Mod>> playerModMap = new HashMap<>();
private Utils(){}
static VarInt readVarInt(byte[] array, int startPos) {
@ -69,6 +69,7 @@ class Utils {
static boolean handleMods(UUID uuid, Locale locale, Consumer<BaseComponent[]> disconnect, List<Mod> mods){
SteamwarUser user = SteamwarUser.get(uuid);
boolean privileged = user.getUserGroup().privilegedMods();
playerModMap.put(uuid,new ArrayList<>(mods));
ModType max = ModType.YELLOW;
Iterator<Mod> it = mods.iterator();
@ -80,8 +81,10 @@ class Utils {
max = ModType.RED;
}
if(mods.isEmpty())
if(mods.isEmpty()) {
return true;
}
ModType finalMax = max;
String modList = mods.stream().filter(mod -> finalMax == ModType.YELLOW || mod.getModType() == ModType.RED).map(Mod::getModName).collect(Collectors.joining("\n"));

Datei anzeigen

@ -19,6 +19,8 @@
package de.steamwar.bungeecore.sql;
import de.steamwar.sql.internal.Statement;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;

Datei anzeigen

@ -19,6 +19,8 @@
package de.steamwar.bungeecore.sql;
import de.steamwar.sql.internal.Statement;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;

Datei anzeigen

@ -19,6 +19,8 @@
package de.steamwar.bungeecore.sql;
import de.steamwar.sql.internal.Statement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Timestamp;

Datei anzeigen

@ -19,6 +19,8 @@
package de.steamwar.bungeecore.sql;
import de.steamwar.sql.internal.Statement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Timestamp;

Datei anzeigen

@ -19,6 +19,7 @@
package de.steamwar.bungeecore.sql;
import de.steamwar.sql.internal.Statement;
import de.steamwar.bungeecore.ArenaMode;
import java.sql.ResultSet;

Datei anzeigen

@ -1,5 +1,6 @@
package de.steamwar.bungeecore.sql;
import de.steamwar.sql.internal.Statement;
import de.steamwar.bungeecore.ArenaMode;
import java.sql.ResultSet;

Datei anzeigen

@ -1,5 +1,7 @@
package de.steamwar.bungeecore.sql;
import de.steamwar.sql.internal.Statement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;

Datei anzeigen

@ -19,6 +19,7 @@
package de.steamwar.bungeecore.sql;
import de.steamwar.sql.internal.Statement;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import java.sql.ResultSet;

Datei anzeigen

@ -19,6 +19,8 @@
package de.steamwar.bungeecore.sql;
import de.steamwar.sql.internal.Statement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.HashSet;

Datei anzeigen

@ -19,6 +19,7 @@
package de.steamwar.bungeecore.sql;
import de.steamwar.sql.internal.Statement;
import de.steamwar.bungeecore.listeners.PollSystem;
import java.sql.ResultSet;

Datei anzeigen

@ -19,6 +19,7 @@
package de.steamwar.bungeecore.sql;
import de.steamwar.sql.internal.Statement;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.RequiredArgsConstructor;

Datei anzeigen

@ -19,6 +19,8 @@
package de.steamwar.bungeecore.sql;
import de.steamwar.sql.internal.Statement;
public class SWException {
private SWException(){}

Datei anzeigen

@ -19,6 +19,7 @@
package de.steamwar.bungeecore.sql;
import de.steamwar.sql.internal.Statement;
import static de.steamwar.bungeecore.sql.UserElo.ELO_DEFAULT;
public class SchemElo {

Datei anzeigen

@ -19,19 +19,16 @@
package de.steamwar.bungeecore.sql;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import de.steamwar.sql.internal.Statement;
import java.io.InputStream;
import java.sql.Blob;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.time.Instant;
import java.util.*;
import java.util.function.Predicate;
import java.util.zip.GZIPInputStream;
public class SchematicNode {
private static final Statement createNode = new Statement("INSERT INTO SchematicNode (NodeName, NodeOwner, ParentNode, NodeType, NodeItem) VALUES (?, ?, ?, ?, ?) ON DUPLICATE KEY UPDATE NodeName = VALUES(NodeName), ParentNode = VALUES(ParentNode), NodeItem = VALUES(NodeItem), NodeType = VALUES(NodeType), NodeItem = VALUES(NodeItem)");

Datei anzeigen

@ -19,6 +19,8 @@
package de.steamwar.bungeecore.sql;
import de.steamwar.sql.internal.Statement;
import java.sql.Timestamp;
public class Session {

Datei anzeigen

@ -1,194 +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.sql;
import de.steamwar.bungeecore.BungeeCore;
import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.config.Configuration;
import net.md_5.bungee.config.ConfigurationProvider;
import net.md_5.bungee.config.YamlConfiguration;
import java.io.File;
import java.io.IOException;
import java.sql.*;
import java.util.*;
import java.util.logging.Level;
import java.util.logging.Logger;
public class Statement implements AutoCloseable {
private static final Logger logger = BungeeCore.get().getLogger();
private static final List<Statement> statements = new ArrayList<>();
private static final Deque<Connection> connections = new ArrayDeque<>();
private static final String URL;
private static final String USER;
private static final String PASSWORD;
static {
File file = new File(System.getProperty("user.home"), "MySQL.yml");
Configuration config;
try {
config = ConfigurationProvider.getProvider(YamlConfiguration.class).load(file);
} catch (IOException e) {
ProxyServer.getInstance().stop();
throw new SecurityException("Could not load SQL connection", e);
}
URL = "jdbc:mysql://" + config.getString("HOST") + ":" + config.getString("PORT") + "/" + config.getString("DATABASE");
USER = config.getString("USER");
PASSWORD = config.getString("PASSWORD");
}
public static void closeAll() {
synchronized (connections) {
for(Connection connection : connections) {
try {
synchronized (statements) {
statements.forEach(statement -> statement.close(connection));
}
connection.close();
} catch (SQLException e) {
logger.log(Level.INFO, "Could not close SQL connection", e);
}
}
connections.clear();
}
}
private final String sql;
private final Map<Connection, PreparedStatement> cachedStatements = new HashMap<>();
public Statement(String sql) {
this.sql = sql;
synchronized (statements) {
statements.add(this);
}
}
public <T> T select(ResultSetUser<T> user, Object... objects) {
return withConnection(st -> {
ResultSet rs = st.executeQuery();
T result = user.use(rs);
rs.close();
return result;
}, objects);
}
public void update(Object... objects) {
withConnection(PreparedStatement::executeUpdate, objects);
}
private <T> T withConnection(SQLRunnable<T> runnable, Object... objects) {
Connection connection = aquireConnection();
T result;
try {
result = tryWithConnection(connection, runnable, objects);
} catch (SQLException e) {
closeConnection(connection);
connection = aquireConnection();
try {
result = tryWithConnection(connection, runnable, objects);
} catch (SQLException ex) {
closeConnection(connection);
throw new SecurityException("Could not execute statement", ex);
}
}
synchronized (connections) {
connections.addLast(connection);
}
return result;
}
private <T> T tryWithConnection(Connection connection, SQLRunnable<T> runnable, Object... objects) throws SQLException {
PreparedStatement st = cachedStatements.get(connection);
if(st == null) {
st = connection.prepareStatement(sql);
cachedStatements.put(connection, st);
}
for (int i = 0; i < objects.length; i++) {
st.setObject(i + 1, objects[i]);
}
return runnable.run(st);
}
@Override
public void close() {
cachedStatements.values().forEach(st -> closeStatement(st, false));
cachedStatements.clear();
synchronized (statements) {
statements.remove(this);
}
}
private void close(Connection connection) {
PreparedStatement st = cachedStatements.remove(connection);
if(st != null)
closeStatement(st, true);
}
private static Connection aquireConnection() {
synchronized (connections) {
if(!connections.isEmpty())
return connections.pop();
}
try {
return DriverManager.getConnection(URL + "?autoReconnect=true&useServerPrepStmts=true", USER, PASSWORD);
} catch (SQLException e) {
throw new SecurityException("Could not open connection", e);
}
}
private static void closeConnection(Connection connection) {
synchronized (statements) {
for (Statement statement : statements) {
statement.close(connection);
}
}
try {
connection.close();
} catch (SQLException e) {
logger.log(Level.INFO, "Could not close connection", e);
}
}
private static void closeStatement(PreparedStatement st, boolean silent) {
try {
st.close();
} catch (SQLException e) {
if(!silent)
logger.log(Level.INFO, "Could not close statement", e);
}
}
public interface ResultSetUser<T> {
T use(ResultSet rs) throws SQLException;
}
private interface SQLRunnable<T> {
T run(PreparedStatement st) throws SQLException;
}
}

Datei anzeigen

@ -19,6 +19,7 @@
package de.steamwar.bungeecore.sql;
import de.steamwar.sql.internal.Statement;
import com.google.gson.JsonParser;
import de.steamwar.bungeecore.BungeeCore;
import de.steamwar.bungeecore.Message;

Datei anzeigen

@ -19,6 +19,8 @@
package de.steamwar.bungeecore.sql;
import de.steamwar.sql.internal.Statement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;

Datei anzeigen

@ -19,6 +19,8 @@
package de.steamwar.bungeecore.sql;
import de.steamwar.sql.internal.Statement;
import java.sql.ResultSet;
import java.util.HashSet;
import java.util.Set;

Datei anzeigen

@ -19,6 +19,8 @@
package de.steamwar.bungeecore.sql;
import de.steamwar.sql.internal.Statement;
import de.steamwar.bungeecore.BungeeCore;
import de.steamwar.bungeecore.ServerStarter;
import de.steamwar.bungeecore.SubserverSystem;

Datei anzeigen

@ -20,6 +20,8 @@
package de.steamwar.bungeecore.sql;
import de.steamwar.sql.internal.Statement;
public class UserConfig {
private UserConfig() {}

Datei anzeigen

@ -19,6 +19,7 @@
package de.steamwar.bungeecore.sql;
import de.steamwar.sql.internal.Statement;
import de.steamwar.bungeecore.ArenaMode;
import de.steamwar.bungeecore.Message;
import net.md_5.bungee.api.connection.ProxiedPlayer;

Datei anzeigen

@ -578,7 +578,7 @@ SERVER_WORLD_ERROR=§cCreating the world failed.
#WhoisCommand
WHOIS_USAGE=§c/whois [player/ID] <-a>
WHOIS_USAGE=§c/whois [player/ID] [-a/-m]
WHOIS_USERNAME=§7Username§8: §e{0}
WHOIS_UUID=§7UUID§8: §e{0}
WHOIS_UUID_HOVER=§eCopy UUID
@ -596,6 +596,10 @@ WHOIS_PUNISHMENTS=§7Punish:
WHOIS_PUNISHMENT=§7{0}§8» §f§l{1}: §e{2} - {3} §f{4}
WHOIS_NO_PUNISHMENT=§a✓ §7This player has no active punishment.
WHOIS_NO_ALL_PUNISHMENT=§a✓ §7The player has not done anything yet.
WHOIS_ACTIVE_MODS=§7Active Mods ({0}):
WHOIS_NO_ACTIVE_MODS=§7This player has no active mods.
WHOIS_ACTIVE_MOD={0}
WHOIS_PLATFORM=§7Modloader: §e{0}
#VerifyCommand
VERIFY_USAGE=§c/verify [Code]

Datei anzeigen

@ -557,7 +557,7 @@ SERVER_WORLD_ERROR=§cDas Erstellen der Welt ist fehlgeschlagen.
#WhoisCommand
WHOIS_USAGE=§c/whois [Spieler/ID] <-a>
WHOIS_USAGE=§c/whois [Spieler/ID] [-a/-m]
WHOIS_USERNAME=§7Username§8: §e{0}
WHOIS_GROUP=§7Gruppe§8: {0}{1}
WHOIS_UUID=§7UUID§8: §e{0}
@ -575,6 +575,8 @@ WHOIS_PUNISHMENTS=§7Strafen:
WHOIS_PUNISHMENT=§7{0}§8» §f§l{1}: §e{2} - {3} §f{4}
WHOIS_NO_PUNISHMENT=§a✓ §7Der Spieler hat keine aktiven Strafen.
WHOIS_NO_ALL_PUNISHMENT=§a✓ §7Der Spieler hat noch nichts getan.
WHOIS_ACTIVE_MODS=§7Aktive Mods ({0}):
WHOIS_NO_ACTIVE_MODS=§7Der Spieler hat keine aktiven Mods.
#VerifyCommand
VERIFY_USAGE=§c/verify [Code]

Datei anzeigen

@ -0,0 +1,37 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2023 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.sql;
import de.steamwar.bungeecore.BungeeCore;
import de.steamwar.sql.internal.SQLConfig;
import java.util.logging.Logger;
public class SQLConfigImpl implements SQLConfig {
@Override
public Logger getLogger() {
return BungeeCore.get().getLogger();
}
@Override
public int maxConnections() {
return 4;
}
}

Datei anzeigen

@ -0,0 +1,86 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2023 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.sql;
import de.steamwar.bungeecore.BungeeCore;
import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.config.ServerInfo;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.config.Configuration;
import net.md_5.bungee.config.ConfigurationProvider;
import net.md_5.bungee.config.YamlConfiguration;
import java.io.File;
import java.io.IOException;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
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");
if(folder.exists()) {
for(File configFile : Arrays.stream(folder.listFiles((file, name) -> name.endsWith(".yml") && !name.endsWith(".kits.yml"))).sorted().collect(Collectors.toList())) {
Configuration config;
try {
config = ConfigurationProvider.getProvider(YamlConfiguration.class).load(configFile);
} catch (IOException e) {
throw new SecurityException("Could not load SchematicTypes", e);
}
if(!config.contains("Schematic"))
continue;
String type = config.getString("Schematic.Type");
assert type != null;
String shortcut = config.getString("Schematic.Shortcut");
if(tmpFromDB.containsKey(type.toLowerCase()))
continue;
SchematicType checktype = null;
String material = config.getString("Schematic.Material");
if(!config.getStringList("CheckQuestions").isEmpty()) {
checktype = new SchematicType("C" + type, "C" + shortcut, SchematicType.Type.CHECK_TYPE, null, material);
tmpTypes.add(checktype);
tmpFromDB.put(checktype.toDB(), checktype);
}
SchematicType current = new SchematicType(type, shortcut, !config.contains("Server") ? SchematicType.Type.FIGHT_TYPE : SchematicType.Type.NORMAL, checktype, material);
tmpTypes.add(current);
tmpFromDB.put(type.toLowerCase(), current);
}
}
}
@Override
public void additionalExceptionMetadata(StringBuilder builder) {
builder.append("\nServers: ");
for(Map.Entry<String, ServerInfo> server : ProxyServer.getInstance().getServers().entrySet()) {
builder.append(server.getKey()).append("(");
for(ProxiedPlayer player : server.getValue().getPlayers()) {
builder.append(player.getName()).append(" ");
}
builder.append(")");
}
}
}

Datei anzeigen

@ -1,6 +1,6 @@
build:
- "cp ~/gradle.properties ."
- "./gradlew buildProject"
- "./gradlew --stop"
artifacts:
"/binarys/bungeecore.jar": "build/libs/bungeecore.jar"