SteamWar/SpigotCore
Archiviert
13
0

Adding the used global conversation script

Dieser Commit ist enthalten in:
Lixfel 2019-12-09 11:57:16 +01:00
Ursprung 441097926b
Commit 526dc25c5d

Datei anzeigen

@ -2,17 +2,17 @@ package de.steamwar.sql;
import com.sk89q.worldedit.extent.clipboard.Clipboard; import com.sk89q.worldedit.extent.clipboard.Clipboard;
import de.steamwar.core.Core; import de.steamwar.core.Core;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import java.io.ByteArrayInputStream; import java.io.*;
import java.io.IOException;
import java.io.InputStream;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
import java.util.logging.Level;
public class Schematic { public class Schematic {
@ -70,6 +70,26 @@ public class Schematic {
} }
} }
public static void convertAllSchematics(){
try{
PreparedStatement ps = SQL.getCon().prepareStatement("SELECT SchemName, SchemOwner FROM Schematic");
ResultSet allSchems = ps.executeQuery();
while(allSchems.next()){
int schemOwner = allSchems.getInt("SchemOwner");
String schemName = allSchems.getString("SchemName");
try{
PreparedStatement st = SQL.getCon().prepareStatement("UPDATE Schematic SET SchemData = ? WHERE SchemOwner = " + schemOwner + " AND SchemName = '" + schemName + "'");
st.setBlob(1, new FileInputStream("/home/minecraft/schematics/" + SteamwarUser.get(schemOwner).getUUID().toString() + "/" + schemName + ".schematic"));
st.executeUpdate();
}catch(FileNotFoundException e){
Bukkit.getLogger().log(Level.WARNING, "Could not convert Schematic " + schemOwner + " " + schemName + " due to missing file.");
}
}
}catch(SQLException e){
throw new SecurityException("Schematic Conversation failed", e);
}
}
public static List<Schematic> getSchemsAccessibleByUser(UUID schemOwner){ public static List<Schematic> getSchemsAccessibleByUser(UUID schemOwner){
return getSchemsAccessibleByUser(SteamwarUser.get(schemOwner).getId()); return getSchemsAccessibleByUser(SteamwarUser.get(schemOwner).getId());
} }