mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-12-15 05:41:51 +08:00
Fixed unique constraint issue #548, added 1.13 protocol
This commit is contained in:
parent
1c6c647aec
commit
0b5805a39f
@ -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:
|
||||
|
@ -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 (?, ?)";
|
||||
|
Loading…
Reference in New Issue
Block a user