Skip to content

Commit

Permalink
Added new serializers, cleared null entries (#869)
Browse files Browse the repository at this point in the history
* Added new serializers, cleared null entries

- added XBiome, XEnchantment, XPotion, and XEntityType serializers to the database
- once the tables are registered, we loop through the entries to remove bad (null) entries

* Update DatabaseManager.java

---------

Co-authored-by: Daniel Scherf <[email protected]>
Co-authored-by: Peaches_MLG <[email protected]>
  • Loading branch information
3 people authored Dec 28, 2024
1 parent 173e5cc commit 645852a
Showing 1 changed file with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

import java.io.File;
import java.sql.SQLException;
import java.util.Comparator;
import java.util.List;
import java.util.concurrent.CompletableFuture;

@Getter
Expand Down Expand Up @@ -50,6 +52,11 @@ public void init() throws SQLException {
String databaseURL = getDatabaseURL(sqlConfig);

DataPersisterManager.registerDataPersisters(XMaterialType.getSingleton());
DataPersisterManager.registerDataPersisters(XEntityTypeType.getSingleton());
DataPersisterManager.registerDataPersisters(XPotionType.getSingleton());
DataPersisterManager.registerDataPersisters(XEnchantmentType.getSingleton());
DataPersisterManager.registerDataPersisters(XBiomeType.getSingleton());

DataPersisterManager.registerDataPersisters(LocationType.getSingleton());
DataPersisterManager.registerDataPersisters(InventoryType.getSingleton());
DataPersisterManager.registerDataPersisters(LocalDateTimeType.getSingleton());
Expand Down Expand Up @@ -77,6 +84,14 @@ public void init() throws SQLException {
this.teamMissionTableManager = new ForeignIslandTableManager<>(teamMission -> getDatabaseKey(teamMission.getTeamID(), teamMission.getMissionName()), connectionSource, TeamMission.class);
this.teamRewardsTableManager = new ForeignIslandTableManager<>(teamRewards -> getDatabaseKey(teamRewards.getId()), connectionSource, TeamReward.class);
this.teamSettingsTableManager = new ForeignIslandTableManager<>(teamSetting -> getDatabaseKey(teamSetting.getTeamID(), teamSetting.getSetting()), connectionSource, TeamSetting.class);

// We need to clear out null values
for(TeamBlock teamBlock : teamBlockTableManager.getEntries()) {
if(teamBlock.getXMaterial() == null) teamBlockTableManager.delete(teamBlock);
}
for(TeamSpawners teamSpawners : teamSpawnerTableManager.getEntries()) {
if(teamSpawners.getEntityType() == null) teamSpawnerTableManager.delete(teamSpawners);
}
}

private String getDatabaseKey(Object... params) {
Expand Down

0 comments on commit 645852a

Please sign in to comment.