Skip to content

Commit

Permalink
Merge branch 'master' into this-is-not-the-world-you-are-looking-for
Browse files Browse the repository at this point in the history
  • Loading branch information
PeachesMLG authored Jan 2, 2025
2 parents b986d99 + 277fb74 commit e71292f
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 15 deletions.
4 changes: 2 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ plugins {
}

group = "com.iridium"
version = "4.1.0"
version = "4.1.0-B5.2"
description = "Skyblock Redefined"

repositories {
Expand All @@ -26,7 +26,7 @@ dependencies {
implementation("org.jetbrains:annotations:26.0.1")
implementation("com.j256.ormlite:ormlite-core:6.1")
implementation("com.j256.ormlite:ormlite-jdbc:6.1")
implementation("com.iridium:IridiumTeams:2.5.9.8")
implementation("com.iridium:IridiumTeams:2.5.12")
implementation("commons-lang:commons-lang:2.6")

// Other dependencies that are not required or already available at runtime
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,6 @@ 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
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public void save() {
} finally {
lock.unlock();
}
} catch (InterruptedException | SQLException e) {
} catch (Exception e) {
e.printStackTrace();
}
}
Expand All @@ -77,7 +77,7 @@ public void save(Value value) {
} finally {
lock.unlock();
}
} catch (InterruptedException | SQLException e) {
} catch (Exception e) {
e.printStackTrace();
}
}
Expand All @@ -95,7 +95,7 @@ public CompletableFuture<Void> delete(Value value) {
} finally {
lock.unlock();
}
} catch (InterruptedException | SQLException e) {
} catch (Exception e) {
e.printStackTrace();
}
});
Expand All @@ -114,14 +114,33 @@ public CompletableFuture<Void> delete(Collection<Value> values) {
} finally {
lock.unlock();
}
} catch (InterruptedException | SQLException e) {
} catch (Exception e) {
e.printStackTrace();
}
});
}

public void addEntry(Value value) {
entries.put(databaseKey.getKey(value), value);
try {
entries.put(databaseKey.getKey(value), value);
}catch (Exception e) {
IridiumSkyblock.getInstance().getLogger().warning("Warning: Deleting "+value.getClass().getName()+" record because "+e.getMessage());
CompletableFuture.runAsync(() -> {
try {
if (!lock.tryLock(5, TimeUnit.SECONDS)) {
IridiumSkyblock.getInstance().getLogger().warning("Warning: Lock acquisition took more than 5 second in delete(value) method.");
}
try {
dao.delete(value);
dao.commit(getDatabaseConnection());
} finally {
lock.unlock();
}
} catch (Exception ex1) {
ex1.printStackTrace();
}
});
}
}

public List<Value> getEntries(Function<? super Value, Boolean> searchFunction) {
Expand Down

0 comments on commit e71292f

Please sign in to comment.