Skip to content

Commit bc4c945

Browse files
authored
Implémentation des translations pour les features economy, events, friend, homes (#1284)
* add translation for economy, events, friend, homes (not finished), c la hess l'IA ma recalé. * finish translation * finish review + testing
1 parent e35ef0e commit bc4c945

46 files changed

Lines changed: 1480 additions & 684 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/main/java/fr/openmc/core/features/economy/BankManager.java

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,10 @@
2424
import fr.openmc.core.utils.text.messages.MessageType;
2525
import fr.openmc.core.utils.text.messages.MessagesManager;
2626
import fr.openmc.core.utils.text.messages.Prefix;
27+
import fr.openmc.core.utils.text.messages.TranslationManager;
2728
import lombok.Getter;
2829
import net.kyori.adventure.text.Component;
30+
import net.kyori.adventure.text.format.NamedTextColor;
2931
import org.bukkit.Bukkit;
3032
import org.bukkit.OfflinePlayer;
3133
import org.bukkit.entity.Player;
@@ -111,7 +113,7 @@ public static void deposit(UUID playerUUID, String input) {
111113
OfflinePlayer offlinePlayer = CacheOfflinePlayer.getOfflinePlayer(playerUUID);
112114

113115
if (!InputUtils.isInputMoney(input)) {
114-
MessagesManager.sendMessage(offlinePlayer, Component.text("Veuillez mettre une entrée correcte"),
116+
MessagesManager.sendMessage(offlinePlayer, TranslationManager.translation("messages.global.invalid_input"),
115117
Prefix.BANK, MessageType.ERROR, true);
116118
return;
117119
}
@@ -121,7 +123,7 @@ public static void deposit(UUID playerUUID, String input) {
121123

122124
if (city == null || city.getLevel() < 2) {
123125
MessagesManager.sendMessage(offlinePlayer,
124-
Component.text("Pour avoir une banque personnelle, vous devez appartenir à une ville de niveau 2 minimum !"),
126+
TranslationManager.translation("feature.economy.bank.deposit.need_city_level_2"),
125127
Prefix.BANK, MessageType.ERROR, false);
126128
return;
127129
}
@@ -131,17 +133,16 @@ public static void deposit(UUID playerUUID, String input) {
131133

132134
if (currentBalance >= limit) {
133135
MessagesManager.sendMessage(offlinePlayer,
134-
Component.text("Vous avez atteint la limite de votre plafond qui est de " +
135-
EconomyManager.getFormattedNumber(limit) +
136-
". Améliorez votre ville au niveau supérieur !"),
136+
TranslationManager.translation("feature.economy.bank.deposit.limit_reached",
137+
Component.text(EconomyManager.getFormattedNumber(limit)).color(NamedTextColor.LIGHT_PURPLE)),
137138
Prefix.BANK, MessageType.ERROR, false);
138139
return;
139140
}
140141

141142
double allowedAmount = Math.min(amount, limit - currentBalance);
142143

143144
if (!EconomyManager.withdrawBalance(playerUUID, allowedAmount)) {
144-
MessagesManager.sendMessage(offlinePlayer, Component.text("Vous n'avez pas assez d'argent"),
145+
MessagesManager.sendMessage(offlinePlayer, TranslationManager.translation("feature.economy.bank.deposit.not_enough_money"),
145146
Prefix.BANK, MessageType.ERROR, false);
146147
return;
147148
}
@@ -150,13 +151,17 @@ public static void deposit(UUID playerUUID, String input) {
150151

151152
if (allowedAmount < amount) {
152153
MessagesManager.sendMessage(offlinePlayer,
153-
Component.text("Seulement " + EconomyManager.getFormattedNumber(allowedAmount) +
154-
" ont été déposés (plafond atteint)."),
154+
TranslationManager.translation(
155+
"feature.economy.bank.deposit.partial",
156+
Component.text(EconomyManager.getFormattedNumber(allowedAmount)).color(NamedTextColor.LIGHT_PURPLE)
157+
),
155158
Prefix.BANK, MessageType.ERROR, false);
156159
} else {
157160
MessagesManager.sendMessage(offlinePlayer,
158-
Component.text("Vous avez déposé " +
159-
EconomyManager.getFormattedNumber(allowedAmount) + "."),
161+
TranslationManager.translation(
162+
"feature.economy.bank.deposit.success",
163+
Component.text(EconomyManager.getFormattedNumber(allowedAmount)).color(NamedTextColor.LIGHT_PURPLE)
164+
),
160165
Prefix.BANK, MessageType.SUCCESS, false);
161166
}
162167
}
@@ -165,25 +170,26 @@ public static void withdraw(UUID playerUUID, String input) {
165170
OfflinePlayer offlinePlayer = CacheOfflinePlayer.getOfflinePlayer(playerUUID);
166171

167172
if (!InputUtils.isInputMoney(input)) {
168-
MessagesManager.sendMessage(offlinePlayer, Component.text("Veuillez mettre une entrée correcte"),
173+
MessagesManager.sendMessage(offlinePlayer, TranslationManager.translation("messages.global.invalid_input"),
169174
Prefix.BANK, MessageType.ERROR, true);
170175
return;
171176
}
172177

173178
double amount = InputUtils.convertToMoneyValue(input);
174179

175180
if (!withdraw(playerUUID, amount)) {
176-
MessagesManager.sendMessage(offlinePlayer,
177-
Component.text("Tu n'as pas assez d'argent en banque"),
178-
Prefix.BANK, MessageType.ERROR, false);
181+
MessagesManager.sendMessage(offlinePlayer, TranslationManager.translation("feature.economy.bank.withdraw.not_enough"), Prefix.BANK, MessageType.ERROR, false);
179182
return;
180183
}
181184

182185
EconomyManager.addBalance(playerUUID, amount, "Retrait banque personnelle");
183186

184187
MessagesManager.sendMessage(offlinePlayer,
185-
Component.text("§d" + EconomyManager.getFormattedSimplifiedNumber(amount) + "§r"
186-
+ EconomyManager.getEconomyIcon() + " ont été transférés à votre compte"),
188+
TranslationManager.translation(
189+
"feature.economy.bank.withdraw.transferred",
190+
Component.text(EconomyManager.getFormattedSimplifiedNumber(amount)).color(NamedTextColor.LIGHT_PURPLE),
191+
Component.text(EconomyManager.getEconomyIcon())
192+
),
187193
Prefix.BANK, MessageType.SUCCESS, false);
188194
}
189195

@@ -231,9 +237,12 @@ public static void applyPlayerInterest(UUID playerUUID) {
231237
Player sender = Bukkit.getPlayer(playerUUID);
232238
if (sender != null)
233239
MessagesManager.sendMessage(sender,
234-
Component.text("Vous venez de percevoir §d" + interest * 100 + "% §rd'intérêt, soit §d"
235-
+ EconomyManager.getFormattedSimplifiedNumber(allowedAmount) + "§r"
236-
+ EconomyManager.getEconomyIcon()),
240+
TranslationManager.translation(
241+
"feature.economy.bank.interest.received",
242+
Component.text(interest * 100 + "%").color(NamedTextColor.LIGHT_PURPLE),
243+
Component.text(EconomyManager.getFormattedSimplifiedNumber(allowedAmount)).color(NamedTextColor.LIGHT_PURPLE),
244+
Component.text(EconomyManager.getEconomyIcon())
245+
),
237246
Prefix.CITY, MessageType.SUCCESS, false);
238247
}
239248

src/main/java/fr/openmc/core/features/economy/Transaction.java

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@
33
import com.j256.ormlite.field.DatabaseField;
44
import com.j256.ormlite.table.DatabaseTable;
55
import fr.openmc.core.utils.cache.CacheOfflinePlayer;
6+
import fr.openmc.core.utils.text.messages.TranslationManager;
7+
import net.kyori.adventure.text.Component;
8+
import net.kyori.adventure.text.format.NamedTextColor;
69
import org.bukkit.Material;
710
import org.bukkit.inventory.ItemStack;
811
import org.bukkit.inventory.meta.ItemMeta;
912

10-
import java.util.List;
1113
import java.util.Objects;
1214
import java.util.UUID;
1315

@@ -49,31 +51,35 @@ public ItemStack toItemStack(UUID player) {
4951
if (!Objects.equals(this.recipient, player.toString())) {
5052
itemstack = new ItemStack(Material.RED_CONCRETE, 1);
5153
itemmeta = itemstack.getItemMeta();
52-
itemmeta.setDisplayName("Transaction sortante");
54+
itemmeta.displayName(TranslationManager.translation("feature.economy.transaction.outgoing.name"));
5355

5456
String recipient = "CONSOLE";
5557
if (!this.recipient.equals("CONSOLE")) {
5658
recipient = CacheOfflinePlayer.getOfflinePlayer(UUID.fromString(this.recipient)).getName();
5759
}
5860

59-
itemmeta.setLore(List.of(
60-
"§r§6Destination :§f " + recipient,
61-
"§r§6Montant :§f " + this.amount,
62-
"§r§6Raison :§f " + reason));
61+
itemmeta.lore(TranslationManager.translationLore(
62+
"feature.economy.transaction.outgoing.lore",
63+
Component.text(recipient).color(NamedTextColor.WHITE),
64+
Component.text(this.amount).color(NamedTextColor.WHITE),
65+
Component.text(reason).color(NamedTextColor.WHITE)
66+
));
6367
} else {
6468
itemstack = new ItemStack(Material.LIME_CONCRETE, 1);
6569
itemmeta = itemstack.getItemMeta();
66-
itemmeta.setDisplayName("Transaction entrante");
70+
itemmeta.displayName(TranslationManager.translation("feature.economy.transaction.incoming.name"));
6771

6872
String senderName = "CONSOLE";
6973
if (!this.sender.equals("CONSOLE")) {
7074
senderName = CacheOfflinePlayer.getOfflinePlayer(UUID.fromString(this.sender)).getName();
7175
}
7276

73-
itemmeta.setLore(List.of(
74-
"§r§6Envoyeur :§f " + senderName,
75-
"§r§6Montant :§f " + this.amount,
76-
"§r§6Raison :§f " + reason));
77+
itemmeta.lore(TranslationManager.translationLore(
78+
"feature.economy.transaction.incoming.lore",
79+
Component.text(senderName).color(NamedTextColor.WHITE),
80+
Component.text(this.amount).color(NamedTextColor.WHITE),
81+
Component.text(reason).color(NamedTextColor.WHITE)
82+
));
7783
}
7884

7985
itemstack.setItemMeta(itemmeta);

src/main/java/fr/openmc/core/features/economy/commands/BankCommands.java

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010
import fr.openmc.core.utils.text.messages.MessageType;
1111
import fr.openmc.core.utils.text.messages.MessagesManager;
1212
import fr.openmc.core.utils.text.messages.Prefix;
13+
import fr.openmc.core.utils.text.messages.TranslationManager;
1314
import net.kyori.adventure.text.Component;
15+
import net.kyori.adventure.text.format.NamedTextColor;
1416
import org.bukkit.entity.Player;
1517
import revxrsal.commands.annotation.*;
1618
import revxrsal.commands.bukkit.annotation.CommandPermission;
@@ -23,7 +25,12 @@ public class BankCommands {
2325
public static void openBankMenu(Player player) {
2426
City playerCity = CityManager.getPlayerCity(player.getUniqueId());
2527
if (playerCity == null || !FeaturesRewards.hasUnlockFeature(playerCity, FeaturesRewards.Feature.PLAYER_BANK)) {
26-
MessagesManager.sendMessage(player, Component.text("Vous n'avez pas débloqué cette feature ! Veuillez améliorer votre ville au niveau " + FeaturesRewards.getFeatureUnlockLevel(FeaturesRewards.Feature.PLAYER_BANK) + "!"), Prefix.CITY, MessageType.ERROR, false);
28+
MessagesManager.sendMessage(player,
29+
TranslationManager.translation(
30+
"feature.economy.bank.command.not_unlocked",
31+
Component.text(FeaturesRewards.getFeatureUnlockLevel(FeaturesRewards.Feature.PLAYER_BANK)).color(NamedTextColor.YELLOW)
32+
),
33+
Prefix.CITY, MessageType.ERROR, false);
2734
return;
2835
}
2936

@@ -38,7 +45,12 @@ void deposit(
3845
) {
3946
City playerCity = CityManager.getPlayerCity(player.getUniqueId());
4047
if (playerCity == null || !FeaturesRewards.hasUnlockFeature(playerCity, FeaturesRewards.Feature.PLAYER_BANK)) {
41-
MessagesManager.sendMessage(player, Component.text("Vous n'avez pas débloqué cette feature ! Veuillez améliorer votre ville au niveau " + FeaturesRewards.getFeatureUnlockLevel(FeaturesRewards.Feature.PLAYER_BANK) + "!"), Prefix.CITY, MessageType.ERROR, false);
48+
MessagesManager.sendMessage(player,
49+
TranslationManager.translation(
50+
"feature.economy.bank.command.not_unlocked",
51+
Component.text(FeaturesRewards.getFeatureUnlockLevel(FeaturesRewards.Feature.PLAYER_BANK)).color(NamedTextColor.YELLOW)
52+
),
53+
Prefix.CITY, MessageType.ERROR, false);
4254
return;
4355
}
4456

@@ -53,7 +65,12 @@ void withdraw(
5365
) {
5466
City playerCity = CityManager.getPlayerCity(player.getUniqueId());
5567
if (playerCity == null || !FeaturesRewards.hasUnlockFeature(playerCity, FeaturesRewards.Feature.PLAYER_BANK)) {
56-
MessagesManager.sendMessage(player, Component.text("Vous n'avez pas débloqué cette feature ! Veuillez améliorer votre ville au niveau " + FeaturesRewards.getFeatureUnlockLevel(FeaturesRewards.Feature.PLAYER_BANK) + "!"), Prefix.CITY, MessageType.ERROR, false);
68+
MessagesManager.sendMessage(player,
69+
TranslationManager.translation(
70+
"feature.economy.bank.command.not_unlocked",
71+
Component.text(FeaturesRewards.getFeatureUnlockLevel(FeaturesRewards.Feature.PLAYER_BANK)).color(NamedTextColor.YELLOW)
72+
),
73+
Prefix.CITY, MessageType.ERROR, false);
5774
return;
5875
}
5976

@@ -69,16 +86,22 @@ void withdraw(Player player) {
6986
}
7087

7188
double balance = BankManager.getBankBalance(player.getUniqueId());
72-
MessagesManager.sendMessage(player, Component.text("Il y a §d" + EconomyManager.getFormattedSimplifiedNumber(balance) + "§r" + EconomyManager.getEconomyIcon() + " dans ta banque"), Prefix.BANK, MessageType.INFO, false);
89+
MessagesManager.sendMessage(player,
90+
TranslationManager.translation(
91+
"feature.economy.bank.command.balance",
92+
Component.text(EconomyManager.getFormattedSimplifiedNumber(balance)).color(NamedTextColor.LIGHT_PURPLE),
93+
Component.text(EconomyManager.getEconomyIcon())
94+
),
95+
Prefix.BANK, MessageType.INFO, false);
7396
}
7497

7598
@Subcommand("admin interest apply")
7699
@Description("Distribue les intérèts à tout les joueurs et a toute les villes")
77100
@CommandPermission("omc.admins.commands.bank.interest.apply")
78101
void applyInterest(Player player) {
79-
MessagesManager.sendMessage(player, Component.text("Distribution des intérêts en cours..."), Prefix.BANK, MessageType.INFO, false);
102+
MessagesManager.sendMessage(player, TranslationManager.translation("feature.economy.bank.interest.apply.start"), Prefix.BANK, MessageType.INFO, false);
80103
BankManager.applyAllPlayerInterests();
81104
CityBankManager.applyAllCityInterests();
82-
MessagesManager.sendMessage(player, Component.text("Distribution des intérêts réussie."), Prefix.BANK, MessageType.SUCCESS, false);
105+
MessagesManager.sendMessage(player, TranslationManager.translation("feature.economy.bank.interest.apply.success"), Prefix.BANK, MessageType.SUCCESS, false);
83106
}
84107
}

0 commit comments

Comments
 (0)