SteamWar/SpigotCore
Archiviert
13
0

Removing SQLException

Dieser Commit ist enthalten in:
Lixfel 2019-12-05 11:03:24 +01:00
Ursprung 00898f996a
Commit 59ba4f4e68

Datei anzeigen

@ -147,69 +147,81 @@ public class Schematic {
updateDB();
}
public Clipboard load() throws WrongVersionException, SQLException, IOException, NoClipboardException {
public Clipboard load() throws WrongVersionException, IOException, NoClipboardException {
if(Core.getVersion() <= 12 && schemFormat)
throw new WrongVersionException();
ResultSet rs = SQL.select("SELECT SchemData FROM Schematic WHERE SchemID = " + schemID);
rs.next();
InputStream is = rs.getBlob("SchemData").getBinaryStream();
switch(Core.getVersion()){
case 8:
return Schematic_8.getClipboard(is);
case 14:
return Schematic_14.getClipboard(is, schemFormat);
default:
return Schematic_12.getClipboard(is);
try {
rs.next();
InputStream is = rs.getBlob("SchemData").getBinaryStream();
switch(Core.getVersion()){
case 8:
return Schematic_8.getClipboard(is);
case 14:
return Schematic_14.getClipboard(is, schemFormat);
default:
return Schematic_12.getClipboard(is);
}
} catch (SQLException e) {
throw new IOException(e);
}
}
public void loadToPlayer(Player player) throws SQLException, IOException, NoClipboardException, WrongVersionException {
public void loadToPlayer(Player player) throws IOException, NoClipboardException, WrongVersionException {
if(Core.getVersion() <= 12 && schemFormat)
throw new WrongVersionException();
ResultSet rs = SQL.select("SELECT SchemData FROM Schematic WHERE SchemID = " + schemID);
rs.next();
InputStream is = rs.getBlob("SchemData").getBinaryStream();
switch(Core.getVersion()){
case 8:
Schematic_8.setPlayerClipboard(player, is);
break;
case 14:
Schematic_14.setPlayerClipboard(player, is, schemFormat);
break;
default:
Schematic_12.setPlayerClipboard(player, is);
try {
rs.next();
InputStream is = rs.getBlob("SchemData").getBinaryStream();
switch(Core.getVersion()){
case 8:
Schematic_8.setPlayerClipboard(player, is);
break;
case 14:
Schematic_14.setPlayerClipboard(player, is, schemFormat);
break;
default:
Schematic_12.setPlayerClipboard(player, is);
}
} catch (SQLException e) {
throw new IOException(e);
}
}
public void saveOldFormatFromPlayer(Player player) throws SQLException, IOException, NoClipboardException {
public void saveOldFormatFromPlayer(Player player) throws IOException, NoClipboardException {
saveFromPlayer(player, false);
}
public void saveFromPlayer(Player player) throws SQLException, IOException, NoClipboardException {
public void saveFromPlayer(Player player) throws IOException, NoClipboardException {
saveFromPlayer(player, true);
}
private void saveFromPlayer(Player player, boolean newFormat) throws SQLException, IOException, NoClipboardException {
PreparedStatement st = SQL.getCon().prepareStatement("UPDATE Schematic SET SchemData = ?, SchemFormat = ? WHERE SchemID = " + schemID);
byte[] data;
switch(Core.getVersion()){
case 8:
newFormat = false;
data = Schematic_8.getPlayerClipboard(player);
break;
case 14:
data = Schematic_14.getPlayerClipboard(player, newFormat);
break;
default:
newFormat = false;
data = Schematic_12.getPlayerClipboard(player);
private void saveFromPlayer(Player player, boolean newFormat) throws IOException, NoClipboardException {
try{
PreparedStatement st = SQL.getCon().prepareStatement("UPDATE Schematic SET SchemData = ?, SchemFormat = ? WHERE SchemID = " + schemID);
byte[] data;
switch(Core.getVersion()){
case 8:
newFormat = false;
data = Schematic_8.getPlayerClipboard(player);
break;
case 14:
data = Schematic_14.getPlayerClipboard(player, newFormat);
break;
default:
newFormat = false;
data = Schematic_12.getPlayerClipboard(player);
}
st.setBlob(1, new ByteArrayInputStream(data));
st.setBoolean(2, newFormat);
st.executeUpdate();
schemFormat = newFormat;
}catch(SQLException e){
throw new IOException(e);
}
st.setBlob(1, new ByteArrayInputStream(data));
st.setBoolean(2, newFormat);
st.executeUpdate();
schemFormat = newFormat;
}
public void remove(){