Fixing Schematic RAM leak and 1.14 support
Dieser Commit ist enthalten in:
Ursprung
efb3e2ce70
Commit
4fa0297480
@ -1,6 +1,5 @@
|
||||
package de.steamwar.sql;
|
||||
|
||||
import com.boydti.fawe.FaweAPI;
|
||||
import com.sk89q.worldedit.EmptyClipboardException;
|
||||
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
@ -23,7 +22,7 @@ class Schematic_14 {
|
||||
static byte[] getPlayerClipboard(Player player, boolean schemFormat) throws IOException, NoClipboardException {
|
||||
ClipboardHolder clipboardHolder;
|
||||
try {
|
||||
clipboardHolder = FaweAPI.wrapPlayer(player).getSession().getClipboard();
|
||||
clipboardHolder = WorldEditPlugin.getInstance().getSession(player).getClipboard();
|
||||
} catch (EmptyClipboardException e) {
|
||||
throw new NoClipboardException();
|
||||
}
|
||||
|
@ -2,17 +2,17 @@ package de.steamwar.sql;
|
||||
|
||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||
import de.steamwar.core.Core;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.io.*;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class Schematic {
|
||||
|
||||
@ -55,7 +55,7 @@ public class Schematic {
|
||||
|
||||
public static Schematic getSchemFromDB(String schemName, int schemOwner){
|
||||
schemName = SQL.disarmString(schemName);
|
||||
ResultSet schematic = SQL.select("SELECT * FROM Schematic WHERE SchemName = '" + schemName + "' AND SchemOwner = '" + schemOwner + "'");
|
||||
ResultSet schematic = SQL.select("SELECT SchemID, SchemName, SchemOwner, Item, SchemType, SchemFormat FROM Schematic WHERE SchemName = '" + schemName + "' AND SchemOwner = '" + schemOwner + "'");
|
||||
try {
|
||||
if(schematic == null || !schematic.next()){
|
||||
SchematicMember member = SchematicMember.getMemberBySchematic(schemName, schemOwner);
|
||||
@ -70,33 +70,13 @@ 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){
|
||||
return getSchemsAccessibleByUser(SteamwarUser.get(schemOwner).getId());
|
||||
}
|
||||
|
||||
public static List<Schematic> getSchemsAccessibleByUser(int schemOwner){
|
||||
try{
|
||||
ResultSet schematic = SQL.select("SELECT * FROM Schematic WHERE SchemOwner = '" + schemOwner + "'");
|
||||
ResultSet schematic = SQL.select("SELECT SchemID, SchemName, SchemOwner, Item, SchemType, SchemFormat FROM Schematic WHERE SchemOwner = '" + schemOwner + "'");
|
||||
List<Schematic> schematics = new ArrayList<>();
|
||||
while(schematic.next()){
|
||||
schematics.add(new Schematic(schematic));
|
||||
@ -126,7 +106,7 @@ public class Schematic {
|
||||
|
||||
public static List<Schematic> getAllSchemsOfType(SchematicType schemType){
|
||||
try{
|
||||
ResultSet schematic = SQL.select("SELECT * FROM Schematic WHERE SchemType = '" + schemType.toDB() + "'");
|
||||
ResultSet schematic = SQL.select("SELECT SchemID, SchemName, SchemOwner, Item, SchemType, SchemFormat FROM Schematic WHERE SchemType = '" + schemType.toDB() + "'");
|
||||
List<Schematic> schematics = new ArrayList<>();
|
||||
while(schematic.next()){
|
||||
schematics.add(new Schematic(schematic));
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren