Removing SQLException
Dieser Commit ist enthalten in:
Ursprung
bd6b5f48c3
Commit
602a4d1098
@ -147,69 +147,81 @@ public class Schematic {
|
|||||||
updateDB();
|
updateDB();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Clipboard load() throws WrongVersionException, SQLException, IOException, NoClipboardException {
|
public Clipboard load() throws WrongVersionException, IOException, NoClipboardException {
|
||||||
if(Core.getVersion() <= 12 && schemFormat)
|
if(Core.getVersion() <= 12 && schemFormat)
|
||||||
throw new WrongVersionException();
|
throw new WrongVersionException();
|
||||||
|
|
||||||
ResultSet rs = SQL.select("SELECT SchemData FROM Schematic WHERE SchemID = " + schemID);
|
ResultSet rs = SQL.select("SELECT SchemData FROM Schematic WHERE SchemID = " + schemID);
|
||||||
rs.next();
|
try {
|
||||||
InputStream is = rs.getBlob("SchemData").getBinaryStream();
|
rs.next();
|
||||||
switch(Core.getVersion()){
|
InputStream is = rs.getBlob("SchemData").getBinaryStream();
|
||||||
case 8:
|
switch(Core.getVersion()){
|
||||||
return Schematic_8.getClipboard(is);
|
case 8:
|
||||||
case 14:
|
return Schematic_8.getClipboard(is);
|
||||||
return Schematic_14.getClipboard(is, schemFormat);
|
case 14:
|
||||||
default:
|
return Schematic_14.getClipboard(is, schemFormat);
|
||||||
return Schematic_12.getClipboard(is);
|
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)
|
if(Core.getVersion() <= 12 && schemFormat)
|
||||||
throw new WrongVersionException();
|
throw new WrongVersionException();
|
||||||
|
|
||||||
ResultSet rs = SQL.select("SELECT SchemData FROM Schematic WHERE SchemID = " + schemID);
|
ResultSet rs = SQL.select("SELECT SchemData FROM Schematic WHERE SchemID = " + schemID);
|
||||||
rs.next();
|
try {
|
||||||
InputStream is = rs.getBlob("SchemData").getBinaryStream();
|
rs.next();
|
||||||
switch(Core.getVersion()){
|
InputStream is = rs.getBlob("SchemData").getBinaryStream();
|
||||||
case 8:
|
switch(Core.getVersion()){
|
||||||
Schematic_8.setPlayerClipboard(player, is);
|
case 8:
|
||||||
break;
|
Schematic_8.setPlayerClipboard(player, is);
|
||||||
case 14:
|
break;
|
||||||
Schematic_14.setPlayerClipboard(player, is, schemFormat);
|
case 14:
|
||||||
break;
|
Schematic_14.setPlayerClipboard(player, is, schemFormat);
|
||||||
default:
|
break;
|
||||||
Schematic_12.setPlayerClipboard(player, is);
|
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);
|
saveFromPlayer(player, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void saveFromPlayer(Player player) throws SQLException, IOException, NoClipboardException {
|
public void saveFromPlayer(Player player) throws IOException, NoClipboardException {
|
||||||
saveFromPlayer(player, true);
|
saveFromPlayer(player, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void saveFromPlayer(Player player, boolean newFormat) throws SQLException, IOException, NoClipboardException {
|
private void saveFromPlayer(Player player, boolean newFormat) throws IOException, NoClipboardException {
|
||||||
PreparedStatement st = SQL.getCon().prepareStatement("UPDATE Schematic SET SchemData = ?, SchemFormat = ? WHERE SchemID = " + schemID);
|
try{
|
||||||
byte[] data;
|
PreparedStatement st = SQL.getCon().prepareStatement("UPDATE Schematic SET SchemData = ?, SchemFormat = ? WHERE SchemID = " + schemID);
|
||||||
switch(Core.getVersion()){
|
byte[] data;
|
||||||
case 8:
|
switch(Core.getVersion()){
|
||||||
newFormat = false;
|
case 8:
|
||||||
data = Schematic_8.getPlayerClipboard(player);
|
newFormat = false;
|
||||||
break;
|
data = Schematic_8.getPlayerClipboard(player);
|
||||||
case 14:
|
break;
|
||||||
data = Schematic_14.getPlayerClipboard(player, newFormat);
|
case 14:
|
||||||
break;
|
data = Schematic_14.getPlayerClipboard(player, newFormat);
|
||||||
default:
|
break;
|
||||||
newFormat = false;
|
default:
|
||||||
data = Schematic_12.getPlayerClipboard(player);
|
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(){
|
public void remove(){
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren