Skip to content

Commit

Permalink
Added boolean placeholder for default "Yes" and "No"
Browse files Browse the repository at this point in the history
  • Loading branch information
OmerBenGera committed Apr 16, 2022
1 parent b9b4f56 commit 1ddeded
Show file tree
Hide file tree
Showing 13 changed files with 62 additions and 15 deletions.
@@ -1,6 +1,7 @@
package com.bgsoftware.superiorskyblock.formatting;

import com.bgsoftware.superiorskyblock.api.enums.BorderColor;
import com.bgsoftware.superiorskyblock.formatting.impl.BooleanFormatter;
import com.bgsoftware.superiorskyblock.formatting.impl.BorderColorFormatter;
import com.bgsoftware.superiorskyblock.formatting.impl.CapitalizedFormatter;
import com.bgsoftware.superiorskyblock.formatting.impl.ColorFormatter;
Expand All @@ -22,6 +23,7 @@

public final class Formatters {

public static final ILocaleFormatter<Boolean> BOOLEAN_FORMATTER = BooleanFormatter.getInstance();
public static final ILocaleFormatter<BorderColor> BORDER_COLOR_FORMATTER = BorderColorFormatter.getInstance();
public static final IFormatter<String> CAPITALIZED_FORMATTER = CapitalizedFormatter.getInstance();
public static final IFormatter<String> COLOR_FORMATTER = ColorFormatter.getInstance();
Expand Down
@@ -0,0 +1,25 @@
package com.bgsoftware.superiorskyblock.formatting.impl;

import com.bgsoftware.superiorskyblock.formatting.ILocaleFormatter;
import com.bgsoftware.superiorskyblock.lang.Message;

import java.util.Locale;

public final class BooleanFormatter implements ILocaleFormatter<Boolean> {

private static final BooleanFormatter INSTANCE = new BooleanFormatter();

public static BooleanFormatter getInstance() {
return INSTANCE;
}

private BooleanFormatter() {

}

@Override
public String format(Boolean value, Locale locale) {
return (value ? Message.PLACEHOLDER_YES : Message.PLACEHOLDER_NO).getMessage(locale);
}

}
Expand Up @@ -565,6 +565,8 @@ public enum Message {
PERMISSION_CHANGED,
PERMISSION_CHANGED_ALL,
PERMISSION_CHANGED_NAME,
PLACEHOLDER_NO,
PLACEHOLDER_YES,
PLAYER_ALREADY_BANNED,
PLAYER_ALREADY_COOP,
PLAYER_ALREADY_IN_ISLAND,
Expand Down
Expand Up @@ -67,15 +67,15 @@ public final class PlaceholdersServiceImpl implements PlaceholdersService {
.put("texture", SuperiorPlayer::getTextureValue)
.put("role", superiorPlayer -> superiorPlayer.getPlayerRole().toString())
.put("locale", superiorPlayer -> Formatters.LOCALE_FORMATTER.format(superiorPlayer.getUserLocale()))
.put("world_border", superiorPlayer -> superiorPlayer.hasWorldBorderEnabled() ? "Yes" : "No")
.put("blocks_stacker", superiorPlayer -> superiorPlayer.hasBlocksStackerEnabled() ? "Yes" : "No")
.put("schematics", superiorPlayer -> superiorPlayer.hasSchematicModeEnabled() ? "Yes" : "No")
.put("team_chat", superiorPlayer -> superiorPlayer.hasTeamChatEnabled() ? "Yes" : "No")
.put("bypass", superiorPlayer -> superiorPlayer.hasBypassModeEnabled() ? "Yes" : "No")
.put("world_border", superiorPlayer -> Formatters.BOOLEAN_FORMATTER.format(superiorPlayer.hasWorldBorderEnabled(), superiorPlayer.getUserLocale()))
.put("blocks_stacker", superiorPlayer -> Formatters.BOOLEAN_FORMATTER.format(superiorPlayer.hasBlocksStackerEnabled(), superiorPlayer.getUserLocale()))
.put("schematics", superiorPlayer -> Formatters.BOOLEAN_FORMATTER.format(superiorPlayer.hasSchematicModeEnabled(), superiorPlayer.getUserLocale()))
.put("team_chat", superiorPlayer -> Formatters.BOOLEAN_FORMATTER.format(superiorPlayer.hasTeamChatEnabled(), superiorPlayer.getUserLocale()))
.put("bypass", superiorPlayer -> Formatters.BOOLEAN_FORMATTER.format(superiorPlayer.hasBypassModeEnabled(), superiorPlayer.getUserLocale()))
.put("disbands", superiorPlayer -> superiorPlayer.getDisbands() + "")
.put("panel", superiorPlayer -> superiorPlayer.hasToggledPanel() ? "Yes" : "No")
.put("fly", superiorPlayer -> superiorPlayer.hasIslandFlyEnabled() ? "Yes" : "No")
.put("chat_spy", superiorPlayer -> superiorPlayer.hasAdminSpyEnabled() ? "Yes" : "No")
.put("panel", superiorPlayer -> Formatters.BOOLEAN_FORMATTER.format(superiorPlayer.hasToggledPanel(), superiorPlayer.getUserLocale()))
.put("fly", superiorPlayer -> Formatters.BOOLEAN_FORMATTER.format(superiorPlayer.hasIslandFlyEnabled(), superiorPlayer.getUserLocale()))
.put("chat_spy", superiorPlayer -> Formatters.BOOLEAN_FORMATTER.format(superiorPlayer.hasAdminSpyEnabled(), superiorPlayer.getUserLocale()))
.put("border_color", superiorPlayer ->
Formatters.BORDER_COLOR_FORMATTER.format(superiorPlayer.getBorderColor(), superiorPlayer.getUserLocale()))
.put("missions_completed", superiorPlayer -> superiorPlayer.getCompletedMissions().size() + "")
Expand Down Expand Up @@ -142,8 +142,8 @@ public final class PlaceholdersServiceImpl implements PlaceholdersService {
island.hasPermission(superiorPlayer, IslandPrivileges.PAYPAL_SHOW) ? island.getPaypal() : "None")
.put("discord_all", (island, superiorPlayer) -> island.getDiscord())
.put("paypal_all", (island, superiorPlayer) -> island.getPaypal())
.put("exists", (island, superiorPlayer) -> "Yes")
.put("locked", (island, superiorPlayer) -> island.isLocked() ? "Yes" : "No")
.put("exists", (island, superiorPlayer) -> Formatters.BOOLEAN_FORMATTER.format(true, superiorPlayer.getUserLocale()))
.put("locked", (island, superiorPlayer) -> Formatters.BOOLEAN_FORMATTER.format(island.isLocked(), superiorPlayer.getUserLocale()))
.put("name", (island, superiorPlayer) -> {
return plugin.getSettings().getIslandNames().isColorSupport() ?
Formatters.COLOR_FORMATTER.format(island.getName()) : island.getName();
Expand All @@ -154,9 +154,9 @@ public final class PlaceholdersServiceImpl implements PlaceholdersService {
Formatters.COLOR_FORMATTER.format(island.getName()) : island.getName();
})
.put("is_leader", (island, superiorPlayer) ->
island.getOwner().equals(superiorPlayer) ? "Yes" : "No")
.put("is_member", (island, superiorPlayer) -> island.isMember(superiorPlayer) ? "Yes" : "No")
.put("is_coop", (island, superiorPlayer) -> island.isCoop(superiorPlayer) ? "Yes" : "No")
Formatters.BOOLEAN_FORMATTER.format(island.getOwner().equals(superiorPlayer), superiorPlayer.getUserLocale()))
.put("is_member", (island, superiorPlayer) -> Formatters.BOOLEAN_FORMATTER.format(island.isMember(superiorPlayer), superiorPlayer.getUserLocale()))
.put("is_coop", (island, superiorPlayer) -> Formatters.BOOLEAN_FORMATTER.format(island.isCoop(superiorPlayer), superiorPlayer.getUserLocale()))
.put("rating", (island, superiorPlayer) -> Formatters.NUMBER_FORMATTER.format(island.getTotalRating()))
.put("rating_amount", (island, superiorPlayer) -> Formatters.NUMBER_FORMATTER.format(island.getRatingAmount()))
.put("rating_stars", (island, superiorPlayer) ->
Expand All @@ -172,8 +172,8 @@ public final class PlaceholdersServiceImpl implements PlaceholdersService {
Formatters.NUMBER_FORMATTER.format(plugin.getGrid().getTotalLevel()))
.put("total_level_format", (island, superiorPlayer) ->
Formatters.FANCY_NUMBER_FORMATTER.format(plugin.getGrid().getTotalLevel(), superiorPlayer.getUserLocale()))
.put("nether_unlocked", (island, superiorPlayer) -> island.isNetherEnabled() ? "Yes" : "No")
.put("end_unlocked", (island, superiorPlayer) -> island.isEndEnabled() ? "Yes" : "No")
.put("nether_unlocked", (island, superiorPlayer) -> Formatters.BOOLEAN_FORMATTER.format(island.isNetherEnabled(), superiorPlayer.getUserLocale()))
.put("end_unlocked", (island, superiorPlayer) -> Formatters.BOOLEAN_FORMATTER.format(island.isEndEnabled(), superiorPlayer.getUserLocale()))
.put("visitors_count", (island, superiorPlayer) -> {
return island.getIslandVisitors(false).size() + "";
})
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/lang/de-DE.yml
Expand Up @@ -765,6 +765,8 @@ PERMISSIONS_RESET_PLAYER: '&e&lInsel | &7Alle Berechtigungen für {0} erfolgreic
Standardwerte zurückgesetzt!'
PERMISSIONS_RESET_ROLES: '&e&lInsel | &7Alle Berechtigungen der Insel erfolgreich
auf Standardwerte zurücksetzen!'
PLACEHOLDER_NO: '&c✘'
PLACEHOLDER_YES: '&a✔'
PLAYER_ALREADY_BANNED: '&c&lFehler | &7Dieser Spieler ist bereits gesperrt.'
PLAYER_ALREADY_COOP: '&c&lError | &7Dieser Spieler ist bereits kooperativ.'
PLAYER_ALREADY_IN_ISLAND: '&c&lError | &7Dieser Spieler befindet sich bereits auf
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/lang/en-US.yml
Expand Up @@ -595,6 +595,8 @@ PERMISSION_CHANGED_NAME: '&e&lIsland | &7Successfully updated the permission {0}
PERMISSION_CHANGED_ALL: '&e&lIsland | &7Successfully updated the permission {0} for all the islands.'
PERMISSIONS_RESET_PLAYER: '&e&lIsland | &7Successfully reset all the permissions for {0} to default values!'
PERMISSIONS_RESET_ROLES: '&e&lIsland | &7Successfully reset all the permissions of the island to default values!'
PLACEHOLDER_NO: '&c✘'
PLACEHOLDER_YES: '&a✔'
PLAYER_ALREADY_BANNED: '&c&lError | &7This player is already banned.'
PLAYER_ALREADY_COOP: '&c&lError | &7This player is already coop.'
PLAYER_ALREADY_IN_ISLAND: '&c&lError | &7This player is already inside an island.'
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/lang/es-ES.yml
Expand Up @@ -595,6 +595,8 @@ PERMISSION_CHANGED_NAME: '&e&lIsla | &7Se actualizó correctamente el permiso {0
PERMISSION_CHANGED_ALL: '&e&lIsla | &7Se actualizó correctamente el permiso {0} para todas las islas.'
PERMISSIONS_RESET_PLAYER: '&e&lIsla | &7¡Restableció correctamente todos los permisos de {0} a los valores predeterminados!'
PERMISSIONS_RESET_ROLES: '&e&lIsla | &7¡Restableció con éxito todos los permisos de la isla a los valores predeterminados!'
PLACEHOLDER_NO: '&c✘'
PLACEHOLDER_YES: '&a✔'
PLAYER_ALREADY_BANNED: '&c&lError | &7Este jugador ya está prohibido.'
PLAYER_ALREADY_COOP: '&c&lError | &7Este jugador ya es coop.'
PLAYER_ALREADY_IN_ISLAND: '&c&lError | &7Este jugador ya está dentro de una isla.'
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/lang/fr-FR.yml
Expand Up @@ -597,6 +597,8 @@ PERMISSION_CHANGED_NAME: '&e&lIle | &7Permission {0} de l''île {1} mise à jour
PERMISSION_CHANGED_ALL: '&e&lIle | &7Permission {0} mise à jour pour toutes les îles.'
PERMISSIONS_RESET_PLAYER: '&e&lIle | &7Réinitialisation de toutes les permissions de {0} !'
PERMISSIONS_RESET_ROLES: '&e&lIle | &7Réinitialisation de toutes les permissions de l''île !'
PLACEHOLDER_NO: '&c✘'
PLACEHOLDER_YES: '&a✔'
PLAYER_ALREADY_BANNED: '&c&lErreur | &7Ce joueur est déjà banni.'
PLAYER_ALREADY_COOP: '&c&lErreur | &7Ce joueur est déjà coopérateur.'
PLAYER_ALREADY_IN_ISLAND: '&c&lErreur | &7Ce joueur est déjà membre d''une île.'
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/lang/it-IT.yml
Expand Up @@ -600,6 +600,8 @@ PERMISSION_CHANGED_NAME: '&e&lIsola | &7Aggiornata correttamente l''autorizzazio
PERMISSION_CHANGED_ALL: '&e&lIsola | &7Aggiornata correttamente l''autorizzazione {0} di tutte le isola.'
PERMISSIONS_RESET_PLAYER: '&e&lIsola | &7Successfully reset all the permissions for {0} to default values!'
PERMISSIONS_RESET_ROLES: '&e&lIsola | &7Successfully reset all the permissions of the island to default values!'
PLACEHOLDER_NO: '&c✘'
PLACEHOLDER_YES: '&a✔'
PLAYER_ALREADY_BANNED: '&c&lErrore | &7Questo giocatore è già stato bannato.'
PLAYER_ALREADY_COOP: '&c&lErrore | &7Questo giocatore è già un membro coop.'
PLAYER_ALREADY_IN_ISLAND: '&c&lErrore | &7Questo giocatore è già all''interno di un''isola.'
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/lang/iw-IL.yml
Expand Up @@ -617,6 +617,8 @@ PERMISSION_CHANGED_NAME: '&e&lיא | &7החלצהב {1} יאב {0} האשרהה
PERMISSION_CHANGED_ALL: '&e&lיא | &7החלצהב םייאה לכב {0} האשרהה תא תיניש.'
PERMISSIONS_RESET_PLAYER: '&e&lIsland | &7Successfully reset all the permissions for {0} to default values!'
PERMISSIONS_RESET_ROLES: '&e&lIsland | &7Successfully reset all the permissions of the island to default values!'
PLACEHOLDER_NO: '&c✘'
PLACEHOLDER_YES: '&a✔'
PLAYER_ALREADY_BANNED: '&c&lהאיגש | &7יאהמ קחרומ רבכ הזה ןקחשה.'
PLAYER_ALREADY_COOP: '&c&lהאיגש | &7יאה לש הלועפ ףתשמ רבכ הזה ןקחשה.'
PLAYER_ALREADY_IN_ISLAND: '&c&lError | &7This player is already inside an island.'
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/lang/pl-PL.yml
Expand Up @@ -597,6 +597,8 @@ PERMISSION_CHANGED_NAME: '&e&lWyspa | &7Pomyslnie zaktualizowano uprawnienia {0}
PERMISSION_CHANGED_ALL: '&e&lWyspa | &7Pomyslnie zaktualizowano uprawnienia {0} dla wszystkich wysp.'
PERMISSIONS_RESET_PLAYER: '&e&lWyspa | &7Pomyslnie zresetuj wszystkie uprawnienia dla {0} do wartosci domyslnych!'
PERMISSIONS_RESET_ROLES: '&e&lWyspa | &7Pomyslnie zresetuj wszystkie uprawnienia wyspy do wartosci domyslnych!'
PLACEHOLDER_NO: '&c✘'
PLACEHOLDER_YES: '&a✔'
PLAYER_ALREADY_BANNED: '&c&lBlad | &7Ten gracz jest juz zbanowany.'
PLAYER_ALREADY_COOP: '&c&lBlad | &7Ten gracz jest juz w trybie wspólpracy.'
PLAYER_ALREADY_IN_ISLAND: '&c&lBlad | &7Ten gracz jest juz na wyspie.'
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/lang/vi-VN.yml
Expand Up @@ -676,6 +676,8 @@ PERMISSION_CHANGED_ALL: '&e&lNâng Cấp | &7Thay đổi thành công quyền {0
các đảo.'
PERMISSIONS_RESET_PLAYER: '&e&lĐảo | &7Thành công đặt lại tất cả các quyền cho {0} thành giá trị mặc định!'
PERMISSIONS_RESET_ROLES: '&e&lĐảo | &7Thành công đặt lại tất cả các quyền của hòn đảo thành giá trị mặc định!'
PLACEHOLDER_NO: '&c✘'
PLACEHOLDER_YES: '&a✔'
PLAYER_ALREADY_BANNED: '&c&lLỗi | &7Người chơi này đã bị cấm.'
PLAYER_ALREADY_COOP: '&c&lLỗi | &7Người chơi này đã hợp tác.'
PLAYER_ALREADY_IN_ISLAND: '&c&lLỗi | &7Người chơi này đã có sẵn trong đảo.'
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/lang/zh-CN.yml
Expand Up @@ -597,6 +597,8 @@ PERMISSION_CHANGED_NAME: '&e&l岛屿 | &7成功更新 &b{1} &7岛屿的 &b{0} &7
PERMISSION_CHANGED_ALL: '&e&l岛屿 | &7成功为所有岛屿更新 &b{0} &7权限.'
PERMISSIONS_RESET_PLAYER: '&e&lIsland | &7Successfully reset all the permissions for {0} to default values!'
PERMISSIONS_RESET_ROLES: '&e&lIsland | &7Successfully reset all the permissions of the island to default values!'
PLACEHOLDER_NO: '&c✘'
PLACEHOLDER_YES: '&a✔'
PLAYER_ALREADY_BANNED: '&c&l错误 | &7这个玩家已经被岛屿禁封了.'
PLAYER_ALREADY_COOP: '&c&l错误 | &7这个玩家已经是岛屿的临时成员了.'
PLAYER_ALREADY_IN_ISLAND: '&c&l错误 | &7这个玩家已经在岛屿中了.'
Expand Down

0 comments on commit 1ddeded

Please sign in to comment.