From 3b1465b5e6571f21b3338ab3584ecfbd9964777c Mon Sep 17 00:00:00 2001 From: iambibi_ <89582596+iambibi@users.noreply.github.com> Date: Sat, 9 May 2026 20:56:06 +0200 Subject: [PATCH 1/6] chore: OMCRegistry (unstable ahah) --- .../api/menulib/template/ConfirmMenu.java | 6 +- .../java/fr/openmc/core/OMCBootstrap.java | 14 +- src/main/java/fr/openmc/core/OMCPlugin.java | 14 +- src/main/java/fr/openmc/core/OMCRegistry.java | 44 +++++ .../registries/LifecycleRegistry.java | 9 + .../core/bootstrap/registries/Registry.java | 26 +++ .../autocomplete/CustomItemAutoComplete.java | 10 +- .../commands/debug/CustomItemCommand.java | 4 +- .../CompanyBankTransactionsMenu.java.bak | 8 +- .../menu/company/CompanyMenu.java.bak | 8 +- .../menu/company/CompanySearchMenu.java.bak | 6 +- .../menu/company/ShopManageMenu.java.bak | 8 +- .../menu/shop/ShopCatalogueMenu.java.bak | 8 +- .../corporation/menu/shop/ShopMenu.java.bak | 22 +-- .../menu/shop/ShopSalesMenu.java.bak | 8 +- .../menu/shop/ShopSearchMenu.java.bak | 8 +- .../menu/shop/ShopStocksMenu.java.bak | 8 +- .../menus/AdminShopCategoryMenu.java | 4 +- .../adminshop/menus/ColorVariantsMenu.java | 4 +- .../features/adminshop/menus/ConfirmMenu.java | 18 +- .../adminshop/menus/LeavesVariantsMenu.java | 4 +- .../adminshop/menus/LogVariantsMenu.java | 4 +- .../city/actions/CityCreateAction.java | 4 +- .../city/actions/CityUnclaimAction.java | 4 +- .../city/conditions/CityChestConditions.java | 4 +- .../city/conditions/CityClaimCondition.java | 4 +- .../city/conditions/CityCreateConditions.java | 4 +- .../features/city/menu/CityChestMenu.java | 8 +- .../features/city/menu/CityPermsMenu.java | 6 +- .../features/city/menu/CityTransferMenu.java | 8 +- .../features/city/menu/InvitationsMenu.java | 8 +- .../city/menu/list/CityPlayerListMenu.java | 8 +- .../menu/playerlist/CityPlayerListMenu.java | 10 +- .../city/sub/mascots/menu/MascotMenu.java | 4 +- .../sub/mascots/menu/MascotsSkinMenu.java | 4 +- .../sub/mayor/actions/MayorSetWarpAction.java | 4 +- .../city/sub/mayor/managers/NPCManager.java | 10 +- .../city/sub/mayor/menu/MayorVoteMenu.java | 8 +- .../mayor/menu/create/MayorCreateMenu.java | 6 +- .../sub/mayor/menu/create/PerkChoiceMenu.java | 8 +- .../features/city/sub/mayor/perks/Perks.java | 4 +- .../sub/mayor/perks/basic/AyweniterPerk.java | 4 +- .../sub/mayor/perks/event/IdyllicRain.java | 6 +- .../mayor/perks/event/ImpotCollection.java | 10 +- .../mayor/perks/event/MineralRushPerk.java | 4 +- .../features/city/sub/mayor/perks/readme.md | 4 +- .../city/sub/milestone/CityLevels.java | 26 +-- .../milestone/menu/LevelMilestoneMenu.java | 6 +- .../sub/rank/menus/CityRankDetailsMenu.java | 12 +- .../city/sub/rank/menus/CityRankIconMenu.java | 4 +- .../sub/rank/menus/CityRankPermsMenu.java | 8 +- .../city/sub/rank/menus/CityRanksMenu.java | 4 +- .../city/sub/war/menu/main/MainWarMenu.java | 8 +- .../sub/war/menu/main/WarPlayerListMenu.java | 8 +- .../selection/WarChooseParticipantsMenu.java | 8 +- .../war/menu/selection/WarChooseSizeMenu.java | 8 +- .../openmc/core/features/credits/Credits.java | 16 +- .../core/features/credits/CreditsMenu.java | 6 +- .../autocomplete/DreamItemAutoComplete.java | 10 +- .../mecanism/cloudcastle/CloudVault.java | 8 +- .../cloudfishing/CloudFishingManager.java | 4 +- .../metaldetector/MetalDetectorManager.java | 4 +- .../mecanism/tradernpc/GlaciteTrade.java | 4 +- .../dream/registries/DreamItemRegistry.java | 8 +- .../registries/DreamLootTableRegistry.java | 10 +- .../enchantements/DreamSleeper.java | 4 +- .../enchantements/Experientastic.java | 4 +- .../registries/enchantements/Soulbound.java | 4 +- .../loottable/CloudVaultLootTable.java | 4 +- .../loottable/MetalDetectorLootTable.java | 5 +- .../economy/menu/TransactionsMenu.java | 8 +- .../commands/calendar/CalendarMenu.java | 4 +- .../halloween/managers/HalloweenManager.java | 4 +- .../contents/contest/Contest.java | 4 +- .../contest/managers/ContestManager.java | 4 +- .../contest/menu/ContributionMenu.java | 4 +- .../contents/contest/menu/TradeMenu.java | 4 +- .../features/homes/HomeUpgradeManager.java | 6 +- .../core/features/homes/icons/HomeIcon.java | 4 +- .../homes/menu/HomeChangeIconMenu.java | 4 +- .../features/homes/menu/HomeConfigMenu.java | 9 +- .../homes/menu/HomeDeleteConfirmMenu.java | 6 +- .../core/features/homes/menu/HomeMenu.java | 4 +- .../features/homes/menu/HomeUpgradeMenu.java | 4 +- .../features/mailboxes/menu/HomeMailbox.java | 6 +- .../mailboxes/utils/MailboxMenuManager.java | 14 +- .../tutorial/quests/BreakAyweniteQuest.java | 4 +- .../tutorial/quests/HomeCreateQuest.java | 4 +- .../tutorial/quests/HomeUpgradeQuest.java | 4 +- .../tutorial/quests/OpenContestMenuQuest.java | 19 +- .../features/quests/menus/QuestsMenu.java | 6 +- .../quests/quests/ConsumeKebabQuest.java | 6 +- .../quests/quests/CraftTheMixtureQuest.java | 8 +- .../quests/quests/MineAyweniteQuest.java | 4 +- .../quests/quests/WinContestQuest.java | 4 +- .../settings/menu/PlayerSettingsMenu.java | 4 +- .../tickets/menus/MachineBallsOpenMenu.java | 6 +- .../core/listeners/BlockBreakListener.java | 4 +- .../core/listeners/EquipableItemListener.java | 8 +- .../core/listeners/InteractListener.java | 4 +- .../CustomEnchantmentRegistry.java | 99 +++------- .../core/registry/items/CustomItem.java | 3 +- .../registry/items/CustomItemRegistry.java | 183 ++++++++---------- .../items/CustomItemsDebugCommand.java | 9 +- .../loottable/CustomLootTableRegistry.java | 27 +-- .../openmc/core/utils/bukkit/ItemUtils.java | 6 +- 106 files changed, 534 insertions(+), 539 deletions(-) create mode 100644 src/main/java/fr/openmc/core/OMCRegistry.java create mode 100644 src/main/java/fr/openmc/core/bootstrap/registries/LifecycleRegistry.java create mode 100644 src/main/java/fr/openmc/core/bootstrap/registries/Registry.java diff --git a/src/main/java/fr/openmc/api/menulib/template/ConfirmMenu.java b/src/main/java/fr/openmc/api/menulib/template/ConfirmMenu.java index 64018b32f..e423b279e 100644 --- a/src/main/java/fr/openmc/api/menulib/template/ConfirmMenu.java +++ b/src/main/java/fr/openmc/api/menulib/template/ConfirmMenu.java @@ -4,7 +4,7 @@ import fr.openmc.api.menulib.Menu; import fr.openmc.api.menulib.utils.InventorySize; import fr.openmc.api.menulib.utils.ItemBuilder; -import fr.openmc.core.registry.items.CustomItemRegistry; +import fr.openmc.core.OMCRegistry; import fr.openmc.core.utils.text.messages.MessageType; import fr.openmc.core.utils.text.messages.MessagesManager; import fr.openmc.core.utils.text.messages.Prefix; @@ -110,8 +110,8 @@ public void onClose(InventoryCloseEvent event) { loreDeny.add(Component.text("§e§lCLIQUEZ ICI POUR REFUSER")); - ItemStack refuseBtn = CustomItemRegistry.getByName("omc_menus:refuse_btn").getBest(); - ItemStack acceptBtn = CustomItemRegistry.getByName("omc_menus:accept_btn").getBest(); + ItemStack refuseBtn = OMCRegistry.CUSTOM_ITEMS.get("omc_menus:refuse_btn").getBest(); + ItemStack acceptBtn = OMCRegistry.CUSTOM_ITEMS.get("omc_menus:accept_btn").getBest(); inventory.put(posDenyBtn, new ItemBuilder(this, refuseBtn, itemMeta -> { itemMeta.displayName(Component.text("§cRefuser")); diff --git a/src/main/java/fr/openmc/core/OMCBootstrap.java b/src/main/java/fr/openmc/core/OMCBootstrap.java index 05144d41b..66e366e05 100644 --- a/src/main/java/fr/openmc/core/OMCBootstrap.java +++ b/src/main/java/fr/openmc/core/OMCBootstrap.java @@ -1,13 +1,11 @@ package fr.openmc.core; import fr.openmc.core.hooks.itemsadder.ItemsAdderHook; -import fr.openmc.core.registry.enchantments.CustomEnchantmentRegistry; import fr.openmc.core.utils.text.messages.TranslationManager; import io.papermc.paper.plugin.bootstrap.BootstrapContext; import io.papermc.paper.plugin.bootstrap.PluginBootstrap; import io.papermc.paper.plugin.bootstrap.PluginProviderContext; import io.papermc.paper.plugin.lifecycle.event.types.LifecycleEvents; -import io.papermc.paper.registry.event.RegistryEvents; import org.bukkit.plugin.java.JavaPlugin; import org.jetbrains.annotations.NotNull; @@ -23,7 +21,6 @@ */ @SuppressWarnings("UnstableApiUsage") public class OMCBootstrap implements PluginBootstrap { - /** * Configure les handlers de cycle de vie necessaires avant l'activation du plugin. * @@ -48,11 +45,12 @@ public void bootstrap(@NotNull BootstrapContext context) { // ** LOAD ITEMS ADDER NAMESPACES ** ItemsAdderHook.copyContentsToItemsAdder(context, "contents"); - // ** ENCHANTMENT IMPL ** - CustomEnchantmentRegistry.init(); - context.getLifecycleManager().registerEventHandler(RegistryEvents.ENCHANTMENT.compose() - .newHandler(CustomEnchantmentRegistry::loadEnchantmentInBootstrap) - ); + // ** REGISTRY MANAGER ** + OMCRegistry.bootstrapAll(); + +// context.getLifecycleManager().registerEventHandler(RegistryEvents.ENCHANTMENT.compose() +// .newHandler(CustomEnchantmentRegistry::loadEnchantmentInBootstrap) +// ); // ** LOAD TRANSLATION ** // this creates resource pack who is needed for item adder diff --git a/src/main/java/fr/openmc/core/OMCPlugin.java b/src/main/java/fr/openmc/core/OMCPlugin.java index 22c5e782d..34b01a38b 100644 --- a/src/main/java/fr/openmc/core/OMCPlugin.java +++ b/src/main/java/fr/openmc/core/OMCPlugin.java @@ -48,9 +48,6 @@ import fr.openmc.core.features.updates.UpdateManager; import fr.openmc.core.hooks.*; import fr.openmc.core.hooks.itemsadder.ItemsAdderHook; -import fr.openmc.core.registry.enchantments.CustomEnchantmentRegistry; -import fr.openmc.core.registry.items.CustomItemRegistry; -import fr.openmc.core.registry.loottable.CustomLootTableRegistry; import fr.openmc.core.utils.bukkit.ParticleUtils; import fr.openmc.core.utils.text.MotdUtils; import io.papermc.paper.datapack.Datapack; @@ -175,6 +172,9 @@ public void onEnable() { CommandsManager.init(); ListenersManager.init(); + /* REGISTRIES */ + OMCRegistry.initAll(); + /* FEATURES */ REGISTRY_FEATURE.stream() .filter(f -> !(f instanceof LoadAfterItemsAdder)) @@ -190,12 +190,10 @@ public void onEnable() { * Charge les registres et features qui doivent être lancé apres ItemsAdder */ public void loadAfterItemsAdder() { - // ** REGISTRIES ** - CustomItemRegistry.init(); - CustomEnchantmentRegistry.postInit(); - CustomLootTableRegistry.init(); + /* REGISTRIES */ + OMCRegistry.postInitAll(); - // ** FEATURES ** + /* FEATURES */ REGISTRY_FEATURE.stream() .filter(f -> f instanceof LoadAfterItemsAdder) .forEachOrdered(Feature::startInit); diff --git a/src/main/java/fr/openmc/core/OMCRegistry.java b/src/main/java/fr/openmc/core/OMCRegistry.java new file mode 100644 index 000000000..f6549b720 --- /dev/null +++ b/src/main/java/fr/openmc/core/OMCRegistry.java @@ -0,0 +1,44 @@ +package fr.openmc.core; + +import fr.openmc.core.bootstrap.registries.BootstrapRegistry; +import fr.openmc.core.bootstrap.registries.LifecycleRegistry; +import fr.openmc.core.registry.enchantments.CustomEnchantmentRegistry; +import fr.openmc.core.registry.items.CustomItemRegistry; +import fr.openmc.core.registry.loottable.CustomLootTableRegistry; + +import java.util.List; + +public final class OMCRegistry { + + public static final CustomItemRegistry CUSTOM_ITEMS = new CustomItemRegistry(); + public static final CustomEnchantmentRegistry CUSTOM_ENCHANTS = new CustomEnchantmentRegistry(); + public static final CustomLootTableRegistry CUSTOM_LOOT_TABLES = new CustomLootTableRegistry(); + + private static final List ALL = List.of( + CUSTOM_ITEMS, + CUSTOM_ENCHANTS, + CUSTOM_LOOT_TABLES + ); + + private OMCRegistry() {} + + public static void bootstrapAll() { + for (LifecycleRegistry r : OMCRegistry.ALL) { + if (r instanceof BootstrapRegistry b) { + b.bootstrap(); + } + } + } + + public static void initAll() { + for (LifecycleRegistry r : OMCRegistry.ALL) { + r.init(); + } + } + + public static void postInitAll() { + for (LifecycleRegistry r : OMCRegistry.ALL) { + r.postInit(); + } + } +} \ No newline at end of file diff --git a/src/main/java/fr/openmc/core/bootstrap/registries/LifecycleRegistry.java b/src/main/java/fr/openmc/core/bootstrap/registries/LifecycleRegistry.java new file mode 100644 index 000000000..810a822a4 --- /dev/null +++ b/src/main/java/fr/openmc/core/bootstrap/registries/LifecycleRegistry.java @@ -0,0 +1,9 @@ +package fr.openmc.core.bootstrap.registries; + +public interface LifecycleRegistry { + default void bootstrap() {} + + default void init() {} + + default void postInit() {} +} diff --git a/src/main/java/fr/openmc/core/bootstrap/registries/Registry.java b/src/main/java/fr/openmc/core/bootstrap/registries/Registry.java new file mode 100644 index 000000000..799aed6c9 --- /dev/null +++ b/src/main/java/fr/openmc/core/bootstrap/registries/Registry.java @@ -0,0 +1,26 @@ +package fr.openmc.core.bootstrap.registries; + +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; + +public class Registry implements LifecycleRegistry { + + protected final Map entries = new HashMap<>(); + + public void register(K key, V value) { + entries.put(key, value); + } + + public V get(K key) { + return entries.get(key); + } + + public Collection keys() { + return entries.keySet(); + } + + public Collection values() { + return entries.values(); + } +} diff --git a/src/main/java/fr/openmc/core/commands/autocomplete/CustomItemAutoComplete.java b/src/main/java/fr/openmc/core/commands/autocomplete/CustomItemAutoComplete.java index aac157d96..b253b2d69 100644 --- a/src/main/java/fr/openmc/core/commands/autocomplete/CustomItemAutoComplete.java +++ b/src/main/java/fr/openmc/core/commands/autocomplete/CustomItemAutoComplete.java @@ -1,6 +1,7 @@ package fr.openmc.core.commands.autocomplete; -import fr.openmc.core.registry.items.CustomItemRegistry; +import fr.openmc.core.OMCRegistry; +import fr.openmc.core.registry.items.CustomItem; import org.jetbrains.annotations.NotNull; import revxrsal.commands.autocomplete.SuggestionProvider; import revxrsal.commands.bukkit.actor.BukkitCommandActor; @@ -12,10 +13,11 @@ public class CustomItemAutoComplete implements SuggestionProvider getSuggestions(@NotNull ExecutionContext context) { - return CustomItemRegistry.getNames() + return OMCRegistry.CUSTOM_ITEMS.values() .stream() - .filter(name -> !name.startsWith("omc_dream:")) - .map(name -> name.replace("omc_dream:", "")) + .map(CustomItem::getId) + .filter(id -> !id.startsWith("omc_dream:")) + .map(id -> id.replace("omc_dream:", "")) .toList(); } } diff --git a/src/main/java/fr/openmc/core/commands/debug/CustomItemCommand.java b/src/main/java/fr/openmc/core/commands/debug/CustomItemCommand.java index bd277e82a..cd6703a24 100644 --- a/src/main/java/fr/openmc/core/commands/debug/CustomItemCommand.java +++ b/src/main/java/fr/openmc/core/commands/debug/CustomItemCommand.java @@ -1,8 +1,8 @@ package fr.openmc.core.commands.debug; +import fr.openmc.core.OMCRegistry; import fr.openmc.core.commands.autocomplete.CustomItemAutoComplete; import fr.openmc.core.registry.items.CustomItem; -import fr.openmc.core.registry.items.CustomItemRegistry; import fr.openmc.core.utils.text.messages.MessageType; import fr.openmc.core.utils.text.messages.MessagesManager; import fr.openmc.core.utils.text.messages.Prefix; @@ -25,7 +25,7 @@ public void get( @SuggestWith(CustomItemAutoComplete.class) String name, @Optional Integer amount ) { - CustomItem item = CustomItemRegistry.getByName(name); + CustomItem item = OMCRegistry.CUSTOM_ITEMS.get(name); if (item == null) { MessagesManager.sendMessage(player, Component.text("Cet item n'existe pas"), Prefix.STAFF, MessageType.ERROR, false); diff --git a/src/main/java/fr/openmc/core/disabled/corporation/menu/company/CompanyBankTransactionsMenu.java.bak b/src/main/java/fr/openmc/core/disabled/corporation/menu/company/CompanyBankTransactionsMenu.java.bak index e15dbad2b..798acc474 100644 --- a/src/main/java/fr/openmc/core/disabled/corporation/menu/company/CompanyBankTransactionsMenu.java.bak +++ b/src/main/java/fr/openmc/core/disabled/corporation/menu/company/CompanyBankTransactionsMenu.java.bak @@ -83,15 +83,15 @@ public class CompanyBankTransactionsMenu extends PaginatedMenu { @Override public Map getButtons() { Map buttons = new HashMap<>(); - buttons.put(49, new ItemBuilder(this, CustomItemRegistry.getByName("_iainternal:icon_cancel").getBest(), itemMeta -> itemMeta.setDisplayName("§7Fermer")) + buttons.put(49, new ItemBuilder(this, OMCRegistry.CUSTOM_ITEMS.get("_iainternal:icon_cancel").getBest(), itemMeta -> itemMeta.setDisplayName("§7Fermer")) .setCloseButton()); - ItemBuilder nextPageButton = new ItemBuilder(this, CustomItemRegistry.getByName("_iainternal:icon_next_orange").getBest(), itemMeta -> itemMeta.setDisplayName("§aPage suivante")); + ItemBuilder nextPageButton = new ItemBuilder(this, OMCRegistry.CUSTOM_ITEMS.get("_iainternal:icon_next_orange").getBest(), itemMeta -> itemMeta.setDisplayName("§aPage suivante")); if ((getPage() == 0 && isLastPage()) || company.getShops().isEmpty()) { - buttons.put(48, new ItemBuilder(this, CustomItemRegistry.getByName("_iainternal:icon_back_orange").getBest(), itemMeta -> itemMeta.setDisplayName("§cRetour")) + buttons.put(48, new ItemBuilder(this, OMCRegistry.CUSTOM_ITEMS.get("_iainternal:icon_back_orange").getBest(), itemMeta -> itemMeta.setDisplayName("§cRetour")) .setOnClick(inventoryClickEvent -> new CompanyMenu(getOwner(), company, false).open())); buttons.put(50, nextPageButton); } else { - buttons.put(48, new ItemBuilder(this, CustomItemRegistry.getByName("_iainternal:icon_back_orange").getBest(), itemMeta -> itemMeta.setDisplayName("§cPage précédente")) + buttons.put(48, new ItemBuilder(this, OMCRegistry.CUSTOM_ITEMS.get("_iainternal:icon_back_orange").getBest(), itemMeta -> itemMeta.setDisplayName("§cPage précédente")) .setPreviousPageButton()); buttons.put(50, nextPageButton.setNextPageButton()); } diff --git a/src/main/java/fr/openmc/core/disabled/corporation/menu/company/CompanyMenu.java.bak b/src/main/java/fr/openmc/core/disabled/corporation/menu/company/CompanyMenu.java.bak index 18ebfb975..cfd5d1a89 100644 --- a/src/main/java/fr/openmc/core/disabled/corporation/menu/company/CompanyMenu.java.bak +++ b/src/main/java/fr/openmc/core/disabled/corporation/menu/company/CompanyMenu.java.bak @@ -73,15 +73,15 @@ public class CompanyMenu extends PaginatedMenu { public Map getButtons() { Map buttons = new HashMap<>(); - ItemBuilder closeButton = new ItemBuilder(this, CustomItemRegistry.getByName("_iainternal:icon_cancel").getBest(), itemMeta -> itemMeta.setDisplayName("§7Fermer")).setCloseButton(); - ItemBuilder backButton = new ItemBuilder(this, CustomItemRegistry.getByName("_iainternal:icon_back_orange").getBest(), itemMeta -> itemMeta.setDisplayName("§7Retour"), true); + ItemBuilder closeButton = new ItemBuilder(this, OMCRegistry.CUSTOM_ITEMS.get("_iainternal:icon_cancel").getBest(), itemMeta -> itemMeta.setDisplayName("§7Fermer")).setCloseButton(); + ItemBuilder backButton = new ItemBuilder(this, OMCRegistry.CUSTOM_ITEMS.get("_iainternal:icon_back_orange").getBest(), itemMeta -> itemMeta.setDisplayName("§7Retour"), true); buttons.put(49, isBackButton ? backButton : closeButton); - buttons.put(48, new ItemBuilder(this, CustomItemRegistry.getByName("_iainternal:icon_back_orange").getBest(), itemMeta -> itemMeta.setDisplayName("§cPage précédente")) + buttons.put(48, new ItemBuilder(this, OMCRegistry.CUSTOM_ITEMS.get("_iainternal:icon_back_orange").getBest(), itemMeta -> itemMeta.setDisplayName("§cPage précédente")) .setPreviousPageButton()); - buttons.put(50, new ItemBuilder(this, CustomItemRegistry.getByName("_iainternal:icon_next_orange").getBest(), itemMeta -> itemMeta.setDisplayName("§aPage suivante")) + buttons.put(50, new ItemBuilder(this, OMCRegistry.CUSTOM_ITEMS.get("_iainternal:icon_next_orange").getBest(), itemMeta -> itemMeta.setDisplayName("§aPage suivante")) .setNextPageButton()); ItemBuilder ownerItem; diff --git a/src/main/java/fr/openmc/core/disabled/corporation/menu/company/CompanySearchMenu.java.bak b/src/main/java/fr/openmc/core/disabled/corporation/menu/company/CompanySearchMenu.java.bak index 3a1187a00..5b2eb6a96 100644 --- a/src/main/java/fr/openmc/core/disabled/corporation/menu/company/CompanySearchMenu.java.bak +++ b/src/main/java/fr/openmc/core/disabled/corporation/menu/company/CompanySearchMenu.java.bak @@ -89,11 +89,11 @@ public class CompanySearchMenu extends PaginatedMenu { @Override public Map getButtons() { Map map = new HashMap<>(); - map.put(49, new ItemBuilder(this, CustomItemRegistry.getByName("_iainternal:icon_cancel").getBest(), itemMeta -> itemMeta.setDisplayName("§7Fermer")) + map.put(49, new ItemBuilder(this, OMCRegistry.CUSTOM_ITEMS.get("_iainternal:icon_cancel").getBest(), itemMeta -> itemMeta.setDisplayName("§7Fermer")) .setCloseButton()); - map.put(48, new ItemBuilder(this, CustomItemRegistry.getByName("_iainternal:icon_back_orange").getBest(), itemMeta -> itemMeta.setDisplayName("§cPage précédente")) + map.put(48, new ItemBuilder(this, OMCRegistry.CUSTOM_ITEMS.get("_iainternal:icon_back_orange").getBest(), itemMeta -> itemMeta.setDisplayName("§cPage précédente")) .setPreviousPageButton()); - map.put(50, new ItemBuilder(this, CustomItemRegistry.getByName("_iainternal:icon_next_orange").getBest(), itemMeta -> itemMeta.setDisplayName("§aPage suivante")) + map.put(50, new ItemBuilder(this, OMCRegistry.CUSTOM_ITEMS.get("_iainternal:icon_next_orange").getBest(), itemMeta -> itemMeta.setDisplayName("§aPage suivante")) .setNextPageButton()); if (CompanyManager.isInCompany(getOwner().getUniqueId())) { map.put(4, new ItemBuilder(this, CompanyManager.getCompany(getOwner().getUniqueId()).getHead(), itemMeta -> { diff --git a/src/main/java/fr/openmc/core/disabled/corporation/menu/company/ShopManageMenu.java.bak b/src/main/java/fr/openmc/core/disabled/corporation/menu/company/ShopManageMenu.java.bak index c8f5c1a28..e4d729384 100644 --- a/src/main/java/fr/openmc/core/disabled/corporation/menu/company/ShopManageMenu.java.bak +++ b/src/main/java/fr/openmc/core/disabled/corporation/menu/company/ShopManageMenu.java.bak @@ -75,15 +75,15 @@ public class ShopManageMenu extends PaginatedMenu { @Override public Map getButtons() { Map buttons = new HashMap<>(); - buttons.put(49, new ItemBuilder(this, CustomItemRegistry.getByName("_iainternal:icon_cancel").getBest(), itemMeta -> itemMeta.setDisplayName("§7Fermer")) + buttons.put(49, new ItemBuilder(this, OMCRegistry.CUSTOM_ITEMS.get("_iainternal:icon_cancel").getBest(), itemMeta -> itemMeta.setDisplayName("§7Fermer")) .setCloseButton()); - ItemBuilder nextPageButton = new ItemBuilder(this, CustomItemRegistry.getByName("_iainternal:icon_next_orange").getBest(), itemMeta -> itemMeta.setDisplayName("§aPage suivante")); + ItemBuilder nextPageButton = new ItemBuilder(this, OMCRegistry.CUSTOM_ITEMS.get("_iainternal:icon_next_orange").getBest(), itemMeta -> itemMeta.setDisplayName("§aPage suivante")); if ((getPage() == 0 && isLastPage()) || company.getShops().isEmpty()) { - buttons.put(48, new ItemBuilder(this, CustomItemRegistry.getByName("_iainternal:icon_back_orange").getBest(), itemMeta -> itemMeta.setDisplayName("§cRetour")) + buttons.put(48, new ItemBuilder(this, OMCRegistry.CUSTOM_ITEMS.get("_iainternal:icon_back_orange").getBest(), itemMeta -> itemMeta.setDisplayName("§cRetour")) .setOnClick(inventoryClickEvent -> new CompanyMenu(getOwner(), company, false).open())); buttons.put(50, nextPageButton); } else { - buttons.put(48, new ItemBuilder(this, CustomItemRegistry.getByName("_iainternal:icon_back_orange").getBest(), itemMeta -> itemMeta.setDisplayName("§cPage précédente")) + buttons.put(48, new ItemBuilder(this, OMCRegistry.CUSTOM_ITEMS.get("_iainternal:icon_back_orange").getBest(), itemMeta -> itemMeta.setDisplayName("§cPage précédente")) .setPreviousPageButton()); buttons.put(50, nextPageButton.setNextPageButton()); } diff --git a/src/main/java/fr/openmc/core/disabled/corporation/menu/shop/ShopCatalogueMenu.java.bak b/src/main/java/fr/openmc/core/disabled/corporation/menu/shop/ShopCatalogueMenu.java.bak index b5c8cf52d..2caa6022e 100644 --- a/src/main/java/fr/openmc/core/disabled/corporation/menu/shop/ShopCatalogueMenu.java.bak +++ b/src/main/java/fr/openmc/core/disabled/corporation/menu/shop/ShopCatalogueMenu.java.bak @@ -71,15 +71,15 @@ public class ShopCatalogueMenu extends PaginatedMenu { @Override public Map getButtons() { Map buttons = new HashMap<>(); - buttons.put(49, new ItemBuilder(this, CustomItemRegistry.getByName("_iainternal:icon_cancel").getBest(), itemMeta -> itemMeta.setDisplayName("§7Fermer")) + buttons.put(49, new ItemBuilder(this, OMCRegistry.CUSTOM_ITEMS.get("_iainternal:icon_cancel").getBest(), itemMeta -> itemMeta.setDisplayName("§7Fermer")) .setCloseButton()); - ItemBuilder nextPageButton = new ItemBuilder(this, CustomItemRegistry.getByName("_iainternal:icon_next_orange").getBest(), itemMeta -> itemMeta.setDisplayName("§aPage suivante")); + ItemBuilder nextPageButton = new ItemBuilder(this, OMCRegistry.CUSTOM_ITEMS.get("_iainternal:icon_next_orange").getBest(), itemMeta -> itemMeta.setDisplayName("§aPage suivante")); if ((getPage() == 0 && isLastPage()) || shop.getItems().isEmpty()) { - buttons.put(48, new ItemBuilder(this, CustomItemRegistry.getByName("_iainternal:icon_back_orange").getBest(), itemMeta -> itemMeta.setDisplayName("§cRetour")) + buttons.put(48, new ItemBuilder(this, OMCRegistry.CUSTOM_ITEMS.get("_iainternal:icon_back_orange").getBest(), itemMeta -> itemMeta.setDisplayName("§cRetour")) .setOnClick(inventoryClickEvent -> new ShopMenu(getOwner(), shop, itemIndex).open())); buttons.put(50, nextPageButton); } else { - buttons.put(48, new ItemBuilder(this, CustomItemRegistry.getByName("_iainternal:icon_back_orange").getBest(), itemMeta -> itemMeta.setDisplayName("§cPage précédente")) + buttons.put(48, new ItemBuilder(this, OMCRegistry.CUSTOM_ITEMS.get("_iainternal:icon_back_orange").getBest(), itemMeta -> itemMeta.setDisplayName("§cPage précédente")) .setPreviousPageButton()); buttons.put(50, nextPageButton.setNextPageButton()); } diff --git a/src/main/java/fr/openmc/core/disabled/corporation/menu/shop/ShopMenu.java.bak b/src/main/java/fr/openmc/core/disabled/corporation/menu/shop/ShopMenu.java.bak index ecff74e22..28037aa11 100644 --- a/src/main/java/fr/openmc/core/disabled/corporation/menu/shop/ShopMenu.java.bak +++ b/src/main/java/fr/openmc/core/disabled/corporation/menu/shop/ShopMenu.java.bak @@ -94,19 +94,19 @@ public class ShopMenu extends Menu { putOwnerItems(content); } - content.put(39, new ItemBuilder(this, CustomItemRegistry.getByName("_iainternal:icon_back_orange").getBest(), itemMeta -> { + content.put(39, new ItemBuilder(this, OMCRegistry.CUSTOM_ITEMS.get("_iainternal:icon_back_orange").getBest(), itemMeta -> { itemMeta.setDisplayName("§cItem précédent"); }).setOnClick(inventoryClickEvent -> new ShopMenu(getOwner(), shop, onFirstItem() ? itemIndex : itemIndex - 1).open())); - content.put(41, new ItemBuilder(this, CustomItemRegistry.getByName("_iainternal:icon_next_orange").getBest(), itemMeta -> { + content.put(41, new ItemBuilder(this, OMCRegistry.CUSTOM_ITEMS.get("_iainternal:icon_next_orange").getBest(), itemMeta -> { itemMeta.setDisplayName("§aItem suivant"); }).setOnClick(inventoryClickEvent -> new ShopMenu(getOwner(), shop, onLastItem() ? itemIndex : itemIndex + 1).open())); - content.put(40, new ItemBuilder(this, CustomItemRegistry.getByName("_iainternal:icon_cancel").getBest(), itemMeta -> { + content.put(40, new ItemBuilder(this, OMCRegistry.CUSTOM_ITEMS.get("_iainternal:icon_cancel").getBest(), itemMeta -> { itemMeta.setDisplayName("§7Fermer"); }).setCloseButton()); - content.put(19, new ItemBuilder(this, CustomItemRegistry.getByName("omc_menus:minus_btn").getBest(), itemMeta -> { + content.put(19, new ItemBuilder(this, OMCRegistry.CUSTOM_ITEMS.get("omc_menus:minus_btn").getBest(), itemMeta -> { itemMeta.setDisplayName("§5Définir à 1"); }).setOnClick(inventoryClickEvent -> { if (getCurrentItem() == null) return; @@ -114,7 +114,7 @@ public class ShopMenu extends Menu { open(); })); - content.put(20, new ItemBuilder(this, CustomItemRegistry.getByName("omc_company:10_btn").getBest(), itemMeta -> { + content.put(20, new ItemBuilder(this, OMCRegistry.CUSTOM_ITEMS.get("omc_company:10_btn").getBest(), itemMeta -> { itemMeta.setDisplayName("§cRetirer 10"); }).setOnClick(inventoryClickEvent -> { if (getCurrentItem() == null) return; @@ -126,7 +126,7 @@ public class ShopMenu extends Menu { } open(); })); - content.put(21, new ItemBuilder(this, CustomItemRegistry.getByName("omc_menus:1_btn").getBest(), itemMeta -> { + content.put(21, new ItemBuilder(this, OMCRegistry.CUSTOM_ITEMS.get("omc_menus:1_btn").getBest(), itemMeta -> { itemMeta.setDisplayName("§cRetirer 1"); }).setOnClick(inventoryClickEvent -> { if (getCurrentItem() == null) return; @@ -145,14 +145,14 @@ public class ShopMenu extends Menu { itemMeta.setLore(lore); }).setOnClick(inventoryClickEvent -> new ConfirmMenu(getOwner(), this::buyAccept, this::refuse, List.of(Component.text("§aAcheter")), List.of(Component.text("§cAnnuler l'achat"))).open())); - content.put(23, new ItemBuilder(this, CustomItemRegistry.getByName("omc_menus:1_btn").getBest(), itemMeta -> { + content.put(23, new ItemBuilder(this, OMCRegistry.CUSTOM_ITEMS.get("omc_menus:1_btn").getBest(), itemMeta -> { itemMeta.setDisplayName("§aAjouter 1"); }).setOnClick(inventoryClickEvent -> { if (getCurrentItem() == null) return; amountToBuy = getCurrentItem().getAmount()<=amountToBuy ? getCurrentItem().getAmount() : amountToBuy + 1; open(); })); - content.put(24, new ItemBuilder(this, CustomItemRegistry.getByName("omc_company:10_btn").getBest(), itemMeta -> { + content.put(24, new ItemBuilder(this, OMCRegistry.CUSTOM_ITEMS.get("omc_company:10_btn").getBest(), itemMeta -> { itemMeta.setDisplayName("§aAjouter 10"); }).setOnClick(inventoryClickEvent -> { if (getCurrentItem() == null) return; @@ -160,7 +160,7 @@ public class ShopMenu extends Menu { open(); })); - content.put(25, new ItemBuilder(this, CustomItemRegistry.getByName("omc_menus:64_btn").getBest(), itemMeta -> { + content.put(25, new ItemBuilder(this, OMCRegistry.CUSTOM_ITEMS.get("omc_menus:64_btn").getBest(), itemMeta -> { itemMeta.setDisplayName("§5Ajouter 64"); }).setOnClick(inventoryClickEvent -> { if (getCurrentItem() == null) return; @@ -169,7 +169,7 @@ public class ShopMenu extends Menu { open(); })); - content.put(44, new ItemBuilder(this, CustomItemRegistry.getByName("omc_company:company_box").getBest(), itemMeta -> { + content.put(44, new ItemBuilder(this, OMCRegistry.CUSTOM_ITEMS.get("omc_company:company_box").getBest(), itemMeta -> { itemMeta.setDisplayName("§7Catalogue"); }).setOnClick(inventoryClickEvent -> new ShopCatalogueMenu(getOwner(), shop, itemIndex).open())); @@ -183,7 +183,7 @@ public class ShopMenu extends Menu { private void putOwnerItems(Map content) { - content.put(0, new ItemBuilder(this, CustomItemRegistry.getByName("omc_homes:omc_homes_icon_bin_red").getBest(), itemMeta -> { + content.put(0, new ItemBuilder(this, OMCRegistry.CUSTOM_ITEMS.get("omc_homes:omc_homes_icon_bin_red").getBest(), itemMeta -> { itemMeta.setDisplayName("§c§lSupprimer le shop"); }).setOnClick(inventoryClickEvent -> new ConfirmMenu(getOwner(), this::accept, this::refuse, List.of(Component.text("§aSupprimer")), List.of(Component.text("§cAnnuler la suppression"))).open())); diff --git a/src/main/java/fr/openmc/core/disabled/corporation/menu/shop/ShopSalesMenu.java.bak b/src/main/java/fr/openmc/core/disabled/corporation/menu/shop/ShopSalesMenu.java.bak index 96f0a4878..927f02f1a 100644 --- a/src/main/java/fr/openmc/core/disabled/corporation/menu/shop/ShopSalesMenu.java.bak +++ b/src/main/java/fr/openmc/core/disabled/corporation/menu/shop/ShopSalesMenu.java.bak @@ -72,15 +72,15 @@ public class ShopSalesMenu extends PaginatedMenu { @Override public Map getButtons() { Map buttons = new HashMap<>(); - buttons.put(49, new ItemBuilder(this, CustomItemRegistry.getByName("_iainternal:icon_cancel").getBest(), itemMeta -> itemMeta.setDisplayName("§7Fermer")) + buttons.put(49, new ItemBuilder(this, OMCRegistry.CUSTOM_ITEMS.get("_iainternal:icon_cancel").getBest(), itemMeta -> itemMeta.setDisplayName("§7Fermer")) .setCloseButton()); - ItemBuilder nextPageButton = new ItemBuilder(this, CustomItemRegistry.getByName("_iainternal:icon_next_orange").getBest(), itemMeta -> itemMeta.setDisplayName("§aPage suivante")); + ItemBuilder nextPageButton = new ItemBuilder(this, OMCRegistry.CUSTOM_ITEMS.get("_iainternal:icon_next_orange").getBest(), itemMeta -> itemMeta.setDisplayName("§aPage suivante")); if ((getPage() == 0 && isLastPage()) || shop.getSales().isEmpty()) { - buttons.put(48, new ItemBuilder(this, CustomItemRegistry.getByName("_iainternal:icon_back_orange").getBest(), itemMeta -> itemMeta.setDisplayName("§cRetour")) + buttons.put(48, new ItemBuilder(this, OMCRegistry.CUSTOM_ITEMS.get("_iainternal:icon_back_orange").getBest(), itemMeta -> itemMeta.setDisplayName("§cRetour")) .setOnClick(inventoryClickEvent -> new ShopMenu(getOwner(), shop, itemIndex).open())); buttons.put(50, nextPageButton); } else { - buttons.put(48, new ItemBuilder(this, CustomItemRegistry.getByName("_iainternal:icon_back_orange").getBest(), itemMeta -> itemMeta.setDisplayName("§cPage précédente")) + buttons.put(48, new ItemBuilder(this, OMCRegistry.CUSTOM_ITEMS.get("_iainternal:icon_back_orange").getBest(), itemMeta -> itemMeta.setDisplayName("§cPage précédente")) .setPreviousPageButton()); buttons.put(50, nextPageButton.setNextPageButton()); } diff --git a/src/main/java/fr/openmc/core/disabled/corporation/menu/shop/ShopSearchMenu.java.bak b/src/main/java/fr/openmc/core/disabled/corporation/menu/shop/ShopSearchMenu.java.bak index f5f9ff662..c58ceb39c 100644 --- a/src/main/java/fr/openmc/core/disabled/corporation/menu/shop/ShopSearchMenu.java.bak +++ b/src/main/java/fr/openmc/core/disabled/corporation/menu/shop/ShopSearchMenu.java.bak @@ -85,13 +85,13 @@ public class ShopSearchMenu extends PaginatedMenu { @Override public Map getButtons() { Map buttons = new HashMap<>(); - buttons.put(49, new ItemBuilder(this, CustomItemRegistry.getByName("_iainternal:icon_cancel").getBest(), itemMeta -> itemMeta.setDisplayName("§7Fermer")) + buttons.put(49, new ItemBuilder(this, OMCRegistry.CUSTOM_ITEMS.get("_iainternal:icon_cancel").getBest(), itemMeta -> itemMeta.setDisplayName("§7Fermer")) .setCloseButton()); - ItemBuilder nextPageButton = new ItemBuilder(this, CustomItemRegistry.getByName("_iainternal:icon_next_orange").getBest(), itemMeta -> itemMeta.setDisplayName("§aPage suivante")); - ItemBuilder searchButton = new ItemBuilder(this, CustomItemRegistry.getByName("_iainternal:icon_search").getBest().getType(), itemMeta -> + ItemBuilder nextPageButton = new ItemBuilder(this, OMCRegistry.CUSTOM_ITEMS.get("_iainternal:icon_next_orange").getBest(), itemMeta -> itemMeta.setDisplayName("§aPage suivante")); + ItemBuilder searchButton = new ItemBuilder(this, OMCRegistry.CUSTOM_ITEMS.get("_iainternal:icon_search").getBest().getType(), itemMeta -> itemMeta.setDisplayName("Rechercher")); if ((getPage() != 0 && !isLastPage()) || !CompanyManager.getShops().isEmpty()) { - buttons.put(48, new ItemBuilder(this, CustomItemRegistry.getByName("_iainternal:icon_back_orange").getBest(), itemMeta -> itemMeta.setDisplayName("§cPage précédente")) + buttons.put(48, new ItemBuilder(this, OMCRegistry.CUSTOM_ITEMS.get("_iainternal:icon_back_orange").getBest(), itemMeta -> itemMeta.setDisplayName("§cPage précédente")) .setPreviousPageButton()); buttons.put(50, nextPageButton.setNextPageButton()); buttons.put(45, searchButton.setOnClick(inventoryClick -> { diff --git a/src/main/java/fr/openmc/core/disabled/corporation/menu/shop/ShopStocksMenu.java.bak b/src/main/java/fr/openmc/core/disabled/corporation/menu/shop/ShopStocksMenu.java.bak index c62873176..f208cbc9a 100644 --- a/src/main/java/fr/openmc/core/disabled/corporation/menu/shop/ShopStocksMenu.java.bak +++ b/src/main/java/fr/openmc/core/disabled/corporation/menu/shop/ShopStocksMenu.java.bak @@ -88,15 +88,15 @@ public class ShopStocksMenu extends PaginatedMenu { @Override public Map getButtons() { Map buttons = new HashMap<>(); - buttons.put(49, new ItemBuilder(this, CustomItemRegistry.getByName("_iainternal:icon_cancel").getBest(), itemMeta -> itemMeta.setDisplayName("§7Fermer")) + buttons.put(49, new ItemBuilder(this, OMCRegistry.CUSTOM_ITEMS.get("_iainternal:icon_cancel").getBest(), itemMeta -> itemMeta.setDisplayName("§7Fermer")) .setCloseButton()); - ItemBuilder nextPageButton = new ItemBuilder(this, CustomItemRegistry.getByName("_iainternal:icon_next_orange").getBest(), itemMeta -> itemMeta.setDisplayName("§aPage suivante")); + ItemBuilder nextPageButton = new ItemBuilder(this, OMCRegistry.CUSTOM_ITEMS.get("_iainternal:icon_next_orange").getBest(), itemMeta -> itemMeta.setDisplayName("§aPage suivante")); if ((getPage() == 0 && isLastPage()) || shop.getSales().isEmpty()) { - buttons.put(48, new ItemBuilder(this, CustomItemRegistry.getByName("_iainternal:icon_back_orange").getBest(), itemMeta -> itemMeta.setDisplayName("§cRetour")) + buttons.put(48, new ItemBuilder(this, OMCRegistry.CUSTOM_ITEMS.get("_iainternal:icon_back_orange").getBest(), itemMeta -> itemMeta.setDisplayName("§cRetour")) .setOnClick(inventoryClickEvent -> new ShopMenu(getOwner(), shop, itemIndex).open())); buttons.put(50, nextPageButton); } else { - buttons.put(48, new ItemBuilder(this, CustomItemRegistry.getByName("_iainternal:icon_back_orange").getBest(), itemMeta -> itemMeta.setDisplayName("§cPage précédente")) + buttons.put(48, new ItemBuilder(this, OMCRegistry.CUSTOM_ITEMS.get("_iainternal:icon_back_orange").getBest(), itemMeta -> itemMeta.setDisplayName("§cPage précédente")) .setPreviousPageButton()); buttons.put(50, nextPageButton.setNextPageButton()); } diff --git a/src/main/java/fr/openmc/core/features/adminshop/menus/AdminShopCategoryMenu.java b/src/main/java/fr/openmc/core/features/adminshop/menus/AdminShopCategoryMenu.java index aafda4f01..90802c5ed 100644 --- a/src/main/java/fr/openmc/core/features/adminshop/menus/AdminShopCategoryMenu.java +++ b/src/main/java/fr/openmc/core/features/adminshop/menus/AdminShopCategoryMenu.java @@ -4,10 +4,10 @@ import fr.openmc.api.menulib.Menu; import fr.openmc.api.menulib.utils.InventorySize; import fr.openmc.api.menulib.utils.ItemBuilder; +import fr.openmc.core.OMCRegistry; import fr.openmc.core.features.adminshop.AdminShopManager; import fr.openmc.core.features.adminshop.AdminShopUtils; import fr.openmc.core.features.adminshop.ShopItem; -import fr.openmc.core.registry.items.CustomItemRegistry; import fr.openmc.core.utils.text.messages.TranslationManager; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.NamedTextColor; @@ -88,7 +88,7 @@ else if (event.isRightClick() && item.getInitialSellPrice() > 0) } content.put(40, new ItemBuilder(this, - CustomItemRegistry.getByName("omc_menus:refuse_btn").getBest(), + OMCRegistry.CUSTOM_ITEMS.get("omc_menus:refuse_btn").getBest(), true)); return content; diff --git a/src/main/java/fr/openmc/core/features/adminshop/menus/ColorVariantsMenu.java b/src/main/java/fr/openmc/core/features/adminshop/menus/ColorVariantsMenu.java index 67a883cc1..845a1dadc 100644 --- a/src/main/java/fr/openmc/core/features/adminshop/menus/ColorVariantsMenu.java +++ b/src/main/java/fr/openmc/core/features/adminshop/menus/ColorVariantsMenu.java @@ -4,10 +4,10 @@ import fr.openmc.api.menulib.Menu; import fr.openmc.api.menulib.utils.InventorySize; import fr.openmc.api.menulib.utils.ItemBuilder; +import fr.openmc.core.OMCRegistry; import fr.openmc.core.features.adminshop.AdminShopManager; import fr.openmc.core.features.adminshop.AdminShopUtils; import fr.openmc.core.features.adminshop.ShopItem; -import fr.openmc.core.registry.items.CustomItemRegistry; import fr.openmc.core.utils.bukkit.ItemUtils; import fr.openmc.core.utils.text.messages.TranslationManager; import net.kyori.adventure.text.Component; @@ -152,7 +152,7 @@ public void onInventoryClick(InventoryClickEvent event) {} } content.put(49, new ItemBuilder(this, - CustomItemRegistry.getByName("omc_menus:refuse_btn").getBest(), + OMCRegistry.CUSTOM_ITEMS.get("omc_menus:refuse_btn").getBest(), true)); return content; diff --git a/src/main/java/fr/openmc/core/features/adminshop/menus/ConfirmMenu.java b/src/main/java/fr/openmc/core/features/adminshop/menus/ConfirmMenu.java index 43f5d5757..33edcdda0 100644 --- a/src/main/java/fr/openmc/core/features/adminshop/menus/ConfirmMenu.java +++ b/src/main/java/fr/openmc/core/features/adminshop/menus/ConfirmMenu.java @@ -5,10 +5,10 @@ import fr.openmc.api.menulib.Menu; import fr.openmc.api.menulib.utils.InventorySize; import fr.openmc.api.menulib.utils.ItemBuilder; +import fr.openmc.core.OMCRegistry; import fr.openmc.core.features.adminshop.AdminShopManager; import fr.openmc.core.features.adminshop.ShopItem; import fr.openmc.core.features.economy.EconomyManager; -import fr.openmc.core.registry.items.CustomItemRegistry; import fr.openmc.core.utils.bukkit.ItemUtils; import fr.openmc.core.utils.text.messages.TranslationManager; import net.kyori.adventure.text.Component; @@ -73,23 +73,23 @@ public void onInventoryClick(InventoryClickEvent inventoryClickEvent) {} Component.text(AdminShopManager.priceFormat.format(totalPrice)), Component.text(EconomyManager.getEconomyIcon()) ); - content.put(9, new ItemBuilder(this, CustomItemRegistry.getByName("omc_menus:refuse_btn").getBest(), meta -> { + content.put(9, new ItemBuilder(this, OMCRegistry.CUSTOM_ITEMS.get("omc_menus:refuse_btn").getBest(), meta -> { meta.displayName(TranslationManager.translation("messages.global.cancel")); }, true)); - content.put(10, createQuantityButton("-64", CustomItemRegistry.getByName("omc_menus:64_btn").getBest(), event -> { + content.put(10, createQuantityButton("-64", OMCRegistry.CUSTOM_ITEMS.get("omc_menus:64_btn").getBest(), event -> { if (quantity > 64) quantity -= 64; else quantity = 1; this.open(); })); - content.put(11, createQuantityButton("-10", CustomItemRegistry.getByName("omc_menus:minus_btn").getBest(), event -> { + content.put(11, createQuantityButton("-10", OMCRegistry.CUSTOM_ITEMS.get("omc_menus:minus_btn").getBest(), event -> { if (quantity > 10) quantity -= 10; else quantity = 1; this.open(); })); - content.put(12, createQuantityButton("-1", CustomItemRegistry.getByName("omc_menus:1_btn").getBest(), event -> { + content.put(12, createQuantityButton("-1", OMCRegistry.CUSTOM_ITEMS.get("omc_menus:1_btn").getBest(), event -> { if (quantity > 1) quantity--; else quantity = 1; this.open(); @@ -119,13 +119,13 @@ public void onInventoryClick(InventoryClickEvent inventoryClickEvent) {} } })); - content.put(14, createQuantityButton("+1", CustomItemRegistry.getByName("omc_menus:1_btn").getBest(), event -> increaseQuantity(1))); + content.put(14, createQuantityButton("+1", OMCRegistry.CUSTOM_ITEMS.get("omc_menus:1_btn").getBest(), event -> increaseQuantity(1))); - content.put(15, createQuantityButton("+10", CustomItemRegistry.getByName("omc_menus:plus_btn").getBest(), event -> increaseQuantity(10))); + content.put(15, createQuantityButton("+10", OMCRegistry.CUSTOM_ITEMS.get("omc_menus:plus_btn").getBest(), event -> increaseQuantity(10))); - content.put(16, createQuantityButton("+64", CustomItemRegistry.getByName("omc_menus:64_btn").getBest(), event -> increaseQuantity(64))); + content.put(16, createQuantityButton("+64", OMCRegistry.CUSTOM_ITEMS.get("omc_menus:64_btn").getBest(), event -> increaseQuantity(64))); - content.put(17, new ItemBuilder(this, CustomItemRegistry.getByName("omc_menus:accept_btn").getBest(), meta -> { + content.put(17, new ItemBuilder(this, OMCRegistry.CUSTOM_ITEMS.get("omc_menus:accept_btn").getBest(), meta -> { meta.displayName(TranslationManager.translation("messages.global.accept")); }).setOnClick(event -> { getOwner().closeInventory(); diff --git a/src/main/java/fr/openmc/core/features/adminshop/menus/LeavesVariantsMenu.java b/src/main/java/fr/openmc/core/features/adminshop/menus/LeavesVariantsMenu.java index eec575e73..23ac9f19c 100644 --- a/src/main/java/fr/openmc/core/features/adminshop/menus/LeavesVariantsMenu.java +++ b/src/main/java/fr/openmc/core/features/adminshop/menus/LeavesVariantsMenu.java @@ -4,10 +4,10 @@ import fr.openmc.api.menulib.Menu; import fr.openmc.api.menulib.utils.InventorySize; import fr.openmc.api.menulib.utils.ItemBuilder; +import fr.openmc.core.OMCRegistry; import fr.openmc.core.features.adminshop.AdminShopManager; import fr.openmc.core.features.adminshop.AdminShopUtils; import fr.openmc.core.features.adminshop.ShopItem; -import fr.openmc.core.registry.items.CustomItemRegistry; import fr.openmc.core.utils.bukkit.ItemUtils; import fr.openmc.core.utils.text.messages.TranslationManager; import net.kyori.adventure.text.Component; @@ -110,7 +110,7 @@ public void onInventoryClick(InventoryClickEvent event) {} } content.put(49, new ItemBuilder(this, - CustomItemRegistry.getByName("omc_menus:refuse_btn").getBest(), + OMCRegistry.CUSTOM_ITEMS.get("omc_menus:refuse_btn").getBest(), true)); return content; } diff --git a/src/main/java/fr/openmc/core/features/adminshop/menus/LogVariantsMenu.java b/src/main/java/fr/openmc/core/features/adminshop/menus/LogVariantsMenu.java index b07930350..8709505e8 100644 --- a/src/main/java/fr/openmc/core/features/adminshop/menus/LogVariantsMenu.java +++ b/src/main/java/fr/openmc/core/features/adminshop/menus/LogVariantsMenu.java @@ -4,10 +4,10 @@ import fr.openmc.api.menulib.Menu; import fr.openmc.api.menulib.utils.InventorySize; import fr.openmc.api.menulib.utils.ItemBuilder; +import fr.openmc.core.OMCRegistry; import fr.openmc.core.features.adminshop.AdminShopManager; import fr.openmc.core.features.adminshop.AdminShopUtils; import fr.openmc.core.features.adminshop.ShopItem; -import fr.openmc.core.registry.items.CustomItemRegistry; import fr.openmc.core.utils.bukkit.ItemUtils; import fr.openmc.core.utils.text.messages.TranslationManager; import net.kyori.adventure.text.Component; @@ -109,7 +109,7 @@ public void onInventoryClick(InventoryClickEvent event) {} } content.put(49, new ItemBuilder(this, - CustomItemRegistry.getByName("omc_menus:refuse_btn").getBest(), + OMCRegistry.CUSTOM_ITEMS.get("omc_menus:refuse_btn").getBest(), true)); return content; diff --git a/src/main/java/fr/openmc/core/features/city/actions/CityCreateAction.java b/src/main/java/fr/openmc/core/features/city/actions/CityCreateAction.java index c382269f4..e77ed06fa 100644 --- a/src/main/java/fr/openmc/core/features/city/actions/CityCreateAction.java +++ b/src/main/java/fr/openmc/core/features/city/actions/CityCreateAction.java @@ -2,6 +2,7 @@ import fr.openmc.api.cooldown.DynamicCooldownManager; import fr.openmc.api.input.location.ItemInteraction; +import fr.openmc.core.OMCRegistry; import fr.openmc.core.features.city.City; import fr.openmc.core.features.city.CityManager; import fr.openmc.core.features.city.CityType; @@ -12,7 +13,6 @@ import fr.openmc.core.features.economy.EconomyManager; import fr.openmc.core.hooks.WorldGuardHook; import fr.openmc.core.registry.items.CustomItem; -import fr.openmc.core.registry.items.CustomItemRegistry; import fr.openmc.core.utils.bukkit.ItemUtils; import fr.openmc.core.utils.text.messages.MessageType; import fr.openmc.core.utils.text.messages.MessagesManager; @@ -70,7 +70,7 @@ public static void beginCreateCity(Player player, String cityName) { private static ItemStack getMascotStick() { ItemStack stick; - CustomItem mascotStick = CustomItemRegistry.getByName("omc_items:mascot_stick"); + CustomItem mascotStick = OMCRegistry.CUSTOM_ITEMS.get("omc_items:mascot_stick"); if (mascotStick != null) stick = mascotStick.getBest(); else diff --git a/src/main/java/fr/openmc/core/features/city/actions/CityUnclaimAction.java b/src/main/java/fr/openmc/core/features/city/actions/CityUnclaimAction.java index 9905276de..e5c5501de 100644 --- a/src/main/java/fr/openmc/core/features/city/actions/CityUnclaimAction.java +++ b/src/main/java/fr/openmc/core/features/city/actions/CityUnclaimAction.java @@ -1,9 +1,9 @@ package fr.openmc.core.features.city.actions; +import fr.openmc.core.OMCRegistry; import fr.openmc.core.features.city.City; import fr.openmc.core.features.city.CityManager; import fr.openmc.core.features.economy.EconomyManager; -import fr.openmc.core.registry.items.CustomItemRegistry; import fr.openmc.core.utils.bukkit.ItemUtils; import fr.openmc.core.utils.text.messages.MessageType; import fr.openmc.core.utils.text.messages.MessagesManager; @@ -15,7 +15,7 @@ public class CityUnclaimAction { - private static final ItemStack ayweniteItemStack = CustomItemRegistry.getByName("omc_items:aywenite").getBest(); + private static final ItemStack ayweniteItemStack = OMCRegistry.CUSTOM_ITEMS.get("omc_items:aywenite").getBest(); public static int calculatePrice(int chunkCount) { return 5000 + ((chunkCount - 1) * 1000) / 3; diff --git a/src/main/java/fr/openmc/core/features/city/conditions/CityChestConditions.java b/src/main/java/fr/openmc/core/features/city/conditions/CityChestConditions.java index 3a460e1ed..f28f57c89 100644 --- a/src/main/java/fr/openmc/core/features/city/conditions/CityChestConditions.java +++ b/src/main/java/fr/openmc/core/features/city/conditions/CityChestConditions.java @@ -1,11 +1,11 @@ package fr.openmc.core.features.city.conditions; +import fr.openmc.core.OMCRegistry; import fr.openmc.core.features.city.City; import fr.openmc.core.features.city.CityPermission; import fr.openmc.core.features.city.sub.milestone.rewards.ChestPageLimitRewards; import fr.openmc.core.features.city.sub.milestone.rewards.FeaturesRewards; import fr.openmc.core.features.economy.EconomyManager; -import fr.openmc.core.registry.items.CustomItemRegistry; import fr.openmc.core.utils.bukkit.ItemUtils; import fr.openmc.core.utils.text.messages.MessageType; import fr.openmc.core.utils.text.messages.MessagesManager; @@ -98,7 +98,7 @@ public static boolean canCityChestUpgrade(City city, Player player) { } int aywenite = city.getChestPages() * UPGRADE_PER_AYWENITE; // fonction linéaire f(x)=ax ; a=UPGRADE_PER_MONEY - if (!ItemUtils.hasEnoughItems(player, Objects.requireNonNull(CustomItemRegistry.getByName("omc_items:aywenite")).getBest(), aywenite)) { + if (!ItemUtils.hasEnoughItems(player, Objects.requireNonNull(OMCRegistry.CUSTOM_ITEMS.get("omc_items:aywenite")).getBest(), aywenite)) { MessagesManager.sendMessage(player, TranslationManager.translation("feature.city.conditions.resource.not_enough_aywenite", Component.text(aywenite)), Prefix.CITY, MessageType.ERROR, false); return false; } diff --git a/src/main/java/fr/openmc/core/features/city/conditions/CityClaimCondition.java b/src/main/java/fr/openmc/core/features/city/conditions/CityClaimCondition.java index aef1b8cd9..e5af9e6a7 100644 --- a/src/main/java/fr/openmc/core/features/city/conditions/CityClaimCondition.java +++ b/src/main/java/fr/openmc/core/features/city/conditions/CityClaimCondition.java @@ -1,10 +1,10 @@ package fr.openmc.core.features.city.conditions; +import fr.openmc.core.OMCRegistry; import fr.openmc.core.features.city.City; import fr.openmc.core.features.city.CityPermission; import fr.openmc.core.features.city.actions.CityClaimAction; import fr.openmc.core.features.economy.EconomyManager; -import fr.openmc.core.registry.items.CustomItemRegistry; import fr.openmc.core.utils.bukkit.ItemUtils; import fr.openmc.core.utils.text.messages.MessageType; import fr.openmc.core.utils.text.messages.MessagesManager; @@ -43,7 +43,7 @@ public static boolean canCityClaim(City city, Player player) { if (city.getFreeClaims() > 0) return true; int amount = CityClaimAction.calculateAywenite(city.getChunks().size()); - if (!ItemUtils.hasEnoughItems(player, CustomItemRegistry.getByName("omc_items:aywenite").getBest(), amount)) { + if (!ItemUtils.hasEnoughItems(player, OMCRegistry.CUSTOM_ITEMS.get("omc_items:aywenite").getBest(), amount)) { MessagesManager.sendMessage( player, TranslationManager.translation("feature.city.conditions.resource.not_enough_aywenite", Component.text(amount)), diff --git a/src/main/java/fr/openmc/core/features/city/conditions/CityCreateConditions.java b/src/main/java/fr/openmc/core/features/city/conditions/CityCreateConditions.java index 2e206a457..de4bc8c1f 100644 --- a/src/main/java/fr/openmc/core/features/city/conditions/CityCreateConditions.java +++ b/src/main/java/fr/openmc/core/features/city/conditions/CityCreateConditions.java @@ -1,9 +1,9 @@ package fr.openmc.core.features.city.conditions; import fr.openmc.api.cooldown.DynamicCooldownManager; +import fr.openmc.core.OMCRegistry; import fr.openmc.core.features.city.CityManager; import fr.openmc.core.features.economy.EconomyManager; -import fr.openmc.core.registry.items.CustomItemRegistry; import fr.openmc.core.utils.bukkit.ItemUtils; import fr.openmc.core.utils.text.InputUtils; import fr.openmc.core.utils.text.messages.MessageType; @@ -52,7 +52,7 @@ public static boolean canCityCreate(Player player, String cityName) { return false; } - if (!ItemUtils.hasEnoughItems(player, Objects.requireNonNull(CustomItemRegistry.getByName("omc_items:aywenite")).getBest(), AYWENITE_CREATE)) { + if (!ItemUtils.hasEnoughItems(player, Objects.requireNonNull(OMCRegistry.CUSTOM_ITEMS.get("omc_items:aywenite")).getBest(), AYWENITE_CREATE)) { MessagesManager.sendMessage(player, TranslationManager.translation("feature.city.conditions.resource.not_enough_aywenite", Component.text(AYWENITE_CREATE)), Prefix.CITY, MessageType.ERROR, false); return false; } diff --git a/src/main/java/fr/openmc/core/features/city/menu/CityChestMenu.java b/src/main/java/fr/openmc/core/features/city/menu/CityChestMenu.java index 862c495b1..c6a0e7570 100644 --- a/src/main/java/fr/openmc/core/features/city/menu/CityChestMenu.java +++ b/src/main/java/fr/openmc/core/features/city/menu/CityChestMenu.java @@ -5,6 +5,7 @@ import fr.openmc.api.menulib.utils.ItemBuilder; import fr.openmc.api.menulib.utils.MenuUtils; import fr.openmc.api.menulib.utils.StaticSlots; +import fr.openmc.core.OMCRegistry; import fr.openmc.core.commands.utils.Restart; import fr.openmc.core.features.city.City; import fr.openmc.core.features.city.CityManager; @@ -12,7 +13,6 @@ import fr.openmc.core.features.city.actions.CityChestAction; import fr.openmc.core.features.city.sub.milestone.rewards.ChestPageLimitRewards; import fr.openmc.core.features.economy.EconomyManager; -import fr.openmc.core.registry.items.CustomItemRegistry; import fr.openmc.core.utils.text.messages.TranslationManager; import lombok.Getter; import net.kyori.adventure.text.Component; @@ -106,7 +106,7 @@ public Map getButtons() { map.put(45, new ItemBuilder(this, Material.ARROW, true).setOnClick(inventoryClickEvent -> exit(city, getInventory()))); - map.put(49, new ItemBuilder(this, CustomItemRegistry.getByName("_iainternal:icon_cancel").getBest(), itemMeta -> { + map.put(49, new ItemBuilder(this, OMCRegistry.CUSTOM_ITEMS.get("_iainternal:icon_cancel").getBest(), itemMeta -> { itemMeta.displayName(TranslationManager.translation("messages.menus.close")); }).setOnClick(inventoryClickEvent -> { exit(city, getInventory()); @@ -114,7 +114,7 @@ public Map getButtons() { })); if (hasPreviousPage()) { - map.put(48, new ItemBuilder(this, CustomItemRegistry.getByName("_iainternal:icon_back_orange").getBest(), itemMeta -> { + map.put(48, new ItemBuilder(this, OMCRegistry.CUSTOM_ITEMS.get("_iainternal:icon_back_orange").getBest(), itemMeta -> { itemMeta.displayName(TranslationManager.translation("messages.menus.previous_page")); }).setOnClick(inventoryClickEvent -> { if (hasPreviousPage()) { @@ -128,7 +128,7 @@ public Map getButtons() { })); } if (hasNextPage()) { - map.put(50, new ItemBuilder(this, CustomItemRegistry.getByName("_iainternal:icon_next_orange").getBest(), itemMeta -> { + map.put(50, new ItemBuilder(this, OMCRegistry.CUSTOM_ITEMS.get("_iainternal:icon_next_orange").getBest(), itemMeta -> { itemMeta.displayName(TranslationManager.translation("messages.menus.next_page")); }).setOnClick(inventoryClickEvent -> { if (hasNextPage()) { diff --git a/src/main/java/fr/openmc/core/features/city/menu/CityPermsMenu.java b/src/main/java/fr/openmc/core/features/city/menu/CityPermsMenu.java index 83318c903..fb560fe43 100644 --- a/src/main/java/fr/openmc/core/features/city/menu/CityPermsMenu.java +++ b/src/main/java/fr/openmc/core/features/city/menu/CityPermsMenu.java @@ -5,11 +5,11 @@ import fr.openmc.api.menulib.utils.ItemBuilder; import fr.openmc.api.menulib.utils.ItemUtils; import fr.openmc.api.menulib.utils.StaticSlots; +import fr.openmc.core.OMCRegistry; import fr.openmc.core.features.city.City; import fr.openmc.core.features.city.CityManager; import fr.openmc.core.features.city.CityPermission; import fr.openmc.core.features.city.commands.CityPermsCommands; -import fr.openmc.core.registry.items.CustomItemRegistry; import fr.openmc.core.utils.cache.CacheOfflinePlayer; import fr.openmc.core.utils.text.messages.MessageType; import fr.openmc.core.utils.text.messages.MessagesManager; @@ -109,12 +109,12 @@ public Map getButtons() { itemMeta.lore(List.of(TranslationManager.translation("messages.menus.back_lore"))); }, true)); - map.put(48, new ItemBuilder(this, CustomItemRegistry.getByName("_iainternal:icon_back_orange").getBest(), itemMeta -> { + map.put(48, new ItemBuilder(this, OMCRegistry.CUSTOM_ITEMS.get("_iainternal:icon_back_orange").getBest(), itemMeta -> { itemMeta.displayName(TranslationManager.translation("messages.menus.previous_page")); itemMeta.lore(TranslationManager.translationLore("messages.menus.previous_page_lore")); }).setPreviousPageButton()); - map.put(50, new ItemBuilder(this, CustomItemRegistry.getByName("_iainternal:icon_next_orange").getBest(), itemMeta -> { + map.put(50, new ItemBuilder(this, OMCRegistry.CUSTOM_ITEMS.get("_iainternal:icon_next_orange").getBest(), itemMeta -> { itemMeta.displayName(TranslationManager.translation("messages.menus.next_page")); itemMeta.lore(TranslationManager.translationLore("messages.menus.next_page_lore")); }).setNextPageButton()); diff --git a/src/main/java/fr/openmc/core/features/city/menu/CityTransferMenu.java b/src/main/java/fr/openmc/core/features/city/menu/CityTransferMenu.java index 2a0d8dab2..ca96d5136 100644 --- a/src/main/java/fr/openmc/core/features/city/menu/CityTransferMenu.java +++ b/src/main/java/fr/openmc/core/features/city/menu/CityTransferMenu.java @@ -4,11 +4,11 @@ import fr.openmc.api.menulib.utils.InventorySize; import fr.openmc.api.menulib.utils.ItemBuilder; import fr.openmc.api.menulib.utils.StaticSlots; +import fr.openmc.core.OMCRegistry; import fr.openmc.core.features.city.City; import fr.openmc.core.features.city.CityManager; import fr.openmc.core.features.city.CityPermission; import fr.openmc.core.features.city.actions.CityTransferAction; -import fr.openmc.core.registry.items.CustomItemRegistry; import fr.openmc.core.utils.bukkit.SkullUtils; import fr.openmc.core.utils.cache.CacheOfflinePlayer; import fr.openmc.core.utils.text.messages.MessageType; @@ -91,13 +91,13 @@ public List getTakableSlot() { @Override public Map getButtons() { Map map = new HashMap<>(); - map.put(49, new ItemBuilder(this, CustomItemRegistry.getByName("_iainternal:icon_cancel").getBest(), itemMeta -> { + map.put(49, new ItemBuilder(this, OMCRegistry.CUSTOM_ITEMS.get("_iainternal:icon_cancel").getBest(), itemMeta -> { itemMeta.displayName(TranslationManager.translation("messages.menus.close")); }).setCloseButton()); - map.put(48, new ItemBuilder(this, CustomItemRegistry.getByName("_iainternal:icon_back_orange").getBest(), itemMeta -> { + map.put(48, new ItemBuilder(this, OMCRegistry.CUSTOM_ITEMS.get("_iainternal:icon_back_orange").getBest(), itemMeta -> { itemMeta.displayName(TranslationManager.translation("messages.menus.previous_page")); }).setPreviousPageButton()); - map.put(50, new ItemBuilder(this, CustomItemRegistry.getByName("_iainternal:icon_next_orange").getBest(), itemMeta -> { + map.put(50, new ItemBuilder(this, OMCRegistry.CUSTOM_ITEMS.get("_iainternal:icon_next_orange").getBest(), itemMeta -> { itemMeta.displayName(TranslationManager.translation("messages.menus.next_page")); }).setNextPageButton()); return map; diff --git a/src/main/java/fr/openmc/core/features/city/menu/InvitationsMenu.java b/src/main/java/fr/openmc/core/features/city/menu/InvitationsMenu.java index 3400a980d..6ff2fddc0 100644 --- a/src/main/java/fr/openmc/core/features/city/menu/InvitationsMenu.java +++ b/src/main/java/fr/openmc/core/features/city/menu/InvitationsMenu.java @@ -5,10 +5,10 @@ import fr.openmc.api.menulib.utils.InventorySize; import fr.openmc.api.menulib.utils.ItemBuilder; import fr.openmc.api.menulib.utils.StaticSlots; +import fr.openmc.core.OMCRegistry; import fr.openmc.core.features.city.City; import fr.openmc.core.features.city.CityManager; import fr.openmc.core.features.city.commands.CityInviteCommands; -import fr.openmc.core.registry.items.CustomItemRegistry; import fr.openmc.core.utils.text.messages.TranslationManager; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.NamedTextColor; @@ -122,7 +122,7 @@ public Map getButtons() { itemMeta.lore(List.of(TranslationManager.translation("messages.menus.back_lore"))); }, true)); - map.put(49, new ItemBuilder(this, CustomItemRegistry.getByName("_iainternal:icon_cancel").getBest(), itemMeta -> { + map.put(49, new ItemBuilder(this, OMCRegistry.CUSTOM_ITEMS.get("_iainternal:icon_cancel").getBest(), itemMeta -> { itemMeta.displayName(TranslationManager.translation("messages.menus.close")); }).setOnClick(inventoryClickEvent -> getOwner().closeInventory() @@ -130,10 +130,10 @@ public Map getButtons() { map.put(48, new ItemBuilder(this, - Objects.requireNonNull(CustomItemRegistry.getByName("_iainternal:icon_back_orange")).getBest(), + Objects.requireNonNull(OMCRegistry.CUSTOM_ITEMS.get("_iainternal:icon_back_orange")).getBest(), itemMeta -> itemMeta.displayName(TranslationManager.translation("messages.menus.previous_page"))).setPreviousPageButton()); map.put(50, - new ItemBuilder(this, Objects.requireNonNull(CustomItemRegistry.getByName("_iainternal:icon_next_orange")).getBest(), + new ItemBuilder(this, Objects.requireNonNull(OMCRegistry.CUSTOM_ITEMS.get("_iainternal:icon_next_orange")).getBest(), itemMeta -> itemMeta.displayName(TranslationManager.translation("messages.menus.next_page"))).setNextPageButton()); return map; diff --git a/src/main/java/fr/openmc/core/features/city/menu/list/CityPlayerListMenu.java b/src/main/java/fr/openmc/core/features/city/menu/list/CityPlayerListMenu.java index 021fa3617..064647bd0 100644 --- a/src/main/java/fr/openmc/core/features/city/menu/list/CityPlayerListMenu.java +++ b/src/main/java/fr/openmc/core/features/city/menu/list/CityPlayerListMenu.java @@ -4,8 +4,8 @@ import fr.openmc.api.menulib.utils.InventorySize; import fr.openmc.api.menulib.utils.ItemBuilder; import fr.openmc.api.menulib.utils.StaticSlots; +import fr.openmc.core.OMCRegistry; import fr.openmc.core.features.city.City; -import fr.openmc.core.registry.items.CustomItemRegistry; import fr.openmc.core.utils.bukkit.SkullUtils; import fr.openmc.core.utils.cache.CacheOfflinePlayer; import fr.openmc.core.utils.text.messages.TranslationManager; @@ -80,9 +80,9 @@ public Map getButtons() { itemMeta.itemName(TranslationManager.translation("messages.menus.back")); itemMeta.lore(TranslationManager.translationLore("feature.city.menus.list.members.back_lore")); }, true)); - map.put(49, new ItemBuilder(this, Objects.requireNonNull(CustomItemRegistry.getByName("_iainternal:icon_cancel")).getBest(), itemMeta -> itemMeta.displayName(TranslationManager.translation("messages.menus.close"))).setCloseButton()); - map.put(48, new ItemBuilder(this, Objects.requireNonNull(CustomItemRegistry.getByName("_iainternal:icon_back_orange")).getBest(), itemMeta -> itemMeta.displayName(TranslationManager.translation("messages.menus.previous_page"))).setPreviousPageButton()); - map.put(50, new ItemBuilder(this, Objects.requireNonNull(CustomItemRegistry.getByName("_iainternal:icon_next_orange")).getBest(), itemMeta -> itemMeta.displayName(TranslationManager.translation("messages.menus.next_page"))).setNextPageButton()); + map.put(49, new ItemBuilder(this, Objects.requireNonNull(OMCRegistry.CUSTOM_ITEMS.get("_iainternal:icon_cancel")).getBest(), itemMeta -> itemMeta.displayName(TranslationManager.translation("messages.menus.close"))).setCloseButton()); + map.put(48, new ItemBuilder(this, Objects.requireNonNull(OMCRegistry.CUSTOM_ITEMS.get("_iainternal:icon_back_orange")).getBest(), itemMeta -> itemMeta.displayName(TranslationManager.translation("messages.menus.previous_page"))).setPreviousPageButton()); + map.put(50, new ItemBuilder(this, Objects.requireNonNull(OMCRegistry.CUSTOM_ITEMS.get("_iainternal:icon_next_orange")).getBest(), itemMeta -> itemMeta.displayName(TranslationManager.translation("messages.menus.next_page"))).setNextPageButton()); return map; } diff --git a/src/main/java/fr/openmc/core/features/city/menu/playerlist/CityPlayerListMenu.java b/src/main/java/fr/openmc/core/features/city/menu/playerlist/CityPlayerListMenu.java index dfa0e0568..c222a9433 100644 --- a/src/main/java/fr/openmc/core/features/city/menu/playerlist/CityPlayerListMenu.java +++ b/src/main/java/fr/openmc/core/features/city/menu/playerlist/CityPlayerListMenu.java @@ -6,6 +6,7 @@ import fr.openmc.api.menulib.utils.InventorySize; import fr.openmc.api.menulib.utils.ItemBuilder; import fr.openmc.api.menulib.utils.StaticSlots; +import fr.openmc.core.OMCRegistry; import fr.openmc.core.features.city.City; import fr.openmc.core.features.city.CityManager; import fr.openmc.core.features.city.CityPermission; @@ -13,7 +14,6 @@ import fr.openmc.core.features.city.commands.CityInviteCommands; import fr.openmc.core.features.city.menu.CityPermsMenu; import fr.openmc.core.features.city.sub.milestone.rewards.MemberLimitRewards; -import fr.openmc.core.registry.items.CustomItemRegistry; import fr.openmc.core.utils.bukkit.SkullUtils; import fr.openmc.core.utils.cache.CacheOfflinePlayer; import fr.openmc.core.utils.text.InputUtils; @@ -159,7 +159,7 @@ public Map getButtons() { itemMeta.lore(List.of(TranslationManager.translation("messages.menus.back_lore"))); }, true)); - map.put(49, new ItemBuilder(this, CustomItemRegistry.getByName("_iainternal:icon_cancel").getBest(), itemMeta -> { + map.put(49, new ItemBuilder(this, OMCRegistry.CUSTOM_ITEMS.get("_iainternal:icon_cancel").getBest(), itemMeta -> { itemMeta.displayName(TranslationManager.translation("messages.menus.close")); }).setOnClick(inventoryClickEvent -> getOwner().closeInventory() @@ -167,14 +167,14 @@ public Map getButtons() { map.put(48, new ItemBuilder(this, - Objects.requireNonNull(CustomItemRegistry.getByName("_iainternal:icon_back_orange")).getBest(), + Objects.requireNonNull(OMCRegistry.CUSTOM_ITEMS.get("_iainternal:icon_back_orange")).getBest(), itemMeta -> itemMeta.displayName(TranslationManager.translation("messages.menus.previous_page"))).setPreviousPageButton()); map.put(50, - new ItemBuilder(this, Objects.requireNonNull(CustomItemRegistry.getByName("_iainternal:icon_next_orange")).getBest(), + new ItemBuilder(this, Objects.requireNonNull(OMCRegistry.CUSTOM_ITEMS.get("_iainternal:icon_next_orange")).getBest(), itemMeta -> itemMeta.displayName(TranslationManager.translation("messages.menus.next_page"))).setNextPageButton()); - map.put(53, new ItemBuilder(this, Objects.requireNonNull(CustomItemRegistry.getByName("_iainternal:icon_search")).getBest(), itemMeta -> { + map.put(53, new ItemBuilder(this, Objects.requireNonNull(OMCRegistry.CUSTOM_ITEMS.get("_iainternal:icon_search")).getBest(), itemMeta -> { itemMeta.displayName(TranslationManager.translation("feature.city.menus.members.invite.title")); itemMeta.lore( TranslationManager.translationLore( diff --git a/src/main/java/fr/openmc/core/features/city/sub/mascots/menu/MascotMenu.java b/src/main/java/fr/openmc/core/features/city/sub/mascots/menu/MascotMenu.java index 6c94abd3c..c954497a2 100644 --- a/src/main/java/fr/openmc/core/features/city/sub/mascots/menu/MascotMenu.java +++ b/src/main/java/fr/openmc/core/features/city/sub/mascots/menu/MascotMenu.java @@ -7,13 +7,13 @@ import fr.openmc.api.menulib.utils.ItemBuilder; import fr.openmc.api.menulib.utils.MenuUtils; import fr.openmc.core.OMCPlugin; +import fr.openmc.core.OMCRegistry; import fr.openmc.core.features.city.City; import fr.openmc.core.features.city.CityManager; import fr.openmc.core.features.city.CityPermission; import fr.openmc.core.features.city.sub.mascots.models.Mascot; import fr.openmc.core.features.city.sub.mascots.models.MascotsLevels; import fr.openmc.core.features.city.sub.milestone.rewards.MascotsLevelsRewards; -import fr.openmc.core.registry.items.CustomItemRegistry; import fr.openmc.core.utils.bukkit.ItemUtils; import fr.openmc.core.utils.text.DateUtils; import fr.openmc.core.utils.text.messages.MessageType; @@ -153,7 +153,7 @@ public void onInventoryClick(InventoryClickEvent inventoryClickEvent) { movingMascots.add(cityUUID); - ItemStack mascotsMoveItem = CustomItemRegistry.getByName("omc_items:mascot_stick").getBest(); + ItemStack mascotsMoveItem = OMCRegistry.CUSTOM_ITEMS.get("omc_items:mascot_stick").getBest(); ItemMeta meta = mascotsMoveItem.getItemMeta(); if (meta != null) { diff --git a/src/main/java/fr/openmc/core/features/city/sub/mascots/menu/MascotsSkinMenu.java b/src/main/java/fr/openmc/core/features/city/sub/mascots/menu/MascotsSkinMenu.java index 70d30e1ed..048663f3b 100644 --- a/src/main/java/fr/openmc/core/features/city/sub/mascots/menu/MascotsSkinMenu.java +++ b/src/main/java/fr/openmc/core/features/city/sub/mascots/menu/MascotsSkinMenu.java @@ -3,12 +3,12 @@ import fr.openmc.api.menulib.Menu; import fr.openmc.api.menulib.utils.InventorySize; import fr.openmc.api.menulib.utils.ItemBuilder; +import fr.openmc.core.OMCRegistry; import fr.openmc.core.features.city.City; import fr.openmc.core.features.city.CityManager; import fr.openmc.core.features.city.sub.mascots.models.Mascot; import fr.openmc.core.features.city.sub.mascots.models.MascotType; import fr.openmc.core.features.city.sub.milestone.rewards.MascotsSkinUnlockRewards; -import fr.openmc.core.registry.items.CustomItemRegistry; import fr.openmc.core.utils.bukkit.ItemUtils; import fr.openmc.core.utils.text.messages.MessageType; import fr.openmc.core.utils.text.messages.MessagesManager; @@ -119,7 +119,7 @@ private ItemBuilder createMascotButton(City city, MascotType type) { } if (!egg.equals(type.getSpawnEgg())) { int aywenite = type.getPrice(); - ItemStack ISAywenite = CustomItemRegistry.getByName("omc_items:aywenite").getBest(); + ItemStack ISAywenite = OMCRegistry.CUSTOM_ITEMS.get("omc_items:aywenite").getBest(); if (ItemUtils.hasEnoughItems(getOwner(), ISAywenite, aywenite)) { changeMascotsSkin(mascots, type.getEntityType(), getOwner(), aywenite); getOwner().playSound(getOwner().getLocation(), selectSound, 1, 1); diff --git a/src/main/java/fr/openmc/core/features/city/sub/mayor/actions/MayorSetWarpAction.java b/src/main/java/fr/openmc/core/features/city/sub/mayor/actions/MayorSetWarpAction.java index 7b59a9627..46ed89e79 100644 --- a/src/main/java/fr/openmc/core/features/city/sub/mayor/actions/MayorSetWarpAction.java +++ b/src/main/java/fr/openmc/core/features/city/sub/mayor/actions/MayorSetWarpAction.java @@ -2,12 +2,12 @@ import fr.openmc.api.cooldown.DynamicCooldownManager; import fr.openmc.api.input.location.ItemInteraction; +import fr.openmc.core.OMCRegistry; import fr.openmc.core.features.city.City; import fr.openmc.core.features.city.CityManager; import fr.openmc.core.features.city.CityPermission; import fr.openmc.core.features.city.sub.mayor.models.CityLaw; import fr.openmc.core.features.city.sub.mayor.models.Mayor; -import fr.openmc.core.registry.items.CustomItemRegistry; import fr.openmc.core.utils.text.messages.MessageType; import fr.openmc.core.utils.text.messages.MessagesManager; import fr.openmc.core.utils.text.messages.Prefix; @@ -75,7 +75,7 @@ public static ItemStack getWarpWand() { List loreItemInterraction = List.of( TranslationManager.translation("feature.city.mayor.warp.wand.lore") ); - ItemStack item = CustomItemRegistry.getByName("omc_items:warp_stick").getBest(); + ItemStack item = OMCRegistry.CUSTOM_ITEMS.get("omc_items:warp_stick").getBest(); ItemMeta itemMeta = item.getItemMeta(); itemMeta.displayName(TranslationManager.translation("feature.city.mayor.warp.wand.name")); diff --git a/src/main/java/fr/openmc/core/features/city/sub/mayor/managers/NPCManager.java b/src/main/java/fr/openmc/core/features/city/sub/mayor/managers/NPCManager.java index 76f204a70..bef2eec2f 100644 --- a/src/main/java/fr/openmc/core/features/city/sub/mayor/managers/NPCManager.java +++ b/src/main/java/fr/openmc/core/features/city/sub/mayor/managers/NPCManager.java @@ -7,6 +7,7 @@ import de.oliver.fancynpcs.api.utils.NpcEquipmentSlot; import fr.openmc.api.input.location.ItemInteraction; import fr.openmc.core.OMCPlugin; +import fr.openmc.core.OMCRegistry; import fr.openmc.core.features.city.City; import fr.openmc.core.features.city.CityManager; import fr.openmc.core.features.city.CityPermission; @@ -17,7 +18,6 @@ import fr.openmc.core.features.city.sub.mayor.npcs.OwnerNPC; import fr.openmc.core.features.city.sub.milestone.rewards.FeaturesRewards; import fr.openmc.core.hooks.FancyNpcsHook; -import fr.openmc.core.registry.items.CustomItemRegistry; import fr.openmc.core.utils.cache.CacheOfflinePlayer; import fr.openmc.core.utils.text.messages.MessageType; import fr.openmc.core.utils.text.messages.MessagesManager; @@ -82,10 +82,10 @@ public static void createNPCS(UUID cityUUID, Location locationMayor, Location lo String mayorDisplayName = "" + TranslationManager.translationString("feature.city.mayor.npc.display.mayor", Component.text(mayorName)) + ""; dataMayor.setDisplayName(mayorDisplayName); - dataMayor.addEquipment(NpcEquipmentSlot.HEAD, CustomItemRegistry.getByName("omc_items:suit_helmet").getBest()); - dataMayor.addEquipment(NpcEquipmentSlot.CHEST, CustomItemRegistry.getByName("omc_items:suit_chestplate").getBest()); - dataMayor.addEquipment(NpcEquipmentSlot.LEGS, CustomItemRegistry.getByName("omc_items:suit_leggings").getBest()); - dataMayor.addEquipment(NpcEquipmentSlot.FEET, CustomItemRegistry.getByName("omc_items:suit_boots").getBest()); + dataMayor.addEquipment(NpcEquipmentSlot.HEAD, OMCRegistry.CUSTOM_ITEMS.get("omc_items:suit_helmet").getBest()); + dataMayor.addEquipment(NpcEquipmentSlot.CHEST, OMCRegistry.CUSTOM_ITEMS.get("omc_items:suit_chestplate").getBest()); + dataMayor.addEquipment(NpcEquipmentSlot.LEGS, OMCRegistry.CUSTOM_ITEMS.get("omc_items:suit_leggings").getBest()); + dataMayor.addEquipment(NpcEquipmentSlot.FEET, OMCRegistry.CUSTOM_ITEMS.get("omc_items:suit_boots").getBest()); } else { dataMayor.setSkin("https://s.namemc.com/i/1971f3c39cb8e3ef.png"); String unknownDisplayName = "" + TranslationManager.translationString("feature.city.mayor.npc.display.unknown") + ""; diff --git a/src/main/java/fr/openmc/core/features/city/sub/mayor/menu/MayorVoteMenu.java b/src/main/java/fr/openmc/core/features/city/sub/mayor/menu/MayorVoteMenu.java index 40e647c1b..0bf56aa80 100644 --- a/src/main/java/fr/openmc/core/features/city/sub/mayor/menu/MayorVoteMenu.java +++ b/src/main/java/fr/openmc/core/features/city/sub/mayor/menu/MayorVoteMenu.java @@ -5,13 +5,13 @@ import fr.openmc.api.menulib.utils.InventorySize; import fr.openmc.api.menulib.utils.ItemBuilder; import fr.openmc.api.menulib.utils.StaticSlots; +import fr.openmc.core.OMCRegistry; import fr.openmc.core.features.city.City; import fr.openmc.core.features.city.CityManager; import fr.openmc.core.features.city.sub.mayor.managers.MayorManager; import fr.openmc.core.features.city.sub.mayor.managers.PerkManager; import fr.openmc.core.features.city.sub.mayor.models.MayorCandidate; import fr.openmc.core.features.city.sub.mayor.perks.Perks; -import fr.openmc.core.registry.items.CustomItemRegistry; import fr.openmc.core.utils.bukkit.SkullUtils; import fr.openmc.core.utils.text.messages.MessageType; import fr.openmc.core.utils.text.messages.MessagesManager; @@ -165,13 +165,13 @@ private int getVotePercentage(int vote, int totalVotes) { @Override public Map getButtons() { Map map = new HashMap<>(); - map.put(49, new ItemBuilder(this, CustomItemRegistry.getByName("_iainternal:icon_cancel").getBest(), itemMeta -> { + map.put(49, new ItemBuilder(this, OMCRegistry.CUSTOM_ITEMS.get("_iainternal:icon_cancel").getBest(), itemMeta -> { itemMeta.displayName(TranslationManager.translation("feature.city.mayor.menu.vote.button.close")); }).setCloseButton()); - map.put(48, new ItemBuilder(this, CustomItemRegistry.getByName("_iainternal:icon_back_orange").getBest(), itemMeta -> { + map.put(48, new ItemBuilder(this, OMCRegistry.CUSTOM_ITEMS.get("_iainternal:icon_back_orange").getBest(), itemMeta -> { itemMeta.displayName(TranslationManager.translation("feature.city.mayor.menu.vote.button.prev")); }).setPreviousPageButton()); - map.put(50, new ItemBuilder(this, CustomItemRegistry.getByName("_iainternal:icon_next_orange").getBest(), itemMeta -> { + map.put(50, new ItemBuilder(this, OMCRegistry.CUSTOM_ITEMS.get("_iainternal:icon_next_orange").getBest(), itemMeta -> { itemMeta.displayName(TranslationManager.translation("feature.city.mayor.menu.vote.button.next")); }).setNextPageButton()); diff --git a/src/main/java/fr/openmc/core/features/city/sub/mayor/menu/create/MayorCreateMenu.java b/src/main/java/fr/openmc/core/features/city/sub/mayor/menu/create/MayorCreateMenu.java index d8ed686a7..2ea5e09ed 100644 --- a/src/main/java/fr/openmc/core/features/city/sub/mayor/menu/create/MayorCreateMenu.java +++ b/src/main/java/fr/openmc/core/features/city/sub/mayor/menu/create/MayorCreateMenu.java @@ -4,12 +4,12 @@ import fr.openmc.api.menulib.Menu; import fr.openmc.api.menulib.utils.InventorySize; import fr.openmc.api.menulib.utils.ItemBuilder; +import fr.openmc.core.OMCRegistry; import fr.openmc.core.features.city.CityManager; import fr.openmc.core.features.city.menu.main.CityMenu; import fr.openmc.core.features.city.sub.mayor.managers.MayorManager; import fr.openmc.core.features.city.sub.mayor.menu.MayorElectionMenu; import fr.openmc.core.features.city.sub.mayor.perks.Perks; -import fr.openmc.core.registry.items.CustomItemRegistry; import fr.openmc.core.utils.text.messages.MessageType; import fr.openmc.core.utils.text.messages.MessagesManager; import fr.openmc.core.utils.text.messages.Prefix; @@ -229,11 +229,11 @@ public void onClose(InventoryCloseEvent event) { Component nameConfirm; List loreConfirm; if (canConfirmPerk) { - matConfirm = CustomItemRegistry.getByName("omc_menus:accept_btn").getBest().getType(); + matConfirm = OMCRegistry.CUSTOM_ITEMS.get("omc_menus:accept_btn").getBest().getType(); nameConfirm = TranslationManager.translation("feature.city.mayor.menu.create.confirm.name.ready").color(NamedTextColor.GREEN); loreConfirm = TranslationManager.translationLore("feature.city.mayor.menu.create.confirm.lore.ready"); } else { - matConfirm = CustomItemRegistry.getByName("omc_menus:refuse_btn").getBest().getType(); + matConfirm = OMCRegistry.CUSTOM_ITEMS.get("omc_menus:refuse_btn").getBest().getType(); nameConfirm = TranslationManager.translation("feature.city.mayor.menu.create.confirm.name.blocked").color(NamedTextColor.RED); loreConfirm = TranslationManager.translationLore("feature.city.mayor.menu.create.confirm.lore.blocked"); } diff --git a/src/main/java/fr/openmc/core/features/city/sub/mayor/menu/create/PerkChoiceMenu.java b/src/main/java/fr/openmc/core/features/city/sub/mayor/menu/create/PerkChoiceMenu.java index b6681e229..d4a076c6e 100644 --- a/src/main/java/fr/openmc/core/features/city/sub/mayor/menu/create/PerkChoiceMenu.java +++ b/src/main/java/fr/openmc/core/features/city/sub/mayor/menu/create/PerkChoiceMenu.java @@ -5,12 +5,12 @@ import fr.openmc.api.menulib.utils.InventorySize; import fr.openmc.api.menulib.utils.ItemBuilder; import fr.openmc.api.menulib.utils.StaticSlots; +import fr.openmc.core.OMCRegistry; import fr.openmc.core.features.city.City; import fr.openmc.core.features.city.CityManager; import fr.openmc.core.features.city.sub.mayor.perks.PerkType; import fr.openmc.core.features.city.sub.mayor.perks.Perks; import fr.openmc.core.features.city.sub.milestone.rewards.FeaturesRewards; -import fr.openmc.core.registry.items.CustomItemRegistry; import fr.openmc.core.utils.text.messages.MessageType; import fr.openmc.core.utils.text.messages.MessagesManager; import fr.openmc.core.utils.text.messages.Prefix; @@ -189,16 +189,16 @@ public List getItems() { @Override public Map getButtons() { Map map = new HashMap<>(); - map.put(49, new ItemBuilder(this, CustomItemRegistry.getByName("_iainternal:icon_cancel").getBest(), itemMeta -> { + map.put(49, new ItemBuilder(this, OMCRegistry.CUSTOM_ITEMS.get("_iainternal:icon_cancel").getBest(), itemMeta -> { itemMeta.displayName(TranslationManager.translation("feature.city.mayor.menu.perk_choice.button.back")); }).setOnClick(inventoryClickEvent -> { new MayorCreateMenu(getOwner(), perk1, perk2, perk3, type).open(); })); - map.put(48, new ItemBuilder(this, CustomItemRegistry.getByName("_iainternal:icon_back_orange").getBest(), itemMeta -> { + map.put(48, new ItemBuilder(this, OMCRegistry.CUSTOM_ITEMS.get("_iainternal:icon_back_orange").getBest(), itemMeta -> { itemMeta.displayName(TranslationManager.translation("feature.city.mayor.menu.perk_choice.button.prev")); }).setPreviousPageButton()); - map.put(50, new ItemBuilder(this, CustomItemRegistry.getByName("_iainternal:icon_next_orange").getBest(), itemMeta -> { + map.put(50, new ItemBuilder(this, OMCRegistry.CUSTOM_ITEMS.get("_iainternal:icon_next_orange").getBest(), itemMeta -> { itemMeta.displayName(TranslationManager.translation("feature.city.mayor.menu.perk_choice.button.next")); }).setNextPageButton()); return map; diff --git a/src/main/java/fr/openmc/core/features/city/sub/mayor/perks/Perks.java b/src/main/java/fr/openmc/core/features/city/sub/mayor/perks/Perks.java index da057e0e0..f77ff7689 100644 --- a/src/main/java/fr/openmc/core/features/city/sub/mayor/perks/Perks.java +++ b/src/main/java/fr/openmc/core/features/city/sub/mayor/perks/Perks.java @@ -1,7 +1,7 @@ package fr.openmc.core.features.city.sub.mayor.perks; +import fr.openmc.core.OMCRegistry; import fr.openmc.core.features.dream.registries.DreamItemRegistry; -import fr.openmc.core.registry.items.CustomItemRegistry; import io.papermc.paper.datacomponent.DataComponentType; import io.papermc.paper.datacomponent.DataComponentTypes; import lombok.Getter; @@ -83,7 +83,7 @@ public enum Perks { 0, "feature.city.mayor.perk.ayweniter.name", "feature.city.mayor.perk.ayweniter.lore", - CustomItemRegistry.getByName("omc_items:aywenite").getBest() + OMCRegistry.CUSTOM_ITEMS.get("omc_items:aywenite").getBest() ), GPS_TRACKER( 9, diff --git a/src/main/java/fr/openmc/core/features/city/sub/mayor/perks/basic/AyweniterPerk.java b/src/main/java/fr/openmc/core/features/city/sub/mayor/perks/basic/AyweniterPerk.java index 903dd034a..45c1a47ad 100644 --- a/src/main/java/fr/openmc/core/features/city/sub/mayor/perks/basic/AyweniterPerk.java +++ b/src/main/java/fr/openmc/core/features/city/sub/mayor/perks/basic/AyweniterPerk.java @@ -1,12 +1,12 @@ package fr.openmc.core.features.city.sub.mayor.perks.basic; +import fr.openmc.core.OMCRegistry; import fr.openmc.core.features.city.City; import fr.openmc.core.features.city.CityManager; import fr.openmc.core.features.city.sub.mayor.managers.MayorManager; import fr.openmc.core.features.city.sub.mayor.managers.PerkManager; import fr.openmc.core.features.city.sub.mayor.perks.Perks; import fr.openmc.core.features.dream.DreamUtils; -import fr.openmc.core.registry.items.CustomItemRegistry; import fr.openmc.core.utils.text.messages.MessageType; import fr.openmc.core.utils.text.messages.MessagesManager; import fr.openmc.core.utils.text.messages.Prefix; @@ -46,7 +46,7 @@ public void onBlockBreak(BlockBreakEvent event) { if (!PerkManager.hasPerk(playerCity.getMayor(), Perks.AYWENITER.getId())) return; if (block.getType() == Material.STONE) { - ItemStack ayweniteItem = CustomItemRegistry.getByName("omc_items:aywenite").getBest(); + ItemStack ayweniteItem = OMCRegistry.CUSTOM_ITEMS.get("omc_items:aywenite").getBest(); ayweniteItem.setAmount(2); player.getInventory().addItem(ayweniteItem); player.playSound(player.getEyeLocation(), Sound.BLOCK_AMETHYST_BLOCK_RESONATE, 10.0F, 0.6F); diff --git a/src/main/java/fr/openmc/core/features/city/sub/mayor/perks/event/IdyllicRain.java b/src/main/java/fr/openmc/core/features/city/sub/mayor/perks/event/IdyllicRain.java index f5ffdf8f7..35b579567 100644 --- a/src/main/java/fr/openmc/core/features/city/sub/mayor/perks/event/IdyllicRain.java +++ b/src/main/java/fr/openmc/core/features/city/sub/mayor/perks/event/IdyllicRain.java @@ -1,9 +1,9 @@ package fr.openmc.core.features.city.sub.mayor.perks.event; import fr.openmc.core.OMCPlugin; +import fr.openmc.core.OMCRegistry; import fr.openmc.core.features.city.City; import fr.openmc.core.features.city.CityManager; -import fr.openmc.core.registry.items.CustomItemRegistry; import fr.openmc.core.utils.world.chunk.ChunkPos; import org.bukkit.Bukkit; import org.bukkit.Location; @@ -61,7 +61,7 @@ public void run() { Location dropLoc = new Location(world, x + 0.5, y, z + 0.5); - ItemStack aywenite = CustomItemRegistry.getByName("omc_items:aywenite").getBest(); + ItemStack aywenite = OMCRegistry.CUSTOM_ITEMS.get("omc_items:aywenite").getBest(); ItemMeta meta = aywenite.getItemMeta(); meta.getPersistentDataContainer().set(cityAyweniteKey, PersistentDataType.STRING, city.getUniqueId().toString()); aywenite.setItemMeta(meta); @@ -98,7 +98,7 @@ public void onItemPickup(EntityPickupItemEvent event) { event.setCancelled(true); - ItemStack cleanAywenite = CustomItemRegistry.getByName("omc_items:aywenite").getBest(); + ItemStack cleanAywenite = OMCRegistry.CUSTOM_ITEMS.get("omc_items:aywenite").getBest(); cleanAywenite.setAmount(item.getAmount()); event.getItem().remove(); diff --git a/src/main/java/fr/openmc/core/features/city/sub/mayor/perks/event/ImpotCollection.java b/src/main/java/fr/openmc/core/features/city/sub/mayor/perks/event/ImpotCollection.java index 710635509..eb6150ad5 100644 --- a/src/main/java/fr/openmc/core/features/city/sub/mayor/perks/event/ImpotCollection.java +++ b/src/main/java/fr/openmc/core/features/city/sub/mayor/perks/event/ImpotCollection.java @@ -1,10 +1,10 @@ package fr.openmc.core.features.city.sub.mayor.perks.event; import fr.openmc.core.OMCPlugin; +import fr.openmc.core.OMCRegistry; import fr.openmc.core.features.city.City; import fr.openmc.core.features.economy.BankManager; import fr.openmc.core.features.economy.EconomyManager; -import fr.openmc.core.registry.items.CustomItemRegistry; import fr.openmc.core.utils.text.messages.MessageType; import fr.openmc.core.utils.text.messages.MessagesManager; import fr.openmc.core.utils.text.messages.Prefix; @@ -57,10 +57,10 @@ public static void spawnZombies(Player player, City city) { EntityEquipment equipment = zombie.getEquipment(); if (equipment != null) { - equipment.setHelmet(CustomItemRegistry.getByName("omc_items:suit_helmet").getBest()); - equipment.setChestplate(CustomItemRegistry.getByName("omc_items:suit_chestplate").getBest()); - equipment.setLeggings(CustomItemRegistry.getByName("omc_items:suit_leggings").getBest()); - equipment.setBoots(CustomItemRegistry.getByName("omc_items:suit_boots").getBest()); + equipment.setHelmet(OMCRegistry.CUSTOM_ITEMS.get("omc_items:suit_helmet").getBest()); + equipment.setChestplate(OMCRegistry.CUSTOM_ITEMS.get("omc_items:suit_chestplate").getBest()); + equipment.setLeggings(OMCRegistry.CUSTOM_ITEMS.get("omc_items:suit_leggings").getBest()); + equipment.setBoots(OMCRegistry.CUSTOM_ITEMS.get("omc_items:suit_boots").getBest()); } zombie.setShouldBurnInDay(false); diff --git a/src/main/java/fr/openmc/core/features/city/sub/mayor/perks/event/MineralRushPerk.java b/src/main/java/fr/openmc/core/features/city/sub/mayor/perks/event/MineralRushPerk.java index d6a27b39b..6f8e6fbb3 100644 --- a/src/main/java/fr/openmc/core/features/city/sub/mayor/perks/event/MineralRushPerk.java +++ b/src/main/java/fr/openmc/core/features/city/sub/mayor/perks/event/MineralRushPerk.java @@ -3,12 +3,12 @@ import dev.lone.itemsadder.api.Events.CustomBlockBreakEvent; import fr.openmc.api.chronometer.Chronometer; import fr.openmc.api.cooldown.DynamicCooldownManager; +import fr.openmc.core.OMCRegistry; import fr.openmc.core.features.city.City; import fr.openmc.core.features.city.CityManager; import fr.openmc.core.features.city.sub.mayor.managers.MayorManager; import fr.openmc.core.features.city.sub.mayor.managers.PerkManager; import fr.openmc.core.features.city.sub.mayor.perks.Perks; -import fr.openmc.core.registry.items.CustomItemRegistry; import fr.openmc.core.utils.bukkit.MaterialUtils; import fr.openmc.core.utils.text.DateUtils; import fr.openmc.core.utils.text.messages.MessageType; @@ -119,6 +119,6 @@ public void onAyweniteBreak(CustomBlockBreakEvent event) { Block block = event.getBlock(); - block.getWorld().dropItemNaturally(block.getLocation(), CustomItemRegistry.getByName("omc_items:aywenite").getBest()); + block.getWorld().dropItemNaturally(block.getLocation(), OMCRegistry.CUSTOM_ITEMS.get("omc_items:aywenite").getBest()); } } diff --git a/src/main/java/fr/openmc/core/features/city/sub/mayor/perks/readme.md b/src/main/java/fr/openmc/core/features/city/sub/mayor/perks/readme.md index 1077e7ee5..9c0f456c6 100644 --- a/src/main/java/fr/openmc/core/features/city/sub/mayor/perks/readme.md +++ b/src/main/java/fr/openmc/core/features/city/sub/mayor/perks/readme.md @@ -35,7 +35,7 @@ Il devra être un int, nom, un string, description, une liste de components itemstack, un itemstack : - ItemStack.of(Material) -- CustomItemRegistry.getByName("omc_items:aywenite").getBest(), un CustomItem d'ItemAdder +- OMCRegistry.CUSTOM_ITEMS.get("omc_items:aywenite").getBest(), un CustomItem d'ItemAdder type de perk, PerkEvent donc soit un BASIC et EVENT Exemple d'une Réforme basique : @@ -92,7 +92,7 @@ public class AyweniterPerk implements Listener { if (block.getType() == Material.STONE) { if (random.nextDouble() < DROP_CHANCE) { - ItemStack ayweniteItem = CustomItemRegistry.getByName("omc_items:aywenite").getBest(); + ItemStack ayweniteItem = OMCRegistry.CUSTOM_ITEMS.get("omc_items:aywenite").getBest(); ayweniteItem.setAmount(2); player.getInventory().addItem(ayweniteItem); player.playSound(player.getEyeLocation(), Sound.BLOCK_AMETHYST_BLOCK_RESONATE, 10.0F, 0.6F); 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 5e6e11c51..b825bfcb2 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 @@ -1,6 +1,7 @@ package fr.openmc.core.features.city.sub.milestone; import fr.openmc.api.cooldown.DynamicCooldownManager; +import fr.openmc.core.OMCRegistry; import fr.openmc.core.features.city.City; import fr.openmc.core.features.city.CityManager; import fr.openmc.core.features.city.sub.mayor.managers.NPCManager; @@ -13,7 +14,6 @@ import fr.openmc.core.features.city.sub.statistics.CityStatisticsManager; import fr.openmc.core.features.city.sub.war.WarManager; import fr.openmc.core.features.economy.EconomyManager; -import fr.openmc.core.registry.items.CustomItemRegistry; import fr.openmc.core.utils.text.messages.TranslationManager; import lombok.Getter; import net.kyori.adventure.text.Component; @@ -73,7 +73,7 @@ public enum CityLevels { ), new TemplateRequirement( city -> city.getLaw().getWarp() != null, - city -> CustomItemRegistry.getByName("omc_items:warp_stick").getBest(), + city -> OMCRegistry.CUSTOM_ITEMS.get("omc_items:warp_stick").getBest(), (city, ignore) -> TranslationManager.translation("feature.city.levels.requirements.setwarp") ), new ItemDepositRequirement(Material.GOLD_INGOT, 128) @@ -217,16 +217,16 @@ public enum CityLevels { ); } ), - new ItemDepositRequirement(CustomItemRegistry.getByName("omc_items:aywenite").getBest(), 128), + new ItemDepositRequirement(OMCRegistry.CUSTOM_ITEMS.get("omc_items:aywenite").getBest(), 128), new ItemDepositRequirement(Material.GRAY_WOOL, 32), new ItemDepositRequirement(Material.GLASS, 128), - new ItemDepositRequirement(CustomItemRegistry.getByName("omc_foods:courgette").getBest(), 8), + new ItemDepositRequirement(OMCRegistry.CUSTOM_ITEMS.get("omc_foods:courgette").getBest(), 8), new EventTemplateRequirement( (city, scope) -> Objects.requireNonNull(CityStatisticsManager .getOrCreateStat(city.getUniqueId(), scope)) .asInt() >= 1, - city -> CustomItemRegistry.getByName("omc_blocks:urne").getBest(), + city -> OMCRegistry.CUSTOM_ITEMS.get("omc_blocks:urne").getBest(), (city, level, scope) -> TranslationManager.translation("feature.city.levels.requirements.craft_urne"), "craft_urne", @@ -234,7 +234,7 @@ public enum CityLevels { (event, scope) -> { CraftItemEvent eventCraft = (CraftItemEvent) event; ItemStack item = eventCraft.getCurrentItem(); - if (item == null || !item.isSimilar(CustomItemRegistry.getByName("omc_blocks:urne").getBest())) + if (item == null || !item.isSimilar(OMCRegistry.CUSTOM_ITEMS.get("omc_blocks:urne").getBest())) return; Player player = (Player) eventCraft.getWhoClicked(); @@ -264,7 +264,7 @@ public enum CityLevels { List.of( new TemplateRequirement( city -> NPCManager.hasNPCS(city.getUniqueId()), - city -> CustomItemRegistry.getByName("omc_blocks:urne").getBest(), + city -> OMCRegistry.CUSTOM_ITEMS.get("omc_blocks:urne").getBest(), (city, level) -> TranslationManager.translation("feature.city.levels.requirements.place_urne") ), @@ -315,7 +315,7 @@ public enum CityLevels { ); } ), - new ItemDepositRequirement(CustomItemRegistry.getByName("omc_foods:the_mixture").getBest(), 32) + new ItemDepositRequirement(OMCRegistry.CUSTOM_ITEMS.get("omc_foods:the_mixture").getBest(), 32) ), List.of( FeaturesRewards.LEVEL_5, @@ -388,7 +388,7 @@ public enum CityLevels { new ItemDepositRequirement(Material.STONE_BRICKS, 400), new ItemDepositRequirement(Material.BLACK_CONCRETE, 184), new ItemDepositRequirement(Material.WHITE_CONCRETE, 64), - new ItemDepositRequirement(CustomItemRegistry.getByName("omc_foods:courgette").getBest(), 98), + new ItemDepositRequirement(OMCRegistry.CUSTOM_ITEMS.get("omc_foods:courgette").getBest(), 98), new ItemDepositRequirement(Material.DIAMOND, 128) ), List.of( @@ -458,7 +458,7 @@ public enum CityLevels { Component.text(6) ) ), - new ItemDepositRequirement(CustomItemRegistry.getByName("omc_items:aywenite").getBest(), 400), + new ItemDepositRequirement(OMCRegistry.CUSTOM_ITEMS.get("omc_items:aywenite").getBest(), 400), new ItemDepositRequirement(Material.DIAMOND_SWORD, 10), new ItemDepositRequirement(Material.TNT, 64), new ItemDepositRequirement(Material.FLINT_AND_STEEL, 16), @@ -630,7 +630,7 @@ public enum CityLevels { new ItemDepositRequirement(Material.DIAMOND, 300), new ItemDepositRequirement(Material.CYAN_CONCRETE, 200), new ItemDepositRequirement(Material.DRIED_GHAST, 5), - new ItemDepositRequirement(CustomItemRegistry.getByName("omc_foods:kebab").getBest(), 128) + new ItemDepositRequirement(OMCRegistry.CUSTOM_ITEMS.get("omc_foods:kebab").getBest(), 128) ), List.of( FeaturesRewards.LEVEL_9, @@ -704,8 +704,8 @@ public enum CityLevels { Component.text(9) ) ), - new ItemDepositRequirement(CustomItemRegistry.getByName("omc_blocks:aywenite_block").getBest(), 64), - new ItemDepositRequirement(CustomItemRegistry.getByName("omc_contest:contest_shell").getBest(), 128), + new ItemDepositRequirement(OMCRegistry.CUSTOM_ITEMS.get("omc_blocks:aywenite_block").getBest(), 64), + new ItemDepositRequirement(OMCRegistry.CUSTOM_ITEMS.get("omc_contest:contest_shell").getBest(), 128), new ItemDepositRequirement(Material.SCULK, 1028) ), List.of( diff --git a/src/main/java/fr/openmc/core/features/city/sub/milestone/menu/LevelMilestoneMenu.java b/src/main/java/fr/openmc/core/features/city/sub/milestone/menu/LevelMilestoneMenu.java index 0d3f6b71a..489c26c13 100644 --- a/src/main/java/fr/openmc/core/features/city/sub/milestone/menu/LevelMilestoneMenu.java +++ b/src/main/java/fr/openmc/core/features/city/sub/milestone/menu/LevelMilestoneMenu.java @@ -3,12 +3,12 @@ import fr.openmc.api.menulib.PaginatedMenu; import fr.openmc.api.menulib.utils.InventorySize; import fr.openmc.api.menulib.utils.ItemBuilder; +import fr.openmc.core.OMCRegistry; import fr.openmc.core.features.city.City; import fr.openmc.core.features.city.sub.milestone.CityLevels; import fr.openmc.core.features.city.sub.milestone.CityRequirement; import fr.openmc.core.features.city.sub.milestone.CityRewards; import fr.openmc.core.features.city.sub.milestone.requirements.ItemDepositRequirement; -import fr.openmc.core.registry.items.CustomItemRegistry; import fr.openmc.core.utils.text.messages.TranslationManager; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.NamedTextColor; @@ -132,10 +132,10 @@ public Map getButtons() { buttons.put(49, new ItemBuilder(this, Material.BARRIER, meta -> meta.displayName(TranslationManager.translation("messages.menus.close"))).setCloseButton()); - buttons.put(48, new ItemBuilder(this, CustomItemRegistry.getByName("_iainternal:icon_back_orange").getBest(), itemMeta -> { + buttons.put(48, new ItemBuilder(this, OMCRegistry.CUSTOM_ITEMS.get("_iainternal:icon_back_orange").getBest(), itemMeta -> { itemMeta.displayName(TranslationManager.translation("messages.menus.previous_page")); }).setPreviousPageButton()); - buttons.put(50, new ItemBuilder(this, CustomItemRegistry.getByName("_iainternal:icon_next_orange").getBest(), itemMeta -> { + buttons.put(50, new ItemBuilder(this, OMCRegistry.CUSTOM_ITEMS.get("_iainternal:icon_next_orange").getBest(), itemMeta -> { itemMeta.displayName(TranslationManager.translation("messages.menus.next_page")); }).setNextPageButton()); diff --git a/src/main/java/fr/openmc/core/features/city/sub/rank/menus/CityRankDetailsMenu.java b/src/main/java/fr/openmc/core/features/city/sub/rank/menus/CityRankDetailsMenu.java index d207bb633..82a90153c 100644 --- a/src/main/java/fr/openmc/core/features/city/sub/rank/menus/CityRankDetailsMenu.java +++ b/src/main/java/fr/openmc/core/features/city/sub/rank/menus/CityRankDetailsMenu.java @@ -3,6 +3,7 @@ import fr.openmc.api.menulib.Menu; import fr.openmc.api.menulib.utils.InventorySize; import fr.openmc.api.menulib.utils.ItemBuilder; +import fr.openmc.core.OMCRegistry; import fr.openmc.core.features.city.City; import fr.openmc.core.features.city.CityPermission; import fr.openmc.core.features.city.models.DBCityRank; @@ -10,7 +11,6 @@ import fr.openmc.core.features.city.sub.rank.CityRankAction; import fr.openmc.core.features.city.sub.rank.CityRankCondition; import fr.openmc.core.features.city.sub.rank.CityRankManager; -import fr.openmc.core.registry.items.CustomItemRegistry; import fr.openmc.core.utils.bukkit.ItemUtils; import fr.openmc.core.utils.text.messages.MessageType; import fr.openmc.core.utils.text.messages.MessagesManager; @@ -150,13 +150,13 @@ private Map createRank() { )); }).setOnClick(inventoryClickEvent -> new CityRankPermsMenu(getOwner(), oldRank, newRank, true, 0).open())); - map.put(18, new ItemBuilder(this, CustomItemRegistry.getByName("omc_menus:refuse_btn").getBest(), itemMeta -> { + map.put(18, new ItemBuilder(this, OMCRegistry.CUSTOM_ITEMS.get("omc_menus:refuse_btn").getBest(), itemMeta -> { itemMeta.displayName(TranslationManager.translation("feature.city.rank.menu.details.cancel_create.title")); itemMeta.lore(TranslationManager.translationLore("feature.city.rank.menu.details.cancel_create.lore")); }).setOnClick(inventoryClickEvent -> getOwner().closeInventory())); if (canManageRanks) { - map.put(26, new ItemBuilder(this, CustomItemRegistry.getByName("omc_menus:accept_btn").getBest(), itemMeta -> { + map.put(26, new ItemBuilder(this, OMCRegistry.CUSTOM_ITEMS.get("omc_menus:accept_btn").getBest(), itemMeta -> { itemMeta.displayName(TranslationManager.translation("feature.city.rank.menu.details.create.title")); itemMeta.lore(TranslationManager.translationLore("feature.city.rank.menu.details.create.lore")); }).setOnClick(inventoryClickEvent -> { @@ -284,7 +284,7 @@ private Map createRank() { else new CityRankPermsMenu(getOwner(), oldRank, newRank, true, 0).open(); })); - map.put(18, new ItemBuilder(this, CustomItemRegistry.getByName("omc_menus:refuse_btn").getBest(), itemMeta -> { + map.put(18, new ItemBuilder(this, OMCRegistry.CUSTOM_ITEMS.get("omc_menus:refuse_btn").getBest(), itemMeta -> { itemMeta.displayName(TranslationManager.translation("feature.city.rank.menu.details.cancel_edit.title")); itemMeta.lore(TranslationManager.translationLore("feature.city.rank.menu.details.cancel_edit.lore")); }).setOnClick(inventoryClickEvent -> { @@ -293,14 +293,14 @@ private Map createRank() { })); if (canManageRanks) { - map.put(22, new ItemBuilder(this, CustomItemRegistry.getByName("omc_menus:minus_btn").getBest(), itemMeta -> { + map.put(22, new ItemBuilder(this, OMCRegistry.CUSTOM_ITEMS.get("omc_menus:minus_btn").getBest(), itemMeta -> { itemMeta.displayName(TranslationManager.translation("feature.city.rank.menu.details.delete.title")); itemMeta.lore(TranslationManager.translationLore("feature.city.rank.menu.details.delete.lore")); }).setOnClick(inventoryClickEvent -> CityRankAction.deleteRank(getOwner(), oldRank.getName()) )); - map.put(26, new ItemBuilder(this, CustomItemRegistry.getByName("omc_menus:accept_btn").getBest(), itemMeta -> { + map.put(26, new ItemBuilder(this, OMCRegistry.CUSTOM_ITEMS.get("omc_menus:accept_btn").getBest(), itemMeta -> { itemMeta.displayName(TranslationManager.translation("feature.city.rank.menu.details.save.title")); itemMeta.lore(TranslationManager.translationLore("feature.city.rank.menu.details.save.lore")); }).setOnClick(inventoryClickEvent -> { diff --git a/src/main/java/fr/openmc/core/features/city/sub/rank/menus/CityRankIconMenu.java b/src/main/java/fr/openmc/core/features/city/sub/rank/menus/CityRankIconMenu.java index 2a48ee868..5389aaedd 100644 --- a/src/main/java/fr/openmc/core/features/city/sub/rank/menus/CityRankIconMenu.java +++ b/src/main/java/fr/openmc/core/features/city/sub/rank/menus/CityRankIconMenu.java @@ -6,9 +6,9 @@ import fr.openmc.api.menulib.utils.InventorySize; import fr.openmc.api.menulib.utils.ItemBuilder; import fr.openmc.api.menulib.utils.StaticSlots; +import fr.openmc.core.OMCRegistry; import fr.openmc.core.features.city.City; import fr.openmc.core.features.city.models.DBCityRank; -import fr.openmc.core.registry.items.CustomItemRegistry; import fr.openmc.core.utils.bukkit.ItemUtils; import fr.openmc.core.utils.text.messages.TranslationManager; import net.kyori.adventure.text.Component; @@ -115,7 +115,7 @@ public Map getButtons() { new CityRankIconMenu(getOwner(), city, page + 1, oldRank, newRank, filter).open(); })); - map.put(49, new ItemBuilder(this, CustomItemRegistry.getByName("_iainternal:icon_search").getBest(), itemMeta -> { + map.put(49, new ItemBuilder(this, OMCRegistry.CUSTOM_ITEMS.get("_iainternal:icon_search").getBest(), itemMeta -> { itemMeta.displayName(TranslationManager.translation("feature.city.rank.menu.icon.search.title")); itemMeta.lore(TranslationManager.translationLore("feature.city.rank.menu.icon.search.lore")); }).setOnClick(event -> { diff --git a/src/main/java/fr/openmc/core/features/city/sub/rank/menus/CityRankPermsMenu.java b/src/main/java/fr/openmc/core/features/city/sub/rank/menus/CityRankPermsMenu.java index 4bab3e7b3..ef7059b5e 100644 --- a/src/main/java/fr/openmc/core/features/city/sub/rank/menus/CityRankPermsMenu.java +++ b/src/main/java/fr/openmc/core/features/city/sub/rank/menus/CityRankPermsMenu.java @@ -5,12 +5,12 @@ import fr.openmc.api.menulib.utils.ItemBuilder; import fr.openmc.api.menulib.utils.ItemUtils; import fr.openmc.api.menulib.utils.StaticSlots; +import fr.openmc.core.OMCRegistry; import fr.openmc.core.features.city.City; import fr.openmc.core.features.city.CityManager; import fr.openmc.core.features.city.CityPermission; import fr.openmc.core.features.city.models.DBCityRank; import fr.openmc.core.features.city.sub.rank.CityRankCommands; -import fr.openmc.core.registry.items.CustomItemRegistry; import fr.openmc.core.utils.text.messages.MessageType; import fr.openmc.core.utils.text.messages.MessagesManager; import fr.openmc.core.utils.text.messages.Prefix; @@ -98,19 +98,19 @@ public List getItems() { public Map getButtons() { Map map = new HashMap<>(); - map.put(45, new ItemBuilder(this, CustomItemRegistry.getByName("_iainternal:icon_cancel").getBest(), itemMeta -> { + map.put(45, new ItemBuilder(this, OMCRegistry.CUSTOM_ITEMS.get("_iainternal:icon_cancel").getBest(), itemMeta -> { itemMeta.displayName(TranslationManager.translation("messages.menus.back")); itemMeta.lore(List.of(TranslationManager.translation("messages.menus.back_lore"))); }).setOnClick(inventoryClickEvent -> new CityRankDetailsMenu(getOwner(), city, oldRank, newRank).open())); if (hasPreviousPage()) { - map.put(48, new ItemBuilder(this, CustomItemRegistry.getByName("_iainternal:icon_back_orange").getBest(), itemMeta -> { + map.put(48, new ItemBuilder(this, OMCRegistry.CUSTOM_ITEMS.get("_iainternal:icon_back_orange").getBest(), itemMeta -> { itemMeta.displayName(TranslationManager.translation("messages.menus.previous_page")); itemMeta.lore(List.of(TranslationManager.translation("messages.menus.previous_page_lore"))); }).setOnClick(inventoryClickEvent -> new CityRankPermsMenu(getOwner(), oldRank, newRank, canEdit, page - 1).open())); } if (hasNextPage()) { - map.put(50, new ItemBuilder(this, CustomItemRegistry.getByName("_iainternal:icon_next_orange").getBest(), itemMeta -> { + map.put(50, new ItemBuilder(this, OMCRegistry.CUSTOM_ITEMS.get("_iainternal:icon_next_orange").getBest(), itemMeta -> { itemMeta.displayName(TranslationManager.translation("messages.menus.next_page")); itemMeta.lore(List.of(TranslationManager.translation("messages.menus.next_page_lore"))); }).setOnClick(inventoryClickEvent -> new CityRankPermsMenu(getOwner(), oldRank, newRank, canEdit, page + 1).open())); diff --git a/src/main/java/fr/openmc/core/features/city/sub/rank/menus/CityRanksMenu.java b/src/main/java/fr/openmc/core/features/city/sub/rank/menus/CityRanksMenu.java index e2fabd60d..70e90831c 100644 --- a/src/main/java/fr/openmc/core/features/city/sub/rank/menus/CityRanksMenu.java +++ b/src/main/java/fr/openmc/core/features/city/sub/rank/menus/CityRanksMenu.java @@ -3,13 +3,13 @@ import fr.openmc.api.menulib.Menu; import fr.openmc.api.menulib.utils.InventorySize; import fr.openmc.api.menulib.utils.ItemBuilder; +import fr.openmc.core.OMCRegistry; import fr.openmc.core.features.city.City; import fr.openmc.core.features.city.CityPermission; import fr.openmc.core.features.city.menu.main.CityMenu; import fr.openmc.core.features.city.models.DBCityRank; import fr.openmc.core.features.city.sub.rank.CityRankAction; import fr.openmc.core.features.city.sub.rank.CityRankCondition; -import fr.openmc.core.registry.items.CustomItemRegistry; import fr.openmc.core.utils.text.messages.TranslationManager; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.NamedTextColor; @@ -127,7 +127,7 @@ public void onClose(InventoryCloseEvent event) { if (canManageRanks) { List loreCreateRank = TranslationManager.translationLore("feature.city.rank.menu.list.create.lore"); - map.put(26, new ItemBuilder(this, CustomItemRegistry.getByName("omc_menus:plus_btn").getBest(), + map.put(26, new ItemBuilder(this, OMCRegistry.CUSTOM_ITEMS.get("omc_menus:plus_btn").getBest(), itemMeta -> { itemMeta.displayName(TranslationManager.translation("feature.city.rank.menu.list.create.title")); itemMeta.lore(loreCreateRank); 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 38960890b..1de4f3976 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 @@ -4,6 +4,7 @@ import fr.openmc.api.menulib.utils.InventorySize; import fr.openmc.api.menulib.utils.ItemBuilder; import fr.openmc.api.menulib.utils.StaticSlots; +import fr.openmc.core.OMCRegistry; import fr.openmc.core.features.city.City; import fr.openmc.core.features.city.CityManager; import fr.openmc.core.features.city.CityPermission; @@ -17,7 +18,6 @@ import fr.openmc.core.features.city.sub.war.actions.WarActions; import fr.openmc.core.features.city.sub.war.menu.MoreInfoMenu; import fr.openmc.core.features.economy.EconomyManager; -import fr.openmc.core.registry.items.CustomItemRegistry; import fr.openmc.core.utils.bukkit.SkullUtils; import fr.openmc.core.utils.cache.PlayerNameCache; import fr.openmc.core.utils.text.messages.TranslationManager; @@ -164,9 +164,9 @@ public List getTakableSlot() { @Override public Map getButtons() { Map map = new HashMap<>(); - map.put(49, new ItemBuilder(this, Objects.requireNonNull(CustomItemRegistry.getByName("_iainternal:icon_cancel")).getBest(), itemMeta -> itemMeta.displayName(TranslationManager.translation("messages.menus.close"))).setCloseButton()); - map.put(48, new ItemBuilder(this, Objects.requireNonNull(CustomItemRegistry.getByName("_iainternal:icon_back_orange")).getBest(), itemMeta -> itemMeta.displayName(TranslationManager.translation("messages.menus.previous_page"))).setPreviousPageButton()); - map.put(50, new ItemBuilder(this, Objects.requireNonNull(CustomItemRegistry.getByName("_iainternal:icon_next_orange")).getBest(), itemMeta -> itemMeta.displayName(TranslationManager.translation("messages.menus.next_page"))).setNextPageButton()); + map.put(49, new ItemBuilder(this, Objects.requireNonNull(OMCRegistry.CUSTOM_ITEMS.get("_iainternal:icon_cancel")).getBest(), itemMeta -> itemMeta.displayName(TranslationManager.translation("messages.menus.close"))).setCloseButton()); + map.put(48, new ItemBuilder(this, Objects.requireNonNull(OMCRegistry.CUSTOM_ITEMS.get("_iainternal:icon_back_orange")).getBest(), itemMeta -> itemMeta.displayName(TranslationManager.translation("messages.menus.previous_page"))).setPreviousPageButton()); + map.put(50, new ItemBuilder(this, Objects.requireNonNull(OMCRegistry.CUSTOM_ITEMS.get("_iainternal:icon_next_orange")).getBest(), itemMeta -> itemMeta.displayName(TranslationManager.translation("messages.menus.next_page"))).setNextPageButton()); List loreInfo = TranslationManager.translationLore("feature.city.war.menu.more_info.lore"); diff --git a/src/main/java/fr/openmc/core/features/city/sub/war/menu/main/WarPlayerListMenu.java b/src/main/java/fr/openmc/core/features/city/sub/war/menu/main/WarPlayerListMenu.java index 25da17d01..c842ddfdf 100644 --- a/src/main/java/fr/openmc/core/features/city/sub/war/menu/main/WarPlayerListMenu.java +++ b/src/main/java/fr/openmc/core/features/city/sub/war/menu/main/WarPlayerListMenu.java @@ -4,10 +4,10 @@ import fr.openmc.api.menulib.utils.InventorySize; import fr.openmc.api.menulib.utils.ItemBuilder; import fr.openmc.api.menulib.utils.StaticSlots; +import fr.openmc.core.OMCRegistry; import fr.openmc.core.features.city.City; import fr.openmc.core.features.city.CityPermission; import fr.openmc.core.features.city.sub.mayor.managers.MayorManager; -import fr.openmc.core.registry.items.CustomItemRegistry; import fr.openmc.core.utils.bukkit.SkullUtils; import fr.openmc.core.utils.cache.CacheOfflinePlayer; import fr.openmc.core.utils.text.messages.TranslationManager; @@ -100,9 +100,9 @@ public Map getButtons() { itemMeta.itemName(TranslationManager.translation("messages.menus.back")); itemMeta.lore(TranslationManager.translationLore("feature.city.war.menu.players.back_lore")); }, true)); - map.put(49, new ItemBuilder(this, CustomItemRegistry.getByName("_iainternal:icon_cancel").getBest(), itemMeta -> itemMeta.displayName(TranslationManager.translation("messages.menus.close"))).setCloseButton()); - map.put(48, new ItemBuilder(this, CustomItemRegistry.getByName("_iainternal:icon_back_orange").getBest(), itemMeta -> itemMeta.displayName(TranslationManager.translation("messages.menus.previous_page"))).setPreviousPageButton()); - map.put(50, new ItemBuilder(this, CustomItemRegistry.getByName("_iainternal:icon_next_orange").getBest(), itemMeta -> itemMeta.displayName(TranslationManager.translation("messages.menus.next_page"))).setNextPageButton()); + map.put(49, new ItemBuilder(this, OMCRegistry.CUSTOM_ITEMS.get("_iainternal:icon_cancel").getBest(), itemMeta -> itemMeta.displayName(TranslationManager.translation("messages.menus.close"))).setCloseButton()); + map.put(48, new ItemBuilder(this, OMCRegistry.CUSTOM_ITEMS.get("_iainternal:icon_back_orange").getBest(), itemMeta -> itemMeta.displayName(TranslationManager.translation("messages.menus.previous_page"))).setPreviousPageButton()); + map.put(50, new ItemBuilder(this, OMCRegistry.CUSTOM_ITEMS.get("_iainternal:icon_next_orange").getBest(), itemMeta -> itemMeta.displayName(TranslationManager.translation("messages.menus.next_page"))).setNextPageButton()); return map; } diff --git a/src/main/java/fr/openmc/core/features/city/sub/war/menu/selection/WarChooseParticipantsMenu.java b/src/main/java/fr/openmc/core/features/city/sub/war/menu/selection/WarChooseParticipantsMenu.java index 2f5b35299..482ff61b2 100644 --- a/src/main/java/fr/openmc/core/features/city/sub/war/menu/selection/WarChooseParticipantsMenu.java +++ b/src/main/java/fr/openmc/core/features/city/sub/war/menu/selection/WarChooseParticipantsMenu.java @@ -4,11 +4,11 @@ import fr.openmc.api.menulib.utils.InventorySize; import fr.openmc.api.menulib.utils.ItemBuilder; import fr.openmc.api.menulib.utils.StaticSlots; +import fr.openmc.core.OMCRegistry; import fr.openmc.core.features.city.City; import fr.openmc.core.features.city.CityPermission; import fr.openmc.core.features.city.sub.mayor.managers.MayorManager; import fr.openmc.core.features.city.sub.war.actions.WarActions; -import fr.openmc.core.registry.items.CustomItemRegistry; import fr.openmc.core.utils.bukkit.SkullUtils; import fr.openmc.core.utils.cache.CacheOfflinePlayer; import fr.openmc.core.utils.text.messages.MessageType; @@ -137,15 +137,15 @@ public Map getButtons() { Map map = new HashMap<>(); Player player = getOwner(); - map.put(48, new ItemBuilder(this, CustomItemRegistry.getByName("_iainternal:icon_back_orange").getBest(), meta -> { + map.put(48, new ItemBuilder(this, OMCRegistry.CUSTOM_ITEMS.get("_iainternal:icon_back_orange").getBest(), meta -> { meta.displayName(TranslationManager.translation("messages.menus.previous_page")); }).setPreviousPageButton()); - map.put(49, new ItemBuilder(this, CustomItemRegistry.getByName("_iainternal:icon_cancel").getBest(), meta -> { + map.put(49, new ItemBuilder(this, OMCRegistry.CUSTOM_ITEMS.get("_iainternal:icon_cancel").getBest(), meta -> { meta.displayName(TranslationManager.translation("messages.menus.close")); }).setCloseButton()); - map.put(50, new ItemBuilder(this, CustomItemRegistry.getByName("_iainternal:icon_next_orange").getBest(), meta -> { + map.put(50, new ItemBuilder(this, OMCRegistry.CUSTOM_ITEMS.get("_iainternal:icon_next_orange").getBest(), meta -> { meta.displayName(TranslationManager.translation("messages.menus.next_page")); }).setNextPageButton()); diff --git a/src/main/java/fr/openmc/core/features/city/sub/war/menu/selection/WarChooseSizeMenu.java b/src/main/java/fr/openmc/core/features/city/sub/war/menu/selection/WarChooseSizeMenu.java index 85b10b497..6de68094d 100644 --- a/src/main/java/fr/openmc/core/features/city/sub/war/menu/selection/WarChooseSizeMenu.java +++ b/src/main/java/fr/openmc/core/features/city/sub/war/menu/selection/WarChooseSizeMenu.java @@ -4,10 +4,10 @@ import fr.openmc.api.menulib.utils.InventorySize; import fr.openmc.api.menulib.utils.ItemBuilder; import fr.openmc.api.menulib.utils.StaticSlots; +import fr.openmc.core.OMCRegistry; import fr.openmc.core.features.city.City; import fr.openmc.core.features.city.sub.war.actions.WarActions; import fr.openmc.core.features.city.sub.war.menu.MoreInfoMenu; -import fr.openmc.core.registry.items.CustomItemRegistry; import fr.openmc.core.utils.text.messages.TranslationManager; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.NamedTextColor; @@ -86,9 +86,9 @@ public List getTakableSlot() { @Override public Map getButtons() { Map map = new HashMap<>(); - map.put(49, new ItemBuilder(this, Objects.requireNonNull(CustomItemRegistry.getByName("_iainternal:icon_cancel")).getBest(), itemMeta -> itemMeta.displayName(TranslationManager.translation("messages.menus.close"))).setCloseButton()); - map.put(48, new ItemBuilder(this, Objects.requireNonNull(CustomItemRegistry.getByName("_iainternal:icon_back_orange")).getBest(), itemMeta -> itemMeta.displayName(TranslationManager.translation("messages.menus.previous_page"))).setPreviousPageButton()); - map.put(50, new ItemBuilder(this, Objects.requireNonNull(CustomItemRegistry.getByName("_iainternal:icon_next_orange")).getBest(), itemMeta -> itemMeta.displayName(TranslationManager.translation("messages.menus.next_page"))).setNextPageButton()); + map.put(49, new ItemBuilder(this, Objects.requireNonNull(OMCRegistry.CUSTOM_ITEMS.get("_iainternal:icon_cancel")).getBest(), itemMeta -> itemMeta.displayName(TranslationManager.translation("messages.menus.close"))).setCloseButton()); + map.put(48, new ItemBuilder(this, Objects.requireNonNull(OMCRegistry.CUSTOM_ITEMS.get("_iainternal:icon_back_orange")).getBest(), itemMeta -> itemMeta.displayName(TranslationManager.translation("messages.menus.previous_page"))).setPreviousPageButton()); + map.put(50, new ItemBuilder(this, Objects.requireNonNull(OMCRegistry.CUSTOM_ITEMS.get("_iainternal:icon_next_orange")).getBest(), itemMeta -> itemMeta.displayName(TranslationManager.translation("messages.menus.next_page"))).setNextPageButton()); List loreInfo = TranslationManager.translationLore("feature.city.war.menu.more_info.lore"); diff --git a/src/main/java/fr/openmc/core/features/credits/Credits.java b/src/main/java/fr/openmc/core/features/credits/Credits.java index 0fc5a29fd..c12b51c27 100644 --- a/src/main/java/fr/openmc/core/features/credits/Credits.java +++ b/src/main/java/fr/openmc/core/features/credits/Credits.java @@ -1,5 +1,6 @@ package fr.openmc.core.features.credits; +import fr.openmc.core.OMCRegistry; import fr.openmc.core.bootstrap.features.Feature; import fr.openmc.core.bootstrap.features.annotations.Credit; import fr.openmc.core.features.adminshop.AdminShopManager; @@ -22,7 +23,6 @@ import fr.openmc.core.features.settings.PlayerSettingsManager; import fr.openmc.core.features.tickets.TicketManager; import fr.openmc.core.features.tpa.TPAManager; -import fr.openmc.core.registry.items.CustomItemRegistry; import lombok.Getter; import org.bukkit.Material; import org.bukkit.inventory.ItemStack; @@ -36,27 +36,27 @@ public enum Credits { ADMINSHOP(Material.GOLD_INGOT, "Adminshop", AdminShopManager.class), ANIMATIONS(Material.AMETHYST_BLOCK, "Les Animations", AnimationsManager.class), CUBE(Material.LAPIS_BLOCK, "Le Cube", Set.of("iambibi_")), - CITY(CustomItemRegistry.getByName("omc_homes:omc_homes_icon_chateau").getBest(), "Les Villes", CityManager.class), + CITY(OMCRegistry.CUSTOM_ITEMS.get("omc_homes:omc_homes_icon_chateau").getBest(), "Les Villes", CityManager.class), DREAM(Material.SCULK, "La Dimension des Rêves", DreamManager.class), - DREAM_MILESTONE(CustomItemRegistry.getByName("omc_dream:singularity").getBest(), "Le Milestone des Rêves", Set.of("gab400", "Rylo42 (histoire et dialogues)")), + DREAM_MILESTONE(OMCRegistry.CUSTOM_ITEMS.get("omc_dream:singularity").getBest(), "Le Milestone des Rêves", Set.of("gab400", "Rylo42 (histoire et dialogues)")), MASCOTS(Material.ZOMBIE_SPAWN_EGG, "Les Mascottes", MascotsManager.class), - MAYOR(CustomItemRegistry.getByName("omc_homes:omc_homes_icon_bank").getBest(), "Les Maires", Set.of("iambibi_"), Set.of("Gexary")), + MAYOR(OMCRegistry.CUSTOM_ITEMS.get("omc_homes:omc_homes_icon_bank").getBest(), "Les Maires", Set.of("iambibi_"), Set.of("Gexary")), CITY_MILESTONE(Material.NETHER_STAR, "Le Milestone des Villes", Set.of("iambibi_")), WAR(Material.IRON_SWORD, "Les Guerres", Set.of("iambibi_")), NOTATION(Material.PAPER, "Les Notations", Set.of("iambibi_")), RANK(Material.VAULT, "Les Grades", Set.of("gab400")), - CONTEST(CustomItemRegistry.getByName("omc_contest:contest_shell").getBest(), "Les Contests", ContestManager.class), + CONTEST(OMCRegistry.CUSTOM_ITEMS.get("omc_contest:contest_shell").getBest(), "Les Contests", ContestManager.class), WEEKLY_EVENTS(Material.FIREWORK_ROCKET, "Les Evenements Hebdomadaires", WeeklyEventsManager.class), HOLOGRAMS(Material.OAK_HANGING_SIGN, "Les Hologrammes", HologramLoader.class), ECONOMY(Material.GOLD_BLOCK, "L'Economie", EconomyManager.class), FRIENDS(Material.EMERALD_BLOCK, "Le systeme d'ami", FriendManager.class), - HOMES(CustomItemRegistry.getByName("omc_homes:omc_homes_icon_maison").getBest(), "Le Systeme d'Home", HomesManager.class), + HOMES(OMCRegistry.CUSTOM_ITEMS.get("omc_homes:omc_homes_icon_maison").getBest(), "Le Systeme d'Home", HomesManager.class), LEADERBOARD(Material.ANCIENT_DEBRIS, "Les Classements", LeaderboardManager.class), MAILBOX(Material.PAPER, "La Boite aux Lettres", MailboxManager.class), - MAINMENU(CustomItemRegistry.getByName("omc_homes:omc_homes_icon_information").getBest(), "Le Menu Principal", MainMenu.class), + MAINMENU(OMCRegistry.CUSTOM_ITEMS.get("omc_homes:omc_homes_icon_information").getBest(), "Le Menu Principal", MainMenu.class), MILESTONES(Material.SEA_LANTERN, "Les Milestones", MilestonesManager.class), PRIVATEMESSAGE(Material.ZOMBIE_HEAD, "Les messages privés", PrivateMessageManager.class), - QUEST(CustomItemRegistry.getByName("omc_homes:omc_homes_icon_chateau").getBest(), "Les Quêtes", QuestsManager.class), + QUEST(OMCRegistry.CUSTOM_ITEMS.get("omc_homes:omc_homes_icon_chateau").getBest(), "Les Quêtes", QuestsManager.class), SETTINGS(Material.REDSTONE_TORCH, "Les Paramêtres", PlayerSettingsManager.class), TICKETS(Material.BOOK, "Les Tickets V1", TicketManager.class), TPA(Material.ENDER_PEARL, "Le Tpa", TPAManager.class), diff --git a/src/main/java/fr/openmc/core/features/credits/CreditsMenu.java b/src/main/java/fr/openmc/core/features/credits/CreditsMenu.java index 75eda7f19..1c3a07fd6 100644 --- a/src/main/java/fr/openmc/core/features/credits/CreditsMenu.java +++ b/src/main/java/fr/openmc/core/features/credits/CreditsMenu.java @@ -5,7 +5,7 @@ import fr.openmc.api.menulib.utils.ItemBuilder; import fr.openmc.api.menulib.utils.ItemUtils; import fr.openmc.api.menulib.utils.StaticSlots; -import fr.openmc.core.registry.items.CustomItemRegistry; +import fr.openmc.core.OMCRegistry; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.TextDecoration; import org.bukkit.Material; @@ -75,8 +75,8 @@ public int getSizeOfItems() { public Map getButtons() { Map map = new HashMap<>(); - map.put(48, new ItemBuilder(this, Objects.requireNonNull(CustomItemRegistry.getByName("_iainternal:icon_back_orange")).getBest(), itemMeta -> itemMeta.displayName(Component.text("§cPage précédente"))).setPreviousPageButton()); - map.put(50, new ItemBuilder(this, Objects.requireNonNull(CustomItemRegistry.getByName("_iainternal:icon_next_orange")).getBest(), itemMeta -> itemMeta.displayName(Component.text("§aPage suivante"))).setNextPageButton()); + map.put(48, new ItemBuilder(this, Objects.requireNonNull(OMCRegistry.CUSTOM_ITEMS.get("_iainternal:icon_back_orange")).getBest(), itemMeta -> itemMeta.displayName(Component.text("§cPage précédente"))).setPreviousPageButton()); + map.put(50, new ItemBuilder(this, Objects.requireNonNull(OMCRegistry.CUSTOM_ITEMS.get("_iainternal:icon_next_orange")).getBest(), itemMeta -> itemMeta.displayName(Component.text("§aPage suivante"))).setNextPageButton()); map.put(49, new ItemBuilder(this, Material.BARRIER, meta -> { meta.displayName(Component.text("§cFermer le menu")); }).setOnClick(e -> getOwner().closeInventory())); diff --git a/src/main/java/fr/openmc/core/features/dream/commands/autocomplete/DreamItemAutoComplete.java b/src/main/java/fr/openmc/core/features/dream/commands/autocomplete/DreamItemAutoComplete.java index fcc597772..164cd3373 100644 --- a/src/main/java/fr/openmc/core/features/dream/commands/autocomplete/DreamItemAutoComplete.java +++ b/src/main/java/fr/openmc/core/features/dream/commands/autocomplete/DreamItemAutoComplete.java @@ -1,6 +1,7 @@ package fr.openmc.core.features.dream.commands.autocomplete; -import fr.openmc.core.registry.items.CustomItemRegistry; +import fr.openmc.core.OMCRegistry; +import fr.openmc.core.registry.items.CustomItem; import org.jetbrains.annotations.NotNull; import revxrsal.commands.autocomplete.SuggestionProvider; import revxrsal.commands.bukkit.actor.BukkitCommandActor; @@ -12,10 +13,11 @@ public class DreamItemAutoComplete implements SuggestionProvider getSuggestions(@NotNull ExecutionContext context) { - return CustomItemRegistry.getNames() + return OMCRegistry.CUSTOM_ITEMS.values() .stream() - .filter(name -> name.startsWith("omc_dream:")) - .map(name -> name.replace("omc_dream:", "")) + .map(CustomItem::getId) + .filter(id -> id.startsWith("omc_dream:")) + .map(id -> id.replace("omc_dream:", "")) .toList(); } } diff --git a/src/main/java/fr/openmc/core/features/dream/mecanism/cloudcastle/CloudVault.java b/src/main/java/fr/openmc/core/features/dream/mecanism/cloudcastle/CloudVault.java index e2197c51f..6973fd271 100644 --- a/src/main/java/fr/openmc/core/features/dream/mecanism/cloudcastle/CloudVault.java +++ b/src/main/java/fr/openmc/core/features/dream/mecanism/cloudcastle/CloudVault.java @@ -1,13 +1,11 @@ package fr.openmc.core.features.dream.mecanism.cloudcastle; import fr.openmc.core.OMCPlugin; +import fr.openmc.core.OMCRegistry; import fr.openmc.core.features.dream.DreamUtils; import fr.openmc.core.features.dream.mecanism.rng.DreamRngLootEvent; import fr.openmc.core.features.dream.registries.DreamItemRegistry; -import fr.openmc.core.registry.enchantments.CustomEnchantmentRegistry; import fr.openmc.core.registry.loottable.CustomLootTable; -import fr.openmc.core.registry.loottable.CustomLootTableRegistry; -import net.kyori.adventure.key.Key; import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.block.Block; @@ -18,12 +16,10 @@ import org.bukkit.event.block.BlockDispenseLootEvent; import org.bukkit.inventory.ItemStack; -import java.util.ArrayList; import java.util.List; -import java.util.Random; public class CloudVault implements Listener { - private final CustomLootTable CLOUD_VAULT_LOOT_TABLE = CustomLootTableRegistry.getByName("omc_dream:cloud_vault"); + private final CustomLootTable CLOUD_VAULT_LOOT_TABLE = OMCRegistry.CUSTOM_LOOT_TABLES.get("omc_dream:cloud_vault"); public static void replaceBlockWithVault(Block block) { block.setType(Material.VAULT); diff --git a/src/main/java/fr/openmc/core/features/dream/mecanism/cloudfishing/CloudFishingManager.java b/src/main/java/fr/openmc/core/features/dream/mecanism/cloudfishing/CloudFishingManager.java index 054ad56a0..8aea2b854 100644 --- a/src/main/java/fr/openmc/core/features/dream/mecanism/cloudfishing/CloudFishingManager.java +++ b/src/main/java/fr/openmc/core/features/dream/mecanism/cloudfishing/CloudFishingManager.java @@ -1,9 +1,9 @@ package fr.openmc.core.features.dream.mecanism.cloudfishing; import fr.openmc.core.OMCPlugin; +import fr.openmc.core.OMCRegistry; import fr.openmc.core.features.dream.generation.biomes.CloudChunkGenerator; import fr.openmc.core.registry.loottable.CustomLootTable; -import fr.openmc.core.registry.loottable.CustomLootTableRegistry; import fr.openmc.core.utils.bukkit.ParticleUtils; import lombok.Getter; import org.bukkit.Location; @@ -24,7 +24,7 @@ public class CloudFishingManager { private static final HashMap hookedPlayers = new HashMap<>(); public static final double Y_CLOUD_FISHING = CloudChunkGenerator.MIN_HEIGHT_CLOUD - 5; - public static final CustomLootTable FISHING_LOOT_TABLE = CustomLootTableRegistry.getByName("omc_dream:cloud_fishing"); + public static final CustomLootTable FISHING_LOOT_TABLE = OMCRegistry.CUSTOM_LOOT_TABLES.get("omc_dream:cloud_fishing"); public static void init() { OMCPlugin.registerEvents( diff --git a/src/main/java/fr/openmc/core/features/dream/mecanism/metaldetector/MetalDetectorManager.java b/src/main/java/fr/openmc/core/features/dream/mecanism/metaldetector/MetalDetectorManager.java index 6ede29111..8dcc61786 100644 --- a/src/main/java/fr/openmc/core/features/dream/mecanism/metaldetector/MetalDetectorManager.java +++ b/src/main/java/fr/openmc/core/features/dream/mecanism/metaldetector/MetalDetectorManager.java @@ -1,8 +1,8 @@ package fr.openmc.core.features.dream.mecanism.metaldetector; import fr.openmc.core.OMCPlugin; +import fr.openmc.core.OMCRegistry; import fr.openmc.core.registry.loottable.CustomLootTable; -import fr.openmc.core.registry.loottable.CustomLootTableRegistry; import java.util.HashMap; import java.util.Map; @@ -11,7 +11,7 @@ public class MetalDetectorManager { public static final Map hiddenChests = new HashMap<>(); - public static final CustomLootTable METAL_DETECTOR_LOOT_TABLE = CustomLootTableRegistry.getByName("omc_dream:metal_detector"); + public static final CustomLootTable METAL_DETECTOR_LOOT_TABLE = OMCRegistry.CUSTOM_LOOT_TABLES.get("omc_dream:metal_detector"); public static void init() { OMCPlugin.registerEvents( diff --git a/src/main/java/fr/openmc/core/features/dream/mecanism/tradernpc/GlaciteTrade.java b/src/main/java/fr/openmc/core/features/dream/mecanism/tradernpc/GlaciteTrade.java index b78f01d7a..c5b632205 100644 --- a/src/main/java/fr/openmc/core/features/dream/mecanism/tradernpc/GlaciteTrade.java +++ b/src/main/java/fr/openmc/core/features/dream/mecanism/tradernpc/GlaciteTrade.java @@ -1,8 +1,8 @@ package fr.openmc.core.features.dream.mecanism.tradernpc; +import fr.openmc.core.OMCRegistry; import fr.openmc.core.features.dream.models.registry.items.DreamItem; import fr.openmc.core.features.dream.registries.DreamItemRegistry; -import fr.openmc.core.registry.enchantments.CustomEnchantmentRegistry; import lombok.Getter; import net.kyori.adventure.key.Key; import net.kyori.adventure.text.Component; @@ -16,7 +16,7 @@ public enum GlaciteTrade { Component.text("§bOrbe de Glacite") ), SOULBOUND_BOOK( - (DreamItem) CustomEnchantmentRegistry.getCustomEnchantmentByKey(Key.key("omc_dream:soulbound")).getEnchantedBookItem(2), + (DreamItem) OMCRegistry.CUSTOM_ENCHANTS.get(Key.key("omc_dream:soulbound")).getEnchantedBookItem(2), 150, 5, Component.text("§bLivre d'enchantement : Soulbound II") diff --git a/src/main/java/fr/openmc/core/features/dream/registries/DreamItemRegistry.java b/src/main/java/fr/openmc/core/features/dream/registries/DreamItemRegistry.java index 6dfc9313b..a044597e2 100644 --- a/src/main/java/fr/openmc/core/features/dream/registries/DreamItemRegistry.java +++ b/src/main/java/fr/openmc/core/features/dream/registries/DreamItemRegistry.java @@ -2,6 +2,7 @@ import fr.openmc.core.CommandsManager; import fr.openmc.core.OMCPlugin; +import fr.openmc.core.OMCRegistry; import fr.openmc.core.features.dream.commands.DreamItemCommand; import fr.openmc.core.features.dream.listeners.registry.DreamItemConvertorListener; import fr.openmc.core.features.dream.listeners.registry.DreamItemDropsListener; @@ -37,7 +38,6 @@ import fr.openmc.core.features.dream.registries.items.orb.*; import fr.openmc.core.features.dream.registries.items.tools.*; import fr.openmc.core.registry.items.CustomItem; -import fr.openmc.core.registry.items.CustomItemRegistry; import org.bukkit.inventory.ItemStack; import javax.annotation.Nullable; @@ -127,7 +127,7 @@ public class DreamItemRegistry { * Charge la classe durant le runtime */ public static void init() { - CustomItemRegistry.registerItems(DREAM_ITEM_REGISTRY); + OMCRegistry.CUSTOM_ITEMS.register(DREAM_ITEM_REGISTRY); CommandsManager.getHandler().register( new DreamItemCommand() @@ -156,7 +156,7 @@ public static Map getBootstrapRegistry() { public static DreamItem getByName(String name) { if (!name.startsWith("omc_dream:")) name = "omc_dream:" + name; - CustomItem ci = CustomItemRegistry.getByName(name); + CustomItem ci = OMCRegistry.CUSTOM_ITEMS.get(name); if (ci == null) return null; if (!(ci instanceof DreamItem di)) return null; @@ -166,7 +166,7 @@ public static DreamItem getByName(String name) { @Nullable public static DreamItem getByItemStack(ItemStack stack) { if (stack == null) return null; - CustomItem ci = CustomItemRegistry.getByItemStack(stack); + CustomItem ci = OMCRegistry.CUSTOM_ITEMS.get(stack); if (ci == null) return null; if (!(ci instanceof DreamItem di)) return null; diff --git a/src/main/java/fr/openmc/core/features/dream/registries/DreamLootTableRegistry.java b/src/main/java/fr/openmc/core/features/dream/registries/DreamLootTableRegistry.java index d1a545a65..df4a0b312 100644 --- a/src/main/java/fr/openmc/core/features/dream/registries/DreamLootTableRegistry.java +++ b/src/main/java/fr/openmc/core/features/dream/registries/DreamLootTableRegistry.java @@ -1,19 +1,13 @@ package fr.openmc.core.features.dream.registries; +import fr.openmc.core.OMCRegistry; import fr.openmc.core.features.dream.registries.loottable.CloudFishingLootTable; import fr.openmc.core.features.dream.registries.loottable.CloudVaultLootTable; import fr.openmc.core.features.dream.registries.loottable.MetalDetectorLootTable; -import fr.openmc.core.registry.loottable.CustomLootTable; -import fr.openmc.core.registry.loottable.CustomLootTableRegistry; -import net.kyori.adventure.key.Key; - -import javax.annotation.Nullable; -import java.util.HashMap; -import java.util.Set; public class DreamLootTableRegistry { public static void init() { - CustomLootTableRegistry.register( + OMCRegistry.CUSTOM_LOOT_TABLES.register( new CloudFishingLootTable(), new MetalDetectorLootTable(), new CloudVaultLootTable() diff --git a/src/main/java/fr/openmc/core/features/dream/registries/enchantements/DreamSleeper.java b/src/main/java/fr/openmc/core/features/dream/registries/enchantements/DreamSleeper.java index 410f8221b..787a1300b 100644 --- a/src/main/java/fr/openmc/core/features/dream/registries/enchantements/DreamSleeper.java +++ b/src/main/java/fr/openmc/core/features/dream/registries/enchantements/DreamSleeper.java @@ -1,8 +1,8 @@ package fr.openmc.core.features.dream.registries.enchantements; import fr.openmc.core.OMCPlugin; +import fr.openmc.core.OMCRegistry; import fr.openmc.core.features.dream.models.registry.DreamEnchantment; -import fr.openmc.core.registry.enchantments.CustomEnchantmentRegistry; import io.papermc.paper.registry.data.EnchantmentRegistryEntry; import io.papermc.paper.registry.keys.tags.ItemTypeTagKeys; import io.papermc.paper.registry.tag.TagKey; @@ -66,7 +66,7 @@ public void onAttack(EntityDamageByEntityEvent event) { if (!(event.getDamager() instanceof Player player)) return; if (!(event.getEntity() instanceof LivingEntity living)) return; - Enchantment enchant = CustomEnchantmentRegistry.getCustomEnchantmentByKey(this.getKey()).getEnchantment(); + Enchantment enchant = OMCRegistry.CUSTOM_ENCHANTS.get(this.getKey()).getEnchantment(); if (enchant == null) return; ItemStack item = player.getInventory().getItemInMainHand(); diff --git a/src/main/java/fr/openmc/core/features/dream/registries/enchantements/Experientastic.java b/src/main/java/fr/openmc/core/features/dream/registries/enchantements/Experientastic.java index b3add80e2..2b8eea470 100644 --- a/src/main/java/fr/openmc/core/features/dream/registries/enchantements/Experientastic.java +++ b/src/main/java/fr/openmc/core/features/dream/registries/enchantements/Experientastic.java @@ -1,7 +1,7 @@ package fr.openmc.core.features.dream.registries.enchantements; +import fr.openmc.core.OMCRegistry; import fr.openmc.core.features.dream.models.registry.DreamEnchantment; -import fr.openmc.core.registry.enchantments.CustomEnchantmentRegistry; import io.papermc.paper.registry.data.EnchantmentRegistryEntry; import io.papermc.paper.registry.keys.tags.ItemTypeTagKeys; import io.papermc.paper.registry.tag.TagKey; @@ -63,7 +63,7 @@ public void onAttack(EntityDeathEvent event) { Player player = event.getEntity().getKiller(); if (player == null) return; - Enchantment enchant = CustomEnchantmentRegistry.getCustomEnchantmentByKey(this.getKey()).getEnchantment(); + Enchantment enchant = OMCRegistry.CUSTOM_ENCHANTS.get(this.getKey()).getEnchantment(); if (enchant == null) return; ItemStack item = player.getInventory().getItemInMainHand(); diff --git a/src/main/java/fr/openmc/core/features/dream/registries/enchantements/Soulbound.java b/src/main/java/fr/openmc/core/features/dream/registries/enchantements/Soulbound.java index 6fce42e1c..2d0e4df65 100644 --- a/src/main/java/fr/openmc/core/features/dream/registries/enchantements/Soulbound.java +++ b/src/main/java/fr/openmc/core/features/dream/registries/enchantements/Soulbound.java @@ -1,8 +1,8 @@ package fr.openmc.core.features.dream.registries.enchantements; import fr.openmc.api.cooldown.DynamicCooldownManager; +import fr.openmc.core.OMCRegistry; import fr.openmc.core.features.dream.models.registry.DreamEnchantment; -import fr.openmc.core.registry.enchantments.CustomEnchantmentRegistry; import fr.openmc.core.utils.text.DateUtils; import fr.openmc.core.utils.text.messages.MessageType; import fr.openmc.core.utils.text.messages.MessagesManager; @@ -75,7 +75,7 @@ public void onDeath(PlayerDeathEvent event) { Player player = event.getPlayer(); UUID uuid = player.getUniqueId(); - Enchantment enchant = CustomEnchantmentRegistry.getCustomEnchantmentByKey(this.getKey()).getEnchantment(); + Enchantment enchant = OMCRegistry.CUSTOM_ENCHANTS.get(this.getKey()).getEnchantment(); if (enchant == null) return; int maxSoulboundLevel = 0; diff --git a/src/main/java/fr/openmc/core/features/dream/registries/loottable/CloudVaultLootTable.java b/src/main/java/fr/openmc/core/features/dream/registries/loottable/CloudVaultLootTable.java index b9ca6f932..ccfa5df39 100644 --- a/src/main/java/fr/openmc/core/features/dream/registries/loottable/CloudVaultLootTable.java +++ b/src/main/java/fr/openmc/core/features/dream/registries/loottable/CloudVaultLootTable.java @@ -1,7 +1,7 @@ package fr.openmc.core.features.dream.registries.loottable; +import fr.openmc.core.OMCRegistry; import fr.openmc.core.features.dream.registries.DreamItemRegistry; -import fr.openmc.core.registry.enchantments.CustomEnchantmentRegistry; import fr.openmc.core.registry.loottable.CustomLoot; import fr.openmc.core.registry.loottable.CustomLootTable; import net.kyori.adventure.key.Key; @@ -52,7 +52,7 @@ public Set getLoots() { 1 ), new CustomLoot( - CustomEnchantmentRegistry.getCustomEnchantmentByKey( + OMCRegistry.CUSTOM_ENCHANTS.get( Key.key("omc_dream:dream_sleeper") ).getEnchantedBookItem(2).getBest(), 0.10, diff --git a/src/main/java/fr/openmc/core/features/dream/registries/loottable/MetalDetectorLootTable.java b/src/main/java/fr/openmc/core/features/dream/registries/loottable/MetalDetectorLootTable.java index 17c512500..522847739 100644 --- a/src/main/java/fr/openmc/core/features/dream/registries/loottable/MetalDetectorLootTable.java +++ b/src/main/java/fr/openmc/core/features/dream/registries/loottable/MetalDetectorLootTable.java @@ -1,8 +1,7 @@ package fr.openmc.core.features.dream.registries.loottable; -import fr.openmc.core.features.dream.models.registry.items.DreamItem; +import fr.openmc.core.OMCRegistry; import fr.openmc.core.features.dream.registries.DreamItemRegistry; -import fr.openmc.core.registry.enchantments.CustomEnchantmentRegistry; import fr.openmc.core.registry.loottable.CustomLoot; import fr.openmc.core.registry.loottable.CustomLootTable; import net.kyori.adventure.key.Key; @@ -71,7 +70,7 @@ public Set getLoots() { 1 ), new CustomLoot( - CustomEnchantmentRegistry.getCustomEnchantmentByKey(Key.key("omc_dream:experientastic")).getEnchantedBookItem(1), + OMCRegistry.CUSTOM_ENCHANTS.get(Key.key("omc_dream:experientastic")).getEnchantedBookItem(1), 0.03, 1, 1 diff --git a/src/main/java/fr/openmc/core/features/economy/menu/TransactionsMenu.java b/src/main/java/fr/openmc/core/features/economy/menu/TransactionsMenu.java index a875fa8d1..217d18d68 100644 --- a/src/main/java/fr/openmc/core/features/economy/menu/TransactionsMenu.java +++ b/src/main/java/fr/openmc/core/features/economy/menu/TransactionsMenu.java @@ -4,9 +4,9 @@ import fr.openmc.api.menulib.utils.InventorySize; import fr.openmc.api.menulib.utils.ItemBuilder; import fr.openmc.api.menulib.utils.StaticSlots; +import fr.openmc.core.OMCRegistry; import fr.openmc.core.features.economy.Transaction; import fr.openmc.core.features.economy.TransactionsManager; -import fr.openmc.core.registry.items.CustomItemRegistry; import fr.openmc.core.utils.cache.CacheOfflinePlayer; import net.kyori.adventure.text.Component; import org.bukkit.Material; @@ -76,9 +76,9 @@ public List getItems() { @Override public Map getButtons() { Map map = new HashMap<>(); - map.put(49, new ItemBuilder(this, CustomItemRegistry.getByName("_iainternal:icon_cancel").getBest(), itemMeta -> itemMeta.displayName(Component.text("§7Fermer"))).setCloseButton()); - map.put(48, new ItemBuilder(this, CustomItemRegistry.getByName("_iainternal:icon_back_orange").getBest(), itemMeta -> itemMeta.displayName(Component.text("§cPage précédente"))).setPreviousPageButton()); - map.put(50, new ItemBuilder(this, CustomItemRegistry.getByName("_iainternal:icon_next_orange").getBest(), itemMeta -> itemMeta.displayName(Component.text("§aPage suivante"))).setNextPageButton()); + map.put(49, new ItemBuilder(this, OMCRegistry.CUSTOM_ITEMS.get("_iainternal:icon_cancel").getBest(), itemMeta -> itemMeta.displayName(Component.text("§7Fermer"))).setCloseButton()); + map.put(48, new ItemBuilder(this, OMCRegistry.CUSTOM_ITEMS.get("_iainternal:icon_back_orange").getBest(), itemMeta -> itemMeta.displayName(Component.text("§cPage précédente"))).setPreviousPageButton()); + map.put(50, new ItemBuilder(this, OMCRegistry.CUSTOM_ITEMS.get("_iainternal:icon_next_orange").getBest(), itemMeta -> itemMeta.displayName(Component.text("§aPage suivante"))).setNextPageButton()); return map; } diff --git a/src/main/java/fr/openmc/core/features/events/commands/calendar/CalendarMenu.java b/src/main/java/fr/openmc/core/features/events/commands/calendar/CalendarMenu.java index 3509451ef..a22cbef88 100644 --- a/src/main/java/fr/openmc/core/features/events/commands/calendar/CalendarMenu.java +++ b/src/main/java/fr/openmc/core/features/events/commands/calendar/CalendarMenu.java @@ -4,10 +4,10 @@ import fr.openmc.api.menulib.utils.InventorySize; import fr.openmc.api.menulib.utils.ItemBuilder; import fr.openmc.api.menulib.utils.StaticSlots; +import fr.openmc.core.OMCRegistry; import fr.openmc.core.features.events.contents.weeklyevents.models.WeeklyEvent; import fr.openmc.core.features.events.contents.weeklyevents.models.WeeklyEventPhase; import fr.openmc.core.features.events.models.Event; -import fr.openmc.core.registry.items.CustomItemRegistry; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.NamedTextColor; import net.kyori.adventure.text.format.TextDecoration; @@ -70,7 +70,7 @@ public int getSizeOfItems() { @Override public Map getButtons() { Map map = new HashMap<>(); - map.put(33, new ItemBuilder(this, Objects.requireNonNull(CustomItemRegistry.getByName("_iainternal:icon_cancel")).getBest(), itemMeta -> itemMeta.displayName(Component.text("§7Fermer"))).setCloseButton()); + map.put(33, new ItemBuilder(this, OMCRegistry.CUSTOM_ITEMS.get("_iainternal:icon_cancel").getBest(), itemMeta -> itemMeta.displayName(Component.text("§7Fermer"))).setCloseButton()); return map; } 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 57f002378..541e4d848 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 @@ -8,6 +8,7 @@ import de.oliver.fancynpcs.api.Npc; import de.oliver.fancynpcs.api.NpcManager; import fr.openmc.core.OMCPlugin; +import fr.openmc.core.OMCRegistry; import fr.openmc.core.bootstrap.features.Feature; import fr.openmc.core.bootstrap.features.types.DatabaseFeature; import fr.openmc.core.bootstrap.features.types.HasCommands; @@ -18,7 +19,6 @@ import fr.openmc.core.features.events.contents.halloween.models.HalloweenData; import fr.openmc.core.features.leaderboards.LeaderboardManager; import fr.openmc.core.features.mailboxes.MailboxManager; -import fr.openmc.core.registry.items.CustomItemRegistry; import io.papermc.paper.datacomponent.DataComponentTypes; import io.papermc.paper.datacomponent.item.DamageResistant; import io.papermc.paper.registry.keys.tags.DamageTypeTagKeys; @@ -125,7 +125,7 @@ public static void endEvent() { List rewards = new ArrayList<>(); - final ItemStack aywenite = CustomItemRegistry.getByName("omc_items:aywenite").getBest(); + final ItemStack aywenite = OMCRegistry.CUSTOM_ITEMS.get("omc_items:aywenite").getBest(); aywenite.setAmount(64); switch (rank) { case 1 -> { diff --git a/src/main/java/fr/openmc/core/features/events/contents/weeklyevents/contents/contest/Contest.java b/src/main/java/fr/openmc/core/features/events/contents/weeklyevents/contents/contest/Contest.java index f7db60aa1..36bb03f5b 100644 --- a/src/main/java/fr/openmc/core/features/events/contents/weeklyevents/contents/contest/Contest.java +++ b/src/main/java/fr/openmc/core/features/events/contents/weeklyevents/contents/contest/Contest.java @@ -1,8 +1,8 @@ package fr.openmc.core.features.events.contents.weeklyevents.contents.contest; +import fr.openmc.core.OMCRegistry; import fr.openmc.core.features.events.contents.weeklyevents.models.WeeklyEvent; import fr.openmc.core.features.events.contents.weeklyevents.models.WeeklyEventPhase; -import fr.openmc.core.registry.items.CustomItemRegistry; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.NamedTextColor; import net.kyori.adventure.text.format.TextDecoration; @@ -28,7 +28,7 @@ public List getDescription() { @Override public ItemStack getIcon() { - return CustomItemRegistry.getByName("omc_contest:contest_shell").getBest(); + return OMCRegistry.CUSTOM_ITEMS.get("omc_contest:contest_shell").getBest(); } @Override diff --git a/src/main/java/fr/openmc/core/features/events/contents/weeklyevents/contents/contest/managers/ContestManager.java b/src/main/java/fr/openmc/core/features/events/contents/weeklyevents/contents/contest/managers/ContestManager.java index 8a1f54fb1..4df4b4166 100644 --- a/src/main/java/fr/openmc/core/features/events/contents/weeklyevents/contents/contest/managers/ContestManager.java +++ b/src/main/java/fr/openmc/core/features/events/contents/weeklyevents/contents/contest/managers/ContestManager.java @@ -7,6 +7,7 @@ import fr.openmc.api.menulib.Menu; import fr.openmc.core.CommandsManager; import fr.openmc.core.OMCPlugin; +import fr.openmc.core.OMCRegistry; import fr.openmc.core.bootstrap.features.Feature; import fr.openmc.core.bootstrap.features.annotations.Credit; import fr.openmc.core.bootstrap.features.types.DatabaseFeature; @@ -26,7 +27,6 @@ import fr.openmc.core.features.mailboxes.MailboxManager; import fr.openmc.core.hooks.WorldGuardHook; import fr.openmc.core.hooks.itemsadder.ItemsAdderHook; -import fr.openmc.core.registry.items.CustomItemRegistry; import fr.openmc.core.utils.bukkit.ParticleUtils; import fr.openmc.core.utils.cache.CacheOfflinePlayer; import fr.openmc.core.utils.text.ColorUtils; @@ -520,7 +520,7 @@ public static void initPhase3() { bookPlayer.setItemMeta(bookMetaPlayer); - ItemStack ayweniteItemStack = CustomItemRegistry.getByName("omc_items:aywenite").getBest(); + ItemStack ayweniteItemStack = OMCRegistry.CUSTOM_ITEMS.get("omc_items:aywenite").getBest(); ayweniteItemStack.setAmount(aywenite); itemListRewards.add(bookPlayer); itemListRewards.add(ayweniteItemStack); diff --git a/src/main/java/fr/openmc/core/features/events/contents/weeklyevents/contents/contest/menu/ContributionMenu.java b/src/main/java/fr/openmc/core/features/events/contents/weeklyevents/contents/contest/menu/ContributionMenu.java index 3afd05d6f..b77f9ea68 100644 --- a/src/main/java/fr/openmc/core/features/events/contents/weeklyevents/contents/contest/menu/ContributionMenu.java +++ b/src/main/java/fr/openmc/core/features/events/contents/weeklyevents/contents/contest/menu/ContributionMenu.java @@ -5,10 +5,10 @@ import fr.openmc.api.menulib.Menu; import fr.openmc.api.menulib.utils.InventorySize; import fr.openmc.api.menulib.utils.ItemBuilder; +import fr.openmc.core.OMCRegistry; import fr.openmc.core.features.events.contents.weeklyevents.contents.contest.managers.ContestManager; import fr.openmc.core.features.events.contents.weeklyevents.contents.contest.managers.ContestPlayerManager; import fr.openmc.core.hooks.itemsadder.ItemsAdderHook; -import fr.openmc.core.registry.items.CustomItemRegistry; import fr.openmc.core.utils.bukkit.ItemUtils; import fr.openmc.core.utils.text.ColorUtils; import fr.openmc.core.utils.text.messages.MessageType; @@ -93,7 +93,7 @@ public void onInventoryClick(InventoryClickEvent click) { ); String namespaceShellContest = "omc_contest:contest_shell"; - ItemStack shellContest = CustomItemRegistry.getByName(namespaceShellContest).getBest(); + ItemStack shellContest = OMCRegistry.CUSTOM_ITEMS.get(namespaceShellContest).getBest(); inventory.put(8, new ItemBuilder(this, Material.GOLD_BLOCK, itemMeta -> { itemMeta.displayName(Component.text("§6§lVotre titre")); diff --git a/src/main/java/fr/openmc/core/features/events/contents/weeklyevents/contents/contest/menu/TradeMenu.java b/src/main/java/fr/openmc/core/features/events/contents/weeklyevents/contents/contest/menu/TradeMenu.java index 8db31e1c2..fbf5bc59d 100644 --- a/src/main/java/fr/openmc/core/features/events/contents/weeklyevents/contents/contest/menu/TradeMenu.java +++ b/src/main/java/fr/openmc/core/features/events/contents/weeklyevents/contents/contest/menu/TradeMenu.java @@ -5,12 +5,12 @@ import fr.openmc.api.menulib.Menu; import fr.openmc.api.menulib.utils.InventorySize; import fr.openmc.api.menulib.utils.ItemBuilder; +import fr.openmc.core.OMCRegistry; import fr.openmc.core.features.events.contents.weeklyevents.contents.contest.managers.ContestManager; import fr.openmc.core.features.events.contents.weeklyevents.contents.contest.managers.ContestPlayerManager; import fr.openmc.core.features.events.contents.weeklyevents.contents.contest.managers.TradeYMLManager; import fr.openmc.core.features.mailboxes.MailboxManager; import fr.openmc.core.hooks.itemsadder.ItemsAdderHook; -import fr.openmc.core.registry.items.CustomItemRegistry; import fr.openmc.core.utils.bukkit.ItemUtils; import fr.openmc.core.utils.text.messages.MessageType; import fr.openmc.core.utils.text.messages.MessagesManager; @@ -64,7 +64,7 @@ public void onInventoryClick(InventoryClickEvent click) { String campName = ContestPlayerManager.getPlayerCampName(player); NamedTextColor campColor = ContestManager.dataPlayer.get(player.getUniqueId()).getColor(); - ItemStack shellContest = CustomItemRegistry.getByName(SHELL_NAMESPACE).getBest(); + ItemStack shellContest = OMCRegistry.CUSTOM_ITEMS.get(SHELL_NAMESPACE).getBest(); List loreInfo = Arrays.asList( Component.text("§7Apprenez en plus sur les contest !"), diff --git a/src/main/java/fr/openmc/core/features/homes/HomeUpgradeManager.java b/src/main/java/fr/openmc/core/features/homes/HomeUpgradeManager.java index e893578bb..6a3dcbcb0 100644 --- a/src/main/java/fr/openmc/core/features/homes/HomeUpgradeManager.java +++ b/src/main/java/fr/openmc/core/features/homes/HomeUpgradeManager.java @@ -1,9 +1,9 @@ package fr.openmc.core.features.homes; import fr.openmc.core.OMCPlugin; +import fr.openmc.core.OMCRegistry; import fr.openmc.core.features.economy.EconomyManager; import fr.openmc.core.features.homes.events.HomeUpgradeEvent; -import fr.openmc.core.registry.items.CustomItemRegistry; import fr.openmc.core.utils.bukkit.ItemUtils; import fr.openmc.core.utils.text.messages.MessageType; import fr.openmc.core.utils.text.messages.MessagesManager; @@ -12,8 +12,6 @@ import org.bukkit.Bukkit; import org.bukkit.entity.Player; -import java.util.Objects; - public class HomeUpgradeManager { public static HomeLimits getCurrentUpgrade(Player player) { @@ -49,7 +47,7 @@ public static void upgradeHome(Player player) { return; } - if (!ItemUtils.hasEnoughItems(player, Objects.requireNonNull(CustomItemRegistry.getByName("omc_items:aywenite")).getBest(), ayweniteAmount)) { + if (!ItemUtils.hasEnoughItems(player, OMCRegistry.CUSTOM_ITEMS.get("omc_items:aywenite").getBest(), ayweniteAmount)) { MessagesManager.sendMessage( player, Component.text("Vous n'avez pas assez d'§dAywenite §f(" + ayweniteAmount + " nécessaires)"), diff --git a/src/main/java/fr/openmc/core/features/homes/icons/HomeIcon.java b/src/main/java/fr/openmc/core/features/homes/icons/HomeIcon.java index 78f96d0c3..d1c47feb6 100644 --- a/src/main/java/fr/openmc/core/features/homes/icons/HomeIcon.java +++ b/src/main/java/fr/openmc/core/features/homes/icons/HomeIcon.java @@ -1,6 +1,6 @@ package fr.openmc.core.features.homes.icons; -import fr.openmc.core.registry.items.CustomItemRegistry; +import fr.openmc.core.OMCRegistry; import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer; import org.bukkit.Material; import org.bukkit.inventory.ItemStack; @@ -51,7 +51,7 @@ public ItemStack getItemStack() { switch (type) { case CUSTOM: try { - return Objects.requireNonNull(CustomItemRegistry.getByName(materialOrCustomId)).getBest(); + return Objects.requireNonNull(OMCRegistry.CUSTOM_ITEMS.get(materialOrCustomId)).getBest(); } catch (Exception e) { return new ItemStack(Material.GRASS_BLOCK); } diff --git a/src/main/java/fr/openmc/core/features/homes/menu/HomeChangeIconMenu.java b/src/main/java/fr/openmc/core/features/homes/menu/HomeChangeIconMenu.java index 4f4e6b55a..3d6b242a0 100644 --- a/src/main/java/fr/openmc/core/features/homes/menu/HomeChangeIconMenu.java +++ b/src/main/java/fr/openmc/core/features/homes/menu/HomeChangeIconMenu.java @@ -6,11 +6,11 @@ import fr.openmc.api.menulib.utils.InventorySize; import fr.openmc.api.menulib.utils.ItemBuilder; import fr.openmc.core.OMCPlugin; +import fr.openmc.core.OMCRegistry; import fr.openmc.core.features.homes.icons.HomeIcon; import fr.openmc.core.features.homes.icons.HomeIconCacheManager; import fr.openmc.core.features.homes.models.Home; import fr.openmc.core.features.mailboxes.utils.MailboxMenuManager; -import fr.openmc.core.registry.items.CustomItemRegistry; import fr.openmc.core.utils.bukkit.ItemUtils; import fr.openmc.core.utils.text.messages.MessageType; import fr.openmc.core.utils.text.messages.MessagesManager; @@ -98,7 +98,7 @@ public List getTakableSlot() { public Map getButtons() { Map map = new HashMap<>(); - map.put(45, new ItemBuilder(this, Objects.requireNonNull(CustomItemRegistry.getByName("_iainternal:icon_back_orange")).getBest(), + map.put(45, new ItemBuilder(this, OMCRegistry.CUSTOM_ITEMS.get("_iainternal:icon_back_orange").getBest(), itemMeta -> itemMeta.displayName(Component.text("§7Retour")), true)); map.put(48, new ItemBuilder(this, MailboxMenuManager.previousPageBtn()).setPreviousPageButton()); diff --git a/src/main/java/fr/openmc/core/features/homes/menu/HomeConfigMenu.java b/src/main/java/fr/openmc/core/features/homes/menu/HomeConfigMenu.java index 0f0787eaf..26a44e6dc 100644 --- a/src/main/java/fr/openmc/core/features/homes/menu/HomeConfigMenu.java +++ b/src/main/java/fr/openmc/core/features/homes/menu/HomeConfigMenu.java @@ -6,11 +6,11 @@ import fr.openmc.api.menulib.utils.InventorySize; import fr.openmc.api.menulib.utils.ItemBuilder; import fr.openmc.api.menulib.utils.ItemUtils; +import fr.openmc.core.OMCRegistry; import fr.openmc.core.features.homes.HomesManager; import fr.openmc.core.features.homes.models.Home; import fr.openmc.core.features.homes.utils.HomeUtil; import fr.openmc.core.features.mailboxes.utils.MailboxMenuManager; -import fr.openmc.core.registry.items.CustomItemRegistry; import fr.openmc.core.utils.text.fonts.CustomFonts; import fr.openmc.core.utils.text.messages.MessageType; import fr.openmc.core.utils.text.messages.MessagesManager; @@ -26,7 +26,10 @@ import org.bukkit.event.inventory.InventoryCloseEvent; import org.jetbrains.annotations.NotNull; -import java.util.*; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; import static fr.openmc.core.features.homes.utils.HomeUtil.MAX_LENGTH_HOME_NAME; @@ -100,7 +103,7 @@ public String getTexture() { HomesManager.renameHome(home, input); }))); - content.put(24, new ItemBuilder(this, Objects.requireNonNull(CustomItemRegistry.getByName("omc_homes:omc_homes_icon_bin_red")).getBest(), itemMeta -> { + content.put(24, new ItemBuilder(this, OMCRegistry.CUSTOM_ITEMS.get("omc_homes:omc_homes_icon_bin_red").getBest(), itemMeta -> { itemMeta.displayName(Component.text(CustomFonts.getBest("omc_homes:bin", "§c🗑") + " §cSupprimer le home")); itemMeta.lore(List.of(Component.text("§7■ §cClique §4gauche §cpour supprimer votre home"))); }).setOnClick(inventoryClickEvent -> new HomeDeleteConfirmMenu(getOwner(), home).open())); diff --git a/src/main/java/fr/openmc/core/features/homes/menu/HomeDeleteConfirmMenu.java b/src/main/java/fr/openmc/core/features/homes/menu/HomeDeleteConfirmMenu.java index 08541e34d..2a902576c 100644 --- a/src/main/java/fr/openmc/core/features/homes/menu/HomeDeleteConfirmMenu.java +++ b/src/main/java/fr/openmc/core/features/homes/menu/HomeDeleteConfirmMenu.java @@ -5,9 +5,9 @@ import fr.openmc.api.menulib.utils.InventorySize; import fr.openmc.api.menulib.utils.ItemBuilder; import fr.openmc.api.menulib.utils.ItemUtils; +import fr.openmc.core.OMCRegistry; import fr.openmc.core.features.homes.HomesManager; import fr.openmc.core.features.homes.models.Home; -import fr.openmc.core.registry.items.CustomItemRegistry; import fr.openmc.core.utils.text.messages.MessageType; import fr.openmc.core.utils.text.messages.MessagesManager; import fr.openmc.core.utils.text.messages.Prefix; @@ -53,7 +53,7 @@ public String getTexture() { content.put(2, new ItemBuilder( this, - Objects.requireNonNull(CustomItemRegistry.getByName("omc_homes:omc_homes_icon_bin_red")).getBest(), + OMCRegistry.CUSTOM_ITEMS.get("omc_homes:omc_homes_icon_bin_red").getBest(), itemMeta -> { itemMeta.displayName(Component.text("§cConfirmer la suppression")); itemMeta.lore(List.of( @@ -75,7 +75,7 @@ public String getTexture() { content.put(6, new ItemBuilder( this, - Objects.requireNonNull(CustomItemRegistry.getByName("omc_homes:omc_homes_icon_bin")).getBest(), + Objects.requireNonNull(OMCRegistry.CUSTOM_ITEMS.get("omc_homes:omc_homes_icon_bin")).getBest(), itemMeta -> itemMeta.displayName(Component.text("§aAnnuler la suppression")), true) ); diff --git a/src/main/java/fr/openmc/core/features/homes/menu/HomeMenu.java b/src/main/java/fr/openmc/core/features/homes/menu/HomeMenu.java index 0f527438c..0611fa00d 100644 --- a/src/main/java/fr/openmc/core/features/homes/menu/HomeMenu.java +++ b/src/main/java/fr/openmc/core/features/homes/menu/HomeMenu.java @@ -6,13 +6,13 @@ import fr.openmc.api.menulib.utils.ItemBuilder; import fr.openmc.api.menulib.utils.ItemUtils; import fr.openmc.core.OMCPlugin; +import fr.openmc.core.OMCRegistry; import fr.openmc.core.features.homes.HomesManager; import fr.openmc.core.features.homes.events.HomeTpEvent; import fr.openmc.core.features.homes.icons.HomeIcon; import fr.openmc.core.features.homes.icons.HomeIconRegistry; import fr.openmc.core.features.homes.models.Home; import fr.openmc.core.features.mailboxes.utils.MailboxMenuManager; -import fr.openmc.core.registry.items.CustomItemRegistry; import fr.openmc.core.utils.text.messages.MessageType; import fr.openmc.core.utils.text.messages.MessagesManager; import fr.openmc.core.utils.text.messages.Prefix; @@ -135,7 +135,7 @@ public Map getButtons() { Map map = new HashMap<>(); if(!wasTarget) { - map.put(53, new ItemBuilder(this, Objects.requireNonNull(CustomItemRegistry.getByName("omc_homes:omc_homes_icon_upgrade")).getBest(), itemMeta -> { + map.put(53, new ItemBuilder(this, Objects.requireNonNull(OMCRegistry.CUSTOM_ITEMS.get("omc_homes:omc_homes_icon_upgrade")).getBest(), itemMeta -> { itemMeta.displayName(Component.text("§8● §6Améliorer les homes §8(Click ici)")); itemMeta.lore(List.of( Component.text("§6Cliquez pour améliorer vos homes") diff --git a/src/main/java/fr/openmc/core/features/homes/menu/HomeUpgradeMenu.java b/src/main/java/fr/openmc/core/features/homes/menu/HomeUpgradeMenu.java index 1f1e09d29..ffb42ae82 100644 --- a/src/main/java/fr/openmc/core/features/homes/menu/HomeUpgradeMenu.java +++ b/src/main/java/fr/openmc/core/features/homes/menu/HomeUpgradeMenu.java @@ -4,11 +4,11 @@ import fr.openmc.api.menulib.Menu; import fr.openmc.api.menulib.utils.InventorySize; import fr.openmc.api.menulib.utils.ItemBuilder; +import fr.openmc.core.OMCRegistry; import fr.openmc.core.features.economy.EconomyManager; import fr.openmc.core.features.homes.HomeLimits; import fr.openmc.core.features.homes.HomeUpgradeManager; import fr.openmc.core.features.homes.HomesManager; -import fr.openmc.core.registry.items.CustomItemRegistry; import net.kyori.adventure.text.Component; import org.bukkit.entity.Player; import org.bukkit.event.inventory.InventoryClickEvent; @@ -46,7 +46,7 @@ public String getTexture() { ? HomeUpgradeManager.getNextUpgrade(HomeUpgradeManager.getCurrentUpgrade(getOwner())) : lastUpgrade; - items.put(4, new ItemBuilder(this, Objects.requireNonNull(CustomItemRegistry.getByName("omc_homes:omc_homes_icon_upgrade")).getBest(), itemMeta -> { + items.put(4, new ItemBuilder(this, Objects.requireNonNull(OMCRegistry.CUSTOM_ITEMS.get("omc_homes:omc_homes_icon_upgrade")).getBest(), itemMeta -> { itemMeta.displayName(Component.text("§8● §6Améliorer les homes §8(Clique gauche)")); List lore = new ArrayList<>(); lore.add(Component.text("§6Nombre de home actuel: §e" + currentHome)); diff --git a/src/main/java/fr/openmc/core/features/mailboxes/menu/HomeMailbox.java b/src/main/java/fr/openmc/core/features/mailboxes/menu/HomeMailbox.java index 184889998..5d3ac22d8 100644 --- a/src/main/java/fr/openmc/core/features/mailboxes/menu/HomeMailbox.java +++ b/src/main/java/fr/openmc/core/features/mailboxes/menu/HomeMailbox.java @@ -4,7 +4,7 @@ import fr.openmc.api.menulib.Menu; import fr.openmc.api.menulib.utils.InventorySize; import fr.openmc.api.menulib.utils.ItemBuilder; -import fr.openmc.core.registry.items.CustomItemRegistry; +import fr.openmc.core.OMCRegistry; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.NamedTextColor; import net.kyori.adventure.text.format.TextDecoration; @@ -44,7 +44,7 @@ public HomeMailbox(Player player) { public @NotNull Map getContent() { Map content = new HashMap<>(); - content.put(3, new ItemBuilder(this, CustomItemRegistry.getByName("omc_menus:mailbox_hourglass").getBest(), meta -> { + content.put(3, new ItemBuilder(this, OMCRegistry.CUSTOM_ITEMS.get("omc_menus:mailbox_hourglass").getBest(), meta -> { meta.displayName(Component .text("En attente", NamedTextColor.DARK_AQUA, TextDecoration.BOLD) .decoration(TextDecoration.ITALIC, false) @@ -58,7 +58,7 @@ public HomeMailbox(Player player) { ); }).setOnClick(e -> new PlayerMailbox(getOwner()).open())); - content.put(5, new ItemBuilder(this, CustomItemRegistry.getByName("omc_menus:mailbox_send").getBest(), meta -> { + content.put(5, new ItemBuilder(this, OMCRegistry.CUSTOM_ITEMS.get("omc_menus:mailbox_send").getBest(), meta -> { meta.displayName(Component .text("Envoyer", NamedTextColor.DARK_AQUA, TextDecoration.BOLD) .decoration(TextDecoration.ITALIC, false) diff --git a/src/main/java/fr/openmc/core/features/mailboxes/utils/MailboxMenuManager.java b/src/main/java/fr/openmc/core/features/mailboxes/utils/MailboxMenuManager.java index 021a2f70f..3bd2aadaa 100644 --- a/src/main/java/fr/openmc/core/features/mailboxes/utils/MailboxMenuManager.java +++ b/src/main/java/fr/openmc/core/features/mailboxes/utils/MailboxMenuManager.java @@ -3,10 +3,10 @@ import fr.openmc.api.menulib.Menu; import fr.openmc.api.menulib.template.ConfirmMenu; import fr.openmc.api.menulib.utils.ItemBuilder; +import fr.openmc.core.OMCRegistry; import fr.openmc.core.features.mailboxes.Letter; import fr.openmc.core.features.mailboxes.menu.HomeMailbox; import fr.openmc.core.features.mailboxes.menu.PendingMailbox; -import fr.openmc.core.registry.items.CustomItemRegistry; import fr.openmc.core.utils.text.messages.MessageType; import fr.openmc.core.utils.text.messages.MessagesManager; import fr.openmc.core.utils.text.messages.Prefix; @@ -27,7 +27,7 @@ public static ItemBuilder getBtn(Menu menu, String symbol, String name, String c .append(Component.text(symbol, color)) .append(Component.text("]", NamedTextColor.DARK_GRAY)) .append(Component.text(" " + name, color)); - return new ItemBuilder(menu, CustomItemRegistry.getByName(customModelName).getBest(), meta -> { + return new ItemBuilder(menu, OMCRegistry.CUSTOM_ITEMS.get(customModelName).getBest(), meta -> { meta.displayName(itemName.decorate(TextDecoration.BOLD).decoration(TextDecoration.ITALIC, false).decoration(TextDecoration.BOLD, bold)); meta.setMaxStackSize(1); }); @@ -39,7 +39,7 @@ public static ItemBuilder cancelBtn(Menu menu) { public static ItemStack nextPageBtn() { Component name = Component.text("Next page ➡", NamedTextColor.GOLD, TextDecoration.BOLD); - ItemStack item = CustomItemRegistry.getByName("omc_menus:mailbox_arrow_right").getBest(); + ItemStack item = OMCRegistry.CUSTOM_ITEMS.get("omc_menus:mailbox_arrow_right").getBest(); ItemMeta meta = item.getItemMeta(); meta.displayName(name); meta.setMaxStackSize(1); @@ -49,7 +49,7 @@ public static ItemStack nextPageBtn() { public static ItemStack previousPageBtn() { Component name = Component.text("⬅ Previous page", NamedTextColor.GOLD, TextDecoration.BOLD); - ItemStack item = CustomItemRegistry.getByName("omc_menus:mailbox_arrow_left").getBest(); + ItemStack item = OMCRegistry.CUSTOM_ITEMS.get("omc_menus:mailbox_arrow_left").getBest(); ItemMeta meta = item.getItemMeta(); meta.displayName(name); meta.setMaxStackSize(1); @@ -85,15 +85,15 @@ public static ItemBuilder homeBtn(Menu menu) { public static HashMap getPaginatedButtons(Menu menu) { HashMap buttons = new HashMap<>(); - buttons.put(48, new ItemBuilder(menu, CustomItemRegistry.getByName("omc_menus:mailbox_arrow_left").getBest(), meta -> { + buttons.put(48, new ItemBuilder(menu, OMCRegistry.CUSTOM_ITEMS.get("omc_menus:mailbox_arrow_left").getBest(), meta -> { meta.displayName(Component.text("§6§l⬅ Page précédente")); }).setPreviousPageButton()); - buttons.put(49, new ItemBuilder(menu, CustomItemRegistry.getByName("omc_menus:mailbox_cancel_btn").getBest(), meta -> { + buttons.put(49, new ItemBuilder(menu, OMCRegistry.CUSTOM_ITEMS.get("omc_menus:mailbox_cancel_btn").getBest(), meta -> { meta.displayName(Component.text("§8§l[§c§l✖§8§l] §c§lFermer")); }).setCloseButton()); - buttons.put(50, new ItemBuilder(menu, CustomItemRegistry.getByName("omc_menus:mailbox_arrow_right").getBest(), meta -> { + buttons.put(50, new ItemBuilder(menu, OMCRegistry.CUSTOM_ITEMS.get("omc_menus:mailbox_arrow_right").getBest(), meta -> { meta.displayName(Component.text("§6§lPage suivante ➡")); }).setNextPageButton()); diff --git a/src/main/java/fr/openmc/core/features/milestones/tutorial/quests/BreakAyweniteQuest.java b/src/main/java/fr/openmc/core/features/milestones/tutorial/quests/BreakAyweniteQuest.java index 4ff241514..73aff8909 100644 --- a/src/main/java/fr/openmc/core/features/milestones/tutorial/quests/BreakAyweniteQuest.java +++ b/src/main/java/fr/openmc/core/features/milestones/tutorial/quests/BreakAyweniteQuest.java @@ -1,6 +1,7 @@ package fr.openmc.core.features.milestones.tutorial.quests; import dev.lone.itemsadder.api.CustomBlock; +import fr.openmc.core.OMCRegistry; import fr.openmc.core.features.city.CityManager; import fr.openmc.core.features.milestones.MilestonesManager; import fr.openmc.core.features.milestones.models.MilestoneQuest; @@ -11,7 +12,6 @@ import fr.openmc.core.features.quests.rewards.QuestMoneyReward; import fr.openmc.core.features.quests.rewards.QuestTextReward; import fr.openmc.core.hooks.itemsadder.ItemsAdderHook; -import fr.openmc.core.registry.items.CustomItemRegistry; import fr.openmc.core.utils.text.messages.MessageType; import fr.openmc.core.utils.text.messages.Prefix; import org.bukkit.entity.Player; @@ -31,7 +31,7 @@ public BreakAyweniteQuest() { "§fLe nouveau minerai de la §dV2, trouvable dans les grottes", "§fIl vous sera §dutile §fdans de nombreuses fonctionnalités" ), - CustomItemRegistry.getByName("omc_items:aywenite").getBest(), + OMCRegistry.CUSTOM_ITEMS.get("omc_items:aywenite").getBest(), MilestoneType.TUTORIAL, TutorialStep.BREAK_AYWENITE, new QuestTier( diff --git a/src/main/java/fr/openmc/core/features/milestones/tutorial/quests/HomeCreateQuest.java b/src/main/java/fr/openmc/core/features/milestones/tutorial/quests/HomeCreateQuest.java index 0f1457f26..575196010 100644 --- a/src/main/java/fr/openmc/core/features/milestones/tutorial/quests/HomeCreateQuest.java +++ b/src/main/java/fr/openmc/core/features/milestones/tutorial/quests/HomeCreateQuest.java @@ -1,5 +1,6 @@ package fr.openmc.core.features.milestones.tutorial.quests; +import fr.openmc.core.OMCRegistry; import fr.openmc.core.features.homes.HomeLimits; import fr.openmc.core.features.homes.events.HomeCreateEvent; import fr.openmc.core.features.milestones.MilestonesManager; @@ -10,7 +11,6 @@ import fr.openmc.core.features.quests.rewards.QuestItemReward; import fr.openmc.core.features.quests.rewards.QuestMoneyReward; import fr.openmc.core.features.quests.rewards.QuestTextReward; -import fr.openmc.core.registry.items.CustomItemRegistry; import fr.openmc.core.utils.text.messages.MessageType; import fr.openmc.core.utils.text.messages.Prefix; import org.bukkit.Material; @@ -35,7 +35,7 @@ public HomeCreateQuest() { new QuestTier( 1, new QuestMoneyReward(HomeLimits.LIMIT_1.getPrice()), - new QuestItemReward(CustomItemRegistry.getByName("omc_items:aywenite").getBest(), HomeLimits.LIMIT_1.getAyweniteCost()), + new QuestItemReward(OMCRegistry.CUSTOM_ITEMS.get("omc_items:aywenite").getBest(), HomeLimits.LIMIT_1.getAyweniteCost()), new QuestTextReward( "Bien joué ! Vous avez fini l'§6étape " + (TutorialStep.HOME_CREATE.ordinal() + 1) + " §f! Les homes sont souvent utilisés pour pas perdre votre base ! Vous êtes limité à avoir que 1 home au début. Il va falloir penser à les améliorer...", Prefix.MILLESTONE, diff --git a/src/main/java/fr/openmc/core/features/milestones/tutorial/quests/HomeUpgradeQuest.java b/src/main/java/fr/openmc/core/features/milestones/tutorial/quests/HomeUpgradeQuest.java index 3033d858e..2cc81127f 100644 --- a/src/main/java/fr/openmc/core/features/milestones/tutorial/quests/HomeUpgradeQuest.java +++ b/src/main/java/fr/openmc/core/features/milestones/tutorial/quests/HomeUpgradeQuest.java @@ -1,5 +1,6 @@ package fr.openmc.core.features.milestones.tutorial.quests; +import fr.openmc.core.OMCRegistry; import fr.openmc.core.features.homes.events.HomeUpgradeEvent; import fr.openmc.core.features.milestones.MilestonesManager; import fr.openmc.core.features.milestones.models.MilestoneQuest; @@ -8,7 +9,6 @@ import fr.openmc.core.features.quests.objects.QuestTier; import fr.openmc.core.features.quests.rewards.QuestMoneyReward; import fr.openmc.core.features.quests.rewards.QuestTextReward; -import fr.openmc.core.registry.items.CustomItemRegistry; import fr.openmc.core.utils.text.messages.MessageType; import fr.openmc.core.utils.text.messages.Prefix; import org.bukkit.entity.Player; @@ -27,7 +27,7 @@ public HomeUpgradeQuest() { "§fpour pouvoir améliorer votre limite de homes", "§8§oCela vous permettra d'avoir plus de homes !" ), - CustomItemRegistry.getByName("omc_homes:omc_homes_icon_upgrade").getBest(), + OMCRegistry.CUSTOM_ITEMS.get("omc_homes:omc_homes_icon_upgrade").getBest(), MilestoneType.TUTORIAL, TutorialStep.HOME_UPGRADE, new QuestTier( diff --git a/src/main/java/fr/openmc/core/features/milestones/tutorial/quests/OpenContestMenuQuest.java b/src/main/java/fr/openmc/core/features/milestones/tutorial/quests/OpenContestMenuQuest.java index ccf7195cd..4d5d9ba69 100644 --- a/src/main/java/fr/openmc/core/features/milestones/tutorial/quests/OpenContestMenuQuest.java +++ b/src/main/java/fr/openmc/core/features/milestones/tutorial/quests/OpenContestMenuQuest.java @@ -1,21 +1,28 @@ package fr.openmc.core.features.milestones.tutorial.quests; +import fr.openmc.core.OMCPlugin; +import fr.openmc.core.OMCRegistry; +import fr.openmc.core.features.mailboxes.MailboxManager; import fr.openmc.core.features.milestones.MilestonesManager; import fr.openmc.core.features.milestones.models.MilestoneQuest; import fr.openmc.core.features.milestones.models.MilestoneType; import fr.openmc.core.features.milestones.tutorial.TutorialStep; import fr.openmc.core.features.quests.objects.QuestTier; import fr.openmc.core.features.quests.rewards.QuestItemReward; +import fr.openmc.core.features.quests.rewards.QuestMethodsReward; import fr.openmc.core.features.quests.rewards.QuestMoneyReward; import fr.openmc.core.features.quests.rewards.QuestTextReward; -import fr.openmc.core.registry.items.CustomItemRegistry; import fr.openmc.core.utils.text.messages.MessageType; import fr.openmc.core.utils.text.messages.Prefix; +import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerCommandPreprocessEvent; +import org.bukkit.inventory.ItemStack; +import java.time.LocalDate; +import java.util.ArrayList; import java.util.List; public class OpenContestMenuQuest extends MilestoneQuest implements Listener { @@ -27,7 +34,7 @@ public OpenContestMenuQuest() { "§fTapez §d/contest §fou bien aller dans le §dmenu principal (/menu) §fpour pouvoir ouvrir le menu", "§8§oUne méthode compétitive pour gagner des grosses récompenses !" ), - CustomItemRegistry.getByName("omc_contest:contest_shell").getBest(), + OMCRegistry.CUSTOM_ITEMS.get("omc_contest:contest_shell").getBest(), MilestoneType.TUTORIAL, TutorialStep.OPEN_CONTEST, new QuestTier( @@ -38,8 +45,8 @@ public OpenContestMenuQuest() { Prefix.MILLESTONE, MessageType.SUCCESS ), - new QuestItemReward(CustomItemRegistry.getByName("omc_items:aywenite").getBest(), 30) - /* new QuestMethodsReward( + new QuestItemReward(OMCRegistry.CUSTOM_ITEMS.get("omc_items:aywenite").getBest(), 30), + new QuestMethodsReward( player -> { List items = new ArrayList<>(); @@ -53,7 +60,7 @@ public OpenContestMenuQuest() { ); if (!limitDate.isBefore(today)) { - ItemStack aywenPlush = CustomItemRegistry.getByName("omc_plush:peluche_awyen").getBest(); + ItemStack aywenPlush = OMCRegistry.CUSTOM_ITEMS.get("omc_plush:peluche_awyen").getBest(); items.add(aywenPlush); } } @@ -62,7 +69,7 @@ public OpenContestMenuQuest() { MailboxManager.sendItems(player, player, itemsArray); } - ) */ // => PELUCHES AVANT LE 3 NOVEMBRE 2025 + ) ) ); } 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 b1e1e3fa7..4571d9da2 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 @@ -4,6 +4,7 @@ import fr.openmc.api.menulib.Menu; import fr.openmc.api.menulib.utils.InventorySize; import fr.openmc.api.menulib.utils.ItemBuilder; +import fr.openmc.core.OMCRegistry; import fr.openmc.core.features.economy.EconomyManager; import fr.openmc.core.features.quests.QuestsManager; import fr.openmc.core.features.quests.objects.Quest; @@ -12,7 +13,6 @@ import fr.openmc.core.features.quests.rewards.QuestItemReward; import fr.openmc.core.features.quests.rewards.QuestMoneyReward; import fr.openmc.core.features.quests.rewards.QuestReward; -import fr.openmc.core.registry.items.CustomItemRegistry; import io.papermc.paper.datacomponent.DataComponentTypes; import io.papermc.paper.datacomponent.item.TooltipDisplay; import net.kyori.adventure.text.Component; @@ -116,13 +116,13 @@ public void onInventoryClick(InventoryClickEvent event) { } if (this.currentPage > 0) { - content.put(19, new ItemBuilder(this, Objects.requireNonNull(CustomItemRegistry.getByName("omc_quests:quests_left_arrow")).getBest(), meta -> + content.put(19, new ItemBuilder(this, Objects.requireNonNull(OMCRegistry.CUSTOM_ITEMS.get("omc_quests:quests_left_arrow")).getBest(), meta -> meta.displayName(Component.text("Page précédente").decoration(TextDecoration.ITALIC, false)) )); } if (this.currentPage < this.totalPages - 1) { - content.put(25, new ItemBuilder(this, Objects.requireNonNull(CustomItemRegistry.getByName("omc_quests:quests_right_arrow")).getBest(), meta -> + content.put(25, new ItemBuilder(this, Objects.requireNonNull(OMCRegistry.CUSTOM_ITEMS.get("omc_quests:quests_right_arrow")).getBest(), meta -> meta.displayName(Component.text("Page suivante").decoration(TextDecoration.ITALIC, false)) )); } diff --git a/src/main/java/fr/openmc/core/features/quests/quests/ConsumeKebabQuest.java b/src/main/java/fr/openmc/core/features/quests/quests/ConsumeKebabQuest.java index d31b29272..ff2571a70 100644 --- a/src/main/java/fr/openmc/core/features/quests/quests/ConsumeKebabQuest.java +++ b/src/main/java/fr/openmc/core/features/quests/quests/ConsumeKebabQuest.java @@ -1,9 +1,9 @@ package fr.openmc.core.features.quests.quests; +import fr.openmc.core.OMCRegistry; import fr.openmc.core.features.quests.objects.Quest; import fr.openmc.core.features.quests.objects.QuestTier; import fr.openmc.core.features.quests.rewards.QuestMoneyReward; -import fr.openmc.core.registry.items.CustomItemRegistry; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; @@ -15,7 +15,7 @@ public class ConsumeKebabQuest extends Quest implements Listener { public ConsumeKebabQuest() { - super("Miam miam", List.of("Manger {target} kebab{s}"), CustomItemRegistry.getByName("omc_foods:kebab").getBest()); + super("Miam miam", List.of("Manger {target} kebab{s}"), OMCRegistry.CUSTOM_ITEMS.get("omc_foods:kebab").getBest()); this.addTiers( new QuestTier(10, new QuestMoneyReward(30)), @@ -28,7 +28,7 @@ public ConsumeKebabQuest() { @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onPlayerConsume(PlayerItemConsumeEvent event) { ItemStack item = event.getItem(); - if (item.isSimilar(CustomItemRegistry.getByName("omc_foods:kebab").getBest())) { + if (item.isSimilar(OMCRegistry.CUSTOM_ITEMS.get("omc_foods:kebab").getBest())) { this.incrementProgress(event.getPlayer().getUniqueId()); } } diff --git a/src/main/java/fr/openmc/core/features/quests/quests/CraftTheMixtureQuest.java b/src/main/java/fr/openmc/core/features/quests/quests/CraftTheMixtureQuest.java index 0fed90267..cfccf12f0 100644 --- a/src/main/java/fr/openmc/core/features/quests/quests/CraftTheMixtureQuest.java +++ b/src/main/java/fr/openmc/core/features/quests/quests/CraftTheMixtureQuest.java @@ -1,10 +1,10 @@ package fr.openmc.core.features.quests.quests; +import fr.openmc.core.OMCRegistry; import fr.openmc.core.features.quests.objects.Quest; import fr.openmc.core.features.quests.objects.QuestTier; import fr.openmc.core.features.quests.rewards.QuestItemReward; import fr.openmc.core.features.quests.rewards.QuestMoneyReward; -import fr.openmc.core.registry.items.CustomItemRegistry; import fr.openmc.core.utils.bukkit.ItemUtils; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -21,11 +21,11 @@ public CraftTheMixtureQuest() { super( "The Mixture", List.of("Fabriquer {target} The Mixture{s}"), - CustomItemRegistry.getByName("omc_foods:the_mixture").getBest() + OMCRegistry.CUSTOM_ITEMS.get("omc_foods:the_mixture").getBest() ); this.addTiers( - new QuestTier(1, new QuestItemReward(CustomItemRegistry.getByName("omc_foods:the_mixture").getBest(), 16)), + new QuestTier(1, new QuestItemReward(OMCRegistry.CUSTOM_ITEMS.get("omc_foods:the_mixture").getBest(), 16)), new QuestTier(32, new QuestMoneyReward(100)), new QuestTier(128, new QuestMoneyReward(300)), new QuestTier(512, new QuestMoneyReward(700)) @@ -35,7 +35,7 @@ public CraftTheMixtureQuest() { @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onPlayerCraft(CraftItemEvent event) { ItemStack item = event.getCurrentItem(); - if (item == null || !item.isSimilar(CustomItemRegistry.getByName("omc_foods:the_mixture").getBest())) + if (item == null || !item.isSimilar(OMCRegistry.CUSTOM_ITEMS.get("omc_foods:the_mixture").getBest())) return; // Le joueur ne craft pas plus d'un kebab diff --git a/src/main/java/fr/openmc/core/features/quests/quests/MineAyweniteQuest.java b/src/main/java/fr/openmc/core/features/quests/quests/MineAyweniteQuest.java index a7d5af386..565db8c3b 100644 --- a/src/main/java/fr/openmc/core/features/quests/quests/MineAyweniteQuest.java +++ b/src/main/java/fr/openmc/core/features/quests/quests/MineAyweniteQuest.java @@ -1,12 +1,12 @@ package fr.openmc.core.features.quests.quests; import dev.lone.itemsadder.api.CustomBlock; +import fr.openmc.core.OMCRegistry; import fr.openmc.core.features.quests.objects.Quest; import fr.openmc.core.features.quests.objects.QuestTier; import fr.openmc.core.features.quests.rewards.QuestItemReward; import fr.openmc.core.features.quests.rewards.QuestMoneyReward; import fr.openmc.core.hooks.itemsadder.ItemsAdderHook; -import fr.openmc.core.registry.items.CustomItemRegistry; import org.bukkit.Material; import org.bukkit.enchantments.Enchantment; import org.bukkit.event.EventHandler; @@ -20,7 +20,7 @@ public class MineAyweniteQuest extends Quest implements Listener { public MineAyweniteQuest() { - super("Ohhh... c'est précieux ça ?", List.of("Miner {target} Aywenite{s}"), CustomItemRegistry.getByName("omc_items:aywenite").getBest()); + super("Ohhh... c'est précieux ça ?", List.of("Miner {target} Aywenite{s}"), OMCRegistry.CUSTOM_ITEMS.get("omc_items:aywenite").getBest()); this.addTiers( new QuestTier(1, new QuestMoneyReward(20)), diff --git a/src/main/java/fr/openmc/core/features/quests/quests/WinContestQuest.java b/src/main/java/fr/openmc/core/features/quests/quests/WinContestQuest.java index 01939956e..b3a5ac600 100644 --- a/src/main/java/fr/openmc/core/features/quests/quests/WinContestQuest.java +++ b/src/main/java/fr/openmc/core/features/quests/quests/WinContestQuest.java @@ -1,10 +1,10 @@ package fr.openmc.core.features.quests.quests; +import fr.openmc.core.OMCRegistry; import fr.openmc.core.features.events.contents.weeklyevents.contents.contest.events.ContestEndEvent; import fr.openmc.core.features.quests.objects.Quest; import fr.openmc.core.features.quests.objects.QuestTier; import fr.openmc.core.features.quests.rewards.QuestItemReward; -import fr.openmc.core.registry.items.CustomItemRegistry; import org.bukkit.Material; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; @@ -21,7 +21,7 @@ public WinContestQuest() { Material.NAUTILUS_SHELL ); - this.addTier(new QuestTier(1, new QuestItemReward(CustomItemRegistry.getByName("omc_contest:contest_shell").getBest(), 5))); + this.addTier(new QuestTier(1, new QuestItemReward(OMCRegistry.CUSTOM_ITEMS.get("omc_contest:contest_shell").getBest(), 5))); } @EventHandler diff --git a/src/main/java/fr/openmc/core/features/settings/menu/PlayerSettingsMenu.java b/src/main/java/fr/openmc/core/features/settings/menu/PlayerSettingsMenu.java index 359493410..77f9aba72 100644 --- a/src/main/java/fr/openmc/core/features/settings/menu/PlayerSettingsMenu.java +++ b/src/main/java/fr/openmc/core/features/settings/menu/PlayerSettingsMenu.java @@ -5,12 +5,12 @@ import fr.openmc.api.menulib.template.ConfirmMenu; import fr.openmc.api.menulib.utils.InventorySize; import fr.openmc.api.menulib.utils.ItemBuilder; +import fr.openmc.core.OMCRegistry; import fr.openmc.core.features.mailboxes.utils.MailboxMenuManager; import fr.openmc.core.features.settings.PlayerSettings; import fr.openmc.core.features.settings.PlayerSettingsManager; import fr.openmc.core.features.settings.SettingType; import fr.openmc.core.features.settings.policy.Policy; -import fr.openmc.core.registry.items.CustomItemRegistry; import fr.openmc.core.utils.text.messages.MessageType; import fr.openmc.core.utils.text.messages.MessagesManager; import fr.openmc.core.utils.text.messages.Prefix; @@ -61,7 +61,7 @@ public int getSizeOfItems() { public Map getButtons() { Map buttons = new HashMap<>(); - buttons.put(45, new ItemBuilder(this, Objects.requireNonNull(CustomItemRegistry.getByName("omc_homes:omc_homes_icon_bin_red")).getBest(), meta -> { + buttons.put(45, new ItemBuilder(this, Objects.requireNonNull(OMCRegistry.CUSTOM_ITEMS.get("omc_homes:omc_homes_icon_bin_red")).getBest(), meta -> { meta.displayName(Component.text("§cRéinitialiser les paramètres", NamedTextColor.RED) .decoration(TextDecoration.ITALIC, false)); }).setOnClick(event -> { diff --git a/src/main/java/fr/openmc/core/features/tickets/menus/MachineBallsOpenMenu.java b/src/main/java/fr/openmc/core/features/tickets/menus/MachineBallsOpenMenu.java index 242d676c4..5f13bcf32 100644 --- a/src/main/java/fr/openmc/core/features/tickets/menus/MachineBallsOpenMenu.java +++ b/src/main/java/fr/openmc/core/features/tickets/menus/MachineBallsOpenMenu.java @@ -4,9 +4,9 @@ import fr.openmc.api.menulib.utils.InventorySize; import fr.openmc.api.menulib.utils.ItemBuilder; import fr.openmc.core.OMCPlugin; +import fr.openmc.core.OMCRegistry; import fr.openmc.core.features.tickets.PlayerStats; import fr.openmc.core.features.tickets.TicketManager; -import fr.openmc.core.registry.items.CustomItemRegistry; import fr.openmc.core.utils.text.messages.MessageType; import fr.openmc.core.utils.text.messages.MessagesManager; import fr.openmc.core.utils.text.messages.Prefix; @@ -260,12 +260,12 @@ private void giveReward(LootItem wonItem) { private List initializeLootItems() { List items = new ArrayList<>(); - items.add(new LootItem(CustomItemRegistry.getByName("omc_plush:peluche_seinyy").getBest(), + items.add(new LootItem(OMCRegistry.CUSTOM_ITEMS.get("omc_plush:peluche_seinyy").getBest(), "§d§lPeluche Seinyy", List.of(Component.text("§7Une petite peluche comme Seinyy !")), 10.0, 1, - List.of(CustomItemRegistry.getByName("omc_plush:peluche_seinyy").getBest()))); + List.of(OMCRegistry.CUSTOM_ITEMS.get("omc_plush:peluche_seinyy").getBest()))); items.add(new LootItem(Material.DIAMOND, "§b§lDiamants", diff --git a/src/main/java/fr/openmc/core/listeners/BlockBreakListener.java b/src/main/java/fr/openmc/core/listeners/BlockBreakListener.java index be66c471a..80ae99862 100644 --- a/src/main/java/fr/openmc/core/listeners/BlockBreakListener.java +++ b/src/main/java/fr/openmc/core/listeners/BlockBreakListener.java @@ -1,8 +1,8 @@ package fr.openmc.core.listeners; +import fr.openmc.core.OMCRegistry; import fr.openmc.core.features.city.ProtectionsManager; import fr.openmc.core.registry.items.CustomItem; -import fr.openmc.core.registry.items.CustomItemRegistry; import fr.openmc.core.registry.items.options.BlockBreakableItem; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -21,7 +21,7 @@ public void onBlockBreak(BlockBreakEvent event) { ProtectionsManager.verify(player, event, event.getBlock().getLocation()); ItemStack itemInHand = player.getInventory().getItemInMainHand(); - CustomItem item = CustomItemRegistry.getByItemStack(itemInHand); + CustomItem item = OMCRegistry.CUSTOM_ITEMS.get(itemInHand); if (item == null) return; if (item instanceof BlockBreakableItem breakableItem) breakableItem.onBlockBreak(player, event); diff --git a/src/main/java/fr/openmc/core/listeners/EquipableItemListener.java b/src/main/java/fr/openmc/core/listeners/EquipableItemListener.java index 9b67bcb06..01eda1174 100644 --- a/src/main/java/fr/openmc/core/listeners/EquipableItemListener.java +++ b/src/main/java/fr/openmc/core/listeners/EquipableItemListener.java @@ -1,10 +1,10 @@ package fr.openmc.core.listeners; import fr.openmc.core.OMCPlugin; +import fr.openmc.core.OMCRegistry; import fr.openmc.core.events.ArmorEquipEvent; import fr.openmc.core.features.dream.DreamUtils; import fr.openmc.core.registry.items.CustomItem; -import fr.openmc.core.registry.items.CustomItemRegistry; import fr.openmc.core.registry.items.options.EquipableItem; import org.bukkit.Bukkit; import org.bukkit.entity.Player; @@ -50,7 +50,7 @@ public void onQuit(PlayerQuitEvent event) { for (ItemStack piece : player.getInventory().getArmorContents()) { if (piece == null || piece.getType().isAir()) continue; - CustomItem customItem = CustomItemRegistry.getByItemStack(piece); + CustomItem customItem = OMCRegistry.CUSTOM_ITEMS.get(piece); if (customItem instanceof EquipableItem equipable) { equipable.removeEffects(player); } @@ -87,7 +87,7 @@ private void recalc(Player player, ItemStack oldPiece) { if (oldPiece != null && !oldPiece.getType().isAir()) { - CustomItem customItem = CustomItemRegistry.getByItemStack(oldPiece); + CustomItem customItem = OMCRegistry.CUSTOM_ITEMS.get(oldPiece); if (customItem instanceof EquipableItem equipable) { equipable.removeEffects(player); } @@ -99,7 +99,7 @@ private void recalc(Player player, ItemStack oldPiece) { if (piece == null || piece.getType().isAir()) continue; - CustomItem customItem = CustomItemRegistry.getByItemStack(piece); + CustomItem customItem = OMCRegistry.CUSTOM_ITEMS.get(piece); if (!(customItem instanceof EquipableItem equipable)) continue; for (var entry : equipable.getEffects().entrySet()) { diff --git a/src/main/java/fr/openmc/core/listeners/InteractListener.java b/src/main/java/fr/openmc/core/listeners/InteractListener.java index 051b7de55..7619b9615 100644 --- a/src/main/java/fr/openmc/core/listeners/InteractListener.java +++ b/src/main/java/fr/openmc/core/listeners/InteractListener.java @@ -1,7 +1,7 @@ package fr.openmc.core.listeners; +import fr.openmc.core.OMCRegistry; import fr.openmc.core.registry.items.CustomItem; -import fr.openmc.core.registry.items.CustomItemRegistry; import fr.openmc.core.registry.items.options.UsableItem; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -18,7 +18,7 @@ void onInteract(PlayerInteractEvent event) { Player player = event.getPlayer(); ItemStack itemInHand = player.getInventory().getItemInMainHand(); - CustomItem item = CustomItemRegistry.getByItemStack(itemInHand); + CustomItem item = OMCRegistry.CUSTOM_ITEMS.get(itemInHand); if (item == null) return; diff --git a/src/main/java/fr/openmc/core/registry/enchantments/CustomEnchantmentRegistry.java b/src/main/java/fr/openmc/core/registry/enchantments/CustomEnchantmentRegistry.java index 7945b3acc..24ecdb6fb 100644 --- a/src/main/java/fr/openmc/core/registry/enchantments/CustomEnchantmentRegistry.java +++ b/src/main/java/fr/openmc/core/registry/enchantments/CustomEnchantmentRegistry.java @@ -1,70 +1,38 @@ package fr.openmc.core.registry.enchantments; import fr.openmc.core.OMCPlugin; -import fr.openmc.core.features.dream.models.registry.DreamEnchantment; -import fr.openmc.core.features.dream.registries.DreamItemRegistry; +import fr.openmc.core.OMCRegistry; +import fr.openmc.core.bootstrap.registries.Registry; import fr.openmc.core.features.dream.registries.enchantements.DreamSleeper; import fr.openmc.core.features.dream.registries.enchantements.Experientastic; import fr.openmc.core.features.dream.registries.enchantements.Soulbound; -import fr.openmc.core.registry.items.CustomItemRegistry; -import io.papermc.paper.registry.RegistryAccess; -import io.papermc.paper.registry.RegistryKey; import io.papermc.paper.registry.data.EnchantmentRegistryEntry; import io.papermc.paper.registry.event.RegistryComposeEvent; +import io.papermc.paper.registry.event.RegistryEvents; import io.papermc.paper.registry.keys.EnchantmentKeys; import net.kyori.adventure.key.Key; -import org.bukkit.NamespacedKey; -import org.bukkit.Registry; import org.bukkit.enchantments.Enchantment; import org.bukkit.event.Listener; import org.bukkit.inventory.EquipmentSlotGroup; -import org.jetbrains.annotations.NotNull; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Set; +@SuppressWarnings("UnstableApiUsage") +public class CustomEnchantmentRegistry extends Registry { -public class CustomEnchantmentRegistry { - private final static HashMap customEnchantments = new HashMap<>(); - - /** - * Initialize the registry by registering all custom enchantments in the customEnchantments map. - *

- * ONLY CALL THIS IN BOOTSTRAP LAUNCH ! - */ - public static void init() { - // ** REGISTER ENCHANTMENTS ** - register( + @Override + public void bootstrap() { + registerAll( new Soulbound(), new Experientastic(), new DreamSleeper() ); - } - /** - * Registers a custom enchantment in the registry. - * @param enchantment The custom enchantment to register. - */ - public static void register(CustomEnchantment enchantment) { - customEnchantments.put(enchantment.getKey(), enchantment); - } + RegistryEvents.ENCHANTMENT.compose() + .newHandler(this::loadEnchantmentInBootstrap); - /** - * Registers multiple custom enchantments at once. - * @param enchantments The custom enchantments to register. - */ - public static void register(CustomEnchantment... enchantments) { - for (CustomEnchantment enchantment : enchantments) { - register(enchantment); - } } - /** - * Loads all custom enchantments from the customEnchantments map into the Minecraft registry. - * @param event The registry compose event for enchantments, used to register custom enchantments during the bootstrap phase. - */ - public static void loadEnchantmentInBootstrap(RegistryComposeEvent event) { - for (CustomEnchantment customEnchantment : customEnchantments.values()) { + private void loadEnchantmentInBootstrap(RegistryComposeEvent event) { + for (CustomEnchantment customEnchantment : values()) { event.registry().register( EnchantmentKeys.create(customEnchantment.getKey()), b -> b.description(customEnchantment.getName()) @@ -79,39 +47,26 @@ public static void loadEnchantmentInBootstrap(RegistryComposeEvent { -public class CustomItemRegistry { - static final HashMap items = new HashMap<>(); - public static final NamespacedKey CUSTOM_ITEM_KEY = new NamespacedKey(OMCPlugin.getInstance(), "custom_item"); + public static final NamespacedKey CUSTOM_ITEM_KEY = + new NamespacedKey(OMCPlugin.getInstance(), "custom_item"); - public static void init() { + @Override + public void postInit() { CommandsManager.getHandler().register(new CustomItemsDebugCommand()); // ** REGISTRER ITEMSTACK OF ITEM ADDER ** /* Buttons */ - registerSimpleItem("_iainternal:icon_cancel", Material.DARK_OAK_DOOR, "Fermer"); - registerSimpleItem("_iainternal:icon_back_orange", Material.ARROW, "Page précédente"); - registerSimpleItem("_iainternal:icon_next_orange", Material.ARROW, "Page suivante"); - registerSimpleItem("_iainternal:icon_search", Material.SPYGLASS, "Rechercher"); - registerSimpleItem("omc_menus:accept_btn", Material.GREEN_CONCRETE, "Accepter"); - registerSimpleItem("omc_menus:refuse_btn", Material.RED_CONCRETE, "Refuser"); - registerSimpleItem("omc_quests:quests_right_arrow", Material.ARROW, "Suivant"); - registerSimpleItem("omc_quests:quests_left_arrow", Material.ARROW, "Précédent"); - registerSimpleItem("omc_menus:1_btn", Material.PAPER); - registerSimpleItem("omc_menus:10_btn", Material.PAPER); - registerSimpleItem("omc_menus:64_btn", Material.PAPER); - registerSimpleItem("omc_menus:minus_btn", Material.PAPER); - registerSimpleItem("omc_menus:plus_btn", Material.PAPER); - registerSimpleItem("omc_menus:mailbox_accept_btn", Material.PAPER); - registerSimpleItem("omc_menus:mailbox_refuse_btn", Material.PAPER); - registerSimpleItem("omc_menus:mailbox_cancel_btn", Material.PAPER); - registerSimpleItem("omc_menus:mailbox_arrow_left", Material.PAPER); - registerSimpleItem("omc_menus:mailbox_arrow_right", Material.PAPER); - registerSimpleItem("omc_menus:mailbox_send", Material.PAPER); - registerSimpleItem("omc_menus:mailbox_hourglass", Material.PAPER); + register("_iainternal:icon_cancel", Material.DARK_OAK_DOOR, "Fermer"); + register("_iainternal:icon_back_orange", Material.ARROW, "Page précédente"); + register("_iainternal:icon_next_orange", Material.ARROW, "Page suivante"); + register("_iainternal:icon_search", Material.SPYGLASS, "Rechercher"); + register("omc_menus:accept_btn", Material.GREEN_CONCRETE, "Accepter"); + register("omc_menus:refuse_btn", Material.RED_CONCRETE, "Refuser"); + register("omc_quests:quests_right_arrow", Material.ARROW, "Suivant"); + register("omc_quests:quests_left_arrow", Material.ARROW, "Précédent"); + register("omc_menus:1_btn", Material.PAPER); + register("omc_menus:10_btn", Material.PAPER); + register("omc_menus:64_btn", Material.PAPER); + register("omc_menus:minus_btn", Material.PAPER); + register("omc_menus:plus_btn", Material.PAPER); + register("omc_menus:mailbox_accept_btn", Material.PAPER); + register("omc_menus:mailbox_refuse_btn", Material.PAPER); + register("omc_menus:mailbox_cancel_btn", Material.PAPER); + register("omc_menus:mailbox_arrow_left", Material.PAPER); + register("omc_menus:mailbox_arrow_right", Material.PAPER); + register("omc_menus:mailbox_send", Material.PAPER); + register("omc_menus:mailbox_hourglass", Material.PAPER); /* Items */ - registerSimpleItem("omc_contest:contest_shell", Material.NAUTILUS_SHELL); - registerSimpleItem("omc_items:aywenite", Material.AMETHYST_SHARD); - registerSimpleItem("omc_foods:kebab", Material.COOKED_BEEF); - registerSimpleItem("omc_foods:the_mixture", Material.HONEY_BOTTLE); - registerSimpleItem("omc_foods:courgette", Material.SEA_PICKLE); - registerSimpleItem("omc_items:mascot_stick", Material.STICK); - registerSimpleItem("omc_items:warp_stick", Material.STICK); - registerSimpleItem("omc_items:aywen_cap", Material.IRON_HELMET); - registerSimpleItem("omc_items:suit_helmet", Material.IRON_HELMET); - registerSimpleItem("omc_items:suit_chestplate", Material.IRON_CHESTPLATE); - registerSimpleItem("omc_items:suit_leggings", Material.IRON_LEGGINGS); - registerSimpleItem("omc_items:suit_boots", Material.IRON_BOOTS); - registerSimpleItem("omc_company:company_box", Material.CHEST); - registerSimpleItem("omc_homes:omc_homes_icon_bin_red", Material.CHEST); - registerSimpleItem("omc_homes:omc_homes_icon_bin", Material.CHEST); - registerSimpleItem("omc_homes:omc_homes_icon_information", Material.CHEST); - registerSimpleItem("omc_homes:omc_homes_icon_upgrade", Material.CHEST); + register("omc_contest:contest_shell", Material.NAUTILUS_SHELL); + register("omc_items:aywenite", Material.AMETHYST_SHARD); + register("omc_foods:kebab", Material.COOKED_BEEF); + register("omc_foods:the_mixture", Material.HONEY_BOTTLE); + register("omc_foods:courgette", Material.SEA_PICKLE); + register("omc_items:mascot_stick", Material.STICK); + register("omc_items:warp_stick", Material.STICK); + register("omc_items:aywen_cap", Material.IRON_HELMET); + register("omc_items:suit_helmet", Material.IRON_HELMET); + register("omc_items:suit_chestplate", Material.IRON_CHESTPLATE); + register("omc_items:suit_leggings", Material.IRON_LEGGINGS); + register("omc_items:suit_boots", Material.IRON_BOOTS); + register("omc_company:company_box", Material.CHEST); + register("omc_homes:omc_homes_icon_bin_red", Material.CHEST); + register("omc_homes:omc_homes_icon_bin", Material.CHEST); + register("omc_homes:omc_homes_icon_information", Material.CHEST); + register("omc_homes:omc_homes_icon_upgrade", Material.CHEST); /* Blocs */ - registerSimpleItem("omc_blocks:aywenite_block", Material.AMETHYST_BLOCK); - registerSimpleItem("omc_plush:peluche_seinyy", Material.PAPER); - registerSimpleItem("omc_plush:peluche_awyen", Material.PAPER); - registerSimpleItem("omc_blocks:urne", Material.GLASS); + register("omc_blocks:aywenite_block", Material.AMETHYST_BLOCK); + register("omc_plush:peluche_seinyy", Material.PAPER); + register("omc_plush:peluche_awyen", Material.PAPER); + register("omc_blocks:urne", Material.GLASS); /* Homes icons */ - registerSimpleItem("omc_homes:omc_homes_icon_axenq", Material.CHEST); - registerSimpleItem("omc_homes:omc_homes_icon_bank", Material.CHEST); - registerSimpleItem("omc_homes:omc_homes_icon_chateau", Material.CHEST); - registerSimpleItem("omc_homes:omc_homes_icon_chest", Material.CHEST); - registerSimpleItem("omc_homes:omc_homes_icon_grass", Material.CHEST); - registerSimpleItem("omc_homes:omc_homes_icon_maison", Material.CHEST); - registerSimpleItem("omc_homes:omc_homes_icon_sandblock", Material.CHEST); - registerSimpleItem("omc_homes:omc_homes_icon_shop", Material.CHEST); - registerSimpleItem("omc_homes:omc_homes_icon_xernas", Material.CHEST); + register("omc_homes:omc_homes_icon_axenq", Material.CHEST); + register("omc_homes:omc_homes_icon_bank", Material.CHEST); + register("omc_homes:omc_homes_icon_chateau", Material.CHEST); + register("omc_homes:omc_homes_icon_chest", Material.CHEST); + register("omc_homes:omc_homes_icon_grass", Material.CHEST); + register("omc_homes:omc_homes_icon_maison", Material.CHEST); + register("omc_homes:omc_homes_icon_sandblock", Material.CHEST); + register("omc_homes:omc_homes_icon_shop", Material.CHEST); + register("omc_homes:omc_homes_icon_xernas", Material.CHEST); /* Equipable */ - registerItem(new AywenCap("omc_items:aywen_cap")); + register(new AywenCap("omc_items:aywen_cap")); /* Hammer */ - registerItem(new Hammer("omc_items:iron_hammer", Material.IRON_PICKAXE, 1, 0)); - registerItem(new Hammer("omc_items:diamond_hammer", Material.DIAMOND_PICKAXE, 1, 1)); - registerItem(new Hammer("omc_items:netherite_hammer", Material.NETHERITE_PICKAXE, 1, 2)); + register(new Hammer("omc_items:iron_hammer", Material.IRON_PICKAXE, 1, 0)); + register(new Hammer("omc_items:diamond_hammer", Material.DIAMOND_PICKAXE, 1, 1)); + register(new Hammer("omc_items:netherite_hammer", Material.NETHERITE_PICKAXE, 1, 2)); } - public static void register(String name, CustomItem item) { - if (!name.matches("[a-zA-Z0-9_:]+")) { - throw new IllegalArgumentException("Custom item name dont match regex \"[a-zA-Z0-9_:]+\""); - } + public CustomItem get(ItemStack stack) { + if (stack == null) return null; + PersistentDataContainerView view = stack.getPersistentDataContainer(); + String id = view.get(CUSTOM_ITEM_KEY, PersistentDataType.STRING); - items.put(name, item); - } + if (id == null && ItemsAdderHook.isEnable()) { + CustomStack itemIa = CustomStack.byItemStack(stack); - public static void registerItems(CustomItem... items) { - for (CustomItem ci : items) { - registerItem(ci); - } - } + if (itemIa == null) return null; - public static void registerItems(Iterable items) { - for (CustomItem ci : items) { - registerItem(ci); + return this.get(itemIa.getNamespacedID()); + } else { + return this.get(id); } } - public static void registerItem(CustomItem item) { + public void register(CustomItem item) { register(item.getId(), item); } - public static void registerSimpleItem(String name, ItemStack item) { + public void register(String name, ItemStack item) { register(name, new CustomItem(name) { @Override public ItemStack getVanilla() { @@ -128,12 +123,12 @@ public ItemStack getVanilla() { }); } - public static void registerSimpleItem(String name, Material item) { - registerSimpleItem(name, new ItemStack(item)); + public void register(String name, Material item) { + register(name, new ItemStack(item)); } - public static void registerSimpleItem(String name, Material material, String displayName) { - registerItem(new CustomItem(name) { + public void register(String name, Material material, String displayName) { + register(new CustomItem(name) { @Override public ItemStack getVanilla() { ItemStack item = new ItemStack(material); @@ -145,29 +140,9 @@ public ItemStack getVanilla() { }); } - @Nullable - public static CustomItem getByName(String name) { - return items.get(name); - } - - @Nullable - public static CustomItem getByItemStack(ItemStack stack) { - if (stack == null) return null; - PersistentDataContainerView view = stack.getPersistentDataContainer(); - String id = view.get(CUSTOM_ITEM_KEY, PersistentDataType.STRING); - - if (id == null && ItemsAdderHook.isEnable()) { - CustomStack itemIa = CustomStack.byItemStack(stack); - - if (itemIa == null) return null; - - return getByName(itemIa.getNamespacedID()); - } else { - return getByName(id); + public void register(Iterable items) { + for (CustomItem item : items) { + register(item); } } - - public static HashSet getNames() { - return new HashSet<>(items.keySet()); - } } diff --git a/src/main/java/fr/openmc/core/registry/items/CustomItemsDebugCommand.java b/src/main/java/fr/openmc/core/registry/items/CustomItemsDebugCommand.java index dc1fd38da..8f3c7bd00 100644 --- a/src/main/java/fr/openmc/core/registry/items/CustomItemsDebugCommand.java +++ b/src/main/java/fr/openmc/core/registry/items/CustomItemsDebugCommand.java @@ -1,5 +1,6 @@ package fr.openmc.core.registry.items; +import fr.openmc.core.OMCRegistry; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.PlayerInventory; @@ -18,7 +19,7 @@ private void passTest(Player player, int test, boolean pass) { public void isCloseButton(Player player) { ItemStack item = player.getInventory().getItemInMainHand(); - CustomItem closeButton = CustomItemRegistry.getByName("_iainternal:icon_cancel"); + CustomItem closeButton = OMCRegistry.CUSTOM_ITEMS.get("_iainternal:icon_cancel"); passTest(player, 1, closeButton.equals(item)); passTest(player, 2, closeButton.equals("_iainternal:icon_cancel")); @@ -34,7 +35,7 @@ public void hand(Player player) { player.sendMessage("§cVous ne tenez rien en main."); return; } - CustomItem item = CustomItemRegistry.getByItemStack(mainhand); + CustomItem item = OMCRegistry.CUSTOM_ITEMS.get(mainhand); if (item == null) { player.sendMessage("§cL'item en main n'est pas un custom item."); } else { @@ -45,14 +46,14 @@ public void hand(Player player) { @Subcommand("list") public void list(Player player) { player.sendMessage("§eListe des custom items :"); - for (String item : CustomItemRegistry.getNames()) { + for (String item : OMCRegistry.CUSTOM_ITEMS.keys()) { player.sendMessage("§e- " + item); } } @Subcommand("get") public void get(Player player, String name) { - CustomItem item = CustomItemRegistry.getByName(name); + CustomItem item = OMCRegistry.CUSTOM_ITEMS.get(name); if (item == null) { player.sendMessage("§cCet item n'existe pas."); return; diff --git a/src/main/java/fr/openmc/core/registry/loottable/CustomLootTableRegistry.java b/src/main/java/fr/openmc/core/registry/loottable/CustomLootTableRegistry.java index f08880820..e79b25177 100644 --- a/src/main/java/fr/openmc/core/registry/loottable/CustomLootTableRegistry.java +++ b/src/main/java/fr/openmc/core/registry/loottable/CustomLootTableRegistry.java @@ -1,35 +1,22 @@ package fr.openmc.core.registry.loottable; -import javax.annotation.Nullable; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Set; +import fr.openmc.core.bootstrap.registries.Registry; -public class CustomLootTableRegistry { - static final HashMap lootTables = new HashMap<>(); +public class CustomLootTableRegistry extends Registry { - public static void init() { + @Override + public void postInit() { // ** REGISTRER LOOT TABLES ** - } - public static void register(CustomLootTable table) { - lootTables.put(table.getName(), table); + public void register(CustomLootTable table) { + register(table.getName(), table); } - public static void register(CustomLootTable... tables) { + public void register(CustomLootTable... tables) { for (CustomLootTable table : tables) { register(table); } } - - @Nullable - public static CustomLootTable getByName(String name) { - return lootTables.get(name); - } - - public static HashSet getNames() { - return new HashSet<>(lootTables.keySet()); - } } \ No newline at end of file diff --git a/src/main/java/fr/openmc/core/utils/bukkit/ItemUtils.java b/src/main/java/fr/openmc/core/utils/bukkit/ItemUtils.java index 5c4c7f88d..7a6e5208b 100644 --- a/src/main/java/fr/openmc/core/utils/bukkit/ItemUtils.java +++ b/src/main/java/fr/openmc/core/utils/bukkit/ItemUtils.java @@ -2,8 +2,8 @@ import dev.lone.itemsadder.api.CustomStack; import fr.openmc.core.OMCPlugin; +import fr.openmc.core.OMCRegistry; import fr.openmc.core.features.mailboxes.MailboxManager; -import fr.openmc.core.registry.items.CustomItemRegistry; import fr.openmc.core.utils.cache.CacheOfflinePlayer; import fr.openmc.core.utils.text.messages.MessageType; import fr.openmc.core.utils.text.messages.MessagesManager; @@ -301,7 +301,7 @@ public static int removeItemsFromInventory(Player player, ItemStack item, int am } public static boolean takeAywenite(Player player, int amount) { - ItemStack aywenite = CustomItemRegistry.getByName("omc_items:aywenite").getBest(); + ItemStack aywenite = OMCRegistry.CUSTOM_ITEMS.get("omc_items:aywenite").getBest(); if (aywenite == null) return false; if (!hasEnoughItems(player, aywenite, amount)) { @@ -320,7 +320,7 @@ public static boolean takeAywenite(Player player, int amount) { } public static boolean giveAywenite(Player player, int amount) { - ItemStack aywenite = CustomItemRegistry.getByName("omc_items:aywenite").getBest(); + ItemStack aywenite = OMCRegistry.CUSTOM_ITEMS.get("omc_items:aywenite").getBest(); if (aywenite == null) return false; aywenite.setAmount(amount); From 4e0e2e31a8d3d9cafab1d6132660137b225f06cf Mon Sep 17 00:00:00 2001 From: iambibi_ <89582596+iambibi@users.noreply.github.com> Date: Sat, 9 May 2026 22:06:44 +0200 Subject: [PATCH 2/6] bootstrap fix + another pb to CustomEnchantmentRegistry --- src/main/java/fr/openmc/core/OMCRegistry.java | 28 +++++++++++++++---- .../autocomplete/CustomItemAutoComplete.java | 2 +- .../registry/items/CustomItemRegistry.java | 12 ++++++-- 3 files changed, 34 insertions(+), 8 deletions(-) diff --git a/src/main/java/fr/openmc/core/OMCRegistry.java b/src/main/java/fr/openmc/core/OMCRegistry.java index f6549b720..cd3e4287e 100644 --- a/src/main/java/fr/openmc/core/OMCRegistry.java +++ b/src/main/java/fr/openmc/core/OMCRegistry.java @@ -1,6 +1,6 @@ package fr.openmc.core; -import fr.openmc.core.bootstrap.registries.BootstrapRegistry; +import fr.openmc.core.bootstrap.integration.OMCLogger; import fr.openmc.core.bootstrap.registries.LifecycleRegistry; import fr.openmc.core.registry.enchantments.CustomEnchantmentRegistry; import fr.openmc.core.registry.items.CustomItemRegistry; @@ -24,21 +24,39 @@ private OMCRegistry() {} public static void bootstrapAll() { for (LifecycleRegistry r : OMCRegistry.ALL) { - if (r instanceof BootstrapRegistry b) { - b.bootstrap(); + if (isOverridden(r, "bootstrap")) { + r.bootstrap(); + OMCLogger.successFormatted("Registre {} chargée pendant le bootstrap", r.getClass().getSimpleName()); } } } public static void initAll() { for (LifecycleRegistry r : OMCRegistry.ALL) { - r.init(); + if (isOverridden(r, "init")) { + r.init(); + OMCLogger.successFormatted("Registre {} chargée pendant le runtime", r.getClass().getSimpleName()); + } } } public static void postInitAll() { for (LifecycleRegistry r : OMCRegistry.ALL) { - r.postInit(); + if (isOverridden(r, "postInit")) { + r.postInit(); + OMCLogger.successFormatted("Registre {} chargée après ItemsAdder", r.getClass().getSimpleName()); + } + } + } + + private static boolean isOverridden(LifecycleRegistry r, String methodName) { + try { + return !r.getClass() + .getMethod(methodName) + .getDeclaringClass() + .equals(LifecycleRegistry.class); + } catch (NoSuchMethodException e) { + return false; } } } \ No newline at end of file diff --git a/src/main/java/fr/openmc/core/commands/autocomplete/CustomItemAutoComplete.java b/src/main/java/fr/openmc/core/commands/autocomplete/CustomItemAutoComplete.java index b253b2d69..1b3228545 100644 --- a/src/main/java/fr/openmc/core/commands/autocomplete/CustomItemAutoComplete.java +++ b/src/main/java/fr/openmc/core/commands/autocomplete/CustomItemAutoComplete.java @@ -17,7 +17,7 @@ public class CustomItemAutoComplete implements SuggestionProvider !id.startsWith("omc_dream:")) - .map(id -> id.replace("omc_dream:", "")) + .map(id -> id.split(":")[1]) .toList(); } } diff --git a/src/main/java/fr/openmc/core/registry/items/CustomItemRegistry.java b/src/main/java/fr/openmc/core/registry/items/CustomItemRegistry.java index c54c32469..7236ba298 100644 --- a/src/main/java/fr/openmc/core/registry/items/CustomItemRegistry.java +++ b/src/main/java/fr/openmc/core/registry/items/CustomItemRegistry.java @@ -2,7 +2,6 @@ import dev.lone.itemsadder.api.CustomStack; import fr.openmc.core.CommandsManager; -import fr.openmc.core.OMCPlugin; import fr.openmc.core.bootstrap.registries.Registry; import fr.openmc.core.hooks.itemsadder.ItemsAdderHook; import fr.openmc.core.registry.items.contents.AywenCap; @@ -19,7 +18,7 @@ public class CustomItemRegistry extends Registry { public static final NamespacedKey CUSTOM_ITEM_KEY = - new NamespacedKey(OMCPlugin.getInstance(), "custom_item"); + new NamespacedKey("openmc", "custom_item"); @Override public void postInit() { @@ -94,6 +93,15 @@ public void postInit() { register(new Hammer("omc_items:netherite_hammer", Material.NETHERITE_PICKAXE, 1, 2)); } + public CustomItem get(String id) { + if (super.get(id) != null) return super.get(id); + + return values().stream() + .filter(item -> item.getId().split(":")[1].equals(id)) + .findFirst() + .orElse(null); + } + public CustomItem get(ItemStack stack) { if (stack == null) return null; PersistentDataContainerView view = stack.getPersistentDataContainer(); From 2c0ad0e1043dd3c457519cb908333b5e5822c090 Mon Sep 17 00:00:00 2001 From: iambibi_ <89582596+iambibi@users.noreply.github.com> Date: Sat, 9 May 2026 22:08:48 +0200 Subject: [PATCH 3/6] fix: CustomEnchantmentRegistry --- src/main/java/fr/openmc/core/OMCBootstrap.java | 2 +- src/main/java/fr/openmc/core/OMCRegistry.java | 6 ++++-- .../core/bootstrap/registries/LifecycleRegistry.java | 5 ++++- .../registry/enchantments/CustomEnchantmentRegistry.java | 7 ++++--- 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/main/java/fr/openmc/core/OMCBootstrap.java b/src/main/java/fr/openmc/core/OMCBootstrap.java index 9c40e3e4a..c8190388a 100644 --- a/src/main/java/fr/openmc/core/OMCBootstrap.java +++ b/src/main/java/fr/openmc/core/OMCBootstrap.java @@ -49,7 +49,7 @@ public void bootstrap(@NotNull BootstrapContext context) { ItemsAdderHook.copyContentsToItemsAdder(context, "contents"); // ** REGISTRY MANAGER ** - OMCRegistry.bootstrapAll(); + OMCRegistry.bootstrapAll(context); // context.getLifecycleManager().registerEventHandler(RegistryEvents.ENCHANTMENT.compose() // .newHandler(CustomEnchantmentRegistry::loadEnchantmentInBootstrap) diff --git a/src/main/java/fr/openmc/core/OMCRegistry.java b/src/main/java/fr/openmc/core/OMCRegistry.java index cd3e4287e..0fee15961 100644 --- a/src/main/java/fr/openmc/core/OMCRegistry.java +++ b/src/main/java/fr/openmc/core/OMCRegistry.java @@ -5,9 +5,11 @@ import fr.openmc.core.registry.enchantments.CustomEnchantmentRegistry; import fr.openmc.core.registry.items.CustomItemRegistry; import fr.openmc.core.registry.loottable.CustomLootTableRegistry; +import io.papermc.paper.plugin.bootstrap.BootstrapContext; import java.util.List; +@SuppressWarnings("UnstableApiUsage") public final class OMCRegistry { public static final CustomItemRegistry CUSTOM_ITEMS = new CustomItemRegistry(); @@ -22,10 +24,10 @@ public final class OMCRegistry { private OMCRegistry() {} - public static void bootstrapAll() { + public static void bootstrapAll(BootstrapContext context) { for (LifecycleRegistry r : OMCRegistry.ALL) { if (isOverridden(r, "bootstrap")) { - r.bootstrap(); + r.bootstrap(context); OMCLogger.successFormatted("Registre {} chargée pendant le bootstrap", r.getClass().getSimpleName()); } } diff --git a/src/main/java/fr/openmc/core/bootstrap/registries/LifecycleRegistry.java b/src/main/java/fr/openmc/core/bootstrap/registries/LifecycleRegistry.java index 810a822a4..51990346f 100644 --- a/src/main/java/fr/openmc/core/bootstrap/registries/LifecycleRegistry.java +++ b/src/main/java/fr/openmc/core/bootstrap/registries/LifecycleRegistry.java @@ -1,7 +1,10 @@ package fr.openmc.core.bootstrap.registries; +import io.papermc.paper.plugin.bootstrap.BootstrapContext; + +@SuppressWarnings("UnstableApiUsage") public interface LifecycleRegistry { - default void bootstrap() {} + default void bootstrap(BootstrapContext context) {} default void init() {} diff --git a/src/main/java/fr/openmc/core/registry/enchantments/CustomEnchantmentRegistry.java b/src/main/java/fr/openmc/core/registry/enchantments/CustomEnchantmentRegistry.java index 24ecdb6fb..691754efc 100644 --- a/src/main/java/fr/openmc/core/registry/enchantments/CustomEnchantmentRegistry.java +++ b/src/main/java/fr/openmc/core/registry/enchantments/CustomEnchantmentRegistry.java @@ -6,6 +6,7 @@ import fr.openmc.core.features.dream.registries.enchantements.DreamSleeper; import fr.openmc.core.features.dream.registries.enchantements.Experientastic; import fr.openmc.core.features.dream.registries.enchantements.Soulbound; +import io.papermc.paper.plugin.bootstrap.BootstrapContext; import io.papermc.paper.registry.data.EnchantmentRegistryEntry; import io.papermc.paper.registry.event.RegistryComposeEvent; import io.papermc.paper.registry.event.RegistryEvents; @@ -19,15 +20,15 @@ public class CustomEnchantmentRegistry extends Registry { @Override - public void bootstrap() { + public void bootstrap(BootstrapContext context) { registerAll( new Soulbound(), new Experientastic(), new DreamSleeper() ); - RegistryEvents.ENCHANTMENT.compose() - .newHandler(this::loadEnchantmentInBootstrap); + context.getLifecycleManager().registerEventHandler(RegistryEvents.ENCHANTMENT.compose() + .newHandler(this::loadEnchantmentInBootstrap)); } From e0d0756517b8b00a61e34930a298c79dce2356ec Mon Sep 17 00:00:00 2001 From: iambibi_ <89582596+iambibi@users.noreply.github.com> Date: Sun, 10 May 2026 11:10:50 +0200 Subject: [PATCH 4/6] fix: CustomEnchantmentRegistry with args --- src/main/java/fr/openmc/core/OMCRegistry.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/fr/openmc/core/OMCRegistry.java b/src/main/java/fr/openmc/core/OMCRegistry.java index 0fee15961..53844dc84 100644 --- a/src/main/java/fr/openmc/core/OMCRegistry.java +++ b/src/main/java/fr/openmc/core/OMCRegistry.java @@ -26,7 +26,7 @@ private OMCRegistry() {} public static void bootstrapAll(BootstrapContext context) { for (LifecycleRegistry r : OMCRegistry.ALL) { - if (isOverridden(r, "bootstrap")) { + if (isOverridden(r, "bootstrap", BootstrapContext.class)) { r.bootstrap(context); OMCLogger.successFormatted("Registre {} chargée pendant le bootstrap", r.getClass().getSimpleName()); } @@ -51,10 +51,10 @@ public static void postInitAll() { } } - private static boolean isOverridden(LifecycleRegistry r, String methodName) { + private static boolean isOverridden(LifecycleRegistry r, String methodName, Class... args) { try { return !r.getClass() - .getMethod(methodName) + .getMethod(methodName, args) .getDeclaringClass() .equals(LifecycleRegistry.class); } catch (NoSuchMethodException e) { From 774a2144b3e724560bc563f7506c5056c32576ec Mon Sep 17 00:00:00 2001 From: iambibi_ <89582596+iambibi@users.noreply.github.com> Date: Mon, 11 May 2026 18:19:04 +0200 Subject: [PATCH 5/6] feat: CustomMobRegistry complete --- src/main/java/fr/openmc/core/OMCRegistry.java | 3 + .../core/features/dream/DreamManager.java | 8 +- .../registry/DreamMobDamageListener.java | 14 +- .../blocksdrops/ChangeBlockDropsListener.java | 30 ++++ .../blocksdrops/DreamBlocksDropsManager.java} | 31 +---- .../cloudcastle/BossCloudSpawner.java | 3 +- .../cloudcastle/PhantomCloudSpawner.java | 4 +- .../cloudcastle/StrayCloudSpawner.java | 4 +- .../dream/models/registry/DreamMob.java | 78 +++-------- .../dream/registries/DreamBlocksRegistry.java | 1 + .../dream/registries/DreamMobsRegistry.java | 84 +++++------ .../dream/registries/mobs/Breezy.java | 18 +-- .../registries/mobs/CorruptedTadpole.java | 40 ++---- .../dream/registries/mobs/CrazyFrog.java | 14 +- .../dream/registries/mobs/DreamCreaking.java | 23 +--- .../dream/registries/mobs/DreamPhantom.java | 25 ++-- .../dream/registries/mobs/DreamSpider.java | 13 +- .../dream/registries/mobs/DreamStray.java | 21 +-- .../features/dream/registries/mobs/Soul.java | 28 ++-- .../MudBeachMobSpawningListener.java | 7 +- .../listeners/PlainsMobSpawningListener.java | 11 +- .../SoulForestMobSpawningListener.java | 7 +- .../openmc/core/registry/mobs/CustomMob.java | 130 ++++++++++++++++++ .../registry/mobs/CustomMobAttribute.java | 12 ++ .../core/registry/mobs/CustomMobEntry.java | 8 ++ .../core/registry/mobs/CustomMobRegistry.java | 56 ++++++++ .../listeners/CustomMobDeathListener.java} | 20 +-- .../openmc/core/utils/bukkit/EntityUtils.java | 20 +++ 28 files changed, 433 insertions(+), 280 deletions(-) create mode 100644 src/main/java/fr/openmc/core/features/dream/mecanism/blocksdrops/ChangeBlockDropsListener.java rename src/main/java/fr/openmc/core/features/dream/{registries/DreamBlocksDropsRegistry.java => mecanism/blocksdrops/DreamBlocksDropsManager.java} (61%) create mode 100644 src/main/java/fr/openmc/core/registry/mobs/CustomMob.java create mode 100644 src/main/java/fr/openmc/core/registry/mobs/CustomMobAttribute.java create mode 100644 src/main/java/fr/openmc/core/registry/mobs/CustomMobEntry.java create mode 100644 src/main/java/fr/openmc/core/registry/mobs/CustomMobRegistry.java rename src/main/java/fr/openmc/core/{features/dream/listeners/registry/DreamMobLootListener.java => registry/mobs/listeners/CustomMobDeathListener.java} (63%) create mode 100644 src/main/java/fr/openmc/core/utils/bukkit/EntityUtils.java diff --git a/src/main/java/fr/openmc/core/OMCRegistry.java b/src/main/java/fr/openmc/core/OMCRegistry.java index 53844dc84..ae9197423 100644 --- a/src/main/java/fr/openmc/core/OMCRegistry.java +++ b/src/main/java/fr/openmc/core/OMCRegistry.java @@ -5,6 +5,7 @@ import fr.openmc.core.registry.enchantments.CustomEnchantmentRegistry; import fr.openmc.core.registry.items.CustomItemRegistry; import fr.openmc.core.registry.loottable.CustomLootTableRegistry; +import fr.openmc.core.registry.mobs.CustomMobRegistry; import io.papermc.paper.plugin.bootstrap.BootstrapContext; import java.util.List; @@ -13,11 +14,13 @@ public final class OMCRegistry { public static final CustomItemRegistry CUSTOM_ITEMS = new CustomItemRegistry(); + public static final CustomMobRegistry CUSTOM_MOBS = new CustomMobRegistry(); public static final CustomEnchantmentRegistry CUSTOM_ENCHANTS = new CustomEnchantmentRegistry(); public static final CustomLootTableRegistry CUSTOM_LOOT_TABLES = new CustomLootTableRegistry(); private static final List ALL = List.of( CUSTOM_ITEMS, + CUSTOM_MOBS, CUSTOM_ENCHANTS, CUSTOM_LOOT_TABLES ); diff --git a/src/main/java/fr/openmc/core/features/dream/DreamManager.java b/src/main/java/fr/openmc/core/features/dream/DreamManager.java index ce03a2a49..fcc468fec 100644 --- a/src/main/java/fr/openmc/core/features/dream/DreamManager.java +++ b/src/main/java/fr/openmc/core/features/dream/DreamManager.java @@ -28,6 +28,7 @@ import fr.openmc.core.features.dream.listeners.registry.DreamItemEquipListener; import fr.openmc.core.features.dream.listeners.structures.PlayerEnterStructureListener; import fr.openmc.core.features.dream.listeners.structures.PlayerExitStructureListener; +import fr.openmc.core.features.dream.mecanism.blocksdrops.DreamBlocksDropsManager; import fr.openmc.core.features.dream.mecanism.cloudfishing.CloudFishingManager; import fr.openmc.core.features.dream.mecanism.cold.ColdManager; import fr.openmc.core.features.dream.mecanism.metaldetector.MetalDetectorManager; @@ -40,7 +41,10 @@ import fr.openmc.core.features.dream.models.db.DBPlayerSave; import fr.openmc.core.features.dream.models.db.DreamPlayer; import fr.openmc.core.features.dream.models.registry.items.DreamItem; -import fr.openmc.core.features.dream.registries.*; +import fr.openmc.core.features.dream.registries.DreamBlocksRegistry; +import fr.openmc.core.features.dream.registries.DreamItemRegistry; +import fr.openmc.core.features.dream.registries.DreamLootTableRegistry; +import fr.openmc.core.features.dream.registries.DreamMobsRegistry; import fr.openmc.core.utils.bukkit.serializer.BukkitSerializer; import fr.openmc.core.utils.world.LocationUtils; import org.bukkit.Bukkit; @@ -82,7 +86,7 @@ public void init() { DreamLootTableRegistry.init(); DreamBlocksRegistry.init(); DreamMobsRegistry.init(); - DreamBlocksDropsRegistry.init(); + DreamBlocksDropsManager.init(); CloudFishingManager.init(); MetalDetectorManager.init(); ColdManager.init(); diff --git a/src/main/java/fr/openmc/core/features/dream/listeners/registry/DreamMobDamageListener.java b/src/main/java/fr/openmc/core/features/dream/listeners/registry/DreamMobDamageListener.java index 82722784a..d61fe1d11 100644 --- a/src/main/java/fr/openmc/core/features/dream/listeners/registry/DreamMobDamageListener.java +++ b/src/main/java/fr/openmc/core/features/dream/listeners/registry/DreamMobDamageListener.java @@ -1,9 +1,11 @@ package fr.openmc.core.features.dream.listeners.registry; +import fr.openmc.core.OMCRegistry; import fr.openmc.core.features.dream.DreamUtils; import fr.openmc.core.features.dream.models.registry.DreamMob; -import fr.openmc.core.features.dream.registries.DreamMobsRegistry; import fr.openmc.core.features.milestones.dialogs.MilestoneDialog; +import fr.openmc.core.registry.mobs.CustomMob; +import fr.openmc.core.registry.mobs.CustomMobRegistry; import org.bukkit.Sound; import org.bukkit.entity.Entity; import org.bukkit.entity.LivingEntity; @@ -19,7 +21,8 @@ public class DreamMobDamageListener implements Listener { @EventHandler public void onEntityDamage(EntityDamageEvent event) { if (!(event.getEntity() instanceof LivingEntity livingEntity)) return; - if (!DreamMobsRegistry.isDreamMob(livingEntity)) return; + if (!CustomMobRegistry.isCustomMob(livingEntity)) return; + if (!(OMCRegistry.CUSTOM_MOBS.getMob(livingEntity) instanceof DreamMob)) return; if (event instanceof EntityDamageByEntityEvent entityEvent) { Entity damager = entityEvent.getDamager(); @@ -37,10 +40,11 @@ public void onPlayerDamage(EntityDamageByEntityEvent event) { if (!(damaged instanceof Player p)) return; if (!(damager instanceof LivingEntity livingEntity)) return; - if (!DreamMobsRegistry.isDreamMob(livingEntity)) return; + if (!CustomMobRegistry.isCustomMob(livingEntity)) return; - DreamMob dreamMob = DreamMobsRegistry.getFromEntity(livingEntity); - if (dreamMob == null) return; + CustomMob customMob = OMCRegistry.CUSTOM_MOBS.getMob(livingEntity); + if (customMob == null) return; + if (!(customMob instanceof DreamMob dreamMob)) return; event.setCancelled(true); if (MilestoneDialog.isInMilestoneDialog(p)) return; diff --git a/src/main/java/fr/openmc/core/features/dream/mecanism/blocksdrops/ChangeBlockDropsListener.java b/src/main/java/fr/openmc/core/features/dream/mecanism/blocksdrops/ChangeBlockDropsListener.java new file mode 100644 index 000000000..a53178af0 --- /dev/null +++ b/src/main/java/fr/openmc/core/features/dream/mecanism/blocksdrops/ChangeBlockDropsListener.java @@ -0,0 +1,30 @@ +package fr.openmc.core.features.dream.mecanism.blocksdrops; + +import fr.openmc.core.features.dream.DreamUtils; +import org.bukkit.GameMode; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.block.BlockBreakEvent; +import org.bukkit.inventory.ItemStack; + +public class ChangeBlockDropsListener implements Listener { + @EventHandler + public void onBlockBreak(BlockBreakEvent event) { + Block block = event.getBlock(); + + if (!DreamUtils.isDreamWorld(block.getLocation())) return; + + Material type = block.getType(); + + ItemStack customDrop = DreamBlocksDropsManager.getCustomDrop(type); + + event.setDropItems(false); + event.setExpToDrop(0); + + if (customDrop != null && !event.getPlayer().getGameMode().equals(GameMode.CREATIVE)) { + block.getWorld().dropItemNaturally(block.getLocation(), customDrop); + } + } +} diff --git a/src/main/java/fr/openmc/core/features/dream/registries/DreamBlocksDropsRegistry.java b/src/main/java/fr/openmc/core/features/dream/mecanism/blocksdrops/DreamBlocksDropsManager.java similarity index 61% rename from src/main/java/fr/openmc/core/features/dream/registries/DreamBlocksDropsRegistry.java rename to src/main/java/fr/openmc/core/features/dream/mecanism/blocksdrops/DreamBlocksDropsManager.java index 874b57967..ae7101d17 100644 --- a/src/main/java/fr/openmc/core/features/dream/registries/DreamBlocksDropsRegistry.java +++ b/src/main/java/fr/openmc/core/features/dream/mecanism/blocksdrops/DreamBlocksDropsManager.java @@ -1,23 +1,18 @@ -package fr.openmc.core.features.dream.registries; +package fr.openmc.core.features.dream.mecanism.blocksdrops; import fr.openmc.core.OMCPlugin; -import fr.openmc.core.features.dream.DreamUtils; -import org.bukkit.GameMode; +import fr.openmc.core.features.dream.registries.DreamItemRegistry; import org.bukkit.Material; -import org.bukkit.block.Block; -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; -import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.inventory.ItemStack; import java.util.HashMap; -public class DreamBlocksDropsRegistry implements Listener { +public class DreamBlocksDropsManager { private final static HashMap customDrops = new HashMap<>(); public static void init() { - OMCPlugin.registerEvents(new DreamBlocksDropsRegistry()); + OMCPlugin.registerEvents(new ChangeBlockDropsListener()); registerCustomDrop(Material.SCULK, DreamItemRegistry.getByName("corrupted_sculk").getBest()); registerCustomDrop(Material.PALE_OAK_WOOD, DreamItemRegistry.getByName("old_pale_oak").getBest()); @@ -38,22 +33,4 @@ public static void registerCustomDrop(Material mat, ItemStack item) { public static ItemStack getCustomDrop(Material mat) { return customDrops.get(mat); } - - @EventHandler - public void onBlockBreak(BlockBreakEvent event) { - Block block = event.getBlock(); - - if (!DreamUtils.isDreamWorld(block.getLocation())) return; - - Material type = block.getType(); - - ItemStack customDrop = DreamBlocksDropsRegistry.getCustomDrop(type); - - event.setDropItems(false); - event.setExpToDrop(0); - - if (customDrop != null && !event.getPlayer().getGameMode().equals(GameMode.CREATIVE)) { - block.getWorld().dropItemNaturally(block.getLocation(), customDrop); - } - } } diff --git a/src/main/java/fr/openmc/core/features/dream/mecanism/cloudcastle/BossCloudSpawner.java b/src/main/java/fr/openmc/core/features/dream/mecanism/cloudcastle/BossCloudSpawner.java index ae19ed03a..ee8a60f7c 100644 --- a/src/main/java/fr/openmc/core/features/dream/mecanism/cloudcastle/BossCloudSpawner.java +++ b/src/main/java/fr/openmc/core/features/dream/mecanism/cloudcastle/BossCloudSpawner.java @@ -1,6 +1,7 @@ package fr.openmc.core.features.dream.mecanism.cloudcastle; import fr.openmc.core.OMCPlugin; +import fr.openmc.core.OMCRegistry; import fr.openmc.core.features.dream.DreamUtils; import fr.openmc.core.features.dream.registries.mobs.Breezy; import org.bukkit.Bukkit; @@ -28,7 +29,7 @@ public static void replaceBlockWithBossCloudSpawner(Block block) { if (block.getState() instanceof TrialSpawner spawner) { TrialSpawnerConfiguration normal = spawner.getNormalConfiguration(); - normal.setSpawnedEntity(new Breezy().createSnapshot()); + normal.setSpawnedEntity(OMCRegistry.CUSTOM_MOBS.getMob("omc_dream:breezy").getMobSnapshot()); NamespacedKey lootKey = new NamespacedKey("openmc", "cloud_castle/boss_spawner"); LootTable lootTable = Bukkit.getLootTable(lootKey); diff --git a/src/main/java/fr/openmc/core/features/dream/mecanism/cloudcastle/PhantomCloudSpawner.java b/src/main/java/fr/openmc/core/features/dream/mecanism/cloudcastle/PhantomCloudSpawner.java index 19f5e617d..6f8e7740b 100644 --- a/src/main/java/fr/openmc/core/features/dream/mecanism/cloudcastle/PhantomCloudSpawner.java +++ b/src/main/java/fr/openmc/core/features/dream/mecanism/cloudcastle/PhantomCloudSpawner.java @@ -1,6 +1,6 @@ package fr.openmc.core.features.dream.mecanism.cloudcastle; -import fr.openmc.core.features.dream.registries.mobs.DreamPhantom; +import fr.openmc.core.OMCRegistry; import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.NamespacedKey; @@ -20,7 +20,7 @@ public static void replaceBlockWithMobCloudSpawner(Block block) { if (block.getState() instanceof TrialSpawner spawner) { TrialSpawnerConfiguration normal = spawner.getNormalConfiguration(); - normal.setSpawnedEntity(new DreamPhantom().createSnapshot(block.getLocation())); + normal.setSpawnedEntity(OMCRegistry.CUSTOM_MOBS.getMob("omc_dream:dream_phantom").getMobSnapshot(block.getLocation())); NamespacedKey lootKey = new NamespacedKey("openmc", "cloud_castle/mob_spawner"); LootTable lootTable = Bukkit.getLootTable(lootKey); diff --git a/src/main/java/fr/openmc/core/features/dream/mecanism/cloudcastle/StrayCloudSpawner.java b/src/main/java/fr/openmc/core/features/dream/mecanism/cloudcastle/StrayCloudSpawner.java index c9e343b56..6cf82f291 100644 --- a/src/main/java/fr/openmc/core/features/dream/mecanism/cloudcastle/StrayCloudSpawner.java +++ b/src/main/java/fr/openmc/core/features/dream/mecanism/cloudcastle/StrayCloudSpawner.java @@ -1,6 +1,6 @@ package fr.openmc.core.features.dream.mecanism.cloudcastle; -import fr.openmc.core.features.dream.registries.mobs.DreamStray; +import fr.openmc.core.OMCRegistry; import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.NamespacedKey; @@ -19,7 +19,7 @@ public static void replaceBlockWithMobCloudSpawner(Block block) { if (block.getState() instanceof TrialSpawner spawner) { TrialSpawnerConfiguration normal = spawner.getNormalConfiguration(); - normal.setSpawnedEntity(new DreamStray().createSnapshot()); + normal.setSpawnedEntity(OMCRegistry.CUSTOM_MOBS.getMob("omc_dream:dream_stray").getMobSnapshot()); NamespacedKey lootKey = new NamespacedKey("openmc", "cloud_castle/mob_spawner"); LootTable lootTable = Bukkit.getLootTable(lootKey); diff --git a/src/main/java/fr/openmc/core/features/dream/models/registry/DreamMob.java b/src/main/java/fr/openmc/core/features/dream/models/registry/DreamMob.java index d0ea7a83d..cf3df6b4e 100644 --- a/src/main/java/fr/openmc/core/features/dream/models/registry/DreamMob.java +++ b/src/main/java/fr/openmc/core/features/dream/models/registry/DreamMob.java @@ -1,77 +1,43 @@ package fr.openmc.core.features.dream.models.registry; -import fr.openmc.core.features.dream.registries.DreamMobsRegistry; import fr.openmc.core.registry.loottable.CustomLoot; +import fr.openmc.core.registry.mobs.CustomMob; +import fr.openmc.core.registry.mobs.CustomMobAttribute; import lombok.Getter; -import net.kyori.adventure.text.Component; -import org.bukkit.Location; import org.bukkit.attribute.Attribute; -import org.bukkit.attribute.AttributeInstance; -import org.bukkit.entity.EntityType; import org.bukkit.entity.LivingEntity; -import org.bukkit.event.entity.CreatureSpawnEvent; -import org.bukkit.persistence.PersistentDataType; import java.util.List; @Getter -public abstract class DreamMob { - private final String id; - private final String name; - private final EntityType type; - private final double health; +public abstract class DreamMob extends CustomMob { private final Long damageTime; - private final double speed; - private final double scale; - private final List loots; - public DreamMob(String id, String name, EntityType type, double health, Long damageTime, double speed, double scale, List loots) { - this.id = id; - this.name = name; - this.type = type; - this.health = health; + public DreamMob(String id, String name, Class entityClass, double health, Long damageTime, double speed, double scale) { + super(id, name, entityClass, health, 0f, speed, + new CustomMobAttribute(Attribute.SCALE, scale)); this.damageTime = damageTime; - this.speed = speed; - this.scale = scale; - this.loots = loots; } - public abstract LivingEntity spawn(Location location); - - protected void setAttributeIfPresent(LivingEntity entity, Attribute attribute, double value) { - AttributeInstance attr = entity.getAttribute(attribute); - if (attr != null) { - attr.setBaseValue(value); - } - } - - public DreamMob getMob() { - return this; + public DreamMob(String id, String name, Class entityClass, double health, Long damageTime, double speed, double scale, List loots) { + super(id, name, entityClass, health, 0f, speed, loots, + new CustomMobAttribute(Attribute.SCALE, scale)); + this.damageTime = damageTime; } - public LivingEntity getPreBuildMob(Location spawnLocation) { - LivingEntity livingEntity = (LivingEntity) spawnLocation.getWorld().spawnEntity(spawnLocation.add(0, 1, 0), this.getType(), CreatureSpawnEvent.SpawnReason.CUSTOM); - - applyStats(livingEntity); - - return livingEntity; + public double getScale() { + return this.getBaseAttributes().stream() + .filter(attr -> attr.attribute() == Attribute.SCALE) + .findFirst() + .map(CustomMobAttribute::value) + .orElse(1.0); } - public void applyStats(LivingEntity livingEntity) { - livingEntity.customName(Component.text(this.getName())); - livingEntity.setCustomNameVisible(true); - - this.setAttributeIfPresent(livingEntity, Attribute.MAX_HEALTH, this.getHealth()); - livingEntity.setHealth(this.getHealth()); - - - this.setAttributeIfPresent(livingEntity, Attribute.MOVEMENT_SPEED, this.getSpeed()); - this.setAttributeIfPresent(livingEntity, Attribute.SCALE, this.getScale()); - - livingEntity.getPersistentDataContainer().set( - DreamMobsRegistry.mobKey, - PersistentDataType.STRING, - this.getId() - ); + public double getSpeed() { + return this.getBaseAttributes().stream() + .filter(attr -> attr.attribute() == Attribute.MOVEMENT_SPEED) + .findFirst() + .map(CustomMobAttribute::value) + .orElse(1.0); } } diff --git a/src/main/java/fr/openmc/core/features/dream/registries/DreamBlocksRegistry.java b/src/main/java/fr/openmc/core/features/dream/registries/DreamBlocksRegistry.java index f9ec9c486..be7fbed35 100644 --- a/src/main/java/fr/openmc/core/features/dream/registries/DreamBlocksRegistry.java +++ b/src/main/java/fr/openmc/core/features/dream/registries/DreamBlocksRegistry.java @@ -33,6 +33,7 @@ public static void init() { new CloudVault(), new BossCloudSpawner() ); + ConfigurationSerialization.registerClass(DreamBlock.class); file = new File(OMCPlugin.getInstance().getDataFolder() + "/data/dream", "registered_blocks.yml"); load(); diff --git a/src/main/java/fr/openmc/core/features/dream/registries/DreamMobsRegistry.java b/src/main/java/fr/openmc/core/features/dream/registries/DreamMobsRegistry.java index 92a8f9d34..d42178b32 100644 --- a/src/main/java/fr/openmc/core/features/dream/registries/DreamMobsRegistry.java +++ b/src/main/java/fr/openmc/core/features/dream/registries/DreamMobsRegistry.java @@ -1,21 +1,14 @@ package fr.openmc.core.features.dream.registries; import fr.openmc.core.OMCPlugin; +import fr.openmc.core.OMCRegistry; import fr.openmc.core.features.dream.listeners.registry.DreamMobDamageListener; -import fr.openmc.core.features.dream.listeners.registry.DreamMobLootListener; -import fr.openmc.core.features.dream.models.registry.DreamMob; import fr.openmc.core.features.dream.registries.mobs.*; import fr.openmc.core.features.dream.registries.mobs.listeners.MudBeachMobSpawningListener; import fr.openmc.core.features.dream.registries.mobs.listeners.PlainsMobSpawningListener; import fr.openmc.core.features.dream.registries.mobs.listeners.SoulForestMobSpawningListener; -import org.bukkit.NamespacedKey; -import org.bukkit.entity.Entity; -import org.bukkit.event.Listener; -import org.bukkit.persistence.PersistentDataContainer; -import org.bukkit.persistence.PersistentDataType; - -import java.util.HashMap; -import java.util.Map; +import fr.openmc.core.registry.mobs.CustomMobEntry; +import fr.openmc.core.registry.mobs.listeners.CustomMobDeathListener; /** * Gestionnaire de l'apparition des mobs dans la Dimension des Rêves. @@ -25,49 +18,48 @@ */ public class DreamMobsRegistry { - public static final NamespacedKey mobKey = new NamespacedKey("openmc", "dream_mob"); - - private static final Map mobsByName = new HashMap<>(); - public static void init() { OMCPlugin.registerEvents( new PlainsMobSpawningListener(), new SoulForestMobSpawningListener(), new MudBeachMobSpawningListener(), - new DreamMobLootListener(), + new CustomMobDeathListener(), new DreamMobDamageListener() ); - register(new DreamCreaking()); - register(new DreamSpider()); - register(new Soul()); - register(new DreamStray()); - register(new Breezy()); - register(new DreamPhantom()); - register(new CorruptedTadpole()); - register(new CrazyFrog()); - } - - public static void register(DreamMob mob) { - if (mob instanceof Listener listener) { - OMCPlugin.registerEvents(listener); - } - mobsByName.put(mob.getId(), mob); - } - - public static boolean isDreamMob(Entity entity) { - return entity.getPersistentDataContainer().has(mobKey); - } - - public static DreamMob getByName(String name) { - return mobsByName.get(name); - } - - public static DreamMob getFromEntity(Entity entity) { - PersistentDataContainer pdc = entity.getPersistentDataContainer(); - if (!pdc.has(DreamMobsRegistry.mobKey, PersistentDataType.STRING)) return null; - - String mobId = pdc.get(DreamMobsRegistry.mobKey, PersistentDataType.STRING); - return getByName(mobId); + OMCRegistry.CUSTOM_MOBS.register( + new CustomMobEntry( + "omc_dream:dream_stray", + DreamStray::new + ), + new CustomMobEntry( + "omc_dream:dream_creaking", + DreamCreaking::new + ), + new CustomMobEntry( + "omc_dream:dream_spider", + DreamSpider::new + ), + new CustomMobEntry( + "omc_dream:soul", + Soul::new + ), + new CustomMobEntry( + "omc_dream:breezy", + Breezy::new + ), + new CustomMobEntry( + "omc_dream:dream_phantom", + DreamPhantom::new + ), + new CustomMobEntry( + "omc_dream:corrupted_tadpole", + CorruptedTadpole::new + ), + new CustomMobEntry( + "omc_dream:crazy_frog", + CrazyFrog::new + ) + ); } } diff --git a/src/main/java/fr/openmc/core/features/dream/registries/mobs/Breezy.java b/src/main/java/fr/openmc/core/features/dream/registries/mobs/Breezy.java index 3b6a26472..6db883ed6 100644 --- a/src/main/java/fr/openmc/core/features/dream/registries/mobs/Breezy.java +++ b/src/main/java/fr/openmc/core/features/dream/registries/mobs/Breezy.java @@ -17,29 +17,23 @@ import org.bukkit.util.Vector; import java.util.Comparator; -import java.util.List; -public class Breezy extends DreamMob implements Listener { +public class Breezy extends DreamMob implements Listener { private static final NamespacedKey BREEZY_WIND_CHARGE_KEY = new NamespacedKey(OMCPlugin.getInstance(), "breezy_wind_charge"); - public Breezy() { - super("brezzy", + public Breezy(String id) { + super("omc_dream:brezzy", "Breezy", - EntityType.BREEZE, + Breeze.class, 100.0, 5L, 0.7, - 4.0, - List.of() + 4.0 ); } @Override - public LivingEntity spawn(Location location) { - return null; - } - - public EntitySnapshot createSnapshot() { + public EntitySnapshot getMobSnapshot() { World world = Bukkit.getWorld(DreamDimensionManager.DIMENSION_NAME); if (world == null) return null; Breeze breeze = world.createEntity(new Location(world, 0, 0, 0), Breeze.class); diff --git a/src/main/java/fr/openmc/core/features/dream/registries/mobs/CorruptedTadpole.java b/src/main/java/fr/openmc/core/features/dream/registries/mobs/CorruptedTadpole.java index ef9c0a552..98e2923cb 100644 --- a/src/main/java/fr/openmc/core/features/dream/registries/mobs/CorruptedTadpole.java +++ b/src/main/java/fr/openmc/core/features/dream/registries/mobs/CorruptedTadpole.java @@ -1,49 +1,35 @@ package fr.openmc.core.features.dream.registries.mobs; +import fr.openmc.core.OMCRegistry; import fr.openmc.core.features.dream.models.registry.DreamMob; -import fr.openmc.core.features.dream.registries.DreamMobsRegistry; +import fr.openmc.core.registry.mobs.CustomMob; import fr.openmc.core.utils.RandomUtils; import org.bukkit.Location; -import org.bukkit.entity.Entity; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.LivingEntity; -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; +import org.bukkit.entity.Tadpole; import org.bukkit.event.entity.EntityDeathEvent; -import java.util.List; +public class CorruptedTadpole extends DreamMob { -public class CorruptedTadpole extends DreamMob implements Listener { - - public CorruptedTadpole() { - super("corrupted_tadpole", + public CorruptedTadpole(String id) { + super(id, "Tétard Corrompu", - EntityType.TADPOLE, + Tadpole.class, 25.0, 0L, RandomUtils.randomBetween(0.2, 0.4), - RandomUtils.randomBetween(5, 6.3), - List.of() + RandomUtils.randomBetween(5, 6.3) ); } @Override - public LivingEntity spawn(Location location) { + public Tadpole spawn(Location location) { return this.getPreBuildMob(location); } - @EventHandler - public void onDeath(EntityDeathEvent event) { - Entity entity = event.getEntity(); - if (!DreamMobsRegistry.isDreamMob(entity)) return; - - DreamMob mob = DreamMobsRegistry.getFromEntity(entity); - if (mob == null) return; - if (!mob.getId().equals(this.getId())) return; - - DreamMob crazyFrog = DreamMobsRegistry.getByName("crazy_frog"); - + @Override + public void onDeath(CustomMob thisMob, EntityDeathEvent event) { + CustomMob crazyFrog = OMCRegistry.CUSTOM_MOBS.getMob("omc_dream:crazy_frog"); if (crazyFrog == null) return; - crazyFrog.spawn(entity.getLocation()); + crazyFrog.spawn(event.getEntity().getLocation()); } } \ No newline at end of file diff --git a/src/main/java/fr/openmc/core/features/dream/registries/mobs/CrazyFrog.java b/src/main/java/fr/openmc/core/features/dream/registries/mobs/CrazyFrog.java index 35ed6026d..70dedb983 100644 --- a/src/main/java/fr/openmc/core/features/dream/registries/mobs/CrazyFrog.java +++ b/src/main/java/fr/openmc/core/features/dream/registries/mobs/CrazyFrog.java @@ -5,18 +5,16 @@ import fr.openmc.core.registry.loottable.CustomLoot; import fr.openmc.core.utils.RandomUtils; import org.bukkit.Location; -import org.bukkit.entity.EntityType; import org.bukkit.entity.Frog; -import org.bukkit.entity.LivingEntity; import java.util.List; -public class CrazyFrog extends DreamMob { +public class CrazyFrog extends DreamMob { - public CrazyFrog() { - super("crazy_frog", + public CrazyFrog(String id) { + super(id, "Grenouille Folle", - EntityType.FROG, + Frog.class, 18.0, 0L, RandomUtils.randomBetween(0.2, 0.4), @@ -31,8 +29,8 @@ public CrazyFrog() { } @Override - public LivingEntity spawn(Location location) { - Frog frog = (Frog) this.getPreBuildMob(location); + public Frog spawn(Location location) { + Frog frog = this.getPreBuildMob(location); frog.setVariant(Frog.Variant.WARM); frog.setVelocity(location.getDirection().multiply(1.3)); diff --git a/src/main/java/fr/openmc/core/features/dream/registries/mobs/DreamCreaking.java b/src/main/java/fr/openmc/core/features/dream/registries/mobs/DreamCreaking.java index 5edf5fb44..87d94ef57 100644 --- a/src/main/java/fr/openmc/core/features/dream/registries/mobs/DreamCreaking.java +++ b/src/main/java/fr/openmc/core/features/dream/registries/mobs/DreamCreaking.java @@ -2,31 +2,18 @@ import fr.openmc.core.features.dream.models.registry.DreamMob; import fr.openmc.core.utils.RandomUtils; -import org.bukkit.Location; import org.bukkit.entity.Creaking; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.LivingEntity; -public class DreamCreaking extends DreamMob { +public class DreamCreaking extends DreamMob { - public DreamCreaking() { - super("dream_creaking", + public DreamCreaking(String id) { + super(id, "Creaking Insomiaque", - EntityType.CREAKING, + Creaking.class, 1, 2L, RandomUtils.randomBetween(0.4, 0.6), - RandomUtils.randomBetween(1.2, 1.7), - null + RandomUtils.randomBetween(1.2, 1.7) ); } - - @Override - public LivingEntity spawn(Location location) { - return null; - } - - public void apply(Creaking creaking) { - applyStats(creaking); - } } \ No newline at end of file diff --git a/src/main/java/fr/openmc/core/features/dream/registries/mobs/DreamPhantom.java b/src/main/java/fr/openmc/core/features/dream/registries/mobs/DreamPhantom.java index 91d9a095a..deba57e26 100644 --- a/src/main/java/fr/openmc/core/features/dream/registries/mobs/DreamPhantom.java +++ b/src/main/java/fr/openmc/core/features/dream/registries/mobs/DreamPhantom.java @@ -7,39 +7,30 @@ import org.bukkit.Location; import org.bukkit.World; import org.bukkit.entity.EntitySnapshot; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Phantom; -import java.util.List; - -public class DreamPhantom extends DreamMob { - - public DreamPhantom() { - super("dream_phantom", +@SuppressWarnings("UnstableApiUsage") +public class DreamPhantom extends DreamMob { + public DreamPhantom(String id) { + super(id, "Phantom Réveillé", - EntityType.PHANTOM, + Phantom.class, 10.0, 3L, 0.4, - RandomUtils.randomBetween(0.4, 0.8), - List.of() + RandomUtils.randomBetween(0.4, 0.8) ); } @Override - public LivingEntity spawn(Location location) { - return null; - } - - public EntitySnapshot createSnapshot(Location location) { + public EntitySnapshot getMobSnapshot(Object... args) { World world = Bukkit.getWorld(DreamDimensionManager.DIMENSION_NAME); if (world == null) return null; Phantom phantom = world.createEntity(new Location(world, 0, 0, 0), Phantom.class); applyStats(phantom); - phantom.setAnchorLocation(location); + phantom.setAnchorLocation((Location) args[0]); phantom.setGlowing(true); phantom.setLootTable(null); diff --git a/src/main/java/fr/openmc/core/features/dream/registries/mobs/DreamSpider.java b/src/main/java/fr/openmc/core/features/dream/registries/mobs/DreamSpider.java index 7fd234f6e..64fbe1051 100644 --- a/src/main/java/fr/openmc/core/features/dream/registries/mobs/DreamSpider.java +++ b/src/main/java/fr/openmc/core/features/dream/registries/mobs/DreamSpider.java @@ -5,17 +5,16 @@ import fr.openmc.core.registry.loottable.CustomLoot; import fr.openmc.core.utils.RandomUtils; import org.bukkit.Location; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Spider; import java.util.List; -public class DreamSpider extends DreamMob { +public class DreamSpider extends DreamMob { - public DreamSpider() { - super("dream_spider", + public DreamSpider(String id) { + super(id, "Arraignée Infestée", - EntityType.SPIDER, + Spider.class, 8.0, 1L, RandomUtils.randomBetween(0.2, 0.3), @@ -30,7 +29,7 @@ public DreamSpider() { } @Override - public LivingEntity spawn(Location location) { + public Spider spawn(Location location) { return this.getPreBuildMob(location); } } \ No newline at end of file diff --git a/src/main/java/fr/openmc/core/features/dream/registries/mobs/DreamStray.java b/src/main/java/fr/openmc/core/features/dream/registries/mobs/DreamStray.java index 3b4f48b3e..11ffcae12 100644 --- a/src/main/java/fr/openmc/core/features/dream/registries/mobs/DreamStray.java +++ b/src/main/java/fr/openmc/core/features/dream/registries/mobs/DreamStray.java @@ -7,34 +7,25 @@ import org.bukkit.Location; import org.bukkit.World; import org.bukkit.entity.EntitySnapshot; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Stray; import org.bukkit.inventory.EntityEquipment; import org.bukkit.inventory.EquipmentSlot; -import java.util.List; +public class DreamStray extends DreamMob { -public class DreamStray extends DreamMob { - - public DreamStray() { - super("dream_stray", + public DreamStray(String id) { + super(id, "Stray Endormi", - EntityType.STRAY, + Stray.class, 9.0, 3L, 0.2, - 1.2, - List.of() + 1.2 ); } @Override - public LivingEntity spawn(Location location) { - return null; - } - - public EntitySnapshot createSnapshot() { + public EntitySnapshot getMobSnapshot() { World world = Bukkit.getWorld(DreamDimensionManager.DIMENSION_NAME); if (world == null) return null; Stray stray = world.createEntity(new Location(world, 0, 0, 0), Stray.class); diff --git a/src/main/java/fr/openmc/core/features/dream/registries/mobs/Soul.java b/src/main/java/fr/openmc/core/features/dream/registries/mobs/Soul.java index ef137f724..99fcc07a4 100644 --- a/src/main/java/fr/openmc/core/features/dream/registries/mobs/Soul.java +++ b/src/main/java/fr/openmc/core/features/dream/registries/mobs/Soul.java @@ -3,9 +3,10 @@ import fr.openmc.core.OMCPlugin; import fr.openmc.core.features.dream.models.registry.DreamMob; import fr.openmc.core.features.dream.registries.DreamItemRegistry; -import fr.openmc.core.features.dream.registries.DreamMobsRegistry; import fr.openmc.core.registry.loottable.CustomLoot; +import fr.openmc.core.registry.mobs.CustomMobRegistry; import fr.openmc.core.utils.RandomUtils; +import fr.openmc.core.utils.bukkit.EntityUtils; import fr.openmc.core.utils.bukkit.SkullUtils; import net.kyori.adventure.text.Component; import org.bukkit.Bukkit; @@ -24,22 +25,21 @@ import java.util.List; -public class Soul extends DreamMob { +public class Soul extends DreamMob { - public Soul() { - super("soul", + public Soul(String id) { + super(id, "Âme", - EntityType.ARMOR_STAND, + Vex.class, 2, 3L, RandomUtils.randomBetween(0.4, 0.5), - RandomUtils.randomBetween(0.7, 0.9), - null + RandomUtils.randomBetween(0.7, 0.9) ); } @Override - public LivingEntity spawn(Location location) { + public Vex spawn(Location location) { World world = location.getWorld(); if (world == null) return null; @@ -51,13 +51,13 @@ public LivingEntity spawn(Location location) { vex.getEquipment().clear(); - this.setAttributeIfPresent(vex, Attribute.MAX_HEALTH, this.getHealth()); + EntityUtils.setAttributeIfPresent(vex, Attribute.MAX_HEALTH, this.getHealth()); vex.setHealth(this.getHealth()); - this.setAttributeIfPresent(vex, Attribute.MOVEMENT_SPEED, this.getSpeed()); - this.setAttributeIfPresent(vex, Attribute.SCALE, this.getScale()); + EntityUtils.setAttributeIfPresent(vex, Attribute.MOVEMENT_SPEED, this.getSpeed()); + EntityUtils.setAttributeIfPresent(vex, Attribute.SCALE, this.getScale()); vex.getPersistentDataContainer().set( - DreamMobsRegistry.mobKey, + CustomMobRegistry.CUSTOM_MOB_KEY, PersistentDataType.STRING, this.getId() ); @@ -76,11 +76,11 @@ public LivingEntity spawn(Location location) { "§6§lSoul" )); - this.setAttributeIfPresent(stand, Attribute.MAX_HEALTH, this.getHealth()); + EntityUtils.setAttributeIfPresent(stand, Attribute.MAX_HEALTH, this.getHealth()); stand.setHealth(this.getHealth()); stand.getPersistentDataContainer().set( - DreamMobsRegistry.mobKey, + CustomMobRegistry.CUSTOM_MOB_KEY, PersistentDataType.STRING, this.getId() ); diff --git a/src/main/java/fr/openmc/core/features/dream/registries/mobs/listeners/MudBeachMobSpawningListener.java b/src/main/java/fr/openmc/core/features/dream/registries/mobs/listeners/MudBeachMobSpawningListener.java index 7eb6775fc..f7a6da8ea 100644 --- a/src/main/java/fr/openmc/core/features/dream/registries/mobs/listeners/MudBeachMobSpawningListener.java +++ b/src/main/java/fr/openmc/core/features/dream/registries/mobs/listeners/MudBeachMobSpawningListener.java @@ -1,8 +1,9 @@ package fr.openmc.core.features.dream.registries.mobs.listeners; +import fr.openmc.core.OMCRegistry; import fr.openmc.core.features.dream.DreamUtils; import fr.openmc.core.features.dream.generation.DreamBiome; -import fr.openmc.core.features.dream.registries.DreamMobsRegistry; +import fr.openmc.core.registry.mobs.CustomMobRegistry; import org.bukkit.Location; import org.bukkit.World; import org.bukkit.event.EventHandler; @@ -28,7 +29,7 @@ public class MudBeachMobSpawningListener implements Listener { */ @EventHandler void onCreatureSpawn(CreatureSpawnEvent e) { - if (DreamMobsRegistry.isDreamMob(e.getEntity())) return; + if (CustomMobRegistry.isCustomMob(e.getEntity())) return; Location spawningLoc = e.getEntity().getLocation(); @@ -42,7 +43,7 @@ void onCreatureSpawn(CreatureSpawnEvent e) { double choice = Math.random(); if (choice < CORRUPTED_TADPOLE_PROBABILITY) { - DreamMobsRegistry.getByName("corrupted_tadpole").spawn(spawningLoc); + OMCRegistry.CUSTOM_MOBS.getMob("omc_dream:corrupted_tadpole").spawn(spawningLoc); e.setCancelled(true); } } diff --git a/src/main/java/fr/openmc/core/features/dream/registries/mobs/listeners/PlainsMobSpawningListener.java b/src/main/java/fr/openmc/core/features/dream/registries/mobs/listeners/PlainsMobSpawningListener.java index 1d30238b1..992d0344a 100644 --- a/src/main/java/fr/openmc/core/features/dream/registries/mobs/listeners/PlainsMobSpawningListener.java +++ b/src/main/java/fr/openmc/core/features/dream/registries/mobs/listeners/PlainsMobSpawningListener.java @@ -1,13 +1,12 @@ package fr.openmc.core.features.dream.registries.mobs.listeners; +import fr.openmc.core.OMCRegistry; import fr.openmc.core.features.dream.DreamUtils; import fr.openmc.core.features.dream.generation.DreamBiome; import fr.openmc.core.features.dream.registries.DreamMobsRegistry; -import fr.openmc.core.features.dream.registries.mobs.DreamCreaking; -import fr.openmc.core.features.dream.registries.mobs.DreamSpider; +import fr.openmc.core.registry.mobs.CustomMobRegistry; import org.bukkit.Location; import org.bukkit.World; -import org.bukkit.entity.Creaking; import org.bukkit.entity.EntityType; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -33,7 +32,7 @@ public class PlainsMobSpawningListener implements Listener { */ @EventHandler(priority = EventPriority.MONITOR) void onCreatureSpawn(CreatureSpawnEvent e) { - if (DreamMobsRegistry.isDreamMob(e.getEntity())) return; + if (CustomMobRegistry.isCustomMob(e.getEntity())) return; Location spawningLoc = e.getEntity().getLocation(); @@ -45,13 +44,13 @@ void onCreatureSpawn(CreatureSpawnEvent e) { if (e.getEntity().getType().equals(EntityType.CREAKING)) { e.setCancelled(false); - new DreamCreaking().apply((Creaking) e.getEntity()); + OMCRegistry.CUSTOM_MOBS.getMob("omc_dream:dream_creaking").apply(e.getEntity()); return; } double choice = Math.random(); if (choice < DREAM_SPIDER_PROBABILITY) { - new DreamSpider().spawn(spawningLoc); + OMCRegistry.CUSTOM_MOBS.getMob("omc_dream:dream_spider").spawn(spawningLoc); e.setCancelled(true); } } diff --git a/src/main/java/fr/openmc/core/features/dream/registries/mobs/listeners/SoulForestMobSpawningListener.java b/src/main/java/fr/openmc/core/features/dream/registries/mobs/listeners/SoulForestMobSpawningListener.java index 657bf2ff2..67576b735 100644 --- a/src/main/java/fr/openmc/core/features/dream/registries/mobs/listeners/SoulForestMobSpawningListener.java +++ b/src/main/java/fr/openmc/core/features/dream/registries/mobs/listeners/SoulForestMobSpawningListener.java @@ -1,9 +1,10 @@ package fr.openmc.core.features.dream.registries.mobs.listeners; +import fr.openmc.core.OMCRegistry; import fr.openmc.core.features.dream.DreamUtils; import fr.openmc.core.features.dream.generation.DreamBiome; import fr.openmc.core.features.dream.registries.DreamMobsRegistry; -import fr.openmc.core.features.dream.registries.mobs.Soul; +import fr.openmc.core.registry.mobs.CustomMobRegistry; import org.bukkit.Location; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; @@ -28,7 +29,7 @@ public class SoulForestMobSpawningListener implements Listener { */ @EventHandler void onCreatureSpawn(CreatureSpawnEvent e) { - if (DreamMobsRegistry.isDreamMob(e.getEntity())) return; + if (CustomMobRegistry.isCustomMob(e.getEntity())) return; Location spawningLoc = e.getEntity().getLocation(); @@ -40,7 +41,7 @@ void onCreatureSpawn(CreatureSpawnEvent e) { double choice = Math.random(); if (choice < SOUL_PROBABILITY) { - new Soul().spawn(spawningLoc); + OMCRegistry.CUSTOM_MOBS.getMob("omc_dream:soul").spawn(spawningLoc); e.setCancelled(true); } } diff --git a/src/main/java/fr/openmc/core/registry/mobs/CustomMob.java b/src/main/java/fr/openmc/core/registry/mobs/CustomMob.java new file mode 100644 index 000000000..791f3092e --- /dev/null +++ b/src/main/java/fr/openmc/core/registry/mobs/CustomMob.java @@ -0,0 +1,130 @@ +package fr.openmc.core.registry.mobs; + +import fr.openmc.core.registry.loottable.CustomLoot; +import lombok.Getter; +import net.kyori.adventure.text.Component; +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.World; +import org.bukkit.attribute.Attribute; +import org.bukkit.entity.EntitySnapshot; +import org.bukkit.entity.LivingEntity; +import org.bukkit.event.entity.CreatureSpawnEvent; +import org.bukkit.event.entity.EntityDeathEvent; +import org.bukkit.persistence.PersistentDataType; + +import java.util.*; + +@Getter +public abstract class CustomMob { + private final String id; + private final String name; + private final Class entityClass; + private final Set baseAttributes = new HashSet<>(); + private final List loots = new ArrayList<>(); + + public CustomMob(String id, String name, Class entityClass, double health, double damage, CustomMobAttribute... baseAttributes) { + this.id = id; + this.name = name; + this.entityClass = entityClass; + this.baseAttributes.add(new CustomMobAttribute(Attribute.MAX_HEALTH, health)); + this.baseAttributes.add(new CustomMobAttribute(Attribute.ATTACK_DAMAGE, damage)); + this.baseAttributes.addAll(Arrays.stream(baseAttributes).toList()); + } + + public CustomMob(String id, String name, Class entityClass, double health, double damage, double speed, CustomMobAttribute... baseAttributes) { + this.id = id; + this.name = name; + this.entityClass = entityClass; + this.baseAttributes.add(new CustomMobAttribute(Attribute.MAX_HEALTH, health)); + this.baseAttributes.add(new CustomMobAttribute(Attribute.ATTACK_DAMAGE, damage)); + this.baseAttributes.add(new CustomMobAttribute(Attribute.MOVEMENT_SPEED, speed)); + this.baseAttributes.addAll(Arrays.stream(baseAttributes).toList()); + } + + public CustomMob(String id, String name, Class entityClass, double health, double damage, double speed, List loots, CustomMobAttribute... baseAttributes) { + this.id = id; + this.name = name; + this.entityClass = entityClass; + this.baseAttributes.add(new CustomMobAttribute(Attribute.MAX_HEALTH, health)); + this.baseAttributes.add(new CustomMobAttribute(Attribute.ATTACK_DAMAGE, damage)); + this.baseAttributes.add(new CustomMobAttribute(Attribute.MOVEMENT_SPEED, speed)); + this.baseAttributes.addAll(Arrays.stream(baseAttributes).toList()); + this.loots.addAll(loots); + } + + public CustomMob(String id, String name, Class entityClass, double health, double damage, List loots, CustomMobAttribute... baseAttributes) { + this.id = id; + this.name = name; + this.entityClass = entityClass; + this.baseAttributes.add(new CustomMobAttribute(Attribute.MAX_HEALTH, health)); + this.baseAttributes.add(new CustomMobAttribute(Attribute.ATTACK_DAMAGE, damage)); + this.baseAttributes.addAll(Arrays.stream(baseAttributes).toList()); + this.loots.addAll(loots); + } + + // * peut etre Override + public T spawn(Location location) { + return null; + } + + // * peut etre Override + public void apply(LivingEntity livingEntity) { + applyStats(livingEntity); + } + + // * peut etre Override + public EntitySnapshot getMobSnapshot() { + World world = Bukkit.getWorld("world"); + if (world == null) return null; + T entity = world.createEntity(new Location(world, 0, 0, 0), entityClass); + + applyStats(entity); + + return entity.createSnapshot(); + } + + // * peut etre Override + public EntitySnapshot getMobSnapshot(Object... objects) { + return null; + } + + // * peut etre Override + public T getPreBuildMob(Location spawnLocation) { + T livingEntity = spawnLocation.getWorld().spawn(spawnLocation.add(0, 1, 0), entityClass, null, CreatureSpawnEvent.SpawnReason.CUSTOM); + applyStats(livingEntity); + return livingEntity; + } + + public void onDeath(CustomMob thisMob, EntityDeathEvent event) {} + + public void applyStats(LivingEntity livingEntity) { + livingEntity.customName(Component.text(this.getName())); + livingEntity.setCustomNameVisible(true); + + for (CustomMobAttribute attribute : baseAttributes) { + attribute.setAttributeIfPresent(livingEntity); + } + + livingEntity.setHealth(this.baseAttributes.stream() + .filter(attr -> attr.attribute() == Attribute.MAX_HEALTH) + .findFirst() + .map(CustomMobAttribute::value) + .orElse(livingEntity.getHealth()) + ); + + livingEntity.getPersistentDataContainer().set( + CustomMobRegistry.CUSTOM_MOB_KEY, + PersistentDataType.STRING, + this.getId() + ); + } + + public double getHealth() { + return baseAttributes.stream() + .filter(attr -> attr.attribute() == Attribute.MAX_HEALTH) + .findFirst() + .map(CustomMobAttribute::value) + .orElse(20.0); + } +} diff --git a/src/main/java/fr/openmc/core/registry/mobs/CustomMobAttribute.java b/src/main/java/fr/openmc/core/registry/mobs/CustomMobAttribute.java new file mode 100644 index 000000000..bbf50d1d9 --- /dev/null +++ b/src/main/java/fr/openmc/core/registry/mobs/CustomMobAttribute.java @@ -0,0 +1,12 @@ +package fr.openmc.core.registry.mobs; + +import fr.openmc.core.utils.bukkit.EntityUtils; +import org.bukkit.attribute.Attribute; +import org.bukkit.entity.LivingEntity; + +public record CustomMobAttribute(Attribute attribute, double value) { + + public void setAttributeIfPresent(LivingEntity entity) { + EntityUtils.setAttributeIfPresent(entity, attribute, value); + } +} diff --git a/src/main/java/fr/openmc/core/registry/mobs/CustomMobEntry.java b/src/main/java/fr/openmc/core/registry/mobs/CustomMobEntry.java new file mode 100644 index 000000000..8c36cb70c --- /dev/null +++ b/src/main/java/fr/openmc/core/registry/mobs/CustomMobEntry.java @@ -0,0 +1,8 @@ +package fr.openmc.core.registry.mobs; + +import java.util.function.Function; + +public record CustomMobEntry( + String id, + Function> factory +) { } diff --git a/src/main/java/fr/openmc/core/registry/mobs/CustomMobRegistry.java b/src/main/java/fr/openmc/core/registry/mobs/CustomMobRegistry.java new file mode 100644 index 000000000..f82fad275 --- /dev/null +++ b/src/main/java/fr/openmc/core/registry/mobs/CustomMobRegistry.java @@ -0,0 +1,56 @@ +package fr.openmc.core.registry.mobs; + +import fr.openmc.core.OMCPlugin; +import fr.openmc.core.bootstrap.registries.Registry; +import org.bukkit.NamespacedKey; +import org.bukkit.entity.Entity; +import org.bukkit.event.Listener; +import org.bukkit.persistence.PersistentDataContainer; +import org.bukkit.persistence.PersistentDataType; + +public class CustomMobRegistry extends Registry { + + public static final NamespacedKey CUSTOM_MOB_KEY = + new NamespacedKey("openmc", "custom_mob"); + + @Override + public void postInit() { + // ** REGISTER MOBS ** + } + + public void register(CustomMobEntry mob) { + if (mob.factory().apply(mob.id()) instanceof Listener listener) { + OMCPlugin.registerEvents(listener); + } + register(mob.id(), mob); + } + + public void register(Iterable mobs) { + for (CustomMobEntry mob : mobs) { + register(mob); + } + } + + public void register(CustomMobEntry... mobs) { + for (CustomMobEntry mob : mobs) { + register(mob); + } + } + + public CustomMob getMob(String id) { + CustomMobEntry entry = get(id); + return entry != null ? entry.factory().apply(id) : null; + } + + public CustomMob getMob(Entity entity) { + PersistentDataContainer pdc = entity.getPersistentDataContainer(); + if (!pdc.has(CUSTOM_MOB_KEY, PersistentDataType.STRING)) return null; + + String mobId = pdc.get(CUSTOM_MOB_KEY, PersistentDataType.STRING); + return getMob(mobId); + } + + public static boolean isCustomMob(Entity entity) { + return entity.getPersistentDataContainer().has(CUSTOM_MOB_KEY); + } +} diff --git a/src/main/java/fr/openmc/core/features/dream/listeners/registry/DreamMobLootListener.java b/src/main/java/fr/openmc/core/registry/mobs/listeners/CustomMobDeathListener.java similarity index 63% rename from src/main/java/fr/openmc/core/features/dream/listeners/registry/DreamMobLootListener.java rename to src/main/java/fr/openmc/core/registry/mobs/listeners/CustomMobDeathListener.java index dae6b8a67..c90ab491b 100644 --- a/src/main/java/fr/openmc/core/features/dream/listeners/registry/DreamMobLootListener.java +++ b/src/main/java/fr/openmc/core/registry/mobs/listeners/CustomMobDeathListener.java @@ -1,8 +1,9 @@ -package fr.openmc.core.features.dream.listeners.registry; +package fr.openmc.core.registry.mobs.listeners; -import fr.openmc.core.features.dream.models.registry.DreamMob; -import fr.openmc.core.features.dream.registries.DreamMobsRegistry; +import fr.openmc.core.OMCRegistry; import fr.openmc.core.registry.loottable.CustomLoot; +import fr.openmc.core.registry.mobs.CustomMob; +import fr.openmc.core.registry.mobs.CustomMobRegistry; import org.bukkit.damage.DamageSource; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; @@ -11,7 +12,7 @@ import org.bukkit.event.entity.EntityDeathEvent; import org.bukkit.inventory.ItemStack; -public class DreamMobLootListener implements Listener { +public class CustomMobDeathListener implements Listener { @EventHandler public void onEntityDeath(EntityDeathEvent event) { @@ -19,19 +20,20 @@ public void onEntityDeath(EntityDeathEvent event) { DamageSource source = event.getDamageSource(); - if (!DreamMobsRegistry.isDreamMob(entity)) return; + if (!CustomMobRegistry.isCustomMob(entity)) return; event.getDrops().clear(); event.setDroppedExp(0); if (!(source.getCausingEntity() instanceof Player)) return; - DreamMob dreamMob = DreamMobsRegistry.getFromEntity(entity); - if (dreamMob == null) return; + CustomMob customMob = OMCRegistry.CUSTOM_MOBS.getMob(entity); + if (customMob == null) return; - if (dreamMob.getLoots() == null) return; + customMob.onDeath(customMob, event); - for (CustomLoot loot : dreamMob.getLoots()) { + if (customMob.getLoots() == null) return; + for (CustomLoot loot : customMob.getLoots()) { if (Math.random() >= loot.getChance()) return; int amount = loot.getMinAmount() + (int) (Math.random() * (loot.getMaxAmount() - loot.getMinAmount() + 1)); diff --git a/src/main/java/fr/openmc/core/utils/bukkit/EntityUtils.java b/src/main/java/fr/openmc/core/utils/bukkit/EntityUtils.java new file mode 100644 index 000000000..c32354f7f --- /dev/null +++ b/src/main/java/fr/openmc/core/utils/bukkit/EntityUtils.java @@ -0,0 +1,20 @@ +package fr.openmc.core.utils.bukkit; + +import org.bukkit.attribute.Attribute; +import org.bukkit.attribute.AttributeInstance; +import org.bukkit.entity.LivingEntity; + +public class EntityUtils { + /** + * Ajoute un attribut si l'AttributeInstance n'est pas nulle + * @param entity l'entity + * @param attribute l'attribut qui veut etre mis + * @param value la valeur appliquée a l'attribut + */ + public static void setAttributeIfPresent(LivingEntity entity, Attribute attribute, double value) { + AttributeInstance attr = entity.getAttribute(attribute); + if (attr != null) { + attr.setBaseValue(value); + } + } +} From 4066fb2dd695629b00f7ea385aef2791dfa9e0fc Mon Sep 17 00:00:00 2001 From: iambibi_ <89582596+iambibi@users.noreply.github.com> Date: Mon, 11 May 2026 19:43:24 +0200 Subject: [PATCH 6/6] fix getMobSnapshopt (weird) --- .../cloudcastle/StrayCloudSpawner.java | 19 ++++++++++++++++++- .../dream/registries/mobs/Breezy.java | 4 ++-- .../dream/registries/mobs/DreamStray.java | 3 ++- .../openmc/core/registry/mobs/CustomMob.java | 2 +- 4 files changed, 23 insertions(+), 5 deletions(-) diff --git a/src/main/java/fr/openmc/core/features/dream/mecanism/cloudcastle/StrayCloudSpawner.java b/src/main/java/fr/openmc/core/features/dream/mecanism/cloudcastle/StrayCloudSpawner.java index 6cf82f291..ed96074e9 100644 --- a/src/main/java/fr/openmc/core/features/dream/mecanism/cloudcastle/StrayCloudSpawner.java +++ b/src/main/java/fr/openmc/core/features/dream/mecanism/cloudcastle/StrayCloudSpawner.java @@ -1,11 +1,14 @@ package fr.openmc.core.features.dream.mecanism.cloudcastle; import fr.openmc.core.OMCRegistry; +import fr.openmc.core.bootstrap.integration.OMCLogger; +import fr.openmc.core.registry.mobs.CustomMob; import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.NamespacedKey; import org.bukkit.block.Block; import org.bukkit.block.TrialSpawner; +import org.bukkit.entity.EntitySnapshot; import org.bukkit.loot.LootTable; import org.bukkit.spawner.TrialSpawnerConfiguration; @@ -19,7 +22,21 @@ public static void replaceBlockWithMobCloudSpawner(Block block) { if (block.getState() instanceof TrialSpawner spawner) { TrialSpawnerConfiguration normal = spawner.getNormalConfiguration(); - normal.setSpawnedEntity(OMCRegistry.CUSTOM_MOBS.getMob("omc_dream:dream_stray").getMobSnapshot()); + CustomMob mob = OMCRegistry.CUSTOM_MOBS.getMob("omc_dream:dream_stray"); + + if (mob == null) { + OMCLogger.warn("Mob 'omc_dream:dream_stray' not found in registry"); + return; + } + + EntitySnapshot snapshot = mob.getMobSnapshot(); + + if (snapshot == null) { + OMCLogger.warn("Snapshot for mob 'omc_dream:dream_stray' is null"); + return; + } + + normal.setSpawnedEntity(snapshot); NamespacedKey lootKey = new NamespacedKey("openmc", "cloud_castle/mob_spawner"); LootTable lootTable = Bukkit.getLootTable(lootKey); diff --git a/src/main/java/fr/openmc/core/features/dream/registries/mobs/Breezy.java b/src/main/java/fr/openmc/core/features/dream/registries/mobs/Breezy.java index 6db883ed6..4a41bfa44 100644 --- a/src/main/java/fr/openmc/core/features/dream/registries/mobs/Breezy.java +++ b/src/main/java/fr/openmc/core/features/dream/registries/mobs/Breezy.java @@ -22,7 +22,7 @@ public class Breezy extends DreamMob implements Listener { private static final NamespacedKey BREEZY_WIND_CHARGE_KEY = new NamespacedKey(OMCPlugin.getInstance(), "breezy_wind_charge"); public Breezy(String id) { - super("omc_dream:brezzy", + super(id, "Breezy", Breeze.class, 100.0, @@ -36,7 +36,7 @@ public Breezy(String id) { public EntitySnapshot getMobSnapshot() { World world = Bukkit.getWorld(DreamDimensionManager.DIMENSION_NAME); if (world == null) return null; - Breeze breeze = world.createEntity(new Location(world, 0, 0, 0), Breeze.class); + Mob breeze = world.createEntity(new Location(world, 0, 0, 0), Breeze.class); applyStats(breeze); diff --git a/src/main/java/fr/openmc/core/features/dream/registries/mobs/DreamStray.java b/src/main/java/fr/openmc/core/features/dream/registries/mobs/DreamStray.java index 11ffcae12..ecdee70d6 100644 --- a/src/main/java/fr/openmc/core/features/dream/registries/mobs/DreamStray.java +++ b/src/main/java/fr/openmc/core/features/dream/registries/mobs/DreamStray.java @@ -7,6 +7,7 @@ import org.bukkit.Location; import org.bukkit.World; import org.bukkit.entity.EntitySnapshot; +import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Stray; import org.bukkit.inventory.EntityEquipment; import org.bukkit.inventory.EquipmentSlot; @@ -28,7 +29,7 @@ public DreamStray(String id) { public EntitySnapshot getMobSnapshot() { World world = Bukkit.getWorld(DreamDimensionManager.DIMENSION_NAME); if (world == null) return null; - Stray stray = world.createEntity(new Location(world, 0, 0, 0), Stray.class); + LivingEntity stray = world.createEntity(new Location(world, 0, 0, 0), Stray.class); applyStats(stray); diff --git a/src/main/java/fr/openmc/core/registry/mobs/CustomMob.java b/src/main/java/fr/openmc/core/registry/mobs/CustomMob.java index 791f3092e..a2e162ca1 100644 --- a/src/main/java/fr/openmc/core/registry/mobs/CustomMob.java +++ b/src/main/java/fr/openmc/core/registry/mobs/CustomMob.java @@ -77,7 +77,7 @@ public void apply(LivingEntity livingEntity) { public EntitySnapshot getMobSnapshot() { World world = Bukkit.getWorld("world"); if (world == null) return null; - T entity = world.createEntity(new Location(world, 0, 0, 0), entityClass); + LivingEntity entity = world.createEntity(new Location(world, 0, 0, 0), entityClass); applyStats(entity);