diff --git a/src/main/java/fr/openmc/api/cooldown/DynamicCooldownManager.java b/src/main/java/fr/openmc/api/cooldown/DynamicCooldownManager.java
index 47aea6ea9..0b7dd82cf 100644
--- a/src/main/java/fr/openmc/api/cooldown/DynamicCooldownManager.java
+++ b/src/main/java/fr/openmc/api/cooldown/DynamicCooldownManager.java
@@ -7,13 +7,12 @@
import com.j256.ormlite.table.DatabaseTable;
import com.j256.ormlite.table.TableUtils;
import fr.openmc.core.OMCPlugin;
-import fr.openmc.core.bootstrap.features.Feature;
-import fr.openmc.core.bootstrap.features.types.HasCommands;
-import fr.openmc.core.bootstrap.features.types.HasDatabase;
-import fr.openmc.core.bootstrap.features.types.LoadAfterItemsAdder;
-import fr.openmc.core.bootstrap.integration.OMCLogger;
import fr.openmc.core.commands.debug.DebugCooldownCommand;
import fr.openmc.core.commands.utils.CooldownCommand;
+import fr.openmc.core.lifecycle.integration.OMCLogger;
+import fr.openmc.core.lifecycle.interfaces.HasCommands;
+import fr.openmc.core.lifecycle.interfaces.HasDatabase;
+import fr.openmc.core.registry.features.Feature;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitTask;
@@ -24,7 +23,7 @@
/**
* Main class for managing cooldowns
*/
-public class DynamicCooldownManager extends Feature implements LoadAfterItemsAdder, HasDatabase, HasCommands {
+public class DynamicCooldownManager extends Feature implements HasDatabase, HasCommands {
/**
* Represents a single cooldown with duration and last use time
diff --git a/src/main/java/fr/openmc/api/entity/player/sub/OMCPlayerCity.java b/src/main/java/fr/openmc/api/entity/player/sub/OMCPlayerCity.java
index 34e09e2ea..606bc664c 100644
--- a/src/main/java/fr/openmc/api/entity/player/sub/OMCPlayerCity.java
+++ b/src/main/java/fr/openmc/api/entity/player/sub/OMCPlayerCity.java
@@ -1,18 +1,22 @@
package fr.openmc.api.entity.player.sub;
+import fr.openmc.core.OMCRegistry;
import fr.openmc.core.features.city.City;
import fr.openmc.core.features.city.CityManager;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.Nullable;
public class OMCPlayerCity extends OMCPlayerFeat {
+ private final CityManager cityManager;
+
public OMCPlayerCity(Player player) {
super(player);
+ this.cityManager = OMCRegistry.FEATURES.CITY.get();
}
@Nullable
public City getCity() {
- return CityManager.getCity(getUniqueId());
+ return cityManager.getCity(getUniqueId());
}
public boolean hasCity() {
diff --git a/src/main/java/fr/openmc/api/menulib/Menu.java b/src/main/java/fr/openmc/api/menulib/Menu.java
index fc3212194..c7dfb2499 100644
--- a/src/main/java/fr/openmc/api/menulib/Menu.java
+++ b/src/main/java/fr/openmc/api/menulib/Menu.java
@@ -4,7 +4,7 @@
import fr.openmc.api.menulib.events.OpenMenuEvent;
import fr.openmc.api.menulib.utils.InventorySize;
import fr.openmc.api.menulib.utils.ItemMenuBuilder;
-import fr.openmc.core.hooks.itemsadder.ItemsAdderHook;
+import fr.openmc.core.OMCRegistry;
import fr.openmc.core.utils.bukkit.ItemUtils;
import fr.openmc.core.utils.text.messages.MessageType;
import fr.openmc.core.utils.text.messages.MessagesManager;
@@ -274,7 +274,7 @@ public final boolean isItem(ItemStack item, String itemId) {
public final Inventory getInventory() {
Component title = getName();
- if (ItemsAdderHook.isEnable() && (getTexture() != null && !getTexture().isEmpty()) && getTexture() != null && !getTexture().isEmpty()) {
+ if (OMCRegistry.HOOKS.ITEMS_ADDER.isEnable() && (getTexture() != null && !getTexture().isEmpty()) && getTexture() != null && !getTexture().isEmpty()) {
title = Component.text(getTexture());
}
diff --git a/src/main/java/fr/openmc/api/menulib/MenuLib.java b/src/main/java/fr/openmc/api/menulib/MenuLib.java
index 90db817fd..469d5c4c2 100644
--- a/src/main/java/fr/openmc/api/menulib/MenuLib.java
+++ b/src/main/java/fr/openmc/api/menulib/MenuLib.java
@@ -3,8 +3,8 @@
import fr.openmc.api.menulib.template.ConfirmMenu;
import fr.openmc.api.menulib.utils.ItemMenuBuilder;
import fr.openmc.core.OMCPlugin;
-import fr.openmc.core.bootstrap.integration.OMCLogger;
import fr.openmc.core.features.homes.menu.HomeDeleteConfirmMenu;
+import fr.openmc.core.lifecycle.integration.OMCLogger;
import fr.openmc.core.utils.bukkit.ItemUtils;
import lombok.Getter;
import org.bukkit.Bukkit;
diff --git a/src/main/java/fr/openmc/api/menulib/utils/ItemMenuBuilder.java b/src/main/java/fr/openmc/api/menulib/utils/ItemMenuBuilder.java
index f2d1f6fce..8d1b461dc 100644
--- a/src/main/java/fr/openmc/api/menulib/utils/ItemMenuBuilder.java
+++ b/src/main/java/fr/openmc/api/menulib/utils/ItemMenuBuilder.java
@@ -3,7 +3,7 @@
import fr.openmc.api.menulib.Menu;
import fr.openmc.api.menulib.MenuLib;
import fr.openmc.api.menulib.PaginatedMenu;
-import fr.openmc.core.bootstrap.integration.OMCLogger;
+import fr.openmc.core.lifecycle.integration.OMCLogger;
import fr.openmc.core.registry.items.CustomItem;
import fr.openmc.core.utils.bukkit.ItemBuilder;
import fr.openmc.core.utils.text.messages.MessageType;
diff --git a/src/main/java/fr/openmc/api/packetmenulib/utils/PacketUtils.java b/src/main/java/fr/openmc/api/packetmenulib/utils/PacketUtils.java
index f0bbf1bcf..b18f3958e 100644
--- a/src/main/java/fr/openmc/api/packetmenulib/utils/PacketUtils.java
+++ b/src/main/java/fr/openmc/api/packetmenulib/utils/PacketUtils.java
@@ -4,7 +4,7 @@
import com.comphenix.protocol.ProtocolLibrary;
import com.comphenix.protocol.ProtocolManager;
import com.comphenix.protocol.events.PacketContainer;
-import fr.openmc.core.bootstrap.integration.OMCLogger;
+import fr.openmc.core.lifecycle.integration.OMCLogger;
import io.papermc.paper.adventure.PaperAdventure;
import net.minecraft.network.chat.Component;
import net.minecraft.world.inventory.MenuType;
diff --git a/src/main/java/fr/openmc/core/ListenersManager.java b/src/main/java/fr/openmc/core/ListenersManager.java
index 079783e58..fde3ccc8d 100644
--- a/src/main/java/fr/openmc/core/ListenersManager.java
+++ b/src/main/java/fr/openmc/core/ListenersManager.java
@@ -2,8 +2,8 @@
import fr.openmc.api.input.ChatInput;
import fr.openmc.api.input.location.ItemInteraction;
-import fr.openmc.core.bootstrap.listeners.ListenerFactory;
import fr.openmc.core.features.itemsadder.SpawnerExtractorListener;
+import fr.openmc.core.lifecycle.listeners.ListenerFactory;
import fr.openmc.core.listeners.*;
import fr.openmc.core.utils.nms.entity.EntityGlowNMS;
diff --git a/src/main/java/fr/openmc/core/OMCBootstrap.java b/src/main/java/fr/openmc/core/OMCBootstrap.java
index ccdc6e821..95fae9e40 100644
--- a/src/main/java/fr/openmc/core/OMCBootstrap.java
+++ b/src/main/java/fr/openmc/core/OMCBootstrap.java
@@ -1,14 +1,12 @@
package fr.openmc.core;
-import fr.openmc.core.bootstrap.integration.DatapackLoader;
-import fr.openmc.core.bootstrap.integration.OMCLogger;
import fr.openmc.core.hooks.itemsadder.ItemsAdderHook;
+import fr.openmc.core.lifecycle.integration.DatapackLoader;
+import fr.openmc.core.lifecycle.integration.OMCLogger;
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.registry.event.RegistryEvents;
-import io.papermc.paper.plugin.lifecycle.event.types.LifecycleEvents;
import org.bukkit.plugin.java.JavaPlugin;
import org.jetbrains.annotations.NotNull;
diff --git a/src/main/java/fr/openmc/core/OMCPlugin.java b/src/main/java/fr/openmc/core/OMCPlugin.java
index efb97d041..2d428dae2 100644
--- a/src/main/java/fr/openmc/core/OMCPlugin.java
+++ b/src/main/java/fr/openmc/core/OMCPlugin.java
@@ -1,67 +1,14 @@
package fr.openmc.core;
import com.j256.ormlite.logger.LoggerFactory;
-import fr.openmc.api.cooldown.DynamicCooldownManager;
import fr.openmc.api.menulib.MenuLib;
import fr.openmc.api.packetmenulib.PacketMenuLib;
-import fr.openmc.core.bootstrap.features.Feature;
-import fr.openmc.core.bootstrap.features.FeatureFactory;
-import fr.openmc.core.bootstrap.features.FeatureLoadingType;
-import fr.openmc.core.bootstrap.hooks.Hooks;
-import fr.openmc.core.bootstrap.integration.DatabaseManager;
-import fr.openmc.core.bootstrap.integration.ErrorReporter;
-import fr.openmc.core.bootstrap.integration.OMCLogger;
-import fr.openmc.core.bootstrap.listeners.ListenerFactory;
-import fr.openmc.core.commands.admin.freeze.FreezeManager;
-import fr.openmc.core.commands.utils.SpawnManager;
-import fr.openmc.core.features.adminshop.AdminShopManager;
-import fr.openmc.core.features.analytics.AnalyticsManager;
-import fr.openmc.core.features.animations.AnimationsManager;
-import fr.openmc.core.features.bits.BitsManager;
-import fr.openmc.core.features.chatanimations.ChatAnimationManager;
-import fr.openmc.core.features.city.CityManager;
-import fr.openmc.core.features.city.sub.mascots.MascotsManager;
-import fr.openmc.core.features.cube.multiblocks.MultiBlockManager;
-import fr.openmc.core.features.dimopener.DimensionOpenerManager;
-import fr.openmc.core.features.displays.TabList;
-import fr.openmc.core.features.displays.bossbar.BossbarManager;
-import fr.openmc.core.features.displays.bossbar.contents.HelpConfigManager;
-import fr.openmc.core.features.displays.holograms.HologramLoader;
-import fr.openmc.core.features.displays.scoreboards.ScoreboardManager;
-import fr.openmc.core.features.dream.DreamManager;
-import fr.openmc.core.features.economy.BankManager;
-import fr.openmc.core.features.economy.EconomyManager;
-import fr.openmc.core.features.economy.TransactionsManager;
-import fr.openmc.core.features.events.EventsManager;
-import fr.openmc.core.features.events.contents.dailyevents.DailyEventsManager;
-import fr.openmc.core.features.events.contents.halloween.managers.HalloweenManager;
-import fr.openmc.core.features.events.contents.weeklyevents.WeeklyEventsManager;
-import fr.openmc.core.features.events.contents.weeklyevents.contents.contest.managers.ContestManager;
-import fr.openmc.core.features.friend.FriendManager;
-import fr.openmc.core.features.homes.HomesManager;
-import fr.openmc.core.features.homes.icons.HomeIconCacheManager;
-import fr.openmc.core.features.itemsadder.elevator.ElevatorManager;
-import fr.openmc.core.features.leaderboards.LeaderboardManager;
-import fr.openmc.core.features.mailboxes.MailboxManager;
-import fr.openmc.core.features.mainmenu.MainMenu;
-import fr.openmc.core.features.milestones.MilestonesManager;
-import fr.openmc.core.features.privatemessage.PrivateMessageManager;
-import fr.openmc.core.features.privatemessage.SocialSpyManager;
-import fr.openmc.core.features.profile.ProfileManager;
-import fr.openmc.core.features.quests.QuestProgressSaveManager;
-import fr.openmc.core.features.quests.QuestsManager;
-import fr.openmc.core.features.settings.PlayerSettingsManager;
-import fr.openmc.core.features.shops.managers.ShopManager;
-import fr.openmc.core.features.tickets.TicketManager;
-import fr.openmc.core.features.toor.DiscordLinkManager;
-import fr.openmc.core.features.tpa.TPAManager;
-import fr.openmc.core.features.updates.UpdateManager;
-import fr.openmc.core.hooks.*;
-import fr.openmc.core.hooks.github.GitHubHook;
-import fr.openmc.core.hooks.itemsadder.ItemsAdderHook;
+import fr.openmc.core.lifecycle.integration.DatabaseManager;
+import fr.openmc.core.lifecycle.integration.ErrorReporter;
+import fr.openmc.core.lifecycle.integration.OMCLogger;
+import fr.openmc.core.lifecycle.listeners.ListenerFactory;
import fr.openmc.core.listeners.ItemsAddersListener;
import fr.openmc.core.utils.bukkit.ParticleUtils;
-import fr.openmc.core.utils.text.MotdUtils;
import io.papermc.paper.datapack.Datapack;
import lombok.Getter;
import org.bukkit.Bukkit;
@@ -70,10 +17,7 @@
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
-import java.io.File;
-import java.util.ArrayList;
import java.util.Collection;
-import java.util.List;
/**
* Plugin principal OpenMC.
@@ -87,70 +31,6 @@ public class OMCPlugin extends JavaPlugin {
public static final String VANISH_META_KEY = "omcstaff.vanished";
- // ** Registry of OMC Features
- // () -> : nécessaire si y'a un package d'api externe (ex com.comphenix.protocol)
- public final List REGISTRY_FEATURE = new ArrayList<>(List.of(
- () -> new TicketManager(new File(this.getDataFolder(), "data/stats")),
- PrivateMessageManager::new,
- SocialSpyManager::new,
- SpawnManager::new,
- UpdateManager::new,
- EconomyManager::new,
- BankManager::new,
- BitsManager::new,
- ScoreboardManager::new,
- HomesManager::new,
- TPAManager::new,
- FreezeManager::new,
- TransactionsManager::new,
- AnalyticsManager::new,
- FriendManager::new,
- () -> new TabList(),
- AdminShopManager::new,
- HelpConfigManager::new,
- () -> new AnimationsManager(),
- () -> new HalloweenManager(),
- QuestProgressSaveManager::new,
- MotdUtils::new,
- MascotsManager::new,
- PlayerSettingsManager::new,
- MailboxManager::new,
- DiscordLinkManager::new,
- ProfileManager::new,
- QuestsManager::new,
- CityManager::new,
- DynamicCooldownManager::new,
- ContestManager::new,
- WeeklyEventsManager::new,
- DailyEventsManager::new,
- ChatAnimationManager::new,
- EventsManager::new,
- DreamManager::new,
- MultiBlockManager::new,
- MilestonesManager::new,
- () -> new LeaderboardManager(),
- () -> new MainMenu(),
- () -> new HologramLoader(),
- BossbarManager::new,
- ShopManager::new,
- HomeIconCacheManager::new,
- DimensionOpenerManager::new,
- () -> new ElevatorManager()
- ));
-
- public static final List loadedFeature = new ArrayList<>();
-
- // ** Registry of OMC Plugin Hooks
- public final List REGISTRY_HOOKS = new ArrayList<>(List.of(
- new ProtocolLibHook(),
- new LuckPermsHook(),
- new PapiHook(),
- new WorldGuardHook(),
- new ItemsAdderHook(),
- new FancyNpcsHook(),
- new GitHubHook()
- ));
-
@Override
public void onLoad() {
LoggerFactory.setLogBackendFactory(DatabaseManager.ShutUpOrmLite::new);
@@ -172,12 +52,6 @@ public void onEnable() {
/* EXTERNALS */
MenuLib.init(this);
- /* HOOKS */
- REGISTRY_HOOKS.forEach(Hooks::startInit);
-
- if (!OMCPlugin.isUnitTestVersion() && ProtocolLibHook.isEnable())
- PacketMenuLib.init(this);
-
OMCLogger.logLoadMessage(this);
if (!OMCPlugin.isUnitTestVersion()) {
Datapack pack = this.getServer().getDatapackManager().getPack(getPluginMeta().getName() + "/omc");
@@ -198,16 +72,11 @@ public void onEnable() {
/* REGISTRIES */
OMCRegistry.initAll();
- /* FEATURES */
- REGISTRY_FEATURE
- .forEach(f -> {
- Feature feature = f.create(FeatureLoadingType.RUNTIME);
-
- registerFeature(feature);
- });
+ if (!OMCPlugin.isUnitTestVersion() && OMCRegistry.HOOKS.PROTOCOL_LIB.isEnable())
+ PacketMenuLib.init(this);
// * Si ItemsAdder n'est pas présent, alors on charge les dernières features maintenant
- if (!ItemsAdderHook.isEnable()) {
+ if (!OMCRegistry.HOOKS.ITEMS_ADDER.isEnable()) {
loadAfterItemsAdder();
}
}
@@ -219,20 +88,12 @@ public void loadAfterItemsAdder() {
ItemsAddersListener.setLoaded(true);
/* LOAD ITEMS ADDER CONTENTS */
- ItemsAdderHook.loadContents();
+ OMCRegistry.HOOKS.ITEMS_ADDER.loadContents();
/* REGISTRIES */
OMCRegistry.postInitAll();
- /* FEATURES */
- REGISTRY_FEATURE
- .forEach(f -> {
- Feature feature = f.create(FeatureLoadingType.AFTER_IA);
-
- registerFeature(feature);
- });
-
- if (WorldGuardHook.isEnable()) {
+ if (OMCRegistry.HOOKS.WORLD_GUARD.isEnable()) {
ParticleUtils.spawnParticlesInRegion("spawn", Bukkit.getWorld("world"), Particle.CHERRY_LEAVES, 50, 70, 130);
}
}
@@ -243,13 +104,6 @@ public void loadAfterItemsAdder() {
@Override
public void onDisable() {
// ** SAVE **
- /* HOOKS */
- REGISTRY_HOOKS.forEach(Hooks::startSave);
-
- for (Feature feature : loadedFeature) {
- feature.startSave();
- }
-
/* REGISTRIES */
OMCRegistry.stopAll();
@@ -282,18 +136,6 @@ public static void registerEvents(Collection listeners) {
registerEvents(listeners.toArray(new ListenerFactory[0]));
}
- /**
- * Enregistre une feature dans le registre des features
- *
- * @param feature Feature à register
- */
- public static void registerFeature(Feature feature) {
- if (feature != null) {
- feature.startInit();
- loadedFeature.add(feature);
- }
- }
-
/**
* Indique si le plugin tourne dans les tests unitaires.
*
diff --git a/src/main/java/fr/openmc/core/OMCRegistry.java b/src/main/java/fr/openmc/core/OMCRegistry.java
index 4d271ea61..6ae4e7d6f 100644
--- a/src/main/java/fr/openmc/core/OMCRegistry.java
+++ b/src/main/java/fr/openmc/core/OMCRegistry.java
@@ -1,14 +1,16 @@
package fr.openmc.core;
-import fr.openmc.core.bootstrap.features.types.HasListeners;
-import fr.openmc.core.bootstrap.integration.OMCLogger;
-import fr.openmc.core.bootstrap.registries.LifecycleRegistry;
-import fr.openmc.core.bootstrap.registries.RegistryContext;
-import fr.openmc.core.bootstrap.registries.RegistryLoadingType;
import fr.openmc.core.features.events.contents.dailyevents.DailyEventsRegistry;
import fr.openmc.core.features.events.contents.weeklyevents.WeeklyEventsRegistry;
+import fr.openmc.core.lifecycle.integration.OMCLogger;
+import fr.openmc.core.lifecycle.interfaces.HasListeners;
+import fr.openmc.core.lifecycle.registries.LifecycleRegistry;
+import fr.openmc.core.lifecycle.registries.RegistryContext;
+import fr.openmc.core.lifecycle.registries.RegistryLoadingType;
import fr.openmc.core.registry.ambient.CustomAmbientRegistry;
import fr.openmc.core.registry.enchantments.CustomEnchantmentRegistry;
+import fr.openmc.core.registry.features.FeaturesRegistry;
+import fr.openmc.core.registry.hooks.HooksRegistry;
import fr.openmc.core.registry.items.CustomItemRegistry;
import fr.openmc.core.registry.lootboxes.CustomLootboxRegistry;
import fr.openmc.core.registry.loottable.CustomLootTableRegistry;
@@ -23,6 +25,9 @@
@SuppressWarnings("UnstableApiUsage")
public final class OMCRegistry {
// * Registre globaux
+ public static FeaturesRegistry FEATURES;
+ public static HooksRegistry HOOKS;
+
public static CustomItemRegistry CUSTOM_ITEMS;
public static CustomMobRegistry CUSTOM_MOBS;
public static CustomEnchantmentRegistry CUSTOM_ENCHANTS;
@@ -36,7 +41,10 @@ public final class OMCRegistry {
private static final List LOADED = new ArrayList<>();
- private static final List ALL = List.of(
+ private static final List ALL = new ArrayList<>(List.of(
+ new RegistryContext(
+ () -> HOOKS = new HooksRegistry(),
+ RegistryLoadingType.RUNTIME),
new RegistryContext(
() -> CUSTOM_ITEMS = new CustomItemRegistry(),
RegistryLoadingType.AFTER_IA),
@@ -57,8 +65,11 @@ public final class OMCRegistry {
new RegistryContext(() -> WEEKLY_EVENTS = new WeeklyEventsRegistry(),
RegistryLoadingType.AFTER_IA),
new RegistryContext(() -> DAILY_EVENTS = new DailyEventsRegistry(),
- RegistryLoadingType.AFTER_IA)
- );
+ RegistryLoadingType.AFTER_IA),
+ new RegistryContext(
+ () -> FEATURES = new FeaturesRegistry(),
+ RegistryLoadingType.RUNTIME, RegistryLoadingType.AFTER_IA)
+ ));
private OMCRegistry() {}
diff --git a/src/main/java/fr/openmc/core/bootstrap/features/FeatureFactory.java b/src/main/java/fr/openmc/core/bootstrap/features/FeatureFactory.java
deleted file mode 100644
index b2038b0f9..000000000
--- a/src/main/java/fr/openmc/core/bootstrap/features/FeatureFactory.java
+++ /dev/null
@@ -1,31 +0,0 @@
-package fr.openmc.core.bootstrap.features;
-
-import fr.openmc.core.bootstrap.features.types.LoadAfterItemsAdder;
-import fr.openmc.core.bootstrap.integration.OMCLogger;
-
-@FunctionalInterface
-public interface FeatureFactory {
- Feature create() throws NoClassDefFoundError;
-
- default Feature create(FeatureLoadingType type) {
- Feature feature = null;
- try {
- feature = create();
- } catch (NoClassDefFoundError e) {
- String featureName = "null";
- if (feature != null) {
- featureName = feature.getClass().getSimpleName();
- }
-
- OMCLogger.errorFormatted("Plugin has failed to start feature {} because {} does not exist.",
- featureName, e.getMessage());
- }
-
- if ((type.equals(FeatureLoadingType.RUNTIME) && !(feature instanceof LoadAfterItemsAdder)) ||
- (type.equals(FeatureLoadingType.AFTER_IA) && feature instanceof LoadAfterItemsAdder)
- ) {
- return feature;
- }
- return null;
- }
-}
diff --git a/src/main/java/fr/openmc/core/bootstrap/features/types/HasFeature.java b/src/main/java/fr/openmc/core/bootstrap/features/types/HasFeature.java
deleted file mode 100644
index ab3da5354..000000000
--- a/src/main/java/fr/openmc/core/bootstrap/features/types/HasFeature.java
+++ /dev/null
@@ -1,13 +0,0 @@
-package fr.openmc.core.bootstrap.features.types;
-
-import fr.openmc.core.bootstrap.features.Feature;
-
-/**
- * Interface permettant aux classes d'enregistrer une feature
- */
-public interface HasFeature {
- /**
- * Feature à initialiser
- */
- Feature getFeature();
-}
diff --git a/src/main/java/fr/openmc/core/bootstrap/features/types/LoadAfterItemsAdder.java b/src/main/java/fr/openmc/core/bootstrap/features/types/LoadAfterItemsAdder.java
deleted file mode 100644
index 42aeb603e..000000000
--- a/src/main/java/fr/openmc/core/bootstrap/features/types/LoadAfterItemsAdder.java
+++ /dev/null
@@ -1,6 +0,0 @@
-package fr.openmc.core.bootstrap.features.types;
-
-/**
- * Marque une feature a initialiser apres la disponibilite d'ItemsAdder.
- */
-public interface LoadAfterItemsAdder { }
diff --git a/src/main/java/fr/openmc/core/commands/admin/freeze/FreezeManager.java b/src/main/java/fr/openmc/core/commands/admin/freeze/FreezeManager.java
index f96005122..78a017f2b 100644
--- a/src/main/java/fr/openmc/core/commands/admin/freeze/FreezeManager.java
+++ b/src/main/java/fr/openmc/core/commands/admin/freeze/FreezeManager.java
@@ -1,9 +1,9 @@
package fr.openmc.core.commands.admin.freeze;
-import fr.openmc.core.bootstrap.features.Feature;
-import fr.openmc.core.bootstrap.features.types.HasCommands;
-import fr.openmc.core.bootstrap.features.types.HasListeners;
-import fr.openmc.core.bootstrap.listeners.ListenerFactory;
+import fr.openmc.core.lifecycle.interfaces.HasCommands;
+import fr.openmc.core.lifecycle.interfaces.HasListeners;
+import fr.openmc.core.lifecycle.listeners.ListenerFactory;
+import fr.openmc.core.registry.features.Feature;
import fr.openmc.core.utils.text.messages.MessageType;
import fr.openmc.core.utils.text.messages.MessagesManager;
import fr.openmc.core.utils.text.messages.Prefix;
diff --git a/src/main/java/fr/openmc/core/commands/utils/CooldownCommand.java b/src/main/java/fr/openmc/core/commands/utils/CooldownCommand.java
index 33effac02..7e8a0b5cc 100644
--- a/src/main/java/fr/openmc/core/commands/utils/CooldownCommand.java
+++ b/src/main/java/fr/openmc/core/commands/utils/CooldownCommand.java
@@ -1,8 +1,8 @@
package fr.openmc.core.commands.utils;
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.utils.text.DateUtils;
import fr.openmc.core.utils.text.messages.MessageType;
import fr.openmc.core.utils.text.messages.MessagesManager;
@@ -46,7 +46,7 @@ public void cooldowns(Player sender) {
))
);
- City playerCity = CityManager.getCity(sender.getUniqueId());
+ City playerCity = OMCRegistry.FEATURES.CITY.get().getCity(sender.getUniqueId());
if (playerCity != null) {
DynamicCooldownManager.getCooldowns(playerCity.getUniqueId()).forEach(
diff --git a/src/main/java/fr/openmc/core/commands/utils/Restart.java b/src/main/java/fr/openmc/core/commands/utils/Restart.java
index d752466c1..1f3a83795 100644
--- a/src/main/java/fr/openmc/core/commands/utils/Restart.java
+++ b/src/main/java/fr/openmc/core/commands/utils/Restart.java
@@ -1,8 +1,8 @@
package fr.openmc.core.commands.utils;
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.utils.text.messages.MessageType;
import fr.openmc.core.utils.text.messages.MessagesManager;
import fr.openmc.core.utils.text.messages.Prefix;
@@ -43,7 +43,7 @@ public void restart(CommandSender sender) {
remainingTime = 60;
// protection pour le bug de duplication
- for (City city : CityManager.getCities()) {
+ for (City city : OMCRegistry.FEATURES.CITY.get().getCities()) {
UUID watcherUUID = city.getChestWatcher();
if (watcherUUID == null) continue;
Player player = Bukkit.getPlayer(watcherUUID);
diff --git a/src/main/java/fr/openmc/core/commands/utils/SpawnManager.java b/src/main/java/fr/openmc/core/commands/utils/SpawnManager.java
index c65c872d1..ab29183e6 100644
--- a/src/main/java/fr/openmc/core/commands/utils/SpawnManager.java
+++ b/src/main/java/fr/openmc/core/commands/utils/SpawnManager.java
@@ -1,12 +1,12 @@
package fr.openmc.core.commands.utils;
import fr.openmc.core.OMCPlugin;
-import fr.openmc.core.bootstrap.features.Feature;
-import fr.openmc.core.bootstrap.features.types.HasCommands;
-import fr.openmc.core.bootstrap.features.types.HasListeners;
-import fr.openmc.core.bootstrap.integration.OMCLogger;
-import fr.openmc.core.bootstrap.listeners.ListenerFactory;
+import fr.openmc.core.lifecycle.integration.OMCLogger;
+import fr.openmc.core.lifecycle.interfaces.HasCommands;
+import fr.openmc.core.lifecycle.interfaces.HasListeners;
+import fr.openmc.core.lifecycle.listeners.ListenerFactory;
import fr.openmc.core.listeners.RespawnListener;
+import fr.openmc.core.registry.features.Feature;
import lombok.Getter;
import org.bukkit.Location;
import org.bukkit.World;
diff --git a/src/main/java/fr/openmc/core/features/adminshop/AdminShopCommand.java b/src/main/java/fr/openmc/core/features/adminshop/AdminShopCommand.java
index 1f882ecde..e2282e241 100644
--- a/src/main/java/fr/openmc/core/features/adminshop/AdminShopCommand.java
+++ b/src/main/java/fr/openmc/core/features/adminshop/AdminShopCommand.java
@@ -7,10 +7,16 @@
public class AdminShopCommand {
+ private final AdminShopManager manager;
+
+ public AdminShopCommand(AdminShopManager manager) {
+ this.manager = manager;
+ }
+
@Command("adminshop")
@Description("Ouvrir le menu du shop admin")
@CommandPermission("omc.commands.adminshop")
public void openAdminShop(Player player) {
- AdminShopManager.openMainMenu(player);
+ manager.openMainMenu(player);
}
}
\ No newline at end of file
diff --git a/src/main/java/fr/openmc/core/features/adminshop/AdminShopManager.java b/src/main/java/fr/openmc/core/features/adminshop/AdminShopManager.java
index 87750f44e..f86175556 100644
--- a/src/main/java/fr/openmc/core/features/adminshop/AdminShopManager.java
+++ b/src/main/java/fr/openmc/core/features/adminshop/AdminShopManager.java
@@ -1,13 +1,13 @@
package fr.openmc.core.features.adminshop;
import fr.openmc.core.OMCPlugin;
-import fr.openmc.core.bootstrap.features.Feature;
-import fr.openmc.core.bootstrap.features.annotations.Credit;
-import fr.openmc.core.bootstrap.features.types.HasCommands;
import fr.openmc.core.features.adminshop.events.BuyEvent;
import fr.openmc.core.features.adminshop.events.SellEvent;
import fr.openmc.core.features.adminshop.menus.*;
import fr.openmc.core.features.economy.EconomyManager;
+import fr.openmc.core.lifecycle.interfaces.HasCommands;
+import fr.openmc.core.registry.features.Feature;
+import fr.openmc.core.registry.features.annotations.Credit;
import fr.openmc.core.utils.bukkit.ItemUtils;
import fr.openmc.core.utils.text.messages.MessageType;
import fr.openmc.core.utils.text.messages.MessagesManager;
@@ -26,25 +26,25 @@
*/
@Credit(developers = {"Axeno"}, graphist = {"Gexary"})
public class AdminShopManager extends Feature implements HasCommands {
- public static final Map categories = new HashMap<>();
- public static final Map> items = new HashMap<>(); // Category -> {ShopID -> ShopItem}
- public static final Map currentCategory = new HashMap<>();
- public static final DecimalFormat priceFormat = new DecimalFormat("#,##0.00");
- private static AdminShopYAML adminShopYAML;
+ public final Map categories = new HashMap<>();
+ public final Map> items = new HashMap<>(); // Category -> {ShopID -> ShopItem}
+ public final Map currentCategory = new HashMap<>();
+ public final DecimalFormat priceFormat = new DecimalFormat("#,##0.00");
+ private AdminShopYAML adminShopYAML;
/**
* Initializes the AdminShopManager by loading the configuration.
*/
@Override
public void init() {
- adminShopYAML = new AdminShopYAML();
+ adminShopYAML = new AdminShopYAML(this);
adminShopYAML.loadConfig();
}
@Override
public Set
*/
-public class NotationManager {
+public class NotationManager extends Feature implements HasCommands, HasListeners, HasDatabase {
+ private final CityManager cityManager;
/**
* Jour d'application de la notation.
*/
private static final DayOfWeek APPLY_NOTATION_DAY = DayOfWeek.SUNDAY;
- private static boolean isApplied;
+ private boolean isApplied;
-
- /**
- * Map des notations par semaine (clé : chaine de la semaine, valeur : liste de CityNotation).
- */
- public static final Map> notationPerWeek = new HashMap<>();
+ // Map des notations par semaine (clé : chaine de la semaine, valeur : liste de CityNotation).
+ public final Map> notationPerWeek = new HashMap<>();
- /**
- * Map des notations par ville (clé : UUID de la ville, valeur : liste de CityNotation).
- */
- public static final Map> cityNotations = new HashMap<>();
+ // Map des notations par ville (clé : UUID de la ville, valeur : liste de CityNotation).
+ public final Map> cityNotations = new HashMap<>();
- /**
- * Map des temps d'activité des joueurs (clé : UUID du joueur, valeur : temps).
- */
- public static final Map activityNotation = new HashMap<>();
+ // Map des temps d'activité des joueurs (clé : UUID du joueur, valeur : temps).
+ public final Map activityNotation = new HashMap<>();
- /**
- * Ensemble des 10 meilleures villes.
- */
- public static final Set top10Cities = new HashSet<>();
+ // Ensemble des 10 meilleures villes.
+ public final Set top10Cities = new HashSet<>();
- /**
- * DAO pour la table des temps d'activité.
- */
- private static Dao activityTimePlayedDao;
-
- /**
- * DAO pour la table des notations de ville.
- */
- private static Dao notationDao;
+ private Dao activityTimePlayedDao;
+ private Dao notationDao;
+ public NotationManager(CityManager cityManager) {
+ this.cityManager = cityManager;
+ }
/**
* Constructeur de NotationManager.
*
*
Charge les notations, enregistre les commandes et les listeners, et planifie la tâche nocturne.
*/
- public static void init() {
+ @Override
+ public void init() {
loadNotations();
- CommandsManager.getHandler().register(
- new NotationCommands(),
- new AdminNotationCommands()
- );
- OMCPlugin.registerEvents(
- PlayerJoinListener::new
- );
+
scheduleMidnightTask();
loadTop10Cities();
}
+ @Override
+ public void save() {
+ saveNotations();
+ }
+
/**
* Initialise la base de données pour les notations.
*
* @param connectionSource la source de connexion de la base de données
* @throws SQLException en cas d'erreur SQL
*/
- public static void initDB(ConnectionSource connectionSource) throws SQLException {
+ @Override
+ public void initDB(ConnectionSource connectionSource) throws SQLException {
TableUtils.createTableIfNotExists(connectionSource, CityNotation.class);
notationDao = DaoManager.createDao(connectionSource, CityNotation.class);
@@ -112,15 +105,30 @@ public static void initDB(ConnectionSource connectionSource) throws SQLException
));
}
+ @Override
+ public Set getCommands() {
+ return Set.of(
+ new NotationCommands(),
+ new AdminNotationCommands(cityManager)
+ );
+ }
+
+ @Override
+ public Set getListeners() {
+ return Set.of(
+ PlayerJoinListener::new
+ );
+ }
+
/**
* Charge les notations depuis la base de données et les répartit dans les maps.
*/
- public static void loadNotations() {
+ public void loadNotations() {
try {
List notations = notationDao.queryForAll();
for (CityNotation notation : notations) {
UUID cityUUID = notation.getCityUUID();
- City city = CityManager.getCity(cityUUID);
+ City city = cityManager.getCity(cityUUID);
if (city == null) continue;
String weekStr = notation.getWeekStr();
@@ -135,7 +143,7 @@ public static void loadNotations() {
/**
* Sauvegarde toutes les notations dans la base de données.
*/
- public static void saveNotations() {
+ public void saveNotations() {
try {
notationDao.delete(notationDao.queryForAll());
} catch (SQLException e) {
@@ -158,7 +166,7 @@ public static void saveNotations() {
*
* @param notation la notation à créer ou mettre à jour
*/
- public static void createOrUpdateNotation(CityNotation notation) {
+ public void createOrUpdateNotation(CityNotation notation) {
try {
notationDao.createOrUpdate(notation);
@@ -185,7 +193,7 @@ public static void createOrUpdateNotation(CityNotation notation) {
/**
* Charge les 10 meilleures villes en fonction des notations.
*/
- public static void loadTop10Cities() {
+ public void loadTop10Cities() {
top10Cities.clear();
for (String weekStr : notationPerWeek.keySet()) {
getSortedNotationForWeek(weekStr).stream()
@@ -201,7 +209,7 @@ public static void loadTop10Cities() {
* @param weekStr la chaîne représentant la semaine
* @return liste de notations triées par note architecturale et cohérence, ordre décroissant
*/
- public static List getSortedNotationForWeek(String weekStr) {
+ public List getSortedNotationForWeek(String weekStr) {
List notations = notationPerWeek.getOrDefault(weekStr, Collections.emptyList());
return notations.stream()
.sorted(Comparator.comparingDouble(
@@ -217,7 +225,7 @@ public static List getSortedNotationForWeek(String weekStr) {
* @return le score moyen d'activité des membres de la ville
* @throws SQLException en cas d'erreur SQL
*/
- public static double getActivityScore(City city) throws SQLException {
+ public double getActivityScore(City city) throws SQLException {
double totalScore = 0;
int playerCount = 0;
for (UUID playerUUID : city.getMembers()) {
@@ -242,7 +250,7 @@ public static double getActivityScore(City city) throws SQLException {
* @param city la ville concernée
* @return le score militaire calculé
*/
- public static double getMilitaryScore(City city) {
+ public double getMilitaryScore(City city) {
int powerPoints = city.getPowerPoints();
int maxNote = NotationNote.NOTE_MILITARY.getMaxNote();
int pointsToGetMaxNote = 30;
@@ -263,7 +271,7 @@ public static double getMilitaryScore(City city) {
* @param city la ville concernée
* @return le score économique (entre 0 et 15)
*/
- public static double getEconomyScore(City city) {
+ public double getEconomyScore(City city) {
double totalMoney = 0;
totalMoney += city.getBalance();
@@ -287,13 +295,13 @@ public static double getEconomyScore(City city) {
* @param weekStr la chaîne représentant la semaine
* @throws SQLException en cas d'erreur SQL
*/
- public static void calculateAllCityScore(String weekStr) throws SQLException {
+ public void calculateAllCityScore(String weekStr) throws SQLException {
List notationsCopy = new ArrayList<>(
notationPerWeek.getOrDefault(weekStr, Collections.emptyList())
);
for (CityNotation notation : notationsCopy) {
- City city = CityManager.getCity(notation.getCityUUID());
+ City city = cityManager.getCity(notation.getCityUUID());
notation.setNoteActivity(getActivityScore(city));
notation.setNoteMilitary(getMilitaryScore(city));
double economyScore = getEconomyScore(city);
@@ -308,7 +316,7 @@ public static void calculateAllCityScore(String weekStr) throws SQLException {
* @param notation la notation de la ville
* @return le montant de la récompense
*/
- public static double calculateReward(CityNotation notation) {
+ public double calculateReward(CityNotation notation) {
double points = notation.getTotalNote();
double money = points * (45000.0 / getMaxTotalNote());
@@ -323,11 +331,11 @@ public static double calculateReward(CityNotation notation) {
*
* @param weekStr la chaîne représentant la semaine
*/
- public static void giveReward(String weekStr) {
+ public void giveReward(String weekStr) {
List notations = notationPerWeek.getOrDefault(weekStr, Collections.emptyList());
for (CityNotation notation : notations) {
- City city = CityManager.getCity(notation.getCityUUID());
+ City city = cityManager.getCity(notation.getCityUUID());
if (city != null) {
city.setBalance(city.getBalance() + calculateReward(notation));
}
@@ -337,7 +345,7 @@ public static void giveReward(String weekStr) {
/**
* Planifie l'exécution de la tâche de minuit qui calcule les scores et attribue les récompenses.
*/
- private static void scheduleMidnightTask() {
+ private void scheduleMidnightTask() {
long delayInTicks = DateUtils.getSecondsUntilDayOfWeekTime(APPLY_NOTATION_DAY, 0, 0, 0) * 20;
Bukkit.getScheduler().runTaskLater(OMCPlugin.getInstance(), () -> {
if (!isApplied) {
diff --git a/src/main/java/fr/openmc/core/features/city/sub/notation/commands/AdminNotationCommands.java b/src/main/java/fr/openmc/core/features/city/sub/notation/commands/AdminNotationCommands.java
index 74fff40f2..4d48117bb 100644
--- a/src/main/java/fr/openmc/core/features/city/sub/notation/commands/AdminNotationCommands.java
+++ b/src/main/java/fr/openmc/core/features/city/sub/notation/commands/AdminNotationCommands.java
@@ -18,11 +18,16 @@
import java.util.List;
-import static fr.openmc.core.features.city.sub.notation.NotationManager.calculateAllCityScore;
-import static fr.openmc.core.features.city.sub.notation.NotationManager.giveReward;
-
public class AdminNotationCommands {
+ private final CityManager cityManager;
+ private final NotationManager notationManager;
+
+ public AdminNotationCommands(CityManager cityManager) {
+ this.cityManager = cityManager;
+ this.notationManager = cityManager.NOTATION;
+ }
+
@Command({"admcity notation edit"})
@CommandPermission("omc.admins.commands.admcity.notation")
public void editNotations(Player sender) {
@@ -38,7 +43,7 @@ public void editNotations(Player sender) {
return;
}
- List cities = CityManager.getCities()
+ List cities = cityManager.getCities()
.stream()
.filter(city -> FeaturesRewards.hasUnlockFeature(city, FeaturesRewards.Feature.NOTATION))
.toList();
@@ -61,19 +66,19 @@ public void editNotations(Player sender) {
public void publishNotations(Player sender) {
String weekStr = DateUtils.getWeekFormat();
- if (!NotationManager.notationPerWeek.containsKey(weekStr)) {
+ if (!notationManager.notationPerWeek.containsKey(weekStr)) {
MessagesManager.sendMessage(sender, TranslationManager.translation("feature.city.notation.admin.publish.missing",
Component.text(weekStr)), Prefix.STAFF, MessageType.ERROR, false);
return;
}
try {
- calculateAllCityScore(weekStr);
+ notationManager.calculateAllCityScore(weekStr);
} catch (Exception e) {
throw new RuntimeException(e);
}
- giveReward(weekStr);
+ notationManager.giveReward(weekStr);
MessagesManager.sendMessage(sender, TranslationManager.translation("feature.city.notation.admin.publish.success",
Component.text(weekStr)), Prefix.STAFF, MessageType.ERROR, false);
diff --git a/src/main/java/fr/openmc/core/features/city/sub/rank/CityRankCommands.java b/src/main/java/fr/openmc/core/features/city/sub/rank/CityRankCommands.java
index 80e0d1c14..626bd3923 100644
--- a/src/main/java/fr/openmc/core/features/city/sub/rank/CityRankCommands.java
+++ b/src/main/java/fr/openmc/core/features/city/sub/rank/CityRankCommands.java
@@ -1,5 +1,6 @@
package fr.openmc.core.features.city.sub.rank;
+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;
@@ -22,11 +23,16 @@
@Command({"city ranks", "ville grades"})
public class CityRankCommands {
+ private final CityManager cityManager;
+
+ public CityRankCommands(CityManager cityManager) {
+ this.cityManager = cityManager;
+ }
@CommandPlaceholder()
@CommandPermission("omc.commands.city.rank")
public void rank(Player player) {
- City city = CityManager.getPlayerCity(player.getUniqueId());
+ City city = cityManager.getPlayerCity(player.getUniqueId());
if (city == null) {
MessagesManager.sendMessage(player, TranslationManager.translation("messages.city.player_no_in_city"), Prefix.CITY, MessageType.ERROR, false);
@@ -56,7 +62,7 @@ public void edit(
Player player,
@Named("rank") @SuggestWith(CityRanksAutoComplete.class) String rankName
) {
- City city = CityManager.getPlayerCity(player.getUniqueId());
+ City city = cityManager.getPlayerCity(player.getUniqueId());
if (city == null) {
MessagesManager.sendMessage(player, TranslationManager.translation("messages.city.player_no_in_city"), Prefix.CITY, MessageType.ERROR, false);
return;
@@ -77,7 +83,7 @@ public void edit(
* @param permission The permission to swap.
*/
public static void swapPermission(Player player, DBCityRank rank, CityPermission permission) {
- City city = CityManager.getPlayerCity(player.getUniqueId());
+ City city = OMCRegistry.FEATURES.CITY.get().getPlayerCity(player.getUniqueId());
if (city == null) {
MessagesManager.sendMessage(player, TranslationManager.translation("messages.city.player_no_in_city"), Prefix.CITY, MessageType.ERROR, false);
return;
@@ -104,7 +110,7 @@ public static void swapPermission(Player player, DBCityRank rank, CityPermission
* @param rank The rank to add the permissions to.
*/
public static void addAllPermissions(Player player, DBCityRank rank) {
- City city = CityManager.getPlayerCity(player.getUniqueId());
+ City city = OMCRegistry.FEATURES.CITY.get().getPlayerCity(player.getUniqueId());
if (city == null) {
MessagesManager.sendMessage(player, TranslationManager.translation("messages.city.player_no_in_city"), Prefix.CITY, MessageType.ERROR, false);
return;
@@ -131,7 +137,7 @@ public static void addAllPermissions(Player player, DBCityRank rank) {
* @param rank The rank to remove the permissions from.
*/
public static void removeAllPermissions(Player player, DBCityRank rank) {
- City city = CityManager.getPlayerCity(player.getUniqueId());
+ City city = OMCRegistry.FEATURES.CITY.get().getPlayerCity(player.getUniqueId());
if (city == null) {
MessagesManager.sendMessage(player, TranslationManager.translation("messages.city.player_no_in_city"), Prefix.CITY, MessageType.ERROR, false);
return;
diff --git a/src/main/java/fr/openmc/core/features/city/sub/rank/CityRankManager.java b/src/main/java/fr/openmc/core/features/city/sub/rank/CityRankManager.java
index b49f93370..9229fbc0f 100644
--- a/src/main/java/fr/openmc/core/features/city/sub/rank/CityRankManager.java
+++ b/src/main/java/fr/openmc/core/features/city/sub/rank/CityRankManager.java
@@ -9,15 +9,23 @@
import fr.openmc.core.features.city.City;
import fr.openmc.core.features.city.CityManager;
import fr.openmc.core.features.city.models.DBCityRank;
+import fr.openmc.core.lifecycle.interfaces.HasDatabase;
+import fr.openmc.core.registry.features.Feature;
import java.sql.SQLException;
import java.util.List;
-public class CityRankManager {
-
- private static Dao ranksDao;
+public class CityRankManager extends Feature implements HasDatabase {
+
+ private final CityManager cityManager;
+ private Dao ranksDao;
+
+ public CityRankManager(CityManager cityManager) {
+ this.cityManager = cityManager;
+ }
- public static void init() {
+ @Override
+ public void init() {
loadRanks();
}
@@ -27,7 +35,8 @@ public static void init() {
* @param connectionSource The connection source to the database.
* @throws SQLException If there is an error creating the table or DAO.
*/
- public static void initDB(ConnectionSource connectionSource) throws SQLException {
+ @Override
+ public void initDB(ConnectionSource connectionSource) throws SQLException {
TableUtils.createTableIfNotExists(connectionSource, DBCityRank.class);
ranksDao = DaoManager.createDao(connectionSource, DBCityRank.class);
}
@@ -38,7 +47,7 @@ public static void initDB(ConnectionSource connectionSource) throws SQLException
* @param city The city whose ranks should be removed.
* @throws SQLException If there is an error during the deletion process.
*/
- public static void removeRanks(City city) throws SQLException {
+ public void removeRanks(City city) throws SQLException {
DeleteBuilder ranksDelete = ranksDao.deleteBuilder();
ranksDelete.where().eq("city_uuid", city.getUniqueId());
ranksDao.delete(ranksDelete.prepare());
@@ -49,7 +58,7 @@ public static void removeRanks(City city) throws SQLException {
*
* @param rank The rank to add
*/
- public static void addCityRank(DBCityRank rank) {
+ public void addCityRank(DBCityRank rank) {
try {
ranksDao.create(rank);
} catch (SQLException e) {
@@ -62,7 +71,7 @@ public static void addCityRank(DBCityRank rank) {
*
* @param rank The rank to remove
*/
- public static void removeCityRank(DBCityRank rank) {
+ public void removeCityRank(DBCityRank rank) {
try {
DeleteBuilder delete = ranksDao.deleteBuilder();
delete.where().eq("city_uuid", rank.getCityUUID()).and().eq("name", rank.getName());
@@ -77,7 +86,7 @@ public static void removeCityRank(DBCityRank rank) {
*
* @param rank The rank to update
*/
- public static void updateCityRank(DBCityRank rank) {
+ public void updateCityRank(DBCityRank rank) {
try {
ranksDao.update(rank);
} catch (SQLException e) {
@@ -90,7 +99,7 @@ public static void updateCityRank(DBCityRank rank) {
*
* @param city The city to load ranks for
*/
- public static void loadCityRanks(City city) {
+ public void loadCityRanks(City city) {
try {
QueryBuilder query = ranksDao.queryBuilder();
query.where().eq("city_uuid", city.getUniqueId());
@@ -110,17 +119,17 @@ public static void loadCityRanks(City city) {
* @param rank The rank to copy.
* @return A new instance of DBCityRank with the same properties as the original.
*/
- public static DBCityRank copy(DBCityRank rank) {
+ public DBCityRank copy(DBCityRank rank) {
return new DBCityRank(rank.getRankUUID(), rank.getCityUUID(), rank.getPriority(), rank.getName(), rank.getIcon(), rank.getPermissionsSet(), rank.getMembersSet());
}
/**
* Load all city ranks from the database and associate them with their respective cities.
*/
- public static void loadRanks() {
+ public void loadRanks() {
try {
for (DBCityRank rank : ranksDao.queryForAll()) {
- City city = CityManager.getCity(rank.getCityUUID());
+ City city = cityManager.getCity(rank.getCityUUID());
if (city != null) city.getRanks().add(rank);
}
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 1ece7c6d4..d6cf79d24 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
@@ -7,7 +7,6 @@
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;
@@ -44,7 +43,7 @@ public CityRankPermsMenu(Player owner, DBCityRank oldRank, DBCityRank newRank, b
this.oldRank = oldRank;
this.newRank = newRank;
this.canEdit = canEdit;
- this.city = CityManager.getPlayerCity(owner.getUniqueId());
+ this.city = OMCRegistry.FEATURES.CITY.get().getPlayerCity(owner.getUniqueId());
this.page = page;
}
diff --git a/src/main/java/fr/openmc/core/features/city/sub/statistics/CityStatisticsManager.java b/src/main/java/fr/openmc/core/features/city/sub/statistics/CityStatisticsManager.java
index df52dcfb1..f5220ed9f 100644
--- a/src/main/java/fr/openmc/core/features/city/sub/statistics/CityStatisticsManager.java
+++ b/src/main/java/fr/openmc/core/features/city/sub/statistics/CityStatisticsManager.java
@@ -7,6 +7,8 @@
import com.j256.ormlite.table.TableUtils;
import fr.openmc.core.OMCPlugin;
import fr.openmc.core.features.city.sub.statistics.models.CityStatistics;
+import fr.openmc.core.lifecycle.interfaces.HasDatabase;
+import fr.openmc.core.registry.features.Feature;
import org.bukkit.Bukkit;
import java.io.Serializable;
@@ -18,29 +20,36 @@
*
*
Cette classe gère le chargement, la sauvegarde et la mise à jour asynchrone des statistiques associées à chaque ville.
*/
-public class CityStatisticsManager {
+public class CityStatisticsManager extends Feature implements HasDatabase {
/**
* Map des statistiques par ville (clé : identifiant de la ville, valeur : ensemble de statistiques).
*/
- public static HashMap> cityStatistics = new HashMap<>();
+ public HashMap> cityStatistics = new HashMap<>();
- private static Dao statisticsDao;
+ private Dao statisticsDao;
/**
* Initialise le gestionnaire des statistiques des villes en chargeant les statistiques depuis la base de données.
*/
- public static void init() {
+ @Override
+ public void init() {
loadCityStatistics();
}
+ @Override
+ public void save() {
+ saveCityStatistics();
+ }
+
/**
* Initialise la base de données pour les statistiques des villes.
*
* @param connectionSource la source de connexion
* @throws SQLException en cas d'erreur SQL
*/
- public static void initDB(ConnectionSource connectionSource) throws SQLException {
+ @Override
+ public void initDB(ConnectionSource connectionSource) throws SQLException {
TableUtils.createTableIfNotExists(connectionSource, CityStatistics.class);
statisticsDao = DaoManager.createDao(connectionSource, CityStatistics.class);
}
@@ -48,7 +57,7 @@ public static void initDB(ConnectionSource connectionSource) throws SQLException
/**
* Charge toutes les statistiques depuis la base de données.
*/
- public static void loadCityStatistics() {
+ public void loadCityStatistics() {
try {
List statistics = statisticsDao.queryForAll();
statistics.forEach(statistic -> cityStatistics.computeIfAbsent(statistic.getCityUUID(), k -> new HashSet<>()).add(statistic));
@@ -60,7 +69,7 @@ public static void loadCityStatistics() {
/**
* Sauvegarde toutes les statistiques dans la base de données.
*/
- public static void saveCityStatistics() {
+ public void saveCityStatistics() {
cityStatistics.forEach((city, statistics) -> statistics.forEach(stat -> {
try {
statisticsDao.createOrUpdate(stat);
@@ -76,7 +85,7 @@ public static void saveCityStatistics() {
* @param cityUUID l'identifiant de la ville
* @return l'ensemble des statistiques associées à la ville
*/
- public static Set getOrCreate(UUID cityUUID) {
+ public Set getOrCreate(UUID cityUUID) {
return cityStatistics.computeIfAbsent(cityUUID, k -> new HashSet<>());
}
@@ -87,7 +96,7 @@ public static Set getOrCreate(UUID cityUUID) {
* @param scope le scope de la statistique
* @return la statistique correspondante
*/
- public static CityStatistics getOrCreateStat(UUID cityUUID, String scope) {
+ public CityStatistics getOrCreateStat(UUID cityUUID, String scope) {
Set stats = getOrCreate(cityUUID);
for (CityStatistics stat : stats) {
if (stat != null && scope.equals(stat.getScope())) {
@@ -106,7 +115,7 @@ public static CityStatistics getOrCreateStat(UUID cityUUID, String scope) {
* @param scope le scope de la statistique
* @param value la nouvelle valeur
*/
- public static void setStat(UUID cityUUID, String scope, Serializable value) {
+ public void setStat(UUID cityUUID, String scope, Serializable value) {
CityStatistics stat = getOrCreateStat(cityUUID, scope);
stat.setValue(value);
Bukkit.getScheduler().runTaskAsynchronously(OMCPlugin.getInstance(), () -> {
@@ -123,7 +132,7 @@ public static void setStat(UUID cityUUID, String scope, Serializable value) {
*
* @param cityUUID l'identifiant de la ville
*/
- public static void removeStats(UUID cityUUID) {
+ public void removeStats(UUID cityUUID) {
if (!cityStatistics.containsKey(cityUUID)) return;
cityStatistics.remove(cityUUID);
Bukkit.getScheduler().runTaskAsynchronously(OMCPlugin.getInstance(), () -> {
@@ -144,7 +153,7 @@ public static void removeStats(UUID cityUUID) {
* @param scope le scope de la statistique
* @param amount le montant à ajouter
*/
- public static void increment(UUID cityUUID, String scope, long amount) {
+ public void increment(UUID cityUUID, String scope, long amount) {
CityStatistics stat = getOrCreateStat(cityUUID, scope);
long current = stat.asLong();
stat.setValue(current + amount);
@@ -164,7 +173,7 @@ public static void increment(UUID cityUUID, String scope, long amount) {
* @param scope le scope de la statistique
* @return la valeur de la statistique
*/
- public static Object getStatValue(UUID cityUUID, String scope) {
+ public Object getStatValue(UUID cityUUID, String scope) {
CityStatistics stat = getOrCreateStat(cityUUID, scope);
return stat.getValue();
}
diff --git a/src/main/java/fr/openmc/core/features/city/sub/war/War.java b/src/main/java/fr/openmc/core/features/city/sub/war/War.java
index 138f62a25..849e0a859 100644
--- a/src/main/java/fr/openmc/core/features/city/sub/war/War.java
+++ b/src/main/java/fr/openmc/core/features/city/sub/war/War.java
@@ -1,6 +1,7 @@
package fr.openmc.core.features.city.sub.war;
import fr.openmc.core.OMCPlugin;
+import fr.openmc.core.OMCRegistry;
import fr.openmc.core.features.city.City;
import fr.openmc.core.utils.text.messages.TranslationManager;
import fr.openmc.core.utils.world.LocationUtils;
@@ -176,7 +177,7 @@ public int getCombatTimeRemaining() {
public void end() {
this.phase = WarPhase.ENDED;
- WarManager.endWar(this);
+ OMCRegistry.FEATURES.CITY.get().WAR.endWar(this);
}
/**
diff --git a/src/main/java/fr/openmc/core/features/city/sub/war/WarManager.java b/src/main/java/fr/openmc/core/features/city/sub/war/WarManager.java
index 9c79f2939..46aae2ed6 100644
--- a/src/main/java/fr/openmc/core/features/city/sub/war/WarManager.java
+++ b/src/main/java/fr/openmc/core/features/city/sub/war/WarManager.java
@@ -5,8 +5,7 @@
import com.j256.ormlite.support.ConnectionSource;
import com.j256.ormlite.table.TableUtils;
import fr.openmc.api.cooldown.DynamicCooldownManager;
-import fr.openmc.core.CommandsManager;
-import fr.openmc.core.OMCPlugin;
+import fr.openmc.core.OMCRegistry;
import fr.openmc.core.features.city.City;
import fr.openmc.core.features.city.sub.mascots.models.Mascot;
import fr.openmc.core.features.city.sub.war.commands.AdminWarCommand;
@@ -14,6 +13,11 @@
import fr.openmc.core.features.city.sub.war.listeners.WarKillListener;
import fr.openmc.core.features.city.sub.war.models.WarHistory;
import fr.openmc.core.features.economy.EconomyManager;
+import fr.openmc.core.lifecycle.interfaces.HasCommands;
+import fr.openmc.core.lifecycle.interfaces.HasDatabase;
+import fr.openmc.core.lifecycle.interfaces.HasListeners;
+import fr.openmc.core.lifecycle.listeners.ListenerFactory;
+import fr.openmc.core.registry.features.Feature;
import fr.openmc.core.utils.text.messages.MessagesManager;
import fr.openmc.core.utils.text.messages.TranslationManager;
import fr.openmc.core.utils.world.chunk.ChunkPos;
@@ -28,7 +32,7 @@
import java.util.*;
import java.util.function.BiConsumer;
-public class WarManager {
+public class WarManager extends Feature implements HasListeners, HasCommands, HasDatabase {
public static final int TIME_PREPARATION = 5; // in minutes
public static final int TIME_FIGHT = 30; // in minutes
@@ -36,32 +40,46 @@ public class WarManager {
public static final long CITY_WINNER_IMMUNITY_FIGHT_COOLDOWN = 24 * 60 * 60 * 1000L; // 1 jour en millisecondes
public static final long CITY_DRAW_IMMUNITY_FIGHT_COOLDOWN = 12 * 60 * 60 * 1000L; // 12 heures en millisecondes
- public static final Map warsByAttacker = new HashMap<>();
- public static final Map warsByDefender = new HashMap<>();
+ public final Map warsByAttacker = new HashMap<>();
+ public final Map warsByDefender = new HashMap<>();
- private static final Map pendingDefenses = new HashMap<>();
+ private final Map pendingDefenses = new HashMap<>();
- private static Dao warHistoryDeo;
+ private Dao warHistoryDeo;
- public static final Map warHistory = new HashMap<>();
+ public final Map warHistory = new HashMap<>();
- /**
- * Initializes the WarManager by registering commands and listeners.
- */
- public static void init() {
- CommandsManager.getHandler().register(
- new WarCommand(),
+ @Override
+ public Set getCommands() {
+ return Set.of(
+ new WarCommand(OMCRegistry.FEATURES.CITY.get()),
new AdminWarCommand()
);
+ }
- OMCPlugin.registerEvents(
- WarKillListener::new
+ @Override
+ public Set getListeners() {
+ return Set.of(
+ () -> new WarKillListener(OMCRegistry.FEATURES.CITY.get())
);
+ }
+
+ /**
+ * Initializes the WarManager by registering commands and listeners.
+ */
+ @Override
+ public void init() {
loadWarHistories();
}
- public static void initDB(ConnectionSource connectionSource) throws SQLException {
+ @Override
+ public void save() {
+ saveWarHistories();
+ }
+
+ @Override
+ public void initDB(ConnectionSource connectionSource) throws SQLException {
TableUtils.createTableIfNotExists(connectionSource, WarHistory.class);
warHistoryDeo = DaoManager.createDao(connectionSource, WarHistory.class);
@@ -70,7 +88,7 @@ public static void initDB(ConnectionSource connectionSource) throws SQLException
}
}
- public static void loadWarHistories() {
+ public void loadWarHistories() {
try {
List warHistories = warHistoryDeo.queryForAll();
@@ -84,7 +102,7 @@ public static void loadWarHistories() {
}
}
- public static void saveWarHistories() {
+ public void saveWarHistories() {
warHistory.forEach((cityUUID, warHistory) -> {
try {
warHistoryDeo.createOrUpdate(warHistory);
@@ -95,7 +113,7 @@ public static void saveWarHistories() {
);
}
- public static WarHistory createOrGetWarHistory(City city) throws SQLException {
+ public WarHistory createOrGetWarHistory(City city) throws SQLException {
WarHistory history = warHistory.get(city.getUniqueId());
if (history == null) {
@@ -114,7 +132,7 @@ public static WarHistory createOrGetWarHistory(City city) throws SQLException {
* @param cityUUID The UUID of the city to check.
* @return true if the city is in war, false otherwise.
*/
- public static boolean isCityInWar(UUID cityUUID) {
+ public boolean isCityInWar(UUID cityUUID) {
return warsByAttacker.containsKey(cityUUID) || warsByDefender.containsKey(cityUUID);
}
@@ -124,7 +142,7 @@ public static boolean isCityInWar(UUID cityUUID) {
* @param cityUUID The UUID of the city.
* @return The War object if found, null otherwise.
*/
- public static War getWarByCity(UUID cityUUID) {
+ public War getWarByCity(UUID cityUUID) {
War war = warsByAttacker.get(cityUUID);
if (war != null) return war;
@@ -140,7 +158,7 @@ public static War getWarByCity(UUID cityUUID) {
* @param attackers The list of UUIDs of the players in the attacking city.
* @param defenders The list of UUIDs of the players in the defending city.
*/
- public static void startWar(City attacker, City defender, List attackers, List defenders) {
+ public void startWar(City attacker, City defender, List attackers, List defenders) {
War war = new War(attacker, defender, attackers, defenders);
warsByAttacker.put(attacker.getUniqueId(), war);
@@ -154,7 +172,7 @@ public static void startWar(City attacker, City defender, List attackers,
*
* @param war The War object representing the war to be ended.
*/
- public static void endWar(War war) {
+ public void endWar(War war) {
War warRemoved = warsByAttacker.remove(war.getCityAttacker().getUniqueId());
warsByDefender.remove(war.getCityDefender().getUniqueId());
@@ -289,7 +307,7 @@ public static void endWar(War war) {
* @param bonusMoney Additional bonus money awarded to the winning city.
* @param claimNumber The number of claims transferred to the winning city.
*/
- public static void broadcastWarResult(War war, City winner, City loser, WinReason reason, int powerChange, double amountStolen, double bonusMoney, int claimNumber) {
+ public void broadcastWarResult(War war, City winner, City loser, WinReason reason, int powerChange, double amountStolen, double bonusMoney, int claimNumber) {
int killsWinner = war.getCityAttacker().equals(winner) ? war.getAttackersKill() : war.getDefendersKill();
int killsLoser = war.getCityAttacker().equals(loser) ? war.getAttackersKill() : war.getDefendersKill();
@@ -416,7 +434,7 @@ public static void broadcastWarResult(War war, City winner, City loser, WinReaso
* @param claimAmount The number of chunks to transfer.
* @return The number of chunks actually transferred.
*/
- public static int transferChunksAfterWar(City winner, City loser, int claimAmount) {
+ public int transferChunksAfterWar(City winner, City loser, int claimAmount) {
if (claimAmount <= 0) return 0;
ChunkPos mascotVec = new ChunkPos(
@@ -530,7 +548,7 @@ public static int transferChunksAfterWar(City winner, City loser, int claimAmoun
* @param phase The war phase to format.
* @return A string representing the formatted phase.
*/
- public static String getFormattedPhase(War.WarPhase phase) {
+ public String getFormattedPhase(War.WarPhase phase) {
return switch (phase) {
case PREPARATION -> "Préparation";
case COMBAT -> "Combat";
@@ -543,7 +561,7 @@ public static String getFormattedPhase(War.WarPhase phase) {
*
* @param defense The WarPendingDefense object containing the defense details.
*/
- public static void addPendingDefense(WarPendingDefense defense) {
+ public void addPendingDefense(WarPendingDefense defense) {
pendingDefenses.put(defense.getDefender().getUniqueId(), defense);
}
@@ -552,7 +570,7 @@ public static void addPendingDefense(WarPendingDefense defense) {
*
* @param city The city for which the pending defense is to be removed.
*/
- public static WarPendingDefense getPendingDefenseFor(City city) {
+ public WarPendingDefense getPendingDefenseFor(City city) {
return pendingDefenses.get(city.getUniqueId());
}
diff --git a/src/main/java/fr/openmc/core/features/city/sub/war/actions/WarActions.java b/src/main/java/fr/openmc/core/features/city/sub/war/actions/WarActions.java
index f2a7642f9..7c8f8b662 100644
--- a/src/main/java/fr/openmc/core/features/city/sub/war/actions/WarActions.java
+++ b/src/main/java/fr/openmc/core/features/city/sub/war/actions/WarActions.java
@@ -2,7 +2,7 @@
import fr.openmc.api.menulib.template.ConfirmMenu;
import fr.openmc.core.OMCPlugin;
-import fr.openmc.core.bootstrap.integration.OMCLogger;
+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;
@@ -12,6 +12,7 @@
import fr.openmc.core.features.city.sub.war.WarPendingDefense;
import fr.openmc.core.features.city.sub.war.menu.selection.WarChooseParticipantsMenu;
import fr.openmc.core.features.city.sub.war.menu.selection.WarChooseSizeMenu;
+import fr.openmc.core.lifecycle.integration.OMCLogger;
import fr.openmc.core.utils.text.messages.MessageType;
import fr.openmc.core.utils.text.messages.MessagesManager;
import fr.openmc.core.utils.text.messages.Prefix;
@@ -38,7 +39,9 @@ public class WarActions {
*/
public static void beginLaunchWar(Player player, City cityAttack) {
UUID launcherUUID = player.getUniqueId();
- City launchCity = CityManager.getPlayerCity(launcherUUID);
+ CityManager cityManager = OMCRegistry.FEATURES.CITY.get();
+ WarManager warManager = OMCRegistry.FEATURES.CITY.get().WAR;
+ City launchCity = cityManager.getPlayerCity(launcherUUID);
if (launchCity == null) {
MessagesManager.sendMessage(player, TranslationManager.translation("messages.city.player_no_in_city"), Prefix.CITY, MessageType.ERROR, false);
@@ -75,7 +78,7 @@ public static void beginLaunchWar(Player player, City cityAttack) {
return;
}
- if (WarManager.getPendingDefenseFor(launchCity) != null) {
+ if (warManager.getPendingDefenseFor(launchCity) != null) {
MessagesManager.sendMessage(player,
TranslationManager.translation("feature.city.war.begin.already_declared"),
Prefix.CITY, MessageType.ERROR, false);
@@ -89,7 +92,7 @@ public static void beginLaunchWar(Player player, City cityAttack) {
return;
}
- if (WarManager.getPendingDefenseFor(cityAttack) != null) {
+ if (warManager.getPendingDefenseFor(cityAttack) != null) {
MessagesManager.sendMessage(player,
TranslationManager.translation("feature.city.war.begin.target_preparing"),
Prefix.CITY, MessageType.ERROR, false);
@@ -278,7 +281,7 @@ public static void finishLaunchWar(Player player, City cityLaunch, City cityAtta
), Prefix.CITY, MessageType.INFO, false);
WarPendingDefense pending = new WarPendingDefense(cityLaunch, cityAttack, attackers, requiredParticipants);
- WarManager.addPendingDefense(pending);
+ OMCRegistry.FEATURES.CITY.get().WAR.addPendingDefense(pending);
Bukkit.getScheduler().runTaskLater(OMCPlugin.getInstance(), () -> {
if (pending.isAlreadyExecuted()) return;
@@ -344,6 +347,6 @@ public static void launchWar(City cityLaunch, City cityAttack, List attack
}
}
- WarManager.startWar(cityLaunch, cityAttack, attackers, chosenDefenders);
+ OMCRegistry.FEATURES.CITY.get().WAR.startWar(cityLaunch, cityAttack, attackers, chosenDefenders);
}
}
diff --git a/src/main/java/fr/openmc/core/features/city/sub/war/commands/AdminWarCommand.java b/src/main/java/fr/openmc/core/features/city/sub/war/commands/AdminWarCommand.java
index 2520c47dc..ee7ba698c 100644
--- a/src/main/java/fr/openmc/core/features/city/sub/war/commands/AdminWarCommand.java
+++ b/src/main/java/fr/openmc/core/features/city/sub/war/commands/AdminWarCommand.java
@@ -1,7 +1,7 @@
package fr.openmc.core.features.city.sub.war.commands;
+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.autocomplete.CityNameAutoComplete;
import fr.openmc.core.features.city.sub.war.War;
import fr.openmc.core.utils.text.messages.MessageType;
@@ -24,7 +24,7 @@ void startCombat(
Player player,
@Named("name") @SuggestWith(CityNameAutoComplete.class) String cityName
) {
- City city = CityManager.getCityByName(cityName);
+ City city = OMCRegistry.FEATURES.CITY.get().getCityByName(cityName);
if (city == null) {
MessagesManager.sendMessage(player, TranslationManager.translation("messages.city.not_found"), Prefix.STAFF, MessageType.ERROR, false);
diff --git a/src/main/java/fr/openmc/core/features/city/sub/war/commands/WarCommand.java b/src/main/java/fr/openmc/core/features/city/sub/war/commands/WarCommand.java
index 749f2a0dd..df2c8a94b 100644
--- a/src/main/java/fr/openmc/core/features/city/sub/war/commands/WarCommand.java
+++ b/src/main/java/fr/openmc/core/features/city/sub/war/commands/WarCommand.java
@@ -31,9 +31,17 @@
@Command({"guerre", "war"})
@CommandPermission("omc.commands.city.war")
public class WarCommand {
+ private final CityManager cityManager;
+ private final WarManager warManager;
+
+ public WarCommand(CityManager cityManager) {
+ this.cityManager = cityManager;
+ this.warManager = cityManager.WAR;
+ }
+
@CommandPlaceholder()
void mainCommand(Player player) {
- City playerCity = CityManager.getPlayerCity(player.getUniqueId());
+ City playerCity = cityManager.getPlayerCity(player.getUniqueId());
if (playerCity == null) {
MessagesManager.sendMessage(player, TranslationManager.translation("messages.city.player_no_in_city"), Prefix.CITY, MessageType.ERROR, false);
return;
@@ -72,7 +80,7 @@ void mainCommand(Player player) {
return;
}
- if (WarManager.getPendingDefenseFor(playerCity) != null) {
+ if (warManager.getPendingDefenseFor(playerCity) != null) {
MessagesManager.sendMessage(player,
TranslationManager.translation("feature.city.war.command.already_declared"),
Prefix.CITY, MessageType.ERROR, false);
@@ -93,7 +101,7 @@ void mainCommand(Player player) {
@CommandPermission("omc.commands.city.war.acceptdefense")
@Description("Accepter de participer a une guerre")
public void acceptDefense(Player player) {
- City city = CityManager.getPlayerCity(player.getUniqueId());
+ City city = cityManager.getPlayerCity(player.getUniqueId());
if (city == null) {
MessagesManager.sendMessage(player, TranslationManager.translation("messages.city.player_no_in_city"), Prefix.CITY, MessageType.ERROR, false);
return;
@@ -107,7 +115,7 @@ public void acceptDefense(Player player) {
return;
}
- WarPendingDefense pending = WarManager.getPendingDefenseFor(city);
+ WarPendingDefense pending = warManager.getPendingDefenseFor(city);
if (pending == null) {
MessagesManager.sendMessage(player,
TranslationManager.translation("feature.city.war.command.defense.none"),
diff --git a/src/main/java/fr/openmc/core/features/city/sub/war/listeners/WarKillListener.java b/src/main/java/fr/openmc/core/features/city/sub/war/listeners/WarKillListener.java
index a6fb079ec..dda234a7b 100644
--- a/src/main/java/fr/openmc/core/features/city/sub/war/listeners/WarKillListener.java
+++ b/src/main/java/fr/openmc/core/features/city/sub/war/listeners/WarKillListener.java
@@ -11,6 +11,11 @@
import java.util.UUID;
public class WarKillListener implements Listener {
+ private final CityManager cityManager;
+
+ public WarKillListener(CityManager cityManager) {
+ this.cityManager = cityManager;
+ }
@EventHandler
public void onPlayerDeath(PlayerDeathEvent event) {
@@ -22,8 +27,8 @@ public void onPlayerDeath(PlayerDeathEvent event) {
UUID victimUUID = victim.getUniqueId();
UUID killerUUID = killer.getUniqueId();
- City victimCity = CityManager.getPlayerCity(victimUUID);
- City killerCity = CityManager.getPlayerCity(killerUUID);
+ City victimCity = cityManager.getPlayerCity(victimUUID);
+ City killerCity = cityManager.getPlayerCity(killerUUID);
if (victimCity == null || killerCity == null) return;
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 c2612ea85..a13123ada 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
@@ -6,14 +6,15 @@
import fr.openmc.api.menulib.utils.ItemMenuBuilder;
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.CityType;
import fr.openmc.core.features.city.sub.mascots.models.Mascot;
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.Mayor;
+import fr.openmc.core.features.city.sub.mayor.perks.PerkUtils;
import fr.openmc.core.features.city.sub.mayor.perks.Perks;
import fr.openmc.core.features.city.sub.war.WarManager;
import fr.openmc.core.features.city.sub.war.actions.WarActions;
@@ -41,9 +42,15 @@
import java.util.*;
public class MainWarMenu extends PaginatedMenu {
+ private final CityManager cityManager;
+ private final WarManager warManager;
+ private final MayorManager mayorManager;
public MainWarMenu(Player owner) {
super(owner);
+ this.cityManager = OMCRegistry.FEATURES.CITY.get();
+ this.warManager = cityManager.WAR;
+ this.mayorManager = cityManager.MAYOR;
}
@Override
@@ -70,16 +77,15 @@ public int getSizeOfItems() {
public List getItems() {
List items = new ArrayList<>();
Player player = getOwner();
-
- List warCities = CityManager.getCities().stream()
+ List warCities = cityManager.getCities().stream()
.sorted((c1, c2) -> Integer.compare(c2.getOnlineMembers().size(), c1.getOnlineMembers().size()))
.toList();
for (City city : warCities) {
- if (city.getUniqueId().equals(CityManager.getPlayerCity(player.getUniqueId()).getUniqueId())) continue;
+ if (city.getUniqueId().equals(cityManager.getPlayerCity(player.getUniqueId()).getUniqueId())) continue;
if (city.getType() != CityType.WAR) continue;
if (city.isImmune()) continue;
- if (WarManager.getPendingDefenseFor(city) != null) continue;
+ if (warManager.getPendingDefenseFor(city) != null) continue;
if (city.isInWar()) continue;
long onlineCount = city.getOnlineMembers().size();
@@ -113,10 +119,10 @@ public List getItems() {
));
Mayor mayor = city.getMayor();
- if (MayorManager.phaseMayor == 2 && mayor != null) {
- Perks perk1 = PerkManager.getPerkById(mayor.getIdPerk1());
- Perks perk2 = PerkManager.getPerkById(mayor.getIdPerk2());
- Perks perk3 = PerkManager.getPerkById(mayor.getIdPerk3());
+ if (mayorManager.phaseMayor == 2 && mayor != null) {
+ Perks perk1 = PerkUtils.getPerkById(mayor.getIdPerk1());
+ Perks perk2 = PerkUtils.getPerkById(mayor.getIdPerk2());
+ Perks perk3 = PerkUtils.getPerkById(mayor.getIdPerk3());
loreCity.add(TranslationManager.translation("feature.city.war.menu.main.reforms").color(NamedTextColor.GRAY));
if (perk1 != null) loreCity.add(Component.text(" - ")
diff --git a/src/main/java/fr/openmc/core/features/city/sub/war/menu/main/WarCityDetailsMenu.java b/src/main/java/fr/openmc/core/features/city/sub/war/menu/main/WarCityDetailsMenu.java
index 44ffff6c6..612cb4dd0 100644
--- a/src/main/java/fr/openmc/core/features/city/sub/war/menu/main/WarCityDetailsMenu.java
+++ b/src/main/java/fr/openmc/core/features/city/sub/war/menu/main/WarCityDetailsMenu.java
@@ -7,8 +7,8 @@
import fr.openmc.core.features.city.CityType;
import fr.openmc.core.features.city.sub.mascots.models.Mascot;
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.Mayor;
+import fr.openmc.core.features.city.sub.mayor.perks.PerkUtils;
import fr.openmc.core.features.city.sub.mayor.perks.Perks;
import fr.openmc.core.features.economy.EconomyManager;
import fr.openmc.core.utils.text.messages.TranslationManager;
@@ -68,9 +68,9 @@ public void onInventoryClick(InventoryClickEvent inventoryClickEvent) {
Mayor mayor = city.getMayor();
if (MayorManager.phaseMayor == 2 && mayor != null) {
- Perks perk1 = PerkManager.getPerkById(mayor.getIdPerk1());
- Perks perk2 = PerkManager.getPerkById(mayor.getIdPerk2());
- Perks perk3 = PerkManager.getPerkById(mayor.getIdPerk3());
+ Perks perk1 = PerkUtils.getPerkById(mayor.getIdPerk1());
+ Perks perk2 = PerkUtils.getPerkById(mayor.getIdPerk2());
+ Perks perk3 = PerkUtils.getPerkById(mayor.getIdPerk3());
ItemStack iaPerk1 = (perk1 != null) ? perk1.getItemStack() : ItemStack.of(Material.DEAD_BRAIN_CORAL_BLOCK);
Component namePerk1 = (perk1 != null) ? TranslationManager.translation(perk1.getNameKey()) :
diff --git a/src/main/java/fr/openmc/core/features/city/view/CityViewManager.java b/src/main/java/fr/openmc/core/features/city/view/CityViewManager.java
index eb2db322d..3845d94e3 100644
--- a/src/main/java/fr/openmc/core/features/city/view/CityViewManager.java
+++ b/src/main/java/fr/openmc/core/features/city/view/CityViewManager.java
@@ -1,9 +1,9 @@
package fr.openmc.core.features.city.view;
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.hooks.WorldGuardHook;
import fr.openmc.core.utils.bukkit.ParticleUtils;
import fr.openmc.core.utils.text.messages.MessageType;
import fr.openmc.core.utils.text.messages.MessagesManager;
@@ -55,7 +55,7 @@ public static void startView(@NotNull Player player) {
);
}
- City playerCity = CityManager.getPlayerCity(player.getUniqueId());
+ City playerCity = OMCRegistry.FEATURES.CITY.get().getPlayerCity(player.getUniqueId());
ScheduledTask task = createViewTask(player, playerCity);
activeViewers.put(player.getUniqueId(), new CityViewData(task, claimsToShow));
@@ -117,6 +117,7 @@ public static void updateView(@NotNull UUID playerUUID) {
private static Object2ObjectMap collectClaimsInRadius(@NotNull Player player) {
Object2ObjectMap claims = new Object2ObjectOpenHashMap<>();
ChunkPos playerChunk = ChunkPos.fromChunk(player.getChunk());
+ CityManager cityManager = OMCRegistry.FEATURES.CITY.get();
for (int x = -VIEW_RADIUS_CHUNKS; x <= VIEW_RADIUS_CHUNKS; x++) {
for (int z = -VIEW_RADIUS_CHUNKS; z <= VIEW_RADIUS_CHUNKS; z++) {
@@ -124,7 +125,7 @@ private static Object2ObjectMap collectClaimsInRadius(@NotNull P
int chunkZ = playerChunk.z() + z;
ChunkPos claim = new ChunkPos(chunkX, chunkZ);
- City city = CityManager.getCityFromChunk(claim);
+ City city = cityManager.getCityFromChunk(claim);
if (city == null)
continue;
@@ -149,7 +150,7 @@ private static ScheduledTask createViewTask(@NotNull Player player, @Nullable Ci
return;
viewData.claims().forEach((chunkPos, city) -> {
- showChunkBorders(player, chunkPos, city, city.equals(playerCity), WorldGuardHook.doesChunkContainWGRegion(chunkPos.getChunkInWorld()), player.getLocation().getBlockY() + 1);
+ showChunkBorders(player, chunkPos, city, city.equals(playerCity), OMCRegistry.HOOKS.WORLD_GUARD.doesChunkContainWGRegion(chunkPos.getChunkInWorld()), player.getLocation().getBlockY() + 1);
});
}, 0L, VIEW_INTERVAL_SECONDS, TimeUnit.SECONDS);
}
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 e34f31f69..f46df1259 100644
--- a/src/main/java/fr/openmc/core/features/credits/Credits.java
+++ b/src/main/java/fr/openmc/core/features/credits/Credits.java
@@ -1,12 +1,10 @@
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;
import fr.openmc.core.features.animations.AnimationsManager;
-import fr.openmc.core.features.chatanimations.ChatAnimationManager;
import fr.openmc.core.features.bits.BitsManager;
+import fr.openmc.core.features.chatanimations.ChatAnimationManager;
import fr.openmc.core.features.city.CityManager;
import fr.openmc.core.features.city.sub.mascots.MascotsManager;
import fr.openmc.core.features.displays.holograms.HologramLoader;
@@ -29,6 +27,8 @@
import fr.openmc.core.features.shops.managers.ShopManager;
import fr.openmc.core.features.tickets.TicketManager;
import fr.openmc.core.features.tpa.TPAManager;
+import fr.openmc.core.registry.features.Feature;
+import fr.openmc.core.registry.features.annotations.Credit;
import fr.openmc.core.registry.items.CustomItem;
import lombok.Getter;
import org.bukkit.Material;
diff --git a/src/main/java/fr/openmc/core/features/cube/multiblocks/MultiBlockManager.java b/src/main/java/fr/openmc/core/features/cube/multiblocks/MultiBlockManager.java
index 1e18f78e2..15959e7c7 100644
--- a/src/main/java/fr/openmc/core/features/cube/multiblocks/MultiBlockManager.java
+++ b/src/main/java/fr/openmc/core/features/cube/multiblocks/MultiBlockManager.java
@@ -1,19 +1,17 @@
package fr.openmc.core.features.cube.multiblocks;
import fr.openmc.core.OMCPlugin;
-import fr.openmc.core.bootstrap.features.Feature;
-import fr.openmc.core.bootstrap.features.types.HasCommands;
-import fr.openmc.core.bootstrap.features.types.HasListeners;
-import fr.openmc.core.bootstrap.features.types.LoadAfterItemsAdder;
-import fr.openmc.core.bootstrap.features.types.NotLoadInUnitTest;
-import fr.openmc.core.bootstrap.integration.OMCLogger;
-import fr.openmc.core.bootstrap.listeners.ListenerFactory;
import fr.openmc.core.features.cube.Cube;
import fr.openmc.core.features.cube.commands.CubeCommands;
import fr.openmc.core.features.cube.listeners.CubeListener;
import fr.openmc.core.features.cube.listeners.RepulseEffectListener;
import fr.openmc.core.features.dream.DreamDimensionManager;
import fr.openmc.core.features.dream.DreamUtils;
+import fr.openmc.core.lifecycle.integration.OMCLogger;
+import fr.openmc.core.lifecycle.interfaces.HasCommands;
+import fr.openmc.core.lifecycle.interfaces.HasListeners;
+import fr.openmc.core.lifecycle.listeners.ListenerFactory;
+import fr.openmc.core.registry.features.Feature;
import lombok.Getter;
import org.bukkit.Bukkit;
import org.bukkit.Location;
@@ -26,7 +24,7 @@
import java.io.IOException;
import java.util.*;
-public class MultiBlockManager extends Feature implements LoadAfterItemsAdder, NotLoadInUnitTest, HasListeners, HasCommands {
+public class MultiBlockManager extends Feature implements HasListeners, HasCommands {
@Getter
public static final List multiBlocks = new ArrayList<>();
private static FileConfiguration config = null;
diff --git a/src/main/java/fr/openmc/core/features/dimopener/DimensionOpenerManager.java b/src/main/java/fr/openmc/core/features/dimopener/DimensionOpenerManager.java
index e927baf7c..966e4518d 100644
--- a/src/main/java/fr/openmc/core/features/dimopener/DimensionOpenerManager.java
+++ b/src/main/java/fr/openmc/core/features/dimopener/DimensionOpenerManager.java
@@ -4,17 +4,16 @@
import com.google.gson.GsonBuilder;
import fr.openmc.core.OMCPlugin;
import fr.openmc.core.OMCRegistry;
-import fr.openmc.core.bootstrap.features.Feature;
-import fr.openmc.core.bootstrap.features.types.HasCommands;
-import fr.openmc.core.bootstrap.features.types.HasListeners;
-import fr.openmc.core.bootstrap.features.types.LoadAfterItemsAdder;
-import fr.openmc.core.bootstrap.integration.OMCLogger;
-import fr.openmc.core.bootstrap.listeners.ListenerFactory;
import fr.openmc.core.features.dimopener.commands.DimensionCommands;
import fr.openmc.core.features.dimopener.data.DimensionData;
import fr.openmc.core.features.dimopener.data.StepDimensionData;
import fr.openmc.core.features.dimopener.listener.DimensionAccessListener;
import fr.openmc.core.features.economy.EconomyManager;
+import fr.openmc.core.lifecycle.integration.OMCLogger;
+import fr.openmc.core.lifecycle.interfaces.HasCommands;
+import fr.openmc.core.lifecycle.interfaces.HasListeners;
+import fr.openmc.core.lifecycle.listeners.ListenerFactory;
+import fr.openmc.core.registry.features.Feature;
import fr.openmc.core.registry.items.CustomItem;
import fr.openmc.core.utils.FilesUtils;
import fr.openmc.core.utils.text.messages.MessageType;
@@ -42,7 +41,7 @@
import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Collectors;
-public class DimensionOpenerManager extends Feature implements HasListeners, HasCommands, LoadAfterItemsAdder {
+public class DimensionOpenerManager extends Feature implements HasListeners, HasCommands {
private static final Gson GSON = new GsonBuilder().setPrettyPrinting().create();
private static final String DIMENSIONS_FOLDER = "data/dimensions";
diff --git a/src/main/java/fr/openmc/core/features/displays/TabList.java b/src/main/java/fr/openmc/core/features/displays/TabList.java
index 3fd9c67c4..62f9d2e73 100644
--- a/src/main/java/fr/openmc/core/features/displays/TabList.java
+++ b/src/main/java/fr/openmc/core/features/displays/TabList.java
@@ -9,12 +9,9 @@
import com.comphenix.protocol.events.PacketEvent;
import dev.lone.itemsadder.api.FontImages.FontImageWrapper;
import fr.openmc.core.OMCPlugin;
-import fr.openmc.core.bootstrap.features.Feature;
-import fr.openmc.core.bootstrap.features.types.LoadIfEnable;
-import fr.openmc.core.bootstrap.features.types.NotLoadInUnitTest;
import fr.openmc.core.features.dream.DreamUtils;
-import fr.openmc.core.hooks.ProtocolLibHook;
import fr.openmc.core.hooks.itemsadder.ItemsAdderHook;
+import fr.openmc.core.registry.features.Feature;
import fr.openmc.core.utils.text.messages.TranslationManager;
import io.papermc.paper.adventure.PaperAdventure;
import net.kyori.adventure.text.Component;
@@ -29,7 +26,7 @@
import java.util.List;
import java.util.UUID;
-public class TabList extends Feature implements NotLoadInUnitTest, LoadIfEnable {
+public class TabList extends Feature {
private static ProtocolManager protocolManager = null;
@Override
diff --git a/src/main/java/fr/openmc/core/features/displays/bossbar/BossbarManager.java b/src/main/java/fr/openmc/core/features/displays/bossbar/BossbarManager.java
index 2e233905d..cc2d00615 100644
--- a/src/main/java/fr/openmc/core/features/displays/bossbar/BossbarManager.java
+++ b/src/main/java/fr/openmc/core/features/displays/bossbar/BossbarManager.java
@@ -1,13 +1,12 @@
package fr.openmc.core.features.displays.bossbar;
import fr.openmc.core.OMCPlugin;
-import fr.openmc.core.bootstrap.features.Feature;
-import fr.openmc.core.bootstrap.features.types.HasCommands;
-import fr.openmc.core.bootstrap.features.types.LoadAfterItemsAdder;
import fr.openmc.core.features.displays.bossbar.commands.BossBarCommand;
import fr.openmc.core.features.displays.bossbar.contents.MainBossbar;
import fr.openmc.core.features.dream.displays.DreamBossBar;
import fr.openmc.core.features.events.contents.dailyevents.display.DailyEventBossbar;
+import fr.openmc.core.lifecycle.interfaces.HasCommands;
+import fr.openmc.core.registry.features.Feature;
import net.kyori.adventure.bossbar.BossBar;
import net.kyori.adventure.text.Component;
import org.bukkit.Bukkit;
@@ -19,7 +18,7 @@
/**
* Gère l'enregistrement, l'affichage et la mise à jour des boss bars.
*/
-public class BossbarManager extends Feature implements HasCommands, LoadAfterItemsAdder {
+public class BossbarManager extends Feature implements HasCommands {
private static final List registeredBossbar = new ArrayList<>();
private static final Map> activeBossbars = new HashMap<>();
diff --git a/src/main/java/fr/openmc/core/features/displays/bossbar/contents/HelpConfigManager.java b/src/main/java/fr/openmc/core/features/displays/bossbar/contents/HelpConfigManager.java
index aea1d4833..209eea7da 100644
--- a/src/main/java/fr/openmc/core/features/displays/bossbar/contents/HelpConfigManager.java
+++ b/src/main/java/fr/openmc/core/features/displays/bossbar/contents/HelpConfigManager.java
@@ -1,8 +1,8 @@
package fr.openmc.core.features.displays.bossbar.contents;
import fr.openmc.core.OMCPlugin;
-import fr.openmc.core.bootstrap.features.Feature;
-import fr.openmc.core.bootstrap.integration.OMCLogger;
+import fr.openmc.core.lifecycle.integration.OMCLogger;
+import fr.openmc.core.registry.features.Feature;
import lombok.Getter;
import org.bukkit.configuration.file.YamlConfiguration;
diff --git a/src/main/java/fr/openmc/core/features/displays/holograms/HologramLoader.java b/src/main/java/fr/openmc/core/features/displays/holograms/HologramLoader.java
index e0b63fcdb..ea13a6ed9 100644
--- a/src/main/java/fr/openmc/core/features/displays/holograms/HologramLoader.java
+++ b/src/main/java/fr/openmc/core/features/displays/holograms/HologramLoader.java
@@ -1,14 +1,12 @@
package fr.openmc.core.features.displays.holograms;
import fr.openmc.core.OMCPlugin;
-import fr.openmc.core.bootstrap.features.Feature;
-import fr.openmc.core.bootstrap.features.annotations.Credit;
-import fr.openmc.core.bootstrap.features.types.HasCommands;
-import fr.openmc.core.bootstrap.features.types.LoadAfterItemsAdder;
-import fr.openmc.core.bootstrap.features.types.NotLoadInUnitTest;
-import fr.openmc.core.bootstrap.integration.OMCLogger;
import fr.openmc.core.features.displays.holograms.commands.HologramCommand;
import fr.openmc.core.features.milestones.tutorial.TutorialHologram;
+import fr.openmc.core.lifecycle.integration.OMCLogger;
+import fr.openmc.core.lifecycle.interfaces.HasCommands;
+import fr.openmc.core.registry.features.Feature;
+import fr.openmc.core.registry.features.annotations.Credit;
import fr.openmc.core.utils.world.entities.TextDisplay;
import net.kyori.adventure.text.Component;
import org.bukkit.Location;
@@ -25,7 +23,7 @@
import java.util.Set;
@Credit(developers = {"iambibi_", "miseur"})
-public class HologramLoader extends Feature implements NotLoadInUnitTest, LoadAfterItemsAdder, HasCommands {
+public class HologramLoader extends Feature implements HasCommands {
public static final HashMap displays = new HashMap<>();
private static BukkitTask taskTimer;
diff --git a/src/main/java/fr/openmc/core/features/displays/scoreboards/GlobalTeamManager.java b/src/main/java/fr/openmc/core/features/displays/scoreboards/GlobalTeamManager.java
index 68fa12933..d93884062 100644
--- a/src/main/java/fr/openmc/core/features/displays/scoreboards/GlobalTeamManager.java
+++ b/src/main/java/fr/openmc/core/features/displays/scoreboards/GlobalTeamManager.java
@@ -22,17 +22,19 @@
public class GlobalTeamManager {
private LuckPerms luckPerms = null;
+ private LuckPermsHook hook = null;
private final ObjectCacheRepository boardCache;
private final Map groupToPrefixCache = new ConcurrentHashMap<>();
private record TeamState(Set members, Component prefix) {}
private final Map teams = new ConcurrentHashMap<>();
private final Map playerTeam = new ConcurrentHashMap<>();
- public GlobalTeamManager(ObjectCacheRepository boardCache) {
+ public GlobalTeamManager(ObjectCacheRepository boardCache, LuckPermsHook hook) {
this.boardCache = boardCache;
- if (LuckPermsHook.isEnable()) {
- this.luckPerms = LuckPermsHook.getApi();
+ if (hook.isEnable()) {
+ this.hook = hook;
+ this.luckPerms = hook.getApi();
initSortedGroups();
this.luckPerms.getEventBus().subscribe(
@@ -47,7 +49,7 @@ private void initSortedGroups() {
List sortedGroups = new ArrayList<>(luckPerms.getGroupManager().getLoadedGroups());
sortedGroups.sort(Comparator.comparing(g -> -g.getWeight().orElse(0)));
for (Group group : sortedGroups) {
- groupToPrefixCache.put(group.getName(), LuckPermsHook.getFormattedPAPIPrefix(group));
+ groupToPrefixCache.put(group.getName(), hook.getFormattedPAPIPrefix(group));
}
}
@@ -62,7 +64,7 @@ public void updatePlayerTeam(Player player) {
Component prefix = groupToPrefixCache.computeIfAbsent(
playerGroup.getName(),
- _ -> LuckPermsHook.getFormattedPAPIPrefix(playerGroup)
+ _ -> hook.getFormattedPAPIPrefix(playerGroup)
);
int weight = playerGroup.getWeight().orElse(0);
diff --git a/src/main/java/fr/openmc/core/features/displays/scoreboards/ScoreboardListener.java b/src/main/java/fr/openmc/core/features/displays/scoreboards/ScoreboardListener.java
index 59c02ddff..02100bd01 100644
--- a/src/main/java/fr/openmc/core/features/displays/scoreboards/ScoreboardListener.java
+++ b/src/main/java/fr/openmc/core/features/displays/scoreboards/ScoreboardListener.java
@@ -7,20 +7,24 @@
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
-import static fr.openmc.core.features.displays.scoreboards.ScoreboardManager.*;
-
public class ScoreboardListener implements Listener {
+
+ private final ScoreboardManager manager;
+ public ScoreboardListener(ScoreboardManager manager) {
+ this.manager = manager;
+ }
+
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event) {
Player player = event.getPlayer();
- SternalBoard board = boardCache.find(player.getUniqueId());
+ SternalBoard board = manager.boardCache.find(player.getUniqueId());
- if (board == null) createNewBoard(player);
- else updateBoard(player, board);
+ if (board == null) manager.createNewBoard(player);
+ else manager.updateBoard(player, board);
}
@EventHandler
public void onPlayerQuit(PlayerQuitEvent event) {
- cleanupPlayer(event.getPlayer());
+ manager.cleanupPlayer(event.getPlayer());
}
}
\ No newline at end of file
diff --git a/src/main/java/fr/openmc/core/features/displays/scoreboards/ScoreboardManager.java b/src/main/java/fr/openmc/core/features/displays/scoreboards/ScoreboardManager.java
index b62818f6c..ef011c998 100644
--- a/src/main/java/fr/openmc/core/features/displays/scoreboards/ScoreboardManager.java
+++ b/src/main/java/fr/openmc/core/features/displays/scoreboards/ScoreboardManager.java
@@ -4,31 +4,33 @@
import fr.openmc.api.scoreboard.repository.ObjectCacheRepository;
import fr.openmc.api.scoreboard.repository.impl.ObjectCacheRepositoryImpl;
import fr.openmc.core.OMCPlugin;
-import fr.openmc.core.bootstrap.features.Feature;
-import fr.openmc.core.bootstrap.features.types.HasListeners;
-import fr.openmc.core.bootstrap.features.types.LoadIfEnable;
-import fr.openmc.core.bootstrap.features.types.NotLoadInUnitTest;
-import fr.openmc.core.bootstrap.listeners.ListenerFactory;
+import fr.openmc.core.OMCRegistry;
import fr.openmc.core.features.displays.scoreboards.sb.CityWarScoreboard;
import fr.openmc.core.features.displays.scoreboards.sb.MainScoreboard;
import fr.openmc.core.features.displays.scoreboards.sb.RestartScoreboard;
import fr.openmc.core.features.dream.displays.DreamScoreboard;
import fr.openmc.core.hooks.LuckPermsHook;
+import fr.openmc.core.lifecycle.interfaces.HasListeners;
+import fr.openmc.core.lifecycle.listeners.ListenerFactory;
+import fr.openmc.core.registry.features.Feature;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.Listener;
import java.util.*;
-public class ScoreboardManager extends Feature implements Listener, NotLoadInUnitTest, LoadIfEnable, HasListeners {
- public static final ObjectCacheRepository boardCache = new ObjectCacheRepositoryImpl();
- private static final List scoreboards = new ArrayList<>();
- private static GlobalTeamManager globalTeamManager;
+public class ScoreboardManager extends Feature implements Listener, HasListeners {
+ private LuckPermsHook luckPermsHook;
+ public final ObjectCacheRepository boardCache = new ObjectCacheRepositoryImpl();
+ private final List scoreboards = new ArrayList<>();
+ private GlobalTeamManager globalTeamManager;
private static final Map> lastUpdate = new HashMap<>();
@Override
public void init() {
+ luckPermsHook = OMCRegistry.HOOKS.LUCK_PERMS;
+
registerScoreboard(
new MainScoreboard(),
new RestartScoreboard(),
@@ -38,21 +40,21 @@ public void init() {
Bukkit.getScheduler().runTaskTimer(
OMCPlugin.getInstance(),
- ScoreboardManager::updateAllBoards,
+ this::updateAllBoards,
0L,
20L // every second
);
- if (LuckPermsHook.isEnable())
- globalTeamManager = new GlobalTeamManager(boardCache);
+ if (luckPermsHook.isEnable())
+ globalTeamManager = new GlobalTeamManager(boardCache, luckPermsHook);
}
@Override
public Set getListeners() {
- return Set.of(ScoreboardListener::new);
+ return Set.of(() -> new ScoreboardListener(this));
}
- public static void updateAllBoards() {
+ public void updateAllBoards() {
long now = System.currentTimeMillis();
Bukkit.getOnlinePlayers().forEach(player -> {
@@ -81,20 +83,20 @@ public static void updateAllBoards() {
active.update(player, board);
playerUpdates.put(active, now);
- if (LuckPermsHook.isEnable() && globalTeamManager != null) {
+ if (luckPermsHook.isEnable() && globalTeamManager != null) {
globalTeamManager.updatePlayerTeam(player);
}
});
}
- public static SternalBoard createNewBoard(Player player) {
+ public SternalBoard createNewBoard(Player player) {
SternalBoard board = new SternalBoard(player);
updateBoard(player, board);
boardCache.create(board);
return board;
}
- public static void updateBoard(Player player, SternalBoard board) {
+ public void updateBoard(Player player, SternalBoard board) {
for (BaseScoreboard scoreboard : scoreboards) {
if (scoreboard.shouldDisplay(player)) {
scoreboard.init(player, board);
@@ -102,17 +104,17 @@ public static void updateBoard(Player player, SternalBoard board) {
}
}
- if (LuckPermsHook.isEnable() && globalTeamManager != null) {
+ if (luckPermsHook.isEnable() && globalTeamManager != null) {
globalTeamManager.updatePlayerTeam(player);
}
}
- public static void registerScoreboard(BaseScoreboard... scoreboard) {
+ public void registerScoreboard(BaseScoreboard... scoreboard) {
scoreboards.addAll(Arrays.asList(scoreboard));
scoreboards.sort(Comparator.comparingInt(BaseScoreboard::priority).reversed());
}
- public static void cleanupPlayer(Player player) {
+ public void cleanupPlayer(Player player) {
UUID uuid = player.getUniqueId();
lastUpdate.remove(uuid);
boardCache.delete(uuid);
diff --git a/src/main/java/fr/openmc/core/features/displays/scoreboards/sb/MainScoreboard.java b/src/main/java/fr/openmc/core/features/displays/scoreboards/sb/MainScoreboard.java
index 67ec91649..458b29b89 100644
--- a/src/main/java/fr/openmc/core/features/displays/scoreboards/sb/MainScoreboard.java
+++ b/src/main/java/fr/openmc/core/features/displays/scoreboards/sb/MainScoreboard.java
@@ -4,6 +4,7 @@
import de.oliver.fancynpcs.api.Npc;
import de.oliver.fancynpcs.api.NpcManager;
import fr.openmc.api.scoreboard.SternalBoard;
+import fr.openmc.core.OMCRegistry;
import fr.openmc.core.features.bits.BitsManager;
import fr.openmc.core.features.city.City;
import fr.openmc.core.features.city.CityManager;
@@ -15,9 +16,6 @@
import fr.openmc.core.features.events.contents.weeklyevents.contents.contest.ContestPhase;
import fr.openmc.core.features.events.contents.weeklyevents.contents.contest.managers.ContestManager;
import fr.openmc.core.features.events.contents.weeklyevents.contents.contest.models.ContestData;
-import fr.openmc.core.hooks.FancyNpcsHook;
-import fr.openmc.core.hooks.LuckPermsHook;
-import fr.openmc.core.hooks.WorldGuardHook;
import fr.openmc.core.utils.text.DateUtils;
import fr.openmc.core.utils.text.messages.TranslationManager;
import net.kyori.adventure.text.Component;
@@ -76,21 +74,23 @@ public void update(Player player, SternalBoard board) {
}
public static List getDefaultLines(Player player) {
- Component rank = LuckPermsHook.isEnable()
- ? Component.text(LuckPermsHook.getFormattedPAPIPrefix(player))
- : TranslationManager.translation("feature.displays.scoreboard.rank.none.to_small").color(TextColor.color(0xFF1FCC));
+ BitsManager bitsManager = OMCRegistry.FEATURES.BITS.get();
+ CityManager cityManager = OMCRegistry.FEATURES.CITY.get();
+ Component rank = OMCRegistry.HOOKS.LUCK_PERMS.isEnable()
+ ? Component.text(OMCRegistry.HOOKS.LUCK_PERMS.getFormattedPAPIPrefix(player))
+ : TranslationManager.translation("feature.displays.scoreboard.rank.none.to_small").color(TextColor.color(0xFF1FCC));
- City city = CityManager.getPlayerCity(player.getUniqueId());
- City chunkCity = CityManager.getCityFromChunk(player.getChunk().getX(), player.getChunk().getZ());
- boolean isInRegion = WorldGuardHook.isRegionConflict(player.getLocation());
+ City city = cityManager.getPlayerCity(player.getUniqueId());
+ City chunkCity = cityManager.getCityFromChunk(player.getChunk().getX(), player.getChunk().getZ());
+ boolean isInRegion = OMCRegistry.HOOKS.WORLD_GUARD.isRegionConflict(player.getLocation());
Component location = isInRegion
? TranslationManager.translation("feature.displays.scoreboard.location.protected.to_small")
: TranslationManager.translation("feature.displays.scoreboard.location.wilderness.to_small");
location = (chunkCity != null) ? textToSmallComponent(chunkCity.getName()) : location;
String balance = EconomyManager.getMiniBalance(player.getUniqueId());
- double bits = BitsManager.getBits(player.getUniqueId());
+ double bits = bitsManager.getBits(player.getUniqueId());
List lines = new ArrayList<>();
@@ -121,7 +121,7 @@ public static List getDefaultLines(Player player) {
.appendSpace()
.append(textToSmallComponent(EconomyManager.getFormattedSimplifiedNumber(bits)).color(TextColor.color(0x07A0F5)))
.appendSpace()
- .append(text(BitsManager.getBitsIcon()))
+ .append(text(bitsManager.getBitsIcon()))
);
}
lines.add(text(" • ", NamedTextColor.DARK_GRAY)
@@ -130,7 +130,7 @@ public static List getDefaultLines(Player player) {
.append(location.color(TextColor.color(0xFF06DC)))
);
- if (FancyNpcsHook.isEnable()) {
+ if (OMCRegistry.HOOKS.FANCY_NPCS.isEnable()) {
NpcManager npcManager = FancyNpcsPlugin.get().getNpcManager();
Npc halloweenNPC = null;
if (npcManager != null)
diff --git a/src/main/java/fr/openmc/core/features/dream/DreamDimensionManager.java b/src/main/java/fr/openmc/core/features/dream/DreamDimensionManager.java
index 02c8bb437..0eca5e2b1 100644
--- a/src/main/java/fr/openmc/core/features/dream/DreamDimensionManager.java
+++ b/src/main/java/fr/openmc/core/features/dream/DreamDimensionManager.java
@@ -1,7 +1,7 @@
package fr.openmc.core.features.dream;
import fr.openmc.core.OMCPlugin;
-import fr.openmc.core.bootstrap.integration.OMCLogger;
+import fr.openmc.core.lifecycle.integration.OMCLogger;
import org.bukkit.Bukkit;
import org.bukkit.GameRules;
import org.bukkit.World;
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 4a51ea934..bb66c52ce 100644
--- a/src/main/java/fr/openmc/core/features/dream/DreamManager.java
+++ b/src/main/java/fr/openmc/core/features/dream/DreamManager.java
@@ -4,18 +4,10 @@
import com.j256.ormlite.dao.DaoManager;
import com.j256.ormlite.support.ConnectionSource;
import com.j256.ormlite.table.TableUtils;
-import fr.openmc.core.bootstrap.features.Feature;
-import fr.openmc.core.bootstrap.features.annotations.Credit;
-import fr.openmc.core.bootstrap.features.types.HasCommands;
-import fr.openmc.core.bootstrap.features.types.HasDatabase;
-import fr.openmc.core.bootstrap.features.types.HasListeners;
-import fr.openmc.core.bootstrap.features.types.LoadAfterItemsAdder;
-import fr.openmc.core.bootstrap.integration.OMCLogger;
-import fr.openmc.core.bootstrap.listeners.ListenerFactory;
+import fr.openmc.core.OMCRegistry;
import fr.openmc.core.commands.utils.SpawnManager;
import fr.openmc.core.features.city.City;
-import fr.openmc.core.features.city.CityManager;
-import fr.openmc.core.features.city.sub.mayor.managers.PerkManager;
+import fr.openmc.core.features.city.sub.mayor.perks.PerkUtils;
import fr.openmc.core.features.city.sub.mayor.perks.Perks;
import fr.openmc.core.features.dream.commands.AdminDreamCommands;
import fr.openmc.core.features.dream.commands.DreamCommands;
@@ -40,6 +32,13 @@
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.lifecycle.integration.OMCLogger;
+import fr.openmc.core.lifecycle.interfaces.HasCommands;
+import fr.openmc.core.lifecycle.interfaces.HasDatabase;
+import fr.openmc.core.lifecycle.interfaces.HasListeners;
+import fr.openmc.core.lifecycle.listeners.ListenerFactory;
+import fr.openmc.core.registry.features.Feature;
+import fr.openmc.core.registry.features.annotations.Credit;
import fr.openmc.core.utils.bukkit.serializer.BukkitSerializer;
import fr.openmc.core.utils.world.LocationUtils;
import org.bukkit.Bukkit;
@@ -57,7 +56,7 @@
import java.util.UUID;
@Credit(developers = {"iambibi_", "gab400"}, graphist = {"Tfloa"}, builders = {"Mcross_bow"})
-public class DreamManager extends Feature implements HasDatabase, LoadAfterItemsAdder, HasCommands, HasListeners {
+public class DreamManager extends Feature implements HasDatabase, HasCommands, HasListeners {
// ** CONSTANTS **
public static final Long BASE_DREAM_TIME = 300L;
@@ -381,8 +380,8 @@ public static double calculateDreamProbability(Player player) {
}
}
- City city = CityManager.getPlayerCity(player.getUniqueId());
- if (city != null && PerkManager.hasPerk(city.getMayor(), Perks.GREAT_SLEEPER.getId())) {
+ City city = OMCRegistry.FEATURES.CITY.get().getPlayerCity(player.getUniqueId());
+ if (city != null && PerkUtils.hasPerk(city.getMayor(), Perks.GREAT_SLEEPER.getId())) {
base += 0.4;
}
return base;
diff --git a/src/main/java/fr/openmc/core/features/dream/listeners/dream/PlayerObtainOrb.java b/src/main/java/fr/openmc/core/features/dream/listeners/dream/PlayerObtainOrb.java
index 941ee7d37..083780b82 100644
--- a/src/main/java/fr/openmc/core/features/dream/listeners/dream/PlayerObtainOrb.java
+++ b/src/main/java/fr/openmc/core/features/dream/listeners/dream/PlayerObtainOrb.java
@@ -1,6 +1,5 @@
package fr.openmc.core.features.dream.listeners.dream;
-import fr.openmc.core.bootstrap.integration.OMCLogger;
import fr.openmc.core.features.dream.DreamManager;
import fr.openmc.core.features.dream.events.AltarCraftingEvent;
import fr.openmc.core.features.dream.events.GlaciteTradeEvent;
@@ -11,6 +10,7 @@
import fr.openmc.core.features.dream.models.registry.items.DreamItem;
import fr.openmc.core.features.dream.registries.DreamBiome;
import fr.openmc.core.features.dream.registries.DreamItemRegistry;
+import fr.openmc.core.lifecycle.integration.OMCLogger;
import fr.openmc.core.registry.loottable.loots.CustomLoot;
import fr.openmc.core.registry.loottable.loots.ItemLoot;
import fr.openmc.core.utils.bukkit.ParticleUtils;
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 6ac66f147..458aa8bad 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,7 +1,7 @@
package fr.openmc.core.features.dream.mecanism.cloudcastle;
-import fr.openmc.core.bootstrap.integration.OMCLogger;
import fr.openmc.core.features.dream.registries.DreamMobsRegistry;
+import fr.openmc.core.lifecycle.integration.OMCLogger;
import fr.openmc.core.registry.mobs.CustomMob;
import org.bukkit.Bukkit;
import org.bukkit.Material;
diff --git a/src/main/java/fr/openmc/core/features/dream/mecanism/sfx/clone/PlayerCloneNpc.java b/src/main/java/fr/openmc/core/features/dream/mecanism/sfx/clone/PlayerCloneNpc.java
index 67e1872c1..3ecb18a0d 100644
--- a/src/main/java/fr/openmc/core/features/dream/mecanism/sfx/clone/PlayerCloneNpc.java
+++ b/src/main/java/fr/openmc/core/features/dream/mecanism/sfx/clone/PlayerCloneNpc.java
@@ -7,8 +7,8 @@
import de.oliver.fancynpcs.api.skins.SkinLoadException;
import de.oliver.fancynpcs.api.utils.NpcEquipmentSlot;
import fr.openmc.core.OMCPlugin;
-import fr.openmc.core.bootstrap.integration.OMCLogger;
import fr.openmc.core.hooks.FancyNpcsHook;
+import fr.openmc.core.lifecycle.integration.OMCLogger;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.block.Block;
diff --git a/src/main/java/fr/openmc/core/features/dream/mecanism/tradernpc/GlaciteNpcManager.java b/src/main/java/fr/openmc/core/features/dream/mecanism/tradernpc/GlaciteNpcManager.java
index b91b89ef3..963f4b9c8 100644
--- a/src/main/java/fr/openmc/core/features/dream/mecanism/tradernpc/GlaciteNpcManager.java
+++ b/src/main/java/fr/openmc/core/features/dream/mecanism/tradernpc/GlaciteNpcManager.java
@@ -4,9 +4,9 @@
import de.oliver.fancynpcs.api.Npc;
import de.oliver.fancynpcs.api.NpcData;
import fr.openmc.core.OMCPlugin;
-import fr.openmc.core.bootstrap.integration.OMCLogger;
import fr.openmc.core.features.dream.DreamDimensionManager;
import fr.openmc.core.hooks.FancyNpcsHook;
+import fr.openmc.core.lifecycle.integration.OMCLogger;
import fr.openmc.core.utils.text.messages.TranslationManager;
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
import org.bukkit.Bukkit;
diff --git a/src/main/java/fr/openmc/core/features/dream/models/db/DreamPlayer.java b/src/main/java/fr/openmc/core/features/dream/models/db/DreamPlayer.java
index 0c33db569..53ffdbc0c 100644
--- a/src/main/java/fr/openmc/core/features/dream/models/db/DreamPlayer.java
+++ b/src/main/java/fr/openmc/core/features/dream/models/db/DreamPlayer.java
@@ -3,7 +3,7 @@
import fr.openmc.core.OMCPlugin;
import fr.openmc.core.features.city.City;
import fr.openmc.core.features.city.CityManager;
-import fr.openmc.core.features.city.sub.mayor.managers.PerkManager;
+import fr.openmc.core.features.city.sub.mayor.perks.PerkUtils;
import fr.openmc.core.features.city.sub.mayor.perks.Perks;
import fr.openmc.core.features.dream.DreamManager;
import fr.openmc.core.features.dream.events.DreamEndEvent;
@@ -53,7 +53,7 @@ public DreamPlayer(Player player, ItemStack[] oldInv, Location oldLocation, Play
this.dreamTime = cacheData == null ? DreamManager.BASE_DREAM_TIME : cacheData.getMaxDreamTime();
City city = CityManager.getPlayerCity(player.getUniqueId());
- if (city != null && PerkManager.hasPerk(city.getMayor(), Perks.GREAT_DREAM.getId())) {
+ if (city != null && PerkUtils.hasPerk(city.getMayor(), Perks.GREAT_DREAM.getId())) {
this.dreamTime = (long) (this.dreamTime * 1.6);
MessagesManager.sendMessage(player,
TranslationManager.translation("feature.dream.message.great_dream_bonus"), Prefix.MAYOR, MessageType.INFO, false
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 4ee1d5df6..f93a182ce 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
@@ -1,13 +1,13 @@
package fr.openmc.core.features.dream.registries;
import fr.openmc.core.OMCPlugin;
-import fr.openmc.core.bootstrap.integration.OMCLogger;
import fr.openmc.core.features.dream.DreamDimensionManager;
import fr.openmc.core.features.dream.listeners.registry.DreamBlocksListeners;
import fr.openmc.core.features.dream.mecanism.altar.AltarManager;
import fr.openmc.core.features.dream.mecanism.cloudcastle.BossCloudSpawner;
import fr.openmc.core.features.dream.mecanism.cloudcastle.CloudVault;
import fr.openmc.core.features.dream.models.registry.DreamBlock;
+import fr.openmc.core.lifecycle.integration.OMCLogger;
import org.bukkit.Location;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
diff --git a/src/main/java/fr/openmc/core/features/economy/BankManager.java b/src/main/java/fr/openmc/core/features/economy/BankManager.java
index 1664ff486..d8921e89a 100644
--- a/src/main/java/fr/openmc/core/features/economy/BankManager.java
+++ b/src/main/java/fr/openmc/core/features/economy/BankManager.java
@@ -6,19 +6,19 @@
import com.j256.ormlite.table.TableUtils;
import fr.openmc.core.CommandsManager;
import fr.openmc.core.OMCPlugin;
-import fr.openmc.core.bootstrap.features.Feature;
-import fr.openmc.core.bootstrap.features.types.HasDatabase;
-import fr.openmc.core.bootstrap.integration.OMCLogger;
+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.bank.CityBankManager;
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.PerkUtils;
import fr.openmc.core.features.city.sub.mayor.perks.Perks;
import fr.openmc.core.features.city.sub.milestone.rewards.PlayerBankLimitRewards;
import fr.openmc.core.features.economy.commands.BankCommands;
import fr.openmc.core.features.economy.events.BankDepositEvent;
import fr.openmc.core.features.economy.models.Bank;
+import fr.openmc.core.lifecycle.integration.OMCLogger;
+import fr.openmc.core.lifecycle.interfaces.HasDatabase;
+import fr.openmc.core.registry.features.Feature;
import fr.openmc.core.utils.cache.CacheOfflinePlayer;
import fr.openmc.core.utils.text.DateUtils;
import fr.openmc.core.utils.text.InputUtils;
@@ -120,7 +120,7 @@ public static void deposit(UUID playerUUID, String input) {
}
double amount = InputUtils.convertToMoneyValue(input);
- City city = CityManager.getPlayerCity(playerUUID);
+ City city = OMCRegistry.FEATURES.CITY.get().getPlayerCity(playerUUID);
if (city == null || city.getLevel() < 2) {
MessagesManager.sendMessage(offlinePlayer,
@@ -213,8 +213,8 @@ public static double calculatePlayerInterest(UUID playerUUID) {
double interest = .01; // base interest is 1%
if (MayorManager.phaseMayor == 2) {
- City city = CityManager.getPlayerCity(playerUUID);
- if (city != null && PerkManager.hasPerk(city.getMayor(), Perks.BUSINESS_MAN.getId())) {
+ City city = OMCRegistry.FEATURES.CITY.get().getPlayerCity(playerUUID);
+ if (city != null && PerkUtils.hasPerk(city.getMayor(), Perks.BUSINESS_MAN.getId())) {
interest += .02; // interest is +2% when perk Business Man enabled
}
}
@@ -226,7 +226,7 @@ public static void applyPlayerInterest(UUID playerUUID) {
double interest = calculatePlayerInterest(playerUUID);
double amount = getBankBalance(playerUUID) * interest;
- City city = CityManager.getPlayerCity(playerUUID);
+ City city = OMCRegistry.FEATURES.CITY.get().getPlayerCity(playerUUID);
if (city == null) return;
diff --git a/src/main/java/fr/openmc/core/features/economy/EconomyManager.java b/src/main/java/fr/openmc/core/features/economy/EconomyManager.java
index e704c1f8a..aa7b9620d 100644
--- a/src/main/java/fr/openmc/core/features/economy/EconomyManager.java
+++ b/src/main/java/fr/openmc/core/features/economy/EconomyManager.java
@@ -5,17 +5,17 @@
import com.j256.ormlite.support.ConnectionSource;
import com.j256.ormlite.table.TableUtils;
import dev.lone.itemsadder.api.FontImages.FontImageWrapper;
-import fr.openmc.core.bootstrap.features.Feature;
-import fr.openmc.core.bootstrap.features.annotations.Credit;
-import fr.openmc.core.bootstrap.features.types.HasCommands;
-import fr.openmc.core.bootstrap.features.types.HasDatabase;
-import fr.openmc.core.bootstrap.integration.OMCLogger;
import fr.openmc.core.features.economy.commands.Baltop;
import fr.openmc.core.features.economy.commands.History;
import fr.openmc.core.features.economy.commands.Money;
import fr.openmc.core.features.economy.commands.Pay;
import fr.openmc.core.features.economy.models.EconomyPlayer;
import fr.openmc.core.hooks.itemsadder.ItemsAdderHook;
+import fr.openmc.core.lifecycle.integration.OMCLogger;
+import fr.openmc.core.lifecycle.interfaces.HasCommands;
+import fr.openmc.core.lifecycle.interfaces.HasDatabase;
+import fr.openmc.core.registry.features.Feature;
+import fr.openmc.core.registry.features.annotations.Credit;
import lombok.Getter;
import org.jetbrains.annotations.NotNull;
diff --git a/src/main/java/fr/openmc/core/features/economy/TransactionsManager.java b/src/main/java/fr/openmc/core/features/economy/TransactionsManager.java
index d934a4c06..974b46836 100644
--- a/src/main/java/fr/openmc/core/features/economy/TransactionsManager.java
+++ b/src/main/java/fr/openmc/core/features/economy/TransactionsManager.java
@@ -6,11 +6,11 @@
import com.j256.ormlite.support.ConnectionSource;
import com.j256.ormlite.table.TableUtils;
import fr.openmc.core.OMCPlugin;
-import fr.openmc.core.bootstrap.features.Feature;
-import fr.openmc.core.bootstrap.features.annotations.Credit;
-import fr.openmc.core.bootstrap.features.types.HasDatabase;
-import fr.openmc.core.bootstrap.integration.OMCLogger;
import fr.openmc.core.features.analytics.Stats;
+import fr.openmc.core.lifecycle.integration.OMCLogger;
+import fr.openmc.core.lifecycle.interfaces.HasDatabase;
+import fr.openmc.core.registry.features.Feature;
+import fr.openmc.core.registry.features.annotations.Credit;
import org.bukkit.Bukkit;
import java.sql.SQLException;
diff --git a/src/main/java/fr/openmc/core/features/economy/menu/PersonalBankMenu.java b/src/main/java/fr/openmc/core/features/economy/menu/PersonalBankMenu.java
index 76b734063..a0838f5b5 100644
--- a/src/main/java/fr/openmc/core/features/economy/menu/PersonalBankMenu.java
+++ b/src/main/java/fr/openmc/core/features/economy/menu/PersonalBankMenu.java
@@ -5,8 +5,8 @@
import fr.openmc.api.menulib.utils.ItemMenuBuilder;
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.sub.milestone.rewards.PlayerBankLimitRewards;
import fr.openmc.core.features.economy.BankManager;
import fr.openmc.core.features.economy.EconomyManager;
@@ -69,7 +69,7 @@ public void onInventoryClick(InventoryClickEvent click) {
new PersonalBankDepositMenu(player).open();
}));
- City playerCity = CityManager.getPlayerCity(player.getUniqueId());
+ City playerCity = OMCRegistry.FEATURES.CITY.get().getPlayerCity(player.getUniqueId());
if (playerCity == null) {
MessagesManager.sendMessage(player,
diff --git a/src/main/java/fr/openmc/core/features/events/EventsManager.java b/src/main/java/fr/openmc/core/features/events/EventsManager.java
index f988763c4..973ced10c 100644
--- a/src/main/java/fr/openmc/core/features/events/EventsManager.java
+++ b/src/main/java/fr/openmc/core/features/events/EventsManager.java
@@ -1,9 +1,6 @@
package fr.openmc.core.features.events;
import fr.openmc.core.OMCRegistry;
-import fr.openmc.core.bootstrap.features.Feature;
-import fr.openmc.core.bootstrap.features.types.HasCommands;
-import fr.openmc.core.bootstrap.features.types.LoadAfterItemsAdder;
import fr.openmc.core.features.events.commands.CalendarCommand;
import fr.openmc.core.features.events.commands.EventCommand;
import fr.openmc.core.features.events.contents.dailyevents.DailyEventsManager;
@@ -13,6 +10,8 @@
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.lifecycle.interfaces.HasCommands;
+import fr.openmc.core.registry.features.Feature;
import fr.openmc.core.utils.text.DateUtils;
import fr.openmc.core.utils.text.messages.TranslationManager;
import net.kyori.adventure.text.Component;
@@ -26,7 +25,7 @@
import java.util.List;
import java.util.Set;
-public class EventsManager extends Feature implements LoadAfterItemsAdder, HasCommands {
+public class EventsManager extends Feature implements HasCommands {
@Override
public Set getCommands() {
return Set.of(
diff --git a/src/main/java/fr/openmc/core/features/events/contents/dailyevents/DailyEventsManager.java b/src/main/java/fr/openmc/core/features/events/contents/dailyevents/DailyEventsManager.java
index e46fb3b92..495aa8c7d 100644
--- a/src/main/java/fr/openmc/core/features/events/contents/dailyevents/DailyEventsManager.java
+++ b/src/main/java/fr/openmc/core/features/events/contents/dailyevents/DailyEventsManager.java
@@ -6,11 +6,6 @@
import com.j256.ormlite.table.TableUtils;
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.*;
-import fr.openmc.core.bootstrap.integration.OMCLogger;
-import fr.openmc.core.bootstrap.listeners.ListenerFactory;
import fr.openmc.core.features.events.contents.dailyevents.commands.DailyEventCommand;
import fr.openmc.core.features.events.contents.dailyevents.listeners.DailyEventAmbientListeners;
import fr.openmc.core.features.events.contents.dailyevents.models.IncomingEventsDB;
@@ -18,6 +13,14 @@
import fr.openmc.core.features.events.contents.dailyevents.models.dailyevent.DailyEvent;
import fr.openmc.core.features.events.contents.dailyevents.tasks.NextEventTask;
import fr.openmc.core.features.events.contents.dailyevents.tasks.ShowBeginningEventTask;
+import fr.openmc.core.lifecycle.integration.OMCLogger;
+import fr.openmc.core.lifecycle.interfaces.HasCommands;
+import fr.openmc.core.lifecycle.interfaces.HasDatabase;
+import fr.openmc.core.lifecycle.interfaces.HasFeature;
+import fr.openmc.core.lifecycle.interfaces.HasListeners;
+import fr.openmc.core.lifecycle.listeners.ListenerFactory;
+import fr.openmc.core.registry.features.Feature;
+import fr.openmc.core.registry.features.annotations.Credit;
import fr.openmc.core.utils.RandomUtils;
import fr.openmc.core.utils.text.DateUtils;
import org.bukkit.scheduler.BukkitTask;
@@ -29,7 +32,7 @@
@Credit(developers = {"iambibi_"})
-public class DailyEventsManager extends Feature implements LoadAfterItemsAdder, HasDatabase, HasListeners, HasCommands {
+public class DailyEventsManager extends Feature implements HasDatabase, HasListeners, HasCommands {
private static final List SLOT_HOURS_EVENTS = new ArrayList<>(List.of(
9, 13, 16, 21
));
@@ -50,7 +53,7 @@ public void init() {
for (DailyEvent event : OMCRegistry.DAILY_EVENTS.values()) {
if (!(event instanceof HasFeature hasFeature)) continue;
- OMCPlugin.registerFeature(hasFeature.getFeature());
+ OMCRegistry.FEATURES.register(hasFeature.feature());
}
incomingEvents = loadIncomingEvents();
diff --git a/src/main/java/fr/openmc/core/features/events/contents/dailyevents/DailyEventsRegistry.java b/src/main/java/fr/openmc/core/features/events/contents/dailyevents/DailyEventsRegistry.java
index 347d8fec1..4b60c6c8c 100644
--- a/src/main/java/fr/openmc/core/features/events/contents/dailyevents/DailyEventsRegistry.java
+++ b/src/main/java/fr/openmc/core/features/events/contents/dailyevents/DailyEventsRegistry.java
@@ -1,11 +1,11 @@
package fr.openmc.core.features.events.contents.dailyevents;
-import fr.openmc.core.bootstrap.registries.KeyedRegistry;
-import fr.openmc.core.bootstrap.registries.Registry;
import fr.openmc.core.features.events.contents.dailyevents.contents.bloodynight.BloodyNightEvent;
import fr.openmc.core.features.events.contents.dailyevents.contents.goldenharvest.GoldenHarvestEvent;
import fr.openmc.core.features.events.contents.dailyevents.contents.miraculousfishing.MiraculousFishingEvent;
import fr.openmc.core.features.events.contents.dailyevents.models.dailyevent.DailyEvent;
+import fr.openmc.core.lifecycle.registries.KeyedRegistry;
+import fr.openmc.core.lifecycle.registries.Registry;
public class DailyEventsRegistry extends Registry
implements KeyedRegistry {
diff --git a/src/main/java/fr/openmc/core/features/events/contents/dailyevents/contents/bloodynight/BloodyNightEvent.java b/src/main/java/fr/openmc/core/features/events/contents/dailyevents/contents/bloodynight/BloodyNightEvent.java
index 977ba2f70..57dee0911 100644
--- a/src/main/java/fr/openmc/core/features/events/contents/dailyevents/contents/bloodynight/BloodyNightEvent.java
+++ b/src/main/java/fr/openmc/core/features/events/contents/dailyevents/contents/bloodynight/BloodyNightEvent.java
@@ -2,12 +2,13 @@
import fr.openmc.api.menulib.Menu;
import fr.openmc.core.OMCRegistry;
-import fr.openmc.core.bootstrap.features.Feature;
-import fr.openmc.core.bootstrap.features.types.HasFeature;
import fr.openmc.core.features.events.contents.dailyevents.contents.bloodynight.menu.BloodyNightMenu;
import fr.openmc.core.features.events.contents.dailyevents.models.dailyevent.*;
import fr.openmc.core.features.events.models.HasMenu;
+import fr.openmc.core.lifecycle.interfaces.HasFeature;
import fr.openmc.core.registry.ambient.CustomAmbient;
+import fr.openmc.core.registry.features.loading.FeatureEntry;
+import fr.openmc.core.registry.features.loading.FeatureLoadingType;
import fr.openmc.core.utils.nms.toast.CustomToastData;
import fr.openmc.core.utils.text.messages.TranslationManager;
import net.kyori.adventure.bossbar.BossBar;
@@ -116,7 +117,7 @@ public BossBar.Overlay getBossBarOverlay() {
}
@Override
- public Feature getFeature() {
- return new BloodyNightManager();
+ public FeatureEntry feature() {
+ return FeatureEntry.of(FeatureLoadingType.RUNTIME, BloodyNightManager::new);
}
}
diff --git a/src/main/java/fr/openmc/core/features/events/contents/dailyevents/contents/bloodynight/BloodyNightManager.java b/src/main/java/fr/openmc/core/features/events/contents/dailyevents/contents/bloodynight/BloodyNightManager.java
index fcb3e8a7d..552042b22 100644
--- a/src/main/java/fr/openmc/core/features/events/contents/dailyevents/contents/bloodynight/BloodyNightManager.java
+++ b/src/main/java/fr/openmc/core/features/events/contents/dailyevents/contents/bloodynight/BloodyNightManager.java
@@ -2,9 +2,6 @@
import fr.openmc.core.OMCPlugin;
import fr.openmc.core.OMCRegistry;
-import fr.openmc.core.bootstrap.features.Feature;
-import fr.openmc.core.bootstrap.features.types.HasListeners;
-import fr.openmc.core.bootstrap.listeners.ListenerFactory;
import fr.openmc.core.features.events.contents.dailyevents.contents.bloodynight.contents.mobs.bloodytypes.AncientMonster;
import fr.openmc.core.features.events.contents.dailyevents.contents.bloodynight.contents.mobs.bloodytypes.CorruptedMonster;
import fr.openmc.core.features.events.contents.dailyevents.contents.bloodynight.contents.mobs.bloodytypes.CursedMonster;
@@ -12,6 +9,9 @@
import fr.openmc.core.features.events.contents.dailyevents.contents.bloodynight.contents.mobs.vampire.VampireBoss;
import fr.openmc.core.features.events.contents.dailyevents.contents.bloodynight.contents.mobs.vampire.VampireSlave;
import fr.openmc.core.features.events.contents.dailyevents.contents.bloodynight.listeners.MonsterSpawnListener;
+import fr.openmc.core.lifecycle.interfaces.HasListeners;
+import fr.openmc.core.lifecycle.listeners.ListenerFactory;
+import fr.openmc.core.registry.features.Feature;
import fr.openmc.core.registry.mobs.CustomMob;
import fr.openmc.core.utils.world.LocationUtils;
import org.bukkit.*;
diff --git a/src/main/java/fr/openmc/core/features/events/contents/dailyevents/contents/bloodynight/listeners/MonsterSpawnListener.java b/src/main/java/fr/openmc/core/features/events/contents/dailyevents/contents/bloodynight/listeners/MonsterSpawnListener.java
index 0ba030d76..7b40a6b3f 100644
--- a/src/main/java/fr/openmc/core/features/events/contents/dailyevents/contents/bloodynight/listeners/MonsterSpawnListener.java
+++ b/src/main/java/fr/openmc/core/features/events/contents/dailyevents/contents/bloodynight/listeners/MonsterSpawnListener.java
@@ -3,12 +3,12 @@
import com.destroystokyo.paper.event.entity.EntityAddToWorldEvent;
import fr.openmc.core.OMCPlugin;
import fr.openmc.core.OMCRegistry;
-import fr.openmc.core.bootstrap.integration.OMCLogger;
import fr.openmc.core.features.events.contents.dailyevents.DailyEventsManager;
import fr.openmc.core.features.events.contents.dailyevents.contents.bloodynight.BloodyNightEvent;
import fr.openmc.core.features.events.contents.dailyevents.contents.bloodynight.BloodyNightManager;
import fr.openmc.core.features.events.contents.dailyevents.contents.bloodynight.contents.mobs.vampire.VampireBoss;
import fr.openmc.core.features.events.contents.dailyevents.contents.bloodynight.contents.mobs.vampire.VampireSlave;
+import fr.openmc.core.lifecycle.integration.OMCLogger;
import fr.openmc.core.registry.mobs.CustomMob;
import org.bukkit.Bukkit;
import org.bukkit.entity.Entity;
diff --git a/src/main/java/fr/openmc/core/features/events/contents/dailyevents/contents/goldenharvest/GoldenHarvestEvent.java b/src/main/java/fr/openmc/core/features/events/contents/dailyevents/contents/goldenharvest/GoldenHarvestEvent.java
index 830bc4cc1..083013785 100644
--- a/src/main/java/fr/openmc/core/features/events/contents/dailyevents/contents/goldenharvest/GoldenHarvestEvent.java
+++ b/src/main/java/fr/openmc/core/features/events/contents/dailyevents/contents/goldenharvest/GoldenHarvestEvent.java
@@ -2,12 +2,15 @@
import fr.openmc.api.menulib.Menu;
import fr.openmc.core.OMCRegistry;
-import fr.openmc.core.bootstrap.features.Feature;
-import fr.openmc.core.bootstrap.features.types.HasFeature;
import fr.openmc.core.features.events.contents.dailyevents.contents.goldenharvest.menu.GoldenHarvestMenu;
+import fr.openmc.core.features.events.contents.dailyevents.contents.miraculousfishing.MiraculousFishingManager;
import fr.openmc.core.features.events.contents.dailyevents.models.dailyevent.*;
import fr.openmc.core.features.events.models.HasMenu;
+import fr.openmc.core.lifecycle.interfaces.HasFeature;
import fr.openmc.core.registry.ambient.CustomAmbient;
+import fr.openmc.core.registry.features.Feature;
+import fr.openmc.core.registry.features.loading.FeatureEntry;
+import fr.openmc.core.registry.features.loading.FeatureLoadingType;
import fr.openmc.core.utils.nms.toast.CustomToastData;
import fr.openmc.core.utils.text.messages.TranslationManager;
import net.kyori.adventure.bossbar.BossBar;
@@ -101,8 +104,8 @@ public Component getEndBroadcast() {
}
@Override
- public Feature getFeature() {
- return new GoldenHarvestManager();
+ public FeatureEntry extends Feature> feature() {
+ return FeatureEntry.of(FeatureLoadingType.RUNTIME, MiraculousFishingManager::new);
}
@Override
diff --git a/src/main/java/fr/openmc/core/features/events/contents/dailyevents/contents/goldenharvest/GoldenHarvestManager.java b/src/main/java/fr/openmc/core/features/events/contents/dailyevents/contents/goldenharvest/GoldenHarvestManager.java
index c5f909f38..150709ab7 100644
--- a/src/main/java/fr/openmc/core/features/events/contents/dailyevents/contents/goldenharvest/GoldenHarvestManager.java
+++ b/src/main/java/fr/openmc/core/features/events/contents/dailyevents/contents/goldenharvest/GoldenHarvestManager.java
@@ -2,12 +2,12 @@
import dev.lone.itemsadder.api.CustomBlock;
import fr.openmc.core.OMCRegistry;
-import fr.openmc.core.bootstrap.features.Feature;
-import fr.openmc.core.bootstrap.features.types.HasListeners;
-import fr.openmc.core.bootstrap.listeners.ListenerFactory;
import fr.openmc.core.features.events.contents.dailyevents.contents.goldenharvest.listeners.*;
import fr.openmc.core.features.events.contents.dailyevents.contents.goldenharvest.obesecrops.ObeseCropsRegistry;
import fr.openmc.core.hooks.itemsadder.behaviours.BehaviourUpBlock;
+import fr.openmc.core.lifecycle.interfaces.HasListeners;
+import fr.openmc.core.lifecycle.listeners.ListenerFactory;
+import fr.openmc.core.registry.features.Feature;
import fr.openmc.core.registry.items.CustomItem;
import fr.openmc.core.registry.items.keys.KeyBlock;
import fr.openmc.core.registry.loottable.loots.ItemLoot;
diff --git a/src/main/java/fr/openmc/core/features/events/contents/dailyevents/contents/goldenharvest/obesecrops/ObeseCropsRegistry.java b/src/main/java/fr/openmc/core/features/events/contents/dailyevents/contents/goldenharvest/obesecrops/ObeseCropsRegistry.java
index 114eabcaa..83820cc12 100644
--- a/src/main/java/fr/openmc/core/features/events/contents/dailyevents/contents/goldenharvest/obesecrops/ObeseCropsRegistry.java
+++ b/src/main/java/fr/openmc/core/features/events/contents/dailyevents/contents/goldenharvest/obesecrops/ObeseCropsRegistry.java
@@ -1,7 +1,7 @@
package fr.openmc.core.features.events.contents.dailyevents.contents.goldenharvest.obesecrops;
import fr.openmc.core.OMCPlugin;
-import fr.openmc.core.bootstrap.integration.OMCLogger;
+import fr.openmc.core.lifecycle.integration.OMCLogger;
import org.bukkit.Location;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
diff --git a/src/main/java/fr/openmc/core/features/events/contents/dailyevents/contents/miraculousfishing/MiraculousFishingEvent.java b/src/main/java/fr/openmc/core/features/events/contents/dailyevents/contents/miraculousfishing/MiraculousFishingEvent.java
index 5cf0306df..673c6704d 100644
--- a/src/main/java/fr/openmc/core/features/events/contents/dailyevents/contents/miraculousfishing/MiraculousFishingEvent.java
+++ b/src/main/java/fr/openmc/core/features/events/contents/dailyevents/contents/miraculousfishing/MiraculousFishingEvent.java
@@ -2,12 +2,13 @@
import fr.openmc.api.menulib.Menu;
import fr.openmc.core.OMCRegistry;
-import fr.openmc.core.bootstrap.features.Feature;
-import fr.openmc.core.bootstrap.features.types.HasFeature;
import fr.openmc.core.features.events.contents.dailyevents.contents.miraculousfishing.menu.MiraculousFishingMenu;
import fr.openmc.core.features.events.contents.dailyevents.models.dailyevent.*;
import fr.openmc.core.features.events.models.HasMenu;
+import fr.openmc.core.lifecycle.interfaces.HasFeature;
import fr.openmc.core.registry.ambient.CustomAmbient;
+import fr.openmc.core.registry.features.loading.FeatureEntry;
+import fr.openmc.core.registry.features.loading.FeatureLoadingType;
import fr.openmc.core.utils.nms.toast.CustomToastData;
import fr.openmc.core.utils.text.messages.TranslationManager;
import net.kyori.adventure.bossbar.BossBar;
@@ -115,8 +116,8 @@ public Menu getInfoMenu(Player player) {
}
@Override
- public Feature getFeature() {
- return new MiraculousFishingManager();
+ public FeatureEntry feature() {
+ return FeatureEntry.of(FeatureLoadingType.RUNTIME, MiraculousFishingManager::new);
}
@Override
diff --git a/src/main/java/fr/openmc/core/features/events/contents/dailyevents/contents/miraculousfishing/MiraculousFishingManager.java b/src/main/java/fr/openmc/core/features/events/contents/dailyevents/contents/miraculousfishing/MiraculousFishingManager.java
index 2e8f656b5..d92cbc3c5 100644
--- a/src/main/java/fr/openmc/core/features/events/contents/dailyevents/contents/miraculousfishing/MiraculousFishingManager.java
+++ b/src/main/java/fr/openmc/core/features/events/contents/dailyevents/contents/miraculousfishing/MiraculousFishingManager.java
@@ -1,13 +1,13 @@
package fr.openmc.core.features.events.contents.dailyevents.contents.miraculousfishing;
import fr.openmc.core.OMCPlugin;
-import fr.openmc.core.bootstrap.features.Feature;
-import fr.openmc.core.bootstrap.features.types.HasListeners;
-import fr.openmc.core.bootstrap.listeners.ListenerFactory;
import fr.openmc.core.features.events.contents.dailyevents.contents.miraculousfishing.listeners.EatKebabFermentedListener;
import fr.openmc.core.features.events.contents.dailyevents.contents.miraculousfishing.listeners.PlayerFishListener;
import fr.openmc.core.features.events.contents.dailyevents.contents.miraculousfishing.listeners.PlayerNotPickUpListener;
import fr.openmc.core.features.events.contents.dailyevents.contents.miraculousfishing.registry.SeaCreatureLoot;
+import fr.openmc.core.lifecycle.interfaces.HasListeners;
+import fr.openmc.core.lifecycle.listeners.ListenerFactory;
+import fr.openmc.core.registry.features.Feature;
import fr.openmc.core.registry.loottable.loots.CustomLoot;
import fr.openmc.core.registry.loottable.loots.MoneyLoot;
import fr.openmc.core.registry.loottable.loots.RepresentedItem;
diff --git a/src/main/java/fr/openmc/core/features/events/contents/halloween/listeners/HalloweenNPCListener.java b/src/main/java/fr/openmc/core/features/events/contents/halloween/listeners/HalloweenNPCListener.java
index fb954e064..81c0e0bf4 100644
--- a/src/main/java/fr/openmc/core/features/events/contents/halloween/listeners/HalloweenNPCListener.java
+++ b/src/main/java/fr/openmc/core/features/events/contents/halloween/listeners/HalloweenNPCListener.java
@@ -1,9 +1,9 @@
package fr.openmc.core.features.events.contents.halloween.listeners;
import de.oliver.fancynpcs.api.events.NpcInteractEvent;
-import fr.openmc.core.bootstrap.features.types.LoadIfEnable;
import fr.openmc.core.features.events.contents.halloween.menus.HalloweenPumpkinDepositMenu;
import fr.openmc.core.hooks.FancyNpcsHook;
+import fr.openmc.core.lifecycle.interfaces.LoadIfEnable;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
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 e83ff3419..414227223 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
@@ -9,18 +9,18 @@
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.HasCommands;
-import fr.openmc.core.bootstrap.features.types.HasDatabase;
-import fr.openmc.core.bootstrap.features.types.HasListeners;
-import fr.openmc.core.bootstrap.integration.OMCLogger;
-import fr.openmc.core.bootstrap.listeners.ListenerFactory;
import fr.openmc.core.features.economy.EconomyManager;
import fr.openmc.core.features.events.contents.halloween.commands.HalloweenCommands;
import fr.openmc.core.features.events.contents.halloween.listeners.HalloweenNPCListener;
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.lifecycle.integration.OMCLogger;
+import fr.openmc.core.lifecycle.interfaces.HasCommands;
+import fr.openmc.core.lifecycle.interfaces.HasDatabase;
+import fr.openmc.core.lifecycle.interfaces.HasListeners;
+import fr.openmc.core.lifecycle.listeners.ListenerFactory;
+import fr.openmc.core.registry.features.Feature;
import fr.openmc.core.utils.text.messages.TranslationManager;
import io.papermc.paper.datacomponent.DataComponentTypes;
import io.papermc.paper.datacomponent.item.DamageResistant;
diff --git a/src/main/java/fr/openmc/core/features/events/contents/weeklyevents/WeeklyEventsManager.java b/src/main/java/fr/openmc/core/features/events/contents/weeklyevents/WeeklyEventsManager.java
index 8dccea4b8..a6f372c29 100644
--- a/src/main/java/fr/openmc/core/features/events/contents/weeklyevents/WeeklyEventsManager.java
+++ b/src/main/java/fr/openmc/core/features/events/contents/weeklyevents/WeeklyEventsManager.java
@@ -6,14 +6,13 @@
import com.j256.ormlite.table.TableUtils;
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.HasDatabase;
-import fr.openmc.core.bootstrap.features.types.LoadAfterItemsAdder;
-import fr.openmc.core.bootstrap.integration.OMCLogger;
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.contents.weeklyevents.models.WeeklyEventsData;
+import fr.openmc.core.lifecycle.integration.OMCLogger;
+import fr.openmc.core.lifecycle.interfaces.HasDatabase;
+import fr.openmc.core.registry.features.Feature;
+import fr.openmc.core.registry.features.annotations.Credit;
import fr.openmc.core.utils.text.DateUtils;
import org.bukkit.Bukkit;
import org.bukkit.scheduler.BukkitTask;
@@ -24,7 +23,7 @@
import java.util.Locale;
@Credit(developers = {"iambibi_"})
-public class WeeklyEventsManager extends Feature implements LoadAfterItemsAdder, HasDatabase {
+public class WeeklyEventsManager extends Feature implements HasDatabase {
private static Dao dao;
private static WeeklyEventsData data;
diff --git a/src/main/java/fr/openmc/core/features/events/contents/weeklyevents/WeeklyEventsRegistry.java b/src/main/java/fr/openmc/core/features/events/contents/weeklyevents/WeeklyEventsRegistry.java
index 3fd4d51e9..c2b40c29b 100644
--- a/src/main/java/fr/openmc/core/features/events/contents/weeklyevents/WeeklyEventsRegistry.java
+++ b/src/main/java/fr/openmc/core/features/events/contents/weeklyevents/WeeklyEventsRegistry.java
@@ -1,9 +1,9 @@
package fr.openmc.core.features.events.contents.weeklyevents;
-import fr.openmc.core.bootstrap.registries.KeyedRegistry;
-import fr.openmc.core.bootstrap.registries.Registry;
import fr.openmc.core.features.events.contents.weeklyevents.contents.contest.Contest;
import fr.openmc.core.features.events.contents.weeklyevents.models.WeeklyEvent;
+import fr.openmc.core.lifecycle.registries.KeyedRegistry;
+import fr.openmc.core.lifecycle.registries.Registry;
import java.util.List;
import java.util.Optional;
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 aa0cf0d28..c31a41d50 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
@@ -8,12 +8,6 @@
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.HasDatabase;
-import fr.openmc.core.bootstrap.features.types.LoadAfterItemsAdder;
-import fr.openmc.core.bootstrap.integration.DatabaseManager;
-import fr.openmc.core.bootstrap.integration.OMCLogger;
import fr.openmc.core.features.economy.EconomyManager;
import fr.openmc.core.features.events.contents.weeklyevents.contents.contest.commands.ContestCommand;
import fr.openmc.core.features.events.contents.weeklyevents.contents.contest.events.ContestEndEvent;
@@ -28,6 +22,11 @@
import fr.openmc.core.features.mailboxes.MailboxManager;
import fr.openmc.core.hooks.WorldGuardHook;
import fr.openmc.core.hooks.itemsadder.ItemsAdderHook;
+import fr.openmc.core.lifecycle.integration.DatabaseManager;
+import fr.openmc.core.lifecycle.integration.OMCLogger;
+import fr.openmc.core.lifecycle.interfaces.HasDatabase;
+import fr.openmc.core.registry.features.Feature;
+import fr.openmc.core.registry.features.annotations.Credit;
import fr.openmc.core.utils.bukkit.ParticleUtils;
import fr.openmc.core.utils.cache.CacheOfflinePlayer;
import fr.openmc.core.utils.text.ColorUtils;
@@ -55,7 +54,7 @@
import static fr.openmc.core.features.mailboxes.utils.MailboxUtils.getHoverEvent;
@Credit(developers = {"iambibi_"}, graphist = {"Gexary", "Tfloa"})
-public class ContestManager extends Feature implements HasDatabase, LoadAfterItemsAdder {
+public class ContestManager extends Feature implements HasDatabase {
public static ContestData data;
public static Map dataPlayer = new HashMap<>();
diff --git a/src/main/java/fr/openmc/core/features/events/contents/weeklyevents/contents/contest/managers/TradeYMLManager.java b/src/main/java/fr/openmc/core/features/events/contents/weeklyevents/contents/contest/managers/TradeYMLManager.java
index b963884c8..ed477c590 100644
--- a/src/main/java/fr/openmc/core/features/events/contents/weeklyevents/contents/contest/managers/TradeYMLManager.java
+++ b/src/main/java/fr/openmc/core/features/events/contents/weeklyevents/contents/contest/managers/TradeYMLManager.java
@@ -1,8 +1,8 @@
package fr.openmc.core.features.events.contents.weeklyevents.contents.contest.managers;
import fr.openmc.core.OMCPlugin;
-import fr.openmc.core.bootstrap.integration.OMCLogger;
import fr.openmc.core.features.events.contents.weeklyevents.contents.contest.models.ContestData;
+import fr.openmc.core.lifecycle.integration.OMCLogger;
import fr.openmc.core.utils.YmlUtils;
import lombok.Getter;
import org.bukkit.configuration.file.FileConfiguration;
diff --git a/src/main/java/fr/openmc/core/features/friend/FriendManager.java b/src/main/java/fr/openmc/core/features/friend/FriendManager.java
index 901d596d3..3f64c5743 100644
--- a/src/main/java/fr/openmc/core/features/friend/FriendManager.java
+++ b/src/main/java/fr/openmc/core/features/friend/FriendManager.java
@@ -1,11 +1,11 @@
package fr.openmc.core.features.friend;
import com.j256.ormlite.support.ConnectionSource;
-import fr.openmc.core.bootstrap.features.Feature;
-import fr.openmc.core.bootstrap.features.annotations.Credit;
-import fr.openmc.core.bootstrap.features.types.HasCommands;
-import fr.openmc.core.bootstrap.features.types.HasDatabase;
import fr.openmc.core.features.friend.commands.FriendCommand;
+import fr.openmc.core.lifecycle.interfaces.HasCommands;
+import fr.openmc.core.lifecycle.interfaces.HasDatabase;
+import fr.openmc.core.registry.features.Feature;
+import fr.openmc.core.registry.features.annotations.Credit;
import lombok.Getter;
import java.sql.SQLException;
diff --git a/src/main/java/fr/openmc/core/features/friend/FriendSQLManager.java b/src/main/java/fr/openmc/core/features/friend/FriendSQLManager.java
index 1abb25afe..4efa39a80 100644
--- a/src/main/java/fr/openmc/core/features/friend/FriendSQLManager.java
+++ b/src/main/java/fr/openmc/core/features/friend/FriendSQLManager.java
@@ -6,7 +6,7 @@
import com.j256.ormlite.stmt.Where;
import com.j256.ormlite.support.ConnectionSource;
import com.j256.ormlite.table.TableUtils;
-import fr.openmc.core.bootstrap.integration.OMCLogger;
+import fr.openmc.core.lifecycle.integration.OMCLogger;
import fr.openmc.core.utils.text.DateUtils;
import java.sql.SQLException;
diff --git a/src/main/java/fr/openmc/core/features/homes/HomesManager.java b/src/main/java/fr/openmc/core/features/homes/HomesManager.java
index e7d0dea5a..17998ea46 100644
--- a/src/main/java/fr/openmc/core/features/homes/HomesManager.java
+++ b/src/main/java/fr/openmc/core/features/homes/HomesManager.java
@@ -4,15 +4,15 @@
import com.j256.ormlite.dao.DaoManager;
import com.j256.ormlite.support.ConnectionSource;
import com.j256.ormlite.table.TableUtils;
-import fr.openmc.core.bootstrap.features.Feature;
-import fr.openmc.core.bootstrap.features.annotations.Credit;
-import fr.openmc.core.bootstrap.features.types.HasCommands;
-import fr.openmc.core.bootstrap.features.types.HasDatabase;
-import fr.openmc.core.bootstrap.integration.DatabaseManager;
import fr.openmc.core.features.homes.command.*;
import fr.openmc.core.features.homes.models.Home;
import fr.openmc.core.features.homes.models.HomeLimit;
import fr.openmc.core.features.homes.world.DisabledWorldHome;
+import fr.openmc.core.lifecycle.integration.DatabaseManager;
+import fr.openmc.core.lifecycle.interfaces.HasCommands;
+import fr.openmc.core.lifecycle.interfaces.HasDatabase;
+import fr.openmc.core.registry.features.Feature;
+import fr.openmc.core.registry.features.annotations.Credit;
import lombok.Getter;
import java.sql.SQLException;
diff --git a/src/main/java/fr/openmc/core/features/homes/icons/HomeIconCacheManager.java b/src/main/java/fr/openmc/core/features/homes/icons/HomeIconCacheManager.java
index 0dd4b1000..5fbc16bc8 100644
--- a/src/main/java/fr/openmc/core/features/homes/icons/HomeIconCacheManager.java
+++ b/src/main/java/fr/openmc/core/features/homes/icons/HomeIconCacheManager.java
@@ -1,11 +1,10 @@
package fr.openmc.core.features.homes.icons;
import fr.openmc.core.OMCPlugin;
-import fr.openmc.core.bootstrap.features.Feature;
-import fr.openmc.core.bootstrap.features.types.LoadAfterItemsAdder;
-import fr.openmc.core.bootstrap.integration.OMCLogger;
import fr.openmc.core.features.homes.menu.HomeChangeIconMenu;
import fr.openmc.core.features.homes.models.Home;
+import fr.openmc.core.lifecycle.integration.OMCLogger;
+import fr.openmc.core.registry.features.Feature;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
@@ -14,7 +13,7 @@
import java.util.List;
import java.util.concurrent.ConcurrentHashMap;
-public class HomeIconCacheManager extends Feature implements LoadAfterItemsAdder {
+public class HomeIconCacheManager extends Feature {
private static final ConcurrentHashMap> CACHED_ITEMS = new ConcurrentHashMap<>();
private static final ConcurrentHashMap> CACHED_SEARCH_RESULTS = new ConcurrentHashMap<>();
diff --git a/src/main/java/fr/openmc/core/features/homes/world/DisabledWorldHome.java b/src/main/java/fr/openmc/core/features/homes/world/DisabledWorldHome.java
index f39f36d02..63dad0941 100644
--- a/src/main/java/fr/openmc/core/features/homes/world/DisabledWorldHome.java
+++ b/src/main/java/fr/openmc/core/features/homes/world/DisabledWorldHome.java
@@ -1,7 +1,7 @@
package fr.openmc.core.features.homes.world;
import fr.openmc.core.OMCPlugin;
-import fr.openmc.core.bootstrap.integration.OMCLogger;
+import fr.openmc.core.lifecycle.integration.OMCLogger;
import fr.openmc.core.utils.text.messages.TranslationManager;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.NamedTextColor;
diff --git a/src/main/java/fr/openmc/core/features/itemsadder/SpawnerExtractorListener.java b/src/main/java/fr/openmc/core/features/itemsadder/SpawnerExtractorListener.java
index eca7ced01..b7ee27146 100644
--- a/src/main/java/fr/openmc/core/features/itemsadder/SpawnerExtractorListener.java
+++ b/src/main/java/fr/openmc/core/features/itemsadder/SpawnerExtractorListener.java
@@ -2,7 +2,6 @@
import dev.lone.itemsadder.api.CustomStack;
import fr.openmc.core.OMCPlugin;
-import fr.openmc.core.bootstrap.features.types.NotLoadInUnitTest;
import fr.openmc.core.utils.text.messages.TranslationManager;
import net.kyori.adventure.text.Component;
import org.bukkit.Material;
@@ -20,7 +19,7 @@
import java.util.concurrent.ThreadLocalRandom;
-public class SpawnerExtractorListener implements Listener, NotLoadInUnitTest {
+public class SpawnerExtractorListener implements Listener {
private static final double FAILURE_CHANCE = 0.4; // 40% chance d’échec
private static final NamespacedKey KEY_SPAWNER_MOB = new NamespacedKey(OMCPlugin.getInstance(), "spawner_extractor_mob_spawner");
diff --git a/src/main/java/fr/openmc/core/features/itemsadder/elevator/ElevatorManager.java b/src/main/java/fr/openmc/core/features/itemsadder/elevator/ElevatorManager.java
index 6edee3a95..86825a0fe 100644
--- a/src/main/java/fr/openmc/core/features/itemsadder/elevator/ElevatorManager.java
+++ b/src/main/java/fr/openmc/core/features/itemsadder/elevator/ElevatorManager.java
@@ -2,10 +2,10 @@
import dev.lone.itemsadder.api.CustomBlock;
import dev.lone.itemsadder.api.CustomStack;
-import fr.openmc.core.bootstrap.features.Feature;
-import fr.openmc.core.bootstrap.features.annotations.Credit;
-import fr.openmc.core.bootstrap.features.types.HasListeners;
-import fr.openmc.core.bootstrap.listeners.ListenerFactory;
+import fr.openmc.core.lifecycle.interfaces.HasListeners;
+import fr.openmc.core.lifecycle.listeners.ListenerFactory;
+import fr.openmc.core.registry.features.Feature;
+import fr.openmc.core.registry.features.annotations.Credit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Tag;
diff --git a/src/main/java/fr/openmc/core/features/leaderboards/LeaderboardManager.java b/src/main/java/fr/openmc/core/features/leaderboards/LeaderboardManager.java
index 54e4a796b..733db3b5b 100644
--- a/src/main/java/fr/openmc/core/features/leaderboards/LeaderboardManager.java
+++ b/src/main/java/fr/openmc/core/features/leaderboards/LeaderboardManager.java
@@ -1,13 +1,8 @@
package fr.openmc.core.features.leaderboards;
import fr.openmc.core.OMCPlugin;
-import fr.openmc.core.bootstrap.features.Feature;
-import fr.openmc.core.bootstrap.features.annotations.Credit;
-import fr.openmc.core.bootstrap.features.types.HasCommands;
-import fr.openmc.core.bootstrap.features.types.LoadAfterItemsAdder;
-import fr.openmc.core.bootstrap.features.types.NotLoadInUnitTest;
+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.BankManager;
import fr.openmc.core.features.economy.EconomyManager;
import fr.openmc.core.features.economy.models.EconomyPlayer;
@@ -16,6 +11,9 @@
import fr.openmc.core.features.leaderboards.commands.LeaderboardCommands;
import fr.openmc.core.hooks.github.GitHubHook;
import fr.openmc.core.hooks.github.models.ContributorStats;
+import fr.openmc.core.lifecycle.interfaces.HasCommands;
+import fr.openmc.core.registry.features.Feature;
+import fr.openmc.core.registry.features.annotations.Credit;
import fr.openmc.core.utils.cache.PlayerNameCache;
import fr.openmc.core.utils.text.DateUtils;
import fr.openmc.core.utils.text.messages.TranslationManager;
@@ -41,7 +39,7 @@
import java.util.*;
@Credit(developers = {"miseur"})
-public class LeaderboardManager extends Feature implements NotLoadInUnitTest, LoadAfterItemsAdder, HasCommands {
+public class LeaderboardManager extends Feature implements HasCommands {
@Getter
private static final Map> githubContributorsMap = new TreeMap<>();
@Getter
@@ -448,12 +446,13 @@ private static void loadLeaderBoardConfig() {
* Documentation GitHub API (REST)
*/
public static void updateGithubContributorsMap() {
- GitHubHook.fetchContributorStats();
+ GitHubHook gitHubHook = OMCRegistry.HOOKS.GITHUB;
+ gitHubHook.fetchContributorStats();
List> statsList = new ArrayList<>();
- for (String login : GitHubHook.getContributors().values()) {
- ContributorStats stats = GitHubHook.getStats(login);
+ for (String login : gitHubHook.getContributors().values()) {
+ ContributorStats stats = gitHubHook.getStats(login);
if (stats == null) continue;
statsList.add(new AbstractMap.SimpleEntry<>(login, stats));
@@ -499,7 +498,7 @@ public static void updatePlayerMoneyMap() {
public static void updateCityMoneyMap() {
villeMoneyMap.clear();
int rank = 1;
- for (City city : CityManager.getCities().stream()
+ for (City city : OMCRegistry.FEATURES.CITY.get().getCities().stream()
.sorted((city1, city2) -> Double.compare(city2.getBalance(), city1.getBalance()))
.limit(10)
.toList()) {
diff --git a/src/main/java/fr/openmc/core/features/mailboxes/MailboxManager.java b/src/main/java/fr/openmc/core/features/mailboxes/MailboxManager.java
index 267eb5eea..19d1bed61 100644
--- a/src/main/java/fr/openmc/core/features/mailboxes/MailboxManager.java
+++ b/src/main/java/fr/openmc/core/features/mailboxes/MailboxManager.java
@@ -4,17 +4,17 @@
import com.j256.ormlite.dao.DaoManager;
import com.j256.ormlite.support.ConnectionSource;
import com.j256.ormlite.table.TableUtils;
-import fr.openmc.core.bootstrap.features.Feature;
-import fr.openmc.core.bootstrap.features.annotations.Credit;
-import fr.openmc.core.bootstrap.features.types.HasCommands;
-import fr.openmc.core.bootstrap.features.types.HasDatabase;
-import fr.openmc.core.bootstrap.integration.OMCLogger;
import fr.openmc.core.features.mailboxes.commands.MailboxCommand;
import fr.openmc.core.features.mailboxes.menu.PlayerMailbox;
import fr.openmc.core.features.mailboxes.menu.letter.LetterMenu;
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.lifecycle.integration.OMCLogger;
+import fr.openmc.core.lifecycle.interfaces.HasCommands;
+import fr.openmc.core.lifecycle.interfaces.HasDatabase;
+import fr.openmc.core.registry.features.Feature;
+import fr.openmc.core.registry.features.annotations.Credit;
import fr.openmc.core.utils.bukkit.serializer.BukkitSerializer;
import fr.openmc.core.utils.text.DateUtils;
import fr.openmc.core.utils.text.messages.MessageType;
diff --git a/src/main/java/fr/openmc/core/features/mainmenu/MainMenu.java b/src/main/java/fr/openmc/core/features/mainmenu/MainMenu.java
index 203e42281..1680d4038 100644
--- a/src/main/java/fr/openmc/core/features/mainmenu/MainMenu.java
+++ b/src/main/java/fr/openmc/core/features/mainmenu/MainMenu.java
@@ -2,22 +2,18 @@
import fr.openmc.api.packetmenulib.PacketMenuLib;
import fr.openmc.core.OMCPlugin;
-import fr.openmc.core.bootstrap.features.Feature;
-import fr.openmc.core.bootstrap.features.annotations.Credit;
-import fr.openmc.core.bootstrap.features.types.HasCommands;
-import fr.openmc.core.bootstrap.features.types.LoadAfterItemsAdder;
-import fr.openmc.core.bootstrap.features.types.LoadIfEnable;
-import fr.openmc.core.bootstrap.features.types.NotLoadInUnitTest;
import fr.openmc.core.features.mainmenu.commands.MainMenuCommand;
import fr.openmc.core.features.mainmenu.listeners.MainMenuListener;
import fr.openmc.core.features.mainmenu.menus.Page1;
-import fr.openmc.core.hooks.ProtocolLibHook;
+import fr.openmc.core.lifecycle.interfaces.HasCommands;
+import fr.openmc.core.registry.features.Feature;
+import fr.openmc.core.registry.features.annotations.Credit;
import org.bukkit.entity.Player;
import java.util.Set;
@Credit(developers = {"miseur"}, graphist = {"Tfloa"})
-public class MainMenu extends Feature implements NotLoadInUnitTest, LoadAfterItemsAdder, LoadIfEnable, HasCommands {
+public class MainMenu extends Feature implements HasCommands {
@Override
public void init() {
new MainMenuListener(OMCPlugin.getInstance());
diff --git a/src/main/java/fr/openmc/core/features/mainmenu/menus/Page1.java b/src/main/java/fr/openmc/core/features/mainmenu/menus/Page1.java
index b7c1526b4..780203352 100644
--- a/src/main/java/fr/openmc/core/features/mainmenu/menus/Page1.java
+++ b/src/main/java/fr/openmc/core/features/mainmenu/menus/Page1.java
@@ -10,6 +10,7 @@
import fr.openmc.api.packetmenulib.menu.InventoryType;
import fr.openmc.api.packetmenulib.menu.Menu;
import fr.openmc.core.OMCPlugin;
+import fr.openmc.core.OMCRegistry;
import fr.openmc.core.features.adminshop.AdminShopManager;
import fr.openmc.core.features.city.City;
import fr.openmc.core.features.city.CityManager;
@@ -69,6 +70,8 @@ public class Page1 implements Menu {
private static final Set MAILBOX_SLOTS = Set.of(85, 86, 87);
private static final int ADVANCEMENTS_SLOT = 88;
+ private final AdminShopManager adminShopManager;
+
public Page1(Player player) {
City playerCity = CityManager.getPlayerCity(player.getUniqueId());
ItemStack cityItem = new ItemStack(Material.PAPER);
@@ -226,6 +229,8 @@ public Page1(Player player) {
.color(NamedTextColor.DARK_GRAY)));
});
MAILBOX_SLOTS.forEach(slot -> content.put(slot, mailboxItem));
+
+ this.adminShopManager = OMCRegistry.FEATURES.ADMIN_SHOP.get();
}
@Override
@@ -275,7 +280,7 @@ public void onInventoryClick(InventoryClickEvent event) {
} else if (CONTEST_SLOTS.contains(slot)) {
Bukkit.getScheduler().runTask(OMCPlugin.getInstance(), () -> ContestCommand.mainCommand(player));
} else if (SHOP_SLOTS.contains(slot)) {
- Bukkit.getScheduler().runTask(OMCPlugin.getInstance(), () -> AdminShopManager.openMainMenu(player));
+ Bukkit.getScheduler().runTask(OMCPlugin.getInstance(), () -> adminShopManager.openMainMenu(player));
} else if (HOME_SLOTS.contains(slot)) {
Bukkit.getScheduler().runTask(OMCPlugin.getInstance(), () -> TpHomeCommand.home(omcPlayer, null));
} else if (PROFILE_SLOTS.contains(slot)) {
diff --git a/src/main/java/fr/openmc/core/features/milestones/MilestonesManager.java b/src/main/java/fr/openmc/core/features/milestones/MilestonesManager.java
index acc45ed05..fddad88a5 100644
--- a/src/main/java/fr/openmc/core/features/milestones/MilestonesManager.java
+++ b/src/main/java/fr/openmc/core/features/milestones/MilestonesManager.java
@@ -5,14 +5,6 @@
import com.j256.ormlite.support.ConnectionSource;
import com.j256.ormlite.table.TableUtils;
import fr.openmc.core.OMCPlugin;
-import fr.openmc.core.bootstrap.features.Feature;
-import fr.openmc.core.bootstrap.features.annotations.Credit;
-import fr.openmc.core.bootstrap.features.types.HasCommands;
-import fr.openmc.core.bootstrap.features.types.HasDatabase;
-import fr.openmc.core.bootstrap.features.types.HasListeners;
-import fr.openmc.core.bootstrap.features.types.LoadAfterItemsAdder;
-import fr.openmc.core.bootstrap.integration.OMCLogger;
-import fr.openmc.core.bootstrap.listeners.ListenerFactory;
import fr.openmc.core.features.displays.bossbar.BossbarManager;
import fr.openmc.core.features.milestones.bossbar.MilestoneBossBar;
import fr.openmc.core.features.milestones.commands.MilestoneCommand;
@@ -21,6 +13,13 @@
import fr.openmc.core.features.milestones.models.MilestoneModel;
import fr.openmc.core.features.milestones.models.MilestoneType;
import fr.openmc.core.features.quests.objects.Quest;
+import fr.openmc.core.lifecycle.integration.OMCLogger;
+import fr.openmc.core.lifecycle.interfaces.HasCommands;
+import fr.openmc.core.lifecycle.interfaces.HasDatabase;
+import fr.openmc.core.lifecycle.interfaces.HasListeners;
+import fr.openmc.core.lifecycle.listeners.ListenerFactory;
+import fr.openmc.core.registry.features.Feature;
+import fr.openmc.core.registry.features.annotations.Credit;
import org.bukkit.entity.Player;
import org.bukkit.event.Listener;
@@ -28,7 +27,7 @@
import java.util.*;
@Credit(developers = {"iambibi_", "gab400"})
-public class MilestonesManager extends Feature implements HasDatabase, LoadAfterItemsAdder, HasListeners, HasCommands {
+public class MilestonesManager extends Feature implements HasDatabase, HasListeners, HasCommands {
private static final Set> milestones = new HashSet<>();
private static Dao millestoneDao;
diff --git a/src/main/java/fr/openmc/core/features/privatemessage/PrivateMessageManager.java b/src/main/java/fr/openmc/core/features/privatemessage/PrivateMessageManager.java
index 27f5f0e19..80aab5590 100644
--- a/src/main/java/fr/openmc/core/features/privatemessage/PrivateMessageManager.java
+++ b/src/main/java/fr/openmc/core/features/privatemessage/PrivateMessageManager.java
@@ -1,10 +1,10 @@
package fr.openmc.core.features.privatemessage;
import fr.openmc.api.entity.player.OMCPlayer;
-import fr.openmc.core.bootstrap.features.Feature;
-import fr.openmc.core.bootstrap.features.annotations.Credit;
-import fr.openmc.core.bootstrap.features.types.HasCommands;
import fr.openmc.core.features.privatemessage.command.PrivateMessageCommand;
+import fr.openmc.core.lifecycle.interfaces.HasCommands;
+import fr.openmc.core.registry.features.Feature;
+import fr.openmc.core.registry.features.annotations.Credit;
import fr.openmc.core.utils.text.messages.MessageType;
import fr.openmc.core.utils.text.messages.MessagesManager;
import fr.openmc.core.utils.text.messages.Prefix;
diff --git a/src/main/java/fr/openmc/core/features/privatemessage/SocialSpyManager.java b/src/main/java/fr/openmc/core/features/privatemessage/SocialSpyManager.java
index c546f375a..8dbdec409 100644
--- a/src/main/java/fr/openmc/core/features/privatemessage/SocialSpyManager.java
+++ b/src/main/java/fr/openmc/core/features/privatemessage/SocialSpyManager.java
@@ -1,9 +1,9 @@
package fr.openmc.core.features.privatemessage;
-import fr.openmc.core.bootstrap.features.Feature;
-import fr.openmc.core.bootstrap.features.annotations.Credit;
-import fr.openmc.core.bootstrap.features.types.HasCommands;
import fr.openmc.core.features.privatemessage.command.SocialSpyCommand;
+import fr.openmc.core.lifecycle.interfaces.HasCommands;
+import fr.openmc.core.registry.features.Feature;
+import fr.openmc.core.registry.features.annotations.Credit;
import fr.openmc.core.utils.text.messages.MessageType;
import fr.openmc.core.utils.text.messages.MessagesManager;
import fr.openmc.core.utils.text.messages.Prefix;
diff --git a/src/main/java/fr/openmc/core/features/profile/ProfileManager.java b/src/main/java/fr/openmc/core/features/profile/ProfileManager.java
index d42c9b598..573892889 100644
--- a/src/main/java/fr/openmc/core/features/profile/ProfileManager.java
+++ b/src/main/java/fr/openmc/core/features/profile/ProfileManager.java
@@ -1,18 +1,17 @@
package fr.openmc.core.features.profile;
-import fr.openmc.core.bootstrap.features.Feature;
-import fr.openmc.core.bootstrap.features.annotations.Credit;
-import fr.openmc.core.bootstrap.features.types.HasCommands;
-import fr.openmc.core.bootstrap.features.types.HasListeners;
-import fr.openmc.core.bootstrap.features.types.LoadAfterItemsAdder;
-import fr.openmc.core.bootstrap.listeners.ListenerFactory;
import fr.openmc.core.features.profile.command.ProfileCommand;
import fr.openmc.core.features.profile.listeners.ProfileInteractionListener;
+import fr.openmc.core.lifecycle.interfaces.HasCommands;
+import fr.openmc.core.lifecycle.interfaces.HasListeners;
+import fr.openmc.core.lifecycle.listeners.ListenerFactory;
+import fr.openmc.core.registry.features.Feature;
+import fr.openmc.core.registry.features.annotations.Credit;
import java.util.Set;
@Credit(developers = {"ar1hurgit"})
-public class ProfileManager extends Feature implements LoadAfterItemsAdder, HasCommands, HasListeners {
+public class ProfileManager extends Feature implements HasCommands, HasListeners {
@Override
public Set getCommands() {
return Set.of(
diff --git a/src/main/java/fr/openmc/core/features/profile/menu/ProfileMenu.java b/src/main/java/fr/openmc/core/features/profile/menu/ProfileMenu.java
index daee4ab63..1429cb2f7 100644
--- a/src/main/java/fr/openmc/core/features/profile/menu/ProfileMenu.java
+++ b/src/main/java/fr/openmc/core/features/profile/menu/ProfileMenu.java
@@ -6,7 +6,6 @@
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.menu.list.CityListDetailsMenu;
import fr.openmc.core.features.friend.FriendManager;
import fr.openmc.core.features.mailboxes.menu.PlayerMailbox;
@@ -94,13 +93,14 @@ public void onClose(InventoryCloseEvent event) {
@SuppressWarnings("UnstableApiUsage")
private void addIdentityItem(Map inventory) {
+ GitHubHook gitHubHook = OMCRegistry.HOOKS.GITHUB;
String statusKey = target.isOnline()
? "feature.profile.status.online"
: "feature.profile.status.offline";
String discordUsername = DiscordLinkManager.getLinkedDiscordUsername(target.getUniqueId());
- Long githubId = GitHubHook.getContributorId(target.getUniqueId());
- String githubUsername = githubId == null ? null : GitHubHook.getUsernameById(githubId);
+ Long githubId = gitHubHook.getContributorId(target.getUniqueId());
+ String githubUsername = githubId == null ? null : gitHubHook.getUsernameById(githubId);
List lore = new ArrayList<>(TranslationManager.translationLore(
"feature.profile.item.identity.lore",
@@ -128,7 +128,7 @@ private void addIdentityItem(Map inventory) {
if (click.getWhoClicked().getUniqueId() == target.getUniqueId()) {
Player owner = getOwner();
Bukkit.getScheduler().runTaskAsynchronously(OMCPlugin.getInstance(), () -> {
- GitHubHook.refreshContributorId(target.getUniqueId());
+ gitHubHook.refreshContributorId(target.getUniqueId());
Bukkit.getScheduler().runTask(OMCPlugin.getInstance(), () -> {
if (owner.isOnline()) {
new ProfileMenu(owner, target).open();
@@ -210,7 +210,7 @@ private void openMailbox(boolean selfProfile) {
}
private void addCityItem(Map inventory) {
- City city = CityManager.getPlayerCity(target.getUniqueId());
+ City city = OMCRegistry.FEATURES.CITY.get().getPlayerCity(target.getUniqueId());
if (city == null) {
inventory.put(15, new ItemMenuBuilder(
this,
diff --git a/src/main/java/fr/openmc/core/features/quests/QuestProgressSaveManager.java b/src/main/java/fr/openmc/core/features/quests/QuestProgressSaveManager.java
index e591f424d..d44e312d3 100644
--- a/src/main/java/fr/openmc/core/features/quests/QuestProgressSaveManager.java
+++ b/src/main/java/fr/openmc/core/features/quests/QuestProgressSaveManager.java
@@ -1,11 +1,11 @@
package fr.openmc.core.features.quests;
import fr.openmc.core.OMCPlugin;
-import fr.openmc.core.bootstrap.features.Feature;
-import fr.openmc.core.bootstrap.integration.OMCLogger;
import fr.openmc.core.features.quests.objects.Quest;
import fr.openmc.core.features.quests.objects.QuestStep;
import fr.openmc.core.features.quests.objects.QuestTier;
+import fr.openmc.core.lifecycle.integration.OMCLogger;
+import fr.openmc.core.registry.features.Feature;
import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
import org.bukkit.configuration.file.YamlConfiguration;
diff --git a/src/main/java/fr/openmc/core/features/quests/QuestsManager.java b/src/main/java/fr/openmc/core/features/quests/QuestsManager.java
index 28856d26e..17b12a72a 100644
--- a/src/main/java/fr/openmc/core/features/quests/QuestsManager.java
+++ b/src/main/java/fr/openmc/core/features/quests/QuestsManager.java
@@ -1,14 +1,13 @@
package fr.openmc.core.features.quests;
import fr.openmc.core.OMCPlugin;
-import fr.openmc.core.bootstrap.features.Feature;
-import fr.openmc.core.bootstrap.features.annotations.Credit;
-import fr.openmc.core.bootstrap.features.types.HasCommands;
-import fr.openmc.core.bootstrap.features.types.LoadAfterItemsAdder;
-import fr.openmc.core.bootstrap.integration.OMCLogger;
import fr.openmc.core.features.quests.command.QuestCommand;
import fr.openmc.core.features.quests.objects.Quest;
import fr.openmc.core.features.quests.quests.*;
+import fr.openmc.core.lifecycle.integration.OMCLogger;
+import fr.openmc.core.lifecycle.interfaces.HasCommands;
+import fr.openmc.core.registry.features.Feature;
+import fr.openmc.core.registry.features.annotations.Credit;
import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
import org.bukkit.Bukkit;
import org.bukkit.event.Listener;
@@ -22,7 +21,7 @@
* and saving quest progress for players.
*/
@Credit(developers = {"Axeno"}, graphist = {"Gexary"})
-public class QuestsManager extends Feature implements LoadAfterItemsAdder, HasCommands {
+public class QuestsManager extends Feature implements HasCommands {
static final Map quests = new HashMap<>();
/**
diff --git a/src/main/java/fr/openmc/core/features/settings/PlayerSettings.java b/src/main/java/fr/openmc/core/features/settings/PlayerSettings.java
index 2d6c2abb0..45a41303b 100644
--- a/src/main/java/fr/openmc/core/features/settings/PlayerSettings.java
+++ b/src/main/java/fr/openmc/core/features/settings/PlayerSettings.java
@@ -1,7 +1,7 @@
package fr.openmc.core.features.settings;
+import fr.openmc.core.OMCRegistry;
import fr.openmc.core.features.city.City;
-import fr.openmc.core.features.city.CityManager;
import fr.openmc.core.features.friend.FriendManager;
import fr.openmc.core.features.settings.policy.CityPolicy;
import fr.openmc.core.features.settings.policy.FriendPolicy;
@@ -214,7 +214,7 @@ public boolean isVisibleToEveryone(SettingType visibilitySetting) {
* @return true if both players are members of the same city, false otherwise
*/
private boolean areSameCityMembers(UUID player1UUID, UUID player2UUID) {
- City player2City = CityManager.getPlayerCity(player2UUID);
+ City player2City = OMCRegistry.FEATURES.CITY.get().getPlayerCity(player2UUID);
Player player1 = Bukkit.getPlayer(player1UUID);
return player1 != null && player2City != null && player2City.isMember(player1);
}
diff --git a/src/main/java/fr/openmc/core/features/settings/PlayerSettingsManager.java b/src/main/java/fr/openmc/core/features/settings/PlayerSettingsManager.java
index 8e803c61c..8e6dfd21e 100644
--- a/src/main/java/fr/openmc/core/features/settings/PlayerSettingsManager.java
+++ b/src/main/java/fr/openmc/core/features/settings/PlayerSettingsManager.java
@@ -6,16 +6,16 @@
import com.j256.ormlite.stmt.QueryBuilder;
import com.j256.ormlite.support.ConnectionSource;
import com.j256.ormlite.table.TableUtils;
-import fr.openmc.core.bootstrap.features.Feature;
-import fr.openmc.core.bootstrap.features.annotations.Credit;
-import fr.openmc.core.bootstrap.features.types.HasCommands;
-import fr.openmc.core.bootstrap.features.types.HasDatabase;
-import fr.openmc.core.bootstrap.features.types.HasListeners;
-import fr.openmc.core.bootstrap.integration.OMCLogger;
-import fr.openmc.core.bootstrap.listeners.ListenerFactory;
import fr.openmc.core.features.settings.command.SettingsCommand;
import fr.openmc.core.features.settings.listeners.PlayerSettingsListener;
import fr.openmc.core.features.settings.models.PlayerSettingEntity;
+import fr.openmc.core.lifecycle.integration.OMCLogger;
+import fr.openmc.core.lifecycle.interfaces.HasCommands;
+import fr.openmc.core.lifecycle.interfaces.HasDatabase;
+import fr.openmc.core.lifecycle.interfaces.HasListeners;
+import fr.openmc.core.lifecycle.listeners.ListenerFactory;
+import fr.openmc.core.registry.features.Feature;
+import fr.openmc.core.registry.features.annotations.Credit;
import lombok.Getter;
import org.bukkit.entity.Player;
diff --git a/src/main/java/fr/openmc/core/features/shops/managers/PlayerShopManager.java b/src/main/java/fr/openmc/core/features/shops/managers/PlayerShopManager.java
index 49f791488..629eac7e9 100644
--- a/src/main/java/fr/openmc/core/features/shops/managers/PlayerShopManager.java
+++ b/src/main/java/fr/openmc/core/features/shops/managers/PlayerShopManager.java
@@ -2,13 +2,14 @@
import fr.openmc.api.input.location.ItemInteraction;
import fr.openmc.core.OMCPlugin;
-import fr.openmc.core.bootstrap.integration.OMCLogger;
+import fr.openmc.core.OMCRegistry;
import fr.openmc.core.features.city.CityManager;
import fr.openmc.core.features.city.ProtectionsManager;
import fr.openmc.core.features.economy.EconomyManager;
import fr.openmc.core.features.shops.events.PlaceShopEvent;
import fr.openmc.core.features.shops.models.Shop;
import fr.openmc.core.hooks.WorldGuardHook;
+import fr.openmc.core.lifecycle.integration.OMCLogger;
import fr.openmc.core.utils.text.messages.MessageType;
import fr.openmc.core.utils.text.messages.MessagesManager;
import fr.openmc.core.utils.text.messages.Prefix;
@@ -69,13 +70,15 @@ public static void startCreatingShop(Player player) {
*/
private static boolean createShop(Player player, Location location) {
Shop shop = new Shop(player.getUniqueId(), location.setRotation(0, 0));
+ CityManager cityManager = OMCRegistry.FEATURES.CITY.get();
if (WorldGuardHook.isRegionConflict(location)) return false;
if (!ProtectionsManager.canBypassPlayer.contains(player.getUniqueId())) {
- if ((CityManager.isChunkClaimed(location.getChunk())
- && !CityManager.getPlayerCity(player.getUniqueId())
- .equals(CityManager.getCityFromChunk(location.getChunk())))
- || (CityManager.isChunkClaimed(location.getChunk()) && CityManager.getPlayerCity(player.getUniqueId()) == null)) {
+ CityManager city = cityManager.getPlayerCity(player.getUniqueId());
+ if ((cityManager.isChunkClaimed(location.getChunk())
+ && city != null
+ && !city.equals(cityManager.getCityFromChunk(location.getChunk())))
+ || (cityManager.isChunkClaimed(location.getChunk()) && city == null)) {
MessagesManager.sendMessage(player, TranslationManager.translation("feature.shop.player.chunk_claimed"), Prefix.SHOP, MessageType.ERROR, true);
return false;
}
diff --git a/src/main/java/fr/openmc/core/features/shops/managers/ShopDatabaseManager.java b/src/main/java/fr/openmc/core/features/shops/managers/ShopDatabaseManager.java
index c6782c187..d60e7c09a 100644
--- a/src/main/java/fr/openmc/core/features/shops/managers/ShopDatabaseManager.java
+++ b/src/main/java/fr/openmc/core/features/shops/managers/ShopDatabaseManager.java
@@ -4,10 +4,10 @@
import com.j256.ormlite.dao.DaoManager;
import com.j256.ormlite.support.ConnectionSource;
import com.j256.ormlite.table.TableUtils;
-import fr.openmc.core.bootstrap.integration.OMCLogger;
import fr.openmc.core.features.shops.models.Shop;
import fr.openmc.core.features.shops.models.ShopItem;
import fr.openmc.core.features.shops.models.ShopSale;
+import fr.openmc.core.lifecycle.integration.OMCLogger;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.jspecify.annotations.NonNull;
diff --git a/src/main/java/fr/openmc/core/features/shops/managers/ShopManager.java b/src/main/java/fr/openmc/core/features/shops/managers/ShopManager.java
index 08639401d..1f385d1d7 100644
--- a/src/main/java/fr/openmc/core/features/shops/managers/ShopManager.java
+++ b/src/main/java/fr/openmc/core/features/shops/managers/ShopManager.java
@@ -2,20 +2,19 @@
import com.j256.ormlite.support.ConnectionSource;
import fr.openmc.core.OMCPlugin;
-import fr.openmc.core.bootstrap.features.Feature;
-import fr.openmc.core.bootstrap.features.annotations.Credit;
-import fr.openmc.core.bootstrap.features.types.HasCommands;
-import fr.openmc.core.bootstrap.features.types.HasDatabase;
-import fr.openmc.core.bootstrap.features.types.HasListeners;
-import fr.openmc.core.bootstrap.features.types.LoadAfterItemsAdder;
-import fr.openmc.core.bootstrap.integration.OMCLogger;
-import fr.openmc.core.bootstrap.listeners.ListenerFactory;
import fr.openmc.core.features.shops.ShopCommand;
import fr.openmc.core.features.shops.ShopFurniture;
import fr.openmc.core.features.shops.ShopListener;
import fr.openmc.core.features.shops.models.Shop;
import fr.openmc.core.features.shops.models.ShopSale;
import fr.openmc.core.hooks.itemsadder.ItemsAdderHook;
+import fr.openmc.core.lifecycle.integration.OMCLogger;
+import fr.openmc.core.lifecycle.interfaces.HasCommands;
+import fr.openmc.core.lifecycle.interfaces.HasDatabase;
+import fr.openmc.core.lifecycle.interfaces.HasListeners;
+import fr.openmc.core.lifecycle.listeners.ListenerFactory;
+import fr.openmc.core.registry.features.Feature;
+import fr.openmc.core.registry.features.annotations.Credit;
import fr.openmc.core.utils.world.WorldUtils;
import lombok.Getter;
import org.bukkit.Bukkit;
@@ -29,7 +28,7 @@
import java.util.*;
@Credit(developers = {"gab400", "Nocolm", "Xernas78"}, graphist = {"Gexary"})
-public class ShopManager extends Feature implements LoadAfterItemsAdder, HasDatabase, HasListeners, HasCommands {
+public class ShopManager extends Feature implements HasDatabase, HasListeners, HasCommands {
@Getter
private static final Map shops = new HashMap<>();
diff --git a/src/main/java/fr/openmc/core/features/tickets/TicketListener.java b/src/main/java/fr/openmc/core/features/tickets/TicketListener.java
index 0b50bfc5f..9cee3916d 100644
--- a/src/main/java/fr/openmc/core/features/tickets/TicketListener.java
+++ b/src/main/java/fr/openmc/core/features/tickets/TicketListener.java
@@ -4,7 +4,6 @@
import dev.lone.itemsadder.api.Events.FurnitureInteractEvent;
import dev.lone.itemsadder.api.Events.FurniturePlacedEvent;
import fr.openmc.core.OMCRegistry;
-import fr.openmc.core.bootstrap.features.types.NotLoadInUnitTest;
import fr.openmc.core.events.LootboxRewardEvent;
import fr.openmc.core.features.displays.holograms.Hologram;
import fr.openmc.core.features.displays.holograms.HologramLoader;
@@ -27,7 +26,7 @@
import java.util.Objects;
import java.util.concurrent.ConcurrentHashMap;
-public class TicketListener implements Listener, NotLoadInUnitTest {
+public class TicketListener implements Listener {
private final Map machineHolograms = new ConcurrentHashMap<>();
diff --git a/src/main/java/fr/openmc/core/features/tickets/TicketManager.java b/src/main/java/fr/openmc/core/features/tickets/TicketManager.java
index 5e2eab52b..918f0f601 100644
--- a/src/main/java/fr/openmc/core/features/tickets/TicketManager.java
+++ b/src/main/java/fr/openmc/core/features/tickets/TicketManager.java
@@ -4,11 +4,11 @@
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
-import fr.openmc.core.bootstrap.features.Feature;
-import fr.openmc.core.bootstrap.features.annotations.Credit;
-import fr.openmc.core.bootstrap.features.types.HasListeners;
-import fr.openmc.core.bootstrap.integration.OMCLogger;
-import fr.openmc.core.bootstrap.listeners.ListenerFactory;
+import fr.openmc.core.lifecycle.integration.OMCLogger;
+import fr.openmc.core.lifecycle.interfaces.HasListeners;
+import fr.openmc.core.lifecycle.listeners.ListenerFactory;
+import fr.openmc.core.registry.features.Feature;
+import fr.openmc.core.registry.features.annotations.Credit;
import lombok.Getter;
import lombok.Setter;
diff --git a/src/main/java/fr/openmc/core/features/toor/DiscordLinkManager.java b/src/main/java/fr/openmc/core/features/toor/DiscordLinkManager.java
index ca445ebbc..29badefd8 100644
--- a/src/main/java/fr/openmc/core/features/toor/DiscordLinkManager.java
+++ b/src/main/java/fr/openmc/core/features/toor/DiscordLinkManager.java
@@ -5,15 +5,15 @@
import com.j256.ormlite.support.ConnectionSource;
import com.j256.ormlite.table.TableUtils;
import fr.openmc.core.OMCPlugin;
-import fr.openmc.core.bootstrap.features.Feature;
-import fr.openmc.core.bootstrap.features.types.HasCommands;
-import fr.openmc.core.bootstrap.features.types.HasDatabase;
-import fr.openmc.core.bootstrap.integration.OMCLogger;
import fr.openmc.core.features.toor.commands.LinkCommand;
import fr.openmc.core.features.toor.commands.UnlinkCommand;
import fr.openmc.core.features.toor.event.ConnectToDiscordEvent;
import fr.openmc.core.features.toor.models.DBDiscordLink;
import fr.openmc.core.features.toor.utils.RequestSigner;
+import fr.openmc.core.lifecycle.integration.OMCLogger;
+import fr.openmc.core.lifecycle.interfaces.HasCommands;
+import fr.openmc.core.lifecycle.interfaces.HasDatabase;
+import fr.openmc.core.registry.features.Feature;
import fr.openmc.core.utils.cache.TtlCache;
import fr.openmc.core.utils.text.messages.MessageType;
import fr.openmc.core.utils.text.messages.MessagesManager;
diff --git a/src/main/java/fr/openmc/core/features/toor/InternalToorApiClient.java b/src/main/java/fr/openmc/core/features/toor/InternalToorApiClient.java
index 60c675e15..38636d6bd 100644
--- a/src/main/java/fr/openmc/core/features/toor/InternalToorApiClient.java
+++ b/src/main/java/fr/openmc/core/features/toor/InternalToorApiClient.java
@@ -1,7 +1,7 @@
package fr.openmc.core.features.toor;
-import fr.openmc.core.bootstrap.integration.OMCLogger;
import fr.openmc.core.features.toor.utils.RequestSigner;
+import fr.openmc.core.lifecycle.integration.OMCLogger;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
diff --git a/src/main/java/fr/openmc/core/features/toor/utils/RequestSigner.java b/src/main/java/fr/openmc/core/features/toor/utils/RequestSigner.java
index 66321fc19..dd64464bf 100644
--- a/src/main/java/fr/openmc/core/features/toor/utils/RequestSigner.java
+++ b/src/main/java/fr/openmc/core/features/toor/utils/RequestSigner.java
@@ -1,6 +1,6 @@
package fr.openmc.core.features.toor.utils;
-import fr.openmc.core.bootstrap.features.DisableFeatureException;
+import fr.openmc.core.registry.features.DisableFeatureException;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
diff --git a/src/main/java/fr/openmc/core/features/tpa/TPAManager.java b/src/main/java/fr/openmc/core/features/tpa/TPAManager.java
index 32e1a3e17..66d082f28 100644
--- a/src/main/java/fr/openmc/core/features/tpa/TPAManager.java
+++ b/src/main/java/fr/openmc/core/features/tpa/TPAManager.java
@@ -1,12 +1,12 @@
package fr.openmc.core.features.tpa;
-import fr.openmc.core.bootstrap.features.Feature;
-import fr.openmc.core.bootstrap.features.annotations.Credit;
-import fr.openmc.core.bootstrap.features.types.HasCommands;
import fr.openmc.core.features.tpa.commands.TPACancelCommand;
import fr.openmc.core.features.tpa.commands.TPACommand;
import fr.openmc.core.features.tpa.commands.TPADenyCommand;
import fr.openmc.core.features.tpa.commands.TPAcceptCommand;
+import fr.openmc.core.lifecycle.interfaces.HasCommands;
+import fr.openmc.core.registry.features.Feature;
+import fr.openmc.core.registry.features.annotations.Credit;
import fr.openmc.core.utils.text.messages.MessageType;
import fr.openmc.core.utils.text.messages.MessagesManager;
import fr.openmc.core.utils.text.messages.Prefix;
diff --git a/src/main/java/fr/openmc/core/features/updates/UpdateManager.java b/src/main/java/fr/openmc/core/features/updates/UpdateManager.java
index cdc3d4686..15c85fce8 100644
--- a/src/main/java/fr/openmc/core/features/updates/UpdateManager.java
+++ b/src/main/java/fr/openmc/core/features/updates/UpdateManager.java
@@ -1,10 +1,10 @@
package fr.openmc.core.features.updates;
import fr.openmc.core.OMCPlugin;
-import fr.openmc.core.bootstrap.features.Feature;
-import fr.openmc.core.bootstrap.features.types.HasCommands;
-import fr.openmc.core.bootstrap.features.types.HasListeners;
-import fr.openmc.core.bootstrap.listeners.ListenerFactory;
+import fr.openmc.core.lifecycle.interfaces.HasCommands;
+import fr.openmc.core.lifecycle.interfaces.HasListeners;
+import fr.openmc.core.lifecycle.listeners.ListenerFactory;
+import fr.openmc.core.registry.features.Feature;
import fr.openmc.core.utils.text.messages.TranslationManager;
import lombok.Getter;
import net.kyori.adventure.text.Component;
diff --git a/src/main/java/fr/openmc/core/hooks/FancyNpcsHook.java b/src/main/java/fr/openmc/core/hooks/FancyNpcsHook.java
index d9d0542d0..be9829071 100644
--- a/src/main/java/fr/openmc/core/hooks/FancyNpcsHook.java
+++ b/src/main/java/fr/openmc/core/hooks/FancyNpcsHook.java
@@ -1,11 +1,11 @@
package fr.openmc.core.hooks;
-import fr.openmc.core.bootstrap.hooks.Hooks;
+import fr.openmc.core.registry.hooks.Hooks;
public class FancyNpcsHook extends Hooks {
public static long FANCY_INIT_DELAY = 20L * 30; // 30 seconds
- public static boolean isEnable() {
+ public boolean isEnable() {
return Hooks.isEnabled(FancyNpcsHook.class);
}
diff --git a/src/main/java/fr/openmc/core/hooks/LuckPermsHook.java b/src/main/java/fr/openmc/core/hooks/LuckPermsHook.java
index 1272682da..7418ac0e0 100644
--- a/src/main/java/fr/openmc/core/hooks/LuckPermsHook.java
+++ b/src/main/java/fr/openmc/core/hooks/LuckPermsHook.java
@@ -1,9 +1,9 @@
package fr.openmc.core.hooks;
import dev.lone.itemsadder.api.FontImages.FontImageWrapper;
-import fr.openmc.core.bootstrap.hooks.ApiHook;
-import fr.openmc.core.bootstrap.hooks.Hooks;
import fr.openmc.core.hooks.itemsadder.ItemsAdderHook;
+import fr.openmc.core.registry.hooks.ApiHook;
+import fr.openmc.core.registry.hooks.Hooks;
import lombok.Getter;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
@@ -18,9 +18,9 @@
public class LuckPermsHook extends Hooks implements ApiHook {
@Getter
- private static LuckPerms api;
+ private LuckPerms api;
- public static boolean isEnable() {
+ public boolean isEnable() {
return Hooks.isEnabled(LuckPermsHook.class);
}
@@ -42,7 +42,7 @@ public void init() {
/**
* Retourne le garde d'une personne
*/
- public static String getPrefix(Player player) {
+ public String getPrefix(Player player) {
if (!isEnable()) return "";
User user = getApi().getUserManager().getUser(player.getUniqueId());
@@ -52,7 +52,20 @@ public static String getPrefix(Player player) {
return Objects.requireNonNullElse(prefix, "");
}
- public static String getFormattedPAPIPrefix(Player player) {
+ /**
+ * Retourne le suffix d'une personne
+ */
+ public String getSuffix(Player player) {
+ if (!isEnable()) return "";
+
+ User user = getApi().getUserManager().getUser(player.getUniqueId());
+ if (user == null) return "";
+
+ String prefix = user.getCachedData().getMetaData(QueryOptions.defaultContextualOptions()).getSuffix();
+ return Objects.requireNonNullElse(prefix, "");
+ }
+
+ public String getFormattedPAPIPrefix(Player player) {
if (!isEnable()) return "";
String prefix = getPrefix(player);
@@ -65,7 +78,7 @@ public static String getFormattedPAPIPrefix(Player player) {
return formattedPrefix;
}
- public static @NotNull Component getFormattedPAPIPrefix(Group group) {
+ public @NotNull Component getFormattedPAPIPrefix(Group group) {
if (!isEnable()) return Component.empty();
String prefix = group.getCachedData().getMetaData(QueryOptions.defaultContextualOptions()).getPrefix();
diff --git a/src/main/java/fr/openmc/core/hooks/PapiHook.java b/src/main/java/fr/openmc/core/hooks/PapiHook.java
index 4af1383fd..3bcb8ecf3 100644
--- a/src/main/java/fr/openmc/core/hooks/PapiHook.java
+++ b/src/main/java/fr/openmc/core/hooks/PapiHook.java
@@ -1,9 +1,9 @@
package fr.openmc.core.hooks;
-import fr.openmc.core.bootstrap.hooks.Hooks;
+import fr.openmc.core.registry.hooks.Hooks;
public class PapiHook extends Hooks {
- public static boolean isEnable() {
+ public boolean isEnable() {
return Hooks.isEnabled(PapiHook.class);
}
diff --git a/src/main/java/fr/openmc/core/hooks/ProtocolLibHook.java b/src/main/java/fr/openmc/core/hooks/ProtocolLibHook.java
index f70ddb6d3..1abc90ef1 100644
--- a/src/main/java/fr/openmc/core/hooks/ProtocolLibHook.java
+++ b/src/main/java/fr/openmc/core/hooks/ProtocolLibHook.java
@@ -1,9 +1,9 @@
package fr.openmc.core.hooks;
-import fr.openmc.core.bootstrap.hooks.Hooks;
+import fr.openmc.core.registry.hooks.Hooks;
public class ProtocolLibHook extends Hooks {
- public static boolean isEnable() {
+ public boolean isEnable() {
return Hooks.isEnabled(ProtocolLibHook.class);
}
diff --git a/src/main/java/fr/openmc/core/hooks/WorldGuardHook.java b/src/main/java/fr/openmc/core/hooks/WorldGuardHook.java
index eddfb0daf..cf53012db 100644
--- a/src/main/java/fr/openmc/core/hooks/WorldGuardHook.java
+++ b/src/main/java/fr/openmc/core/hooks/WorldGuardHook.java
@@ -8,7 +8,7 @@
import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion;
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
import com.sk89q.worldguard.protection.regions.RegionContainer;
-import fr.openmc.core.bootstrap.hooks.Hooks;
+import fr.openmc.core.registry.hooks.Hooks;
import org.bukkit.Chunk;
import org.bukkit.Location;
@@ -16,7 +16,7 @@
import java.util.Collections;
public class WorldGuardHook extends Hooks {
- public static boolean isEnable() {
+ public boolean isEnable() {
return Hooks.isEnabled(WorldGuardHook.class);
}
@@ -25,7 +25,7 @@ protected String getPluginName() {
return "WorldGuard";
}
- public static boolean isRegionConflict(Location location) {
+ public boolean isRegionConflict(Location location) {
if (!isEnable()) return false;
RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer();
@@ -44,11 +44,11 @@ public static boolean isRegionConflict(Location location) {
/**
* Retourne si la positon mise est dans une région
*/
- public static boolean isInside(ProtectedRegion region, Location location) {
+ public boolean isInside(ProtectedRegion region, Location location) {
return region.contains(location.getBlockX(), location.getBlockY(), location.getBlockZ());
}
- public static boolean doesChunkContainWGRegion(Chunk chunk) {
+ public boolean doesChunkContainWGRegion(Chunk chunk) {
if (!isEnable()) return false;
org.bukkit.World world = chunk.getWorld();
diff --git a/src/main/java/fr/openmc/core/hooks/github/GitHubHook.java b/src/main/java/fr/openmc/core/hooks/github/GitHubHook.java
index d75b684a4..6407b7f35 100644
--- a/src/main/java/fr/openmc/core/hooks/github/GitHubHook.java
+++ b/src/main/java/fr/openmc/core/hooks/github/GitHubHook.java
@@ -4,13 +4,13 @@
import com.j256.ormlite.dao.DaoManager;
import com.j256.ormlite.support.ConnectionSource;
import com.j256.ormlite.table.TableUtils;
-import fr.openmc.core.bootstrap.features.types.HasDatabase;
-import fr.openmc.core.bootstrap.hooks.Hooks;
-import fr.openmc.core.bootstrap.hooks.HttpsHook;
-import fr.openmc.core.bootstrap.integration.OMCLogger;
import fr.openmc.core.features.toor.InternalToorApiClient;
import fr.openmc.core.hooks.github.models.ContributorStats;
import fr.openmc.core.hooks.github.models.DBGithubMinecraft;
+import fr.openmc.core.lifecycle.integration.OMCLogger;
+import fr.openmc.core.lifecycle.interfaces.HasDatabase;
+import fr.openmc.core.registry.hooks.Hooks;
+import fr.openmc.core.registry.hooks.HttpsHook;
import fr.openmc.core.utils.cache.TtlCache;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
@@ -31,13 +31,13 @@ public class GitHubHook extends HttpsHook implements HasDatabase {
public final static String REPO_OWNER = "ServerOpenMC";
public final static String REPO_NAME = "PluginV2";
- private static Dao linkGithubMinecraft;
+ private Dao linkGithubMinecraft;
- public static final Map lastKnownLinkMap = new ConcurrentHashMap<>();
- private static final Map contributorStatsMap = new ConcurrentHashMap<>();
+ public final Map lastKnownLinkMap = new ConcurrentHashMap<>();
+ private final Map contributorStatsMap = new ConcurrentHashMap<>();
- private static final TtlCache githubLinkCache = new TtlCache<>(60, TimeUnit.SECONDS);
- private static final TtlCache usernameCache = new TtlCache<>(10, TimeUnit.MINUTES);
+ private final TtlCache githubLinkCache = new TtlCache<>(60, TimeUnit.SECONDS);
+ private final TtlCache usernameCache = new TtlCache<>(10, TimeUnit.MINUTES);
@Override
public void init() {
@@ -56,11 +56,11 @@ public String getName() {
return "GitHubHook";
}
- public static boolean isEnable() {
+ public boolean isEnable() {
return Hooks.isEnabled(GitHubHook.class);
}
- private static void loadAllPlayerLinkGithubData() {
+ private void loadAllPlayerLinkGithubData() {
try {
lastKnownLinkMap.clear();
for (DBGithubMinecraft link : linkGithubMinecraft.queryForAll()) {
@@ -71,7 +71,7 @@ private static void loadAllPlayerLinkGithubData() {
}
}
- public static Long getContributorId(UUID playerUUID) {
+ public Long getContributorId(UUID playerUUID) {
if (githubLinkCache.contains(playerUUID)) return githubLinkCache.get(playerUUID);
InternalToorApiClient.GithubStatus status = InternalToorApiClient.checkGithubStatus(playerUUID);
@@ -88,7 +88,7 @@ public static Long getContributorId(UUID playerUUID) {
return null;
}
- private static void persistFallback(UUID playerUUID, long githubId) {
+ private void persistFallback(UUID playerUUID, long githubId) {
DBGithubMinecraft link = new DBGithubMinecraft(playerUUID, githubId);
lastKnownLinkMap.put(playerUUID, link);
try {
@@ -98,7 +98,7 @@ private static void persistFallback(UUID playerUUID, long githubId) {
}
}
- private static void removeFallback(UUID playerUUID) {
+ private void removeFallback(UUID playerUUID) {
if (lastKnownLinkMap.remove(playerUUID) != null) {
try {
linkGithubMinecraft.deleteById(playerUUID.toString());
@@ -108,12 +108,12 @@ private static void removeFallback(UUID playerUUID) {
}
}
- public static Long refreshContributorId(UUID playerUUID) {
+ public Long refreshContributorId(UUID playerUUID) {
githubLinkCache.invalidate(playerUUID);
return getContributorId(playerUUID);
}
- public static Map getContributors() {
+ public Map getContributors() {
Map contributors = new HashMap<>();
String apiUrl = String.format("https://api.github.com/repos/%s/%s/contributors?per_page=100",
REPO_OWNER, REPO_NAME);
@@ -153,7 +153,7 @@ public static Map getContributors() {
/**
* Mets à jours les stats des contributeurs dans la map contributorStatsMap
*/
- public static void fetchContributorStats() {
+ public void fetchContributorStats() {
Collection contributors = getContributors().values();
String apiUrl = String.format("https://api.github.com/repos/%s/%s/stats/contributors",
REPO_OWNER, REPO_NAME);
@@ -201,55 +201,55 @@ public static void fetchContributorStats() {
}
}
- public static ContributorStats getStats(String nameGithub) {
+ public ContributorStats getStats(String nameGithub) {
return contributorStatsMap.get(nameGithub);
}
- public static int getTotalLines(String nameGithub) {
+ public int getTotalLines(String nameGithub) {
ContributorStats stats = contributorStatsMap.get(nameGithub);
return stats == null ? 0 : stats.getTotalLines();
}
- public static int getTotalAddedLines(String nameGithub) {
+ public int getTotalAddedLines(String nameGithub) {
ContributorStats stats = contributorStatsMap.get(nameGithub);
return stats == null ? 0 : stats.totalAddLines();
}
- public static int getTotalRemovedLines(String nameGithub) {
+ public int getTotalRemovedLines(String nameGithub) {
ContributorStats stats = contributorStatsMap.get(nameGithub);
return stats == null ? 0 : stats.totalRemoveLines();
}
- public static String getContributorName(long idGithub) {
+ public String getContributorName(long idGithub) {
return getContributors().getOrDefault(idGithub, "null");
}
- public static ContributorStats getStats(long idGithub) {
+ public ContributorStats getStats(long idGithub) {
return contributorStatsMap.get(getContributorName(idGithub));
}
- public static int getTotalLines(long idGithub) {
+ public int getTotalLines(long idGithub) {
ContributorStats stats = contributorStatsMap.get(getContributorName(idGithub));
return stats == null ? 0 : stats.getTotalLines();
}
- public static int getTotalAddedLines(long idGithub) {
+ public int getTotalAddedLines(long idGithub) {
ContributorStats stats = contributorStatsMap.get(getContributorName(idGithub));
return stats == null ? 0 : stats.totalAddLines();
}
- public static int getTotalRemovedLines(long idGithub) {
+ public int getTotalRemovedLines(long idGithub) {
ContributorStats stats = contributorStatsMap.get(getContributorName(idGithub));
return stats == null ? 0 : stats.totalRemoveLines();
}
- public static DBGithubMinecraft getContributorLink(UUID uuid) {
+ public DBGithubMinecraft getContributorLink(UUID uuid) {
Long githubId = getContributorId(uuid);
if (githubId == null) return null;
return lastKnownLinkMap.getOrDefault(uuid, new DBGithubMinecraft(uuid, githubId));
}
- public static UUID getPlayerLinkTo(long idGithub) {
+ public UUID getPlayerLinkTo(long idGithub) {
return lastKnownLinkMap.values().stream()
.filter(data -> data.getGithubID() == idGithub)
.map(DBGithubMinecraft::getPlayerUUID)
@@ -257,11 +257,11 @@ public static UUID getPlayerLinkTo(long idGithub) {
.orElse(null);
}
- public static Collection getKnownLinks() {
+ public Collection getKnownLinks() {
return lastKnownLinkMap.values();
}
- public static String getUsernameById(long githubId) {
+ public String getUsernameById(long githubId) {
return usernameCache.getOrCompute(githubId, InternalToorApiClient::getGithubUsername);
}
}
diff --git a/src/main/java/fr/openmc/core/hooks/itemsadder/ItemsAdderHook.java b/src/main/java/fr/openmc/core/hooks/itemsadder/ItemsAdderHook.java
index c252d7668..9690c0e35 100644
--- a/src/main/java/fr/openmc/core/hooks/itemsadder/ItemsAdderHook.java
+++ b/src/main/java/fr/openmc/core/hooks/itemsadder/ItemsAdderHook.java
@@ -2,12 +2,12 @@
import dev.lone.itemsadder.api.ItemsAdder;
import fr.openmc.core.OMCPlugin;
-import fr.openmc.core.bootstrap.hooks.ApiHook;
-import fr.openmc.core.bootstrap.hooks.Hooks;
-import fr.openmc.core.bootstrap.integration.OMCLogger;
import fr.openmc.core.hooks.itemsadder.behaviours.BehaviourUpBlock;
import fr.openmc.core.hooks.itemsadder.events.IAItemLoadEvent;
import fr.openmc.core.hooks.itemsadder.placeholders.IAPlaceholderRegistry;
+import fr.openmc.core.lifecycle.integration.OMCLogger;
+import fr.openmc.core.registry.hooks.ApiHook;
+import fr.openmc.core.registry.hooks.Hooks;
import fr.openmc.core.utils.FilesUtils;
import io.papermc.paper.plugin.bootstrap.BootstrapContext;
import lombok.Getter;
@@ -27,12 +27,12 @@
@SuppressWarnings("UnstableApiUsage")
public class ItemsAdderHook extends Hooks implements ApiHook {
@Getter
- private static ItemsAdder api;
+ private ItemsAdder api;
private static final String CONTENTS_FOLDER_NAME = "contents";
private static final String MERGE_RESOURCEPACK_PATH = "resource-pack.zip.merge_other_plugins_resourcepacks_folders";
- public static boolean isEnable() {
+ public boolean isEnable() {
return Hooks.isEnabled(ItemsAdderHook.class);
}
@@ -57,7 +57,7 @@ public void init() {
* Appelle {@code IAItemLoadEvent} et donne en meme temps le Yaml de l'item.
* DOIT ETRE LANCE APRES QUE ITEMS ADDER SOIT COMPLETEMENT CHARGE
*/
- public static void loadContents() {
+ public void loadContents() {
File pluginsDir = OMCPlugin.getInstance().getDataFolder().getParentFile(); // * root/pluigns
File itemsAdderDir = new File(pluginsDir, "ItemsAdder"); // * root/pluigns/ItemsAdder
File contentDir = new File(itemsAdderDir, CONTENTS_FOLDER_NAME); // * root/pluigns/ItemsAdder/contents
diff --git a/src/main/java/fr/openmc/core/hooks/itemsadder/placeholders/IAPlaceholderRegistry.java b/src/main/java/fr/openmc/core/hooks/itemsadder/placeholders/IAPlaceholderRegistry.java
index 169ca7bf3..19d9a72ad 100644
--- a/src/main/java/fr/openmc/core/hooks/itemsadder/placeholders/IAPlaceholderRegistry.java
+++ b/src/main/java/fr/openmc/core/hooks/itemsadder/placeholders/IAPlaceholderRegistry.java
@@ -1,6 +1,5 @@
package fr.openmc.core.hooks.itemsadder.placeholders;
-import fr.openmc.core.bootstrap.integration.OMCLogger;
import fr.openmc.core.features.dream.placeholders.DreamItemMaterialPlaceholder;
import fr.openmc.core.features.dream.placeholders.DreamItemNamePlaceholder;
import fr.openmc.core.features.dream.placeholders.DreamItemTooltipPlaceholder;
@@ -8,6 +7,8 @@
import fr.openmc.core.features.events.contents.dailyevents.contents.goldenharvest.contents.placeholder.GoldenCropsChancePlaceholder;
import fr.openmc.core.features.events.contents.dailyevents.contents.miraculousfishing.contents.placeholder.DoubleHookChancePlaceholder;
import fr.openmc.core.features.events.contents.dailyevents.contents.miraculousfishing.contents.placeholder.FishingSpeedPlaceholder;
+import fr.openmc.core.lifecycle.integration.OMCLogger;
+
import java.util.HashMap;
import java.util.Map;
diff --git a/src/main/java/fr/openmc/core/bootstrap/integration/DatabaseManager.java b/src/main/java/fr/openmc/core/lifecycle/integration/DatabaseManager.java
similarity index 59%
rename from src/main/java/fr/openmc/core/bootstrap/integration/DatabaseManager.java
rename to src/main/java/fr/openmc/core/lifecycle/integration/DatabaseManager.java
index e4e62c1cb..c3d2564d5 100644
--- a/src/main/java/fr/openmc/core/bootstrap/integration/DatabaseManager.java
+++ b/src/main/java/fr/openmc/core/lifecycle/integration/DatabaseManager.java
@@ -1,11 +1,12 @@
-package fr.openmc.core.bootstrap.integration;
+package fr.openmc.core.lifecycle.integration;
import com.j256.ormlite.jdbc.JdbcPooledConnectionSource;
import com.j256.ormlite.logger.Level;
import com.j256.ormlite.logger.LocalLogBackend;
import com.j256.ormlite.support.ConnectionSource;
import fr.openmc.core.OMCPlugin;
-import fr.openmc.core.bootstrap.features.Feature;
+import fr.openmc.core.registry.features.Feature;
+import fr.openmc.core.registry.hooks.Hooks;
import lombok.Getter;
import org.bukkit.configuration.file.FileConfiguration;
@@ -32,7 +33,7 @@ public static void init() {
Class.forName("com.mysql.cj.jdbc.Driver");
}
} catch (ClassNotFoundException e) {
- OMCLogger.error("Database driver not found. Please ensure the MySQL or H2 driver is included in the classpath.");
+ OMCLogger.error("Le Driver de la Database n'est pas trouvé. Assurez vous que MYSQL ou H2 driver est dans le classpath.");
throw new RuntimeException(e);
}
@@ -43,45 +44,49 @@ public static void init() {
String username = config.getString("database.username");
String password = config.getString("database.password");
connectionSource = new JdbcPooledConnectionSource(databaseUrl, username, password);
+ } catch (SQLException e) {
+ OMCLogger.error("Tentative d'initialisation de la base de donnée échouée.", e);
+ throw new RuntimeException(e);
+ } catch (ConnectionPendingException e) {
+ OMCLogger.error("La connection à la base de donnée est en attente. Veuillez vérifier votre configuration de base de données.");
+ throw new RuntimeException(e);
+ }
+ }
- OMCPlugin.getInstance().REGISTRY_HOOKS
- .forEach(h -> {
- try {
- h.startDB(connectionSource);
- } catch (SQLException e) {
- OMCLogger.error("Failed to initialize the database connection.", e);
- throw new RuntimeException(e);
- } catch (ConnectionPendingException e) {
- OMCLogger.error("Database connection is pending. Please check your database configuration.");
- throw new RuntimeException(e);
- } catch (NoClassDefFoundError e) {
- OMCLogger.errorFormatted("Plugin has failed to start feature because {} does not exist.",
- e.getMessage());
- }
- });
+ public static void startFeatureDB(Feature feature) {
+ if (connectionSource == null) {
+ OMCLogger.error("Tentative de start la DB d'une feature avant que DatabseManager soit init.");
+ return;
+ }
+ try {
+ feature.startDB(connectionSource);
+ } catch (SQLException e) {
+ OMCLogger.error("Tentative d'initialisation de la base de donnée d'une feature échouée.", e);
+ throw new RuntimeException(e);
+ } catch (ConnectionPendingException e) {
+ OMCLogger.error("La connection à la base de donnée est en attente. Veuillez vérifier votre configuration de base de données.");
+ throw new RuntimeException(e);
+ } catch (NoClassDefFoundError e) {
+ OMCLogger.errorFormatted("Le plugin a tenté de lancer une feature mais {} n'existe pas.", e.getMessage());
+ }
+ }
- OMCPlugin.getInstance().REGISTRY_FEATURE
- .forEach(f -> {
- try {
- Feature feature = f.create();
- feature.startDB(connectionSource);
- } catch (SQLException e) {
- OMCLogger.error("Failed to initialize the database connection.", e);
- throw new RuntimeException(e);
- } catch (ConnectionPendingException e) {
- OMCLogger.error("Database connection is pending. Please check your database configuration.");
- throw new RuntimeException(e);
- } catch (NoClassDefFoundError e) {
- OMCLogger.errorFormatted("Plugin has failed to start feature because {} does not exist.",
- e.getMessage());
- }
- });
+ public static void startHookDB(Hooks hook) {
+ if (connectionSource == null) {
+ OMCLogger.error("Tentative de start la DB d'un hook avant que DatabseManager soit init.");
+ return;
+ }
+ try {
+ hook.startDB(connectionSource);
} catch (SQLException e) {
- OMCLogger.error("Failed to initialize the database connection.", e);
+ OMCLogger.error("Tentative d'initialisation de la base de donnée d'un hook échouée.", e);
throw new RuntimeException(e);
} catch (ConnectionPendingException e) {
- OMCLogger.error("Database connection is pending. Please check your database configuration.");
+ OMCLogger.error("La connection à la base de donnée est en attente. Veuillez vérifier votre configuration de base de données.");
throw new RuntimeException(e);
+ } catch (NoClassDefFoundError e) {
+ OMCLogger.errorFormatted("Le plugin a tenté de lancer un hook mais {} n'existe pas.",
+ e.getMessage());
}
}
diff --git a/src/main/java/fr/openmc/core/bootstrap/integration/DatapackLoader.java b/src/main/java/fr/openmc/core/lifecycle/integration/DatapackLoader.java
similarity index 97%
rename from src/main/java/fr/openmc/core/bootstrap/integration/DatapackLoader.java
rename to src/main/java/fr/openmc/core/lifecycle/integration/DatapackLoader.java
index 5e5f23b32..cac83b8c4 100644
--- a/src/main/java/fr/openmc/core/bootstrap/integration/DatapackLoader.java
+++ b/src/main/java/fr/openmc/core/lifecycle/integration/DatapackLoader.java
@@ -1,4 +1,4 @@
-package fr.openmc.core.bootstrap.integration;
+package fr.openmc.core.lifecycle.integration;
import fr.openmc.core.utils.FilesUtils;
import io.papermc.paper.plugin.bootstrap.BootstrapContext;
diff --git a/src/main/java/fr/openmc/core/bootstrap/integration/ErrorReporter.java b/src/main/java/fr/openmc/core/lifecycle/integration/ErrorReporter.java
similarity index 99%
rename from src/main/java/fr/openmc/core/bootstrap/integration/ErrorReporter.java
rename to src/main/java/fr/openmc/core/lifecycle/integration/ErrorReporter.java
index 27d36b562..ea34fce2c 100644
--- a/src/main/java/fr/openmc/core/bootstrap/integration/ErrorReporter.java
+++ b/src/main/java/fr/openmc/core/lifecycle/integration/ErrorReporter.java
@@ -1,4 +1,4 @@
-package fr.openmc.core.bootstrap.integration;
+package fr.openmc.core.lifecycle.integration;
import fr.openmc.core.OMCPlugin;
import fr.openmc.core.utils.DiscordWebhookUtils;
diff --git a/src/main/java/fr/openmc/core/bootstrap/integration/OMCLogger.java b/src/main/java/fr/openmc/core/lifecycle/integration/OMCLogger.java
similarity index 99%
rename from src/main/java/fr/openmc/core/bootstrap/integration/OMCLogger.java
rename to src/main/java/fr/openmc/core/lifecycle/integration/OMCLogger.java
index 1dc80c4f7..3ab785083 100644
--- a/src/main/java/fr/openmc/core/bootstrap/integration/OMCLogger.java
+++ b/src/main/java/fr/openmc/core/lifecycle/integration/OMCLogger.java
@@ -1,4 +1,4 @@
-package fr.openmc.core.bootstrap.integration;
+package fr.openmc.core.lifecycle.integration;
import fr.openmc.core.OMCPlugin;
import lombok.Setter;
diff --git a/src/main/java/fr/openmc/core/bootstrap/integration/ResourcePacksGenerator.java b/src/main/java/fr/openmc/core/lifecycle/integration/ResourcePacksGenerator.java
similarity index 97%
rename from src/main/java/fr/openmc/core/bootstrap/integration/ResourcePacksGenerator.java
rename to src/main/java/fr/openmc/core/lifecycle/integration/ResourcePacksGenerator.java
index fc4104b6f..ab6bcc4c8 100644
--- a/src/main/java/fr/openmc/core/bootstrap/integration/ResourcePacksGenerator.java
+++ b/src/main/java/fr/openmc/core/lifecycle/integration/ResourcePacksGenerator.java
@@ -1,4 +1,4 @@
-package fr.openmc.core.bootstrap.integration;
+package fr.openmc.core.lifecycle.integration;
import fr.openmc.core.utils.FilesUtils;
import io.papermc.paper.plugin.bootstrap.BootstrapContext;
diff --git a/src/main/java/fr/openmc/core/bootstrap/features/types/HasCommands.java b/src/main/java/fr/openmc/core/lifecycle/interfaces/HasCommands.java
similarity index 83%
rename from src/main/java/fr/openmc/core/bootstrap/features/types/HasCommands.java
rename to src/main/java/fr/openmc/core/lifecycle/interfaces/HasCommands.java
index 4c88e004a..6cd9502a3 100644
--- a/src/main/java/fr/openmc/core/bootstrap/features/types/HasCommands.java
+++ b/src/main/java/fr/openmc/core/lifecycle/interfaces/HasCommands.java
@@ -1,4 +1,4 @@
-package fr.openmc.core.bootstrap.features.types;
+package fr.openmc.core.lifecycle.interfaces;
import java.util.Set;
diff --git a/src/main/java/fr/openmc/core/bootstrap/features/types/HasDatabase.java b/src/main/java/fr/openmc/core/lifecycle/interfaces/HasDatabase.java
similarity index 78%
rename from src/main/java/fr/openmc/core/bootstrap/features/types/HasDatabase.java
rename to src/main/java/fr/openmc/core/lifecycle/interfaces/HasDatabase.java
index 88450c1a7..edfa79761 100644
--- a/src/main/java/fr/openmc/core/bootstrap/features/types/HasDatabase.java
+++ b/src/main/java/fr/openmc/core/lifecycle/interfaces/HasDatabase.java
@@ -1,4 +1,4 @@
-package fr.openmc.core.bootstrap.features.types;
+package fr.openmc.core.lifecycle.interfaces;
import com.j256.ormlite.support.ConnectionSource;
@@ -15,4 +15,6 @@ public interface HasDatabase {
* @throws SQLException Si l'initialisation DB échoue
*/
void initDB(ConnectionSource connectionSource) throws SQLException;
+
+ // todo interface qui fait des load et des saves d'un dao dans une type de map choisies?
}
diff --git a/src/main/java/fr/openmc/core/lifecycle/interfaces/HasFeature.java b/src/main/java/fr/openmc/core/lifecycle/interfaces/HasFeature.java
new file mode 100644
index 000000000..0ec7d2aaa
--- /dev/null
+++ b/src/main/java/fr/openmc/core/lifecycle/interfaces/HasFeature.java
@@ -0,0 +1,14 @@
+package fr.openmc.core.lifecycle.interfaces;
+
+import fr.openmc.core.registry.features.Feature;
+import fr.openmc.core.registry.features.loading.FeatureEntry;
+
+/**
+ * Interface permettant aux classes d'enregistrer une feature
+ */
+public interface HasFeature {
+ /**
+ * Feature à initialiser
+ */
+ FeatureEntry extends Feature> feature();
+}
diff --git a/src/main/java/fr/openmc/core/bootstrap/features/types/HasListeners.java b/src/main/java/fr/openmc/core/lifecycle/interfaces/HasListeners.java
similarity index 79%
rename from src/main/java/fr/openmc/core/bootstrap/features/types/HasListeners.java
rename to src/main/java/fr/openmc/core/lifecycle/interfaces/HasListeners.java
index fcd218cd8..928df602e 100644
--- a/src/main/java/fr/openmc/core/bootstrap/features/types/HasListeners.java
+++ b/src/main/java/fr/openmc/core/lifecycle/interfaces/HasListeners.java
@@ -1,6 +1,6 @@
-package fr.openmc.core.bootstrap.features.types;
+package fr.openmc.core.lifecycle.interfaces;
-import fr.openmc.core.bootstrap.listeners.ListenerFactory;
+import fr.openmc.core.lifecycle.listeners.ListenerFactory;
import java.util.Set;
diff --git a/src/main/java/fr/openmc/core/bootstrap/features/types/LoadIfEnable.java b/src/main/java/fr/openmc/core/lifecycle/interfaces/LoadIfEnable.java
similarity index 93%
rename from src/main/java/fr/openmc/core/bootstrap/features/types/LoadIfEnable.java
rename to src/main/java/fr/openmc/core/lifecycle/interfaces/LoadIfEnable.java
index b44bb41e4..6037d6d7d 100644
--- a/src/main/java/fr/openmc/core/bootstrap/features/types/LoadIfEnable.java
+++ b/src/main/java/fr/openmc/core/lifecycle/interfaces/LoadIfEnable.java
@@ -1,7 +1,7 @@
-package fr.openmc.core.bootstrap.features.types;
+package fr.openmc.core.lifecycle.interfaces;
-import fr.openmc.core.bootstrap.hooks.Hooks;
-import fr.openmc.core.bootstrap.integration.OMCLogger;
+import fr.openmc.core.lifecycle.integration.OMCLogger;
+import fr.openmc.core.registry.hooks.Hooks;
import java.lang.reflect.Method;
import java.lang.reflect.ParameterizedType;
diff --git a/src/main/java/fr/openmc/core/bootstrap/features/types/NotLoadInUnitTest.java b/src/main/java/fr/openmc/core/lifecycle/interfaces/NotLoadInUnitTest.java
similarity index 71%
rename from src/main/java/fr/openmc/core/bootstrap/features/types/NotLoadInUnitTest.java
rename to src/main/java/fr/openmc/core/lifecycle/interfaces/NotLoadInUnitTest.java
index a3024b276..7d45606a3 100644
--- a/src/main/java/fr/openmc/core/bootstrap/features/types/NotLoadInUnitTest.java
+++ b/src/main/java/fr/openmc/core/lifecycle/interfaces/NotLoadInUnitTest.java
@@ -1,4 +1,4 @@
-package fr.openmc.core.bootstrap.features.types;
+package fr.openmc.core.lifecycle.interfaces;
/**
* Charge uniquement la feature ou le listener hors des tests unitaires
diff --git a/src/main/java/fr/openmc/core/bootstrap/listeners/ListenerFactory.java b/src/main/java/fr/openmc/core/lifecycle/listeners/ListenerFactory.java
similarity index 90%
rename from src/main/java/fr/openmc/core/bootstrap/listeners/ListenerFactory.java
rename to src/main/java/fr/openmc/core/lifecycle/listeners/ListenerFactory.java
index 1e3289822..5a7ead498 100644
--- a/src/main/java/fr/openmc/core/bootstrap/listeners/ListenerFactory.java
+++ b/src/main/java/fr/openmc/core/lifecycle/listeners/ListenerFactory.java
@@ -1,7 +1,7 @@
-package fr.openmc.core.bootstrap.listeners;
+package fr.openmc.core.lifecycle.listeners;
import fr.openmc.core.OMCPlugin;
-import fr.openmc.core.bootstrap.integration.OMCLogger;
+import fr.openmc.core.lifecycle.integration.OMCLogger;
import org.bukkit.Bukkit;
import org.bukkit.Server;
import org.bukkit.event.Listener;
diff --git a/src/main/java/fr/openmc/core/bootstrap/registries/KeyedRegistry.java b/src/main/java/fr/openmc/core/lifecycle/registries/KeyedRegistry.java
similarity index 69%
rename from src/main/java/fr/openmc/core/bootstrap/registries/KeyedRegistry.java
rename to src/main/java/fr/openmc/core/lifecycle/registries/KeyedRegistry.java
index 7548dda09..35db42c72 100644
--- a/src/main/java/fr/openmc/core/bootstrap/registries/KeyedRegistry.java
+++ b/src/main/java/fr/openmc/core/lifecycle/registries/KeyedRegistry.java
@@ -1,12 +1,13 @@
-package fr.openmc.core.bootstrap.registries;
+package fr.openmc.core.lifecycle.registries;
public interface KeyedRegistry {
K key(V registryObject);
V register(K key, V value);
- default V register(V value) {
- return register(key(value), value);
+ default T register(T value) {
+ register(key(value), value);
+ return value;
}
default void register(V... values) {
@@ -20,4 +21,4 @@ default void register(Iterable values) {
register(value);
}
}
-}
+}
\ 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/lifecycle/registries/LifecycleRegistry.java
similarity index 87%
rename from src/main/java/fr/openmc/core/bootstrap/registries/LifecycleRegistry.java
rename to src/main/java/fr/openmc/core/lifecycle/registries/LifecycleRegistry.java
index 506ca7f96..4b6745488 100644
--- a/src/main/java/fr/openmc/core/bootstrap/registries/LifecycleRegistry.java
+++ b/src/main/java/fr/openmc/core/lifecycle/registries/LifecycleRegistry.java
@@ -1,4 +1,4 @@
-package fr.openmc.core.bootstrap.registries;
+package fr.openmc.core.lifecycle.registries;
import io.papermc.paper.plugin.bootstrap.BootstrapContext;
diff --git a/src/main/java/fr/openmc/core/bootstrap/registries/Registry.java b/src/main/java/fr/openmc/core/lifecycle/registries/Registry.java
similarity index 81%
rename from src/main/java/fr/openmc/core/bootstrap/registries/Registry.java
rename to src/main/java/fr/openmc/core/lifecycle/registries/Registry.java
index d18b31d38..44de500a4 100644
--- a/src/main/java/fr/openmc/core/bootstrap/registries/Registry.java
+++ b/src/main/java/fr/openmc/core/lifecycle/registries/Registry.java
@@ -1,13 +1,13 @@
-package fr.openmc.core.bootstrap.registries;
+package fr.openmc.core.lifecycle.registries;
import java.util.Collection;
-import java.util.HashMap;
+import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Optional;
public class Registry implements LifecycleRegistry {
- protected final Map entries = new HashMap<>();
+ protected final Map entries = new LinkedHashMap<>();;
public V register(K key, V value) {
entries.put(key, value);
diff --git a/src/main/java/fr/openmc/core/bootstrap/registries/RegistryContext.java b/src/main/java/fr/openmc/core/lifecycle/registries/RegistryContext.java
similarity index 92%
rename from src/main/java/fr/openmc/core/bootstrap/registries/RegistryContext.java
rename to src/main/java/fr/openmc/core/lifecycle/registries/RegistryContext.java
index 6984ae43d..0587a08a4 100644
--- a/src/main/java/fr/openmc/core/bootstrap/registries/RegistryContext.java
+++ b/src/main/java/fr/openmc/core/lifecycle/registries/RegistryContext.java
@@ -1,4 +1,4 @@
-package fr.openmc.core.bootstrap.registries;
+package fr.openmc.core.lifecycle.registries;
import java.util.function.Supplier;
diff --git a/src/main/java/fr/openmc/core/bootstrap/registries/RegistryLoadingType.java b/src/main/java/fr/openmc/core/lifecycle/registries/RegistryLoadingType.java
similarity index 91%
rename from src/main/java/fr/openmc/core/bootstrap/registries/RegistryLoadingType.java
rename to src/main/java/fr/openmc/core/lifecycle/registries/RegistryLoadingType.java
index 20f8dfd79..baa57a185 100644
--- a/src/main/java/fr/openmc/core/bootstrap/registries/RegistryLoadingType.java
+++ b/src/main/java/fr/openmc/core/lifecycle/registries/RegistryLoadingType.java
@@ -1,4 +1,4 @@
-package fr.openmc.core.bootstrap.registries;
+package fr.openmc.core.lifecycle.registries;
/**
* Les Conditions de Chargement :
diff --git a/src/main/java/fr/openmc/core/listeners/AsyncChatListener.java b/src/main/java/fr/openmc/core/listeners/AsyncChatListener.java
index 60ff29faa..4aba39b9c 100644
--- a/src/main/java/fr/openmc/core/listeners/AsyncChatListener.java
+++ b/src/main/java/fr/openmc/core/listeners/AsyncChatListener.java
@@ -1,14 +1,13 @@
package fr.openmc.core.listeners;
import fr.openmc.core.OMCPlugin;
+import fr.openmc.core.OMCRegistry;
import fr.openmc.core.hooks.LuckPermsHook;
import io.papermc.paper.event.player.AsyncChatEvent;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.TextColor;
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
-import net.luckperms.api.LuckPerms;
-import net.luckperms.api.cacheddata.CachedMetaData;
import org.bukkit.Bukkit;
import org.bukkit.Sound;
import org.bukkit.SoundCategory;
@@ -22,22 +21,21 @@
public class AsyncChatListener implements Listener {
private final OMCPlugin plugin;
- private final LuckPerms luckperms;
+ private final LuckPermsHook luckPermsHook;
public AsyncChatListener(OMCPlugin plugin) {
this.plugin = plugin;
- this.luckperms = LuckPermsHook.getApi();
+ this.luckPermsHook = OMCRegistry.HOOKS.LUCK_PERMS;
}
@EventHandler
public void onChat(AsyncChatEvent event) {
final Player player = event.getPlayer();
- final CachedMetaData metaData = this.luckperms.getPlayerAdapter(Player.class).getMetaData(player);
String message = PlainTextComponentSerializer.plainText().serialize(event.message());
String rawMessage = plugin.getConfig().getString("chat.message", "{prefix}{name}§7: {message}")
- .replace("{prefix}", LuckPermsHook.getFormattedPAPIPrefix(player))
- .replace("{suffix}", metaData.getSuffix() != null ? metaData.getSuffix() : "")
+ .replace("{prefix}", luckPermsHook.getFormattedPAPIPrefix(player))
+ .replace("{suffix}", luckPermsHook.getSuffix(player))
.replace("{name}", player.getName())
.replace("{message}", message);
diff --git a/src/main/java/fr/openmc/core/listeners/ItemsAddersListener.java b/src/main/java/fr/openmc/core/listeners/ItemsAddersListener.java
index e5e7a7ef4..c258d275c 100644
--- a/src/main/java/fr/openmc/core/listeners/ItemsAddersListener.java
+++ b/src/main/java/fr/openmc/core/listeners/ItemsAddersListener.java
@@ -2,8 +2,8 @@
import dev.lone.itemsadder.api.Events.ItemsAdderLoadDataEvent;
import fr.openmc.core.OMCPlugin;
-import fr.openmc.core.bootstrap.features.types.LoadIfEnable;
import fr.openmc.core.hooks.itemsadder.ItemsAdderHook;
+import fr.openmc.core.lifecycle.interfaces.LoadIfEnable;
import lombok.Setter;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
diff --git a/src/main/java/fr/openmc/core/listeners/JoinQuitMessageListener.java b/src/main/java/fr/openmc/core/listeners/JoinQuitMessageListener.java
index e47919b36..0143887db 100644
--- a/src/main/java/fr/openmc/core/listeners/JoinQuitMessageListener.java
+++ b/src/main/java/fr/openmc/core/listeners/JoinQuitMessageListener.java
@@ -1,7 +1,7 @@
package fr.openmc.core.listeners;
import fr.openmc.core.OMCPlugin;
-import fr.openmc.core.bootstrap.integration.OMCLogger;
+import fr.openmc.core.OMCRegistry;
import fr.openmc.core.commands.utils.SpawnManager;
import fr.openmc.core.features.displays.TabList;
import fr.openmc.core.features.economy.EconomyManager;
@@ -11,6 +11,7 @@
import fr.openmc.core.features.tpa.TPAManager;
import fr.openmc.core.hooks.LuckPermsHook;
import fr.openmc.core.hooks.github.GitHubHook;
+import fr.openmc.core.lifecycle.integration.OMCLogger;
import fr.openmc.core.utils.text.messages.MessageType;
import fr.openmc.core.utils.text.messages.MessagesManager;
import fr.openmc.core.utils.text.messages.Prefix;
@@ -30,12 +31,14 @@
public class JoinQuitMessageListener implements Listener {
private final double balanceOnJoin;
+ private final LuckPermsHook luckPermsHook;
public static final String JOIN_MESSAGE = "§8[§a§l+§8] §r%s%s";
public static final String QUIT_MESSAGE = "§8[§c§l-§8] §r%s%s";
public JoinQuitMessageListener() {
this.balanceOnJoin = OMCPlugin.getInstance().getConfig().getDouble("money-on-first-join", 500D);
+ this.luckPermsHook = OMCRegistry.HOOKS.LUCK_PERMS;
}
@EventHandler
@@ -52,7 +55,7 @@ public void onPlayerJoin(PlayerJoinEvent event) {
if (friend != null && friend.isOnline() && !friend.hasMetadata(OMCPlugin.VANISH_META_KEY)) {
MessagesManager.sendMessage(friend, TranslationManager.translation(
"core.player.join.friend_online",
- Component.text(LuckPermsHook.getFormattedPAPIPrefix(player) + player.getName()).color(NamedTextColor.GREEN)
+ Component.text(luckPermsHook.getFormattedPAPIPrefix(player) + player.getName()).color(NamedTextColor.GREEN)
), Prefix.FRIEND, MessageType.NONE, true);
}
}
@@ -84,7 +87,7 @@ public void onPlayerJoin(PlayerJoinEvent event) {
});
if (!player.hasMetadata(OMCPlugin.VANISH_META_KEY))
- event.joinMessage(Component.text(JOIN_MESSAGE.formatted(LuckPermsHook.getFormattedPAPIPrefix(player), player.getName())));
+ event.joinMessage(Component.text(JOIN_MESSAGE.formatted(luckPermsHook.getFormattedPAPIPrefix(player), player.getName())));
// Adjust player's spawn location
if (!player.hasPlayedBefore()) {
@@ -117,7 +120,7 @@ public void onPlayerQuit(PlayerQuitEvent event) {
if (friend != null && friend.isOnline() && !friend.hasMetadata(OMCPlugin.VANISH_META_KEY)) {
MessagesManager.sendMessage(friend, TranslationManager.translation(
"core.player.quit.friend_offline",
- Component.text(LuckPermsHook.getFormattedPAPIPrefix(player) + player.getName()).color(NamedTextColor.YELLOW)
+ Component.text(luckPermsHook.getFormattedPAPIPrefix(player) + player.getName()).color(NamedTextColor.YELLOW)
), Prefix.FRIEND, MessageType.NONE, true);
}
}
@@ -144,7 +147,7 @@ public void onPlayerQuit(PlayerQuitEvent event) {
}
if (!player.hasMetadata(OMCPlugin.VANISH_META_KEY))
- event.quitMessage(Component.text(QUIT_MESSAGE.formatted(LuckPermsHook.getFormattedPAPIPrefix(player), player.getName())));
+ event.quitMessage(Component.text(QUIT_MESSAGE.formatted(luckPermsHook.getFormattedPAPIPrefix(player), player.getName())));
}
}
diff --git a/src/main/java/fr/openmc/core/listeners/RegionTrackingListener.java b/src/main/java/fr/openmc/core/listeners/RegionTrackingListener.java
index a59e99dee..be6a01321 100644
--- a/src/main/java/fr/openmc/core/listeners/RegionTrackingListener.java
+++ b/src/main/java/fr/openmc/core/listeners/RegionTrackingListener.java
@@ -6,9 +6,9 @@
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
import com.sk89q.worldguard.protection.regions.RegionContainer;
import com.sk89q.worldguard.protection.regions.RegionQuery;
-import fr.openmc.core.bootstrap.features.types.NotLoadInUnitTest;
import fr.openmc.core.events.RegionEnterEvent;
import fr.openmc.core.events.RegionLeaveEvent;
+import fr.openmc.core.lifecycle.interfaces.NotLoadInUnitTest;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.entity.Player;
diff --git a/src/main/java/fr/openmc/core/registry/ambient/CustomAmbientRegistry.java b/src/main/java/fr/openmc/core/registry/ambient/CustomAmbientRegistry.java
index 48b026fbc..a1c134270 100644
--- a/src/main/java/fr/openmc/core/registry/ambient/CustomAmbientRegistry.java
+++ b/src/main/java/fr/openmc/core/registry/ambient/CustomAmbientRegistry.java
@@ -2,14 +2,14 @@
import fr.openmc.api.datapacks.OMCDatapack;
import fr.openmc.api.datapacks.injectors.BiomesInjector;
-import fr.openmc.core.bootstrap.features.types.HasListeners;
-import fr.openmc.core.bootstrap.integration.OMCLogger;
-import fr.openmc.core.bootstrap.listeners.ListenerFactory;
-import fr.openmc.core.bootstrap.registries.KeyedRegistry;
-import fr.openmc.core.bootstrap.registries.Registry;
import fr.openmc.core.features.events.contents.dailyevents.contents.bloodynight.contents.ambient.BloodyAmbient;
import fr.openmc.core.features.events.contents.dailyevents.contents.goldenharvest.contents.ambient.GoldenAmbient;
import fr.openmc.core.features.events.contents.dailyevents.contents.miraculousfishing.contents.ambient.BlessedAmbient;
+import fr.openmc.core.lifecycle.integration.OMCLogger;
+import fr.openmc.core.lifecycle.interfaces.HasListeners;
+import fr.openmc.core.lifecycle.listeners.ListenerFactory;
+import fr.openmc.core.lifecycle.registries.KeyedRegistry;
+import fr.openmc.core.lifecycle.registries.Registry;
import fr.openmc.core.registry.ambient.contents.DarkAmbient;
import fr.openmc.core.registry.ambient.contents.HellAmbient;
import fr.openmc.core.registry.ambient.listeners.AmbientFixedTimeListener;
diff --git a/src/main/java/fr/openmc/core/registry/ambient/RegistriesLoadConfig.java b/src/main/java/fr/openmc/core/registry/ambient/RegistriesLoadConfig.java
index ace14e441..3acf7d04a 100644
--- a/src/main/java/fr/openmc/core/registry/ambient/RegistriesLoadConfig.java
+++ b/src/main/java/fr/openmc/core/registry/ambient/RegistriesLoadConfig.java
@@ -1,6 +1,6 @@
package fr.openmc.core.registry.ambient;
-import fr.openmc.core.bootstrap.integration.OMCLogger;
+import fr.openmc.core.lifecycle.integration.OMCLogger;
import lombok.Getter;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
diff --git a/src/main/java/fr/openmc/core/registry/ambient/listeners/AmbientFixedTimeListener.java b/src/main/java/fr/openmc/core/registry/ambient/listeners/AmbientFixedTimeListener.java
index 144e81755..0db2e9d7a 100644
--- a/src/main/java/fr/openmc/core/registry/ambient/listeners/AmbientFixedTimeListener.java
+++ b/src/main/java/fr/openmc/core/registry/ambient/listeners/AmbientFixedTimeListener.java
@@ -2,9 +2,9 @@
import fr.openmc.core.OMCPlugin;
import fr.openmc.core.OMCRegistry;
-import fr.openmc.core.bootstrap.features.types.NotLoadInUnitTest;
import fr.openmc.core.events.RegionEnterEvent;
import fr.openmc.core.events.RegionLeaveEvent;
+import fr.openmc.core.lifecycle.interfaces.NotLoadInUnitTest;
import fr.openmc.core.registry.ambient.CustomAmbient;
import fr.openmc.core.utils.nms.PlayerSetTimeNMS;
import org.bukkit.Bukkit;
diff --git a/src/main/java/fr/openmc/core/registry/ambient/listeners/AmbientWeatherListener.java b/src/main/java/fr/openmc/core/registry/ambient/listeners/AmbientWeatherListener.java
index 2cf6e1467..c46fa634c 100644
--- a/src/main/java/fr/openmc/core/registry/ambient/listeners/AmbientWeatherListener.java
+++ b/src/main/java/fr/openmc/core/registry/ambient/listeners/AmbientWeatherListener.java
@@ -2,9 +2,9 @@
import fr.openmc.core.OMCPlugin;
import fr.openmc.core.OMCRegistry;
-import fr.openmc.core.bootstrap.features.types.NotLoadInUnitTest;
import fr.openmc.core.events.RegionEnterEvent;
import fr.openmc.core.events.RegionLeaveEvent;
+import fr.openmc.core.lifecycle.interfaces.NotLoadInUnitTest;
import fr.openmc.core.registry.ambient.CustomAmbient;
import fr.openmc.core.utils.nms.PlayerWeatherNMS;
import org.bukkit.Bukkit;
diff --git a/src/main/java/fr/openmc/core/registry/ambient/listeners/BiomesOnChunkLoad.java b/src/main/java/fr/openmc/core/registry/ambient/listeners/BiomesOnChunkLoad.java
index bdd0fef43..34d6f8233 100644
--- a/src/main/java/fr/openmc/core/registry/ambient/listeners/BiomesOnChunkLoad.java
+++ b/src/main/java/fr/openmc/core/registry/ambient/listeners/BiomesOnChunkLoad.java
@@ -1,7 +1,7 @@
package fr.openmc.core.registry.ambient.listeners;
import fr.openmc.core.OMCRegistry;
-import fr.openmc.core.bootstrap.features.types.NotLoadInUnitTest;
+import fr.openmc.core.lifecycle.interfaces.NotLoadInUnitTest;
import fr.openmc.core.registry.ambient.CustomAmbient;
import fr.openmc.core.utils.nms.PlayerBiomeNMS;
import io.papermc.paper.event.packet.PlayerChunkLoadEvent;
diff --git a/src/main/java/fr/openmc/core/registry/enchantments/CustomEnchantment.java b/src/main/java/fr/openmc/core/registry/enchantments/CustomEnchantment.java
index 911a43420..28aa69c13 100644
--- a/src/main/java/fr/openmc/core/registry/enchantments/CustomEnchantment.java
+++ b/src/main/java/fr/openmc/core/registry/enchantments/CustomEnchantment.java
@@ -1,6 +1,6 @@
package fr.openmc.core.registry.enchantments;
-import fr.openmc.core.bootstrap.integration.OMCLogger;
+import fr.openmc.core.lifecycle.integration.OMCLogger;
import fr.openmc.core.registry.items.CustomItem;
import fr.openmc.core.utils.RandomUtils;
import io.papermc.paper.registry.RegistryAccess;
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 1b65943c4..5a1107f96 100644
--- a/src/main/java/fr/openmc/core/registry/enchantments/CustomEnchantmentRegistry.java
+++ b/src/main/java/fr/openmc/core/registry/enchantments/CustomEnchantmentRegistry.java
@@ -2,13 +2,13 @@
import fr.openmc.core.OMCPlugin;
import fr.openmc.core.OMCRegistry;
-import fr.openmc.core.bootstrap.registries.KeyedRegistry;
-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.features.events.contents.dailyevents.contents.bloodynight.contents.enchantments.Vampirism;
import fr.openmc.core.features.events.contents.dailyevents.contents.goldenharvest.contents.enchantments.Plantation;
+import fr.openmc.core.lifecycle.registries.KeyedRegistry;
+import fr.openmc.core.lifecycle.registries.Registry;
import io.papermc.paper.plugin.bootstrap.BootstrapContext;
import io.papermc.paper.registry.data.EnchantmentRegistryEntry;
import io.papermc.paper.registry.event.RegistryComposeEvent;
diff --git a/src/main/java/fr/openmc/core/bootstrap/features/DisableFeatureException.java b/src/main/java/fr/openmc/core/registry/features/DisableFeatureException.java
similarity index 85%
rename from src/main/java/fr/openmc/core/bootstrap/features/DisableFeatureException.java
rename to src/main/java/fr/openmc/core/registry/features/DisableFeatureException.java
index 5226504b5..3dfba67d1 100644
--- a/src/main/java/fr/openmc/core/bootstrap/features/DisableFeatureException.java
+++ b/src/main/java/fr/openmc/core/registry/features/DisableFeatureException.java
@@ -1,4 +1,4 @@
-package fr.openmc.core.bootstrap.features;
+package fr.openmc.core.registry.features;
public class DisableFeatureException extends RuntimeException {
public DisableFeatureException(String message) {
diff --git a/src/main/java/fr/openmc/core/bootstrap/features/Feature.java b/src/main/java/fr/openmc/core/registry/features/Feature.java
similarity index 76%
rename from src/main/java/fr/openmc/core/bootstrap/features/Feature.java
rename to src/main/java/fr/openmc/core/registry/features/Feature.java
index eca286465..e76291509 100644
--- a/src/main/java/fr/openmc/core/bootstrap/features/Feature.java
+++ b/src/main/java/fr/openmc/core/registry/features/Feature.java
@@ -1,11 +1,14 @@
-package fr.openmc.core.bootstrap.features;
+package fr.openmc.core.registry.features;
import com.j256.ormlite.support.ConnectionSource;
import fr.openmc.core.CommandsManager;
import fr.openmc.core.OMCPlugin;
-import fr.openmc.core.bootstrap.features.types.*;
-import fr.openmc.core.bootstrap.integration.OMCLogger;
-import fr.openmc.core.bootstrap.listeners.ListenerFactory;
+import fr.openmc.core.lifecycle.integration.DatabaseManager;
+import fr.openmc.core.lifecycle.integration.OMCLogger;
+import fr.openmc.core.lifecycle.interfaces.HasCommands;
+import fr.openmc.core.lifecycle.interfaces.HasDatabase;
+import fr.openmc.core.lifecycle.interfaces.HasListeners;
+import fr.openmc.core.lifecycle.listeners.ListenerFactory;
import java.sql.SQLException;
@@ -20,17 +23,8 @@ public abstract class Feature {
* Lance l'initialisation avec des règles en fonction des interfaces mises (NotUnitTest, LoadIfEnable)
*/
public final void startInit() {
- // Condition d'initialisation (si feature ne doit pas être lancée dans les tests ou qu'elle nécessite un hook)
- if (this instanceof NotLoadInUnitTest && OMCPlugin.isUnitTestVersion()) {
- OMCLogger.errorFormatted("Feature " + this.getClass().getSimpleName() + " non initialisée dans les Unit Tests");
- return;
- }
- if (this instanceof LoadIfEnable> loadIfEnable && !loadIfEnable.shouldLoad()) {
- OMCLogger.errorFormatted("Feature " + this.getClass().getSimpleName() + " non initialisée car le hook associé n'est pas activé");
- return;
- }
-
try {
+ DatabaseManager.startFeatureDB(this);
init();
// Enregistre les listeners
@@ -67,7 +61,6 @@ public final void startInit() {
* @throws SQLException Si l'initialisation DB échoue
*/
public final void startDB(ConnectionSource connectionSource) throws SQLException {
- if (this instanceof NotLoadInUnitTest && OMCPlugin.isUnitTestVersion()) return;
if (this instanceof HasDatabase dbF) {
dbF.initDB(connectionSource);
}
@@ -78,7 +71,6 @@ public final void startDB(ConnectionSource connectionSource) throws SQLException
*/
public final void startSave() {
if (!initialize) return;
- if (this instanceof NotLoadInUnitTest && OMCPlugin.isUnitTestVersion()) return;
try {
save();
diff --git a/src/main/java/fr/openmc/core/registry/features/FeaturesRegistry.java b/src/main/java/fr/openmc/core/registry/features/FeaturesRegistry.java
new file mode 100644
index 000000000..39104546f
--- /dev/null
+++ b/src/main/java/fr/openmc/core/registry/features/FeaturesRegistry.java
@@ -0,0 +1,214 @@
+package fr.openmc.core.registry.features;
+
+import com.google.common.base.Supplier;
+import fr.openmc.api.cooldown.DynamicCooldownManager;
+import fr.openmc.core.OMCPlugin;
+import fr.openmc.core.OMCRegistry;
+import fr.openmc.core.commands.admin.freeze.FreezeManager;
+import fr.openmc.core.commands.utils.SpawnManager;
+import fr.openmc.core.features.adminshop.AdminShopManager;
+import fr.openmc.core.features.analytics.AnalyticsManager;
+import fr.openmc.core.features.animations.AnimationsManager;
+import fr.openmc.core.features.bits.BitsManager;
+import fr.openmc.core.features.chatanimations.ChatAnimationManager;
+import fr.openmc.core.features.city.CityManager;
+import fr.openmc.core.features.city.sub.mascots.MascotsManager;
+import fr.openmc.core.features.cube.multiblocks.MultiBlockManager;
+import fr.openmc.core.features.dimopener.DimensionOpenerManager;
+import fr.openmc.core.features.displays.TabList;
+import fr.openmc.core.features.displays.bossbar.BossbarManager;
+import fr.openmc.core.features.displays.bossbar.contents.HelpConfigManager;
+import fr.openmc.core.features.displays.holograms.HologramLoader;
+import fr.openmc.core.features.displays.scoreboards.ScoreboardManager;
+import fr.openmc.core.features.dream.DreamManager;
+import fr.openmc.core.features.economy.BankManager;
+import fr.openmc.core.features.economy.EconomyManager;
+import fr.openmc.core.features.economy.TransactionsManager;
+import fr.openmc.core.features.events.EventsManager;
+import fr.openmc.core.features.events.contents.dailyevents.DailyEventsManager;
+import fr.openmc.core.features.events.contents.halloween.managers.HalloweenManager;
+import fr.openmc.core.features.events.contents.weeklyevents.WeeklyEventsManager;
+import fr.openmc.core.features.events.contents.weeklyevents.contents.contest.managers.ContestManager;
+import fr.openmc.core.features.friend.FriendManager;
+import fr.openmc.core.features.homes.HomesManager;
+import fr.openmc.core.features.homes.icons.HomeIconCacheManager;
+import fr.openmc.core.features.itemsadder.elevator.ElevatorManager;
+import fr.openmc.core.features.leaderboards.LeaderboardManager;
+import fr.openmc.core.features.mailboxes.MailboxManager;
+import fr.openmc.core.features.mainmenu.MainMenu;
+import fr.openmc.core.features.milestones.MilestonesManager;
+import fr.openmc.core.features.privatemessage.PrivateMessageManager;
+import fr.openmc.core.features.privatemessage.SocialSpyManager;
+import fr.openmc.core.features.profile.ProfileManager;
+import fr.openmc.core.features.quests.QuestProgressSaveManager;
+import fr.openmc.core.features.quests.QuestsManager;
+import fr.openmc.core.features.settings.PlayerSettingsManager;
+import fr.openmc.core.features.shops.managers.ShopManager;
+import fr.openmc.core.features.tickets.TicketManager;
+import fr.openmc.core.features.toor.DiscordLinkManager;
+import fr.openmc.core.features.tpa.TPAManager;
+import fr.openmc.core.features.updates.UpdateManager;
+import fr.openmc.core.lifecycle.registries.KeyedRegistry;
+import fr.openmc.core.lifecycle.registries.Registry;
+import fr.openmc.core.registry.features.loading.FeatureEntry;
+import fr.openmc.core.registry.features.loading.FeatureFlag;
+import fr.openmc.core.registry.features.loading.FeatureLoadingType;
+import fr.openmc.core.utils.text.MotdUtils;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Optional;
+
+public class FeaturesRegistry extends Registry
+ implements KeyedRegistry {
+
+ // * Flags pré enregistrés
+ public final FeatureFlag NOT_IN_UNIT_TEST = new FeatureFlag.NotInUnitTest();
+ public final FeatureFlag NEED_FANCY_NPC = new FeatureFlag.NeedApi(OMCRegistry.HOOKS.FANCY_NPCS::isEnable, "FancyNPC");
+ public final FeatureFlag NEED_LUCK_PERMS = new FeatureFlag.NeedApi(OMCRegistry.HOOKS.LUCK_PERMS::isEnable, "LuckPerms");
+ public final FeatureFlag NEED_ITEMS_ADDER = new FeatureFlag.NeedApi(OMCRegistry.HOOKS.ITEMS_ADDER::isEnable, "ItemsAdder");
+ public final FeatureFlag NEED_PAPI = new FeatureFlag.NeedApi(OMCRegistry.HOOKS.PAPI::isEnable, "PlaceHolderAPI");
+ public final FeatureFlag NEED_PROTOCOL_LIB = new FeatureFlag.NeedApi(OMCRegistry.HOOKS.PROTOCOL_LIB::isEnable, "ProtocolLib");
+ public final FeatureFlag NEED_WORLD_GUARD = new FeatureFlag.NeedApi(OMCRegistry.HOOKS.WORLD_GUARD::isEnable, "WorldGuard");
+
+ private final List> declarations = new ArrayList<>();
+
+ public final FeatureEntry TICKETS = declare(FeatureLoadingType.RUNTIME,
+ () -> new TicketManager(new File(OMCPlugin.getInstance().getDataFolder(), "data/stats")));
+
+ public final FeatureEntry PRIVATE_SPY = declare(FeatureLoadingType.RUNTIME,
+ PrivateMessageManager::new);
+ public final FeatureEntry SOCIAL_SPY = declare(FeatureLoadingType.RUNTIME,
+ SocialSpyManager::new);
+ public final FeatureEntry SPAWN = declare(FeatureLoadingType.RUNTIME,
+ SpawnManager::new);
+ public final FeatureEntry UPDATE = declare(FeatureLoadingType.RUNTIME,
+ UpdateManager::new);
+ public final FeatureEntry ECONOMY = declare(FeatureLoadingType.RUNTIME,
+ EconomyManager::new);
+ public final FeatureEntry BANK = declare(FeatureLoadingType.RUNTIME,
+ BankManager::new);
+ public final FeatureEntry BITS = declare(FeatureLoadingType.RUNTIME,
+ BitsManager::new);
+ public final FeatureEntry SCOREBOARD = declare(FeatureLoadingType.RUNTIME,
+ () -> new ScoreboardManager(), NOT_IN_UNIT_TEST, NEED_LUCK_PERMS);
+ public final FeatureEntry HOMES = declare(FeatureLoadingType.RUNTIME,
+ HomesManager::new);
+ public final FeatureEntry TPA = declare(FeatureLoadingType.RUNTIME,
+ TPAManager::new);
+ public final FeatureEntry FREEZE = declare(FeatureLoadingType.RUNTIME,
+ FreezeManager::new);
+ public final FeatureEntry TRANSACTIONS = declare(FeatureLoadingType.RUNTIME,
+ TransactionsManager::new);
+ public final FeatureEntry ANALYTICS = declare(FeatureLoadingType.RUNTIME,
+ AnalyticsManager::new);
+ public final FeatureEntry FRIENDS = declare(FeatureLoadingType.RUNTIME,
+ FriendManager::new);
+ public final FeatureEntry TAB = declare(FeatureLoadingType.RUNTIME,
+ () -> new TabList(), NOT_IN_UNIT_TEST, NEED_PROTOCOL_LIB);
+ public final FeatureEntry ADMIN_SHOP = declare(FeatureLoadingType.RUNTIME,
+ AdminShopManager::new);
+ public final FeatureEntry HELP_CONFIG = declare(FeatureLoadingType.RUNTIME,
+ HelpConfigManager::new);
+ public final FeatureEntry ANIMATIONS = declare(FeatureLoadingType.RUNTIME,
+ () -> new AnimationsManager(), NOT_IN_UNIT_TEST, NEED_ITEMS_ADDER);
+ public final FeatureEntry HALLOWEEN = declare(FeatureLoadingType.RUNTIME,
+ HalloweenManager::new);
+ public final FeatureEntry QUEST_PROGRESS = declare(FeatureLoadingType.RUNTIME,
+ QuestProgressSaveManager::new);
+ public final FeatureEntry MOTD = declare(FeatureLoadingType.RUNTIME,
+ MotdUtils::new);
+ public final FeatureEntry MASCOTS = declare(FeatureLoadingType.RUNTIME,
+ MascotsManager::new);
+ public final FeatureEntry PLAYER_SETTINGS = declare(FeatureLoadingType.RUNTIME,
+ PlayerSettingsManager::new);
+ public final FeatureEntry MAILBOX = declare(FeatureLoadingType.RUNTIME,
+ MailboxManager::new);
+ public final FeatureEntry DISCORD_LINK = declare(FeatureLoadingType.RUNTIME,
+ DiscordLinkManager::new);
+ public final FeatureEntry ELEVATOR = declare(FeatureLoadingType.RUNTIME,
+ () -> new ElevatorManager(), NEED_ITEMS_ADDER);
+ public final FeatureEntry PROFILE = declare(FeatureLoadingType.AFTER_IA,
+ ProfileManager::new);
+ public final FeatureEntry QUESTS = declare(FeatureLoadingType.AFTER_IA,
+ QuestsManager::new);
+ public final FeatureEntry CITY = declare(FeatureLoadingType.AFTER_IA,
+ CityManager::new);
+ public final FeatureEntry DYNAMIC_COOLDOWN = declare(FeatureLoadingType.AFTER_IA,
+ DynamicCooldownManager::new);
+ public final FeatureEntry CONTEST = declare(FeatureLoadingType.AFTER_IA,
+ ContestManager::new);
+ public final FeatureEntry WEEKLY_EVENTS = declare(FeatureLoadingType.AFTER_IA,
+ WeeklyEventsManager::new);
+ public final FeatureEntry DAILY_EVENTS = declare(FeatureLoadingType.AFTER_IA,
+ DailyEventsManager::new);
+ public final FeatureEntry CHAT_ANIMATIONS = declare(FeatureLoadingType.AFTER_IA,
+ ChatAnimationManager::new);
+ public final FeatureEntry EVENTS = declare(FeatureLoadingType.AFTER_IA,
+ EventsManager::new);
+ public final FeatureEntry DREAM = declare(FeatureLoadingType.AFTER_IA,
+ DreamManager::new);
+ public final FeatureEntry MULTIBLOCKS = declare(FeatureLoadingType.AFTER_IA,
+ () -> new MultiBlockManager(), NOT_IN_UNIT_TEST);
+ public final FeatureEntry MILESTONES = declare(FeatureLoadingType.AFTER_IA,
+ MilestonesManager::new);
+ public final FeatureEntry LEADERBOARD = declare(FeatureLoadingType.AFTER_IA,
+ () -> new LeaderboardManager(), NOT_IN_UNIT_TEST);
+ public final FeatureEntry MAIN_MENU = declare(FeatureLoadingType.AFTER_IA,
+ () -> new MainMenu(), NOT_IN_UNIT_TEST, NEED_PROTOCOL_LIB);
+ public final FeatureEntry HOLOGRAM_LOADER = declare(FeatureLoadingType.AFTER_IA,
+ () -> new HologramLoader(), NOT_IN_UNIT_TEST);
+ public final FeatureEntry BOSSBAR = declare(FeatureLoadingType.AFTER_IA,
+ BossbarManager::new);
+ public final FeatureEntry SHOP = declare(FeatureLoadingType.AFTER_IA,
+ ShopManager::new);
+ public final FeatureEntry HOME_ICON_CACHE = declare(FeatureLoadingType.AFTER_IA,
+ HomeIconCacheManager::new);
+ public final FeatureEntry DIMENSION_OPENER = declare(FeatureLoadingType.AFTER_IA,
+ DimensionOpenerManager::new);
+
+ private FeatureEntry declare(FeatureLoadingType type, Supplier supplier, FeatureFlag... flags) {
+ FeatureEntry entry = new FeatureEntry<>(supplier, type, flags);
+ declarations.add(entry);
+ return entry;
+ }
+
+ @Override
+ public void init() {
+ load(FeatureLoadingType.RUNTIME);
+ }
+
+ @Override
+ public void postInit() {
+ load(FeatureLoadingType.AFTER_IA);
+ }
+
+ @Override
+ public void stop() {
+ for (Feature feature : values()) {
+ feature.startSave();
+ }
+ }
+
+ public Optional register(FeatureEntry> entry) {
+ if (!entry.shouldLoad()) return Optional.empty();
+
+ Feature feature = entry.create();
+ feature.startInit();
+ register(key(feature), feature);
+ return Optional.of(feature);
+ }
+
+ public void load(FeatureLoadingType loadingType) {
+ for (FeatureEntry> entry : declarations) {
+ if (entry.getLoadingType() != loadingType) continue;
+ register(entry);
+ }
+ }
+
+ @Override
+ public String key(Feature registryObject) {
+ return registryObject.getClass().getSimpleName();
+ }
+}
diff --git a/src/main/java/fr/openmc/core/bootstrap/features/annotations/Credit.java b/src/main/java/fr/openmc/core/registry/features/annotations/Credit.java
similarity index 86%
rename from src/main/java/fr/openmc/core/bootstrap/features/annotations/Credit.java
rename to src/main/java/fr/openmc/core/registry/features/annotations/Credit.java
index 002798d9a..11d2d7ce2 100644
--- a/src/main/java/fr/openmc/core/bootstrap/features/annotations/Credit.java
+++ b/src/main/java/fr/openmc/core/registry/features/annotations/Credit.java
@@ -1,4 +1,4 @@
-package fr.openmc.core.bootstrap.features.annotations;
+package fr.openmc.core.registry.features.annotations;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
diff --git a/src/main/java/fr/openmc/core/registry/features/loading/FeatureEntry.java b/src/main/java/fr/openmc/core/registry/features/loading/FeatureEntry.java
new file mode 100644
index 000000000..0844fd3ea
--- /dev/null
+++ b/src/main/java/fr/openmc/core/registry/features/loading/FeatureEntry.java
@@ -0,0 +1,58 @@
+package fr.openmc.core.registry.features.loading;
+
+import com.google.common.base.Supplier;
+import fr.openmc.core.OMCPlugin;
+import fr.openmc.core.lifecycle.integration.OMCLogger;
+import fr.openmc.core.registry.features.Feature;
+import lombok.Getter;
+
+import java.util.Set;
+
+public class FeatureEntry {
+ private final Supplier supplier;
+ @Getter
+ private final FeatureLoadingType loadingType;
+ private final Set flags;
+ private F instance;
+
+ public FeatureEntry(Supplier supplier, FeatureLoadingType loadingType, FeatureFlag... flags) {
+ this.supplier = supplier;
+ this.loadingType = loadingType;
+ this.flags = Set.of(flags);
+ }
+
+ public static FeatureEntry of(FeatureLoadingType loadingType, Supplier supplier, FeatureFlag... flags) {
+ return new FeatureEntry<>(supplier, loadingType, flags);
+ }
+
+ public F create() {
+ if (instance == null) {
+ instance = supplier.get();
+ }
+ return instance;
+ }
+
+ public boolean shouldLoad() {
+ for (FeatureFlag flag : flags) {
+ if (flag == null) {
+ OMCLogger.errorFormatted("Un FeatureFlag est nul dans une feature");
+ return false;
+ }
+
+ return !(switch (flag) {
+ case FeatureFlag.NotInUnitTest _ -> OMCPlugin.isUnitTestVersion();
+ case FeatureFlag.NeedApi needApi -> !needApi.isEnabled().get();
+ default -> throw new IllegalStateException("FeatureFlag non implémenter dans FeatureEntry#shouldLoad() : " + flag);
+ });
+ }
+ return true;
+ }
+
+ public F get() {
+ if (instance == null)
+ throw new IllegalStateException("La feature n'est pas encore crée");
+ return instance;
+ }
+
+ public boolean has(FeatureFlag flag) { return flags.contains(flag); }
+}
diff --git a/src/main/java/fr/openmc/core/registry/features/loading/FeatureFlag.java b/src/main/java/fr/openmc/core/registry/features/loading/FeatureFlag.java
new file mode 100644
index 000000000..0e2a605fe
--- /dev/null
+++ b/src/main/java/fr/openmc/core/registry/features/loading/FeatureFlag.java
@@ -0,0 +1,11 @@
+package fr.openmc.core.registry.features.loading;
+
+import java.util.function.Supplier;
+
+public interface FeatureFlag {
+
+ record NotInUnitTest() implements FeatureFlag {}
+
+ record NeedApi(Supplier isEnabled, String label) implements FeatureFlag {}
+
+}
diff --git a/src/main/java/fr/openmc/core/bootstrap/features/FeatureLoadingType.java b/src/main/java/fr/openmc/core/registry/features/loading/FeatureLoadingType.java
similarity index 55%
rename from src/main/java/fr/openmc/core/bootstrap/features/FeatureLoadingType.java
rename to src/main/java/fr/openmc/core/registry/features/loading/FeatureLoadingType.java
index 8334d55a6..a77eb0b2a 100644
--- a/src/main/java/fr/openmc/core/bootstrap/features/FeatureLoadingType.java
+++ b/src/main/java/fr/openmc/core/registry/features/loading/FeatureLoadingType.java
@@ -1,4 +1,4 @@
-package fr.openmc.core.bootstrap.features;
+package fr.openmc.core.registry.features.loading;
public enum FeatureLoadingType {
RUNTIME,
diff --git a/src/main/java/fr/openmc/core/bootstrap/hooks/ApiHook.java b/src/main/java/fr/openmc/core/registry/hooks/ApiHook.java
similarity index 94%
rename from src/main/java/fr/openmc/core/bootstrap/hooks/ApiHook.java
rename to src/main/java/fr/openmc/core/registry/hooks/ApiHook.java
index 657896ab8..cba01a940 100644
--- a/src/main/java/fr/openmc/core/bootstrap/hooks/ApiHook.java
+++ b/src/main/java/fr/openmc/core/registry/hooks/ApiHook.java
@@ -1,4 +1,4 @@
-package fr.openmc.core.bootstrap.hooks;
+package fr.openmc.core.registry.hooks;
import fr.openmc.core.OMCPlugin;
diff --git a/src/main/java/fr/openmc/core/bootstrap/hooks/Hooks.java b/src/main/java/fr/openmc/core/registry/hooks/Hooks.java
similarity index 94%
rename from src/main/java/fr/openmc/core/bootstrap/hooks/Hooks.java
rename to src/main/java/fr/openmc/core/registry/hooks/Hooks.java
index 9d99c88bf..d6a1a9ca0 100644
--- a/src/main/java/fr/openmc/core/bootstrap/hooks/Hooks.java
+++ b/src/main/java/fr/openmc/core/registry/hooks/Hooks.java
@@ -1,10 +1,10 @@
-package fr.openmc.core.bootstrap.hooks;
+package fr.openmc.core.registry.hooks;
import com.j256.ormlite.support.ConnectionSource;
import fr.openmc.core.OMCPlugin;
-import fr.openmc.core.bootstrap.features.types.HasDatabase;
-import fr.openmc.core.bootstrap.features.types.NotLoadInUnitTest;
-import fr.openmc.core.bootstrap.integration.OMCLogger;
+import fr.openmc.core.lifecycle.integration.OMCLogger;
+import fr.openmc.core.lifecycle.interfaces.HasDatabase;
+import fr.openmc.core.lifecycle.interfaces.NotLoadInUnitTest;
import org.bukkit.plugin.PluginManager;
import java.sql.SQLException;
diff --git a/src/main/java/fr/openmc/core/registry/hooks/HooksRegistry.java b/src/main/java/fr/openmc/core/registry/hooks/HooksRegistry.java
new file mode 100644
index 000000000..7fcbc35a3
--- /dev/null
+++ b/src/main/java/fr/openmc/core/registry/hooks/HooksRegistry.java
@@ -0,0 +1,40 @@
+package fr.openmc.core.registry.hooks;
+
+import fr.openmc.core.hooks.*;
+import fr.openmc.core.hooks.github.GitHubHook;
+import fr.openmc.core.hooks.itemsadder.ItemsAdderHook;
+import fr.openmc.core.lifecycle.integration.DatabaseManager;
+import fr.openmc.core.lifecycle.registries.KeyedRegistry;
+import fr.openmc.core.lifecycle.registries.Registry;
+
+public class HooksRegistry extends Registry
+ implements KeyedRegistry {
+
+ public final ProtocolLibHook PROTOCOL_LIB = register(new ProtocolLibHook());
+ public final PapiHook PAPI = register(new PapiHook());
+ public final LuckPermsHook LUCK_PERMS = register(new LuckPermsHook());
+ public final WorldGuardHook WORLD_GUARD = register(new WorldGuardHook());
+ public final ItemsAdderHook ITEMS_ADDER = register(new ItemsAdderHook());
+ public final FancyNpcsHook FANCY_NPCS = register(new FancyNpcsHook());
+ public final GitHubHook GITHUB = register(new GitHubHook());
+
+ @Override
+ public void init() {
+ for (Hooks hook : values()) {
+ DatabaseManager.startHookDB(hook);
+ hook.startInit();
+ }
+ }
+
+ @Override
+ public void stop() {
+ for (Hooks hook : values()) {
+ hook.startSave();
+ }
+ }
+
+ @Override
+ public String key(Hooks registryObject) {
+ return registryObject.getClass().getSimpleName();
+ }
+}
diff --git a/src/main/java/fr/openmc/core/bootstrap/hooks/HttpsHook.java b/src/main/java/fr/openmc/core/registry/hooks/HttpsHook.java
similarity index 74%
rename from src/main/java/fr/openmc/core/bootstrap/hooks/HttpsHook.java
rename to src/main/java/fr/openmc/core/registry/hooks/HttpsHook.java
index 14a589e2b..784eff221 100644
--- a/src/main/java/fr/openmc/core/bootstrap/hooks/HttpsHook.java
+++ b/src/main/java/fr/openmc/core/registry/hooks/HttpsHook.java
@@ -1,9 +1,9 @@
-package fr.openmc.core.bootstrap.hooks;
+package fr.openmc.core.registry.hooks;
public abstract class HttpsHook extends Hooks {
abstract public String getName();
- public static boolean isEnable() {
+ public boolean isEnable() {
return Hooks.isEnabled(HttpsHook.class);
}
diff --git a/src/main/java/fr/openmc/core/registry/items/CustomItem.java b/src/main/java/fr/openmc/core/registry/items/CustomItem.java
index 2f2604927..b11e9db61 100644
--- a/src/main/java/fr/openmc/core/registry/items/CustomItem.java
+++ b/src/main/java/fr/openmc/core/registry/items/CustomItem.java
@@ -3,7 +3,6 @@
import dev.lone.itemsadder.api.CustomBlock;
import dev.lone.itemsadder.api.CustomStack;
import fr.openmc.core.OMCRegistry;
-import fr.openmc.core.hooks.itemsadder.ItemsAdderHook;
import fr.openmc.core.utils.bukkit.ItemUtils;
import lombok.Getter;
import org.bukkit.inventory.ItemStack;
@@ -76,7 +75,7 @@ public boolean equals(Object object) {
*/
public ItemStack getBest() {
ItemStack item;
- if (!ItemsAdderHook.isEnable() || getItemsAdder() == null) {
+ if (!OMCRegistry.HOOKS.ITEMS_ADDER.isEnable() || getItemsAdder() == null) {
item = getVanilla();
} else {
item = getItemsAdder();
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 597c02ab5..07c481475 100644
--- a/src/main/java/fr/openmc/core/registry/items/CustomItemRegistry.java
+++ b/src/main/java/fr/openmc/core/registry/items/CustomItemRegistry.java
@@ -3,10 +3,6 @@
import dev.lone.itemsadder.api.CustomBlock;
import dev.lone.itemsadder.api.CustomStack;
import fr.openmc.core.CommandsManager;
-import fr.openmc.core.bootstrap.features.types.HasListeners;
-import fr.openmc.core.bootstrap.listeners.ListenerFactory;
-import fr.openmc.core.bootstrap.registries.KeyedRegistry;
-import fr.openmc.core.bootstrap.registries.Registry;
import fr.openmc.core.features.bits.contents.items.KitchenBox;
import fr.openmc.core.features.bits.contents.items.MedievalBox;
import fr.openmc.core.features.bits.contents.items.ModernBox;
@@ -18,6 +14,10 @@
import fr.openmc.core.features.itemsadder.elevator.ElevatorBlock;
import fr.openmc.core.features.itemsadder.elevator.ElevatorColor;
import fr.openmc.core.hooks.itemsadder.ItemsAdderHook;
+import fr.openmc.core.lifecycle.interfaces.HasListeners;
+import fr.openmc.core.lifecycle.listeners.ListenerFactory;
+import fr.openmc.core.lifecycle.registries.KeyedRegistry;
+import fr.openmc.core.lifecycle.registries.Registry;
import fr.openmc.core.registry.items.contents.AywenCap;
import fr.openmc.core.registry.items.contents.Hammer;
import fr.openmc.core.registry.items.listeners.BlockBreakListener;
diff --git a/src/main/java/fr/openmc/core/registry/lootboxes/CustomLootboxRegistry.java b/src/main/java/fr/openmc/core/registry/lootboxes/CustomLootboxRegistry.java
index f41a75b20..59cd96935 100644
--- a/src/main/java/fr/openmc/core/registry/lootboxes/CustomLootboxRegistry.java
+++ b/src/main/java/fr/openmc/core/registry/lootboxes/CustomLootboxRegistry.java
@@ -1,9 +1,5 @@
package fr.openmc.core.registry.lootboxes;
-import fr.openmc.core.bootstrap.features.types.HasListeners;
-import fr.openmc.core.bootstrap.listeners.ListenerFactory;
-import fr.openmc.core.bootstrap.registries.KeyedRegistry;
-import fr.openmc.core.bootstrap.registries.Registry;
import fr.openmc.core.features.bits.contents.lootboxes.KitchenLootbox;
import fr.openmc.core.features.bits.contents.lootboxes.MedievalLootbox;
import fr.openmc.core.features.bits.contents.lootboxes.ModernLootbox;
@@ -12,6 +8,10 @@
import fr.openmc.core.features.events.contents.dailyevents.contents.miraculousfishing.contents.lootboxes.FishingFurnitureLootbox;
import fr.openmc.core.features.events.contents.dailyevents.contents.miraculousfishing.contents.lootboxes.LegendaryFishingTreasureLootbox;
import fr.openmc.core.features.events.contents.dailyevents.contents.miraculousfishing.contents.lootboxes.RareFishingTreasureLootbox;
+import fr.openmc.core.lifecycle.interfaces.HasListeners;
+import fr.openmc.core.lifecycle.listeners.ListenerFactory;
+import fr.openmc.core.lifecycle.registries.KeyedRegistry;
+import fr.openmc.core.lifecycle.registries.Registry;
import fr.openmc.core.registry.lootboxes.contents.MachineBallLootbox;
import fr.openmc.core.registry.lootboxes.listener.DesactivateFireworkDamageListener;
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 5cc2abe7c..5f6724809 100644
--- a/src/main/java/fr/openmc/core/registry/loottable/CustomLootTableRegistry.java
+++ b/src/main/java/fr/openmc/core/registry/loottable/CustomLootTableRegistry.java
@@ -1,7 +1,5 @@
package fr.openmc.core.registry.loottable;
-import fr.openmc.core.bootstrap.registries.KeyedRegistry;
-import fr.openmc.core.bootstrap.registries.Registry;
import fr.openmc.core.features.bits.contents.loottables.KitchenLootTable;
import fr.openmc.core.features.bits.contents.loottables.MedievalLootTable;
import fr.openmc.core.features.bits.contents.loottables.ModernLootTable;
@@ -21,6 +19,8 @@
import fr.openmc.core.features.events.contents.dailyevents.contents.miraculousfishing.contents.loottable.lootbox.FishingFurnitureLootTable;
import fr.openmc.core.features.events.contents.dailyevents.contents.miraculousfishing.contents.loottable.lootbox.LegendaryFishingTreasureLootTable;
import fr.openmc.core.features.events.contents.dailyevents.contents.miraculousfishing.contents.loottable.lootbox.RareFishingTreasureLootTable;
+import fr.openmc.core.lifecycle.registries.KeyedRegistry;
+import fr.openmc.core.lifecycle.registries.Registry;
import fr.openmc.core.registry.loottable.contents.MachineBallLootTable;
public class CustomLootTableRegistry extends Registry implements KeyedRegistry {
diff --git a/src/main/java/fr/openmc/core/registry/mobs/CustomMobRegistry.java b/src/main/java/fr/openmc/core/registry/mobs/CustomMobRegistry.java
index e829f95ff..7194656c5 100644
--- a/src/main/java/fr/openmc/core/registry/mobs/CustomMobRegistry.java
+++ b/src/main/java/fr/openmc/core/registry/mobs/CustomMobRegistry.java
@@ -1,10 +1,6 @@
package fr.openmc.core.registry.mobs;
import fr.openmc.core.OMCPlugin;
-import fr.openmc.core.bootstrap.features.types.HasListeners;
-import fr.openmc.core.bootstrap.listeners.ListenerFactory;
-import fr.openmc.core.bootstrap.registries.KeyedRegistry;
-import fr.openmc.core.bootstrap.registries.Registry;
import fr.openmc.core.features.events.contents.dailyevents.contents.bloodynight.contents.mobs.bat.ExplosiveVampireBat;
import fr.openmc.core.features.events.contents.dailyevents.contents.bloodynight.contents.mobs.bat.LevitationVampireBat;
import fr.openmc.core.features.events.contents.dailyevents.contents.bloodynight.contents.mobs.bat.PoisonVampireBat;
@@ -16,6 +12,10 @@
import fr.openmc.core.features.events.contents.dailyevents.contents.bloodynight.contents.mobs.vampire.VampireSlave;
import fr.openmc.core.features.events.contents.dailyevents.contents.miraculousfishing.contents.mobs.*;
import fr.openmc.core.features.events.contents.dailyevents.contents.miraculousfishing.contents.mobs.kraken.Kraken;
+import fr.openmc.core.lifecycle.interfaces.HasListeners;
+import fr.openmc.core.lifecycle.listeners.ListenerFactory;
+import fr.openmc.core.lifecycle.registries.KeyedRegistry;
+import fr.openmc.core.lifecycle.registries.Registry;
import fr.openmc.core.registry.mobs.listeners.CustomMobBossbarListener;
import fr.openmc.core.registry.mobs.listeners.CustomMobDeathListener;
import fr.openmc.core.registry.mobs.listeners.CustomMobLoadListener;
diff --git a/src/main/java/fr/openmc/core/utils/FilesUtils.java b/src/main/java/fr/openmc/core/utils/FilesUtils.java
index 91196c17a..eca22ff90 100644
--- a/src/main/java/fr/openmc/core/utils/FilesUtils.java
+++ b/src/main/java/fr/openmc/core/utils/FilesUtils.java
@@ -1,7 +1,7 @@
package fr.openmc.core.utils;
import fr.openmc.core.OMCBootstrap;
-import fr.openmc.core.bootstrap.integration.OMCLogger;
+import fr.openmc.core.lifecycle.integration.OMCLogger;
import java.io.File;
import java.io.IOException;
diff --git a/src/main/java/fr/openmc/core/utils/nms/PlayerBiomeNMS.java b/src/main/java/fr/openmc/core/utils/nms/PlayerBiomeNMS.java
index 46df5530f..77ab1ca11 100644
--- a/src/main/java/fr/openmc/core/utils/nms/PlayerBiomeNMS.java
+++ b/src/main/java/fr/openmc/core/utils/nms/PlayerBiomeNMS.java
@@ -1,6 +1,6 @@
package fr.openmc.core.utils.nms;
-import fr.openmc.core.bootstrap.integration.OMCLogger;
+import fr.openmc.core.lifecycle.integration.OMCLogger;
import net.minecraft.core.Holder;
import net.minecraft.core.Registry;
import net.minecraft.core.registries.Registries;
diff --git a/src/main/java/fr/openmc/core/utils/nms/entity/EntityGlowNMS.java b/src/main/java/fr/openmc/core/utils/nms/entity/EntityGlowNMS.java
index 67431b012..5ddd79ff7 100644
--- a/src/main/java/fr/openmc/core/utils/nms/entity/EntityGlowNMS.java
+++ b/src/main/java/fr/openmc/core/utils/nms/entity/EntityGlowNMS.java
@@ -1,6 +1,6 @@
package fr.openmc.core.utils.nms.entity;
-import fr.openmc.core.bootstrap.features.types.NotLoadInUnitTest;
+import fr.openmc.core.lifecycle.interfaces.NotLoadInUnitTest;
import net.minecraft.network.protocol.game.ClientboundSetPlayerTeamPacket;
import net.minecraft.world.scores.PlayerTeam;
import net.minecraft.world.scores.Scoreboard;
diff --git a/src/main/java/fr/openmc/core/utils/text/InputUtils.java b/src/main/java/fr/openmc/core/utils/text/InputUtils.java
index 0ea922c62..d77339435 100644
--- a/src/main/java/fr/openmc/core/utils/text/InputUtils.java
+++ b/src/main/java/fr/openmc/core/utils/text/InputUtils.java
@@ -1,7 +1,7 @@
package fr.openmc.core.utils.text;
+import fr.openmc.core.OMCRegistry;
import fr.openmc.core.features.city.City;
-import fr.openmc.core.features.city.CityManager;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.TextComponent;
import org.bukkit.Bukkit;
@@ -82,7 +82,7 @@ public static boolean isInputCityName(String input) {
return false;
}
- for (City city : CityManager.getCities()) {
+ for (City city : OMCRegistry.FEATURES.CITY.get().getCities()) {
String testCityName = city.getName();
if (testCityName.equalsIgnoreCase(input)) {
return false;
diff --git a/src/main/java/fr/openmc/core/utils/text/MotdUtils.java b/src/main/java/fr/openmc/core/utils/text/MotdUtils.java
index 91493718b..208954e52 100644
--- a/src/main/java/fr/openmc/core/utils/text/MotdUtils.java
+++ b/src/main/java/fr/openmc/core/utils/text/MotdUtils.java
@@ -1,7 +1,7 @@
package fr.openmc.core.utils.text;
import fr.openmc.core.OMCPlugin;
-import fr.openmc.core.bootstrap.features.Feature;
+import fr.openmc.core.registry.features.Feature;
import net.kyori.adventure.text.Component;
import org.bukkit.Bukkit;
import org.bukkit.configuration.file.YamlConfiguration;
diff --git a/src/main/java/fr/openmc/core/utils/text/messages/TranslationManager.java b/src/main/java/fr/openmc/core/utils/text/messages/TranslationManager.java
index fbc199382..6a6ebb1e0 100644
--- a/src/main/java/fr/openmc/core/utils/text/messages/TranslationManager.java
+++ b/src/main/java/fr/openmc/core/utils/text/messages/TranslationManager.java
@@ -3,8 +3,8 @@
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonObject;
-import fr.openmc.core.bootstrap.integration.OMCLogger;
-import fr.openmc.core.bootstrap.integration.ResourcePacksGenerator;
+import fr.openmc.core.lifecycle.integration.OMCLogger;
+import fr.openmc.core.lifecycle.integration.ResourcePacksGenerator;
import fr.openmc.core.utils.text.ComponentUtils;
import fr.openmc.core.utils.types.MultiResourceBundle;
import io.papermc.paper.plugin.bootstrap.BootstrapContext;