SteamWar/SpigotCore
Archiviert
13
0

Fix merge issues
Einige Prüfungen sind fehlgeschlagen
SteamWarCI Build failed

Dieser Commit ist enthalten in:
Lixfel 2022-10-29 12:42:41 +02:00
Ursprung 4548f80843
Commit 74823ba86f
4 geänderte Dateien mit 2 neuen und 123 gelöschten Zeilen

Datei anzeigen

@ -139,9 +139,4 @@ public class Core extends JavaPlugin{
if(crashDetector.onMainThread())
Statement.closeAll();
}
private static void setSqlConfig() {
sqlConfig = new File(System.getProperty("user.home"), "MySQL.yml");
standalone = !sqlConfig.exists();
}
}

Datei anzeigen

@ -20,7 +20,7 @@
package de.steamwar.core;
import de.steamwar.sql.SWException;
import de.steamwar.sql.Statement;
import de.steamwar.sql.internal.Statement;
import org.bukkit.Bukkit;
import java.util.Arrays;
@ -64,7 +64,7 @@ public class CrashDetector {
if(Core.getInstance().isEnabled()) {
Core.getInstance().onDisable();
}
Statement.close();
Statement.closeAll();
//System.exit(0); Does freeze, potential freezing issues: ConsoleRestoreHook, ApplicationShutdownHooks or DeleteOnExitHook
Runtime.getRuntime().halt(0);
}

Datei anzeigen

@ -1,65 +0,0 @@
/*
* 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.sql;
import lombok.AllArgsConstructor;
import lombok.Getter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.nio.file.Files;
import java.sql.SQLException;
@AllArgsConstructor
public class Replay {
private static final Statement get = new Statement("SELECT Replay FROM Replay WHERE FightID = ?");
private static final Statement insert = new Statement("INSERT INTO Replay (FightID, Replay) VALUES (?, ?)");
public static Replay get(int fightID) {
return get.select(rs -> {
rs.next();
File file;
try {
file = File.createTempFile("replay", "replay");
file.deleteOnExit();
Files.copy(rs.getBinaryStream("Replay"), file.toPath());
} catch (IOException e) {
throw new SQLException(e);
}
return new Replay(fightID, file);
}, fightID);
}
public static void save(int fightID, File file) {
try {
insert.update(fightID, new FileInputStream(file));
} catch (FileNotFoundException e) {
throw new SecurityException("Could not save replay", e);
}
}
private final int fightID;
@Getter
private final File replay;
}

Datei anzeigen

@ -1,51 +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.sql;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.entity.Player;
import java.io.File;
public class SWException {
private SWException(){}
private static final String serverVersion = Bukkit.getServer().getVersion();
private static final String cwd = System.getProperty("user.dir");
private static final String server = new File(cwd).getName();
public static void init() {
//force class loading
}
public static void log(String message, String stacktrace){
StringBuilder msgBuilder = new StringBuilder(message).append("\nPlayers: ");
for(Player player : Bukkit.getOnlinePlayers())
msgBuilder.append(player.getName()).append(" ");
msgBuilder.append("\nWorlds: ");
for(World world : Bukkit.getWorlds())
msgBuilder.append(world.getName()).append(" ");
msgBuilder.append("\nServer: ").append(serverVersion);
msgBuilder.append("\nCWD: ").append(cwd);
Provider.impl.logException(server, msgBuilder.toString(), stacktrace);
}
}