Skip to content

Commit

Permalink
improve visibility of open plots when selecting plot difficulty in co…
Browse files Browse the repository at this point in the history
…mpanion menu
  • Loading branch information
LordTuxn committed Aug 20, 2022
1 parent b2e7be6 commit bc21f84
Show file tree
Hide file tree
Showing 10 changed files with 20 additions and 3 deletions.
13 changes: 11 additions & 2 deletions src/main/java/com/alpsbte/plotsystem/core/system/CityProject.java
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,15 @@ public ItemStack getItem(Player player, PlotDifficulty selectedPlotDifficulty) t
int plotsOpen = PlotManager.getPlots(getID(), Status.unclaimed).size();
int plotsInProgress = PlotManager.getPlots(getID(), Status.unfinished, Status.unreviewed).size();
int plotsCompleted = PlotManager.getPlots(getID(), Status.completed).size();
int plotsUnclaimed = PlotManager.getPlots(getID(), cpPlotDifficulty, Status.unclaimed).size();
int plotsUnclaimed = cpPlotDifficulty != null ? PlotManager.getPlots(getID(), cpPlotDifficulty, Status.unclaimed).size() : 0;
int plotsOpenForPlayer = cpPlotDifficulty != null && plotsUnclaimed != 0 ? getOpenPlotsForPlayer(getID(), cpPlotDifficulty) : 0;

return new ItemBuilder(cpItem)
.setName("§b§l" + getName())
.setLore(new LoreBuilder()
.addLines(getDescription(),
"",
"§6" + plotsOpen + " §7" + LangUtil.get(player, LangPaths.CityProject.PROJECT_OPEN),
"§6" + plotsOpen + " §7" + LangUtil.get(player, LangPaths.CityProject.PROJECT_OPEN) + " §8" + LangUtil.get(player, LangPaths.CityProject.FOR_YOUR_DIFFICULTY, (plotsOpenForPlayer == 0 ? "§c" : "§a") + plotsOpenForPlayer + "§8"),
"§8---------------------",
"§6" + plotsInProgress + " §7" + LangUtil.get(player, LangPaths.CityProject.PROJECT_IN_PROGRESS),
"§6" + plotsCompleted + " §7" + LangUtil.get(player, LangPaths.CityProject.PROJECT_COMPLETED),
Expand Down Expand Up @@ -146,6 +147,14 @@ public static List<CityProject> getCityProjects(Country country, boolean onlyVis
return new ArrayList<>();
}

private int getOpenPlotsForPlayer(int plotID, PlotDifficulty plotDifficulty) throws SQLException {
int openPlots = 0;
for (PlotDifficulty pd : PlotDifficulty.values()) {
if (pd.ordinal() <= plotDifficulty.ordinal()) openPlots += PlotManager.getPlots(plotID, pd, Status.unclaimed).size();
}
return openPlots;
}


public static List<CityProject> getCityProjects(boolean onlyVisible) {
return getCityProjects(null, onlyVisible);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@ public static CompletableFuture<PlotDifficulty> getPlotDifficultyForBuilder(int
return CompletableFuture.completedFuture(PlotDifficulty.MEDIUM);
}
}
return CompletableFuture.completedFuture(PlotDifficulty.HARD); // If nothing is available return hard (plot availability will be checked later additionally)
return CompletableFuture.completedFuture(null); // If nothing is available return null
}

public static boolean isPlotWorld(World world) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public static final class CityProject {
public static final String PROJECT_COMPLETED = CITY_PROJECT + "completed";
public static final String PROJECT_PLOTS_AVAILABLE = CITY_PROJECT + "plots-available";
public static final String PROJECT_NO_PLOTS_AVAILABLE = CITY_PROJECT + "no-plots-available";
public static final String FOR_YOUR_DIFFICULTY = CITY_PROJECT + "for-your-difficulty";
}

public static final class Country {
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/lang/de_DE.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ city-project:
completed: "Abgeschlossene Plots"
plots-available: 'Plots Verfügbar'
no-plots-available: "Keine Plots Verfügbar"
for-your-difficulty: "({0} für deinen Schwierigkeitsgrad)"

# -----------------------------------------------------
# | Countries
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/lang/en_GB.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ city-project:
completed: "Plots Completed"
plots-available: 'Plots Available'
no-plots-available: "No Plots Available"
for-your-difficulty: "({0} for your difficulty)"

# -----------------------------------------------------
# | Countries
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/lang/fr_FR.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ city-project:
completed: 'Plots Complété'
plots-available: 'Plots Available'
no-plots-available: 'Aucun Plots Disponibles'
for-your-difficulty: "({0} for your difficulty)"

# -----------------------------------------------------
# | Countries
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/lang/ko_KR.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ city-project:
completed: "개의 완성된 플롯"
plots-available: 'Plots Available'
no-plots-available: "건축할 수 있는 플롯이 없음"
for-your-difficulty: "({0} for your difficulty)"

# -----------------------------------------------------
# | Countries
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/lang/ru_RU.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ city-project:
completed: "Завершённых Участков"
plots-available: 'Plots Available'
no-plots-available: "Доступных Участков Нет"
for-your-difficulty: "({0} for your difficulty)"

# -----------------------------------------------------
# | Countries
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/lang/zh_CN.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ city-project:
completed: "已完成建地"
plots-available: 'Plots Available'
no-plots-available: "无可用建地"
for-your-difficulty: "({0} for your difficulty)"

# -----------------------------------------------------
# | Countries
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/lang/zh_TW.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ city-project:
completed: "已完成建地"
plots-available: 'Plots Available'
no-plots-available: "無可用建地"
for-your-difficulty: "({0} for your difficulty)"

# -----------------------------------------------------
# | Countries
Expand Down

0 comments on commit bc21f84

Please sign in to comment.