use of com.alpsbte.plotsystem.core.system.CityProject in project Plot-System by AlpsBTE.
the class CompanionMenu method setCityProjectItems.
/**
* Sets city project items asynchronously in the menu
* @throws SQLException When querying database
*/
private void setCityProjectItems() throws SQLException {
for (int i = 0; i < cityProjects.size(); i++) {
if (i <= 28) {
CityProject cp = cityProjects.get(i);
ItemStack cpItem = cp.getCountry().getHead();
try {
PlotDifficulty cpPlotDifficulty = selectedPlotDifficulty != null ? selectedPlotDifficulty : PlotManager.getPlotDifficultyForBuilder(cp.getID(), new Builder(getMenuPlayer().getUniqueId())).get();
int plotsOpen = PlotManager.getPlots(cp.getID(), Status.unclaimed).size();
int plotsInProgress = PlotManager.getPlots(cp.getID(), Status.unfinished, Status.unreviewed).size();
int plotsCompleted = PlotManager.getPlots(cp.getID(), Status.completed).size();
int plotsUnclaimed = PlotManager.getPlots(cp.getID(), cpPlotDifficulty, Status.unclaimed).size();
getMenu().getSlot(9 + cityProjects.indexOf(cp)).setItem(new ItemBuilder(cpItem).setName("§b§l" + cp.getName()).setLore(new LoreBuilder().addLines(cp.getDescription(), "", "§6" + plotsOpen + " §7" + LangUtil.get(getMenuPlayer(), LangPaths.CityProject.PROJECT_OPEN), "§8---------------------", "§6" + plotsInProgress + " §7" + LangUtil.get(getMenuPlayer(), LangPaths.CityProject.PROJECT_IN_PROGRESS), "§6" + plotsCompleted + " §7" + LangUtil.get(getMenuPlayer(), LangPaths.CityProject.PROJECT_COMPLETED), "", plotsUnclaimed != 0 ? Utils.getFormattedDifficulty(cpPlotDifficulty) : "§f§l" + LangUtil.get(getMenuPlayer(), LangPaths.CityProject.PROJECT_NO_PLOTS)).build()).build());
} catch (SQLException | ExecutionException | InterruptedException ex) {
Bukkit.getLogger().log(Level.SEVERE, "A SQL error occurred!", ex);
getMenu().getSlot(9 + cityProjects.indexOf(cp)).setItem(MenuItems.errorItem(getMenuPlayer()));
}
}
}
}
use of com.alpsbte.plotsystem.core.system.CityProject in project Plot-System by AlpsBTE.
the class Plot method getCity.
@Override
public CityProject getCity() throws SQLException {
try (ResultSet rs = DatabaseConnection.createStatement("SELECT city_project_id FROM plotsystem_plots WHERE id = ?").setValue(this.ID).executeQuery()) {
if (rs.next()) {
int i = rs.getInt(1);
DatabaseConnection.closeResultSet(rs);
return new CityProject(i);
}
DatabaseConnection.closeResultSet(rs);
return null;
}
}
Aggregations