Merge pull request #2 from HexedHero/fix-npe

Move null check into statement like other methods
This commit is contained in:
Christian Koop 2022-06-28 16:52:54 +02:00 committed by GitHub
commit 300b12502a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -57,7 +57,6 @@ public class DataManager extends DataManagerAbstract {
})); }));
} }
public void createSpawner(SpawnerStack spawnerStack) { public void createSpawner(SpawnerStack spawnerStack) {
this.queueAsync(() -> this.databaseConnector.connect(connection -> { this.queueAsync(() -> this.databaseConnector.connect(connection -> {
@ -88,7 +87,6 @@ public class DataManager extends DataManagerAbstract {
})); }));
} }
public void createBlock(BlockStack blockStack) { public void createBlock(BlockStack blockStack) {
this.queueAsync(() -> this.databaseConnector.connect(connection -> { this.queueAsync(() -> this.databaseConnector.connect(connection -> {
@ -108,12 +106,11 @@ public class DataManager extends DataManagerAbstract {
}), "create"); }), "create");
} }
public void createHostEntity(ColdEntityStack stack) { public void createHostEntity(ColdEntityStack stack) {
this.queueAsync(() -> this.databaseConnector.connect(connection -> { this.queueAsync(() -> this.databaseConnector.connect(connection -> {
if (stack == null || stack.getHostUniqueId() == null) return;
String createSerializedEntity = "INSERT INTO " + this.getTablePrefix() + "host_entities (uuid, create_duplicates) VALUES (?, ?)"; String createSerializedEntity = "INSERT INTO " + this.getTablePrefix() + "host_entities (uuid, create_duplicates) VALUES (?, ?)";
try (PreparedStatement statement = connection.prepareStatement(createSerializedEntity)) { try (PreparedStatement statement = connection.prepareStatement(createSerializedEntity)) {
if (stack == null || stack.getHostUniqueId() == null) return;
statement.setString(1, stack.getHostUniqueId().toString()); statement.setString(1, stack.getHostUniqueId().toString());
statement.setInt(2, stack.getCreateDuplicates()); statement.setInt(2, stack.getCreateDuplicates());
statement.executeUpdate(); statement.executeUpdate();