Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions src/main/java/fr/openmc/core/features/city/City.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import lombok.Getter;
import lombok.Setter;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.NamedTextColor;
import org.bukkit.Bukkit;
import org.bukkit.Chunk;
import org.bukkit.OfflinePlayer;
Expand Down Expand Up @@ -794,21 +795,30 @@ public void changeRank(Player sender, UUID playerUUID, DBCityRank newRank) {

DBCityRank currentRank = getRankOfMember(playerUUID);
OfflinePlayer player = CacheOfflinePlayer.getOfflinePlayer(playerUUID);

if (currentRank != null) {
currentRank.removeMember(playerUUID);
for (CityPermission permission : currentRank.getPermissionsSet()) {
removePermission(playerUUID, permission);
}
MessagesManager.sendMessage(sender, Component.text("§cVous avez retiré le grade §e" + currentRank.getName() + "§c de §6" + player.getName()), Prefix.CITY, MessageType.SUCCESS, true);
MessagesManager.sendMessage(sender,
TranslationManager.translation("feature.city.grade.remove_grade",
Component.text(currentRank.getName()).color(NamedTextColor.YELLOW),
Component.text(player.getName())).color(NamedTextColor.GOLD),
Prefix.CITY, MessageType.SUCCESS, true);
}

if (currentRank != newRank) {
newRank.addMember(playerUUID);
for (CityPermission permission : newRank.getPermissionsSet()) {
addPermission(playerUUID, permission);
}
MessagesManager.sendMessage(sender, Component.text("§aVous avez assigné le grade §e" + newRank.getName() + "§a à §6" + player.getName()), Prefix.CITY, MessageType.SUCCESS, true);
MessagesManager.sendMessage(sender,
TranslationManager.translation("feature.city.grade.assign_grade",
Component.text(newRank.getName()).color(NamedTextColor.YELLOW),
Component.text(player.getName()).color(NamedTextColor.GOLD)
),
Prefix.CITY, MessageType.SUCCESS, true);
}

Bukkit.getScheduler().runTaskAsynchronously(OMCPlugin.getInstance(), () -> {
Expand Down
14 changes: 10 additions & 4 deletions src/main/java/fr/openmc/core/features/city/CityChatManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import fr.openmc.core.utils.messages.MessageType;
import fr.openmc.core.utils.messages.MessagesManager;
import fr.openmc.core.utils.messages.Prefix;
import fr.openmc.core.utils.messages.TranslationManager;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.NamedTextColor;
import org.bukkit.Bukkit;
Expand All @@ -26,7 +27,8 @@ public class CityChatManager {
*/
public static void addCityChatMember(Player player) {
cityChatMembers.add(player);
MessagesManager.sendMessage(player, Component.text("Vous avez rejoint le chat de ville"), Prefix.CITY, MessageType.INFO, false);
MessagesManager.sendMessage(player, TranslationManager.translation("feature.city.chat.entered"),
Prefix.CITY, MessageType.INFO, false);
}

/**
Expand All @@ -35,7 +37,8 @@ public static void addCityChatMember(Player player) {
*/
public static void removeCityChatMember(Player player) {
cityChatMembers.remove(player);
MessagesManager.sendMessage(player, Component.text("Vous avez quitté le chat de ville"), Prefix.CITY, MessageType.INFO, false);
MessagesManager.sendMessage(player, TranslationManager.translation("feature.city.chat.leaved"),
Prefix.CITY, MessageType.INFO, false);
}

/**
Expand All @@ -55,11 +58,14 @@ public static boolean isCityChatMember(Player player) {
public static void sendCityChatMessage(Player sender, Component message) {
City city = CityManager.getPlayerCity(sender.getUniqueId());
if (city == null) {
MessagesManager.sendMessage(sender, Component.text("Tu n'habites dans aucune ville"), Prefix.CITY, MessageType.ERROR, false);
MessagesManager.sendMessage(sender, TranslationManager.translation("messages.city.player_no_in_city"),
Prefix.CITY, MessageType.ERROR, false);
return;
}

Component msg_component = Component.text("#ville ").color(NamedTextColor.GOLD).append(sender.displayName().color(NamedTextColor.WHITE)).append(
Component msg_component = TranslationManager.translation("feature.city.chat.prefix").color(NamedTextColor.GOLD)
.appendSpace()
.append(sender.displayName().color(NamedTextColor.WHITE)).append(
Component.text(" » ").color(NamedTextColor.GRAY).append(
message.color(NamedTextColor.WHITE)
)
Expand Down
57 changes: 29 additions & 28 deletions src/main/java/fr/openmc/core/features/city/CityPermission.java
Original file line number Diff line number Diff line change
@@ -1,41 +1,42 @@
package fr.openmc.core.features.city;

import fr.openmc.core.utils.messages.TranslationManager;
import lombok.Getter;
import net.kyori.adventure.text.Component;
import org.bukkit.Material;

@Getter
public enum CityPermission {
OWNER("Propriétaire", Material.NETHERITE_BLOCK), //Impossible à donner sauf avec un transfert
INVITE("Inviter", Material.OAK_DOOR),
KICK("Expulser", Material.IRON_DOOR),
PLACE("Placer des blocs", Material.OAK_LOG),
BREAK("Casser des blocs", Material.STONE_PICKAXE),
OPEN_CHEST("Ouvrir les coffres", Material.CHEST),
INTERACT("Interagir avec les blocs (sauf coffres)", Material.LEVER),
CLAIM("Claim", Material.GRASS_BLOCK),
SEE_CHUNKS("Voir les claims", Material.MAP),
RENAME("Renommer", Material.NAME_TAG),
MONEY_GIVE("Déposer de l'argent", Material.EMERALD),
MONEY_BALANCE("Voir l'argent", Material.GOLD_INGOT),
MONEY_TAKE("Retirer de l'argent", Material.DIAMOND),
PERMS("Permissions", Material.DIAMOND_BLOCK), // Cette permission est donnée seulement par l'owner
CHEST("Accès au coffre de ville", Material.ENDER_CHEST),
CHEST_UPGRADE("Améliorer le coffre de ville", Material.OAK_CHEST_BOAT),
TYPE("Changer le type de ville", Material.BIRCH_SIGN),
MASCOT_MOVE("Déplacer la mascotte", Material.LEAD),
MASCOT_SKIN("Changer le skin de la mascotte", Material.ZOMBIE_SPAWN_EGG),
MASCOT_UPGRADE("Améliorer la mascotte", Material.BONE),
MASCOT_HEAL("Soigner la mascotte", Material.POTION),
LAUNCH_WAR("Lancer des guerres", Material.IRON_SWORD),
MANAGE_RANKS("Gérer les grades", Material.PAPER),
ASSIGN_RANKS("Assigner des grades", Material.BOOK)
OWNER(TranslationManager.translation("feature.city.permission.owner"), Material.NETHERITE_BLOCK), //Impossible à donner sauf avec un transfert
INVITE(TranslationManager.translation("feature.city.permission.invite"), Material.OAK_DOOR),
KICK(TranslationManager.translation("feature.city.permission.kick"), Material.IRON_DOOR),
PLACE(TranslationManager.translation("feature.city.permission.place"), Material.OAK_LOG),
BREAK(TranslationManager.translation("feature.city.permission.break"), Material.STONE_PICKAXE),
OPEN_CHEST(TranslationManager.translation("feature.city.permission.open_chest"), Material.CHEST),
INTERACT(TranslationManager.translation("feature.city.permission.interact"), Material.LEVER),
CLAIM(TranslationManager.translation("feature.city.permission.claim"), Material.GRASS_BLOCK),
SEE_CHUNKS(TranslationManager.translation("feature.city.permission.see_claim"), Material.MAP),
RENAME(TranslationManager.translation("feature.city.permission.rename"), Material.NAME_TAG),
MONEY_DEPOSIT(TranslationManager.translation("feature.city.permission.money_deposit"), Material.EMERALD),
MONEY_BALANCE(TranslationManager.translation("feature.city.permission.money_see"), Material.GOLD_INGOT),
MONEY_WITHDRAW(TranslationManager.translation("feature.city.permission.money_withdraw"), Material.DIAMOND),
MANAGE_PERMS(TranslationManager.translation("feature.city.permission.manage_perm"), Material.DIAMOND_BLOCK), // Cette permission est donnée seulement par l'owner
ACCESS_CITY_CHEST(TranslationManager.translation("feature.city.permission.access_city_chest"), Material.ENDER_CHEST),
UPGRADE_CHEST(TranslationManager.translation("feature.city.permission.upgrade_chest"), Material.OAK_CHEST_BOAT),
CHANGE_TYPE(TranslationManager.translation("feature.city.permission.change_type"), Material.BIRCH_SIGN),
MASCOT_MOVE(TranslationManager.translation("feature.city.permission.move_mascot"), Material.LEAD),
MASCOT_CHANGE_SKIN(TranslationManager.translation("feature.city.permission.change_mascot_skin"), Material.ZOMBIE_SPAWN_EGG),
MASCOT_UPGRADE(TranslationManager.translation("feature.city.permission.upgrade_mascot"), Material.BONE),
MASCOT_HEAL(TranslationManager.translation("feature.city.permission.heal_mascot"), Material.POTION),
LAUNCH_WAR(TranslationManager.translation("feature.city.permission.launch_war"), Material.IRON_SWORD),
MANAGE_RANKS(TranslationManager.translation("feature.city.permission.manage_grade"), Material.PAPER),
ASSIGN_RANKS(TranslationManager.translation("feature.city.permission.assign_grade"), Material.BOOK)
;

@Getter
private final String displayName;
@Getter
private final Component displayName;
private final Material icon;

CityPermission(String displayName, Material icon) {
CityPermission(Component displayName, Material icon) {
this.displayName = displayName;
this.icon = icon;
}
Expand Down
17 changes: 6 additions & 11 deletions src/main/java/fr/openmc/core/features/city/CityType.java
Original file line number Diff line number Diff line change
@@ -1,23 +1,18 @@
package fr.openmc.core.features.city;

import fr.openmc.core.utils.messages.TranslationManager;
import lombok.Getter;
import net.kyori.adventure.text.Component;

@Getter
public enum CityType {
WAR("Guerre", "§c"),
PEACE("Paix", "§a"),

WAR(TranslationManager.translation("feature.city.war.war")),
PEACE(TranslationManager.translation("feature.city.war.peace")),
;

private String displayName;
private String color;
private final Component displayName;

CityType(String displayName, String color) {
CityType(Component displayName) {
this.displayName = displayName;
this.color = color;
}

public String getName() {
return color + displayName + "§7";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import fr.openmc.core.utils.messages.MessageType;
import fr.openmc.core.utils.messages.MessagesManager;
import fr.openmc.core.utils.messages.Prefix;
import net.kyori.adventure.text.Component;
import fr.openmc.core.utils.messages.TranslationManager;
import org.bukkit.Location;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
Expand Down Expand Up @@ -123,7 +123,7 @@ public static void cancelMessage(Player player) {
lastErrorMessageTime.put(player.getUniqueId(), now);
MessagesManager.sendMessage(
player,
Component.text("Vous n'avez pas l'autorisation de faire ceci !"),
TranslationManager.translation("feature.city.cant_do_this"),
Prefix.CITY,
MessageType.ERROR,
0.6F,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import fr.openmc.core.utils.messages.Prefix;
import fr.openmc.core.utils.messages.TranslationManager;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.NamedTextColor;
import org.bukkit.NamespacedKey;
import org.bukkit.attribute.Attribute;
import org.bukkit.attribute.AttributeModifier;
Expand All @@ -35,24 +36,26 @@ public static void beginChangeCity(Player player, CityType typeChange) {
if (!CityTypeConditions.canCityChangeType(city, player, typeChange)) return;

if (typeChange.equals(CityType.WAR) && !FeaturesRewards.hasUnlockFeature(city, FeaturesRewards.Feature.TYPE_WAR)) {
MessagesManager.sendMessage(player, Component.text("Vous n'avez pas débloqué cette feature ! Veuillez améliorer votre ville au niveau " + FeaturesRewards.getFeatureUnlockLevel(FeaturesRewards.Feature.TYPE_WAR) + "!"), Prefix.CITY, MessageType.ERROR, false);
MessagesManager.sendMessage(player, TranslationManager.translation("messages.city.havent_unlocked_feature",
Component.text(FeaturesRewards.getFeatureUnlockLevel(FeaturesRewards.Feature.TYPE_WAR))),
Prefix.CITY, MessageType.ERROR, false);
return;
}

String cityTypeActuel;
String cityTypeAfter;
cityTypeActuel = city.getType() == CityType.WAR ? "§cen guerre§7" : "§aen paix§7";
cityTypeAfter = city.getType() == CityType.WAR ? "§aen paix§7" : "§cen guerre§7";
Component inPeace = TranslationManager.translation("feature.city.type.in_peace").color(NamedTextColor.GREEN);
Component inWar = TranslationManager.translation("feature.city.type.in_war").color(NamedTextColor.RED);
Component cityTypeActuel = city.getType() == CityType.WAR ? inWar : inPeace;
Component cityTypeAfter = city.getType() == CityType.WAR ? inPeace : inWar;

List<Component> confirmLore = new ArrayList<>();
confirmLore.add(Component.text("§cEs-tu sûr de vouloir changer le type de ta §dville §7?"));
confirmLore.add(Component.text("§7Vous allez passez d'une §dville " + cityTypeActuel + " à une §dville " + cityTypeAfter));
confirmLore.add(TranslationManager.translation("feature.city.type.confirm_change"));
confirmLore.add(TranslationManager.translation("feature.city.type.change_type_to_type", cityTypeActuel, cityTypeAfter));
if (typeChange == CityType.WAR) {
confirmLore.add(Component.empty());
confirmLore.add(Component.text("§c⚠ Vous pourrez être exposé à des guerres contre d'autres villes à tout moment !"));
confirmLore.add(TranslationManager.translation("feature.city.type.warning_war"));
}
confirmLore.add(Component.empty());
confirmLore.add(Component.text("§c⚠ Ta mascotte §4§lperdera 1 niveau !"));
confirmLore.add(TranslationManager.translation("feature.city.type.mascot_losing_level"));

ConfirmMenu menu = new ConfirmMenu(
player,
Expand All @@ -63,7 +66,7 @@ public static void beginChangeCity(Player player, CityType typeChange) {
player::closeInventory,
confirmLore,
List.of(
Component.text("§7Ne pas changer le §dtype de ville")
TranslationManager.translation("feature.city.type.not_change_type")
)
);
menu.open();
Expand All @@ -82,17 +85,21 @@ public static void finishChange(Player sender) {
Mascot mascot = city.getMascot();

if (mascot == null) {
MessagesManager.sendMessage(sender, Component.text("Vous n'avez pas de mascotte pour changer le type de votre ville (contactez le staff)"), Prefix.CITY, MessageType.ERROR, false);
MessagesManager.sendMessage(sender, TranslationManager.translation("feature.city.type.mascot_not_exist_change_type"),
Prefix.CITY, MessageType.ERROR, false);
return;
}

if (!mascot.isAlive()) {
MessagesManager.sendMessage(sender, Component.text("Votre mascotte doit être en vie pour changer le type de ville"), Prefix.CITY, MessageType.ERROR, false);
MessagesManager.sendMessage(sender, TranslationManager.translation("feature.city.type.mascot_must_by_alive_change_type"),
Prefix.CITY, MessageType.ERROR, false);
return;
}

if (!DynamicCooldownManager.isReady(city.getUniqueId(), "city:type")) {
MessagesManager.sendMessage(sender, Component.text("Vous devez attendre " + DateUtils.convertMillisToTime(DynamicCooldownManager.getRemaining(city.getUniqueId(), "city:type")) + " avant de changer de type de ville"), Prefix.CITY, MessageType.ERROR, false);
MessagesManager.sendMessage(sender, TranslationManager.translation("feature.city.type.must_wait_before_change_type",
Component.text(DateUtils.convertMillisToTime(DynamicCooldownManager.getRemaining(city.getUniqueId(), "city:type")))),
Prefix.CITY, MessageType.ERROR, false);
return;
}

Expand Down Expand Up @@ -128,9 +135,13 @@ public static void finishChange(Player sender) {
throw new RuntimeException(e);
}

String cityTypeActuel = city.getType() == CityType.WAR ? "§aen paix§7" : "§cen guerre§7";
String cityTypeAfter = city.getType() == CityType.WAR ? "§cen guerre§7" : "§aen paix§7";
Component inPeace = TranslationManager.translation("feature.city.type.in_peace").color(NamedTextColor.GREEN);
Component inWar = TranslationManager.translation("feature.city.type.in_war").color(NamedTextColor.RED);
Component cityTypeActuel = city.getType() == CityType.WAR ? inWar : inPeace;
Component cityTypeAfter = city.getType() == CityType.WAR ? inPeace : inWar;

MessagesManager.sendMessage(sender, Component.text("Vous avez changé le type de votre ville de " + cityTypeActuel + " à " + cityTypeAfter), Prefix.CITY, MessageType.SUCCESS, false);
MessagesManager.sendMessage(sender, TranslationManager.translation("feature.city.type.change_type_success",
cityTypeActuel, cityTypeAfter),
Prefix.CITY, MessageType.SUCCESS, false);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import fr.openmc.core.utils.messages.MessageType;
import fr.openmc.core.utils.messages.MessagesManager;
import fr.openmc.core.utils.messages.Prefix;
import net.kyori.adventure.text.Component;
import fr.openmc.core.utils.messages.TranslationManager;
import org.bukkit.entity.Player;

import static fr.openmc.core.features.city.conditions.CityChestConditions.UPGRADE_PER_AYWENITE;
Expand All @@ -24,7 +24,8 @@ public static void upgradeChest(Player player, City city) {

if (ItemUtils.takeAywenite(player, aywenite)) {
city.saveChestContent(city.getChestPages() + 1, null);
MessagesManager.sendMessage(player, Component.text("Le coffre a été amélioré"), Prefix.CITY, MessageType.SUCCESS, true);
MessagesManager.sendMessage(player, TranslationManager.translation("feature.city.chest.upgraded"),
Prefix.CITY, MessageType.SUCCESS, true);
}
}
}
Loading
Loading