Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import java.util.NavigableMap;
import java.util.TreeMap;
import java.util.concurrent.CompletableFuture;
import java.util.logging.Level;

public class MySQLPlayerMapper extends AbstractMapper implements IPlayerMapper {
private static MySQLPlayerMapper instance;
Expand All @@ -27,7 +28,7 @@ public static MySQLPlayerMapper getInstance() {
@Override
public void insertPlayerDataAsync(PlayerData playerData) {
CompletableFuture.runAsync(() -> this.updatePlayerData(playerData)).exceptionally(ex -> {
ex.printStackTrace();
this.plugin.getLogger().log(Level.SEVERE, String.format("Could not insert PlayerData for %s.", playerData.getPlayer().getName()), ex);
return null;
});
}
Expand Down Expand Up @@ -92,7 +93,7 @@ public void updatePlayerData(PlayerData playerData) {
this.updatePlayerDataSync(playerData);
} else {
CompletableFuture.runAsync(() -> this.updatePlayerDataSync(playerData)).exceptionally(ex -> {
ex.printStackTrace();
this.plugin.getLogger().log(Level.SEVERE, String.format("Could not update PlayerData for %s asynchronously.", playerData.getPlayer().getName()), ex);
return null;
});
}
Expand Down Expand Up @@ -134,7 +135,7 @@ private void updatePlayerDataSync(PlayerData playerData) {
preparedStatement.setLong(19, playerData.getTimeTillNextMaxHealth());
preparedStatement.execute();
} catch (SQLException e) {
e.printStackTrace();
this.plugin.getLogger().log(Level.SEVERE, String.format("Could not update PlayerData for %s.", playerData.getPlayer().getName()), e);
}
}

Expand All @@ -148,10 +149,10 @@ public void deletePlayerData(OfflinePlayer player) {
preparedStatement.setString(1, player.getUniqueId().toString());
preparedStatement.execute();
} catch (SQLException e) {
e.printStackTrace();
this.plugin.getLogger().log(Level.SEVERE, String.format("Could not delete PlayerData for %s.", player.getName()), e);
}
}).exceptionally(ex -> {
ex.printStackTrace();
this.plugin.getLogger().log(Level.SEVERE, String.format("Could not delete PlayerData for %s asynchronously.", player.getName()), ex);
return null;
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ private void insertPlayerData(PlayerData data) {
@Override
public void insertPlayerDataAsync(PlayerData data) {
CompletableFuture.runAsync(() -> this.insertPlayerData(data)).exceptionally(ex -> {
ex.printStackTrace();
this.plugin.getLogger().log(Level.SEVERE, String.format("Could not insert PlayerData for %s.", data.getPlayer().getName()), ex);
return null;
});
}
Expand Down Expand Up @@ -73,7 +73,7 @@ public void deletePlayerData(OfflinePlayer player) {
file.delete();
}
}).exceptionally(ex -> {
ex.printStackTrace();
this.plugin.getLogger().log(Level.SEVERE, String.format("Could not delete PlayerData for %s.", player.getName()), ex);
return null;
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
import java.util.logging.Level;
import java.util.concurrent.ConcurrentHashMap;

public class PlayerRepository {
Expand Down Expand Up @@ -52,7 +53,7 @@ public CompletableFuture<PlayerData> getByPlayer(OfflinePlayer player) {
return this.mapper.getByPlayer(player).thenApplyAsync(playerData -> this.getFromDataAndCache(player, playerData));
} else {
return CompletableFuture.supplyAsync(() -> player).thenApplyAsync(this::getFromCache).exceptionally(ex -> {
ex.printStackTrace();
this.plugin.getLogger().log(Level.SEVERE, String.format("Failed to retrieve PlayerData for %s from cache.", player.getName()), ex);
return null;
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public ServerRepository() {
this.plugin = JavaPlugin.getPlugin(AugmentedHardcore.class);
this.initializeMapper();
this.getServerData(this.plugin.getServer()).thenAcceptAsync(serverData -> this.plugin.getLogger().log(Level.INFO, String.format("Loaded %d ongoing death %s.", serverData.getTotalOngoingBans(), serverData.getTotalOngoingBans() != 1 ? "bans" : "ban"))).exceptionally(e -> {
e.printStackTrace();
this.plugin.getLogger().log(Level.SEVERE, "Could not load server data asynchronously.", e);
return null;
});
}
Expand Down