From 252c0683deb2393d5be0bda36454891ebe9b31ca Mon Sep 17 00:00:00 2001 From: iambibi_ <89582596+iambibi@users.noreply.github.com> Date: Wed, 18 Feb 2026 18:54:26 +0100 Subject: [PATCH 1/3] fix: claim dupli --- .../city/actions/CityUnclaimAction.java | 22 +++++++++++-------- .../features/city/menu/CityChunkMenu.java | 21 ++++++++++++++---- 2 files changed, 30 insertions(+), 13 deletions(-) diff --git a/src/main/java/fr/openmc/core/features/city/actions/CityUnclaimAction.java b/src/main/java/fr/openmc/core/features/city/actions/CityUnclaimAction.java index 2bdacdb99..10b6cbbf3 100644 --- a/src/main/java/fr/openmc/core/features/city/actions/CityUnclaimAction.java +++ b/src/main/java/fr/openmc/core/features/city/actions/CityUnclaimAction.java @@ -9,6 +9,7 @@ import fr.openmc.core.utils.messages.MessagesManager; import fr.openmc.core.utils.messages.Prefix; import net.kyori.adventure.text.Component; +import org.bukkit.World; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; @@ -26,7 +27,7 @@ public static int calculateAywenite(int chunkCount) { public static void startUnclaim(Player sender, int chunkX, int chunkZ) { City city = CityManager.getPlayerCity(sender.getUniqueId()); - org.bukkit.World bWorld = sender.getWorld(); + World bWorld = sender.getWorld(); if (!bWorld.getName().equals("world")) { MessagesManager.sendMessage(sender, Component.text("Tu ne peux pas étendre ta ville ici"), Prefix.CITY, MessageType.ERROR, false); return; @@ -42,14 +43,17 @@ public static void startUnclaim(Player sender, int chunkX, int chunkZ) { return; } - int price = calculatePrice(city.getChunks().size()); - int ayweniteNb = calculateAywenite(city.getChunks().size()); - - EconomyManager.addBalance(sender.getUniqueId(), price, "Unclaim de chunk de ville"); - ItemStack aywenite = ayweniteItemStack.clone(); - aywenite.setAmount(ayweniteNb); - for (ItemStack item : ItemUtils.splitAmountIntoStack(aywenite)) { - sender.dropItem(item); + // si on unclaim des claims gratuits on ne rend rien, sinon on rend une partie de l'argent et d'aywenite + if (city.getChunks().size() > CityCreateAction.FREE_CLAIMS+1) { + int price = calculatePrice(city.getChunks().size()); + int ayweniteNb = calculateAywenite(city.getChunks().size()); + + EconomyManager.addBalance(sender.getUniqueId(), price, "Unclaim de chunk de ville"); + ItemStack aywenite = ayweniteItemStack.clone(); + aywenite.setAmount(ayweniteNb); + for (ItemStack item : ItemUtils.splitAmountIntoStack(aywenite)) { + sender.dropItem(item); + } } city.removeChunk(chunkX, chunkZ); diff --git a/src/main/java/fr/openmc/core/features/city/menu/CityChunkMenu.java b/src/main/java/fr/openmc/core/features/city/menu/CityChunkMenu.java index 553bf95fa..b444fdaa2 100644 --- a/src/main/java/fr/openmc/core/features/city/menu/CityChunkMenu.java +++ b/src/main/java/fr/openmc/core/features/city/menu/CityChunkMenu.java @@ -11,6 +11,7 @@ import fr.openmc.core.features.city.CityManager; import fr.openmc.core.features.city.CityPermission; import fr.openmc.core.features.city.actions.CityClaimAction; +import fr.openmc.core.features.city.actions.CityCreateAction; import fr.openmc.core.features.city.actions.CityUnclaimAction; import fr.openmc.core.features.economy.EconomyManager; import fr.openmc.core.utils.ChunkInfo; @@ -264,9 +265,9 @@ private ItemBuilder createProtectedChunkItem(Material material, int chunkX, int } private ItemBuilder createPlayerCityChunkItem(Material material, City city, int chunkX, int chunkZ) { - return new ItemBuilder(this, material, itemMeta -> { - itemMeta.displayName(Component.text("§9Claim de votre ville")); - itemMeta.lore(List.of( + List lore; + if (city.getChunks().size() > CityCreateAction.FREE_CLAIMS+1) { + lore = List.of( Component.text("§7Ville : §d" + city.getName()), Component.text("§7Position : §f" + chunkX + ", " + chunkZ), Component.empty(), @@ -275,7 +276,19 @@ private ItemBuilder createPlayerCityChunkItem(Material material, City city, int Component.text("§8- §d" + CityUnclaimAction.calculateAywenite(playerCity.getChunks().size()) + " d'Aywenite"), Component.empty(), Component.text("§e§lCLIQUEZ POUR UNCLAIM") - )); + ); + } else { + lore = List.of( + Component.text("§7Ville : §d" + city.getName()), + Component.text("§7Position : §f" + chunkX + ", " + chunkZ), + Component.empty(), + Component.text("§e§lCLIQUEZ POUR UNCLAIM") + ); + } + + return new ItemBuilder(this, material, itemMeta -> { + itemMeta.displayName(Component.text("§9Claim de votre ville")); + itemMeta.lore(lore); }).setOnClick(event -> handleChunkUnclaimClick(player, chunkX, chunkZ, hasPermissionClaim)); } From 84c93b3d3d3b231a5c8fa77e0e33da418e36c6c3 Mon Sep 17 00:00:00 2001 From: iambibi_ <89582596+iambibi@users.noreply.github.com> Date: Thu, 19 Feb 2026 10:59:52 +0100 Subject: [PATCH 2/3] fix: Cannot invoke "String.isEmpty()" because "content" is null --- .../features/leaderboards/LeaderboardManager.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/main/java/fr/openmc/core/features/leaderboards/LeaderboardManager.java b/src/main/java/fr/openmc/core/features/leaderboards/LeaderboardManager.java index fd7da9e8d..fa688a272 100644 --- a/src/main/java/fr/openmc/core/features/leaderboards/LeaderboardManager.java +++ b/src/main/java/fr/openmc/core/features/leaderboards/LeaderboardManager.java @@ -91,6 +91,9 @@ public static Component createContributorsTextLeaderboard() { int rank = entry.getKey(); String contributorName = entry.getValue().getKey(); ContributorStats stats = entry.getValue().getValue(); + + if (contributorName == null || stats == null) continue; + int addLines = stats.added(); int removeLines = stats.removed(); Component line = Component.text("\n#") @@ -126,6 +129,9 @@ public static Component createMoneyTextLeaderboard() { int rank = entry.getKey(); String playerName = entry.getValue().getKey(); String money = entry.getValue().getValue(); + + if (playerName == null || money == null) continue; + Component line = Component.text("\n#") .color(getRankColor(rank)) .append(Component.text(rank).color(getRankColor(rank))) @@ -157,6 +163,9 @@ public static Component createCityMoneyTextLeaderboard() { int rank = entry.getKey(); String cityName = entry.getValue().getKey(); String money = entry.getValue().getValue(); + + if (cityName == null || money == null) continue; + Component line = Component.text("\n#") .color(getRankColor(rank)) .append(Component.text(rank).color(getRankColor(rank))) @@ -188,6 +197,9 @@ public static Component createPlayTimeTextLeaderboard() { int rank = entry.getKey(); String playerName = entry.getValue().getKey(); String time = entry.getValue().getValue(); + + if (playerName == null || time == null) continue; + Component line = Component.text("\n#") .color(getRankColor(rank)) .append(Component.text(rank).color(getRankColor(rank))) @@ -214,6 +226,9 @@ public static Component createPumpkinCountTextLeaderboard() { int rank = entry.getKey(); String playerName = entry.getValue().getKey(); String pumpkinCount = entry.getValue().getValue(); + + if (playerName == null || pumpkinCount == null) continue; + Component line = Component.text("\n#") .color(getRankColor(rank)) .append(Component.text(rank).color(getRankColor(rank))) From c05579ec96e5faee920ccdcbf2ae006a88c09221 Mon Sep 17 00:00:00 2001 From: iambibi_ <89582596+iambibi@users.noreply.github.com> Date: Thu, 19 Feb 2026 11:01:01 +0100 Subject: [PATCH 3/3] fix: FancyNpcsPlugin is null --- .../scoreboards/sb/MainScoreboard.java | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/src/main/java/fr/openmc/core/features/displays/scoreboards/sb/MainScoreboard.java b/src/main/java/fr/openmc/core/features/displays/scoreboards/sb/MainScoreboard.java index 89e7b63db..33ba1ebc2 100644 --- a/src/main/java/fr/openmc/core/features/displays/scoreboards/sb/MainScoreboard.java +++ b/src/main/java/fr/openmc/core/features/displays/scoreboards/sb/MainScoreboard.java @@ -3,6 +3,7 @@ import de.oliver.fancynpcs.api.FancyNpcsPlugin; import de.oliver.fancynpcs.api.Npc; import de.oliver.fancynpcs.api.NpcManager; +import fr.openmc.api.hooks.FancyNpcsHook; import fr.openmc.api.hooks.LuckPermsHook; import fr.openmc.api.hooks.WorldGuardHook; import fr.openmc.api.scoreboard.SternalBoard; @@ -61,9 +62,6 @@ public void update(Player player, SternalBoard board) { } public static List getDefaultLines(Player player) { - NpcManager npcManager = FancyNpcsPlugin.get().getNpcManager(); - Npc halloweenNPC = npcManager.getNpc("halloween_pumpkin_deposit_npc"); - Component rank = LuckPermsHook.isHasLuckPerms() ? Component.text(LuckPermsHook.getFormattedPAPIPrefix(player)) : Component.text(textToSmall("aucun")).color(TextColor.color(0xFF1FCC)); @@ -102,13 +100,18 @@ public static List getDefaultLines(Player player) { .appendSpace() .append(text(textToSmall(location)).color(TextColor.color(0xFF06DC))) ); - if (halloweenNPC != null) { - String pumpkinCount = EconomyManager.getFormattedSimplifiedNumber(HalloweenManager.getPumpkinCount(player.getUniqueId())); - lines.add(text(" • ", NamedTextColor.DARK_GRAY) - .append(text(textToSmall("citrouilles:"), NamedTextColor.GRAY)) - .appendSpace() - .append(text(textToSmall(pumpkinCount)).color(TextColor.color(0xFF7518))) - ); + + if (FancyNpcsHook.isHasFancyNpc()) { + NpcManager npcManager = FancyNpcsPlugin.get().getNpcManager(); + Npc halloweenNPC = npcManager.getNpc("halloween_pumpkin_deposit_npc"); + if (halloweenNPC != null) { + String pumpkinCount = EconomyManager.getFormattedSimplifiedNumber(HalloweenManager.getPumpkinCount(player.getUniqueId())); + lines.add(text(" • ", NamedTextColor.DARK_GRAY) + .append(text(textToSmall("citrouilles:"), NamedTextColor.GRAY)) + .appendSpace() + .append(text(textToSmall(pumpkinCount)).color(TextColor.color(0xFF7518))) + ); + } } lines.add(newline());