Fixed unique constraint issue #548, added 1.13 protocol

This commit is contained in:
Rsl1122 2018-07-16 18:03:51 +03:00
parent 1c6c647aec
commit 0b5805a39f
2 changed files with 7 additions and 28 deletions

View File

@ -25,6 +25,11 @@ public class Protocol {
*/
public static String getMCVersion(int protocolVersion) {
switch (protocolVersion) {
case 390:
case 391:
case 392:
case 393:
return "1.13";
case 340:
return "1.12.2";
case 338:

View File

@ -46,14 +46,6 @@ public class ProtocolTable extends Table {
);
}
public void saveProtocolVersion(UUID uuid, int version) {
if (exists(uuid)) {
updateProtocolVersion(uuid, version);
} else {
insertProtocolVersion(uuid, version);
}
}
public int getProtocolVersion(UUID uuid) {
String sql = "SELECT " + columnProtocolVersion + " FROM " + tableName + " WHERE " + columnUUID + "=?";
@ -89,26 +81,8 @@ public class ProtocolTable extends Table {
});
}
private boolean exists(UUID uuid) {
return getProtocolVersion(uuid) != -1;
}
private void updateProtocolVersion(UUID uuid, int version) {
String sql = "UPDATE " + tableName + " SET "
+ columnProtocolVersion + "=? "
+ " WHERE (" + columnUUID + "=?)";
execute(new ExecStatement(sql) {
@Override
public void prepare(PreparedStatement statement) throws SQLException {
statement.setInt(1, version);
statement.setString(2, uuid.toString());
}
});
}
private void insertProtocolVersion(UUID uuid, int version) {
String sql = "INSERT INTO " + tableName + " ("
public void saveProtocolVersion(UUID uuid, int version) {
String sql = "REPLACE INTO " + tableName + " ("
+ columnUUID + ", "
+ columnProtocolVersion
+ ") VALUES (?, ?)";