From 84860bae9bc9b73dacbbe2ca7db0dcc69404e728 Mon Sep 17 00:00:00 2001 From: iambibi_ <89582596+iambibi@users.noreply.github.com> Date: Sun, 30 Aug 2026 23:15:24 +0200 Subject: [PATCH 01/28] feat: reactived experimental features --- src/main/java/fr/openmc/core/OMCPlugin.java | 10 +++--- .../fr/openmc/core/hooks/BedrockHook.java | 33 ++++++++++--------- src/main/resources/paper-plugin.yml | 18 +++++----- 3 files changed, 31 insertions(+), 30 deletions(-) diff --git a/src/main/java/fr/openmc/core/OMCPlugin.java b/src/main/java/fr/openmc/core/OMCPlugin.java index 4c3fee7c0..09e034d0a 100644 --- a/src/main/java/fr/openmc/core/OMCPlugin.java +++ b/src/main/java/fr/openmc/core/OMCPlugin.java @@ -221,11 +221,11 @@ public void loadAfterItemsAdder() { ItemsAddersListener.setLoaded(true); // todo: a rewrite lors registre hook et features -// try { -// new BedrockHook().startInit(); -// } catch (NoClassDefFoundError e) { -// OMCLogger.error("Hook BedrockHook désactivé (package non trouvé) " + e.getMessage()); -// } + try { + new BedrockHook().startInit(); + } catch (NoClassDefFoundError e) { + OMCLogger.error("Hook BedrockHook désactivé (package non trouvé) " + e.getMessage()); + } /* LOAD ITEMS ADDER CONTENTS */ ItemsAdderHook.loadContents(); diff --git a/src/main/java/fr/openmc/core/hooks/BedrockHook.java b/src/main/java/fr/openmc/core/hooks/BedrockHook.java index d0631c4be..a4d6d949e 100644 --- a/src/main/java/fr/openmc/core/hooks/BedrockHook.java +++ b/src/main/java/fr/openmc/core/hooks/BedrockHook.java @@ -1,15 +1,18 @@ package fr.openmc.core.hooks; import fr.openmc.core.bootstrap.hooks.Hooks; +import fr.openmc.riftengine.core.RiftRegistry; +import fr.openmc.riftengine.core.registry.glyphs.Glyph; +import lombok.Getter; import org.bukkit.entity.Player; -//import org.geysermc.floodgate.api.FloodgateApi; -//import org.geysermc.geyser.api.GeyserApi; +import org.geysermc.floodgate.api.FloodgateApi; +import org.geysermc.geyser.api.GeyserApi; import java.util.Set; public class BedrockHook extends Hooks { public static boolean isEnabled() { - return false; // return Hooks.isEnabled(FancyNpcsHook.class); + return Hooks.isEnabled(FancyNpcsHook.class); } @Override @@ -17,15 +20,15 @@ protected Set getPluginsName() { return Set.of("Geyser-Spigot", "floodgate", "RiftEngine"); } -// @Getter -// private static GeyserApi geyserApi; -// @Getter -// private static FloodgateApi floodgateApi; + @Getter + private static GeyserApi geyserApi; + @Getter + private static FloodgateApi floodgateApi; @Override public void init() { -// floodgateApi = FloodgateApi.getInstance(); -// geyserApi = GeyserApi.api(); + floodgateApi = FloodgateApi.getInstance(); + geyserApi = GeyserApi.api(); } /** @@ -35,15 +38,13 @@ public void init() { */ public static boolean isBedrockPlayer(Player player) { if (!isEnabled()) return false; - return false; -// return floodgateApi.isFloodgatePlayer(player.getUniqueId()); + return floodgateApi.isFloodgatePlayer(player.getUniqueId()); } public static Character getGlyph(String namespacedId) { -// Glyph glyph = RiftRegistry.GLYPHS.get(namespacedId).orElse(null); -// if (glyph == null) return null; -// -// return glyph.getBedrockChar(); - return null; + Glyph glyph = RiftRegistry.GLYPHS.get(namespacedId).orElse(null); + if (glyph == null) return null; + + return glyph.getBedrockChar(); } } diff --git a/src/main/resources/paper-plugin.yml b/src/main/resources/paper-plugin.yml index 9fc4f692d..9c063effe 100644 --- a/src/main/resources/paper-plugin.yml +++ b/src/main/resources/paper-plugin.yml @@ -30,15 +30,15 @@ dependencies: FastAsyncWorldEdit: load: BEFORE required: false -# Geyser-Spigot: -# load: BEFORE -# required: false -# floodgate: -# load: BEFORE -# required: false -# RiftEngine: -# load: AFTER -# required: false + Geyser-Spigot: + load: BEFORE + required: false + floodgate: + load: BEFORE + required: false + RiftEngine: + load: AFTER + required: false prefix: OMC authors: [ La communauté ] From 2e92b9f94e02b00b6cf1883ddbf75b8b3e76a217 Mon Sep 17 00:00:00 2001 From: iambibi_ <89582596+iambibi@users.noreply.github.com> Date: Mon, 31 Aug 2026 15:10:21 +0200 Subject: [PATCH 02/28] fix: rank show but null --- .../scoreboards/sb/MainScoreboard.java | 18 ++++---- .../fr/openmc/core/hooks/LuckPermsHook.java | 4 +- .../core/listeners/AsyncChatListener.java | 3 +- .../listeners/JoinQuitMessageListener.java | 41 ++++++++++--------- 4 files changed, 36 insertions(+), 30 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 f953efcde..60036bdcb 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 @@ -96,9 +96,9 @@ public void update(Player player, SternalBoard board) { } public static List getDefaultLines(Player player, boolean inWar) { - Component rank = LuckPermsHook.isEnable() - ? Component.text(LuckPermsHook.getFormattedPAPIPrefix(player)) - : TranslationManager.translation("feature.displays.scoreboard.rank.none", true).color(TextColor.color(0xFF1FCC)); + String rank = LuckPermsHook.isEnable() + ? LuckPermsHook.getFormattedPAPIPrefix(player) + : null; City city = CityManager.getPlayerCity(player.getUniqueId()); @@ -118,11 +118,13 @@ public static List getDefaultLines(Player player, boolean inWar) { lines.add(MiniMessage.miniMessage().deserialize( "%s".formatted( player.getName())).decoration(TextDecoration.BOLD, true)); - lines.add(text(" " + CharRemplacementUtils.getPointChar(player) + " ", NamedTextColor.DARK_GRAY) - .append(TranslationManager.translation(player, "feature.displays.scoreboard.rank.label", true).color(NamedTextColor.GRAY)) - .appendSpace() - .append(rank) - ); + if (rank != null) { + lines.add(text(" " + CharRemplacementUtils.getPointChar(player) + " ", NamedTextColor.DARK_GRAY) + .append(TranslationManager.translation(player, "feature.displays.scoreboard.rank.label", true).color(NamedTextColor.GRAY)) + .appendSpace() + .append(Component.text(rank)) + ); + } lines.add(text(" " + CharRemplacementUtils.getPointChar(player) + " ", NamedTextColor.DARK_GRAY) .append(TranslationManager.translation(player, "feature.displays.scoreboard.city.label", true).color(NamedTextColor.GRAY)) .appendSpace() diff --git a/src/main/java/fr/openmc/core/hooks/LuckPermsHook.java b/src/main/java/fr/openmc/core/hooks/LuckPermsHook.java index ebf7173b9..ea3ef51fc 100644 --- a/src/main/java/fr/openmc/core/hooks/LuckPermsHook.java +++ b/src/main/java/fr/openmc/core/hooks/LuckPermsHook.java @@ -55,10 +55,10 @@ public static String getPrefix(Player player) { } public static String getFormattedPAPIPrefix(Player player) { - if (!isEnable()) return ""; + if (!isEnable()) return null; String prefix = getPrefix(player); - if (prefix == null || prefix.isEmpty()) return ""; + if (prefix == null || prefix.isEmpty()) return null; String formattedPrefix = prefix.replace("&", "§"); if (ItemsAdderHook.isEnable()) { diff --git a/src/main/java/fr/openmc/core/listeners/AsyncChatListener.java b/src/main/java/fr/openmc/core/listeners/AsyncChatListener.java index 60ff29faa..e4fd2b9b8 100644 --- a/src/main/java/fr/openmc/core/listeners/AsyncChatListener.java +++ b/src/main/java/fr/openmc/core/listeners/AsyncChatListener.java @@ -34,9 +34,10 @@ public void onChat(AsyncChatEvent event) { final Player player = event.getPlayer(); final CachedMetaData metaData = this.luckperms.getPlayerAdapter(Player.class).getMetaData(player); + String prefix = LuckPermsHook.getFormattedPAPIPrefix(player); String message = PlainTextComponentSerializer.plainText().serialize(event.message()); String rawMessage = plugin.getConfig().getString("chat.message", "{prefix}{name}§7: {message}") - .replace("{prefix}", LuckPermsHook.getFormattedPAPIPrefix(player)) + .replace("{prefix}", prefix != null ? prefix : "") .replace("{suffix}", metaData.getSuffix() != null ? metaData.getSuffix() : "") .replace("{name}", player.getName()) .replace("{message}", message); diff --git a/src/main/java/fr/openmc/core/listeners/JoinQuitMessageListener.java b/src/main/java/fr/openmc/core/listeners/JoinQuitMessageListener.java index e47919b36..d09ae3598 100644 --- a/src/main/java/fr/openmc/core/listeners/JoinQuitMessageListener.java +++ b/src/main/java/fr/openmc/core/listeners/JoinQuitMessageListener.java @@ -45,6 +45,7 @@ public void onPlayerJoin(PlayerJoinEvent event) { MessagesManager.sendMessage(player, TranslationManager.translation("core.player.join.welcome"), Prefix.OPENMC, MessageType.INFO, false); TabList.updateTabList(player); + String prefix = LuckPermsHook.getFormattedPAPIPrefix(player); FriendManager.getFriendsAsync(player.getUniqueId()).thenAccept(friendsUUIDS -> { for (UUID friendUUID : friendsUUIDS) { @@ -52,7 +53,7 @@ public void onPlayerJoin(PlayerJoinEvent event) { if (friend != null && friend.isOnline() && !friend.hasMetadata(OMCPlugin.VANISH_META_KEY)) { MessagesManager.sendMessage(friend, TranslationManager.translation( "core.player.join.friend_online", - Component.text(LuckPermsHook.getFormattedPAPIPrefix(player) + player.getName()).color(NamedTextColor.GREEN) + Component.text((prefix != null ? prefix : "") + player.getName()).color(NamedTextColor.GREEN) ), Prefix.FRIEND, MessageType.NONE, true); } } @@ -68,23 +69,22 @@ public void onPlayerJoin(PlayerJoinEvent event) { continue; int pendingRewardsNumber = quest.getPendingRewardTiers(player.getUniqueId()).size(); - Bukkit.getScheduler().runTask(OMCPlugin.getInstance(), () -> { - MessagesManager.sendMessage(player, - TranslationManager.translation("core.player.join.quest_reward", Component.text(pendingRewardsNumber)) - .append(Component.text(" ")) - .append(TranslationManager.translation("core.player.join.quest_reward_click")) - .clickEvent(ClickEvent.runCommand("/quest")), - Prefix.QUEST, - MessageType.INFO, - true); - }); + Bukkit.getScheduler().runTask(OMCPlugin.getInstance(), () -> + MessagesManager.sendMessage(player, + TranslationManager.translation("core.player.join.quest_reward", Component.text(pendingRewardsNumber)) + .append(Component.text(" ")) + .append(TranslationManager.translation("core.player.join.quest_reward_click")) + .clickEvent(ClickEvent.runCommand("/quest")), + Prefix.QUEST, + MessageType.INFO, + true)); } GitHubHook.refreshContributorId(player.getUniqueId()); }); if (!player.hasMetadata(OMCPlugin.VANISH_META_KEY)) - event.joinMessage(Component.text(JOIN_MESSAGE.formatted(LuckPermsHook.getFormattedPAPIPrefix(player), player.getName()))); + event.joinMessage(Component.text(JOIN_MESSAGE.formatted(prefix != null ? prefix : "", player.getName()))); // Adjust player's spawn location if (!player.hasPlayedBefore()) { @@ -111,13 +111,14 @@ public void onPlayerQuit(PlayerQuitEvent event) { Bukkit.getScheduler().runTaskAsynchronously(OMCPlugin.getInstance(), () -> QuestsManager.saveQuests(player.getUniqueId())); + String prefix = LuckPermsHook.getFormattedPAPIPrefix(player); FriendManager.getFriendsAsync(player.getUniqueId()).thenAccept(friendsUUIDS -> { for (UUID friendUUID : friendsUUIDS) { final Player friend = player.getServer().getPlayer(friendUUID); if (friend != null && friend.isOnline() && !friend.hasMetadata(OMCPlugin.VANISH_META_KEY)) { MessagesManager.sendMessage(friend, TranslationManager.translation( "core.player.quit.friend_offline", - Component.text(LuckPermsHook.getFormattedPAPIPrefix(player) + player.getName()).color(NamedTextColor.YELLOW) + Component.text((prefix != null ? prefix : "") + player.getName()).color(NamedTextColor.YELLOW) ), Prefix.FRIEND, MessageType.NONE, true); } } @@ -128,11 +129,13 @@ public void onPlayerQuit(PlayerQuitEvent event) { if (TPAManager.requesterHasPendingRequest(player)) { Player targetTPA = TPAManager.getTargetByRequester(player); - TPAManager.removeRequest(player, targetTPA); - MessagesManager.sendMessage(targetTPA, TranslationManager.translation( - "core.player.tpa.expired_target", - Component.text(player.getName()).color(NamedTextColor.GOLD) - ), Prefix.OPENMC, MessageType.INFO, true); + if (targetTPA != null) { + TPAManager.removeRequest(player, targetTPA); + MessagesManager.sendMessage(targetTPA, TranslationManager.translation( + "core.player.tpa.expired_target", + Component.text(player.getName()).color(NamedTextColor.GOLD) + ), Prefix.OPENMC, MessageType.INFO, true); + } } else if (TPAManager.hasPendingRequest(player)) { for (Player requester : TPAManager.getRequesters(player)) { TPAManager.removeRequest(requester, player); @@ -144,7 +147,7 @@ public void onPlayerQuit(PlayerQuitEvent event) { } if (!player.hasMetadata(OMCPlugin.VANISH_META_KEY)) - event.quitMessage(Component.text(QUIT_MESSAGE.formatted(LuckPermsHook.getFormattedPAPIPrefix(player), player.getName()))); + event.quitMessage(Component.text(QUIT_MESSAGE.formatted(prefix != null ? prefix : "", player.getName()))); } } From 564fab2da6751623a33ed1eea6629c00715c4036 Mon Sep 17 00:00:00 2001 From: iambibi_ <89582596+iambibi@users.noreply.github.com> Date: Fri, 4 Sep 2026 20:10:49 +0200 Subject: [PATCH 03/28] fix: to small --- .../java/fr/openmc/core/utils/text/fonts/SmallCapsUtils.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/fr/openmc/core/utils/text/fonts/SmallCapsUtils.java b/src/main/java/fr/openmc/core/utils/text/fonts/SmallCapsUtils.java index ccc30bc38..28f98dc4c 100644 --- a/src/main/java/fr/openmc/core/utils/text/fonts/SmallCapsUtils.java +++ b/src/main/java/fr/openmc/core/utils/text/fonts/SmallCapsUtils.java @@ -13,7 +13,7 @@ public class SmallCapsUtils { public final static Key SMALL_CAPS_FONT = Key.key("omc_fonts", "small_caps"); public static Component toSmall(Player player, String text){ - Component component = Component.text(text.toLowerCase()); + Component component = Component.text(text); return BedrockHook.isBedrockPlayer(player) ? component : component.font(SMALL_CAPS_FONT); } From 98d704f847fa2f725df00efd18350ed73dd6b8bc Mon Sep 17 00:00:00 2001 From: iambibi_ <89582596+iambibi@users.noreply.github.com> Date: Sat, 12 Sep 2026 18:39:55 +0200 Subject: [PATCH 04/28] fix: invalid caracter on bedrock with currency bidule la --- .../core/features/bits/BitsManager.java | 11 ++------- .../core/features/city/menu/CityTopMenu.java | 2 +- .../city/menu/list/CityListDetailsMenu.java | 2 +- .../features/city/menu/list/CityListMenu.java | 2 +- .../menu/main/buttons/NotationsButton.java | 2 +- .../city/sub/bank/CityBankManager.java | 2 +- .../sub/bank/menu/CityBankDepositMenu.java | 4 ++-- .../city/sub/bank/menu/CityBankMenu.java | 2 +- .../sub/bank/menu/CityBankWithdrawMenu.java | 4 ++-- .../city/sub/milestone/CityLevels.java | 16 ++++++------- .../features/city/sub/war/WarManager.java | 8 +++---- .../city/sub/war/menu/main/MainWarMenu.java | 2 +- .../sub/war/menu/main/WarCityDetailsMenu.java | 2 +- .../scoreboards/sb/MainScoreboard.java | 4 ++-- .../core/features/economy/BankManager.java | 4 ++-- .../core/features/economy/EconomyManager.java | 23 +++---------------- .../economy/commands/BankCommands.java | 2 +- .../economy/menu/PersonalBankDepositMenu.java | 4 ++-- .../economy/menu/PersonalBankMenu.java | 4 ++-- .../menu/PersonalBankWithdrawMenu.java | 4 ++-- .../leaderboards/LeaderboardManager.java | 6 ++--- .../features/quests/menus/QuestsMenu.java | 4 ++-- .../quests/rewards/QuestMoneyReward.java | 2 +- .../core/listeners/PlayerDeathListener.java | 4 ++-- .../economy/EconomyFormattingTest.java | 16 ++++++------- 25 files changed, 56 insertions(+), 80 deletions(-) diff --git a/src/main/java/fr/openmc/core/features/bits/BitsManager.java b/src/main/java/fr/openmc/core/features/bits/BitsManager.java index 14ebb9cba..a57e2ece1 100644 --- a/src/main/java/fr/openmc/core/features/bits/BitsManager.java +++ b/src/main/java/fr/openmc/core/features/bits/BitsManager.java @@ -14,6 +14,7 @@ import fr.openmc.core.features.bits.commands.BitsCommands; import fr.openmc.core.features.bits.models.BitsPlayer; import fr.openmc.core.features.city.sub.bank.CityBankManager; +import fr.openmc.core.features.economy.EconomyManager; import fr.openmc.core.hooks.github.GitHubHook; import fr.openmc.core.hooks.github.models.ContributorStats; import fr.openmc.core.hooks.itemsadder.ItemsAdderHook; @@ -21,9 +22,7 @@ import org.bukkit.Bukkit; import org.bukkit.scheduler.BukkitTask; -import java.math.BigDecimal; import java.sql.SQLException; -import java.text.NumberFormat; import java.util.*; @Credit(developers = {"iambibi_"}) @@ -117,13 +116,7 @@ public static BitsPlayer getBitsPlayer(UUID playerUUID) { } public static String getFormattedBits(UUID playerUUID) { - String balance = String.valueOf(getBits(playerUUID)); - Currency currency = Currency.getInstance(Locale.FRANCE); - NumberFormat format = NumberFormat.getCurrencyInstance(Locale.FRANCE); - format.setCurrency(currency); - BigDecimal bd = new BigDecimal(balance); - return format.format(bd).replace(NumberFormat.getCurrencyInstance(Locale.FRANCE).getCurrency().getSymbol(), - getBitsIcon()); + return EconomyManager.getFormattedNumber(getBits(playerUUID)); } public static String getBitsIcon() { diff --git a/src/main/java/fr/openmc/core/features/city/menu/CityTopMenu.java b/src/main/java/fr/openmc/core/features/city/menu/CityTopMenu.java index f037be95b..fddc3665a 100644 --- a/src/main/java/fr/openmc/core/features/city/menu/CityTopMenu.java +++ b/src/main/java/fr/openmc/core/features/city/menu/CityTopMenu.java @@ -90,7 +90,7 @@ public List getItems() { Component membersCurrent = Component.text(city.getMembers().size()).color(NamedTextColor.GREEN); Component membersLimit = Component.text(MemberLimitRewards.getMemberLimit(city.getLevel())).color(NamedTextColor.GREEN); Component areaComponent = Component.text(city.getChunks().size()).color(NamedTextColor.GOLD); - Component wealthComponent = Component.text(EconomyManager.getFormattedSimplifiedNumber(city.getBalance())).color(NamedTextColor.GOLD); + Component wealthComponent = Component.text(EconomyManager.getFormattedNumber(city.getBalance())).color(NamedTextColor.GOLD); Component wealthIcon = Component.text(EconomyManager.getEconomyIcon()).color(NamedTextColor.GOLD); Component powerComponent = Component.text(city.getPowerPoints()).color(NamedTextColor.RED); diff --git a/src/main/java/fr/openmc/core/features/city/menu/list/CityListDetailsMenu.java b/src/main/java/fr/openmc/core/features/city/menu/list/CityListDetailsMenu.java index ea01d3e67..e247f544d 100644 --- a/src/main/java/fr/openmc/core/features/city/menu/list/CityListDetailsMenu.java +++ b/src/main/java/fr/openmc/core/features/city/menu/list/CityListDetailsMenu.java @@ -158,7 +158,7 @@ public void onInventoryClick(InventoryClickEvent inventoryClickEvent) { map.put(22, new ItemMenuBuilder(this, new ItemStack(Material.DIAMOND), itemMeta -> itemMeta.displayName(TranslationManager.translation( "feature.city.menus.list.details.wealth", - Component.text(EconomyManager.getFormattedSimplifiedNumber(city.getBalance())).color(NamedTextColor.GOLD), + Component.text(EconomyManager.getFormattedNumber(city.getBalance())).color(NamedTextColor.GOLD), Component.text(EconomyManager.getEconomyIcon()).color(NamedTextColor.GOLD) )))); diff --git a/src/main/java/fr/openmc/core/features/city/menu/list/CityListMenu.java b/src/main/java/fr/openmc/core/features/city/menu/list/CityListMenu.java index d73b43143..c55feddb8 100644 --- a/src/main/java/fr/openmc/core/features/city/menu/list/CityListMenu.java +++ b/src/main/java/fr/openmc/core/features/city/menu/list/CityListMenu.java @@ -87,7 +87,7 @@ public List getItems() { Component membersLimit = Component.text(MemberLimitRewards.getMemberLimit(city.getLevel())).color(NamedTextColor.GREEN); Component membersSuffix = Component.text(city.getMembers().size() > 1 ? "s" : ""); Component typeComponent = city.getType().getDisplayName(); - Component wealthComponent = Component.text(EconomyManager.getFormattedSimplifiedNumber(city.getBalance())).color(NamedTextColor.GOLD); + Component wealthComponent = Component.text(EconomyManager.getFormattedNumber(city.getBalance())).color(NamedTextColor.GOLD); Component wealthIcon = Component.text(EconomyManager.getEconomyIcon()).color(NamedTextColor.GOLD); if (MayorManager.phaseMayor == 2 && FeaturesRewards.hasUnlockFeature(city, FeaturesRewards.Feature.MAYOR)) { Component mayorCity = city.getMayor() == null diff --git a/src/main/java/fr/openmc/core/features/city/menu/main/buttons/NotationsButton.java b/src/main/java/fr/openmc/core/features/city/menu/main/buttons/NotationsButton.java index 1c0fa881e..e83e7c7c7 100644 --- a/src/main/java/fr/openmc/core/features/city/menu/main/buttons/NotationsButton.java +++ b/src/main/java/fr/openmc/core/features/city/menu/main/buttons/NotationsButton.java @@ -47,7 +47,7 @@ private static List getDynamicLore(City city, CityNotation notation) "feature.city.menus.main.notation.lore", Component.text(Math.floor(notation.getTotalNote())).color(NamedTextColor.BLUE), Component.text(NotationNote.getMaxTotalNote()).color(NamedTextColor.BLUE), - Component.text(EconomyManager.getFormattedSimplifiedNumber(notation.getMoney())).color(NamedTextColor.GOLD), + Component.text(EconomyManager.getFormattedNumber(notation.getMoney())).color(NamedTextColor.GOLD), Component.text(EconomyManager.getEconomyIcon()).color(NamedTextColor.GOLD) ); } else { diff --git a/src/main/java/fr/openmc/core/features/city/sub/bank/CityBankManager.java b/src/main/java/fr/openmc/core/features/city/sub/bank/CityBankManager.java index 82560b5e0..6b04fae0a 100644 --- a/src/main/java/fr/openmc/core/features/city/sub/bank/CityBankManager.java +++ b/src/main/java/fr/openmc/core/features/city/sub/bank/CityBankManager.java @@ -104,7 +104,7 @@ public static void withdrawCityBank(City city, Player player, String input) { MessagesManager.sendMessage(player, TranslationManager.translation( "feature.city.bank.withdraw.success", - Component.text(EconomyManager.getFormattedSimplifiedNumber(amount)).color(NamedTextColor.LIGHT_PURPLE), + Component.text(EconomyManager.getFormattedNumber(amount)).color(NamedTextColor.LIGHT_PURPLE), Component.text(EconomyManager.getEconomyIcon()).color(NamedTextColor.LIGHT_PURPLE) ), Prefix.CITY, MessageType.SUCCESS, false); diff --git a/src/main/java/fr/openmc/core/features/city/sub/bank/menu/CityBankDepositMenu.java b/src/main/java/fr/openmc/core/features/city/sub/bank/menu/CityBankDepositMenu.java index 83009dd08..fc7434d6e 100644 --- a/src/main/java/fr/openmc/core/features/city/sub/bank/menu/CityBankDepositMenu.java +++ b/src/main/java/fr/openmc/core/features/city/sub/bank/menu/CityBankDepositMenu.java @@ -69,7 +69,7 @@ public void onInventoryClick(InventoryClickEvent click) { if (hasPermissionMoneyGive) { loreBankDepositAll = TranslationManager.translationLore( "feature.city.bank.menu.deposit.all.lore", - Component.text(EconomyManager.getFormattedSimplifiedNumber(moneyPlayer)).color(NamedTextColor.LIGHT_PURPLE), + Component.text(EconomyManager.getFormattedNumber(moneyPlayer)).color(NamedTextColor.LIGHT_PURPLE), Component.text(EconomyManager.getEconomyIcon()).color(NamedTextColor.LIGHT_PURPLE) ); } else { @@ -90,7 +90,7 @@ public void onInventoryClick(InventoryClickEvent click) { if (hasPermissionMoneyGive) { loreBankDepositHalf = TranslationManager.translationLore( "feature.city.bank.menu.deposit.half.lore", - Component.text(EconomyManager.getFormattedSimplifiedNumber(halfMoneyPlayer)).color(NamedTextColor.LIGHT_PURPLE), + Component.text(EconomyManager.getFormattedNumber(halfMoneyPlayer)).color(NamedTextColor.LIGHT_PURPLE), Component.text(EconomyManager.getEconomyIcon()).color(NamedTextColor.LIGHT_PURPLE) ); } else { diff --git a/src/main/java/fr/openmc/core/features/city/sub/bank/menu/CityBankMenu.java b/src/main/java/fr/openmc/core/features/city/sub/bank/menu/CityBankMenu.java index b83f93ea3..22048c06c 100644 --- a/src/main/java/fr/openmc/core/features/city/sub/bank/menu/CityBankMenu.java +++ b/src/main/java/fr/openmc/core/features/city/sub/bank/menu/CityBankMenu.java @@ -91,7 +91,7 @@ public void onInventoryClick(InventoryClickEvent click) { itemMeta.itemName(TranslationManager.translation("feature.city.bank.menu.balance.title")); itemMeta.lore(TranslationManager.translationLore( "feature.city.bank.menu.balance.lore", - Component.text(EconomyManager.getFormattedSimplifiedNumber(city.getBalance())).color(NamedTextColor.LIGHT_PURPLE), + Component.text(EconomyManager.getFormattedNumber(city.getBalance())).color(NamedTextColor.LIGHT_PURPLE), Component.text(EconomyManager.getEconomyIcon()).color(NamedTextColor.LIGHT_PURPLE), Component.text(city.calculateCityInterest() * 100 + "%").color(NamedTextColor.AQUA), Component.text(DateUtils.convertSecondToTime(BankManager.getSecondsUntilInterest())).color(NamedTextColor.AQUA) diff --git a/src/main/java/fr/openmc/core/features/city/sub/bank/menu/CityBankWithdrawMenu.java b/src/main/java/fr/openmc/core/features/city/sub/bank/menu/CityBankWithdrawMenu.java index eecccdf65..7a9b793df 100644 --- a/src/main/java/fr/openmc/core/features/city/sub/bank/menu/CityBankWithdrawMenu.java +++ b/src/main/java/fr/openmc/core/features/city/sub/bank/menu/CityBankWithdrawMenu.java @@ -69,7 +69,7 @@ public void onInventoryClick(InventoryClickEvent click) { if (hasPermissionMoneyTake) { loreBankWithdrawAll = TranslationManager.translationLore( "feature.city.bank.menu.withdraw.all.lore", - Component.text(EconomyManager.getFormattedSimplifiedNumber(moneyBankCity)).color(NamedTextColor.LIGHT_PURPLE), + Component.text(EconomyManager.getFormattedNumber(moneyBankCity)).color(NamedTextColor.LIGHT_PURPLE), Component.text(EconomyManager.getEconomyIcon()).color(NamedTextColor.LIGHT_PURPLE) ); } else { @@ -89,7 +89,7 @@ public void onInventoryClick(InventoryClickEvent click) { if (hasPermissionMoneyTake) { loreBankWithdrawHalf = TranslationManager.translationLore( "feature.city.bank.menu.withdraw.half.lore", - Component.text(EconomyManager.getFormattedSimplifiedNumber(halfMoneyBankCity)).color(NamedTextColor.LIGHT_PURPLE), + Component.text(EconomyManager.getFormattedNumber(halfMoneyBankCity)).color(NamedTextColor.LIGHT_PURPLE), Component.text(EconomyManager.getEconomyIcon()).color(NamedTextColor.LIGHT_PURPLE) ); } else { diff --git a/src/main/java/fr/openmc/core/features/city/sub/milestone/CityLevels.java b/src/main/java/fr/openmc/core/features/city/sub/milestone/CityLevels.java index 2c8b9ec57..beb2471a5 100644 --- a/src/main/java/fr/openmc/core/features/city/sub/milestone/CityLevels.java +++ b/src/main/java/fr/openmc/core/features/city/sub/milestone/CityLevels.java @@ -127,7 +127,7 @@ public enum CityLevels { return TranslationManager.translation( "feature.city.levels.requirements.bank.progress", Component.text("5k"), - Component.text(EconomyManager.getFormattedSimplifiedNumber(city.getBalance())) + Component.text(EconomyManager.getFormattedNumber(city.getBalance())) ); } ), @@ -214,7 +214,7 @@ public enum CityLevels { return TranslationManager.translation( "feature.city.levels.requirements.bank.progress", Component.text("15k"), - Component.text(EconomyManager.getFormattedSimplifiedNumber(city.getBalance())) + Component.text(EconomyManager.getFormattedNumber(city.getBalance())) ); } ), @@ -294,7 +294,7 @@ public enum CityLevels { return TranslationManager.translation( "feature.city.levels.requirements.bank.progress", Component.text("20k"), - Component.text(EconomyManager.getFormattedSimplifiedNumber(city.getBalance())) + Component.text(EconomyManager.getFormattedNumber(city.getBalance())) ); } ), @@ -364,7 +364,7 @@ public enum CityLevels { return TranslationManager.translation( "feature.city.levels.requirements.bank.progress", Component.text("30k"), - Component.text(EconomyManager.getFormattedSimplifiedNumber(city.getBalance())) + Component.text(EconomyManager.getFormattedNumber(city.getBalance())) ); } ), @@ -455,7 +455,7 @@ public enum CityLevels { return TranslationManager.translation( "feature.city.levels.requirements.bank.progress", Component.text("40k"), - Component.text(EconomyManager.getFormattedSimplifiedNumber(city.getBalance())) + Component.text(EconomyManager.getFormattedNumber(city.getBalance())) ); } ), @@ -528,7 +528,7 @@ public enum CityLevels { return TranslationManager.translation( "feature.city.levels.requirements.bank.progress", Component.text("60k"), - Component.text(EconomyManager.getFormattedSimplifiedNumber(city.getBalance())) + Component.text(EconomyManager.getFormattedNumber(city.getBalance())) ); } ), @@ -620,7 +620,7 @@ public enum CityLevels { return TranslationManager.translation( "feature.city.levels.requirements.bank.progress", Component.text("80k"), - Component.text(EconomyManager.getFormattedSimplifiedNumber(city.getBalance())) + Component.text(EconomyManager.getFormattedNumber(city.getBalance())) ); } ), @@ -700,7 +700,7 @@ public enum CityLevels { return TranslationManager.translation( "feature.city.levels.requirements.bank.progress", Component.text("200k"), - Component.text(EconomyManager.getFormattedSimplifiedNumber(city.getBalance())) + Component.text(EconomyManager.getFormattedNumber(city.getBalance())) ); } ), diff --git a/src/main/java/fr/openmc/core/features/city/sub/war/WarManager.java b/src/main/java/fr/openmc/core/features/city/sub/war/WarManager.java index 9c79f2939..791c4b011 100644 --- a/src/main/java/fr/openmc/core/features/city/sub/war/WarManager.java +++ b/src/main/java/fr/openmc/core/features/city/sub/war/WarManager.java @@ -332,14 +332,14 @@ public static void broadcastWarResult(War war, City winner, City loser, WinReaso Component rewardMoney = bonusMoney > 0 ? TranslationManager.translation( "feature.city.war.result.reward.money_bonus", - Component.text(EconomyManager.getFormattedSimplifiedNumber(amountStolen) + EconomyManager.getEconomyIcon()) + Component.text(EconomyManager.getFormattedNumber(amountStolen) + EconomyManager.getEconomyIcon()) .color(NamedTextColor.GOLD), - Component.text(EconomyManager.getFormattedSimplifiedNumber(bonusMoney) + EconomyManager.getEconomyIcon()) + Component.text(EconomyManager.getFormattedNumber(bonusMoney) + EconomyManager.getEconomyIcon()) .color(NamedTextColor.GOLD) ) : TranslationManager.translation( "feature.city.war.result.reward.money", - Component.text(EconomyManager.getFormattedSimplifiedNumber(amountStolen) + EconomyManager.getEconomyIcon()) + Component.text(EconomyManager.getFormattedNumber(amountStolen) + EconomyManager.getEconomyIcon()) .color(NamedTextColor.GOLD) ); Component rewardClaims = TranslationManager.translation( @@ -378,7 +378,7 @@ public static void broadcastWarResult(War war, City winner, City loser, WinReaso ); Component lossMoney = TranslationManager.translation( "feature.city.war.result.loss.money", - Component.text(EconomyManager.getFormattedSimplifiedNumber(amountStolen) + EconomyManager.getEconomyIcon()) + Component.text(EconomyManager.getFormattedNumber(amountStolen) + EconomyManager.getEconomyIcon()) .color(NamedTextColor.RED) ); Component lossClaims = TranslationManager.translation( diff --git a/src/main/java/fr/openmc/core/features/city/sub/war/menu/main/MainWarMenu.java b/src/main/java/fr/openmc/core/features/city/sub/war/menu/main/MainWarMenu.java index d80364bf5..fd6943c6c 100644 --- a/src/main/java/fr/openmc/core/features/city/sub/war/menu/main/MainWarMenu.java +++ b/src/main/java/fr/openmc/core/features/city/sub/war/menu/main/MainWarMenu.java @@ -132,7 +132,7 @@ public List getItems() { loreCity.add(TranslationManager.translation( "feature.city.war.menu.main.wealth", - Component.text(EconomyManager.getFormattedSimplifiedNumber(city.getBalance()) + EconomyManager.getEconomyIcon()) + Component.text(EconomyManager.getFormattedNumber(city.getBalance()) + EconomyManager.getEconomyIcon()) .color(NamedTextColor.GOLD) ).color(NamedTextColor.GRAY)); diff --git a/src/main/java/fr/openmc/core/features/city/sub/war/menu/main/WarCityDetailsMenu.java b/src/main/java/fr/openmc/core/features/city/sub/war/menu/main/WarCityDetailsMenu.java index 44ffff6c6..08442549c 100644 --- a/src/main/java/fr/openmc/core/features/city/sub/war/menu/main/WarCityDetailsMenu.java +++ b/src/main/java/fr/openmc/core/features/city/sub/war/menu/main/WarCityDetailsMenu.java @@ -124,7 +124,7 @@ public void onInventoryClick(InventoryClickEvent inventoryClickEvent) { map.put(22, new ItemMenuBuilder(this, new ItemStack(Material.DIAMOND), itemMeta -> itemMeta.displayName(TranslationManager.translation( "feature.city.war.menu.details.wealth", - Component.text(EconomyManager.getFormattedSimplifiedNumber(city.getBalance()) + " " + EconomyManager.getEconomyIcon()) + Component.text(EconomyManager.getFormattedNumber(city.getBalance()) + " " + EconomyManager.getEconomyIcon()) .color(NamedTextColor.GOLD) ).color(NamedTextColor.GRAY)))); 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 60036bdcb..f69407f62 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 @@ -144,7 +144,7 @@ public static List getDefaultLines(Player player, boolean inWar) { lines.add(text(" " + CharRemplacementUtils.getPointChar(player) + " ", NamedTextColor.DARK_GRAY) .append(TranslationManager.translation(player, "feature.displays.scoreboard.bits.label", true).color(NamedTextColor.GRAY)) .appendSpace() - .append(toSmall(player, EconomyManager.getFormattedSimplifiedNumber(bits)).color(TextColor.color(0x07A0F5))) + .append(toSmall(player, EconomyManager.getFormattedNumber(bits)).color(TextColor.color(0x07A0F5))) .appendSpace() .append(text(BitsManager.getBitsIcon())) ); @@ -162,7 +162,7 @@ public static List getDefaultLines(Player player, boolean inWar) { if (npcManager != null) halloweenNPC = npcManager.getNpc("halloween_pumpkin_deposit_npc"); if (halloweenNPC != null) { - String pumpkinCount = EconomyManager.getFormattedSimplifiedNumber(HalloweenManager.getPumpkinCount(player.getUniqueId())); + String pumpkinCount = EconomyManager.getFormattedNumber(HalloweenManager.getPumpkinCount(player.getUniqueId())); lines.add(text(" " + CharRemplacementUtils.getPointChar(player) + " ", NamedTextColor.DARK_GRAY) .append(TranslationManager.translation(player, "feature.displays.scoreboard.pumpkins.label", true).color(NamedTextColor.GRAY)) .appendSpace() diff --git a/src/main/java/fr/openmc/core/features/economy/BankManager.java b/src/main/java/fr/openmc/core/features/economy/BankManager.java index 1664ff486..ce95f0fcb 100644 --- a/src/main/java/fr/openmc/core/features/economy/BankManager.java +++ b/src/main/java/fr/openmc/core/features/economy/BankManager.java @@ -188,7 +188,7 @@ public static void withdraw(UUID playerUUID, String input) { MessagesManager.sendMessage(offlinePlayer, TranslationManager.translation( "feature.economy.bank.withdraw.transferred", - Component.text(EconomyManager.getFormattedSimplifiedNumber(amount)).color(NamedTextColor.LIGHT_PURPLE), + Component.text(EconomyManager.getFormattedNumber(amount)).color(NamedTextColor.LIGHT_PURPLE), Component.text(EconomyManager.getEconomyIcon()) ), Prefix.BANK, MessageType.SUCCESS, false); @@ -241,7 +241,7 @@ public static void applyPlayerInterest(UUID playerUUID) { TranslationManager.translation( "feature.economy.bank.interest.received", Component.text(interest * 100 + "%").color(NamedTextColor.LIGHT_PURPLE), - Component.text(EconomyManager.getFormattedSimplifiedNumber(allowedAmount)).color(NamedTextColor.LIGHT_PURPLE), + Component.text(EconomyManager.getFormattedNumber(allowedAmount)).color(NamedTextColor.LIGHT_PURPLE), Component.text(EconomyManager.getEconomyIcon()) ), Prefix.CITY, MessageType.SUCCESS, false); diff --git a/src/main/java/fr/openmc/core/features/economy/EconomyManager.java b/src/main/java/fr/openmc/core/features/economy/EconomyManager.java index e704c1f8a..a62b76f6a 100644 --- a/src/main/java/fr/openmc/core/features/economy/EconomyManager.java +++ b/src/main/java/fr/openmc/core/features/economy/EconomyManager.java @@ -20,10 +20,8 @@ import org.jetbrains.annotations.NotNull; import javax.annotation.Nullable; -import java.math.BigDecimal; import java.sql.SQLException; import java.text.DecimalFormat; -import java.text.NumberFormat; import java.util.*; @Credit(developers = {"Axeno", "Piquel Chips", "PuppyTransGirl", "Gyro"}) @@ -161,7 +159,7 @@ public static void setBalance(UUID playerUUID, double amount) { public static String getMiniBalance(UUID playerUUID) { double balance = getBalance(playerUUID); - return getFormattedSimplifiedNumber(balance); + return getFormattedNumber(balance); } public static EconomyPlayer getPlayerBank(UUID playerUUID) { @@ -197,25 +195,10 @@ public static Map loadAllBalances() { } public static String getFormattedBalance(UUID playerUUID) { - String balance = String.valueOf(getBalance(playerUUID)); - Currency currency = Currency.getInstance(Locale.FRANCE); - NumberFormat format = NumberFormat.getCurrencyInstance(Locale.FRANCE); - format.setCurrency(currency); - BigDecimal bd = new BigDecimal(balance); - return format.format(bd).replace(NumberFormat.getCurrencyInstance(Locale.FRANCE).getCurrency().getSymbol(), - getEconomyIcon()); + return getFormattedNumber(getBalance(playerUUID)); } - public static String getFormattedNumber(double number) { - Currency currency = Currency.getInstance(Locale.FRANCE); - NumberFormat format = NumberFormat.getCurrencyInstance(Locale.FRANCE); - format.setCurrency(currency); - BigDecimal bd = new BigDecimal(number); - return format.format(bd).replace(NumberFormat.getCurrencyInstance(Locale.FRANCE).getCurrency().getSymbol(), - getEconomyIcon()); - } - - public static String getFormattedSimplifiedNumber(double balance) { + public static String getFormattedNumber(double balance) { if (balance == 0) { return "0"; } diff --git a/src/main/java/fr/openmc/core/features/economy/commands/BankCommands.java b/src/main/java/fr/openmc/core/features/economy/commands/BankCommands.java index 881d76b5d..14b9a1e51 100644 --- a/src/main/java/fr/openmc/core/features/economy/commands/BankCommands.java +++ b/src/main/java/fr/openmc/core/features/economy/commands/BankCommands.java @@ -87,7 +87,7 @@ void withdraw(OMCPlayer player) { player.message().sendInfo( TranslationManager.translation( "feature.economy.bank.command.balance", - Component.text(EconomyManager.getFormattedSimplifiedNumber(balance)).color(NamedTextColor.LIGHT_PURPLE), + Component.text(EconomyManager.getFormattedNumber(balance)).color(NamedTextColor.LIGHT_PURPLE), Component.text(EconomyManager.getEconomyIcon()) ), Prefix.BANK diff --git a/src/main/java/fr/openmc/core/features/economy/menu/PersonalBankDepositMenu.java b/src/main/java/fr/openmc/core/features/economy/menu/PersonalBankDepositMenu.java index e1f487a5b..8cf8f0c0f 100644 --- a/src/main/java/fr/openmc/core/features/economy/menu/PersonalBankDepositMenu.java +++ b/src/main/java/fr/openmc/core/features/economy/menu/PersonalBankDepositMenu.java @@ -59,7 +59,7 @@ public void onInventoryClick(InventoryClickEvent click) { List loreBankDepositAll = TranslationManager.translationLore( "feature.economy.bank.deposit.all.lore", - Component.text(EconomyManager.getFormattedSimplifiedNumber(moneyPlayer)).color(NamedTextColor.LIGHT_PURPLE), + Component.text(EconomyManager.getFormattedNumber(moneyPlayer)).color(NamedTextColor.LIGHT_PURPLE), Component.text(EconomyManager.getEconomyIcon()).decoration(TextDecoration.ITALIC, false) ); @@ -74,7 +74,7 @@ public void onInventoryClick(InventoryClickEvent click) { List loreBankDepositHalf = TranslationManager.translationLore( "feature.economy.bank.deposit.half.lore", - Component.text(EconomyManager.getFormattedSimplifiedNumber(halfMoneyPlayer)).color(NamedTextColor.LIGHT_PURPLE), + Component.text(EconomyManager.getFormattedNumber(halfMoneyPlayer)).color(NamedTextColor.LIGHT_PURPLE), Component.text(EconomyManager.getEconomyIcon()).decoration(TextDecoration.ITALIC, false) ); diff --git a/src/main/java/fr/openmc/core/features/economy/menu/PersonalBankMenu.java b/src/main/java/fr/openmc/core/features/economy/menu/PersonalBankMenu.java index 76b734063..58e653d75 100644 --- a/src/main/java/fr/openmc/core/features/economy/menu/PersonalBankMenu.java +++ b/src/main/java/fr/openmc/core/features/economy/menu/PersonalBankMenu.java @@ -83,9 +83,9 @@ public void onInventoryClick(InventoryClickEvent click) { itemMeta.itemName(TranslationManager.translation("feature.economy.bank.menu.balance.name")); itemMeta.lore(TranslationManager.translationLore( "feature.economy.bank.menu.balance.lore", - Component.text(EconomyManager.getFormattedSimplifiedNumber(BankManager.getBankBalance(player.getUniqueId()))).color(NamedTextColor.LIGHT_PURPLE), + Component.text(EconomyManager.getFormattedNumber(BankManager.getBankBalance(player.getUniqueId()))).color(NamedTextColor.LIGHT_PURPLE), Component.text(EconomyManager.getEconomyIcon()).decoration(TextDecoration.ITALIC, false), - Component.text(EconomyManager.getFormattedSimplifiedNumber(PlayerBankLimitRewards.getBankBalanceLimit(playerCity.getLevel()))).color(NamedTextColor.LIGHT_PURPLE), + Component.text(EconomyManager.getFormattedNumber(PlayerBankLimitRewards.getBankBalanceLimit(playerCity.getLevel()))).color(NamedTextColor.LIGHT_PURPLE), Component.text(EconomyManager.getEconomyIcon()).decoration(TextDecoration.ITALIC, false), Component.text(BankManager.calculatePlayerInterest(player.getUniqueId()) * 100 + "%").color(NamedTextColor.AQUA), Component.text(DateUtils.convertSecondToTime(BankManager.getSecondsUntilInterest())).color(NamedTextColor.AQUA) diff --git a/src/main/java/fr/openmc/core/features/economy/menu/PersonalBankWithdrawMenu.java b/src/main/java/fr/openmc/core/features/economy/menu/PersonalBankWithdrawMenu.java index 22eb007be..20ed7479f 100644 --- a/src/main/java/fr/openmc/core/features/economy/menu/PersonalBankWithdrawMenu.java +++ b/src/main/java/fr/openmc/core/features/economy/menu/PersonalBankWithdrawMenu.java @@ -59,7 +59,7 @@ public void onInventoryClick(InventoryClickEvent click) { List loreBankWithdrawAll = TranslationManager.translationLore( "feature.economy.bank.withdraw.all.lore", - Component.text(EconomyManager.getFormattedSimplifiedNumber(moneyBankPlayer)).color(NamedTextColor.LIGHT_PURPLE), + Component.text(EconomyManager.getFormattedNumber(moneyBankPlayer)).color(NamedTextColor.LIGHT_PURPLE), Component.text(EconomyManager.getEconomyIcon()).decoration(TextDecoration.ITALIC, false) ); @@ -73,7 +73,7 @@ public void onInventoryClick(InventoryClickEvent click) { List loreBankWithdrawHalf = TranslationManager.translationLore( "feature.economy.bank.withdraw.half.lore", - Component.text(EconomyManager.getFormattedSimplifiedNumber(halfMoneyBankPlayer)).color(NamedTextColor.LIGHT_PURPLE), + Component.text(EconomyManager.getFormattedNumber(halfMoneyBankPlayer)).color(NamedTextColor.LIGHT_PURPLE), Component.text(EconomyManager.getEconomyIcon()).decoration(TextDecoration.ITALIC, false) ); 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 e570a856d..86716f3cd 100644 --- a/src/main/java/fr/openmc/core/features/leaderboards/LeaderboardManager.java +++ b/src/main/java/fr/openmc/core/features/leaderboards/LeaderboardManager.java @@ -488,7 +488,7 @@ public static void updatePlayerMoneyMap() { .limit(10) .toList()) { String playerName = CachePlayerName.getName(entry.getKey()); - String formattedBalance = EconomyManager.getFormattedSimplifiedNumber(entry.getValue()); + String formattedBalance = EconomyManager.getFormattedNumber(entry.getValue()); newMap.put(rank++, new AbstractMap.SimpleEntry<>(playerName, formattedBalance)); } @@ -506,7 +506,7 @@ public static void updateCityMoneyMap() { .limit(10) .toList()) { String cityName = city.getName(); - String cityBalance = EconomyManager.getFormattedSimplifiedNumber(city.getBalance()); + String cityBalance = EconomyManager.getFormattedNumber(city.getBalance()); newMap.put(rank++, new AbstractMap.SimpleEntry<>(cityName, cityBalance)); } villeMoneyMap = newMap; @@ -545,7 +545,7 @@ public static void updatePumpkinCountMap() { .limit(10) .toList()) { String playerName = CachePlayerName.getName(entry.getKey()); - String formattedPumpkinCount = EconomyManager.getFormattedSimplifiedNumber(entry.getValue().getPumpkinCount()); + String formattedPumpkinCount = EconomyManager.getFormattedNumber(entry.getValue().getPumpkinCount()); newMap.put(rank++, new AbstractMap.SimpleEntry<>(playerName, formattedPumpkinCount)); } pumpkinCountMap = newMap; diff --git a/src/main/java/fr/openmc/core/features/quests/menus/QuestsMenu.java b/src/main/java/fr/openmc/core/features/quests/menus/QuestsMenu.java index 8873b1a54..f541e53c2 100644 --- a/src/main/java/fr/openmc/core/features/quests/menus/QuestsMenu.java +++ b/src/main/java/fr/openmc/core/features/quests/menus/QuestsMenu.java @@ -246,7 +246,7 @@ private void createItems(Quest quest, ItemStack item, ItemMeta meta) { .decoration(TextDecoration.ITALIC, false)); } else if (reward instanceof QuestMoneyReward(double amount)) { lore.add(Component.text(" - ", NamedTextColor.DARK_GRAY) - .append(Component.text(EconomyManager.getFormattedSimplifiedNumber(amount), NamedTextColor.GOLD)) + .append(Component.text(EconomyManager.getFormattedNumber(amount), NamedTextColor.GOLD)) .append(Component.space()) .append(Component.text(EconomyManager.getEconomyIcon(), NamedTextColor.WHITE)) .decoration(TextDecoration.ITALIC, false)); @@ -272,7 +272,7 @@ private void createItems(Quest quest, ItemStack item, ItemMeta meta) { .decoration(TextDecoration.ITALIC, false)); } else if (reward instanceof QuestMoneyReward(double amount)) { lore.add(Component.text(" - ", NamedTextColor.DARK_GRAY) - .append(Component.text(EconomyManager.getFormattedSimplifiedNumber(amount), NamedTextColor.GOLD)) + .append(Component.text(EconomyManager.getFormattedNumber(amount), NamedTextColor.GOLD)) .append(Component.space()) .append(Component.text(EconomyManager.getEconomyIcon(), NamedTextColor.WHITE)) .decoration(TextDecoration.ITALIC, false)); diff --git a/src/main/java/fr/openmc/core/features/quests/rewards/QuestMoneyReward.java b/src/main/java/fr/openmc/core/features/quests/rewards/QuestMoneyReward.java index 948627b11..82c8ad89e 100644 --- a/src/main/java/fr/openmc/core/features/quests/rewards/QuestMoneyReward.java +++ b/src/main/java/fr/openmc/core/features/quests/rewards/QuestMoneyReward.java @@ -24,7 +24,7 @@ public record QuestMoneyReward(double amount) implements QuestReward { @Override public void giveReward(Player player) { EconomyManager.addBalance(player.getUniqueId(), amount, "Récompense de quête"); - Component amountComponent = Component.text(EconomyManager.getFormattedSimplifiedNumber(amount) + " " + EconomyManager.getEconomyIcon()) + Component amountComponent = Component.text(EconomyManager.getFormattedNumber(amount) + " " + EconomyManager.getEconomyIcon()) .color(NamedTextColor.YELLOW); Component message = TranslationManager.translation("feature.quests.message.money_reward", amountComponent) .color(NamedTextColor.GREEN); diff --git a/src/main/java/fr/openmc/core/listeners/PlayerDeathListener.java b/src/main/java/fr/openmc/core/listeners/PlayerDeathListener.java index 66d21a6d5..7b71e357e 100644 --- a/src/main/java/fr/openmc/core/listeners/PlayerDeathListener.java +++ b/src/main/java/fr/openmc/core/listeners/PlayerDeathListener.java @@ -30,8 +30,8 @@ public void onPlayerDead(PlayerDeathEvent event) { withdrawBalance(player.getUniqueId(), balance * LOSS_MONEY); MessagesManager.sendMessage(player, TranslationManager.translation( "core.player.death.message", - Component.text(getFormattedSimplifiedNumber(balance) + EconomyManager.getEconomyIcon()).color(NamedTextColor.GOLD), - Component.text(getFormattedSimplifiedNumber(balance * LOSS_MONEY) + EconomyManager.getEconomyIcon()).color(NamedTextColor.GOLD) + Component.text(getFormattedNumber(balance) + EconomyManager.getEconomyIcon()).color(NamedTextColor.GOLD), + Component.text(getFormattedNumber(balance * LOSS_MONEY) + EconomyManager.getEconomyIcon()).color(NamedTextColor.GOLD) ), Prefix.OPENMC, MessageType.INFO, false); } diff --git a/src/test/java/fr/openmc/core/features/economy/EconomyFormattingTest.java b/src/test/java/fr/openmc/core/features/economy/EconomyFormattingTest.java index c0443cd71..205694a39 100644 --- a/src/test/java/fr/openmc/core/features/economy/EconomyFormattingTest.java +++ b/src/test/java/fr/openmc/core/features/economy/EconomyFormattingTest.java @@ -17,50 +17,50 @@ static void setUpLocale() { @Test @DisplayName("Format zero balance") void testFormat_Zero() { - Assertions.assertEquals("0", EconomyManager.getFormattedSimplifiedNumber(0)); + Assertions.assertEquals("0", EconomyManager.getFormattedNumber(0)); } @Test @DisplayName("Format small number without suffix") void testFormat_SmallNumber() { - Assertions.assertEquals("500", EconomyManager.getFormattedSimplifiedNumber(500)); + Assertions.assertEquals("500", EconomyManager.getFormattedNumber(500)); } @Test @DisplayName("Format thousands with k suffix") void testFormat_Thousands() { - String result = EconomyManager.getFormattedSimplifiedNumber(1500); + String result = EconomyManager.getFormattedNumber(1500); Assertions.assertEquals("1.5k", result); } @Test @DisplayName("Format exact thousand") void testFormat_ExactThousand() { - Assertions.assertEquals("1k", EconomyManager.getFormattedSimplifiedNumber(1000)); + Assertions.assertEquals("1k", EconomyManager.getFormattedNumber(1000)); } @Test @DisplayName("Format millions with M suffix") void testFormat_Millions() { - Assertions.assertEquals("3M", EconomyManager.getFormattedSimplifiedNumber(3_000_000)); + Assertions.assertEquals("3M", EconomyManager.getFormattedNumber(3_000_000)); } @Test @DisplayName("Format billions with B suffix") void testFormat_Billions() { - Assertions.assertEquals("1B", EconomyManager.getFormattedSimplifiedNumber(1_000_000_000)); + Assertions.assertEquals("1B", EconomyManager.getFormattedNumber(1_000_000_000)); } @Test @DisplayName("Format with decimal truncation") void testFormat_Decimal() { - String result = EconomyManager.getFormattedSimplifiedNumber(2_500_000); + String result = EconomyManager.getFormattedNumber(2_500_000); Assertions.assertEquals("2.5M", result); } @Test @DisplayName("Format number under 1000") void testFormat_Under1000() { - Assertions.assertEquals("999", EconomyManager.getFormattedSimplifiedNumber(999)); + Assertions.assertEquals("999", EconomyManager.getFormattedNumber(999)); } } From 30ecaeebbec96775f566801536d1e739387c2da4 Mon Sep 17 00:00:00 2001 From: iambibi_ <89582596+iambibi@users.noreply.github.com> Date: Sat, 12 Sep 2026 21:26:16 +0200 Subject: [PATCH 05/28] fix: update change every time (hyper casse couille) --- build.gradle | 4 ++-- gradle.properties | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/build.gradle b/build.gradle index 04409aeb8..6271a0db8 100644 --- a/build.gradle +++ b/build.gradle @@ -51,7 +51,7 @@ repositories { } dependencies { - paperweight.paperDevBundle "${minecraftVersion}.build.+" + paperweight.paperDevBundle "${minecraftVersion}.build.${paperVersion}" compileOnly("com.sk89q.worldguard:worldguard-bukkit:${worldguardVersion}") { exclude group: 'com.google.guava', module: 'guava' @@ -85,7 +85,7 @@ dependencies { testImplementation "org.slf4j:slf4j-simple:${slf4jVersion}" testImplementation "org.junit.jupiter:junit-jupiter:${junitVersion}" testRuntimeOnly "org.junit.platform:junit-platform-launcher" - testImplementation paperweight.paperDevBundle("${minecraftVersion}.build.+") + testImplementation paperweight.paperDevBundle("${minecraftVersion}.build.${paperVersion}") testImplementation "org.mockbukkit.mockbukkit:mockbukkit-v26.2:${mockbukkitVersion}" testImplementation "com.h2database:h2:${h2DatabaseVersion}" } diff --git a/gradle.properties b/gradle.properties index 0957c4797..b8814720c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,6 @@ minecraftVersion = 26.2 -paperWeightUserDevVersion = 2.0.0-beta.21 +paperVersion = 118-stable +paperWeightUserDevVersion = 2.0.0-beta.23 # Plugins worldguardVersion = 7.0.16 From 681f39de43f2556fa105c7396e2c29f9b074cd46 Mon Sep 17 00:00:00 2001 From: iambibi <89582596+iambibi@users.noreply.github.com> Date: Sun, 20 Sep 2026 10:41:02 +0200 Subject: [PATCH 06/28] build: fix + enchanced build.gradle --- build.gradle | 18 +++++++++++++----- .../resources/contents/omc_dream/items.yml | 2 +- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/build.gradle b/build.gradle index ab158b26e..bd1433aa6 100644 --- a/build.gradle +++ b/build.gradle @@ -28,26 +28,34 @@ group = 'fr.openmc' repositories { mavenCentral() + // * PlaceholderAPI maven { url "https://repo.extendedclip.com/content/repositories/placeholderapi/" } + // * WorldGuard & WorldEdit maven { url "https://maven.enginehub.org/repo/" } + // * FancyNpc maven { url "https://repo.fancyinnovations.com/releases" } + // * PaperMC maven { url = "https://repo.papermc.io/repository/maven-public/" } + // * GeyserMC + maven { + url "https://repo.opencollab.dev/main/" + } + // * ItemsAdder maven { url "https://maven.devs.beer/" } + // * ProtocolLib maven { url "https://repo.dmulloy2.net/repository/public/" } - // * GeyserMC - //maven {url "https://repo.opencollab.dev/main/"} maven { url "https://jitpack.io" // Toujours à la fin } @@ -71,9 +79,9 @@ dependencies { compileOnly "net.dmulloy2:ProtocolLib:${protocolLibVersion}" // Bedrock Dependencies - //compileOnly files("libs/RiftEngine-${riftEngineVersion}.jar") - //compileOnly "org.geysermc.geyser:api:${geyserApiVersion}" - //compileOnly "org.geysermc.floodgate:api:${floodgateApiVersion}" + compileOnly files("libs/RiftEngine-${riftEngineVersion}.jar") + compileOnly "org.geysermc.geyser:api:${geyserApiVersion}" + compileOnly "org.geysermc.floodgate:api:${floodgateApiVersion}" implementation "org.jetbrains:annotations:${jetbrainsAnnotationsVersion}" implementation "io.github.revxrsal:lamp.common:${revxrsalLampVersion}" diff --git a/src/main/resources/contents/omc_dream/items.yml b/src/main/resources/contents/omc_dream/items.yml index beca51b6a..cd8dcc356 100644 --- a/src/main/resources/contents/omc_dream/items.yml +++ b/src/main/resources/contents/omc_dream/items.yml @@ -173,7 +173,7 @@ items: resource: material: {dream_item_material:coal_burn} generate: false - model_path: "minecraft:item/charcoal" + texture: "minecraft:item/charcoal" tooltip_style: "{dream_rarity:coal_burn}" hard_stone: From 738e91982799c759f8ccf7e23f7f5c919526aa9a Mon Sep 17 00:00:00 2001 From: iambibi <89582596+iambibi@users.noreply.github.com> Date: Sun, 20 Sep 2026 12:02:22 +0200 Subject: [PATCH 07/28] fix: item --- src/main/resources/contents/omc_dream/items.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/resources/contents/omc_dream/items.yml b/src/main/resources/contents/omc_dream/items.yml index cd8dcc356..4afadbdba 100644 --- a/src/main/resources/contents/omc_dream/items.yml +++ b/src/main/resources/contents/omc_dream/items.yml @@ -6,7 +6,7 @@ items: resource: material: {dream_item_material:corrupted_sculk} generate: false - model_path: "minecraft:item/sculk" + model_path: "minecraft:block/sculk" lore: - tooltip_style: "{dream_rarity:corrupted_sculk}" @@ -173,7 +173,7 @@ items: resource: material: {dream_item_material:coal_burn} generate: false - texture: "minecraft:item/charcoal" + model_path: "minecraft:item/charcoal" tooltip_style: "{dream_rarity:coal_burn}" hard_stone: From 299894ef2d75ba9a38515e693b9de8c466e90f9e Mon Sep 17 00:00:00 2001 From: iambibi <89582596+iambibi@users.noreply.github.com> Date: Thu, 15 Oct 2026 11:26:22 +0200 Subject: [PATCH 08/28] build: fix --- local.properties | 2 +- .../events/contents/halloween/managers/HalloweenManager.java | 2 +- .../leaderboards/leaderboards/CityMoneyLeaderBoard.java | 2 +- .../features/leaderboards/leaderboards/MoneyLeaderBoard.java | 3 +-- .../leaderboards/leaderboards/PumpkinCountLeaderBoard.java | 3 +-- .../java/fr/openmc/core/listeners/JoinQuitMessageListener.java | 1 - 6 files changed, 5 insertions(+), 8 deletions(-) diff --git a/local.properties b/local.properties index e483db0bb..3b69739b9 100644 --- a/local.properties +++ b/local.properties @@ -1 +1 @@ -minecraftServerDir=/home/iambibi_/Documents/ServeurMinecraftLocal/26.3-OMC \ No newline at end of file +minecraftServerDir=/home/iambibi_/Documents/ServeurMinecraftLocal/26.3-OMC-Rift \ No newline at end of file diff --git a/src/main/java/fr/openmc/core/features/events/contents/halloween/managers/HalloweenManager.java b/src/main/java/fr/openmc/core/features/events/contents/halloween/managers/HalloweenManager.java index 27a5eaee2..41c42dadc 100644 --- a/src/main/java/fr/openmc/core/features/events/contents/halloween/managers/HalloweenManager.java +++ b/src/main/java/fr/openmc/core/features/events/contents/halloween/managers/HalloweenManager.java @@ -127,7 +127,7 @@ public static void endEvent() { .limit(10) .toList()) { String playerName = CachePlayerName.getName(entry.getKey()); - String formattedPumpkinCount = EconomyManager.getFormattedSimplifiedNumber(entry.getValue().getPumpkinCount()); + String formattedPumpkinCount = EconomyManager.getFormattedNumber(entry.getValue().getPumpkinCount()); newMap.put(rank++, new AbstractMap.SimpleEntry<>(playerName, formattedPumpkinCount)); } diff --git a/src/main/java/fr/openmc/core/features/leaderboards/leaderboards/CityMoneyLeaderBoard.java b/src/main/java/fr/openmc/core/features/leaderboards/leaderboards/CityMoneyLeaderBoard.java index 7bc664c45..f1e606aef 100644 --- a/src/main/java/fr/openmc/core/features/leaderboards/leaderboards/CityMoneyLeaderBoard.java +++ b/src/main/java/fr/openmc/core/features/leaderboards/leaderboards/CityMoneyLeaderBoard.java @@ -39,7 +39,7 @@ public Component createComponent(){ for (int i = 0; i < cities.size(); i++){ City city = cities.get(i); Component rank = Component.text("#" + (i+1)).color(ColorUtils.getRankColor(i+1)); - Component cityBalance = Component.text(EconomyManager.getFormattedSimplifiedNumber(city.getBalance()) + " " + EconomyManager.getEconomyIcon()) + Component cityBalance = Component.text(EconomyManager.getFormattedNumber(city.getBalance()) + " " + EconomyManager.getEconomyIcon()) .color(NamedTextColor.WHITE); text = text.append(Component.text("\n").append(TranslationManager.translation( "feature.leaderboards.line.city_money", diff --git a/src/main/java/fr/openmc/core/features/leaderboards/leaderboards/MoneyLeaderBoard.java b/src/main/java/fr/openmc/core/features/leaderboards/leaderboards/MoneyLeaderBoard.java index 84425d928..8895489e7 100644 --- a/src/main/java/fr/openmc/core/features/leaderboards/leaderboards/MoneyLeaderBoard.java +++ b/src/main/java/fr/openmc/core/features/leaderboards/leaderboards/MoneyLeaderBoard.java @@ -4,7 +4,6 @@ import fr.openmc.core.features.economy.BankManager; import fr.openmc.core.features.economy.EconomyManager; import fr.openmc.core.features.leaderboards.LeaderBoard; -import fr.openmc.core.utils.cache.CachePlayerName; import fr.openmc.core.utils.text.ColorUtils; import fr.openmc.core.utils.text.messages.TranslationManager; import net.kyori.adventure.text.Component; @@ -56,7 +55,7 @@ public Component createComponent() { "feature.leaderboards.line.money", rank, player.getNameWithHead().color(NamedTextColor.LIGHT_PURPLE), - Component.text(EconomyManager.getFormattedSimplifiedNumber(balance.getValue()) + " " + EconomyManager.getEconomyIcon()) + Component.text(EconomyManager.getFormattedNumber(balance.getValue()) + " " + EconomyManager.getEconomyIcon()) .color(NamedTextColor.WHITE) ))); } diff --git a/src/main/java/fr/openmc/core/features/leaderboards/leaderboards/PumpkinCountLeaderBoard.java b/src/main/java/fr/openmc/core/features/leaderboards/leaderboards/PumpkinCountLeaderBoard.java index 2b696b5d1..d62d53e6a 100644 --- a/src/main/java/fr/openmc/core/features/leaderboards/leaderboards/PumpkinCountLeaderBoard.java +++ b/src/main/java/fr/openmc/core/features/leaderboards/leaderboards/PumpkinCountLeaderBoard.java @@ -5,7 +5,6 @@ import fr.openmc.core.features.events.contents.halloween.managers.HalloweenManager; import fr.openmc.core.features.events.contents.halloween.models.HalloweenData; import fr.openmc.core.features.leaderboards.LeaderBoard; -import fr.openmc.core.utils.cache.CachePlayerName; import fr.openmc.core.utils.text.ColorUtils; import fr.openmc.core.utils.text.messages.TranslationManager; import net.kyori.adventure.text.Component; @@ -49,7 +48,7 @@ public Component createComponent() { HalloweenData data = datas.get(i); OMCOfflinePlayer player = OMCOfflinePlayer.of(data.getPlayerUUID()); Component name = player.getNameWithHead(); - String formattedPumpkinCount = EconomyManager.getFormattedSimplifiedNumber(data.getPumpkinCount()); + String formattedPumpkinCount = EconomyManager.getFormattedNumber(data.getPumpkinCount()); Component rank = Component.text("#" + (i+1)).color(ColorUtils.getRankColor(i+1)); text = text.append(Component.text("\n").append(TranslationManager.translation( "feature.leaderboards.line.pumpkin", diff --git a/src/main/java/fr/openmc/core/listeners/JoinQuitMessageListener.java b/src/main/java/fr/openmc/core/listeners/JoinQuitMessageListener.java index 62a2effef..cbdbc2dd8 100644 --- a/src/main/java/fr/openmc/core/listeners/JoinQuitMessageListener.java +++ b/src/main/java/fr/openmc/core/listeners/JoinQuitMessageListener.java @@ -153,7 +153,6 @@ public void onPlayerQuit(PlayerQuitEvent event) { } public static Component getJoinMessageComponent(Player player) { - String prefix = LuckPermsHook.getFormattedPAPIPrefix(player); String prefix = LuckPermsHook.getFormattedPAPIPrefix(player); return Component.text("§8[§a§l+§8] §r") .append(Component.object(ObjectContents.playerHead(player.getUniqueId())).color(NamedTextColor.WHITE)) From b209aa90f4de96dd9c728537c7b66d070c13431a Mon Sep 17 00:00:00 2001 From: iambibi <89582596+iambibi@users.noreply.github.com> Date: Thu, 15 Oct 2026 14:02:37 +0200 Subject: [PATCH 09/28] bump lamp --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 9a217b732..6f08ebe8c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -13,7 +13,7 @@ protocolLibVersion = 5.4.0 # Dependencies jetbrainsAnnotationsVersion = 26.1.0 -revxrsalLampVersion = 4.0.0-rc.18 +revxrsalLampVersion = 4.0.0-rc.19 ormVersion = 6.1 lombokVersion = 1.18.48 From 0246107b7e6241bd26822ed94e13ca51b29f47f2 Mon Sep 17 00:00:00 2001 From: iambibi <89582596+iambibi@users.noreply.github.com> Date: Thu, 15 Oct 2026 17:11:41 +0200 Subject: [PATCH 10/28] update api Item Scan for multiple textures --- .../hooks/itemsadder/sprite/SpriteUtils.java | 6 +-- .../api/scanner/items/ItemEntry.java | 45 ++++++++++--------- 2 files changed, 27 insertions(+), 24 deletions(-) diff --git a/src/main/java/fr/openmc/core/hooks/itemsadder/sprite/SpriteUtils.java b/src/main/java/fr/openmc/core/hooks/itemsadder/sprite/SpriteUtils.java index 9fdbedbe7..58a2c262d 100644 --- a/src/main/java/fr/openmc/core/hooks/itemsadder/sprite/SpriteUtils.java +++ b/src/main/java/fr/openmc/core/hooks/itemsadder/sprite/SpriteUtils.java @@ -1,7 +1,5 @@ package fr.openmc.core.hooks.itemsadder.sprite; -import fr.openmc.core.OMCPlugin; -import fr.openmc.core.bootstrap.integration.OMCLogger; import fr.openmc.core.registry.items.CustomItem; import fr.openmc.riftengine.api.scanner.items.ItemEntry; import fr.openmc.riftengine.api.utils.IdentifierUtils; @@ -11,7 +9,7 @@ import net.kyori.adventure.text.format.NamedTextColor; import net.kyori.adventure.text.object.ObjectContents; -import java.util.Set; +import java.util.Collection; public class SpriteUtils { public static ObjectComponent getSprite(CustomItem item) { @@ -22,7 +20,7 @@ public static ObjectComponent getSprite(CustomItem item) { Key atlasKey = itemEntry.getBehaviour().isBlockBehaviour() ? Key.key("minecraft", "blocks") : Key.key("minecraft", "items"); - Set bestResourcesId = itemEntry.getBestResourcesId(); + Collection bestResourcesId = itemEntry.getBestResourcesId().values(); if (bestResourcesId == null || bestResourcesId.isEmpty()) return null; String bestResourceId = bestResourcesId.stream().findFirst().orElseThrow(); diff --git a/src/main/java/fr/openmc/riftengine/api/scanner/items/ItemEntry.java b/src/main/java/fr/openmc/riftengine/api/scanner/items/ItemEntry.java index c241a9318..2a1119c27 100644 --- a/src/main/java/fr/openmc/riftengine/api/scanner/items/ItemEntry.java +++ b/src/main/java/fr/openmc/riftengine/api/scanner/items/ItemEntry.java @@ -9,7 +9,8 @@ import org.bukkit.Material; import java.nio.file.Path; -import java.util.*; +import java.util.HashMap; +import java.util.Map; import java.util.function.Function; import java.util.stream.Collectors; @@ -22,7 +23,7 @@ public class ItemEntry { private final ItemResource resource; private final ItemGraphics graphics; - private final Function> resourcePath; + private final Function> resourcePath; private final ItemBehaviour behaviour; @@ -37,7 +38,7 @@ private ItemEntry( // * Méthodes de création d'items (moderne ou legacy) ItemResource resource, ItemGraphics graphics, - Function> resourcePath, + Function> resourcePath, // tqdq rift engine faire un mapping des behavours (blocks et furnitures) ItemBehaviour behaviour, @@ -81,32 +82,26 @@ public static ItemEntry from(Map> cmdCache, Path ); } - public Set getBestResourcesId() { + public Map getBestResourcesId() { if (resource != null) { if (resource.hasTextures()) return resource.textures().stream() .map(id -> IdentifierUtils.normalizeId(id, namespace)) - .collect(Collectors.toSet()); + .collect(Collectors.toMap(id -> "_", id -> id)); else if (resource.hasModel()) - return Collections.singleton(IdentifierUtils.normalizeId(resource.model(), namespace)); + return getMapResource(IdentifierUtils.normalizeId(resource.model(), namespace)); } // * Méthode graphics if (graphics != null) { if (graphics.hasModel()) { - return Collections.singleton(IdentifierUtils.normalizeId(graphics.model(), namespace)); + return getMapResource(IdentifierUtils.normalizeId(graphics.model(), namespace)); } if (graphics.hasTexture()) { - return Collections.singleton(IdentifierUtils.normalizeId(graphics.texture(), namespace)); + return getMapResource(IdentifierUtils.normalizeId(graphics.texture(), namespace)); } if (graphics.hasTextures()) { - Set texturesNormalized = new HashSet<>(); - - for (String value : graphics.textures().values()) { - texturesNormalized.add(IdentifierUtils.normalizeId(value, namespace)); - } - - return texturesNormalized; + return new HashMap<>(graphics.textures()); } } @@ -126,29 +121,35 @@ private static Material getMaterial(ItemResource resource, ItemGraphics graphics return byDefault; } - private static Function> resolvePathFunction(String namespace, ItemGraphics graphics, ItemResource resource) { + private static Function> resolvePathFunction(String namespace, ItemGraphics graphics, ItemResource resource) { // * Méthode legacy if (resource != null) { if (resource.hasTextures()) return javaRoot -> resource.textures().stream() .map(id -> IdentifierUtils.resolveTextureId(javaRoot, IdentifierUtils.normalizeId(id, namespace))) - .collect(Collectors.toSet()); + .collect(Collectors.toMap(v -> "_", k -> k)); else if (resource.hasModel()) - return javaRoot -> Collections.singleton(IdentifierUtils.resolveModelId(javaRoot, + return javaRoot -> getMapResource(IdentifierUtils.resolveModelId(javaRoot, IdentifierUtils.normalizeId(resource.model(), namespace))); } // * Méthode graphics if (graphics != null) { if (graphics.hasModel()) { - return javaRoot -> Collections.singleton(IdentifierUtils.resolveModelId(javaRoot, + return javaRoot -> getMapResource(IdentifierUtils.resolveModelId(javaRoot, IdentifierUtils.normalizeId(graphics.model(), namespace))); } if (graphics.hasTexture()) { - return javaRoot -> Collections.singleton(IdentifierUtils.resolveTextureId(javaRoot, + return javaRoot -> getMapResource(IdentifierUtils.resolveTextureId(javaRoot, IdentifierUtils.normalizeId(graphics.texture(), namespace))); } + if (graphics.hasTextures()) { + return javaRoot -> graphics.textures().entrySet().stream() + .map(entry -> Map.entry(entry.getKey(), IdentifierUtils.resolveTextureId(javaRoot, + IdentifierUtils.normalizeId(entry.getValue(), namespace)))) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); + } } return _ -> null; @@ -157,4 +158,8 @@ else if (resource.hasModel()) public String namespacedId() { return namespace + ":" + key; } + + public static Map getMapResource(T value) { + return Map.of("_", value); + } } \ No newline at end of file From dcc598f26d84b5cf188e43c54b6ed07b9b3f9708 Mon Sep 17 00:00:00 2001 From: iambibi <89582596+iambibi@users.noreply.github.com> Date: Fri, 16 Oct 2026 14:26:04 +0200 Subject: [PATCH 11/28] feat: scan block behaviour --- .../hooks/itemsadder/sprite/SpriteUtils.java | 11 +++--- .../java/fr/openmc/core/utils/YmlUtils.java | 39 +++++++++++++++++-- .../api/scanner/icons/IconEntry.java | 6 +-- .../api/scanner/items/ItemEntry.java | 10 ++--- .../scanner/items/entry/ItemBehaviour.java | 28 ------------- .../api/scanner/items/entry/ItemGraphics.java | 32 +++++---------- .../api/scanner/items/entry/ItemResource.java | 29 +++++++------- .../items/entry/behaviours/IABehaviour.java | 37 ++++++++++++++++++ .../entry/behaviours/block/BlockType.java | 21 ++++++++++ .../behaviours/block/BlocksBehaviour.java | 35 +++++++++++++++++ .../entry/behaviours/block/BlocksSound.java | 26 +++++++++++++ .../entry/behaviours/block/PlacedModel.java | 16 ++++++++ 12 files changed, 206 insertions(+), 84 deletions(-) delete mode 100644 src/main/java/fr/openmc/riftengine/api/scanner/items/entry/ItemBehaviour.java create mode 100644 src/main/java/fr/openmc/riftengine/api/scanner/items/entry/behaviours/IABehaviour.java create mode 100644 src/main/java/fr/openmc/riftengine/api/scanner/items/entry/behaviours/block/BlockType.java create mode 100644 src/main/java/fr/openmc/riftengine/api/scanner/items/entry/behaviours/block/BlocksBehaviour.java create mode 100644 src/main/java/fr/openmc/riftengine/api/scanner/items/entry/behaviours/block/BlocksSound.java create mode 100644 src/main/java/fr/openmc/riftengine/api/scanner/items/entry/behaviours/block/PlacedModel.java diff --git a/src/main/java/fr/openmc/core/hooks/itemsadder/sprite/SpriteUtils.java b/src/main/java/fr/openmc/core/hooks/itemsadder/sprite/SpriteUtils.java index 58a2c262d..e497b3511 100644 --- a/src/main/java/fr/openmc/core/hooks/itemsadder/sprite/SpriteUtils.java +++ b/src/main/java/fr/openmc/core/hooks/itemsadder/sprite/SpriteUtils.java @@ -9,7 +9,7 @@ import net.kyori.adventure.text.format.NamedTextColor; import net.kyori.adventure.text.object.ObjectContents; -import java.util.Collection; +import java.util.Map; public class SpriteUtils { public static ObjectComponent getSprite(CustomItem item) { @@ -17,17 +17,18 @@ public static ObjectComponent getSprite(CustomItem item) { if (itemEntry == null) return null; - Key atlasKey = itemEntry.getBehaviour().isBlockBehaviour() ? Key.key("minecraft", "blocks") + Key atlasKey = itemEntry.getBehaviour().isBlock() ? Key.key("minecraft", "blocks") : Key.key("minecraft", "items"); - Collection bestResourcesId = itemEntry.getBestResourcesId().values(); + + Map bestResourcesId = itemEntry.getBestResourcesId(); if (bestResourcesId == null || bestResourcesId.isEmpty()) return null; - String bestResourceId = bestResourcesId.stream().findFirst().orElseThrow(); + String bestResourceId = bestResourcesId.values().stream().findFirst().orElseThrow(); String prefix = "_"; - if (itemEntry.getBehaviour().isBlockBehaviour() + if (itemEntry.getBehaviour().isBlock() && itemEntry.getGraphics() != null && itemEntry.getGraphics().hasTextures()) { prefix += "b_"; diff --git a/src/main/java/fr/openmc/core/utils/YmlUtils.java b/src/main/java/fr/openmc/core/utils/YmlUtils.java index 3f644e2c1..4be360c8d 100644 --- a/src/main/java/fr/openmc/core/utils/YmlUtils.java +++ b/src/main/java/fr/openmc/core/utils/YmlUtils.java @@ -20,30 +20,61 @@ public static Map loadYml(Path path) throws IOException { } } - public static String getString(Object obj, String def) { + public static String getString(Map map, String key, String def) { + if (map == null) return def; + Object obj = map.get(key); if (obj == null) return def; if (obj instanceof String s) return s; return String.valueOf(obj); } - public static Integer getInt(Object obj, Integer def) { + public static Integer getInt(Map map, String key, Integer def) { + if (map == null) return def; + Object obj = map.get(key); if (obj == null) return def; if (obj instanceof Number n) return n.intValue(); return Integer.parseInt(obj.toString()); } - public static Boolean getBool(Object obj, Boolean def) { + public static Boolean getBool(Map map, String key, Boolean def) { + if (map == null) return def; + Object obj = map.get(key); if (obj == null) return def; if (obj instanceof Boolean b) return b; return Boolean.parseBoolean(obj.toString()); } - public static Double getDouble(Object obj, Double def) { + public static Double getDouble(Map map, String key, Double def) { + if (map == null) return def; + Object obj = map.get(key); if (obj == null) return def; if (obj instanceof Number n) return n.doubleValue(); return Double.parseDouble(obj.toString()); } + public static Map getStringMap(Map map, String key) { + Map section = getMap(map, key); + if (section == null) return null; + + Map result = new HashMap<>(); + for (Map.Entry e : section.entrySet()) { + result.put(String.valueOf(e.getKey()), String.valueOf(e.getValue())); + } + return result; + } + + public static Map getMap(Map map, String key) { + if (map == null) return null; + return map.get(key) instanceof Map m ? m : null; + } + + public static List getStringList(Map map, String key) { + if (map == null) return List.of(); + return map.get(key) instanceof List l + ? l.stream().map(String::valueOf).toList() + : List.of(); + } + public static Object deepCopyObject(Object value) { if (value instanceof Map map) { Map copy = new HashMap<>(); diff --git a/src/main/java/fr/openmc/riftengine/api/scanner/icons/IconEntry.java b/src/main/java/fr/openmc/riftengine/api/scanner/icons/IconEntry.java index 26e95b0d8..7fdccc7e7 100644 --- a/src/main/java/fr/openmc/riftengine/api/scanner/icons/IconEntry.java +++ b/src/main/java/fr/openmc/riftengine/api/scanner/icons/IconEntry.java @@ -34,9 +34,9 @@ public static IconEntry from(Path sourceYml, String namespace, String key, Map IdentifierUtils.resolveTextureId(javaRoot, IdentifierUtils.normalizeId(String.valueOf(data.get("path")), namespace)), permission, - YmlUtils.getBool(data.get("show_in_gui"), true), - YmlUtils.getDouble(data.get("scale_ratio"), null), - YmlUtils.getInt(data.get("y_position"), null), + YmlUtils.getBool(data, "show_in_gui", true), + YmlUtils.getDouble(data, "scale_ratio", null), + YmlUtils.getInt(data, "y_position", null), sourceYml ); } diff --git a/src/main/java/fr/openmc/riftengine/api/scanner/items/ItemEntry.java b/src/main/java/fr/openmc/riftengine/api/scanner/items/ItemEntry.java index 2a1119c27..fc3dcb605 100644 --- a/src/main/java/fr/openmc/riftengine/api/scanner/items/ItemEntry.java +++ b/src/main/java/fr/openmc/riftengine/api/scanner/items/ItemEntry.java @@ -1,9 +1,8 @@ package fr.openmc.riftengine.api.scanner.items; - -import fr.openmc.riftengine.api.scanner.items.entry.ItemBehaviour; import fr.openmc.riftengine.api.scanner.items.entry.ItemGraphics; import fr.openmc.riftengine.api.scanner.items.entry.ItemResource; +import fr.openmc.riftengine.api.scanner.items.entry.behaviours.IABehaviour; import fr.openmc.riftengine.api.utils.IdentifierUtils; import lombok.Getter; import org.bukkit.Material; @@ -25,7 +24,7 @@ public class ItemEntry { private final ItemGraphics graphics; private final Function> resourcePath; - private final ItemBehaviour behaviour; + private final IABehaviour behaviour; private final Path sourceYml; @@ -40,8 +39,7 @@ private ItemEntry( ItemGraphics graphics, Function> resourcePath, - // tqdq rift engine faire un mapping des behavours (blocks et furnitures) - ItemBehaviour behaviour, + IABehaviour behaviour, Path sourceYml ) { @@ -59,7 +57,7 @@ private ItemEntry( public static ItemEntry from(Map> cmdCache, Path sourceYml, String namespace, String key, Map data) { ItemResource itemResource = ItemResource.from(data); ItemGraphics itemGraphics = ItemGraphics.from(data); - ItemBehaviour behaviour = ItemBehaviour.from(data); + IABehaviour behaviour = IABehaviour.from(data); Material material = getMaterial(itemResource, itemGraphics); diff --git a/src/main/java/fr/openmc/riftengine/api/scanner/items/entry/ItemBehaviour.java b/src/main/java/fr/openmc/riftengine/api/scanner/items/entry/ItemBehaviour.java deleted file mode 100644 index 5615cad1b..000000000 --- a/src/main/java/fr/openmc/riftengine/api/scanner/items/entry/ItemBehaviour.java +++ /dev/null @@ -1,28 +0,0 @@ -package fr.openmc.riftengine.api.scanner.items.entry; - -import java.util.Map; - -public record ItemBehaviour(boolean isBlockBehaviour) { - public static ItemBehaviour from(Map data) { - Object resourceObj = data.get("behaviours"); - if (!(resourceObj instanceof Map behaviour)) - return new ItemBehaviour(false); - - Object blockObj = behaviour.get("block"); - - if (blockObj != null) - return new ItemBehaviour(true); - - Object specificPropertiesObj = data.get("specific_properties"); - - if (!(specificPropertiesObj instanceof Map specificProperties)) - return new ItemBehaviour(false); - - Object blockObj2 = specificProperties.get("block"); - - if (blockObj2 != null) - return new ItemBehaviour(true); - - return new ItemBehaviour(false); - } -} diff --git a/src/main/java/fr/openmc/riftengine/api/scanner/items/entry/ItemGraphics.java b/src/main/java/fr/openmc/riftengine/api/scanner/items/entry/ItemGraphics.java index 42b492061..c45187c80 100644 --- a/src/main/java/fr/openmc/riftengine/api/scanner/items/entry/ItemGraphics.java +++ b/src/main/java/fr/openmc/riftengine/api/scanner/items/entry/ItemGraphics.java @@ -3,7 +3,6 @@ import fr.openmc.core.utils.YmlUtils; import org.bukkit.Material; -import java.util.HashMap; import java.util.Map; public record ItemGraphics( @@ -13,30 +12,19 @@ public record ItemGraphics( Material material ) { public static ItemGraphics from(Map data) { - if (!(data.get("graphics") instanceof Map graphics)) + Map graphics = YmlUtils.getMap(data, "graphics"); + if (graphics == null) return new ItemGraphics(null, null, null, Material.PAPER); + Material material = Material.valueOf( + YmlUtils.getString(data, "material", ItemResource.DEFAULT_MATERIAL).toUpperCase()); - Map textures = null; - - Object texturesObj = graphics.get("textures"); - if (texturesObj instanceof Map texturesMap) { - textures = new HashMap<>(); - - for (Map.Entry entry : texturesMap.entrySet()) { - textures.put( - entry.getKey().toString(), - entry.getValue().toString() - ); - } - } - - String texture = YmlUtils.getString(graphics.get("texture"), null); - String model = YmlUtils.getString(graphics.get("model"), null); - Material material = Material.valueOf(YmlUtils.getString( - data.get("material"), ItemResource.DEFAULT_MATERIAL).toUpperCase()); - - return new ItemGraphics(texture, textures, model, material); + return new ItemGraphics( + YmlUtils.getString(graphics, "texture", null), + YmlUtils.getStringMap(graphics, "textures"), + YmlUtils.getString(graphics, "model", null), + material + ); } public boolean hasTexture() { diff --git a/src/main/java/fr/openmc/riftengine/api/scanner/items/entry/ItemResource.java b/src/main/java/fr/openmc/riftengine/api/scanner/items/entry/ItemResource.java index 7a526f264..9801a7805 100644 --- a/src/main/java/fr/openmc/riftengine/api/scanner/items/entry/ItemResource.java +++ b/src/main/java/fr/openmc/riftengine/api/scanner/items/entry/ItemResource.java @@ -19,26 +19,23 @@ public static ItemResource from(Map data) { if (!(resourceObj instanceof Map resource)) return new ItemResource(Material.valueOf(DEFAULT_MATERIAL), false, List.of(), null); - Material material = Material.valueOf(YmlUtils.getString( - resource.get("material"), DEFAULT_MATERIAL).toUpperCase()); + Material material = Material.matchMaterial(YmlUtils.getString(resource, "material", DEFAULT_MATERIAL).toUpperCase()); - boolean generate = YmlUtils.getBool(resource.get("generate"), false); - - List textures = resource.get("textures") instanceof List list && resource.get("textures") != null - ? list.stream().map(String::valueOf).toList() - : List.of(); - - if (resource.get("textures") == null && resource.get("texture") != null && textures.isEmpty()) - textures = List.of(String.valueOf(resource.get("texture"))); + return new ItemResource(material, + YmlUtils.getBool(resource, "generate", false), + getTextures(resource), + YmlUtils.getString(resource, "model_path", null) + ); + } - if (textures.isEmpty() && resource.get("textures") instanceof String string) - textures = List.of(string); + private static List getTextures(Map resource) { + if (resource.get("textures") instanceof List) + return YmlUtils.getStringList(resource, "textures"); - String modelPath = resource.get("model_path") != null - ? String.valueOf(resource.get("model_path")) - : null; + String single = YmlUtils.getString(resource, "textures", + YmlUtils.getString(resource, "texture", null)); - return new ItemResource(material, generate, textures, modelPath); + return single == null ? List.of() : List.of(single); } public boolean hasTextures() { diff --git a/src/main/java/fr/openmc/riftengine/api/scanner/items/entry/behaviours/IABehaviour.java b/src/main/java/fr/openmc/riftengine/api/scanner/items/entry/behaviours/IABehaviour.java new file mode 100644 index 000000000..237da9942 --- /dev/null +++ b/src/main/java/fr/openmc/riftengine/api/scanner/items/entry/behaviours/IABehaviour.java @@ -0,0 +1,37 @@ +package fr.openmc.riftengine.api.scanner.items.entry.behaviours; + +import fr.openmc.riftengine.api.scanner.items.entry.behaviours.block.BlocksBehaviour; + +import java.util.Map; + +public interface IABehaviour { + static IABehaviour from(Map data) { + if (data == null) return null; + + Object resourceObj = data.get("behaviours"); + Object specificPropertiesObj = data.get("specific_properties"); + + if (resourceObj == null || specificPropertiesObj == null) return null; + + Map behaviours; + + if (resourceObj instanceof Map b) { + behaviours = b; + } else if (specificPropertiesObj instanceof Map b) { + behaviours = b; + } else return null; + + + IABehaviour behaviour = null; + + if (behaviours.get("block") instanceof Map block) { + behaviour = BlocksBehaviour.from(block); + } + + return behaviour; + } + + default boolean isBlock() { + return this instanceof BlocksBehaviour; + } +} diff --git a/src/main/java/fr/openmc/riftengine/api/scanner/items/entry/behaviours/block/BlockType.java b/src/main/java/fr/openmc/riftengine/api/scanner/items/entry/behaviours/block/BlockType.java new file mode 100644 index 000000000..854b83a01 --- /dev/null +++ b/src/main/java/fr/openmc/riftengine/api/scanner/items/entry/behaviours/block/BlockType.java @@ -0,0 +1,21 @@ +package fr.openmc.riftengine.api.scanner.items.entry.behaviours.block; + +public enum BlockType { + REAL_WIRE, + REAL_NOTE, + REAL, + REAL_TRANSPARENT, + TILE, + FIRE, // le feu est un bloc cool + UNKNOWN + ; + + static BlockType from(String s) { + if (s == null) return UNKNOWN; + try { + return valueOf(s.toUpperCase()); + } catch (IllegalArgumentException e) { + return UNKNOWN; + } + } +} diff --git a/src/main/java/fr/openmc/riftengine/api/scanner/items/entry/behaviours/block/BlocksBehaviour.java b/src/main/java/fr/openmc/riftengine/api/scanner/items/entry/behaviours/block/BlocksBehaviour.java new file mode 100644 index 000000000..cbd6aa355 --- /dev/null +++ b/src/main/java/fr/openmc/riftengine/api/scanner/items/entry/behaviours/block/BlocksBehaviour.java @@ -0,0 +1,35 @@ +package fr.openmc.riftengine.api.scanner.items.entry.behaviours.block; + +import fr.openmc.core.utils.YmlUtils; +import fr.openmc.riftengine.api.scanner.items.entry.behaviours.IABehaviour; + +import java.util.List; +import java.util.Map; + +// note: toutes les options ne sont pas mappé +public record BlocksBehaviour(PlacedModel placedModel, + boolean dropWhenMined, + int lightLevel, + List breakToolsBlacklist, + List breakToolsWhitelist, + double hardness, + double blastResistance, + boolean noExplosion, + BlocksSound sounds +) implements IABehaviour { + public static BlocksBehaviour from(Map block) { + double hardness = YmlUtils.getDouble(block, "hardness", 2d); + + return new BlocksBehaviour( + PlacedModel.from(YmlUtils.getMap(block, "placed_model")), + YmlUtils.getBool(block, "drop_when_mined", true), + YmlUtils.getInt(block, "light_level", 0), + YmlUtils.getStringList(block, "break_tools_blacklist"), + YmlUtils.getStringList(block, "break_tools_whitelist"), + hardness, + YmlUtils.getDouble(block, "blast_resistance", hardness * 3), + YmlUtils.getBool(block, "no_explosion", false), + BlocksSound.from(YmlUtils.getMap(block, "sound")) + ); + } +} diff --git a/src/main/java/fr/openmc/riftengine/api/scanner/items/entry/behaviours/block/BlocksSound.java b/src/main/java/fr/openmc/riftengine/api/scanner/items/entry/behaviours/block/BlocksSound.java new file mode 100644 index 000000000..d426d7f6a --- /dev/null +++ b/src/main/java/fr/openmc/riftengine/api/scanner/items/entry/behaviours/block/BlocksSound.java @@ -0,0 +1,26 @@ +package fr.openmc.riftengine.api.scanner.items.entry.behaviours.block; + +import fr.openmc.core.utils.YmlUtils; + +import java.util.Map; + +public record BlocksSound(IASound breakSound, IASound placeSound) { + static BlocksSound from(Map m) { + return new BlocksSound( + IASound.from(YmlUtils.getMap(m, "break")), + IASound.from(YmlUtils.getMap(m, "place")) + ); + } + + public record IASound(String name, float volume, float pitch) { + static IASound from(Map m) { + if (m == null) return null; + return new IASound( + YmlUtils.getString(m, "name", null), + YmlUtils.getDouble(m, "volume", 1.0).floatValue(), + YmlUtils.getDouble(m, "pitch", 1.0).floatValue() + ); + } + } +} + diff --git a/src/main/java/fr/openmc/riftengine/api/scanner/items/entry/behaviours/block/PlacedModel.java b/src/main/java/fr/openmc/riftengine/api/scanner/items/entry/behaviours/block/PlacedModel.java new file mode 100644 index 000000000..66597a122 --- /dev/null +++ b/src/main/java/fr/openmc/riftengine/api/scanner/items/entry/behaviours/block/PlacedModel.java @@ -0,0 +1,16 @@ +package fr.openmc.riftengine.api.scanner.items.entry.behaviours.block; + +import fr.openmc.core.utils.YmlUtils; + +import java.util.Map; + +public record PlacedModel(BlockType type, String breakParticles, int rotX, int rotY) { + static PlacedModel from(Map m) { + return new PlacedModel( + BlockType.from(YmlUtils.getString(m, "type", null)), + YmlUtils.getString(m, "break_particles", "BLOCK"), + YmlUtils.getInt(m, "rotx", 0), + YmlUtils.getInt(m, "roty", 0) + ); + } +} \ No newline at end of file From a27ac64dc47def50dc448964dbb4576aa6322e76 Mon Sep 17 00:00:00 2001 From: iambibi <89582596+iambibi@users.noreply.github.com> Date: Fri, 16 Oct 2026 15:07:07 +0200 Subject: [PATCH 12/28] fix little bug --- .../core/features/mainmenu/menus/buttons/ProfileButton.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/fr/openmc/core/features/mainmenu/menus/buttons/ProfileButton.java b/src/main/java/fr/openmc/core/features/mainmenu/menus/buttons/ProfileButton.java index e8bfb3bf9..6179c567b 100644 --- a/src/main/java/fr/openmc/core/features/mainmenu/menus/buttons/ProfileButton.java +++ b/src/main/java/fr/openmc/core/features/mainmenu/menus/buttons/ProfileButton.java @@ -6,6 +6,7 @@ import fr.openmc.core.features.mainmenu.menus.ButtonMenu; import fr.openmc.core.features.profile.menu.ProfileMenu; import net.kyori.adventure.text.format.TextDecoration; +import org.bukkit.Material; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.SkullMeta; @@ -30,7 +31,10 @@ public ItemStack item(OMCPlayer player) { public ItemStack itemAt(OMCPlayer player, int slot) { if (slot != 60) return item(player); - ItemStack head = CustomStack.getInstance("omc_main_menu:player_head").getItemStack(); + CustomStack playerHead = CustomStack.getInstance("omc_main_menu:player_head"); + if (playerHead == null) return ItemStack.of(Material.PLAYER_HEAD); + + ItemStack head = playerHead.getItemStack(); head.editMeta(meta -> { meta.customName(ButtonItems.name("feature.mainmenu.item.profile.name") .decoration(TextDecoration.ITALIC, false)); From 102069a9e2244380b2f11b7e64895bb582dce411 Mon Sep 17 00:00:00 2001 From: iambibi <89582596+iambibi@users.noreply.github.com> Date: Fri, 16 Oct 2026 15:21:24 +0200 Subject: [PATCH 13/28] feat: blocks states scanner --- .../api/registry/scanner/ScannerRegistry.java | 2 + .../api/scanner/blocks/BlockStateScanner.java | 39 +++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 src/main/java/fr/openmc/riftengine/api/scanner/blocks/BlockStateScanner.java diff --git a/src/main/java/fr/openmc/riftengine/api/registry/scanner/ScannerRegistry.java b/src/main/java/fr/openmc/riftengine/api/registry/scanner/ScannerRegistry.java index 8a5df67c6..960d8f8b6 100644 --- a/src/main/java/fr/openmc/riftengine/api/registry/scanner/ScannerRegistry.java +++ b/src/main/java/fr/openmc/riftengine/api/registry/scanner/ScannerRegistry.java @@ -2,6 +2,7 @@ import fr.openmc.core.bootstrap.registries.KeyedRegistry; import fr.openmc.core.bootstrap.registries.Registry; +import fr.openmc.riftengine.api.scanner.blocks.BlockStateScanner; import fr.openmc.riftengine.api.scanner.general.YamlNamespaceIAScanner; import fr.openmc.riftengine.api.scanner.general.YamlScanner; import fr.openmc.riftengine.api.scanner.icons.IconScanner; @@ -14,6 +15,7 @@ public class ScannerRegistry extends Registry> public final IconScanner ICONS = register(new IconScanner()); public final ItemScanner ITEMS = register(new ItemScanner()); public final CustomModelDataScanner CUSTOM_MODEL_DATA_CACHE = register(new CustomModelDataScanner()); + public final BlockStateScanner BLOCKSTATES_CACHE = register(new BlockStateScanner()); public final YamlNamespaceIAScanner YAML_ITEMSADDER_NAMESPACE = register(new YamlNamespaceIAScanner()); public final YamlScanner YAML = register(new YamlScanner()); diff --git a/src/main/java/fr/openmc/riftengine/api/scanner/blocks/BlockStateScanner.java b/src/main/java/fr/openmc/riftengine/api/scanner/blocks/BlockStateScanner.java new file mode 100644 index 000000000..b648b2a0e --- /dev/null +++ b/src/main/java/fr/openmc/riftengine/api/scanner/blocks/BlockStateScanner.java @@ -0,0 +1,39 @@ +package fr.openmc.riftengine.api.scanner.blocks; + +import fr.openmc.core.OMCPlugin; +import fr.openmc.core.hooks.itemsadder.ItemsAdderHook; +import fr.openmc.core.utils.FilesUtils; +import fr.openmc.core.utils.YmlUtils; +import fr.openmc.riftengine.api.registry.scanner.AbstractScanner; +import fr.openmc.riftengine.api.utils.IdentifierUtils; + +import java.nio.file.Path; +import java.util.HashMap; +import java.util.Map; + +/** + * Scan le cache des CustomModelData qui sont assignés par ItemsAdder + */ +public class BlockStateScanner extends AbstractScanner, Void> { + + public Map scan(Void voyd) throws Exception { + Path blockstatesFolderPath = ItemsAdderHook.getItemsAdderPath(OMCPlugin.getInstance().getDataPath()) + .resolve("storage").resolve("blockstates"); + Map blockstates = new HashMap<>(); // + + for (String fileName : FilesUtils.listFileNames(blockstatesFolderPath.toAbsolutePath().toString())) { + Path filePath = blockstatesFolderPath.resolve(fileName); + Map root = YmlUtils.loadYml(filePath); + + for (var iterRoot : root.entrySet()) { + String key = iterRoot.getKey(); + + if (!(iterRoot.getValue() instanceof String valueStr)) continue; + + blockstates.put(key, IdentifierUtils.removeExtensionPath(valueStr) + valueStr); + } + } + + return blockstates; + } +} From 9ffd7f113c522c2c3ea7917f4046c421d56fb4e2 Mon Sep 17 00:00:00 2001 From: iambibi <89582596+iambibi@users.noreply.github.com> Date: Fri, 16 Oct 2026 15:32:29 +0200 Subject: [PATCH 14/28] feat: blockstate acces in BlocksBehaviour --- .../api/scanner/items/ItemEntry.java | 12 ++++++++-- .../api/scanner/items/ItemScanner.java | 5 ++-- .../api/scanner/items/entry/ItemInfo.java | 21 +++++++++++++++++ .../items/entry/behaviours/IABehaviour.java | 5 ++-- .../behaviours/block/BlocksBehaviour.java | 23 +++++++++++-------- 5 files changed, 51 insertions(+), 15 deletions(-) create mode 100644 src/main/java/fr/openmc/riftengine/api/scanner/items/entry/ItemInfo.java diff --git a/src/main/java/fr/openmc/riftengine/api/scanner/items/ItemEntry.java b/src/main/java/fr/openmc/riftengine/api/scanner/items/ItemEntry.java index fc3dcb605..84a5b0a88 100644 --- a/src/main/java/fr/openmc/riftengine/api/scanner/items/ItemEntry.java +++ b/src/main/java/fr/openmc/riftengine/api/scanner/items/ItemEntry.java @@ -1,6 +1,7 @@ package fr.openmc.riftengine.api.scanner.items; import fr.openmc.riftengine.api.scanner.items.entry.ItemGraphics; +import fr.openmc.riftengine.api.scanner.items.entry.ItemInfo; import fr.openmc.riftengine.api.scanner.items.entry.ItemResource; import fr.openmc.riftengine.api.scanner.items.entry.behaviours.IABehaviour; import fr.openmc.riftengine.api.utils.IdentifierUtils; @@ -54,10 +55,17 @@ private ItemEntry( this.sourceYml = sourceYml; } - public static ItemEntry from(Map> cmdCache, Path sourceYml, String namespace, String key, Map data) { + public static ItemEntry from(Map> cmdCache, + Map blockStateCache, + Path sourceYml, + String namespace, + String key, + Map data) { + ItemInfo itemInfo = ItemInfo.from(namespace, key, cmdCache, blockStateCache); + ItemResource itemResource = ItemResource.from(data); ItemGraphics itemGraphics = ItemGraphics.from(data); - IABehaviour behaviour = IABehaviour.from(data); + IABehaviour behaviour = IABehaviour.from(itemInfo, data); Material material = getMaterial(itemResource, itemGraphics); diff --git a/src/main/java/fr/openmc/riftengine/api/scanner/items/ItemScanner.java b/src/main/java/fr/openmc/riftengine/api/scanner/items/ItemScanner.java index a51b8e568..43efa32a4 100644 --- a/src/main/java/fr/openmc/riftengine/api/scanner/items/ItemScanner.java +++ b/src/main/java/fr/openmc/riftengine/api/scanner/items/ItemScanner.java @@ -32,13 +32,14 @@ public List scan(Path itemsAdderContentsPath) throws Exception { if (!(itemsObj instanceof Map itemsMap)) continue; String namespace = OMCRegistry.SCANNERS.YAML_ITEMSADDER_NAMESPACE.scan(root); - Map> mappedCache = OMCRegistry.SCANNERS.CUSTOM_MODEL_DATA_CACHE.scan(null); + Map> cmdCache = OMCRegistry.SCANNERS.CUSTOM_MODEL_DATA_CACHE.scan(null); + Map blockStateCache = OMCRegistry.SCANNERS.BLOCKSTATES_CACHE.scan(null); for (Map.Entry entry : itemsMap.entrySet()) { String key = String.valueOf(entry.getKey()); if (!(entry.getValue() instanceof Map data)) continue; - result.add(ItemEntry.from(mappedCache, ymlFile, namespace, key, data)); + result.add(ItemEntry.from(cmdCache, blockStateCache, ymlFile, namespace, key, data)); } } diff --git a/src/main/java/fr/openmc/riftengine/api/scanner/items/entry/ItemInfo.java b/src/main/java/fr/openmc/riftengine/api/scanner/items/entry/ItemInfo.java new file mode 100644 index 000000000..b53eb62e4 --- /dev/null +++ b/src/main/java/fr/openmc/riftengine/api/scanner/items/entry/ItemInfo.java @@ -0,0 +1,21 @@ +package fr.openmc.riftengine.api.scanner.items.entry; + +import org.bukkit.Material; + +import java.util.Map; + +public record ItemInfo(String namespace, + String key, + Map> cmdCache, + Map blockStateCache) { + public static ItemInfo from(String namespace, + String key, + Map> cmdCache, + Map blockStateCache) { + return new ItemInfo(namespace, key, cmdCache, blockStateCache); + } + + public String namespacedId() { + return namespace + ":" + key; + } +} diff --git a/src/main/java/fr/openmc/riftengine/api/scanner/items/entry/behaviours/IABehaviour.java b/src/main/java/fr/openmc/riftengine/api/scanner/items/entry/behaviours/IABehaviour.java index 237da9942..e99028b37 100644 --- a/src/main/java/fr/openmc/riftengine/api/scanner/items/entry/behaviours/IABehaviour.java +++ b/src/main/java/fr/openmc/riftengine/api/scanner/items/entry/behaviours/IABehaviour.java @@ -1,11 +1,12 @@ package fr.openmc.riftengine.api.scanner.items.entry.behaviours; +import fr.openmc.riftengine.api.scanner.items.entry.ItemInfo; import fr.openmc.riftengine.api.scanner.items.entry.behaviours.block.BlocksBehaviour; import java.util.Map; public interface IABehaviour { - static IABehaviour from(Map data) { + static IABehaviour from(ItemInfo info, Map data) { if (data == null) return null; Object resourceObj = data.get("behaviours"); @@ -25,7 +26,7 @@ static IABehaviour from(Map data) { IABehaviour behaviour = null; if (behaviours.get("block") instanceof Map block) { - behaviour = BlocksBehaviour.from(block); + behaviour = BlocksBehaviour.from(info, block); } return behaviour; diff --git a/src/main/java/fr/openmc/riftengine/api/scanner/items/entry/behaviours/block/BlocksBehaviour.java b/src/main/java/fr/openmc/riftengine/api/scanner/items/entry/behaviours/block/BlocksBehaviour.java index cbd6aa355..d95c34ff0 100644 --- a/src/main/java/fr/openmc/riftengine/api/scanner/items/entry/behaviours/block/BlocksBehaviour.java +++ b/src/main/java/fr/openmc/riftengine/api/scanner/items/entry/behaviours/block/BlocksBehaviour.java @@ -1,6 +1,7 @@ package fr.openmc.riftengine.api.scanner.items.entry.behaviours.block; import fr.openmc.core.utils.YmlUtils; +import fr.openmc.riftengine.api.scanner.items.entry.ItemInfo; import fr.openmc.riftengine.api.scanner.items.entry.behaviours.IABehaviour; import java.util.List; @@ -8,20 +9,24 @@ // note: toutes les options ne sont pas mappé public record BlocksBehaviour(PlacedModel placedModel, - boolean dropWhenMined, - int lightLevel, - List breakToolsBlacklist, - List breakToolsWhitelist, - double hardness, - double blastResistance, - boolean noExplosion, - BlocksSound sounds + String blockState, + boolean dropWhenMined, + int lightLevel, + List breakToolsBlacklist, + List breakToolsWhitelist, + double hardness, + double blastResistance, + boolean noExplosion, + BlocksSound sounds ) implements IABehaviour { - public static BlocksBehaviour from(Map block) { + public static BlocksBehaviour from(ItemInfo info, Map block) { double hardness = YmlUtils.getDouble(block, "hardness", 2d); + String blockState = info.blockStateCache().get(info.namespacedId()); + return new BlocksBehaviour( PlacedModel.from(YmlUtils.getMap(block, "placed_model")), + blockState, YmlUtils.getBool(block, "drop_when_mined", true), YmlUtils.getInt(block, "light_level", 0), YmlUtils.getStringList(block, "break_tools_blacklist"), From 62cb869821811eb75cacff16fe1b1cb22ce14975 Mon Sep 17 00:00:00 2001 From: iambibi <89582596+iambibi@users.noreply.github.com> Date: Fri, 16 Oct 2026 15:54:12 +0200 Subject: [PATCH 15/28] fix: error --- src/main/java/fr/openmc/core/OMCRegistry.java | 8 ++++---- .../riftengine/api/scanner/blocks/BlockStateScanner.java | 1 + 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main/java/fr/openmc/core/OMCRegistry.java b/src/main/java/fr/openmc/core/OMCRegistry.java index 94db57547..c64a1fa5c 100644 --- a/src/main/java/fr/openmc/core/OMCRegistry.java +++ b/src/main/java/fr/openmc/core/OMCRegistry.java @@ -14,8 +14,8 @@ import fr.openmc.core.registry.loottable.CustomLootTableRegistry; import fr.openmc.core.registry.mobs.CustomMobRegistry; import fr.openmc.core.registry.regions.CustomRegionRegistry; -import fr.openmc.riftengine.api.registry.scanner.ScannerRegistry; import fr.openmc.core.registry.worldtemplates.WorldTemplateRegistry; +import fr.openmc.riftengine.api.registry.scanner.ScannerRegistry; import io.papermc.paper.plugin.bootstrap.BootstrapContext; import java.io.IOException; @@ -87,7 +87,7 @@ public static void bootstrapAll(BootstrapContext context) { r.bootstrap(context); } catch (IOException e) { OMCLogger.errorFormatted("Erreur lors du chargement du registre lors du bootstrap"); - OMCLogger.error(e.getMessage()); + OMCLogger.error(e.getMessage(), e); } OMCLogger.successFormatted("Registre {} chargé pendant le bootstrap", r.getClass().getSimpleName()); } @@ -108,7 +108,7 @@ public static void initAll() { r.init(); } catch (Exception e) { OMCLogger.errorFormatted("Erreur lors du chargement du registre lors du runtime"); - OMCLogger.error(e.getMessage()); + OMCLogger.error(e.getMessage(), e); } OMCLogger.successFormatted("Registre {} chargé pendant le runtime", r.getClass().getSimpleName()); } @@ -130,7 +130,7 @@ public static void postInitAll() { r.postInit(); } catch (Exception e) { OMCLogger.errorFormatted("Erreur lors du chargement du registre apres ItemsAdder"); - OMCLogger.error(e.getMessage()); + OMCLogger.error(e.getMessage(), e); } OMCLogger.successFormatted("Registre {} chargé après ItemsAdder", r.getClass().getSimpleName()); diff --git a/src/main/java/fr/openmc/riftengine/api/scanner/blocks/BlockStateScanner.java b/src/main/java/fr/openmc/riftengine/api/scanner/blocks/BlockStateScanner.java index b648b2a0e..1bc42d21a 100644 --- a/src/main/java/fr/openmc/riftengine/api/scanner/blocks/BlockStateScanner.java +++ b/src/main/java/fr/openmc/riftengine/api/scanner/blocks/BlockStateScanner.java @@ -24,6 +24,7 @@ public Map scan(Void voyd) throws Exception { for (String fileName : FilesUtils.listFileNames(blockstatesFolderPath.toAbsolutePath().toString())) { Path filePath = blockstatesFolderPath.resolve(fileName); Map root = YmlUtils.loadYml(filePath); + if (root == null) continue; for (var iterRoot : root.entrySet()) { String key = iterRoot.getKey(); From 48fdbe46f97517f39dbd95b6c83e747b7e65e4c9 Mon Sep 17 00:00:00 2001 From: iambibi <89582596+iambibi@users.noreply.github.com> Date: Fri, 16 Oct 2026 19:02:58 +0200 Subject: [PATCH 16/28] fix: conception --- .../riftengine/api/scanner/blocks/BlockStateScanner.java | 3 +-- .../fr/openmc/riftengine/api/scanner/items/ItemEntry.java | 6 +++--- .../api/scanner/items/entry/behaviours/IABehaviour.java | 2 +- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/main/java/fr/openmc/riftengine/api/scanner/blocks/BlockStateScanner.java b/src/main/java/fr/openmc/riftengine/api/scanner/blocks/BlockStateScanner.java index 1bc42d21a..ae4a0286e 100644 --- a/src/main/java/fr/openmc/riftengine/api/scanner/blocks/BlockStateScanner.java +++ b/src/main/java/fr/openmc/riftengine/api/scanner/blocks/BlockStateScanner.java @@ -5,7 +5,6 @@ import fr.openmc.core.utils.FilesUtils; import fr.openmc.core.utils.YmlUtils; import fr.openmc.riftengine.api.registry.scanner.AbstractScanner; -import fr.openmc.riftengine.api.utils.IdentifierUtils; import java.nio.file.Path; import java.util.HashMap; @@ -31,7 +30,7 @@ public Map scan(Void voyd) throws Exception { if (!(iterRoot.getValue() instanceof String valueStr)) continue; - blockstates.put(key, IdentifierUtils.removeExtensionPath(valueStr) + valueStr); + blockstates.put(key, valueStr); } } diff --git a/src/main/java/fr/openmc/riftengine/api/scanner/items/ItemEntry.java b/src/main/java/fr/openmc/riftengine/api/scanner/items/ItemEntry.java index 84a5b0a88..81ed1b8d5 100644 --- a/src/main/java/fr/openmc/riftengine/api/scanner/items/ItemEntry.java +++ b/src/main/java/fr/openmc/riftengine/api/scanner/items/ItemEntry.java @@ -61,13 +61,13 @@ public static ItemEntry from(Map> cmdCache, String namespace, String key, Map data) { - ItemInfo itemInfo = ItemInfo.from(namespace, key, cmdCache, blockStateCache); - ItemResource itemResource = ItemResource.from(data); ItemGraphics itemGraphics = ItemGraphics.from(data); + Material material = getMaterial(itemResource, itemGraphics); + ItemInfo itemInfo = ItemInfo.from(namespace, key, cmdCache, blockStateCache); + IABehaviour behaviour = IABehaviour.from(itemInfo, data); - Material material = getMaterial(itemResource, itemGraphics); Integer customModelData = null; diff --git a/src/main/java/fr/openmc/riftengine/api/scanner/items/entry/behaviours/IABehaviour.java b/src/main/java/fr/openmc/riftengine/api/scanner/items/entry/behaviours/IABehaviour.java index e99028b37..283fa553a 100644 --- a/src/main/java/fr/openmc/riftengine/api/scanner/items/entry/behaviours/IABehaviour.java +++ b/src/main/java/fr/openmc/riftengine/api/scanner/items/entry/behaviours/IABehaviour.java @@ -12,7 +12,7 @@ static IABehaviour from(ItemInfo info, Map data) { Object resourceObj = data.get("behaviours"); Object specificPropertiesObj = data.get("specific_properties"); - if (resourceObj == null || specificPropertiesObj == null) return null; + if (resourceObj == null && specificPropertiesObj == null) return null; Map behaviours; From 943074de8a6db902a012ba4c69f830b5fbf1d141 Mon Sep 17 00:00:00 2001 From: iambibi <89582596+iambibi@users.noreply.github.com> Date: Mon, 19 Oct 2026 13:42:01 +0200 Subject: [PATCH 17/28] fix: adjust code for blocks definition --- .../api/scanner/blocks/BlockStateScanner.java | 38 ++++++++++++++++--- .../api/scanner/items/ItemEntry.java | 25 ++++++------ .../api/scanner/items/ItemScanner.java | 8 ++-- .../api/scanner/items/entry/ItemInfo.java | 14 ++----- .../entry/behaviours/EmptyBehaviour.java | 4 ++ .../items/entry/behaviours/IABehaviour.java | 14 ++++--- .../behaviours/block/BlocksBehaviour.java | 9 +++-- 7 files changed, 73 insertions(+), 39 deletions(-) create mode 100644 src/main/java/fr/openmc/riftengine/api/scanner/items/entry/behaviours/EmptyBehaviour.java diff --git a/src/main/java/fr/openmc/riftengine/api/scanner/blocks/BlockStateScanner.java b/src/main/java/fr/openmc/riftengine/api/scanner/blocks/BlockStateScanner.java index ae4a0286e..d485c03f2 100644 --- a/src/main/java/fr/openmc/riftengine/api/scanner/blocks/BlockStateScanner.java +++ b/src/main/java/fr/openmc/riftengine/api/scanner/blocks/BlockStateScanner.java @@ -5,20 +5,25 @@ import fr.openmc.core.utils.FilesUtils; import fr.openmc.core.utils.YmlUtils; import fr.openmc.riftengine.api.registry.scanner.AbstractScanner; +import fr.openmc.riftengine.api.utils.IdentifierUtils; +import org.bukkit.Material; import java.nio.file.Path; +import java.util.Arrays; +import java.util.Comparator; import java.util.HashMap; import java.util.Map; +import java.util.stream.Collectors; /** - * Scan le cache des CustomModelData qui sont assignés par ItemsAdder + * Scan le cache des BlockStates et des BlockMaterials qui sont assignés par ItemsAdder */ -public class BlockStateScanner extends AbstractScanner, Void> { +public class BlockStateScanner extends AbstractScanner, Void> { - public Map scan(Void voyd) throws Exception { + public Map scan(Void voyd) throws Exception { Path blockstatesFolderPath = ItemsAdderHook.getItemsAdderPath(OMCPlugin.getInstance().getDataPath()) .resolve("storage").resolve("blockstates"); - Map blockstates = new HashMap<>(); // + Map blockstates = new HashMap<>(); // for (String fileName : FilesUtils.listFileNames(blockstatesFolderPath.toAbsolutePath().toString())) { Path filePath = blockstatesFolderPath.resolve(fileName); @@ -30,10 +35,33 @@ public Map scan(Void voyd) throws Exception { if (!(iterRoot.getValue() instanceof String valueStr)) continue; - blockstates.put(key, valueStr); + blockstates.put(key, new CustomBlockState(key, + "minecraft:" + IdentifierUtils.removeExtensionPath(fileName), + normalizeState(valueStr) + )); } } return blockstates; } + + // ex d'id: omc_blocks:aywenite_ore, javaBlock: minecraft:note_block, state: [powered=true] + public record CustomBlockState(String id, String javaBlock, String state) { + public Material materialBlock() { + return Material.matchMaterial(javaBlock); + } + } + + /** + * Enleve les crochets et mets dans l'ordre les states afin que geyser ne throw pas d'erreur + * @param state le state d'un block [powered=true, gngng...] + * @return le state normalisé + */ + private String normalizeState(String state) { + return Arrays.stream(state.replace("[", "").replace("]", "").split(",")) + .map(String::trim) + .filter(p -> !p.isEmpty()) + .sorted(Comparator.comparing((String p) -> p.substring(0, p.indexOf('=')))) + .collect(Collectors.joining(",")); + } } diff --git a/src/main/java/fr/openmc/riftengine/api/scanner/items/ItemEntry.java b/src/main/java/fr/openmc/riftengine/api/scanner/items/ItemEntry.java index 81ed1b8d5..64566a13a 100644 --- a/src/main/java/fr/openmc/riftengine/api/scanner/items/ItemEntry.java +++ b/src/main/java/fr/openmc/riftengine/api/scanner/items/ItemEntry.java @@ -1,9 +1,11 @@ package fr.openmc.riftengine.api.scanner.items; +import fr.openmc.core.OMCRegistry; import fr.openmc.riftengine.api.scanner.items.entry.ItemGraphics; import fr.openmc.riftengine.api.scanner.items.entry.ItemInfo; import fr.openmc.riftengine.api.scanner.items.entry.ItemResource; import fr.openmc.riftengine.api.scanner.items.entry.behaviours.IABehaviour; +import fr.openmc.riftengine.api.scanner.items.entry.behaviours.block.BlocksBehaviour; import fr.openmc.riftengine.api.utils.IdentifierUtils; import lombok.Getter; import org.bukkit.Material; @@ -16,6 +18,8 @@ @Getter public class ItemEntry { + public static final String DEFAULT_STATE = "normal"; + private final String namespace; private final String key; private final Integer customModelData; @@ -55,23 +59,22 @@ private ItemEntry( this.sourceYml = sourceYml; } - public static ItemEntry from(Map> cmdCache, - Map blockStateCache, - Path sourceYml, + public static ItemEntry from(Path sourceYml, String namespace, String key, - Map data) { + Map data) throws Exception { ItemResource itemResource = ItemResource.from(data); ItemGraphics itemGraphics = ItemGraphics.from(data); Material material = getMaterial(itemResource, itemGraphics); - ItemInfo itemInfo = ItemInfo.from(namespace, key, cmdCache, blockStateCache); + ItemInfo itemInfo = ItemInfo.from(namespace, key); IABehaviour behaviour = IABehaviour.from(itemInfo, data); - - Integer customModelData = null; - Map map = cmdCache.get(material); + if (behaviour.isBlock() && behaviour instanceof BlocksBehaviour blockBehaviour) + material = blockBehaviour.blockState().materialBlock(); + + Map map = OMCRegistry.SCANNERS.CUSTOM_MODEL_DATA_CACHE.getCache(null).get(material); if (map != null && map.get(namespace + ":" + key) != null) customModelData = map.get(namespace + ":" + key); @@ -93,7 +96,7 @@ public Map getBestResourcesId() { if (resource.hasTextures()) return resource.textures().stream() .map(id -> IdentifierUtils.normalizeId(id, namespace)) - .collect(Collectors.toMap(id -> "_", id -> id)); + .collect(Collectors.toMap(id -> DEFAULT_STATE, id -> id)); else if (resource.hasModel()) return getMapResource(IdentifierUtils.normalizeId(resource.model(), namespace)); } @@ -134,7 +137,7 @@ private static Function> resolvePathFunction(String name return javaRoot -> resource.textures().stream() .map(id -> IdentifierUtils.resolveTextureId(javaRoot, IdentifierUtils.normalizeId(id, namespace))) - .collect(Collectors.toMap(v -> "_", k -> k)); + .collect(Collectors.toMap(v -> DEFAULT_STATE, k -> k)); else if (resource.hasModel()) return javaRoot -> getMapResource(IdentifierUtils.resolveModelId(javaRoot, IdentifierUtils.normalizeId(resource.model(), namespace))); @@ -166,6 +169,6 @@ public String namespacedId() { } public static Map getMapResource(T value) { - return Map.of("_", value); + return Map.of(DEFAULT_STATE, value); } } \ No newline at end of file diff --git a/src/main/java/fr/openmc/riftengine/api/scanner/items/ItemScanner.java b/src/main/java/fr/openmc/riftengine/api/scanner/items/ItemScanner.java index 43efa32a4..0e109d90d 100644 --- a/src/main/java/fr/openmc/riftengine/api/scanner/items/ItemScanner.java +++ b/src/main/java/fr/openmc/riftengine/api/scanner/items/ItemScanner.java @@ -4,7 +4,6 @@ import fr.openmc.core.bootstrap.integration.OMCLogger; import fr.openmc.core.utils.YmlUtils; import fr.openmc.riftengine.api.registry.scanner.AbstractScanner; -import org.bukkit.Material; import java.nio.file.Files; import java.nio.file.Path; @@ -20,6 +19,9 @@ public List scan(Path itemsAdderContentsPath) throws Exception { if (!Files.isDirectory(itemsAdderContentsPath)) return new ArrayList<>(); List ymlFiles = OMCRegistry.SCANNERS.YAML.scan(itemsAdderContentsPath); + // actualise les caches + OMCRegistry.SCANNERS.CUSTOM_MODEL_DATA_CACHE.getCache(null); + OMCRegistry.SCANNERS.BLOCKSTATES_CACHE.getCache(null); List result = new ArrayList<>(); @@ -32,14 +34,12 @@ public List scan(Path itemsAdderContentsPath) throws Exception { if (!(itemsObj instanceof Map itemsMap)) continue; String namespace = OMCRegistry.SCANNERS.YAML_ITEMSADDER_NAMESPACE.scan(root); - Map> cmdCache = OMCRegistry.SCANNERS.CUSTOM_MODEL_DATA_CACHE.scan(null); - Map blockStateCache = OMCRegistry.SCANNERS.BLOCKSTATES_CACHE.scan(null); for (Map.Entry entry : itemsMap.entrySet()) { String key = String.valueOf(entry.getKey()); if (!(entry.getValue() instanceof Map data)) continue; - result.add(ItemEntry.from(cmdCache, blockStateCache, ymlFile, namespace, key, data)); + result.add(ItemEntry.from(ymlFile, namespace, key, data)); } } diff --git a/src/main/java/fr/openmc/riftengine/api/scanner/items/entry/ItemInfo.java b/src/main/java/fr/openmc/riftengine/api/scanner/items/entry/ItemInfo.java index b53eb62e4..d8b126bea 100644 --- a/src/main/java/fr/openmc/riftengine/api/scanner/items/entry/ItemInfo.java +++ b/src/main/java/fr/openmc/riftengine/api/scanner/items/entry/ItemInfo.java @@ -1,18 +1,10 @@ package fr.openmc.riftengine.api.scanner.items.entry; -import org.bukkit.Material; - -import java.util.Map; - public record ItemInfo(String namespace, - String key, - Map> cmdCache, - Map blockStateCache) { + String key) { public static ItemInfo from(String namespace, - String key, - Map> cmdCache, - Map blockStateCache) { - return new ItemInfo(namespace, key, cmdCache, blockStateCache); + String key) { + return new ItemInfo(namespace, key); } public String namespacedId() { diff --git a/src/main/java/fr/openmc/riftengine/api/scanner/items/entry/behaviours/EmptyBehaviour.java b/src/main/java/fr/openmc/riftengine/api/scanner/items/entry/behaviours/EmptyBehaviour.java new file mode 100644 index 000000000..f9b85ba55 --- /dev/null +++ b/src/main/java/fr/openmc/riftengine/api/scanner/items/entry/behaviours/EmptyBehaviour.java @@ -0,0 +1,4 @@ +package fr.openmc.riftengine.api.scanner.items.entry.behaviours; + +public class EmptyBehaviour implements IABehaviour{ +} diff --git a/src/main/java/fr/openmc/riftengine/api/scanner/items/entry/behaviours/IABehaviour.java b/src/main/java/fr/openmc/riftengine/api/scanner/items/entry/behaviours/IABehaviour.java index 283fa553a..033e7614e 100644 --- a/src/main/java/fr/openmc/riftengine/api/scanner/items/entry/behaviours/IABehaviour.java +++ b/src/main/java/fr/openmc/riftengine/api/scanner/items/entry/behaviours/IABehaviour.java @@ -6,13 +6,13 @@ import java.util.Map; public interface IABehaviour { - static IABehaviour from(ItemInfo info, Map data) { - if (data == null) return null; + static IABehaviour from(ItemInfo info, Map data) throws Exception { + if (data == null) return new EmptyBehaviour(); Object resourceObj = data.get("behaviours"); Object specificPropertiesObj = data.get("specific_properties"); - if (resourceObj == null && specificPropertiesObj == null) return null; + if (resourceObj == null && specificPropertiesObj == null) return new EmptyBehaviour(); Map behaviours; @@ -20,10 +20,10 @@ static IABehaviour from(ItemInfo info, Map data) { behaviours = b; } else if (specificPropertiesObj instanceof Map b) { behaviours = b; - } else return null; + } else return new EmptyBehaviour(); - IABehaviour behaviour = null; + IABehaviour behaviour = new EmptyBehaviour(); if (behaviours.get("block") instanceof Map block) { behaviour = BlocksBehaviour.from(info, block); @@ -32,6 +32,10 @@ static IABehaviour from(ItemInfo info, Map data) { return behaviour; } + default boolean isItem() { + return !this.isBlock(); + } + default boolean isBlock() { return this instanceof BlocksBehaviour; } diff --git a/src/main/java/fr/openmc/riftengine/api/scanner/items/entry/behaviours/block/BlocksBehaviour.java b/src/main/java/fr/openmc/riftengine/api/scanner/items/entry/behaviours/block/BlocksBehaviour.java index d95c34ff0..a86faa0c1 100644 --- a/src/main/java/fr/openmc/riftengine/api/scanner/items/entry/behaviours/block/BlocksBehaviour.java +++ b/src/main/java/fr/openmc/riftengine/api/scanner/items/entry/behaviours/block/BlocksBehaviour.java @@ -1,6 +1,8 @@ package fr.openmc.riftengine.api.scanner.items.entry.behaviours.block; +import fr.openmc.core.OMCRegistry; import fr.openmc.core.utils.YmlUtils; +import fr.openmc.riftengine.api.scanner.blocks.BlockStateScanner; import fr.openmc.riftengine.api.scanner.items.entry.ItemInfo; import fr.openmc.riftengine.api.scanner.items.entry.behaviours.IABehaviour; @@ -9,7 +11,7 @@ // note: toutes les options ne sont pas mappé public record BlocksBehaviour(PlacedModel placedModel, - String blockState, + BlockStateScanner.CustomBlockState blockState, boolean dropWhenMined, int lightLevel, List breakToolsBlacklist, @@ -19,10 +21,11 @@ public record BlocksBehaviour(PlacedModel placedModel, boolean noExplosion, BlocksSound sounds ) implements IABehaviour { - public static BlocksBehaviour from(ItemInfo info, Map block) { + public static BlocksBehaviour from(ItemInfo info, Map block) throws Exception { double hardness = YmlUtils.getDouble(block, "hardness", 2d); - String blockState = info.blockStateCache().get(info.namespacedId()); + BlockStateScanner.CustomBlockState blockState = OMCRegistry.SCANNERS.BLOCKSTATES_CACHE.getCache(null) + .get(info.namespacedId()); return new BlocksBehaviour( PlacedModel.from(YmlUtils.getMap(block, "placed_model")), From 064f3d75a39e0945e22b21d6e521c448e19bcc1e Mon Sep 17 00:00:00 2001 From: iambibi <89582596+iambibi@users.noreply.github.com> Date: Mon, 19 Oct 2026 19:53:19 +0200 Subject: [PATCH 18/28] feat: pdate --- .../java/fr/openmc/core/utils/text/DateUtils.java | 11 ++++++----- .../items/entry/behaviours/EmptyBehaviour.java | 2 +- .../items/entry/behaviours/block/BlockType.java | 2 +- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/main/java/fr/openmc/core/utils/text/DateUtils.java b/src/main/java/fr/openmc/core/utils/text/DateUtils.java index 1a69ea521..fe0675a82 100644 --- a/src/main/java/fr/openmc/core/utils/text/DateUtils.java +++ b/src/main/java/fr/openmc/core/utils/text/DateUtils.java @@ -2,10 +2,7 @@ import fr.openmc.core.utils.text.messages.TranslationManager; import net.kyori.adventure.text.Component; -import java.time.DayOfWeek; -import java.time.Duration; -import java.time.LocalDate; -import java.time.LocalDateTime; + import java.time.*; import java.time.format.DateTimeFormatter; import java.time.format.TextStyle; @@ -224,7 +221,11 @@ public static long getSecondsUntilDayOfWeekTime(DayOfWeek dayOfWeek, int hour, i public static long getDelayBetweenNow(LocalDateTime time) { LocalDateTime now = getLocalDateTime(); - return ChronoUnit.SECONDS.between(now, time); } + + public static long getDelayBetweenNowMillis(LocalDateTime time) { + LocalDateTime now = getLocalDateTime(); + return ChronoUnit.MILLIS.between(now, time); + } } diff --git a/src/main/java/fr/openmc/riftengine/api/scanner/items/entry/behaviours/EmptyBehaviour.java b/src/main/java/fr/openmc/riftengine/api/scanner/items/entry/behaviours/EmptyBehaviour.java index f9b85ba55..c0ac87c42 100644 --- a/src/main/java/fr/openmc/riftengine/api/scanner/items/entry/behaviours/EmptyBehaviour.java +++ b/src/main/java/fr/openmc/riftengine/api/scanner/items/entry/behaviours/EmptyBehaviour.java @@ -1,4 +1,4 @@ package fr.openmc.riftengine.api.scanner.items.entry.behaviours; -public class EmptyBehaviour implements IABehaviour{ +public class EmptyBehaviour implements IABehaviour { } diff --git a/src/main/java/fr/openmc/riftengine/api/scanner/items/entry/behaviours/block/BlockType.java b/src/main/java/fr/openmc/riftengine/api/scanner/items/entry/behaviours/block/BlockType.java index 854b83a01..6920ddb11 100644 --- a/src/main/java/fr/openmc/riftengine/api/scanner/items/entry/behaviours/block/BlockType.java +++ b/src/main/java/fr/openmc/riftengine/api/scanner/items/entry/behaviours/block/BlockType.java @@ -5,7 +5,7 @@ public enum BlockType { REAL_NOTE, REAL, REAL_TRANSPARENT, - TILE, + ENTITY, FIRE, // le feu est un bloc cool UNKNOWN ; From 8e9986a8ab46ae6f22921cd619eb1f6452a08544 Mon Sep 17 00:00:00 2001 From: iambibi <89582596+iambibi@users.noreply.github.com> Date: Tue, 20 Oct 2026 10:03:04 +0200 Subject: [PATCH 19/28] feat: scan tooltip_style --- .../fr/openmc/riftengine/api/scanner/items/ItemEntry.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/java/fr/openmc/riftengine/api/scanner/items/ItemEntry.java b/src/main/java/fr/openmc/riftengine/api/scanner/items/ItemEntry.java index 64566a13a..9e8f893c4 100644 --- a/src/main/java/fr/openmc/riftengine/api/scanner/items/ItemEntry.java +++ b/src/main/java/fr/openmc/riftengine/api/scanner/items/ItemEntry.java @@ -1,6 +1,7 @@ package fr.openmc.riftengine.api.scanner.items; import fr.openmc.core.OMCRegistry; +import fr.openmc.core.utils.YmlUtils; import fr.openmc.riftengine.api.scanner.items.entry.ItemGraphics; import fr.openmc.riftengine.api.scanner.items.entry.ItemInfo; import fr.openmc.riftengine.api.scanner.items.entry.ItemResource; @@ -24,6 +25,7 @@ public class ItemEntry { private final String key; private final Integer customModelData; private final Material material; + private final String tooltipResourceId; private final ItemResource resource; private final ItemGraphics graphics; @@ -38,6 +40,7 @@ private ItemEntry( String key, Integer customModelData, Material material, + String tooltipResourceId, // * Méthodes de création d'items (moderne ou legacy) ItemResource resource, @@ -52,6 +55,7 @@ private ItemEntry( this.key = key; this.customModelData = customModelData; this.material = material; + this.tooltipResourceId = tooltipResourceId; this.resource = resource; this.graphics = graphics; this.resourcePath = resourcePath; @@ -67,6 +71,7 @@ public static ItemEntry from(Path sourceYml, ItemGraphics itemGraphics = ItemGraphics.from(data); Material material = getMaterial(itemResource, itemGraphics); ItemInfo itemInfo = ItemInfo.from(namespace, key); + String tooltipResourceId = YmlUtils.getString(data, "tooltip_style", null); IABehaviour behaviour = IABehaviour.from(itemInfo, data); Integer customModelData = null; @@ -83,6 +88,7 @@ public static ItemEntry from(Path sourceYml, key, customModelData, material, + tooltipResourceId, itemResource, itemGraphics, resolvePathFunction(namespace, itemGraphics, itemResource), From 2b309d1d6ac7af4c75b8e651aec3f58a6a17d04c Mon Sep 17 00:00:00 2001 From: iambibi <89582596+iambibi@users.noreply.github.com> Date: Tue, 20 Oct 2026 21:44:58 +0200 Subject: [PATCH 20/28] feat: tooltip (utils) --- .../java/fr/openmc/core/utils/JsonUtils.java | 51 +++++++++++++++++++ .../riftengine/api/utils/IdentifierUtils.java | 20 ++++++-- 2 files changed, 68 insertions(+), 3 deletions(-) create mode 100644 src/main/java/fr/openmc/core/utils/JsonUtils.java diff --git a/src/main/java/fr/openmc/core/utils/JsonUtils.java b/src/main/java/fr/openmc/core/utils/JsonUtils.java new file mode 100644 index 000000000..9f527bfb2 --- /dev/null +++ b/src/main/java/fr/openmc/core/utils/JsonUtils.java @@ -0,0 +1,51 @@ +package fr.openmc.core.utils; + +import com.google.gson.JsonArray; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; + +public class JsonUtils { + public static JsonObject loadJson(Path path) { + JsonObject root; + try { + root = JsonParser.parseString(Files.readString(path)).getAsJsonObject(); + } catch (IOException e) { + return null; + } + return root; + } + + public static JsonArray loadJsonArray(Path path) { + JsonArray root; + try { + root = JsonParser.parseString(Files.readString(path)).getAsJsonArray(); + } catch (IOException e) { + return null; + } + return root; + } + + public static JsonObject parseJson(String content) { + return JsonParser.parseString(content).getAsJsonObject(); + } + + public static JsonArray parseJsonArray(String content) { + return JsonParser.parseString(content).getAsJsonArray(); + } + + public static String getString(JsonObject object, String key, String def) { + return object.has(key) ? object.get(key).getAsString() : def; + } + + public static Integer getInt(JsonObject object, String key, Integer def) { + return object.has(key) ? object.get(key).getAsInt() : def; + } + + public static Boolean getBool(JsonObject object, String key, Boolean def) { + return object.has(key) ? object.get(key).getAsBoolean() : def; + } +} diff --git a/src/main/java/fr/openmc/riftengine/api/utils/IdentifierUtils.java b/src/main/java/fr/openmc/riftengine/api/utils/IdentifierUtils.java index 953fc1157..e20e54025 100644 --- a/src/main/java/fr/openmc/riftengine/api/utils/IdentifierUtils.java +++ b/src/main/java/fr/openmc/riftengine/api/utils/IdentifierUtils.java @@ -25,9 +25,23 @@ public static String normalizeId(String id, String defaultNamespace) { } /** - * Résout un identifiant en un chemin de fichier dans les assets + * Résout un identifiant en un chemin vers une image (.png) dans les assets */ public static Path resolveTextureId(Path rootPath, String id) { + return resolveFileId(rootPath, id, ".png"); + } + + /** + * Résout un identifiant en un chemin vers des meta donnée de mc (.mcmeta) dans les assets + */ + public static Path resolveMetaId(Path rootPath, String id, String ext) { + return resolveFileId(rootPath, id, ext + ".mcmeta"); + } + + /** + * Résout un identifiant en un chemin de fichier dans les assets + */ + public static Path resolveFileId(Path rootPath, String id, String ext) { String normalizedId = normalizeId(id); String[] split = normalizedId.split(":", 2); @@ -42,8 +56,8 @@ public static Path resolveTextureId(Path rootPath, String id) { texturePath = split[0]; } - if (!texturePath.endsWith(".png")) - texturePath += ".png"; + if (!texturePath.endsWith(ext)) + texturePath += ext; return rootPath From 41dc4622ee7bd7e5fe68b13e575b70d22ed98554 Mon Sep 17 00:00:00 2001 From: iambibi <89582596+iambibi@users.noreply.github.com> Date: Tue, 20 Oct 2026 22:56:17 +0200 Subject: [PATCH 21/28] feat: sounds --- .../java/fr/openmc/core/utils/JsonUtils.java | 4 ++ .../api/registry/scanner/ScannerRegistry.java | 6 +++ .../api/scanner/sounds/SoundEntry.java | 36 +++++++++++++ .../api/scanner/sounds/SoundScanner.java | 52 +++++++++++++++++++ 4 files changed, 98 insertions(+) create mode 100644 src/main/java/fr/openmc/riftengine/api/scanner/sounds/SoundEntry.java create mode 100644 src/main/java/fr/openmc/riftengine/api/scanner/sounds/SoundScanner.java diff --git a/src/main/java/fr/openmc/core/utils/JsonUtils.java b/src/main/java/fr/openmc/core/utils/JsonUtils.java index 9f527bfb2..73424e31f 100644 --- a/src/main/java/fr/openmc/core/utils/JsonUtils.java +++ b/src/main/java/fr/openmc/core/utils/JsonUtils.java @@ -48,4 +48,8 @@ public static Integer getInt(JsonObject object, String key, Integer def) { public static Boolean getBool(JsonObject object, String key, Boolean def) { return object.has(key) ? object.get(key).getAsBoolean() : def; } + + public static Float getFloat(JsonObject object, String key, Float def) { + return object.has(key) ? object.get(key).getAsFloat() : def; + } } diff --git a/src/main/java/fr/openmc/riftengine/api/registry/scanner/ScannerRegistry.java b/src/main/java/fr/openmc/riftengine/api/registry/scanner/ScannerRegistry.java index 960d8f8b6..ff4524dc2 100644 --- a/src/main/java/fr/openmc/riftengine/api/registry/scanner/ScannerRegistry.java +++ b/src/main/java/fr/openmc/riftengine/api/registry/scanner/ScannerRegistry.java @@ -8,14 +8,20 @@ import fr.openmc.riftengine.api.scanner.icons.IconScanner; import fr.openmc.riftengine.api.scanner.items.CustomModelDataScanner; import fr.openmc.riftengine.api.scanner.items.ItemScanner; +import fr.openmc.riftengine.api.scanner.sounds.SoundScanner; public class ScannerRegistry extends Registry> implements KeyedRegistry> { + public final SoundScanner SOUNDS = register(new SoundScanner()); + public final IconScanner ICONS = register(new IconScanner()); + public final ItemScanner ITEMS = register(new ItemScanner()); + public final CustomModelDataScanner CUSTOM_MODEL_DATA_CACHE = register(new CustomModelDataScanner()); public final BlockStateScanner BLOCKSTATES_CACHE = register(new BlockStateScanner()); + public final YamlNamespaceIAScanner YAML_ITEMSADDER_NAMESPACE = register(new YamlNamespaceIAScanner()); public final YamlScanner YAML = register(new YamlScanner()); diff --git a/src/main/java/fr/openmc/riftengine/api/scanner/sounds/SoundEntry.java b/src/main/java/fr/openmc/riftengine/api/scanner/sounds/SoundEntry.java new file mode 100644 index 000000000..ef1379679 --- /dev/null +++ b/src/main/java/fr/openmc/riftengine/api/scanner/sounds/SoundEntry.java @@ -0,0 +1,36 @@ +package fr.openmc.riftengine.api.scanner.sounds; + +import java.util.List; + +public record SoundEntry(String namespace, String path, List soundResourcesId) { + public String toBedrockEventId() { + return namespace + "." + path; + } + + public String toJavaPath(String defaultNamespace, String resourceId) { + String namespace = defaultNamespace; + String path = resourceId; + String[] split = resourceId.split(":"); + if (split.length == 2) { + namespace = split[0]; + path = split[1]; + } + + return "assets/" + namespace + "/sounds/" + path; + } + + /** + * omc_sounds:ambient/join_rift -> sounds/omc_sounds/ambient/join_rift + */ + public String toBedrockPath(String defaultNamespace, String resourceId) { + String namespace = defaultNamespace; + String path = resourceId; + + String[] split = resourceId.split(":"); + if (split.length == 2) { + namespace = split[0]; + path = split[1]; + } + return "sounds/" + namespace + "/" + path; + } +} \ No newline at end of file diff --git a/src/main/java/fr/openmc/riftengine/api/scanner/sounds/SoundScanner.java b/src/main/java/fr/openmc/riftengine/api/scanner/sounds/SoundScanner.java new file mode 100644 index 000000000..900d0ceeb --- /dev/null +++ b/src/main/java/fr/openmc/riftengine/api/scanner/sounds/SoundScanner.java @@ -0,0 +1,52 @@ +package fr.openmc.riftengine.api.scanner.sounds; + +import com.google.gson.JsonArray; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import fr.openmc.core.utils.FilesUtils; +import fr.openmc.core.utils.JsonUtils; +import fr.openmc.riftengine.api.registry.scanner.AbstractScanner; + +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +/** + * Scan tout les sons initialisé par ItemsAdder + */ +public class SoundScanner extends AbstractScanner, Path> { + @Override + public List scan(Path javaRootPath) { + List result = new ArrayList<>(); + Path assetsPath = javaRootPath.resolve("assets"); + + for (String namespace : FilesUtils.listFolderNames(assetsPath.toString())) { + Path file = assetsPath.resolve(namespace).resolve("sounds.json"); + if (!Files.exists(file)) continue; + + JsonObject root = JsonUtils.loadJson(file); + if (root == null) continue; + + for (Map.Entry entry : root.entrySet()) { + SoundEntry soundEntry = parseEntry(namespace, entry.getKey(), entry.getValue()); + if (soundEntry != null) result.add(soundEntry); + } + } + return result; + } + + private SoundEntry parseEntry(String namespace, String eventId, JsonElement element) { + if (!(element instanceof JsonObject eventObj)) return null; + if (!(eventObj.get("sounds") instanceof JsonArray soundsArray)) return null; + + List soundResourceId = new ArrayList<>(); + for (JsonElement elt : soundsArray) { + if (!(elt instanceof JsonObject jsonObject)) continue; + + soundResourceId.add(JsonUtils.getString(jsonObject, "name", null)); + } + return soundResourceId.isEmpty() ? null : new SoundEntry(namespace, eventId, soundResourceId); + } +} From f914e08c34a100b07f848b137dd0b793acf67c8d Mon Sep 17 00:00:00 2001 From: iambibi <89582596+iambibi@users.noreply.github.com> Date: Wed, 21 Oct 2026 19:56:43 +0200 Subject: [PATCH 22/28] feat: WIP menu gui --- .../api/registry/scanner/ScannerRegistry.java | 4 +++ .../icons/CaracterUnicodeCacheScanner.java | 31 ++++++++++++++++ .../scanner/icons/OffsetCaracterScanner.java | 35 +++++++++++++++++++ .../riftengine/api/utils/IdentifierUtils.java | 10 ++++++ 4 files changed, 80 insertions(+) create mode 100644 src/main/java/fr/openmc/riftengine/api/scanner/icons/CaracterUnicodeCacheScanner.java create mode 100644 src/main/java/fr/openmc/riftengine/api/scanner/icons/OffsetCaracterScanner.java diff --git a/src/main/java/fr/openmc/riftengine/api/registry/scanner/ScannerRegistry.java b/src/main/java/fr/openmc/riftengine/api/registry/scanner/ScannerRegistry.java index ff4524dc2..9ddbe7bda 100644 --- a/src/main/java/fr/openmc/riftengine/api/registry/scanner/ScannerRegistry.java +++ b/src/main/java/fr/openmc/riftengine/api/registry/scanner/ScannerRegistry.java @@ -5,7 +5,9 @@ import fr.openmc.riftengine.api.scanner.blocks.BlockStateScanner; import fr.openmc.riftengine.api.scanner.general.YamlNamespaceIAScanner; import fr.openmc.riftengine.api.scanner.general.YamlScanner; +import fr.openmc.riftengine.api.scanner.icons.CaracterUnicodeCacheScanner; import fr.openmc.riftengine.api.scanner.icons.IconScanner; +import fr.openmc.riftengine.api.scanner.icons.OffsetCaracterScanner; import fr.openmc.riftengine.api.scanner.items.CustomModelDataScanner; import fr.openmc.riftengine.api.scanner.items.ItemScanner; import fr.openmc.riftengine.api.scanner.sounds.SoundScanner; @@ -15,6 +17,8 @@ public class ScannerRegistry extends Registry> public final SoundScanner SOUNDS = register(new SoundScanner()); + public final CaracterUnicodeCacheScanner CARACTER_UNICODE_CACHE = register(new CaracterUnicodeCacheScanner()); + public final OffsetCaracterScanner OFFSET_CARACTER = register(new OffsetCaracterScanner()); public final IconScanner ICONS = register(new IconScanner()); public final ItemScanner ITEMS = register(new ItemScanner()); diff --git a/src/main/java/fr/openmc/riftengine/api/scanner/icons/CaracterUnicodeCacheScanner.java b/src/main/java/fr/openmc/riftengine/api/scanner/icons/CaracterUnicodeCacheScanner.java new file mode 100644 index 000000000..fcfabe315 --- /dev/null +++ b/src/main/java/fr/openmc/riftengine/api/scanner/icons/CaracterUnicodeCacheScanner.java @@ -0,0 +1,31 @@ +package fr.openmc.riftengine.api.scanner.icons; + +import fr.openmc.core.utils.YmlUtils; +import fr.openmc.riftengine.api.registry.scanner.AbstractScanner; + +import java.io.IOException; +import java.nio.file.Path; +import java.util.HashMap; +import java.util.Map; + +public class CaracterUnicodeCacheScanner extends AbstractScanner, Path> { + private final String TARGET_FILE = "storage/font_images_unicode_cache.yml"; + + public Map scan(Path itemsAdderDataPath) throws IOException { + Map caractersByNamespacedId = new HashMap<>(); + + Map cache = YmlUtils.loadYml(itemsAdderDataPath.resolve(TARGET_FILE)); + if (cache == null) return caractersByNamespacedId; + + for (Map.Entry entry : cache.entrySet()) { + String namespacedId = entry.getKey(); + String character = YmlUtils.getString(cache, namespacedId, ""); + + if (character.isEmpty()) continue; + + caractersByNamespacedId.put(character.charAt(0), namespacedId); + } + + return caractersByNamespacedId; + } +} diff --git a/src/main/java/fr/openmc/riftengine/api/scanner/icons/OffsetCaracterScanner.java b/src/main/java/fr/openmc/riftengine/api/scanner/icons/OffsetCaracterScanner.java new file mode 100644 index 000000000..fc40630ce --- /dev/null +++ b/src/main/java/fr/openmc/riftengine/api/scanner/icons/OffsetCaracterScanner.java @@ -0,0 +1,35 @@ +package fr.openmc.riftengine.api.scanner.icons; + +import com.google.gson.JsonArray; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import fr.openmc.core.utils.JsonUtils; +import fr.openmc.riftengine.api.registry.scanner.AbstractScanner; + +import java.nio.file.Path; +import java.util.HashSet; +import java.util.Set; + +public class OffsetCaracterScanner extends AbstractScanner, Path> { + private final String TARGET_FILE = "assets/minecraft/font/default.json"; + + public Set scan(Path javaRootPath) { + Set offsetCaracters = new HashSet<>(); + + JsonObject jsonObject = JsonUtils.loadJson(javaRootPath.resolve(TARGET_FILE)); + for (JsonElement elt : jsonObject.getAsJsonArray("providers")) { + JsonObject provider = elt.getAsJsonObject(); + + if (!(provider.has("file") && + JsonUtils.getString(provider, "file", "e").equals("char/black.png"))) continue; + + JsonArray chars = provider.getAsJsonArray("chars"); + + for (JsonElement charElt : chars) { + offsetCaracters.add(charElt.getAsString().charAt(0)); + } + } + + return offsetCaracters; + } +} diff --git a/src/main/java/fr/openmc/riftengine/api/utils/IdentifierUtils.java b/src/main/java/fr/openmc/riftengine/api/utils/IdentifierUtils.java index e20e54025..41967a14f 100644 --- a/src/main/java/fr/openmc/riftengine/api/utils/IdentifierUtils.java +++ b/src/main/java/fr/openmc/riftengine/api/utils/IdentifierUtils.java @@ -24,6 +24,13 @@ public static String normalizeId(String id, String defaultNamespace) { return defaultNamespace + ":" + id; } + public static String removeNamespace(String namespacedId) { + String[] splited = namespacedId.split(":"); + if (splited.length != 2) return namespacedId; + + return splited[1]; + } + /** * Résout un identifiant en un chemin vers une image (.png) dans les assets */ @@ -96,6 +103,9 @@ public static Path resolveModelId(Path rootPath, String id) { } public static String toBedrockTexturePath(String javaPath) { + if (!javaPath.endsWith(".png")) + javaPath = javaPath + ".png"; + if (javaPath.startsWith("textures/item/")) return "textures/items/" + javaPath.substring("textures/item/".length()); if (javaPath.startsWith("textures/block/")) From 94a2c09d401da042d2faecea75625edc620f1a77 Mon Sep 17 00:00:00 2001 From: iambibi <89582596+iambibi@users.noreply.github.com> Date: Wed, 21 Oct 2026 20:41:51 +0200 Subject: [PATCH 23/28] feat: ArmorsBehaviour --- .../api/registry/scanner/ScannerRegistry.java | 2 + .../scanner/equipements/EquipementEntry.java | 19 +++++++ .../equipements/EquipementsScanner.java | 49 +++++++++++++++++++ .../api/scanner/items/ItemEntry.java | 7 ++- .../api/scanner/items/ItemScanner.java | 5 +- .../items/entry/behaviours/IABehaviour.java | 27 ++++------ .../behaviours/armors/ArmorsBehaviour.java | 32 ++++++++++++ .../behaviours/block/BlocksBehaviour.java | 24 ++++++++- 8 files changed, 143 insertions(+), 22 deletions(-) create mode 100644 src/main/java/fr/openmc/riftengine/api/scanner/equipements/EquipementEntry.java create mode 100644 src/main/java/fr/openmc/riftengine/api/scanner/equipements/EquipementsScanner.java create mode 100644 src/main/java/fr/openmc/riftengine/api/scanner/items/entry/behaviours/armors/ArmorsBehaviour.java diff --git a/src/main/java/fr/openmc/riftengine/api/registry/scanner/ScannerRegistry.java b/src/main/java/fr/openmc/riftengine/api/registry/scanner/ScannerRegistry.java index 9ddbe7bda..b15b8a257 100644 --- a/src/main/java/fr/openmc/riftengine/api/registry/scanner/ScannerRegistry.java +++ b/src/main/java/fr/openmc/riftengine/api/registry/scanner/ScannerRegistry.java @@ -3,6 +3,7 @@ import fr.openmc.core.bootstrap.registries.KeyedRegistry; import fr.openmc.core.bootstrap.registries.Registry; import fr.openmc.riftengine.api.scanner.blocks.BlockStateScanner; +import fr.openmc.riftengine.api.scanner.equipements.EquipementsScanner; import fr.openmc.riftengine.api.scanner.general.YamlNamespaceIAScanner; import fr.openmc.riftengine.api.scanner.general.YamlScanner; import fr.openmc.riftengine.api.scanner.icons.CaracterUnicodeCacheScanner; @@ -22,6 +23,7 @@ public class ScannerRegistry extends Registry> public final IconScanner ICONS = register(new IconScanner()); public final ItemScanner ITEMS = register(new ItemScanner()); + public final EquipementsScanner ARMORS = register(new EquipementsScanner()); public final CustomModelDataScanner CUSTOM_MODEL_DATA_CACHE = register(new CustomModelDataScanner()); public final BlockStateScanner BLOCKSTATES_CACHE = register(new BlockStateScanner()); diff --git a/src/main/java/fr/openmc/riftengine/api/scanner/equipements/EquipementEntry.java b/src/main/java/fr/openmc/riftengine/api/scanner/equipements/EquipementEntry.java new file mode 100644 index 000000000..55169002a --- /dev/null +++ b/src/main/java/fr/openmc/riftengine/api/scanner/equipements/EquipementEntry.java @@ -0,0 +1,19 @@ +package fr.openmc.riftengine.api.scanner.equipements; + +import fr.openmc.riftengine.api.utils.IdentifierUtils; + +import java.nio.file.Path; + +public record EquipementEntry(String namespace, String key, String layer1Path, String layer2Path) { + public String namespacedId() { + return namespace + ":" + key; + } + + public Path getLayer1Path(Path javaRootPath) { + return IdentifierUtils.resolveTextureId(javaRootPath, namespace + ":" + layer1Path); + } + + public Path getLayer2Path(Path javaRootPath) { + return IdentifierUtils.resolveTextureId(javaRootPath, namespace + ":" + layer2Path); + } +} diff --git a/src/main/java/fr/openmc/riftengine/api/scanner/equipements/EquipementsScanner.java b/src/main/java/fr/openmc/riftengine/api/scanner/equipements/EquipementsScanner.java new file mode 100644 index 000000000..b03530ad3 --- /dev/null +++ b/src/main/java/fr/openmc/riftengine/api/scanner/equipements/EquipementsScanner.java @@ -0,0 +1,49 @@ +package fr.openmc.riftengine.api.scanner.equipements; + +import fr.openmc.core.OMCRegistry; +import fr.openmc.core.utils.YmlUtils; +import fr.openmc.riftengine.api.registry.scanner.AbstractScanner; + +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +/** + * Scan tout les equipements initialisé par ItemsAdder + */ +public class EquipementsScanner extends AbstractScanner, Path> { + public List scan(Path itemsAdderContentsPath) throws Exception { + if (!Files.isDirectory(itemsAdderContentsPath)) return new ArrayList<>(); + + List ymlFiles = OMCRegistry.SCANNERS.YAML.scan(itemsAdderContentsPath); + + List result = new ArrayList<>(); + + for (Path ymlFile : ymlFiles) { + Map root = YmlUtils.loadYml(ymlFile); + + if (root == null) continue; + + Object equipements = root.get("equipements"); + if (!(equipements instanceof Map equipementsMap)) continue; + + String namespace = OMCRegistry.SCANNERS.YAML_ITEMSADDER_NAMESPACE.scan(root); + + for (Map.Entry entry : equipementsMap.entrySet()) { + String key = String.valueOf(entry.getKey()); + + if (!(key.equals("layer_1") && key.equals("layer_2"))) continue; + + result.add(new EquipementEntry( + namespace, + key, + YmlUtils.getString(root, "layer_1", null), + YmlUtils.getString(root, "layer_2", null))); + } + } + + return result; + } +} diff --git a/src/main/java/fr/openmc/riftengine/api/scanner/items/ItemEntry.java b/src/main/java/fr/openmc/riftengine/api/scanner/items/ItemEntry.java index 9e8f893c4..9e90fd9a8 100644 --- a/src/main/java/fr/openmc/riftengine/api/scanner/items/ItemEntry.java +++ b/src/main/java/fr/openmc/riftengine/api/scanner/items/ItemEntry.java @@ -2,6 +2,7 @@ import fr.openmc.core.OMCRegistry; import fr.openmc.core.utils.YmlUtils; +import fr.openmc.riftengine.api.scanner.equipements.EquipementEntry; import fr.openmc.riftengine.api.scanner.items.entry.ItemGraphics; import fr.openmc.riftengine.api.scanner.items.entry.ItemInfo; import fr.openmc.riftengine.api.scanner.items.entry.ItemResource; @@ -13,6 +14,7 @@ import java.nio.file.Path; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.function.Function; import java.util.stream.Collectors; @@ -66,14 +68,15 @@ private ItemEntry( public static ItemEntry from(Path sourceYml, String namespace, String key, - Map data) throws Exception { + Map data, + List equipements) throws Exception { ItemResource itemResource = ItemResource.from(data); ItemGraphics itemGraphics = ItemGraphics.from(data); Material material = getMaterial(itemResource, itemGraphics); ItemInfo itemInfo = ItemInfo.from(namespace, key); String tooltipResourceId = YmlUtils.getString(data, "tooltip_style", null); - IABehaviour behaviour = IABehaviour.from(itemInfo, data); + IABehaviour behaviour = IABehaviour.from(itemInfo, data, equipements); Integer customModelData = null; if (behaviour.isBlock() && behaviour instanceof BlocksBehaviour blockBehaviour) diff --git a/src/main/java/fr/openmc/riftengine/api/scanner/items/ItemScanner.java b/src/main/java/fr/openmc/riftengine/api/scanner/items/ItemScanner.java index 0e109d90d..4bf30848b 100644 --- a/src/main/java/fr/openmc/riftengine/api/scanner/items/ItemScanner.java +++ b/src/main/java/fr/openmc/riftengine/api/scanner/items/ItemScanner.java @@ -4,6 +4,7 @@ import fr.openmc.core.bootstrap.integration.OMCLogger; import fr.openmc.core.utils.YmlUtils; import fr.openmc.riftengine.api.registry.scanner.AbstractScanner; +import fr.openmc.riftengine.api.scanner.equipements.EquipementEntry; import java.nio.file.Files; import java.nio.file.Path; @@ -19,6 +20,8 @@ public List scan(Path itemsAdderContentsPath) throws Exception { if (!Files.isDirectory(itemsAdderContentsPath)) return new ArrayList<>(); List ymlFiles = OMCRegistry.SCANNERS.YAML.scan(itemsAdderContentsPath); + List equipements = OMCRegistry.SCANNERS.ARMORS.scan(itemsAdderContentsPath); + // actualise les caches OMCRegistry.SCANNERS.CUSTOM_MODEL_DATA_CACHE.getCache(null); OMCRegistry.SCANNERS.BLOCKSTATES_CACHE.getCache(null); @@ -39,7 +42,7 @@ public List scan(Path itemsAdderContentsPath) throws Exception { String key = String.valueOf(entry.getKey()); if (!(entry.getValue() instanceof Map data)) continue; - result.add(ItemEntry.from(ymlFile, namespace, key, data)); + result.add(ItemEntry.from(ymlFile, namespace, key, data, equipements)); } } diff --git a/src/main/java/fr/openmc/riftengine/api/scanner/items/entry/behaviours/IABehaviour.java b/src/main/java/fr/openmc/riftengine/api/scanner/items/entry/behaviours/IABehaviour.java index 033e7614e..9984ee011 100644 --- a/src/main/java/fr/openmc/riftengine/api/scanner/items/entry/behaviours/IABehaviour.java +++ b/src/main/java/fr/openmc/riftengine/api/scanner/items/entry/behaviours/IABehaviour.java @@ -1,33 +1,22 @@ package fr.openmc.riftengine.api.scanner.items.entry.behaviours; +import fr.openmc.riftengine.api.scanner.equipements.EquipementEntry; import fr.openmc.riftengine.api.scanner.items.entry.ItemInfo; +import fr.openmc.riftengine.api.scanner.items.entry.behaviours.armors.ArmorsBehaviour; import fr.openmc.riftengine.api.scanner.items.entry.behaviours.block.BlocksBehaviour; +import java.util.List; import java.util.Map; public interface IABehaviour { - static IABehaviour from(ItemInfo info, Map data) throws Exception { + static IABehaviour from(ItemInfo info, Map data, List equipements) throws Exception { if (data == null) return new EmptyBehaviour(); Object resourceObj = data.get("behaviours"); - Object specificPropertiesObj = data.get("specific_properties"); - if (resourceObj == null && specificPropertiesObj == null) return new EmptyBehaviour(); + IABehaviour behaviour = BlocksBehaviour.detectBlockBehaviour(info, data, resourceObj); - Map behaviours; - - if (resourceObj instanceof Map b) { - behaviours = b; - } else if (specificPropertiesObj instanceof Map b) { - behaviours = b; - } else return new EmptyBehaviour(); - - - IABehaviour behaviour = new EmptyBehaviour(); - - if (behaviours.get("block") instanceof Map block) { - behaviour = BlocksBehaviour.from(info, block); - } + if (behaviour == null) return ArmorsBehaviour.detectArmorBehaviour(data, equipements); return behaviour; } @@ -36,6 +25,10 @@ default boolean isItem() { return !this.isBlock(); } + default boolean isArmor() { + return this instanceof ArmorsBehaviour; + } + default boolean isBlock() { return this instanceof BlocksBehaviour; } diff --git a/src/main/java/fr/openmc/riftengine/api/scanner/items/entry/behaviours/armors/ArmorsBehaviour.java b/src/main/java/fr/openmc/riftengine/api/scanner/items/entry/behaviours/armors/ArmorsBehaviour.java new file mode 100644 index 000000000..834d54858 --- /dev/null +++ b/src/main/java/fr/openmc/riftengine/api/scanner/items/entry/behaviours/armors/ArmorsBehaviour.java @@ -0,0 +1,32 @@ +package fr.openmc.riftengine.api.scanner.items.entry.behaviours.armors; + +import fr.openmc.core.utils.YmlUtils; +import fr.openmc.riftengine.api.scanner.equipements.EquipementEntry; +import fr.openmc.riftengine.api.scanner.items.entry.behaviours.EmptyBehaviour; +import fr.openmc.riftengine.api.scanner.items.entry.behaviours.IABehaviour; + +import java.util.List; +import java.util.Map; + +public record ArmorsBehaviour(EquipementEntry entry) implements IABehaviour { + private static ArmorsBehaviour from(List equipements, Map equipement) { + String id = YmlUtils.getString(equipement, "id", null); + + EquipementEntry entry = equipements.stream() + .filter(e -> e.namespacedId().equals(id)) + .findFirst() + .orElse(null); + + return new ArmorsBehaviour(entry); + } + + public static IABehaviour detectArmorBehaviour(Map data, List equipements) { + Object equipement = data.get("equipement"); + + if (equipement == null) return new EmptyBehaviour(); + + Map equipementMap = (Map) equipement; + + return ArmorsBehaviour.from(equipements, equipementMap); + } +} diff --git a/src/main/java/fr/openmc/riftengine/api/scanner/items/entry/behaviours/block/BlocksBehaviour.java b/src/main/java/fr/openmc/riftengine/api/scanner/items/entry/behaviours/block/BlocksBehaviour.java index a86faa0c1..fdb9a5b2a 100644 --- a/src/main/java/fr/openmc/riftengine/api/scanner/items/entry/behaviours/block/BlocksBehaviour.java +++ b/src/main/java/fr/openmc/riftengine/api/scanner/items/entry/behaviours/block/BlocksBehaviour.java @@ -4,12 +4,12 @@ import fr.openmc.core.utils.YmlUtils; import fr.openmc.riftengine.api.scanner.blocks.BlockStateScanner; import fr.openmc.riftengine.api.scanner.items.entry.ItemInfo; +import fr.openmc.riftengine.api.scanner.items.entry.behaviours.EmptyBehaviour; import fr.openmc.riftengine.api.scanner.items.entry.behaviours.IABehaviour; import java.util.List; import java.util.Map; -// note: toutes les options ne sont pas mappé public record BlocksBehaviour(PlacedModel placedModel, BlockStateScanner.CustomBlockState blockState, boolean dropWhenMined, @@ -21,7 +21,7 @@ public record BlocksBehaviour(PlacedModel placedModel, boolean noExplosion, BlocksSound sounds ) implements IABehaviour { - public static BlocksBehaviour from(ItemInfo info, Map block) throws Exception { + private static BlocksBehaviour from(ItemInfo info, Map block) throws Exception { double hardness = YmlUtils.getDouble(block, "hardness", 2d); BlockStateScanner.CustomBlockState blockState = OMCRegistry.SCANNERS.BLOCKSTATES_CACHE.getCache(null) @@ -40,4 +40,24 @@ public static BlocksBehaviour from(ItemInfo info, Map block) throws Except BlocksSound.from(YmlUtils.getMap(block, "sound")) ); } + + public static IABehaviour detectBlockBehaviour(ItemInfo info, Map data, Object resourceObj) throws Exception { + Object specificPropertiesObj = data.get("specific_properties"); + + if (resourceObj == null && specificPropertiesObj == null) return new EmptyBehaviour(); + + Map behaviours; + + if (resourceObj instanceof Map b) { + behaviours = b; + } else if (specificPropertiesObj instanceof Map b) { + behaviours = b; + } else return new EmptyBehaviour(); + + + if (behaviours.get("block") instanceof Map block) + return BlocksBehaviour.from(info, block); + + return new EmptyBehaviour(); + } } From b34229f8ffef22321054d5651c5c6d47cc0e73b9 Mon Sep 17 00:00:00 2001 From: iambibi <89582596+iambibi@users.noreply.github.com> Date: Thu, 22 Oct 2026 10:50:13 +0200 Subject: [PATCH 24/28] feat: custom armor --- .../scanner/equipements/EquipementEntry.java | 19 +++++++--- .../equipements/EquipementsScanner.java | 14 ++++---- .../api/scanner/items/ItemEntry.java | 2 +- .../api/scanner/items/entry/ItemInfo.java | 10 ++++-- .../items/entry/behaviours/IABehaviour.java | 5 +-- .../entry/behaviours/armors/ArmorType.java | 36 +++++++++++++++++++ .../behaviours/armors/ArmorsBehaviour.java | 19 +++++----- 7 files changed, 79 insertions(+), 26 deletions(-) create mode 100644 src/main/java/fr/openmc/riftengine/api/scanner/items/entry/behaviours/armors/ArmorType.java diff --git a/src/main/java/fr/openmc/riftengine/api/scanner/equipements/EquipementEntry.java b/src/main/java/fr/openmc/riftengine/api/scanner/equipements/EquipementEntry.java index 55169002a..5bcd88bea 100644 --- a/src/main/java/fr/openmc/riftengine/api/scanner/equipements/EquipementEntry.java +++ b/src/main/java/fr/openmc/riftengine/api/scanner/equipements/EquipementEntry.java @@ -1,7 +1,5 @@ package fr.openmc.riftengine.api.scanner.equipements; -import fr.openmc.riftengine.api.utils.IdentifierUtils; - import java.nio.file.Path; public record EquipementEntry(String namespace, String key, String layer1Path, String layer2Path) { @@ -10,10 +8,23 @@ public String namespacedId() { } public Path getLayer1Path(Path javaRootPath) { - return IdentifierUtils.resolveTextureId(javaRootPath, namespace + ":" + layer1Path); + return baseLayerPath(javaRootPath).resolve("humanoid").resolve(key + ".png"); } public Path getLayer2Path(Path javaRootPath) { - return IdentifierUtils.resolveTextureId(javaRootPath, namespace + ":" + layer2Path); + return baseLayerPath(javaRootPath).resolve("humanoid_leggings").resolve(key + ".png"); + } + + private Path baseLayerPath(Path javaRootPath) { + return javaRootPath.resolve("assets") + .resolve(namespace).resolve("textures/entity/equipment/"); + } + + public Path getLayer1BedrockPath(Path bedrockRootPath) { + return bedrockRootPath.resolve("textures").resolve(layer1Path + ".png"); + } + + public Path getLayer2BedrockPath(Path bedrockRootPath) { + return bedrockRootPath.resolve("textures").resolve(layer2Path + ".png"); } } diff --git a/src/main/java/fr/openmc/riftengine/api/scanner/equipements/EquipementsScanner.java b/src/main/java/fr/openmc/riftengine/api/scanner/equipements/EquipementsScanner.java index b03530ad3..798b1b9a0 100644 --- a/src/main/java/fr/openmc/riftengine/api/scanner/equipements/EquipementsScanner.java +++ b/src/main/java/fr/openmc/riftengine/api/scanner/equipements/EquipementsScanner.java @@ -26,21 +26,21 @@ public List scan(Path itemsAdderContentsPath) throws Exception if (root == null) continue; - Object equipements = root.get("equipements"); - if (!(equipements instanceof Map equipementsMap)) continue; + Map equipments = YmlUtils.getMap(root, "equipments"); + + if (equipments == null) continue; String namespace = OMCRegistry.SCANNERS.YAML_ITEMSADDER_NAMESPACE.scan(root); - for (Map.Entry entry : equipementsMap.entrySet()) { + for (Map.Entry entry : equipments.entrySet()) { String key = String.valueOf(entry.getKey()); - - if (!(key.equals("layer_1") && key.equals("layer_2"))) continue; + Map keyInfo = YmlUtils.getMap(equipments, key); result.add(new EquipementEntry( namespace, key, - YmlUtils.getString(root, "layer_1", null), - YmlUtils.getString(root, "layer_2", null))); + YmlUtils.getString(keyInfo, "layer_1", null), + YmlUtils.getString(keyInfo, "layer_2", null))); } } diff --git a/src/main/java/fr/openmc/riftengine/api/scanner/items/ItemEntry.java b/src/main/java/fr/openmc/riftengine/api/scanner/items/ItemEntry.java index 9e90fd9a8..a926ba96a 100644 --- a/src/main/java/fr/openmc/riftengine/api/scanner/items/ItemEntry.java +++ b/src/main/java/fr/openmc/riftengine/api/scanner/items/ItemEntry.java @@ -73,7 +73,7 @@ public static ItemEntry from(Path sourceYml, ItemResource itemResource = ItemResource.from(data); ItemGraphics itemGraphics = ItemGraphics.from(data); Material material = getMaterial(itemResource, itemGraphics); - ItemInfo itemInfo = ItemInfo.from(namespace, key); + ItemInfo itemInfo = ItemInfo.from(namespace, key, material); String tooltipResourceId = YmlUtils.getString(data, "tooltip_style", null); IABehaviour behaviour = IABehaviour.from(itemInfo, data, equipements); diff --git a/src/main/java/fr/openmc/riftengine/api/scanner/items/entry/ItemInfo.java b/src/main/java/fr/openmc/riftengine/api/scanner/items/entry/ItemInfo.java index d8b126bea..3647a08f1 100644 --- a/src/main/java/fr/openmc/riftengine/api/scanner/items/entry/ItemInfo.java +++ b/src/main/java/fr/openmc/riftengine/api/scanner/items/entry/ItemInfo.java @@ -1,10 +1,14 @@ package fr.openmc.riftengine.api.scanner.items.entry; +import org.bukkit.Material; + public record ItemInfo(String namespace, - String key) { + String key, + Material material) { public static ItemInfo from(String namespace, - String key) { - return new ItemInfo(namespace, key); + String key, + Material material) { + return new ItemInfo(namespace, key, material); } public String namespacedId() { diff --git a/src/main/java/fr/openmc/riftengine/api/scanner/items/entry/behaviours/IABehaviour.java b/src/main/java/fr/openmc/riftengine/api/scanner/items/entry/behaviours/IABehaviour.java index 9984ee011..542b9a61d 100644 --- a/src/main/java/fr/openmc/riftengine/api/scanner/items/entry/behaviours/IABehaviour.java +++ b/src/main/java/fr/openmc/riftengine/api/scanner/items/entry/behaviours/IABehaviour.java @@ -11,12 +11,13 @@ public interface IABehaviour { static IABehaviour from(ItemInfo info, Map data, List equipements) throws Exception { if (data == null) return new EmptyBehaviour(); - Object resourceObj = data.get("behaviours"); IABehaviour behaviour = BlocksBehaviour.detectBlockBehaviour(info, data, resourceObj); - if (behaviour == null) return ArmorsBehaviour.detectArmorBehaviour(data, equipements); + if (behaviour instanceof EmptyBehaviour) { + return ArmorsBehaviour.detectArmorBehaviour(info, data, equipements); + } return behaviour; } diff --git a/src/main/java/fr/openmc/riftengine/api/scanner/items/entry/behaviours/armors/ArmorType.java b/src/main/java/fr/openmc/riftengine/api/scanner/items/entry/behaviours/armors/ArmorType.java new file mode 100644 index 000000000..a2b8e4130 --- /dev/null +++ b/src/main/java/fr/openmc/riftengine/api/scanner/items/entry/behaviours/armors/ArmorType.java @@ -0,0 +1,36 @@ +package fr.openmc.riftengine.api.scanner.items.entry.behaviours.armors; + +import lombok.Getter; +import org.bukkit.Material; + +import java.util.Arrays; + +@Getter +public enum ArmorType { + HELMET("helmet", "helmet"), + CHESTPLATE("chestplate", "chest"), + LEGGINGS("leggings", "leg"), + BOOTS("boots", "boot") + ; + + private final String type; + private final String shortType; + + ArmorType(String type, String shortType) { + this.type = type; + this.shortType = shortType; + } + + public static ArmorType from(Material material) { + return Arrays.stream(ArmorType.values()) + .filter(t -> material.name().toLowerCase().contains(t.type)) + .findFirst() + .orElse(null); + } + + public String selectLayer(String layer1, String layer2) { + if (this.equals(ArmorType.LEGGINGS)) + return layer2; + return layer1; + } +} diff --git a/src/main/java/fr/openmc/riftengine/api/scanner/items/entry/behaviours/armors/ArmorsBehaviour.java b/src/main/java/fr/openmc/riftengine/api/scanner/items/entry/behaviours/armors/ArmorsBehaviour.java index 834d54858..19a0e2cdf 100644 --- a/src/main/java/fr/openmc/riftengine/api/scanner/items/entry/behaviours/armors/ArmorsBehaviour.java +++ b/src/main/java/fr/openmc/riftengine/api/scanner/items/entry/behaviours/armors/ArmorsBehaviour.java @@ -2,14 +2,15 @@ import fr.openmc.core.utils.YmlUtils; import fr.openmc.riftengine.api.scanner.equipements.EquipementEntry; +import fr.openmc.riftengine.api.scanner.items.entry.ItemInfo; import fr.openmc.riftengine.api.scanner.items.entry.behaviours.EmptyBehaviour; import fr.openmc.riftengine.api.scanner.items.entry.behaviours.IABehaviour; import java.util.List; import java.util.Map; -public record ArmorsBehaviour(EquipementEntry entry) implements IABehaviour { - private static ArmorsBehaviour from(List equipements, Map equipement) { +public record ArmorsBehaviour(EquipementEntry entry, ArmorType type) implements IABehaviour { + private static ArmorsBehaviour from(ItemInfo itemInfo, List equipements, Map equipement) { String id = YmlUtils.getString(equipement, "id", null); EquipementEntry entry = equipements.stream() @@ -17,16 +18,16 @@ private static ArmorsBehaviour from(List equipements, Map .findFirst() .orElse(null); - return new ArmorsBehaviour(entry); - } + ArmorType type = ArmorType.from(itemInfo.material()); - public static IABehaviour detectArmorBehaviour(Map data, List equipements) { - Object equipement = data.get("equipement"); + return new ArmorsBehaviour(entry, type); + } - if (equipement == null) return new EmptyBehaviour(); + public static IABehaviour detectArmorBehaviour(ItemInfo info, Map data, List equipements) { + Map equipment = YmlUtils.getMap(data, "equipment"); - Map equipementMap = (Map) equipement; + if (equipment == null) return new EmptyBehaviour(); - return ArmorsBehaviour.from(equipements, equipementMap); + return ArmorsBehaviour.from(info, equipements, equipment); } } From ef174cb7fad511d8a65c8fb0fdfb345d6d22ba44 Mon Sep 17 00:00:00 2001 From: iambibi <89582596+iambibi@users.noreply.github.com> Date: Thu, 22 Oct 2026 10:51:29 +0200 Subject: [PATCH 25/28] fix: cold boots --- .../dream/registries/items/armors/cold/ColdBoots.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/fr/openmc/core/features/dream/registries/items/armors/cold/ColdBoots.java b/src/main/java/fr/openmc/core/features/dream/registries/items/armors/cold/ColdBoots.java index 2920e4fbf..3e2224ba2 100644 --- a/src/main/java/fr/openmc/core/features/dream/registries/items/armors/cold/ColdBoots.java +++ b/src/main/java/fr/openmc/core/features/dream/registries/items/armors/cold/ColdBoots.java @@ -13,8 +13,8 @@ public ColdBoots() { super(new DreamItemMeta( "omc_dream:cold_boots", TranslationManager.translation("feature.dream.item.cold_boots.name"), - DreamRarity.EPIC, - Material.LEATHER_LEGGINGS, + DreamRarity.LEGENDARY, + Material.LEATHER_BOOTS, true )); } From 158a86fa219cd24eb0a125aea36fbca6daaa9f46 Mon Sep 17 00:00:00 2001 From: iambibi <89582596+iambibi@users.noreply.github.com> Date: Thu, 22 Oct 2026 16:41:35 +0200 Subject: [PATCH 26/28] feat: start of items 3d --- .../api/scanner/items/ItemEntry.java | 7 ++ .../api/scanner/items/entry/ItemGraphics.java | 4 +- .../api/scanner/items/entry/ItemModel.java | 76 +++++++++++++++++++ 3 files changed, 86 insertions(+), 1 deletion(-) create mode 100644 src/main/java/fr/openmc/riftengine/api/scanner/items/entry/ItemModel.java diff --git a/src/main/java/fr/openmc/riftengine/api/scanner/items/ItemEntry.java b/src/main/java/fr/openmc/riftengine/api/scanner/items/ItemEntry.java index a926ba96a..96985850d 100644 --- a/src/main/java/fr/openmc/riftengine/api/scanner/items/ItemEntry.java +++ b/src/main/java/fr/openmc/riftengine/api/scanner/items/ItemEntry.java @@ -5,6 +5,7 @@ import fr.openmc.riftengine.api.scanner.equipements.EquipementEntry; import fr.openmc.riftengine.api.scanner.items.entry.ItemGraphics; import fr.openmc.riftengine.api.scanner.items.entry.ItemInfo; +import fr.openmc.riftengine.api.scanner.items.entry.ItemModel; import fr.openmc.riftengine.api.scanner.items.entry.ItemResource; import fr.openmc.riftengine.api.scanner.items.entry.behaviours.IABehaviour; import fr.openmc.riftengine.api.scanner.items.entry.behaviours.block.BlocksBehaviour; @@ -31,6 +32,7 @@ public class ItemEntry { private final ItemResource resource; private final ItemGraphics graphics; + private final ItemModel model; private final Function> resourcePath; private final IABehaviour behaviour; @@ -47,6 +49,7 @@ private ItemEntry( // * Méthodes de création d'items (moderne ou legacy) ItemResource resource, ItemGraphics graphics, + ItemModel model, Function> resourcePath, IABehaviour behaviour, @@ -60,6 +63,7 @@ private ItemEntry( this.tooltipResourceId = tooltipResourceId; this.resource = resource; this.graphics = graphics; + this.model = model; this.resourcePath = resourcePath; this.behaviour = behaviour; this.sourceYml = sourceYml; @@ -74,6 +78,8 @@ public static ItemEntry from(Path sourceYml, ItemGraphics itemGraphics = ItemGraphics.from(data); Material material = getMaterial(itemResource, itemGraphics); ItemInfo itemInfo = ItemInfo.from(namespace, key, material); + ItemModel itemModel = new ItemModel(itemInfo, itemResource, itemGraphics); + String tooltipResourceId = YmlUtils.getString(data, "tooltip_style", null); IABehaviour behaviour = IABehaviour.from(itemInfo, data, equipements); @@ -94,6 +100,7 @@ public static ItemEntry from(Path sourceYml, tooltipResourceId, itemResource, itemGraphics, + itemModel, resolvePathFunction(namespace, itemGraphics, itemResource), behaviour, sourceYml diff --git a/src/main/java/fr/openmc/riftengine/api/scanner/items/entry/ItemGraphics.java b/src/main/java/fr/openmc/riftengine/api/scanner/items/entry/ItemGraphics.java index c45187c80..45e56b23d 100644 --- a/src/main/java/fr/openmc/riftengine/api/scanner/items/entry/ItemGraphics.java +++ b/src/main/java/fr/openmc/riftengine/api/scanner/items/entry/ItemGraphics.java @@ -9,12 +9,13 @@ public record ItemGraphics( String texture, Map textures, String model, + String parent, // ex block/cross Material material ) { public static ItemGraphics from(Map data) { Map graphics = YmlUtils.getMap(data, "graphics"); if (graphics == null) - return new ItemGraphics(null, null, null, Material.PAPER); + return new ItemGraphics(null, null, null, null, Material.PAPER); Material material = Material.valueOf( YmlUtils.getString(data, "material", ItemResource.DEFAULT_MATERIAL).toUpperCase()); @@ -23,6 +24,7 @@ public static ItemGraphics from(Map data) { YmlUtils.getString(graphics, "texture", null), YmlUtils.getStringMap(graphics, "textures"), YmlUtils.getString(graphics, "model", null), + YmlUtils.getString(graphics, "parent", null), material ); } diff --git a/src/main/java/fr/openmc/riftengine/api/scanner/items/entry/ItemModel.java b/src/main/java/fr/openmc/riftengine/api/scanner/items/entry/ItemModel.java new file mode 100644 index 000000000..6a98c29e3 --- /dev/null +++ b/src/main/java/fr/openmc/riftengine/api/scanner/items/entry/ItemModel.java @@ -0,0 +1,76 @@ +package fr.openmc.riftengine.api.scanner.items.entry; + +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import fr.openmc.core.utils.JsonUtils; +import fr.openmc.riftengine.api.utils.IdentifierUtils; + +import java.nio.file.Path; +import java.util.ArrayList; +import java.util.List; + +public record ItemModel(ItemInfo info, ItemResource resource, ItemGraphics graphics) { + public List texturesPath(Path javaRootPath) { + List texturesPath = new ArrayList<>(); + + String model = getModel(); + + if (model == null) return texturesPath; + + Path targetJson = IdentifierUtils.resolveModelId(javaRootPath, model); + JsonObject rootModelJson = JsonUtils.loadJson(targetJson); + + if (rootModelJson == null) return texturesPath; + + JsonObject textures = rootModelJson.getAsJsonObject("textures"); + + for (JsonElement textureName : textures.asMap().values()) { + if (!(textureName.isJsonPrimitive())) continue; + + String textureNameStr = textureName.getAsString(); + if (textureNameStr.startsWith("_")) + textureNameStr = textureNameStr.substring(1); + + texturesPath.add(textureNameStr); + } + return texturesPath; + } + + /** + * ex omc_dream:orb/orb_cloud en models/entity/attachable/omc_dream/orb/orb_cloud.geo.json + */ + public String toBedrockModelPath() { + String[] id = IdentifierUtils.normalizeId(modelId()).split(":"); + return "models/entity/attachable/" + id[0] + "/" + id[1] + ".geo.json"; + } + + /** + * ex omc_dream:orb/orb_cloud en geometry.omc_dream.orb.orb_cloud + */ + public String toBedrockGeometryId() { + String[] id = IdentifierUtils.normalizeId(modelId()).split(":"); + return "geometry." + id[0] + "." + id[1].replace('/', '.'); + } + + public boolean hasModel() { + return getModel() != null; + } + + public String getModel() { + if (graphics != null && graphics.hasModel()) { + return graphics.model(); + } else if (resource != null && resource.hasModel()) { + return resource.model(); + } + return null; + } + + /** + * @return l'id du model avec namespace, ex omc_dream:orb/orb_cloud + */ + public String modelId() { + if (getModel() == null) return null; + return IdentifierUtils.normalizeId(this.getModel(), info.namespace()); // ⚠ adapte + } + +} From d673cfe31f4069d67ba6b39f1714589dadbec746 Mon Sep 17 00:00:00 2001 From: iambibi <89582596+iambibi@users.noreply.github.com> Date: Thu, 22 Oct 2026 21:41:00 +0200 Subject: [PATCH 27/28] fix: multiple textures --- .../api/scanner/items/entry/ItemModel.java | 27 ++++++++++++++--- .../riftengine/api/utils/IdentifierUtils.java | 29 +++++++++++++++---- 2 files changed, 47 insertions(+), 9 deletions(-) diff --git a/src/main/java/fr/openmc/riftengine/api/scanner/items/entry/ItemModel.java b/src/main/java/fr/openmc/riftengine/api/scanner/items/entry/ItemModel.java index 6a98c29e3..106b3cb5b 100644 --- a/src/main/java/fr/openmc/riftengine/api/scanner/items/entry/ItemModel.java +++ b/src/main/java/fr/openmc/riftengine/api/scanner/items/entry/ItemModel.java @@ -8,6 +8,7 @@ import java.nio.file.Path; import java.util.ArrayList; import java.util.List; +import java.util.Map; public record ItemModel(ItemInfo info, ItemResource resource, ItemGraphics graphics) { public List texturesPath(Path javaRootPath) { @@ -17,25 +18,35 @@ public List texturesPath(Path javaRootPath) { if (model == null) return texturesPath; - Path targetJson = IdentifierUtils.resolveModelId(javaRootPath, model); + Path targetJson = IdentifierUtils.resolveModelId(javaRootPath, info.namespace(), model); JsonObject rootModelJson = JsonUtils.loadJson(targetJson); if (rootModelJson == null) return texturesPath; JsonObject textures = rootModelJson.getAsJsonObject("textures"); - for (JsonElement textureName : textures.asMap().values()) { - if (!(textureName.isJsonPrimitive())) continue; + if (textures == null) return texturesPath; + Map texturesMap = textures.asMap(); + if (texturesMap == null) return texturesPath; + + for (JsonElement textureName : texturesMap.values()) { String textureNameStr = textureName.getAsString(); + if (textureNameStr.startsWith("#")) continue; if (textureNameStr.startsWith("_")) textureNameStr = textureNameStr.substring(1); - texturesPath.add(textureNameStr); + String[] textureSplit = textureNameStr.split(":"); + + texturesPath.add(textureSplit[1]); } return texturesPath; } + public String namespace() { + return this.info.namespace(); + } + /** * ex omc_dream:orb/orb_cloud en models/entity/attachable/omc_dream/orb/orb_cloud.geo.json */ @@ -52,6 +63,14 @@ public String toBedrockGeometryId() { return "geometry." + id[0] + "." + id[1].replace('/', '.'); } + /** + * ex omc_dream:orb/orb_cloud en textures/omc_dream/atlas/orb_cloud + */ + public String toBedrockAtlasPath() { + String[] id = IdentifierUtils.normalizeId(modelId()).split(":"); + return "textures/" + id[0] + "/atlas/" + id[1]; + } + public boolean hasModel() { return getModel() != null; } diff --git a/src/main/java/fr/openmc/riftengine/api/utils/IdentifierUtils.java b/src/main/java/fr/openmc/riftengine/api/utils/IdentifierUtils.java index 41967a14f..1999fbba3 100644 --- a/src/main/java/fr/openmc/riftengine/api/utils/IdentifierUtils.java +++ b/src/main/java/fr/openmc/riftengine/api/utils/IdentifierUtils.java @@ -38,6 +38,13 @@ public static Path resolveTextureId(Path rootPath, String id) { return resolveFileId(rootPath, id, ".png"); } + /** + * Résout un identifiant en un chemin vers une image (.png) dans les assets + */ + public static Path resolveTextureId(Path rootPath, String namespace, String id) { + return resolveFileId(rootPath, namespace, id, ".png"); + } + /** * Résout un identifiant en un chemin vers des meta donnée de mc (.mcmeta) dans les assets */ @@ -49,10 +56,16 @@ public static Path resolveMetaId(Path rootPath, String id, String ext) { * Résout un identifiant en un chemin de fichier dans les assets */ public static Path resolveFileId(Path rootPath, String id, String ext) { - String normalizedId = normalizeId(id); + return resolveFileId(rootPath, "minecraft", id, ext); + } + + /** + * Résout un identifiant en un chemin de fichier dans les assets + */ + public static Path resolveFileId(Path rootPath, String namespace, String id, String ext) { + String normalizedId = normalizeId(id, namespace); String[] split = normalizedId.split(":", 2); - String namespace; String texturePath; if (split.length == 2) { @@ -77,11 +90,10 @@ public static Path resolveFileId(Path rootPath, String id, String ext) { /** * Résout un identifiant en un chemin de fichier dans les assets pour les models */ - public static Path resolveModelId(Path rootPath, String id) { - String normalizedId = normalizeId(id); + public static Path resolveModelId(Path rootPath, String namespace, String id) { + String normalizedId = normalizeId(id, namespace); String[] split = normalizedId.split(":", 2); - String namespace; String modelPath; if (split.length == 2) { @@ -102,6 +114,13 @@ public static Path resolveModelId(Path rootPath, String id) { .resolve(modelPath); } + /** + * Résout un identifiant en un chemin de fichier dans les assets pour les models + */ + public static Path resolveModelId(Path rootPath, String id) { + return resolveModelId(rootPath, "minecraft", id); + } + public static String toBedrockTexturePath(String javaPath) { if (!javaPath.endsWith(".png")) javaPath = javaPath + ".png"; From b1499bff98be91b2928a5cb8852acfbeef03cd4f Mon Sep 17 00:00:00 2001 From: iambibi <89582596+iambibi@users.noreply.github.com> Date: Sun, 25 Oct 2026 21:36:10 +0100 Subject: [PATCH 28/28] change: branch --- .../java/fr/openmc/core/utils/JsonUtils.java | 8 ++++ .../api/scanner/items/entry/ItemModel.java | 13 +++++- .../entry/behaviours/block/BlockFaces.java | 46 +++++++++++++++++++ 3 files changed, 65 insertions(+), 2 deletions(-) create mode 100644 src/main/java/fr/openmc/riftengine/api/scanner/items/entry/behaviours/block/BlockFaces.java diff --git a/src/main/java/fr/openmc/core/utils/JsonUtils.java b/src/main/java/fr/openmc/core/utils/JsonUtils.java index 73424e31f..0204ab4a0 100644 --- a/src/main/java/fr/openmc/core/utils/JsonUtils.java +++ b/src/main/java/fr/openmc/core/utils/JsonUtils.java @@ -52,4 +52,12 @@ public static Boolean getBool(JsonObject object, String key, Boolean def) { public static Float getFloat(JsonObject object, String key, Float def) { return object.has(key) ? object.get(key).getAsFloat() : def; } + + public static JsonObject getJsonObject(JsonObject object, String key, JsonObject def) { + return object.has(key) && object.get(key).isJsonObject() ? object.get(key).getAsJsonObject() : def; + } + + public static JsonArray getJsonArray(JsonObject object, String key, JsonArray def) { + return object.has(key) && object.get(key).isJsonArray() ? object.get(key).getAsJsonArray() : def; + } } diff --git a/src/main/java/fr/openmc/riftengine/api/scanner/items/entry/ItemModel.java b/src/main/java/fr/openmc/riftengine/api/scanner/items/entry/ItemModel.java index 106b3cb5b..ed4293610 100644 --- a/src/main/java/fr/openmc/riftengine/api/scanner/items/entry/ItemModel.java +++ b/src/main/java/fr/openmc/riftengine/api/scanner/items/entry/ItemModel.java @@ -71,6 +71,16 @@ public String toBedrockAtlasPath() { return "textures/" + id[0] + "/atlas/" + id[1]; } + public String toBedrockAnimationId() { + String[] id = IdentifierUtils.normalizeId(modelId()).split(":"); + return "animation." + id[0] + "." + id[1].replace('/', '.'); + } + + public String toBedrockAnimationPath() { + String[] id = IdentifierUtils.normalizeId(modelId()).split(":"); + return "animations/" + id[0] + "/" + id[1] + ".animation.json"; + } + public boolean hasModel() { return getModel() != null; } @@ -89,7 +99,6 @@ public String getModel() { */ public String modelId() { if (getModel() == null) return null; - return IdentifierUtils.normalizeId(this.getModel(), info.namespace()); // ⚠ adapte + return IdentifierUtils.normalizeId(this.getModel(), info.namespace()); } - } diff --git a/src/main/java/fr/openmc/riftengine/api/scanner/items/entry/behaviours/block/BlockFaces.java b/src/main/java/fr/openmc/riftengine/api/scanner/items/entry/behaviours/block/BlockFaces.java new file mode 100644 index 000000000..a69cca672 --- /dev/null +++ b/src/main/java/fr/openmc/riftengine/api/scanner/items/entry/behaviours/block/BlockFaces.java @@ -0,0 +1,46 @@ +package fr.openmc.riftengine.api.scanner.items.entry.behaviours.block; + +import fr.openmc.riftengine.api.utils.IdentifierUtils; + +import java.util.List; +import java.util.Map; + +public record BlockFaces(String north, String south, String east, String west, String up, String down) { + private static final List BLOCK_FACES = List.of( + "north", "south", "east", "west", "up", "down" + ); + + public static BlockFaces from(Map faces) { + if (faces == null) return null; + + if (!faces.keySet().containsAll(BLOCK_FACES) && !faces.isEmpty()) { + String face = removeExt(faces.values().stream().findFirst().get()); + return new BlockFaces(face, face, face, face, face, face); + } + + return new BlockFaces( + removeExt(faces.get("north")), + removeExt(faces.get("south")), + removeExt(faces.get("east")), + removeExt(faces.get("west")), + removeExt(faces.get("up")), + removeExt(faces.get("down")) + ); + } + + private static String removeExt(String face) { + return IdentifierUtils.removeExtensionPath(face); + } + + + public Map getFaces() { + return Map.of( + "north", north, + "south", south, + "east", east, + "west", west, + "up", up, + "down", down + ); + } +}