SteamWar/SpigotCore
Archiviert
13
0

Adding SchemDownloadlink-Generator

Dieser Commit ist enthalten in:
Lixfel 2019-12-16 19:37:53 +01:00
Ursprung 6cab302ac0
Commit 3ed64a8b60

Datei anzeigen

@ -1,7 +1,27 @@
package de.steamwar.sql;
import org.bukkit.craftbukkit.libs.org.apache.commons.codec.digest.DigestUtils;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.time.Instant;
public class DownloadSchematic {
public DownloadSchematic(Schematic schem){
SQL.update("");
private DownloadSchematic(){}
private static final String BASE = "https://steamwar.de/download.php?schem=";
public static String getLink(Schematic schem){
ResultSet rs = SQL.select("SELECT * FROM SchemDownload WHERE SchemID = " + schem.getSchemID());
try {
if(rs.next())
return BASE + rs.getString("Link");
} catch (SQLException e) {
throw new SecurityException("Could not check schematic for existance", e);
}
String hash = DigestUtils.sha1Hex(Instant.now().toString() + schem.getSchemOwner() + schem.getSchemID());
SQL.update("INSERT INTO SchemDownload (SchemID, Link) VALUES (" + schem.getSchemID() + ", '" + hash + "')");
return BASE + hash;
}
}